From f30c06d506a6295446490b6b03f77677b233ce0e Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 26 May 2016 16:46:39 +1000 Subject: [PATCH 01/73] rethink evaluation and plotly object representation model --- DESCRIPTION | 5 +- NAMESPACE | 27 +- NEWS | 20 + R/add.R | 61 +++ R/export.R | 32 ++ R/figure.R | 2 +- R/ggplotly.R | 14 +- R/helpers.R | 66 +++ R/imports.R | 4 +- R/layout.R | 66 +++ R/plotly.R | 462 ++---------------- R/plotly_POST.R | 2 +- R/plotly_build.R | 158 ++++++ R/print.R | 64 +-- R/process.R | 5 +- R/shiny.R | 2 - R/subplots.R | 4 +- R/sysdata.rda | Bin 0 -> 202 bytes R/utils.R | 116 ++--- .../lib/plotlyjs/plotly-latest.min.js | 62 +-- inst/htmlwidgets/plotly.js | 4 +- inst/htmlwidgets/plotly.yaml | 2 +- inst/plotlyjs.R | 9 +- man/add_trace.Rd | 9 +- man/as.widget.Rd | 10 +- man/config.Rd | 4 +- man/export.Rd | 25 + man/get_plot.Rd | 19 - man/knit_print.plotly_built.Rd | 19 - ....figure.Rd => knit_print.plotly_figure.Rd} | 6 +- man/knit_print.plotly_hash.Rd | 19 - man/last_plot.Rd | 18 - man/layout.Rd | 10 +- man/plot_ly.Rd | 32 +- man/plotly_build.Rd | 18 +- man/plotly_empty.Rd | 2 +- man/plotly_spec.Rd | 24 + man/print.plotly_built.Rd | 17 - ...print.figure.Rd => print.plotly_figure.Rd} | 6 +- man/print.plotly_hash.Rd | 17 - man/style.Rd | 6 +- man/toWebGL.Rd | 25 + 42 files changed, 697 insertions(+), 776 deletions(-) create mode 100644 R/add.R create mode 100644 R/export.R create mode 100644 R/helpers.R create mode 100644 R/layout.R create mode 100644 R/plotly_build.R create mode 100644 R/sysdata.rda create mode 100644 man/export.Rd delete mode 100644 man/get_plot.Rd delete mode 100644 man/knit_print.plotly_built.Rd rename man/{knit_print.figure.Rd => knit_print.plotly_figure.Rd} (79%) delete mode 100644 man/knit_print.plotly_hash.Rd delete mode 100644 man/last_plot.Rd create mode 100644 man/plotly_spec.Rd delete mode 100644 man/print.plotly_built.Rd rename man/{print.figure.Rd => print.plotly_figure.Rd} (75%) delete mode 100644 man/print.plotly_hash.Rd create mode 100644 man/toWebGL.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 0f00783085..c328c1bd7c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,7 +31,7 @@ Imports: base64enc, htmlwidgets, tidyr, - hexbin + hexbin, Suggests: dplyr, maps, @@ -47,7 +47,8 @@ Suggests: RColorBrewer, Rserve, RSclient, - broom + broom, + webshot LazyData: true VignetteBuilder: knitr RoxygenNote: 5.0.1 diff --git a/NAMESPACE b/NAMESPACE index 0df6ffa82c..1322fb13ae 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,14 +13,11 @@ S3method(geom2trace,GeomTile) S3method(geom2trace,default) S3method(ggplotly,ggmatrix) S3method(ggplotly,ggplot) -S3method(plotly_build,default) +S3method(layout,matrix) +S3method(layout,plotly) S3method(plotly_build,gg) -S3method(plotly_build,plotly_built) -S3method(plotly_build,plotly_hash) -S3method(plotly_build,plotly_subplot) -S3method(print,figure) -S3method(print,plotly_built) -S3method(print,plotly_hash) +S3method(plotly_build,plotly) +S3method(print,plotly_figure) S3method(to_basic,GeomAbline) S3method(to_basic,GeomArea) S3method(to_basic,GeomBoxplot) @@ -47,19 +44,20 @@ S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) S3method(to_basic,default) export("%>%") +export(add_lines) +export(add_points) +export(add_text) export(add_trace) export(as.widget) export(config) export(embed_notebook) export(event_data) +export(export) export(geom2trace) export(get_figure) export(gg2list) export(ggplotly) -export(knit_print.figure) -export(knit_print.plotly_built) -export(knit_print.plotly_hash) -export(last_plot) +export(knit_print.plotly_figure) export(layout) export(offline) export(plot_ly) @@ -69,16 +67,20 @@ export(plotly_IMAGE) export(plotly_POST) export(plotly_build) export(plotly_empty) +export(plotly_spec) export(renderPlotly) export(signup) export(style) export(subplot) export(toRGB) +export(toWebGL) export(to_basic) import(ggplot2) importFrom(base64enc,base64encode) importFrom(grDevices,col2rgb) +importFrom(graphics,layout) importFrom(htmlwidgets,createWidget) +importFrom(htmlwidgets,saveWidget) importFrom(htmlwidgets,shinyRenderWidget) importFrom(htmlwidgets,shinyWidgetOutput) importFrom(htmlwidgets,sizingPolicy) @@ -91,6 +93,9 @@ importFrom(httr,content) importFrom(httr,stop_for_status) importFrom(jsonlite,fromJSON) importFrom(jsonlite,toJSON) +importFrom(lazyeval,dots_capture) +importFrom(lazyeval,f_eval) +importFrom(lazyeval,f_list) importFrom(magrittr,"%>%") importFrom(stats,complete.cases) importFrom(stats,setNames) diff --git a/NEWS b/NEWS index 3f9bfb4296..20b583569c 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,23 @@ +4.0.0 + +MAJOR CHANGES & IMPROVEMENTS: + +* Formulas (instead of plain expressions) are now required when referring to variable names. For example, `plot_ly(mtcars, x = wt, y = mpg, color = vs)` should now be `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~vs)`. This is a major breaking change, but it is necessary to ensure that evaluation is correct in all contexts (as a result, `evaluate` argument is now deprecated). It also has the benefit of being easier to program with (i.e., writing your own custom functions that wrap `plot_ly()`). For more details, see the [lazyeval vignette](https://github.com/hadley/lazyeval/blob/master/vignettes/lazyeval.Rmd) +* The central object (i.e., the return value and first argument to functions) is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, plotly objects can now be serialized across R sessions and avoid [memory leak issues](https://github.com/rstudio/shiny/issues/1151). This also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided. + + +NEW FEATURES & IMPROVEMENTS: + +* Error checking for trace types. +* New `add_points()`/`add_lines()`/`add_text()` functions provide a shorthand for common plots. +* New `toWebGL()` function for easy conversion from SVG to WebGL. +* New `export()` function makes it easy to save plots as png/jpeg/pdf. +* `layout()` is now a generic function and uses method dispatch to avoid conflicts with graphics:layout(). +* Added a `plotly_json()` function to help + + + + 3.6.2 -- 24 May 2016 CHANGES: diff --git a/R/add.R b/R/add.R new file mode 100644 index 0000000000..550aecd893 --- /dev/null +++ b/R/add.R @@ -0,0 +1,61 @@ +#' Add a trace to a plotly visualization +#' +#' @param p a plotly or ggplot object. +#' @param ... These arguments are documented in the references section below. +#' Note that acceptable arguments depend on the trace type. +#' @param group Either a variable name or a vector to use for grouping. If used, +#' a different trace will be created for each unique value. +#' @param color Either a variable name or a vector to use for color mapping. +#' @param colors Either a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"), +#' or a vector of colors to interpolate in hexadecimal "#RRGGBB" format, +#' or a color interpolation function like \code{colorRamp}. +#' @param symbol Either a variable name or a (discrete) vector to use for symbol encoding. +#' @param symbols A character vector of symbol types. Possible values: +#' 'dot', 'cross', 'diamond', 'square', 'triangle-down', 'triangle-left', 'triangle-right', 'triangle-up' +#' @param size A variable name or numeric vector to encode the size of markers. +#' @param data A data frame to associate with this trace (optional). If not +#' provided, arguments are evaluated using the data frame in \code{\link{plot_ly}()}. +#' @seealso \code{\link{plot_ly}()} +#' @references \url{https://plot.ly/r/reference/} +#' @author Carson Sievert +#' @export +add_trace <- function(p, ..., + group, color, colors, symbol, symbols, size, data = NULL) { + p <- verify_plot(p) + # "native" plotly arguments + argz <- list(...) + # tack on "special" arguments + if (!missing(group)) argz$group <- substitute(group) + if (!missing(color)) argz$color <- substitute(color) + if (!missing(colors)) argz$colors <- substitute(colors) + if (!missing(symbol)) argz$symbol <- substitute(symbol) + if (!missing(symbols)) argz$symbols <- substitute(symbols) + if (!missing(size)) argz$size <- substitute(size) + + argz$type <- verify_type(argz$type) + + nTraces <- length(p$x$data) + + p$x$data[[nTraces + 1]] <- list( + attrs = argz, + rdata = data %||% p$x$data[[1]]$rdata + ) + + p +} + +#' @export +add_points <- function(p, ...) { + add_trace(p, type = "scatter", mode = "markers", ...) +} + +#' @export +add_lines <- function(p, ...) { + add_trace(p, type = "scatter", mode = "lines", ...) +} + +#' @export +add_text <- function(p, ...) { + add_trace(p, type = "scatter", mode = "text", ...) +} + diff --git a/R/export.R b/R/export.R new file mode 100644 index 0000000000..7bafcc6c3a --- /dev/null +++ b/R/export.R @@ -0,0 +1,32 @@ +#' Export a plotly graph to a static file +#' +#' @param p a plotly or ggplot object. +#' @param file a filename. See the file argument of \code{webshot::webshot} +#' for valid extensions. +#' @param ... arguments passed onto \code{webshot::webshot} +#' @export +#' @examples \dontrun{ +#' export(plot_ly(economics, x = ~date, y = ~pce)) +#' } +export <- function(p, file = "plotly.png", ...) { + if (system.file(package = "webshot") == "") { + stop( + 'Please install the webshot package ', + '(if not on CRAN, try devtools::install_github("wch/webshot"))' + ) + } + f <- basename(tempfile('plotly', '.', '.html')) + on.exit(unlink(f), add = TRUE) + html <- htmlwidgets::saveWidget(plotly_build(p), f) + webshot::webshot(f, file, ...) +} + + +#library(htmlwidgets) +#plot_ly(economics, x = ~date, y = ~uempmed) %>% +# onRender( +# "function(el, x) { +# var gd = document.getElementById(el.id); +# Plotly.downloadImage(gd, {format: 'jpeg', height: 300, width: 300, filename: 'plotly_download'}) +# }" +# ) diff --git a/R/figure.R b/R/figure.R index 6b3edf346b..bfa8711421 100644 --- a/R/figure.R +++ b/R/figure.R @@ -20,5 +20,5 @@ get_figure <- function(username, id) { if (missing(id)) stop("Please provide a figure id number") base_url <- file.path(get_domain(), "apigetfile", username, id) resp <- httr::GET(base_url, plotly_headers(), httr::config(ssl_verifypeer=FALSE)) - process(append_class(resp, "figure")) + process(append_class(resp, "plotly_figure")) } diff --git a/R/ggplotly.R b/R/ggplotly.R index a1ab6b6522..8fab417eb4 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -66,14 +66,14 @@ ggplotly.ggmatrix <- function(p = ggplot2::last_plot(), width = NULL, if (nchar(p$title) > 0) { s <- layout(s, title = p$title) } - hash_plot(p$data, plotly_build(s)) + s } #' @export ggplotly.ggplot <- function(p = ggplot2::last_plot(), width = NULL, height = NULL, tooltip = "all", source = "A", ...) { - l <- gg2list(p, width = width, height = height, tooltip = tooltip, source = source) - hash_plot(p$data, l) + l <- gg2list(p, width = width, height = height, tooltip = tooltip, source = source, ...) + as.widget(l) } #' Convert a ggplot to a list. @@ -687,13 +687,13 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A # If a trace isn't named, it shouldn't have additional hoverinfo traces <- lapply(compact(traces), function(x) { x$name <- x$name %||% ""; x }) - l <- list(data = setNames(traces, NULL), layout = compact(gglayout)) + l <- list(data = setNames(traces, NULL), layout = list(compact(gglayout))) # ensure properties are boxed correctly l <- add_boxed(rm_asis(l)) - l$width <- width - l$height <- height + l$layout$width <- width + l$layout$height <- height l$source <- source - structure(l, class = "plotly_built") + l } diff --git a/R/helpers.R b/R/helpers.R new file mode 100644 index 0000000000..609e97fb10 --- /dev/null +++ b/R/helpers.R @@ -0,0 +1,66 @@ +#' Obtain JSON sent to plotly.js +#' +#' This function returns the JSON sent to plotly.js which can be useful for +#' debugging. +#' +#' @param p a plotly or ggplot object. +#' @param as in what format should the spec be printed? +#' @param ... arguments passed onto \code{jsonlite::toJSON} +#' @export +#' @examples +#' +#' plotly_spec(plot_ly(), as = "json", pretty = TRUE) + +plotly_spec <- function(p = plot_ly(), as = c("plain", "json"), ...) { + spec <- plotly_build(p)$x + if (identical("json", match.arg(as))) { + return(to_JSON(spec, ...)) + } + spec +} + + +#' Convert trace types to WebGL +#' +#' This function will also build +#' +#' @param p a plotly or ggplot object. +#' @param warn should a warning be produced if the trace type doesn't have +#' a WebGL equivalent? +#' @export +#' @examples +#' +#' # currently no bargl trace type +#' toWebGL(qplot(1:10)) +#' toWebGL(qplot(1:10, 1:10)) +#' +toWebGL <- function(p, warn = TRUE) { + p <- plotly_build(p) + types <- sapply(p$x$data, function(x) x[["type"]][1] %||% "scatter") + idx <- paste0(types, "gl") %in% traces + if (any(!idx) && warn) { + warning( + "The following traces don't have a WebGL equivalent: ", + paste(which(!idx), collapse = ", ") + ) + } + for (i in which(idx)) { + p$x$data[[i]]$type <- paste0(p$x$data[[i]]$type, "gl") + } + p +} + + +#' Create a complete empty plotly graph. +#' +#' Useful when used with \link{subplot} +#' +#' @export +plotly_empty <- function() { + eaxis <- list( + showticklabels = FALSE, + showgrid = FALSE, + zeroline = FALSE + ) + layout(plot_ly(), xaxis = eaxis, yaxis = eaxis) +} diff --git a/R/imports.R b/R/imports.R index f8a474f579..3f1295e74c 100644 --- a/R/imports.R +++ b/R/imports.R @@ -1,10 +1,12 @@ #' @import ggplot2 #' @importFrom grDevices col2rgb +#' @importFrom graphics layout #' @importFrom utils getFromNamespace modifyList data packageVersion browseURL #' @importFrom stats setNames complete.cases #' @importFrom tidyr gather #' @importFrom viridis viridis #' @importFrom jsonlite toJSON fromJSON #' @importFrom httr GET POST PATCH content config add_headers stop_for_status -#' @importFrom htmlwidgets createWidget sizingPolicy +#' @importFrom htmlwidgets createWidget sizingPolicy saveWidget +#' @importFrom lazyeval f_eval f_list dots_capture NULL diff --git a/R/layout.R b/R/layout.R new file mode 100644 index 0000000000..9b0fd254f5 --- /dev/null +++ b/R/layout.R @@ -0,0 +1,66 @@ +#' Modify the layout of a plotly visualization +#' +#' @param p A plotly object. +#' @param ... Arguments to the layout object. For documentation, +#' see \url{https://plot.ly/r/reference/#Layout_and_layout_style_objects} +#' @param data A data frame to associate with this layout (optional). If not +#' provided, arguments are evaluated using the data frame in \code{\link{plot_ly}()}. +#' @author Carson Sievert +#' @export +layout <- function(p, ..., data = NULL) { + UseMethod("layout") +} + +#' @export +layout.matrix <- function(p, ..., data = NULL) { + # workaround for the popular graphics::layout() function + # https://github.com/ropensci/plotly/issues/464 + graphics::layout(p, ...) +} + +#' @export +layout.plotly <- function(p, ..., data = NULL) { + argz <- list(...) + nLayouts <- length(p$x$layout) + p$x$layout[[nLayouts + 1]] <- list( + attrs = argz, + rdata = data %||% p$x$data[[1]]$rdata + ) + p +} + +#' Set the default configuration for plotly +#' +#' @param p a plotly object +#' @param ... these arguments are documented at +#' \url{https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js} +#' @author Carson Sievert +#' @export +#' @examples \dontrun{ +#' config(plot_ly(), displaylogo = FALSE, modeBarButtonsToRemove = list('sendDataToCloud')) +#' } + +config <- function(p, ...) { + nConfig <- length(p$x$config) + p$x$config[[nConfig + 1]] <- list(...) + p +} + +#' Modify trace(s) +#' +#' Modify trace(s) of an existing plotly visualization. Useful when used in +#' conjunction with \code{\link{get_figure}()}. +#' +#' @param p A plotly visualization. +#' @param ... Visual properties. +#' @param traces numeric vector. Which traces should be modified? +#' @seealso \code{\link{get_figure}()} +#' @author Carson Sievert +#' @export +style <- function(p, ..., traces = 1) { + p <- plotly_build(p) + idx <- traces >= length(p$x$data) + if (any(idx)) warning("You've referenced non-existent traces", call. = FALSE) + p$x$style <- c(p$x$style, list(...)) + p +} diff --git a/R/plotly.R b/R/plotly.R index 46a275315c..4392013e0e 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -22,7 +22,6 @@ #' @param width Width in pixels (optional, defaults to automatic sizing). #' @param height Height in pixels (optional, defaults to automatic sizing). #' @param inherit logical. Should future traces inherit properties from this initial trace? -#' @param evaluate logical. Evaluate arguments when this function is called? #' @param source Only relevant for \link{event_data}. #' @seealso \code{\link{layout}()}, \code{\link{add_trace}()}, \code{\link{style}()} #' @author Carson Sievert @@ -31,10 +30,9 @@ #' \dontrun{ #' data(economics, package = "ggplot2") #' # basic time-series plot -#' p <- plot_ly(economics, x = date, y = uempmed, type = "scatter", -#' showlegend = FALSE) +#' p <- plot_ly(economics, x = ~date, y = ~uempmed, inherit = TRUE) #' # add a loess smoother -#' p2 <- add_trace(p, y = fitted(loess(uempmed ~ as.numeric(date)))) +#' p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) #' # add a title #' p3 <- layout(p2, title = "Median duration of unemployment (in weeks)") #' # change the font @@ -51,25 +49,32 @@ #' } #' plot_ly(economics, x = unemploy / pop, color = decade(date), type = "box") #' -#' # plotly loves pipelines -#' economics %>% -#' transform(rate = unemploy / pop) %>% -#' plot_ly(x = date, y = rate) %>% -#' loess(rate ~ as.numeric(date), data = .) %>% -#' broom::augment() %>% +#' # monads::`%>>%` enables data-plot-pipelines +#' +#' plot_ly(mtcars, x = ~wt, y = ~mpg) +#' +#' +#' economics %>>% +#' transform(rate = unemploy / pop) %>>% +#' +#' %>% +#' %>>% +#' loess(rate ~ as.numeric(date), data = .) %>>% +#' broom::augment() %>>% #' add_trace(y = .fitted) #' #' # sometimes, a data frame isn't fit for the use case... #' # for 3D surface plots, a numeric matrix is more natural #' plot_ly(z = volcano, type = "surface") +#' #' } #' -plot_ly <- function(data = data.frame(), ..., type = "scatter", +plot_ly <- function(data = data.frame(), ..., type = NULL, group, color, colors, symbol, symbols, size, - width = NULL, height = NULL, inherit = FALSE, - evaluate = FALSE, source = "A") { + width = NULL, height = NULL, inherit = FALSE, + source = "A") { # "native" plotly arguments - argz <- substitute(list(...)) + argz <- list(...) # old arguments to this function that are no longer supported if (!is.null(argz$filename)) warning("Ignoring filename. Use plotly_POST() if you want to post figures to plotly.") @@ -78,407 +83,36 @@ plot_ly <- function(data = data.frame(), ..., type = "scatter", if (!is.null(argz$world_readable)) warning("Ignoring world_readable. Use plotly_POST() if you want to post figures to plotly.") # tack on "special" arguments - if (!missing(group)) argz$group <- substitute(group) - if (!missing(color)) argz$color <- substitute(color) - if (!missing(colors)) argz$colors <- substitute(colors) - if (!missing(symbol)) argz$symbol <- substitute(symbol) - if (!missing(symbols)) argz$symbols <- substitute(symbols) - if (!missing(size)) argz$size <- substitute(size) - # trace information - tr <- list( - type = type, - args = argz, - env = list2env(data), # environment in which to evaluate arguments - enclos = parent.frame(), # if objects aren't found in env, look here - inherit = inherit - ) - # plotly objects should always have a _list_ of trace(s) + argz$group <- verify_arg(group) + argz$color <- verify_arg(color) + argz$symbol <- verify_arg(symbol) + argz$size <- verify_arg(size) + # TODO: do we really need to verify these? + argz$colors <- verify_arg(colors) + argz$symbols <- verify_arg(symbols) + + # we always deal with a _list_ of traces and _list_ of layouts + # since they can each have different data p <- list( - data = list(tr), - layout = NULL, - url = NULL, - width = width, - height = height, - source = source + data = list( + list( + type = verify_type(type), + attrs = argz, + rdata = data + ) + ), + layout = list( + list( + width = width, + height = height, + # sane margin defaults (mainly for RStudio) + margin = list(b = 40, l = 60, t = 25, r = 10) + ) + ), + config = list(modeBarButtonsToRemove = I("sendDataToCloud")), + inherit = inherit, + base_url = get_domain() ) - if (evaluate) p <- plotly_build(p) - hash_plot(data, p) -} - -#' Add a trace to a plotly visualization -#' -#' @param p A plotly object. -#' @param ... These arguments are documented in the references section below. -#' Note that acceptable arguments depend on the trace type. -#' @param group Either a variable name or a vector to use for grouping. If used, -#' a different trace will be created for each unique value. -#' @param color Either a variable name or a vector to use for color mapping. -#' @param colors Either a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"), -#' or a vector of colors to interpolate in hexadecimal "#RRGGBB" format, -#' or a color interpolation function like \code{colorRamp}. -#' @param symbol Either a variable name or a (discrete) vector to use for symbol encoding. -#' @param symbols A character vector of symbol types. Possible values: -#' 'dot', 'cross', 'diamond', 'square', 'triangle-down', 'triangle-left', 'triangle-right', 'triangle-up' -#' @param size A variable name or numeric vector to encode the size of markers. -#' @param data A data frame to associate with this trace (optional). If not -#' provided, arguments are evaluated using the data frame in \code{\link{plot_ly}()}. -#' @param evaluate logical. Evaluate arguments when this function is called? -#' @seealso \code{\link{plot_ly}()} -#' @references \url{https://plot.ly/r/reference/} -#' @author Carson Sievert -#' @export -add_trace <- function(p = last_plot(), ..., - group, color, colors, symbol, symbols, size, - data = NULL, evaluate = FALSE) { - # "native" plotly arguments - argz <- substitute(list(...)) - # tack on "special" arguments - if (!missing(group)) argz$group <- substitute(group) - if (!missing(color)) argz$color <- substitute(color) - if (!missing(colors)) argz$colors <- substitute(colors) - if (!missing(symbol)) argz$symbol <- substitute(symbol) - if (!missing(symbols)) argz$symbols <- substitute(symbols) - if (!missing(size)) argz$size <- substitute(size) - data <- data %||% if (is.data.frame(p)) p else list() - tr <- list( - args = argz, - env = list2env(data), - enclos = parent.frame() - ) - p <- last_plot(p) - p$data <- c(p$data, list(tr)) - if (evaluate) p <- plotly_build(p) - hash_plot(data, p) -} - -#' Add and/or modify layout of a plotly -#' -#' @param p A plotly object. -#' @param ... Arguments to the layout object. For documentation, -#' see \url{https://plot.ly/r/reference/#Layout_and_layout_style_objects} -#' @param data A data frame to associate with this layout (optional). If not -#' provided, arguments are evaluated using the data frame in \code{\link{plot_ly}()}. -#' @param evaluate logical. Evaluate arguments when this function is called? -#' @author Carson Sievert -#' @export -layout <- function(p = last_plot(), ..., - data = NULL, evaluate = FALSE) { - data <- data %||% if (is.data.frame(p)) p else list() - layout <- list( - args = substitute(list(...)), - env = list2env(data), - enclos = parent.frame() - ) - p <- last_plot(p) - p$layout <- c(p$layout, list(layout = layout)) - if (evaluate) p <- plotly_build(p) - hash_plot(data, p) -} - -#' Set the default configuration for plotly -#' -#' @param p a plotly object -#' @param ... these arguments are documented at -#' \url{https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js} -#' @author Carson Sievert -#' @export -#' @examples \dontrun{ -#' config(plot_ly(), displaylogo = FALSE, modeBarButtonsToRemove = list('sendDataToCloud')) -#' } - -config <- function(p = last_plot(), ...) { - conf <- list(...) - p <- last_plot(p) - p$config <- c(p$config, conf) - hash_plot(if (is.data.frame(p)) p else list(), p) -} - -#' Modify trace(s) -#' -#' Modify trace(s) of an existing plotly visualization. Useful when used in -#' conjunction with \code{\link{get_figure}()}. -#' -#' @param p A plotly visualization. -#' @param ... Visual properties. -#' @param traces numeric vector. Which traces should be modified? -#' @param evaluate logical. Evaluate arguments when this function is called? -#' @seealso \code{\link{get_figure}()} -#' @author Carson Sievert -#' @export -style <- function(p = last_plot(), ..., traces = 1, evaluate = FALSE) { - idx <- traces >= length(p$data) - if (any(idx)) warning("You've referenced non-existent traces", call. = FALSE) - style <- list( - args = substitute(list(...)), - # not optimal.... - env = p$data[[max(traces)]]$env, - enclos = parent.frame(), - traces = traces - ) - p$style <- c(p$style, list(style)) - if (evaluate) p <- plotly_build(p) - hash_plot(data, p) -} - -#' Create a 'plotly_built' object -#' -#' This generic function creates the list object sent to plotly.js -#' for rendering. Using this function can be useful for overriding defaults -#' provided by \code{ggplotly}/\code{plot_ly} or for debugging rendering -#' errors. -#' -#' @param l a ggplot object, or a plotly_hash object, or a list. -#' @export -#' @examples -#' -#' p <- plot_ly() -#' # data frame -#' str(p) -#' # the actual list of options sent to plotly.js -#' str(plotly_build(p)) -#' -#' p <- qplot(data = mtcars, wt, mpg, geom = c("point", "smooth")) -#' l <- plotly_build(p) -#' # turn off hoverinfo for the smooth (but keep it for the points) -#' l$data[[2]]$hoverinfo <- "none" -#' l$data[[3]]$hoverinfo <- "none" -#' l -#' -plotly_build <- function(l = last_plot()) { - UseMethod("plotly_build") -} - -#' @export -plotly_build.default <- function(l = last_plot()) { - l -} - -#' @export -plotly_build.plotly_built <- function(l = last_plot()) { - l -} - -#' @export -plotly_build.plotly_subplot <- function(l = last_plot()) { - prefix_class(get_plot(l), "plotly_built") -} - -#' @export -plotly_build.gg <- function(l = last_plot()) { - prefix_class(get_plot(ggplotly(l)), "plotly_built") -} - -#' @export -plotly_build.plotly_hash <- function(l = last_plot()) { - l <- get_plot(l) - # assume unnamed list elements are data/traces - nms <- names(l) - idx <- nms %in% "" - l <- if (is.null(nms)) { - list(data = l) - } else if (any(idx)) { - c(data = c(l$data, l[idx]), l[!idx]) - } else l - # carry over properties, if necessary (but don't carry over evaluation envir) - if (length(l$data) > 1 && isTRUE(l$data[[1]]$inherit)) { - d <- l$data[[1]] - d <- d[!names(d) %in% c("env", "enclos")] - for (i in seq.int(2, length(l$data))) { - l$data[[i]] <- modifyList(l$data[[i]], d) - } - } - # 'x' is the same as 'l', but with arguments evaluated - # this is ugly, but I think it is necessary, since we don't know how many - # traces we have until we evaluate args and call traceify() (or similar) - x <- list() - for (i in seq_along(l$data)) { - d <- l$data[[i]] - if (should_eval(d)) { - dat <- do_eval(d) - # start processing specially named arguments - s <- dat[["size"]] - if (!is.null(s)) { - if (!is.numeric(s)) warning("size should be numeric", call. = FALSE) - # if autosizing is used, guess that the plot is 300 by 600 - auto <- dat[["layout"]][["autosize"]] %||% TRUE - hw <- if (auto) c(300, 600) - else c(dat[["layout"]][["height"]], dat[["layout"]][["width"]]) - # ensure that markers cover 30% of the plot area - m <- list( - size = 0.3 * prod(hw) * (s/sum(s)), - sizemode = "area" - ) - # the marker object is the only type of object which respects size - dat[["marker"]] <- modifyList(dat[["marker"]] %||% list(), m) - # either add some appropriate hover text - txt <- paste0(as.list(d$args)[["size"]], " (size): ", s) - dat[["text"]] <- if (is.null(dat[["text"]])) txt else paste0(dat[["text"]], "
", txt) - } - has_color <- !is.null(dat[["color"]]) || - isTRUE(!is.null(dat[["z"]]) && !dat[["type"]] %in% "scatter3d") - has_symbol <- !is.null(dat[["symbol"]]) - has_group <- !is.null(dat[["group"]]) - if (has_color) { - title <- as.list(d$args)[["color"]] %||% as.list(d$args)[["z"]] %||% "" - x$data <- c(x$data, colorize(dat, title)) - } - # TODO: add a legend title (is this only possible via annotations?!?) - if (has_symbol) x$data <- c(x$data, symbolize(dat)) - if (has_group) x$data <- c(x$data, traceify(dat, "group")) - if (!has_color && !has_symbol && !has_group) x$data <- c(x$data, list(dat)) - } else { - x$data <- c(x$data, list(d)) - } - } - # it's possible have nested layouts (e.g., plot_ly() %>% layout() %>% layout()) - nms <- names(l$layout) - idx <- nms %in% "layout" - l$layout <- c(list(l$layout[!idx]), setNames(l$layout[idx], NULL)) - for (i in seq_along(l$layout)) { - x$layout[[i]] <- perform_eval(l$layout[[i]]) - } - x$layout <- Reduce(modifyList, x$layout) - # if style is not null, use it to modify existing traces - if (!is.null(l$style)) { - for (i in seq_along(l$style)) { - sty <- perform_eval(l$style[[i]]) - for (k in l$style[[i]]$traces) - x$data[[k]] <- modifyList(x$data[[k]], sty) - } - } - # add appropriate axis title (if they don't already exist) - x <- axis_titles(x, l) - # tack on other keyword arguments, if necessary - idx <- !names(l) %in% c("data", "layout") - if (any(idx)) x <- c(x, l[idx]) - x <- add_boxed(x) - # ugh, annotations _must_ be an _array_ of object(s)... - a <- x$layout$annotations - if (!is.null(a) && !is.null(names(a))) { - x$layout$annotations <- list(x$layout$annotations) - } - # traces shouldn't have any names - x$data <- setNames(x$data, NULL) - # if this is a non-line scatter trace and no hovermode exists, - # set hovermode to closest - if (is.null(x$data[[1]]$type) || isTRUE(x$data[[1]]$type == "scatter")) { - if (!grepl("lines", x$data[[1]]$mode %||% "lines")) - x$layout$hovermode <- x$layout$hovermode %||% "closest" - } - # add plotly class mainly for printing method - structure(x, class = unique("plotly_built", class(x))) -} - -# returns a _list of traces_. -colorize <- function(dat, title = "") { - cols <- dat[["color"]] %||% dat[["z"]] - if (is.numeric(cols)) { - # by default, use viridis::viridis(10) -> http://rud.is/b/2015/07/20/using-the-new-viridis-colormap-in-r-thanks-to-simon-garnier/ - colors <- dat[["colors"]] %||% viridis::viridis(10) - cols <- as.vector(cols) - rng <- range(cols, na.rm = TRUE) - x <- seq(min(rng), max(rng), length.out = 10) - colz <- scales::col_numeric(colors, rng, na.color = "transparent")(x) - df <- if (length(cols) > 1) data.frame(scales::rescale(x), colz) - else data.frame(c(0, 1), rep(colz, 2)) - col_list <- list( - colorbar = list(title = as.character(title)), - colorscale = setNames(df, NULL) - ) - # scatter-like traces can have both line and marker objects - if (grepl("scatter", dat[["type"]] %||% "scatter")) { - col_list$color <- cols - dat[["marker"]] <- modifyList(col_list, dat[["marker"]] %||% list()) - #mode <- dat[["mode"]] %||% "markers+lines" - # can't have a colorscale for both markers and lines??? - #dat[["line"]] <- modifyList(col_list, dat[["line"]] %||% list()) - } else { - dat <- c(dat, col_list) - } - dat <- list(dat) - } else { # discrete color scale - lvls <- unique(cols) - N <- length(lvls) - default <- if (is.ordered(cols)) viridis::viridis(N) - else RColorBrewer::brewer.pal(N, "Set2") - colors <- dat[["colors"]] %||% default - colz <- scales::col_factor(colors, levels = lvls, na.color = "transparent")(lvls) - dat <- traceify(dat, "color") - dat <- Map(function(x, y) { x[["marker"]] <- c(x[["marker"]], list(color = y)); x }, - dat, colz) - } - dat <- lapply(dat, function(x) { x$color <- NULL; x$colors <- NULL; x }) - dat -} - -symbolize <- function(dat) { - # symbols really only make sense when markers are in the mode, right? - dat$mode <- dat$mode %||% "markers" - dat <- traceify(dat, "symbol") - dat <- lapply(dat, function(x) { x$symbol <- NULL; x }) - N <- length(dat) - if (N > 8) warning("Plotly supports 8 different symbols, but you have ", N, " levels!") - symbols <- c('dot', 'cross', 'diamond', 'square', 'triangle-down', 'triangle-left', 'triangle-right', 'triangle-up') - sym <- dat[[1]][["symbols"]][seq_len(N)] %||% symbols[seq_len(N)] - dat <- Map(function(x, y) { x$marker$symbol <- y; x }, dat, sym) - dat -} - -# break up a single trace into multiple traces according to values stored -# a particular key name -traceify <- function(dat, nm = "group") { - x <- dat[[nm]] - if (is.null(x)) { - return(list(dat)) - } else { - # the order of lvls determines the order in which traces are drawn - # for ordered factors at least, it makes sense to draw the highest level first - # since that _should_ be the darkest color in a sequential pallette - lvls <- if (is.factor(x)) rev(levels(x)) else unique(x) - n <- length(x) - # recursively search for a non-list of appropriate length (if it is, subset it) - recurse <- function(z, n, idx) { - if (is.list(z)) lapply(z, recurse, n, idx) else if (length(z) == n) z[idx] else z - } - new_dat <- list() - for (j in seq_along(lvls)) { - new_dat[[j]] <- lapply(dat, function(y) recurse(y, n, x %in% lvls[j])) - new_dat[[j]]$name <- lvls[j] - } - return(new_dat) - } -} - -axis_titles <- function(x, l) { - d <- l$data[[1]] - argz <- as.list(d$args) - scene <- if (isTRUE(d$type %in% c("scatter3d", "surface"))) TRUE else FALSE - for (i in c("x", "y", "z")) { - ax <- paste0(i, "axis") - t <- x$layout[[ax]]$title %||% x$layout$scene[[ax]]$title - if (is.null(t)) { - idx <- which(names(argz) %in% i) - if (length(idx)) { - title <- if (is.language(argz[[idx]])) deparse(argz[[idx]]) else i - if (scene) x$layout[["scene"]][[ax]]$title <- title - else x$layout[[ax]]$title <- title - } - } - } - x -} - -#' Create a complete empty plotly graph. -#' -#' Useful when used with \link{subplot} -#' -#' @export -plotly_empty <- function() { - eaxis <- list( - showticklabels = FALSE, - showgrid = FALSE, - zeroline = FALSE - ) - layout(plot_ly(), xaxis = eaxis, yaxis = eaxis) + as.widget(p) } diff --git a/R/plotly_POST.R b/R/plotly_POST.R index e4ced1affc..b455db22a9 100644 --- a/R/plotly_POST.R +++ b/R/plotly_POST.R @@ -83,5 +83,5 @@ plotly_POST <- function(x, filename = NULL, fileopt = "overwrite", new = "Success! Created a new plotly here -> ", overwrite = "Success! Modified your plotly here -> ") message(msg, con$url) - structure(con, class = "figure") + structure(con, class = "plotly_figure") } diff --git a/R/plotly_build.R b/R/plotly_build.R new file mode 100644 index 0000000000..73c0532a8c --- /dev/null +++ b/R/plotly_build.R @@ -0,0 +1,158 @@ +#' 'Build' (i.e., evaluate) a plotly object +#' +#' +#' This generic function creates the list object sent to plotly.js +#' for rendering. Using this function can be useful for overriding defaults +#' provided by \code{ggplotly}/\code{plot_ly} or for debugging rendering +#' errors. +#' +#' @param p a ggplot object, or a plotly object, or a list. +#' @export +#' @examples +#' +#' p <- plot_ly(economics, x = ~date, y = ~pce) +#' # a plotly visualization object +#' str(p$x$data) +#' # the actual list of options sent to plotly.js +#' str(plotly_build(p)) +#' +#' p <- qplot(data = mtcars, wt, mpg, geom = c("point", "smooth")) +#' l <- plotly_build(p) +#' # turn off hoverinfo for the smooth (but keep it for the points) +#' l$x$data[[2]]$hoverinfo <- "none" +#' l$x$data[[3]]$hoverinfo <- "none" +#' l +#' +plotly_build <- function(p) { + UseMethod("plotly_build") +} + +#' @export +plotly_build.gg <- function(p) { + ggplotly(p) +} + +#' @export +plotly_build.plotly <- function(p) { + + # Initiating a plot with plot_ly() should have a _list_ of layouts + if (is.list(p$x$layout) && is.null(names(p$x$layout))) { + p$x$layout <- lapply(p$x$layout, function(lay) { + is_formula <- vapply(lay$attrs, is.formula, logical(1)) + fl <- lazyeval::as_f_list(lay$attrs[is_formula] %||% list()) + for (var in names(fl)) { + lay[[var]] <- lazyeval::f_eval(fl[[var]], lay$rdata) + } + # tack on attributes, that aren't formulas, without evaluating them + lay <- c(lay, lay$attrs[!is_formula]) + lay[c("attrs", "rdata")] <- NULL + lay[lengths(lay) > 0] + }) + # combine all the layouts into one layout + # (with later layout() calls overriding previous ones) + p$x$layout <- Reduce(modifyList, p$x$layout) + } + + p$x$data <- lapply(p$x$data, function(tr) { + is_formula <- vapply(tr$attrs, is.formula, logical(1)) + fl <- lazyeval::as_f_list(tr$attrs[is_formula] %||% list()) + for (var in names(fl)) { + tr[[var]] <- lazyeval::f_eval(fl[[var]], tr$rdata) + varname <- sub("^~", "", deparse2(fl[[var]])) + # deparse axis names and add to layout + if (any(c("x", "y", "z") %in% var)) { + if (is3d(tr$type)) { + p$x$layout$scene[[paste0(var, "axis")]]$title <<- varname + } else { + p$x$layout[[paste0(var, "axis")]]$title <<- varname + } + } + } + # tack on attributes, that aren't formulas, without evaluating them + tr <- c(tr, tr$attrs[!is_formula]) + tr[c("attrs", "rdata")] <- NULL + tr[lengths(tr) > 0] + }) + + p +} + +# returns a _list of traces_. +colorize <- function(dat, title = "") { + cols <- dat[["color"]] %||% dat[["z"]] + if (is.numeric(cols)) { + # by default, use viridis::viridis(10) -> http://rud.is/b/2015/07/20/using-the-new-viridis-colormap-in-r-thanks-to-simon-garnier/ + colors <- dat[["colors"]] %||% viridis::viridis(10) + cols <- as.vector(cols) + rng <- range(cols, na.rm = TRUE) + x <- seq(min(rng), max(rng), length.out = 10) + colz <- scales::col_numeric(colors, rng, na.color = "transparent")(x) + df <- if (length(cols) > 1) data.frame(scales::rescale(x), colz) + else data.frame(c(0, 1), rep(colz, 2)) + col_list <- list( + colorbar = list(title = as.character(title)), + colorscale = setNames(df, NULL) + ) + # scatter-like traces can have both line and marker objects + if (grepl("scatter", dat[["type"]] %||% "scatter")) { + col_list$color <- cols + dat[["marker"]] <- modifyList(col_list, dat[["marker"]] %||% list()) + #mode <- dat[["mode"]] %||% "markers+lines" + # can't have a colorscale for both markers and lines??? + #dat[["line"]] <- modifyList(col_list, dat[["line"]] %||% list()) + } else { + dat <- c(dat, col_list) + } + dat <- list(dat) + } else { # discrete color scale + lvls <- unique(cols) + N <- length(lvls) + default <- if (is.ordered(cols)) viridis::viridis(N) + else RColorBrewer::brewer.pal(N, "Set2") + colors <- dat[["colors"]] %||% default + colz <- scales::col_factor(colors, levels = lvls, na.color = "transparent")(lvls) + dat <- traceify(dat, "color") + dat <- Map(function(x, y) { x[["marker"]] <- c(x[["marker"]], list(color = y)); x }, + dat, colz) + } + dat <- lapply(dat, function(x) { x$color <- NULL; x$colors <- NULL; x }) + dat +} + +symbolize <- function(dat) { + # symbols really only make sense when markers are in the mode, right? + dat$mode <- dat$mode %||% "markers" + dat <- traceify(dat, "symbol") + dat <- lapply(dat, function(x) { x$symbol <- NULL; x }) + N <- length(dat) + if (N > 8) warning("Plotly supports 8 different symbols, but you have ", N, " levels!") + symbols <- c('dot', 'cross', 'diamond', 'square', 'triangle-down', 'triangle-left', 'triangle-right', 'triangle-up') + sym <- dat[[1]][["symbols"]][seq_len(N)] %||% symbols[seq_len(N)] + dat <- Map(function(x, y) { x$marker$symbol <- y; x }, dat, sym) + dat +} + +# break up a single trace into multiple traces according to values stored +# a particular key name +traceify <- function(dat, nm = "group") { + x <- dat[[nm]] + if (is.null(x)) { + return(list(dat)) + } else { + # the order of lvls determines the order in which traces are drawn + # for ordered factors at least, it makes sense to draw the highest level first + # since that _should_ be the darkest color in a sequential pallette + lvls <- if (is.factor(x)) rev(levels(x)) else unique(x) + n <- length(x) + # recursively search for a non-list of appropriate length (if it is, subset it) + recurse <- function(z, n, idx) { + if (is.list(z)) lapply(z, recurse, n, idx) else if (length(z) == n) z[idx] else z + } + new_dat <- list() + for (j in seq_along(lvls)) { + new_dat[[j]] <- lapply(dat, function(y) recurse(y, n, x %in% lvls[j])) + new_dat[[j]]$name <- lvls[j] + } + return(new_dat) + } +} diff --git a/R/print.R b/R/print.R index 4985fd3e04..57d24a41d3 100644 --- a/R/print.R +++ b/R/print.R @@ -1,75 +1,29 @@ -#' Print a plotly object -#' -#' @param x a plotly object -#' @param ... additional arguments -#' @export -print.plotly_hash <- function(x, ...) { - x <- as.widget(x) - print(x, ...) -} - -#' Print a 'built' plotly object -#' -#' @param x a plotly object -#' @param ... additional arguments -#' @export -print.plotly_built <- print.plotly_hash - -#' Print a plotly object in a knitr doc -#' -#' @param x a plotly object -#' @param options knitr options. -#' @param ... additional arguments -#' @export -knit_print.plotly_hash <- function(x, options, ...) { - x <- as.widget(x) - knitr::knit_print(x, options = options, ...) -} - -#' Print a 'built' plotly object in a knitr doc -#' -#' @param x a plotly object -#' @param options knitr options. -#' @param ... additional arguments -#' @export -knit_print.plotly_built <- knit_print.plotly_hash - #' Convert a plotly object to an htmlwidget object #' +#' As of version 4.0.0, plotly objects are now htmlwidget objects, +#' so users shouldn't have to use this function directly. +#' #' @param x a plotly object. #' @param ... other options passed onto \code{htmlwidgets::createWidget} #' @export -#' @examples \dontrun{ -#' p <- plot_ly(mtcars, x = mpg, y = disp, mode = "markers") -#' htmlwidgets::saveWidget(as.widget(p), "index.html") -#' } #' as.widget <- function(x, ...) { if (inherits(x, "htmlwidget")) return(x) - if (!inherits(x, "plotly_built")) x <- plotly_build(x) - # set some margin defaults if none are provided - x$layout$margin <- modifyList( - list(b = 40, l = 60, t = 25, r = 10), - x$layout$margin %||% list() - ) - x$config$modeBarButtonsToRemove <- - i(x$config$modeBarButtonsToRemove %||% "sendDataToCloud") - x$base_url <- get_domain() + # add plotly class mainly for printing method # customize the JSON serializer (for htmlwidgets) attr(x, 'TOJSON_FUNC') <- to_JSON htmlwidgets::createWidget( name = "plotly", x = x, - width = x$width, - height = x$height, + width = x$layout$width, + height = x$layout$height, sizingPolicy = htmlwidgets::sizingPolicy( - padding = 5, browser.fill = TRUE, defaultWidth = '100%', defaultHeight = 400 ), - ... + preRenderHook = plotly_build ) } @@ -81,7 +35,7 @@ toWidget <- as.widget #' @param x a plotly figure object #' @param ... additional arguments (currently ignored) #' @export -print.figure <- function(x, ...) { +print.plotly_figure <- function(x, ...) { utils::browseURL(x$url) } @@ -92,7 +46,7 @@ print.figure <- function(x, ...) { #' @param ... placeholder. #' @export #' @references https://github.com/yihui/knitr/blob/master/vignettes/knit_print.Rmd -knit_print.figure <- function(x, options, ...) { +knit_print.plotly_figure <- function(x, options, ...) { if (!requireNamespace("knitr")) { warning("Please install.packages('knitr')") return(x) diff --git a/R/process.R b/R/process.R index 7f13d59104..864e709c06 100644 --- a/R/process.R +++ b/R/process.R @@ -24,7 +24,7 @@ process.image <- function(resp) { error = function(e) httr::content(resp, as = "raw")) } -process.figure <- function(resp) { +process.plotly_figure <- function(resp) { httr::stop_for_status(resp) con <- from_JSON(content(resp, as = "text")) fig <- con$payload$figure @@ -33,8 +33,7 @@ process.figure <- function(resp) { con$url <- sub("^http[s]?:", "https:", con$url) fig <- add_boxed(fig) fig$data[[1]]$inherit <- FALSE - # any reasonable way to return a data frame? - hash_plot(data.frame(), fig) + as.widget(fig) } process.signup <- function(resp) { diff --git a/R/shiny.R b/R/shiny.R index 4ad38425e2..f377a14b2e 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -25,8 +25,6 @@ plotlyOutput <- function(outputId, width = "100%", height = "400px") { #' @export renderPlotly <- function(expr, env = parent.frame(), quoted = FALSE) { if (!quoted) { expr <- substitute(expr) } # force quoted - # https://github.com/ramnathv/htmlwidgets/issues/166#issuecomment-153000306 - expr <- call("as.widget", expr) shinyRenderWidget(expr, plotlyOutput, env, quoted = TRUE) } diff --git a/R/subplots.R b/R/subplots.R index c3fd97b357..d5fd017e24 100644 --- a/R/subplots.R +++ b/R/subplots.R @@ -236,9 +236,7 @@ subplot <- function(..., nrows = 1, widths = NULL, heights = NULL, margin = 0.02 layouts <- layouts[which_layout] } p$layout <- c(p$layout, Reduce(modifyList, layouts)) - - res <- hash_plot(data.frame(), p) - prefix_class(res, "plotly_subplot") + p } diff --git a/R/sysdata.rda b/R/sysdata.rda new file mode 100644 index 0000000000000000000000000000000000000000..a1dff32fa34ac6eeb4bb75f341261e17c582ebe5 GIT binary patch literal 202 zcmV;*05$(YT4*^jL0KkKS=P3vUH|}J?|}WePyiSJ1ON~~Kj+?H00A%nxok$LXf)F! zOn@31dVtYP)MN&LXaE`sBBs>zN2#>{(0WE{G(EPcGD|r=5g@`8Szn)K+vgj!g=~81 zbzt&Kl0d>t#q)6?Q@f=0la)VVj&KN>ed<*cD2j@IJVdZ0o5=kjhV0=9ASi1XM-?Su zVpj^t*0G8MNo`R*gBC>q(H!KZ8H6-9Ip+o7NhlPW*e)!}%}9}B5zF|yk}1N3hPAai E@H}}{r2qf` literal 0 HcmV?d00001 diff --git a/R/utils.R b/R/utils.R index ab838f958a..8a93b04f37 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,21 +1,13 @@ is.plotly <- function(x) { - inherits(x, c("plotly_hash", "plotly_built", "plotly_subplot")) + inherits(x, "plotly") } -"%||%" <- function(x, y) { - if (length(x) > 0 || is_blank(x)) x else y -} - -# modify %||% so that NA is considered NULL -"%|x|%" <- function(x, y) { - if (length(x) == 1) { - if (is.na(x)) x <- NULL - } - x %||% y +is.formula <- function(f) { + inherits(f, "formula") } -strextract <- function(str, pattern) { - regmatches(str, regexpr(pattern, str)) +"%||%" <- function(x, y) { + if (length(x) > 0 || is_blank(x)) x else y } compact <- function(x) { @@ -26,57 +18,47 @@ is.discrete <- function(x) { is.factor(x) || is.character(x) || is.logical(x) } -# special enviroment that enables NSE -plotlyEnv <- new.env(parent = emptyenv()) +deparse2 <- function(x) paste(deparse(x, 500L), collapse = "") -# hash plot info, assign it to the special plotly environment, & attach it to data -hash_plot <- function(df, p) { - if (missing(df) || is.null(df)) df <- data.frame() - hash <- digest::digest(p) - # terrible hack to ensure we can always find the most recent hash - hash <- paste(hash, length(ls(plotlyEnv)), sep = "#") - assign(hash, p, envir = plotlyEnv) - attr(df, "plotly_hash") <- hash - # add plotly class mainly for printing method - class(df) <- unique(c("plotly_hash", class(df))) - # return a data frame to be compatible with things like dplyr - df +verify_arg <- function(arg) { + if (missing(arg)) return(NULL) + if (!is.formula(arg)) { + stop("Argument must be a formula.") + } + arg } -#' Obtain underlying data of plotly object -#' -#' Given a data frame with a class of plotly, this function returns the arguments -#' and/or data used to create the plotly. If no data frame is provided, -#' the last plotly object created in this R session is returned (if it exists). -#' -#' @param data a data frame with a class of plotly (and a plotly_hash attribute). -#' @param last if no plotly attribute is found, return the last plot or NULL? -get_plot <- function(data = NULL, last = FALSE) { - hash <- attr(data, "plotly_hash") - if (!is.null(hash)) { - get(hash, envir = plotlyEnv) - } else if (last) { - envs <- strsplit(ls(plotlyEnv), "#") - last_env <- ls(plotlyEnv)[which.max(sapply(envs, "[[", 2))] - get(last_env, envir = plotlyEnv) - } else { - data %||% list() +verify_plot <- function(p) { + if (!is.plotly(p)) { + stop("Don't know how to add traces to an object of class:", + class(p), call. = FALSE) + } + p +} + +# make sure trace type is valid +# TODO: add an argument to verify trace properties are valid (https://github.com/ropensci/plotly/issues/540) +verify_type <- function(type = NULL) { + if (is.null(type)) { + message("No trace type specified. Guessing you want a scatter trace") + type <- "scatter" + } + if (!is.character(type) || length(type) != 1) { + stop("The trace type must be a character vector of length 1.\n", + call. = FALSE) } + if (!type %in% traces) { + stop("Trace type must be one of the following: \n", + "'", paste(traces, collapse = "', '"), "'", + call. = FALSE) + } + type } -#' Retrive and create the last plotly (or ggplot). -#' -#' @seealso \link{plotly_build} -#' @param data (optional) a data frame with a class of plotly (and a plotly_hash attribute). -#' @export -last_plot <- function(data = NULL) { - p <- try(get_plot(data, last = TRUE), silent = TRUE) - if (inherits(p, "try-error")) p <- try(ggplotly(), silent = TRUE) - if (inherits(p, "try-error")) stop("The last plot doesn't exist") - structure( - p, - class = unique(c("plotly_hash", class(p))) - ) +# is a given trace type 3d? +is3d <- function(type = NULL) { + type <- type %||% "scatter" + type %in% c("mesh3d", "scatter3d", "surface") } # Check for credentials/configuration and throw warnings where appropriate @@ -249,24 +231,6 @@ plotly_headers <- function(type = "main") { } -perform_eval <- function(x) { - if (should_eval(x)) do_eval(x) else x -} - -# env/enclos are special properties specific to the R API -# if they appear _and_ are environments, then evaluate arguments -# (sometimes figures return these properties but evaluation doesn't make sense) -should_eval <- function(x) { - any(vapply(x[c("env", "enclos")], is.environment, logical(1))) -} - -# perform evaluation of arguments, keeping other list elements -do_eval <- function(x) { - y <- c(x, eval(x$args, as.list(x$env, all.names = TRUE), x$enclos)) - y[c("args", "env", "enclos")] <- NULL - y -} - # try to write environment variables to an .Rprofile cat_profile <- function(key, value, path = "~") { r_profile <- file.path(normalizePath(path, mustWork = TRUE), diff --git a/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js b/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js index 99e0f712f8..08e5b506a7 100644 --- a/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js +++ b/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js @@ -1,44 +1,44 @@ /** -* plotly.js v1.10.1 +* plotly.js v1.11.0 * Copyright 2012-2016, Plotly, Inc. * All rights reserved. * Licensed under the MIT license */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Plotly=t()}}(function(){var t;return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,function(e){var r=t[o][1][e];return i(r?r:e)},u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;or;++r)e[r]=0;return e}function o(t,e,r){switch(arguments.length){case 0:return new i([0],[0],0);case 1:if("number"==typeof t){var n=a(t);return new i(n,n,0)}return new i(t,a(t.length),0);case 2:if("number"==typeof e){var n=a(t.length);return new i(t,n,+e)}r=0;case 3:if(t.length!==e.length)throw new Error("state and velocity lengths must match");return new i(t,e,r)}}e.exports=o;var s=t("cubic-hermite"),l=t("binary-search-bounds"),c=i.prototype;c.flush=function(t){var e=l.gt(this._time,t)-1;0>=e||(this._time.splice(0,e),this._state.splice(0,e*this.dimension),this._velocity.splice(0,e*this.dimension))},c.curve=function(t){var e=this._time,r=e.length,i=l.le(e,t),a=this._scratch[0],o=this._state,c=this._velocity,u=this.dimension,f=this.bounds;if(0>i)for(var h=u-1,d=0;u>d;++d,--h)a[d]=o[h];else if(i>=r-1)for(var h=o.length-1,p=t-e[r-1],d=0;u>d;++d,--h)a[d]=o[h]+p*c[h];else{for(var h=u*(i+1)-1,g=e[i],v=e[i+1],m=v-g||1,y=this._scratch[1],b=this._scratch[2],x=this._scratch[3],_=this._scratch[4],w=!0,d=0;u>d;++d,--h)y[d]=o[h],x[d]=c[h]*m,b[d]=o[h+u],_[d]=c[h+u]*m,w=w&&y[d]===b[d]&&x[d]===_[d]&&0===x[d];if(w)for(var d=0;u>d;++d)a[d]=y[d];else s(y,x,b,_,(t-g)/m,a)}for(var k=f[0],A=f[1],d=0;u>d;++d)a[d]=n(k[d],A[d],a[d]);return a},c.dcurve=function(t){var e=this._time,r=e.length,n=l.le(e,t),i=this._scratch[0],a=this._state,o=this._velocity,c=this.dimension;if(n>=r-1)for(var u=a.length-1,f=(t-e[r-1],0);c>f;++f,--u)i[f]=o[u];else{for(var u=c*(n+1)-1,h=e[n],d=e[n+1],p=d-h||1,g=this._scratch[1],v=this._scratch[2],m=this._scratch[3],y=this._scratch[4],b=!0,f=0;c>f;++f,--u)g[f]=a[u],m[f]=o[u]*p,v[f]=a[u+c],y[f]=o[u+c]*p,b=b&&g[f]===v[f]&&m[f]===y[f]&&0===m[f];if(b)for(var f=0;c>f;++f)i[f]=0;else{s.derivative(g,m,v,y,(t-h)/p,i);for(var f=0;c>f;++f)i[f]/=p}}return i},c.lastT=function(){var t=this._time;return t[t.length-1]},c.stable=function(){for(var t=this._velocity,e=t.length,r=this.dimension-1;r>=0;--r)if(t[--e])return!1;return!0},c.jump=function(t){var e=this.lastT(),r=this.dimension;if(!(e>t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1];this._time.push(e,t);for(var u=0;2>u;++u)for(var f=0;r>f;++f)i.push(i[o++]),a.push(0);this._time.push(t);for(var f=r;f>0;--f)i.push(n(l[f-1],c[f-1],arguments[f])),a.push(0)}},c.push=function(t){var e=this.lastT(),r=this.dimension;if(!(e>t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=t-e,l=this.bounds,c=l[0],u=l[1],f=s>1e-6?1/s:0;this._time.push(t);for(var h=r;h>0;--h){var d=n(c[h-1],u[h-1],arguments[h]);i.push(d),a.push((d-i[o++])*f)}}},c.set=function(t){var e=this.dimension;if(!(t0;--l)r.push(n(o[l-1],s[l-1],arguments[l])),i.push(0)}},c.move=function(t){var e=this.lastT(),r=this.dimension;if(!(e>=t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1],u=t-e,f=u>1e-6?1/u:0;this._time.push(t);for(var h=r;h>0;--h){var d=arguments[h];i.push(n(l[h-1],c[h-1],i[o++]+d)),a.push(d*f)}}},c.idle=function(t){var e=this.lastT();if(!(e>t)){var r=this.dimension,i=this._state,a=this._velocity,o=i.length-r,s=this.bounds,l=s[0],c=s[1],u=t-e;this._time.push(t);for(var f=r-1;f>=0;--f)i.push(n(l[f],c[f],i[o]+u*a[o])),a.push(0),o+=1}}},{"binary-search-bounds":21,"cubic-hermite":22}],21:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],22:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=6*i*i-6*i,s=3*i*i-4*i+1,l=-6*i*i+6*i,c=3*i*i-2*i;if(t.length){a||(a=new Array(t.length));for(var u=t.length-1;u>=0;--u)a[u]=o*t[u]+s*e[u]+l*r[u]+c*n[u];return a}return o*t+s*e+l*r[u]+c*n}function i(t,e,r,n,i,a){var o=i-1,s=i*i,l=o*o,c=(1+2*i)*l,u=i*l,f=s*(3-2*i),h=s*o;if(t.length){a||(a=new Array(t.length));for(var d=t.length-1;d>=0;--d)a[d]=c*t[d]+u*e[d]+f*r[d]+h*n[d];return a}return c*t+u*e+f*r+h*n}e.exports=i,e.exports.derivative=n},{}],23:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=i*l-a*s,t[1]=a*o-n*l,t[2]=n*s-i*o,t}e.exports=n},{}],24:[function(t,e,r){function n(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}e.exports=n},{}],25:[function(t,e,r){function n(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}e.exports=n},{}],26:[function(t,e,r){function n(t,e,r,n){var i=e[0],a=e[1],o=e[2];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t}e.exports=n},{}],27:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t}e.exports=n},{}],28:[function(t,e,r){"use strict";function n(t){this._components=t.slice(),this._time=[0],this.prevMatrix=t.slice(),this.nextMatrix=t.slice(),this.computedMatrix=t.slice(),this.computedInverse=t.slice(),this.computedEye=[0,0,0],this.computedUp=[0,0,0],this.computedCenter=[0,0,0],this.computedRadius=[0],this._limits=[-(1/0),1/0]}function i(t){t=t||{};var e=t.matrix||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return new n(e)}var a=t("binary-search-bounds"),o=t("mat4-interpolate"),s=t("gl-mat4/invert"),l=t("gl-mat4/rotateX"),c=t("gl-mat4/rotateY"),u=t("gl-mat4/rotateZ"),f=t("gl-mat4/lookAt"),h=t("gl-mat4/translate"),d=(t("gl-mat4/scale"),t("gl-vec3/normalize")),p=[0,0,0];e.exports=i;var g=n.prototype;g.recalcMatrix=function(t){var e=this._time,r=a.le(e,t),n=this.computedMatrix;if(!(0>r)){var i=this._components;if(r===e.length-1)for(var l=16*r,c=0;16>c;++c)n[c]=i[l++];else{for(var u=e[r+1]-e[r],l=16*r,f=this.prevMatrix,h=!0,c=0;16>c;++c)f[c]=i[l++];for(var p=this.nextMatrix,c=0;16>c;++c)p[c]=i[l++],h=h&&f[c]===p[c];if(1e-6>u||h)for(var c=0;16>c;++c)n[c]=f[c];else o(n,f,p,(t-e[r])/u)}var g=this.computedUp;g[0]=n[1],g[1]=n[5],g[2]=n[6],d(g,g);var v=this.computedInverse;s(v,n);var m=this.computedEye,y=v[15];m[0]=v[12]/y,m[1]=v[13]/y,m[2]=v[14]/y;for(var b=this.computedCenter,x=Math.exp(this.computedRadius[0]),c=0;3>c;++c)b[c]=m[c]-n[2+4*c]*x}},g.idle=function(t){if(!(tn;++n)e.push(e[r++]);this._time.push(t)}},g.flush=function(t){var e=a.gt(this._time,t)-2;0>e||(this._time.slice(0,e),this._components.slice(0,16*e))},g.lastT=function(){return this._time[this._time.length-1]},g.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||p,n=n||this.computedUp,this.setMatrix(t,f(this.computedMatrix,e,r,n));for(var i=0,a=0;3>a;++a)i+=Math.pow(r[a]-e[a],2);i=Math.log(Math.sqrt(i)),this.computedRadius[0]=i},g.rotate=function(t,e,r,n){this.recalcMatrix(t);var i=this.computedInverse;e&&c(i,i,e),r&&l(i,i,r),n&&u(i,i,n),this.setMatrix(t,s(this.computedMatrix,i))};var v=[0,0,0];g.pan=function(t,e,r,n){v[0]=-(e||0),v[1]=-(r||0),v[2]=-(n||0),this.recalcMatrix(t);var i=this.computedInverse;h(i,i,v),this.setMatrix(t,s(i,i))},g.translate=function(t,e,r,n){v[0]=e||0,v[1]=r||0,v[2]=n||0,this.recalcMatrix(t);var i=this.computedMatrix;h(i,i,v),this.setMatrix(t,i)},g.setMatrix=function(t,e){if(!(tr;++r)this._components.push(e[r])}},g.setDistance=function(t,e){this.computedRadius[0]=e},g.setDistanceLimits=function(t,e){var r=this._limits;r[0]=t,r[1]=e},g.getDistanceLimits=function(t){var e=this._limits;return t?(t[0]=e[0],t[1]=e[1],t):e}},{"binary-search-bounds":29,"gl-mat4/invert":96,"gl-mat4/lookAt":97,"gl-mat4/rotateX":101,"gl-mat4/rotateY":102,"gl-mat4/rotateZ":103,"gl-mat4/scale":104,"gl-mat4/translate":105,"gl-vec3/normalize":27,"mat4-interpolate":30}],29:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],30:[function(t,e,r){function n(t,e,r,n){if(0===u(e)||0===u(r))return!1;var i=c(e,h.translate,h.scale,h.skew,h.perspective,h.quaternion),a=c(r,d.translate,d.scale,d.skew,d.perspective,d.quaternion);return i&&a?(s(p.translate,h.translate,d.translate,n),s(p.skew,h.skew,d.skew,n),s(p.scale,h.scale,d.scale,n),s(p.perspective,h.perspective,d.perspective,n),f(p.quaternion,h.quaternion,d.quaternion,n),l(t,p.translate,p.scale,p.skew,p.perspective,p.quaternion),!0):!1}function i(){return{translate:a(),scale:a(1),skew:a(),perspective:o(),quaternion:o()}}function a(t){return[t||0,t||0,t||0]}function o(){return[0,0,0,1]}var s=t("gl-vec3/lerp"),l=t("mat4-recompose"),c=t("mat4-decompose"),u=t("gl-mat4/determinant"),f=t("quat-slerp"),h=i(),d=i(),p=i();e.exports=n},{"gl-mat4/determinant":92,"gl-vec3/lerp":26,"mat4-decompose":31,"mat4-recompose":33,"quat-slerp":34}],31:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}function i(t,e){t[0][0]=e[0],t[0][1]=e[1],t[0][2]=e[2],t[1][0]=e[4],t[1][1]=e[5],t[1][2]=e[6],t[2][0]=e[8],t[2][1]=e[9],t[2][2]=e[10]}function a(t,e,r,n,i){t[0]=e[0]*n+r[0]*i,t[1]=e[1]*n+r[1]*i,t[2]=e[2]*n+r[2]*i}var o=t("./normalize"),s=t("gl-mat4/create"),l=t("gl-mat4/clone"),c=t("gl-mat4/determinant"),u=t("gl-mat4/invert"),f=t("gl-mat4/transpose"),h={length:t("gl-vec3/length"),normalize:t("gl-vec3/normalize"),dot:t("gl-vec3/dot"),cross:t("gl-vec3/cross")},d=s(),p=s(),g=[0,0,0,0],v=[[0,0,0],[0,0,0],[0,0,0]],m=[0,0,0];e.exports=function(t,e,r,s,y,b){if(e||(e=[0,0,0]),r||(r=[0,0,0]),s||(s=[0,0,0]),y||(y=[0,0,0,1]),b||(b=[0,0,0,1]),!o(d,t))return!1;if(l(p,d),p[3]=0,p[7]=0,p[11]=0,p[15]=1,Math.abs(c(p)<1e-8))return!1;var x=d[3],_=d[7],w=d[11],k=d[12],A=d[13],M=d[14],T=d[15];if(0!==x||0!==_||0!==w){g[0]=x,g[1]=_,g[2]=w,g[3]=T;var E=u(p,p);if(!E)return!1;f(p,p),n(y,g,p)}else y[0]=y[1]=y[2]=0,y[3]=1;if(e[0]=k,e[1]=A,e[2]=M,i(v,d),r[0]=h.length(v[0]),h.normalize(v[0],v[0]),s[0]=h.dot(v[0],v[1]),a(v[1],v[1],v[0],1,-s[0]),r[1]=h.length(v[1]),h.normalize(v[1],v[1]),s[0]/=r[1],s[1]=h.dot(v[0],v[2]),a(v[2],v[2],v[0],1,-s[1]),s[2]=h.dot(v[1],v[2]),a(v[2],v[2],v[1],1,-s[2]),r[2]=h.length(v[2]),h.normalize(v[2],v[2]),s[1]/=r[2],s[2]/=r[2],h.cross(m,v[1],v[2]),h.dot(v[0],m)<0)for(var L=0;3>L;L++)r[L]*=-1,v[L][0]*=-1,v[L][1]*=-1,v[L][2]*=-1;return b[0]=.5*Math.sqrt(Math.max(1+v[0][0]-v[1][1]-v[2][2],0)),b[1]=.5*Math.sqrt(Math.max(1-v[0][0]+v[1][1]-v[2][2],0)),b[2]=.5*Math.sqrt(Math.max(1-v[0][0]-v[1][1]+v[2][2],0)),b[3]=.5*Math.sqrt(Math.max(1+v[0][0]+v[1][1]+v[2][2],0)),v[2][1]>v[1][2]&&(b[0]=-b[0]),v[0][2]>v[2][0]&&(b[1]=-b[1]),v[1][0]>v[0][1]&&(b[2]=-b[2]),!0}},{"./normalize":32,"gl-mat4/clone":90,"gl-mat4/create":91,"gl-mat4/determinant":92,"gl-mat4/invert":96,"gl-mat4/transpose":106,"gl-vec3/cross":23,"gl-vec3/dot":24,"gl-vec3/length":25,"gl-vec3/normalize":27}],32:[function(t,e,r){e.exports=function(t,e){var r=e[15];if(0===r)return!1;for(var n=1/r,i=0;16>i;i++)t[i]=e[i]*n;return!0}},{}],33:[function(t,e,r){var n={identity:t("gl-mat4/identity"),translate:t("gl-mat4/translate"),multiply:t("gl-mat4/multiply"),create:t("gl-mat4/create"),scale:t("gl-mat4/scale"),fromRotationTranslation:t("gl-mat4/fromRotationTranslation")},i=(n.create(),n.create());e.exports=function(t,e,r,a,o,s){return n.identity(t),n.fromRotationTranslation(t,s,e),t[3]=o[0],t[7]=o[1],t[11]=o[2],t[15]=o[3],n.identity(i),0!==a[2]&&(i[9]=a[2],n.multiply(t,t,i)),0!==a[1]&&(i[9]=0,i[8]=a[1],n.multiply(t,t,i)),0!==a[0]&&(i[8]=0,i[4]=a[0],n.multiply(t,t,i)),n.scale(t,t,r),t}},{"gl-mat4/create":91,"gl-mat4/fromRotationTranslation":94,"gl-mat4/identity":95,"gl-mat4/multiply":98,"gl-mat4/scale":104,"gl-mat4/translate":105}],34:[function(t,e,r){e.exports=t("gl-quat/slerp")},{"gl-quat/slerp":35}],35:[function(t,e,r){function n(t,e,r,n){var i,a,o,s,l,c=e[0],u=e[1],f=e[2],h=e[3],d=r[0],p=r[1],g=r[2],v=r[3];return a=c*d+u*p+f*g+h*v,0>a&&(a=-a,d=-d,p=-p,g=-g,v=-v),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n),t[0]=s*c+l*d,t[1]=s*u+l*p,t[2]=s*f+l*g,t[3]=s*h+l*v,t}e.exports=n},{}],36:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c){var u=e+a+c;if(f>0){var f=Math.sqrt(u+1);t[0]=.5*(o-l)/f,t[1]=.5*(s-n)/f,t[2]=.5*(r-a)/f,t[3]=.5*f}else{var h=Math.max(e,a,c),f=Math.sqrt(2*h-u+1);e>=h?(t[0]=.5*f,t[1]=.5*(i+r)/f,t[2]=.5*(s+n)/f,t[3]=.5*(o-l)/f):a>=h?(t[0]=.5*(r+i)/f,t[1]=.5*f,t[2]=.5*(l+o)/f,t[3]=.5*(s-n)/f):(t[0]=.5*(n+s)/f,t[1]=.5*(o+l)/f,t[2]=.5*f,t[3]=.5*(r-i)/f)}return t}e.exports=n},{}],37:[function(t,e,r){"use strict";function n(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function i(t,e,r,n){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2)+Math.pow(n,2))}function a(t,e){var r=e[0],n=e[1],a=e[2],o=e[3],s=i(r,n,a,o);s>1e-6?(t[0]=r/s,t[1]=n/s,t[2]=a/s,t[3]=o/s):(t[0]=t[1]=t[2]=0,t[3]=1)}function o(t,e,r){this.radius=l([r]),this.center=l(e),this.rotation=l(t),this.computedRadius=this.radius.curve(0),this.computedCenter=this.center.curve(0),this.computedRotation=this.rotation.curve(0),this.computedUp=[.1,0,0],this.computedEye=[.1,0,0],this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.recalcMatrix(0)}function s(t){t=t||{};var e=t.center||[0,0,0],r=t.rotation||[0,0,0,1],n=t.radius||1;e=[].slice.call(e,0,3),r=[].slice.call(r,0,4),a(r,r);var i=new o(r,e,Math.log(n));return i.setDistanceLimits(t.zoomMin,t.zoomMax),("eye"in t||"up"in t)&&i.lookAt(0,t.eye,t.center,t.up),i}e.exports=s;var l=t("filtered-vector"),c=t("gl-mat4/lookAt"),u=t("gl-mat4/fromQuat"),f=t("gl-mat4/invert"),h=t("./lib/quatFromFrame"),d=o.prototype;d.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())},d.recalcMatrix=function(t){this.radius.curve(t),this.center.curve(t),this.rotation.curve(t);var e=this.computedRotation;a(e,e);var r=this.computedMatrix;u(r,e);var n=this.computedCenter,i=this.computedEye,o=this.computedUp,s=Math.exp(this.computedRadius[0]);i[0]=n[0]+s*r[2],i[1]=n[1]+s*r[6],i[2]=n[2]+s*r[10],o[0]=r[1],o[1]=r[5],o[2]=r[9];for(var l=0;3>l;++l){for(var c=0,f=0;3>f;++f)c+=r[l+4*f]*i[f];r[12+l]=-c}},d.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;16>n;++n)e[n]=r[n];return e}return r},d.idle=function(t){this.center.idle(t),this.radius.idle(t),this.rotation.idle(t)},d.flush=function(t){this.center.flush(t),this.radius.flush(t),this.rotation.flush(t)},d.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=a[1],s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],f=a[4],h=a[8],d=u*o+f*s+h*l;u-=o*d,f-=s*d,h-=l*d;var p=n(u,f,h);u/=p,f/=p,h/=p;var g=a[2],v=a[6],m=a[10],y=g*o+v*s+m*l,b=g*u+v*f+m*h;g-=y*o+b*u,v-=y*s+b*f,m-=y*l+b*h;var x=n(g,v,m);g/=x,v/=x,m/=x;var _=u*e+o*r,w=f*e+s*r,k=h*e+l*r;this.center.move(t,_,w,k);var A=Math.exp(this.computedRadius[0]);A=Math.max(1e-4,A+i),this.radius.set(t,Math.log(A))},d.rotate=function(t,e,r,a){this.recalcMatrix(t),e=e||0,r=r||0;var o=this.computedMatrix,s=o[0],l=o[4],c=o[8],u=o[1],f=o[5],h=o[9],d=o[2],p=o[6],g=o[10],v=e*s+r*u,m=e*l+r*f,y=e*c+r*h,b=-(p*y-g*m),x=-(g*v-d*y),_=-(d*m-p*v),w=Math.sqrt(Math.max(0,1-Math.pow(b,2)-Math.pow(x,2)-Math.pow(_,2))),k=i(b,x,_,w);k>1e-6?(b/=k,x/=k,_/=k,w/=k):(b=x=_=0,w=1);var A=this.computedRotation,M=A[0],T=A[1],E=A[2],L=A[3],S=M*w+L*b+T*_-E*x,C=T*w+L*x+E*b-M*_,z=E*w+L*_+M*x-T*b,P=L*w-M*b-T*x-E*_;if(a){b=d,x=p,_=g;var R=Math.sin(a)/n(b,x,_);b*=R,x*=R,_*=R,w=Math.cos(e),S=S*w+P*b+C*_-z*x,C=C*w+P*x+z*b-S*_,z=z*w+P*_+S*x-C*b,P=P*w-S*b-C*x-z*_}var O=i(S,C,z,P);O>1e-6?(S/=O,C/=O,z/=O,P/=O):(S=C=z=0,P=1),this.rotation.set(t,S,C,z,P)},d.lookAt=function(t,e,r,n){this.recalcMatrix(t),r=r||this.computedCenter,e=e||this.computedEye,n=n||this.computedUp;var i=this.computedMatrix;c(i,e,r,n);var o=this.computedRotation;h(o,i[0],i[1],i[2],i[4],i[5],i[6],i[8],i[9],i[10]),a(o,o),this.rotation.set(t,o[0],o[1],o[2],o[3]);for(var s=0,l=0;3>l;++l)s+=Math.pow(r[l]-e[l],2);this.radius.set(t,.5*Math.log(Math.max(s,1e-6))),this.center.set(t,r[0],r[1],r[2])},d.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},d.setMatrix=function(t,e){var r=this.computedRotation;h(r,e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]),a(r,r),this.rotation.set(t,r[0],r[1],r[2],r[3]);var n=this.computedMatrix;f(n,e);var i=n[15];if(Math.abs(i)>1e-6){var o=n[12]/i,s=n[13]/i,l=n[14]/i;this.recalcMatrix(t);var c=Math.exp(this.computedRadius[0]);this.center.set(t,o-n[2]*c,s-n[6]*c,l-n[10]*c),this.radius.idle(t)}else this.center.idle(t),this.radius.idle(t)},d.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},d.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-(1/0),e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},d.getDistanceLimits=function(t){var e=this.radius.bounds; -return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},d.toJSON=function(){return this.recalcMatrix(this.lastT()),{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}},d.fromJSON=function(t){var e=this.lastT(),r=t.center;r&&this.center.set(e,r[0],r[1],r[2]);var n=t.rotation;n&&this.rotation.set(e,n[0],n[1],n[2],n[3]);var i=t.distance;i&&i>0&&this.radius.set(e,Math.log(i)),this.setDistanceLimits(t.zoomMin,t.zoomMax)}},{"./lib/quatFromFrame":36,"filtered-vector":20,"gl-mat4/fromQuat":93,"gl-mat4/invert":96,"gl-mat4/lookAt":97}],38:[function(t,e,r){"use strict";function n(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function i(t){return Math.min(1,Math.max(-1,t))}function a(t){var e=Math.abs(t[0]),r=Math.abs(t[1]),n=Math.abs(t[2]),i=[0,0,0];e>Math.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,s=0;3>s;++s)a+=t[s]*t[s],o+=i[s]*t[s];for(var s=0;3>s;++s)i[s]-=o/a*t[s];return h(i,i),i}function o(t,e,r,n,i,a,o,s){this.center=l(r),this.up=l(n),this.right=l(i),this.radius=l([a]),this.angle=l([o,s]),this.angle.bounds=[[-(1/0),-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var c=0;16>c;++c)this.computedMatrix[c]=.5;this.recalcMatrix(0)}function s(t){t=t||{};var e=t.center||[0,0,0],r=t.up||[0,1,0],i=t.right||a(r),s=t.radius||1,l=t.theta||0,c=t.phi||0;if(e=[].slice.call(e,0,3),r=[].slice.call(r,0,3),h(r,r),i=[].slice.call(i,0,3),h(i,i),"eye"in t){var u=t.eye,p=[u[0]-e[0],u[1]-e[1],u[2]-e[2]];f(i,p,r),n(i[0],i[1],i[2])<1e-6?i=a(r):h(i,i),s=n(p[0],p[1],p[2]);var g=d(r,p)/s,v=d(i,p)/s;c=Math.acos(g),l=Math.acos(v)}return s=Math.log(s),new o(t.zoomMin,t.zoomMax,e,r,i,s,l,c)}e.exports=s;var l=t("filtered-vector"),c=t("gl-mat4/invert"),u=t("gl-mat4/rotate"),f=t("gl-vec3/cross"),h=t("gl-vec3/normalize"),d=t("gl-vec3/dot"),p=o.prototype;p.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-(1/0),e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},p.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},p.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,i=0,a=0,o=0;3>o;++o)a+=e[o]*r[o],i+=e[o]*e[o];for(var s=Math.sqrt(i),l=0,o=0;3>o;++o)r[o]-=e[o]*a/i,l+=r[o]*r[o],e[o]/=s;for(var c=Math.sqrt(l),o=0;3>o;++o)r[o]/=c;var u=this.computedToward;f(u,e,r),h(u,u);for(var d=Math.exp(this.computedRadius[0]),p=this.computedAngle[0],g=this.computedAngle[1],v=Math.cos(p),m=Math.sin(p),y=Math.cos(g),b=Math.sin(g),x=this.computedCenter,_=v*y,w=m*y,k=b,A=-v*b,M=-m*b,T=y,E=this.computedEye,L=this.computedMatrix,o=0;3>o;++o){var S=_*r[o]+w*u[o]+k*e[o];L[4*o+1]=A*r[o]+M*u[o]+T*e[o],L[4*o+2]=S,L[4*o+3]=0}var C=L[1],z=L[5],P=L[9],R=L[2],O=L[6],I=L[10],N=z*I-P*O,j=P*R-C*I,F=C*O-z*R,D=n(N,j,F);N/=D,j/=D,F/=D,L[0]=N,L[4]=j,L[8]=F;for(var o=0;3>o;++o)E[o]=x[o]+L[2+4*o]*d;for(var o=0;3>o;++o){for(var l=0,B=0;3>B;++B)l+=L[o+4*B]*E[B];L[12+o]=-l}L[15]=1},p.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;16>n;++n)e[n]=r[n];return e}return r};var g=[0,0,0];p.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;g[0]=i[2],g[1]=i[6],g[2]=i[10];for(var a=this.computedUp,o=this.computedRight,s=this.computedToward,l=0;3>l;++l)i[4*l]=a[l],i[4*l+1]=o[l],i[4*l+2]=s[l];u(i,i,n,g);for(var l=0;3>l;++l)a[l]=i[4*l],o[l]=i[4*l+1];this.up.set(t,a[0],a[1],a[2]),this.right.set(t,o[0],o[1],o[2])}},p.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=(Math.exp(this.computedRadius[0]),a[1]),s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],f=a[4],h=a[8],d=u*o+f*s+h*l;u-=o*d,f-=s*d,h-=l*d;var p=n(u,f,h);u/=p,f/=p,h/=p;var g=u*e+o*r,v=f*e+s*r,m=h*e+l*r;this.center.move(t,g,v,m);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+i),this.radius.set(t,Math.log(y))},p.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},p.setMatrix=function(t,e,r,a){var o=1;"number"==typeof r&&(o=0|r),(0>o||o>3)&&(o=1);var s=(o+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var l=e[o],u=e[o+4],f=e[o+8];if(a){var h=Math.abs(l),d=Math.abs(u),p=Math.abs(f),g=Math.max(h,d,p);h===g?(l=0>l?-1:1,u=f=0):p===g?(f=0>f?-1:1,l=u=0):(u=0>u?-1:1,l=f=0)}else{var v=n(l,u,f);l/=v,u/=v,f/=v}var m=e[s],y=e[s+4],b=e[s+8],x=m*l+y*u+b*f;m-=l*x,y-=u*x,b-=f*x;var _=n(m,y,b);m/=_,y/=_,b/=_;var w=u*b-f*y,k=f*m-l*b,A=l*y-u*m,M=n(w,k,A);w/=M,k/=M,A/=M,this.center.jump(t,H,G,Y),this.radius.idle(t),this.up.jump(t,l,u,f),this.right.jump(t,m,y,b);var T,E;if(2===o){var L=e[1],S=e[5],C=e[9],z=L*m+S*y+C*b,P=L*w+S*k+C*A;T=0>N?-Math.PI/2:Math.PI/2,E=Math.atan2(P,z)}else{var R=e[2],O=e[6],I=e[10],N=R*l+O*u+I*f,j=R*m+O*y+I*b,F=R*w+O*k+I*A;T=Math.asin(i(N)),E=Math.atan2(F,j)}this.angle.jump(t,E,T),this.recalcMatrix(t);var D=e[2],B=e[6],U=e[10],V=this.computedMatrix;c(V,e);var q=V[15],H=V[12]/q,G=V[13]/q,Y=V[14]/q,X=Math.exp(this.computedRadius[0]);this.center.jump(t,H-D*X,G-B*X,Y-U*X)},p.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},p.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},p.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},p.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},p.lookAt=function(t,e,r,a){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter,a=a||this.computedUp;var o=a[0],s=a[1],l=a[2],c=n(o,s,l);if(!(1e-6>c)){o/=c,s/=c,l/=c;var u=e[0]-r[0],f=e[1]-r[1],h=e[2]-r[2],d=n(u,f,h);if(!(1e-6>d)){u/=d,f/=d,h/=d;var p=this.computedRight,g=p[0],v=p[1],m=p[2],y=o*g+s*v+l*m;g-=y*o,v-=y*s,m-=y*l;var b=n(g,v,m);if(!(.01>b&&(g=s*h-l*f,v=l*u-o*h,m=o*f-s*u,b=n(g,v,m),1e-6>b))){g/=b,v/=b,m/=b,this.up.set(t,o,s,l),this.right.set(t,g,v,m),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(d));var x=s*m-l*v,_=l*g-o*m,w=o*v-s*g,k=n(x,_,w);x/=k,_/=k,w/=k;var A=o*u+s*f+l*h,M=g*u+v*f+m*h,T=x*u+_*f+w*h,E=Math.asin(i(A)),L=Math.atan2(T,M),S=this.angle._state,C=S[S.length-1],z=S[S.length-2];C%=2*Math.PI;var P=Math.abs(C+2*Math.PI-L),R=Math.abs(C-L),O=Math.abs(C-2*Math.PI-L);R>P&&(C+=2*Math.PI),R>O&&(C-=2*Math.PI),this.angle.jump(this.angle.lastT(),C,z),this.angle.set(t,L,E)}}}}},{"filtered-vector":20,"gl-mat4/invert":96,"gl-mat4/rotate":100,"gl-vec3/cross":23,"gl-vec3/dot":24,"gl-vec3/normalize":27}],39:[function(t,e,r){"use strict";function n(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map(function(e){return t[e]}),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.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}function i(t){t=t||{};var e=t.eye||[0,0,1],r=t.center||[0,0,0],i=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],c=t.mode||"turntable",u=a(),f=o(),h=s();return u.setDistanceLimits(l[0],l[1]),u.lookAt(0,e,r,i),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,i),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,i),new n({turntable:u,orbit:f,matrix:h},c)}e.exports=i;var a=t("turntable-camera-controller"),o=t("orbit-camera-controller"),s=t("matrix-camera-controller"),l=n.prototype,c=[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]];c.forEach(function(t){for(var e=t[0],r=[],n=0;ne)){var r=this._active,n=this._controllerList[e],i=Math.max(r.lastT(),n.lastT());r.recalcMatrix(i),n.setMatrix(i,r.computedMatrix),this._active=n,this._mode=t,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}}},l.getMode=function(){return this._mode}},{"matrix-camera-controller":28,"orbit-camera-controller":37,"turntable-camera-controller":38}],40:[function(t,e,r){function n(t,e){return a(i(t,e))}e.exports=n;var i=t("alpha-complex"),a=t("simplicial-complex-boundary")},{"alpha-complex":41,"simplicial-complex-boundary":44}],41:[function(t,e,r){"use strict";function n(t,e){return i(e).filter(function(r){for(var n=new Array(r.length),i=0;ii;++i)r+=t[i]*e[i];return r}function i(t){var e=t.length;if(0===e)return[];var r=(t[0].length,o([t.length+1,t.length+1],1)),i=o([t.length+1],1);r[e][e]=0;for(var a=0;e>a;++a){for(var l=0;a>=l;++l)r[l][a]=r[a][l]=2*n(t[a],t[l]);i[a]=n(t[a],t[a])}for(var c=s(r,i),u=0,f=c[e+1],a=0;aa;++a){for(var f=c[a],d=0,l=0;ls;++s)r[s]+=t[a][s]*n[a];return r}var o=t("dup"),s=t("robust-linear-solve");a.barycenetric=i,e.exports=a},{dup:74,"robust-linear-solve":215}],44:[function(t,e,r){"use strict";function n(t){return a(i(t))}e.exports=n;var i=t("boundary-cells"),a=t("reduce-simplicial-complex")},{"boundary-cells":45,"reduce-simplicial-complex":48}],45:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=0,n=0;e>n;++n)r+=t[n].length;for(var i=new Array(r),a=0,n=0;e>n;++n)for(var o=t[n],s=o.length,l=0;s>l;++l)for(var c=i[a++]=new Array(s-1),u=1;s>u;++u)c[u-1]=o[(l+u)%s];return i}e.exports=n},{}],46:[function(t,e,r){"use strict";function n(t){for(var e=1,r=1;rn;++n)if(t[r]n;++n){var s=t[n],l=o(s);if(0!==l){if(r>0){var c=t[r-1];if(0===i(s,c)&&o(c)!==l){r-=1;continue}}t[r++]=s}}return t.length=r,t}var i=t("compare-cell"),a=t("compare-oriented-cell"),o=t("cell-orientation");e.exports=n},{"cell-orientation":46,"compare-cell":60,"compare-oriented-cell":47}],49:[function(t,e,r){"use strict";var n=function(){function t(t){return!Array.isArray(t)&&null!==t&&"object"==typeof t}function e(t,e,r){for(var n=(e-t)/Math.max(r-1,1),i=[],a=0;r>a;a++)i.push(t+a*n);return i}function r(){for(var t=[].slice.call(arguments),e=t.map(function(t){return t.length}),r=Math.min.apply(null,e),n=[],i=0;r>i;i++){n[i]=[];for(var a=0;aa;a++)i.push([t[a],e[a],r[a]]);return i}function i(t){function e(t){for(var n=0;n>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3])),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}function c(t,e){var r,n;if("string"!=typeof t)return t;if(r=[],"#"===t[0]?(t=t.substr(1),3===t.length&&(t+=t),n=parseInt(t,16),r[0]=n>>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3]),n[4]?r[3]=parseFloat(n[4]):r[3]=1),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}var u={},f=/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,.*)?\)$/,h=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,?\s*(.*)?\)$/;return u.isPlainObject=t,u.linspace=e,u.zip3=n,u.sum=i,u.zip=r,u.isEqual=s,u.copy2D=a,u.copy1D=o,u.str2RgbArray=l,u.str2RgbaArray=c,u};e.exports=n()},{}],50:[function(t,e,r){"use strict";"use restrict";function n(t){var e=32;return t&=-t,t&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}var i=32;r.INT_BITS=i,r.INT_MAX=2147483647,r.INT_MIN=-1<0)-(0>t)},r.abs=function(t){var e=t>>i-1;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(e>t)},r.max=function(t,e){return t^(t^e)&-(e>t)},r.isPow2=function(t){return!(t&t-1||!t)},r.log2=function(t){var e,r;return e=(t>65535)<<4,t>>>=e,r=(t>255)<<3,t>>>=r,e|=r,r=(t>15)<<2,t>>>=r,e|=r,r=(t>3)<<1,t>>>=r,e|=r,e|t>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return t-=t>>>1&1431655765,t=(858993459&t)+(t>>>2&858993459),16843009*(t+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,t&=15,27030>>>t&1};var a=new Array(256);!function(t){for(var e=0;256>e;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|a[t>>>16&255]<<8|a[t>>>24&255]},r.interleave2=function(t,e){return t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},r.deinterleave2=function(t,e){return t=t>>>e&1431655765,t=858993459&(t|t>>>1),t=252645135&(t|t>>>2),t=16711935&(t|t>>>4),t=65535&(t|t>>>16),t<<16>>16},r.interleave3=function(t,e,r){return t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t|=e<<1,r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),t|r<<2},r.deinterleave3=function(t,e){return t=t>>>e&1227133513,t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),t=1023&(t|t>>>16),t<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],51:[function(t,e,r){(function(e){"use strict";function n(){try{var t=new Uint8Array(1);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function i(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t){return this instanceof a?(a.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?o(this,t):"string"==typeof t?s(this,t,arguments.length>1?arguments[1]:"utf8"):l(this,t)):arguments.length>1?new a(t,arguments[1]):new a(t)}function o(t,e){if(t=g(t,0>e?0:0|v(e)),!a.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;r++)t[r]=0;return t}function s(t,e,r){"string"==typeof r&&""!==r||(r="utf8");var n=0|y(e,r);return t=g(t,n),t.write(e,r),t}function l(t,e){if(a.isBuffer(e))return c(t,e);if(K(e))return u(t,e);if(null==e)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(e.buffer instanceof ArrayBuffer)return f(t,e);if(e instanceof ArrayBuffer)return h(t,e)}return e.length?d(t,e):p(t,e)}function c(t,e){var r=0|v(e.length);return t=g(t,r),e.copy(t,0,0,r),t}function u(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function f(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function h(t,e){return e.byteLength,a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=a.prototype):t=f(t,new Uint8Array(e)),t}function d(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function p(t,e){var r,n=0;"Buffer"===e.type&&K(e.data)&&(r=e.data,n=0|v(r.length)),t=g(t,n);for(var i=0;n>i;i+=1)t[i]=255&r[i];return t}function g(t,e){a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=a.prototype):t.length=e;var r=0!==e&&e<=a.poolSize>>>1;return r&&(t.parent=Q),t}function v(t){if(t>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function m(t,e){if(!(this instanceof m))return new m(t,e);var r=new a(t,e);return delete r.parent,r}function y(t,e){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(t).length;default:if(n)return q(t).length;e=(""+e).toLowerCase(),n=!0}}function b(t,e,r){var n=!1;if(e=0|e,r=void 0===r||r===1/0?this.length:0|r,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return z(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return S(this,e,r);case"binary":return C(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function x(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=e.length;if(a%2!==0)throw new Error("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;n>o;o++){var s=parseInt(e.substr(2*o,2),16);if(isNaN(s))throw new Error("Invalid hex string");t[r+o]=s}return o}function _(t,e,r,n){return X(q(e,t.length-r),t,r,n)}function w(t,e,r,n){return X(H(e),t,r,n)}function k(t,e,r,n){return w(t,e,r,n)}function A(t,e,r,n){return X(Y(e),t,r,n)}function M(t,e,r,n){return X(G(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;r>i;){var a=t[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(r>=i+s){var l,c,u,f;switch(s){case 1:128>a&&(o=a);break;case 2:l=t[i+1],128===(192&l)&&(f=(31&a)<<6|63&l,f>127&&(o=f));break;case 3:l=t[i+1],c=t[i+2],128===(192&l)&&128===(192&c)&&(f=(15&a)<<12|(63&l)<<6|63&c,f>2047&&(55296>f||f>57343)&&(o=f));break;case 4:l=t[i+1],c=t[i+2],u=t[i+3],128===(192&l)&&128===(192&c)&&128===(192&u)&&(f=(15&a)<<18|(63&l)<<12|(63&c)<<6|63&u,f>65535&&1114112>f&&(o=f))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return L(n)}function L(t){var e=t.length;if($>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=$));return r}function S(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function C(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function z(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",a=e;r>a;a++)i+=V(t[a]);return i}function P(t,e,r){for(var n=t.slice(e,r),i="",a=0;at)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!a.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>i||o>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range")}function I(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,a=Math.min(t.length-r,2);a>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function N(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,a=Math.min(t.length-r,4);a>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function j(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function F(t,e,r,n,i){return i||j(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,i){return i||j(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(t,e,r,n,52,8),r+8}function B(t){if(t=U(t).replace(J,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function U(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function V(t){return 16>t?"0"+t.toString(16):t.toString(16)}function q(t,e){e=e||1/0;for(var r,n=t.length,i=null,a=[],o=0;n>o;o++){if(r=t.charCodeAt(o),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,128>r){if((e-=1)<0)break;a.push(r)}else if(2048>r){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function H(t){for(var e=[],r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function Y(t){return W.toByteArray(B(t))}function X(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}var W=t("base64-js"),Z=t("ieee754"),K=t("isarray");r.Buffer=a,r.SlowBuffer=m,r.INSPECT_MAX_BYTES=50,a.poolSize=8192;var Q={};a.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),a._augment=function(t){return t.__proto__=a.prototype,t},a.TYPED_ARRAY_SUPPORT?(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})):(a.prototype.length=void 0,a.prototype.parent=void 0),a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,e){if(!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);o>i&&t[i]===e[i];)++i;return i!==o&&(r=t[i],n=e[i]),n>r?-1:r>n?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!K(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new a(0);var r;if(void 0===e)for(e=0,r=0;r0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},a.prototype.compare=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:a.compare(this,t)},a.prototype.indexOf=function(t,e){function r(t,e,r){for(var n=-1,i=0;r+i2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,e);if(a.isBuffer(t))return r(this,t,e);if("number"==typeof t)return a.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):r(this,[t],e);throw new TypeError("val must be string, number or Buffer")},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite(e))e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var i=n;n=e,e=0|r,r=i}var a=this.length-e;if((void 0===r||r>a)&&(r=a),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return x(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":return w(this,t,e,r);case"binary":return k(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var n;if(a.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=a.prototype;else{var i=e-t;n=new a(i,void 0);for(var o=0;i>o;o++)n[o]=this[o+t]}return n.length&&(n.parent=this.parent||this),n},a.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||R(t,e,this.length);for(var n=this[t],i=1,a=0;++a0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||R(t,e,this.length);for(var n=this[t],i=1,a=0;++a=i&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||R(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a},a.prototype.readInt8=function(t,e){return e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),Z.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),Z.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),Z.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),Z.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,r,n){t=+t,e=0|e,r=0|r,n||O(this,t,e,r,Math.pow(2,8*r),0);var i=1,a=0;for(this[e]=255&t;++a=0&&(a*=256);)this[e+i]=t/a&255;return e+r},a.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):N(this,t,e,!0),e+4},a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=0,o=1,s=0>t?1:0;for(this[e]=255&t;++a>0)-s&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0>t?1:0;for(this[e+a]=255&t;--a>=0&&(o*=256);)this[e+a]=(t/o>>0)-s&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):N(this,t,e,!0),e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},a.prototype.writeFloatLE=function(t,e,r){return F(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return F(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length), +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Plotly=t()}}(function(){var t;return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,function(e){var r=t[o][1][e];return i(r?r:e)},u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;or;++r)e[r]=0;return e}function o(t,e,r){switch(arguments.length){case 0:return new i([0],[0],0);case 1:if("number"==typeof t){var n=a(t);return new i(n,n,0)}return new i(t,a(t.length),0);case 2:if("number"==typeof e){var n=a(t.length);return new i(t,n,+e)}r=0;case 3:if(t.length!==e.length)throw new Error("state and velocity lengths must match");return new i(t,e,r)}}e.exports=o;var s=t("cubic-hermite"),l=t("binary-search-bounds"),c=i.prototype;c.flush=function(t){var e=l.gt(this._time,t)-1;0>=e||(this._time.splice(0,e),this._state.splice(0,e*this.dimension),this._velocity.splice(0,e*this.dimension))},c.curve=function(t){var e=this._time,r=e.length,i=l.le(e,t),a=this._scratch[0],o=this._state,c=this._velocity,u=this.dimension,f=this.bounds;if(0>i)for(var h=u-1,d=0;u>d;++d,--h)a[d]=o[h];else if(i>=r-1)for(var h=o.length-1,p=t-e[r-1],d=0;u>d;++d,--h)a[d]=o[h]+p*c[h];else{for(var h=u*(i+1)-1,g=e[i],v=e[i+1],m=v-g||1,y=this._scratch[1],b=this._scratch[2],x=this._scratch[3],_=this._scratch[4],w=!0,d=0;u>d;++d,--h)y[d]=o[h],x[d]=c[h]*m,b[d]=o[h+u],_[d]=c[h+u]*m,w=w&&y[d]===b[d]&&x[d]===_[d]&&0===x[d];if(w)for(var d=0;u>d;++d)a[d]=y[d];else s(y,x,b,_,(t-g)/m,a)}for(var k=f[0],A=f[1],d=0;u>d;++d)a[d]=n(k[d],A[d],a[d]);return a},c.dcurve=function(t){var e=this._time,r=e.length,n=l.le(e,t),i=this._scratch[0],a=this._state,o=this._velocity,c=this.dimension;if(n>=r-1)for(var u=a.length-1,f=(t-e[r-1],0);c>f;++f,--u)i[f]=o[u];else{for(var u=c*(n+1)-1,h=e[n],d=e[n+1],p=d-h||1,g=this._scratch[1],v=this._scratch[2],m=this._scratch[3],y=this._scratch[4],b=!0,f=0;c>f;++f,--u)g[f]=a[u],m[f]=o[u]*p,v[f]=a[u+c],y[f]=o[u+c]*p,b=b&&g[f]===v[f]&&m[f]===y[f]&&0===m[f];if(b)for(var f=0;c>f;++f)i[f]=0;else{s.derivative(g,m,v,y,(t-h)/p,i);for(var f=0;c>f;++f)i[f]/=p}}return i},c.lastT=function(){var t=this._time;return t[t.length-1]},c.stable=function(){for(var t=this._velocity,e=t.length,r=this.dimension-1;r>=0;--r)if(t[--e])return!1;return!0},c.jump=function(t){var e=this.lastT(),r=this.dimension;if(!(e>t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1];this._time.push(e,t);for(var u=0;2>u;++u)for(var f=0;r>f;++f)i.push(i[o++]),a.push(0);this._time.push(t);for(var f=r;f>0;--f)i.push(n(l[f-1],c[f-1],arguments[f])),a.push(0)}},c.push=function(t){var e=this.lastT(),r=this.dimension;if(!(e>t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=t-e,l=this.bounds,c=l[0],u=l[1],f=s>1e-6?1/s:0;this._time.push(t);for(var h=r;h>0;--h){var d=n(c[h-1],u[h-1],arguments[h]);i.push(d),a.push((d-i[o++])*f)}}},c.set=function(t){var e=this.dimension;if(!(t0;--l)r.push(n(o[l-1],s[l-1],arguments[l])),i.push(0)}},c.move=function(t){var e=this.lastT(),r=this.dimension;if(!(e>=t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1],u=t-e,f=u>1e-6?1/u:0;this._time.push(t);for(var h=r;h>0;--h){var d=arguments[h];i.push(n(l[h-1],c[h-1],i[o++]+d)),a.push(d*f)}}},c.idle=function(t){var e=this.lastT();if(!(e>t)){var r=this.dimension,i=this._state,a=this._velocity,o=i.length-r,s=this.bounds,l=s[0],c=s[1],u=t-e;this._time.push(t);for(var f=r-1;f>=0;--f)i.push(n(l[f],c[f],i[o]+u*a[o])),a.push(0),o+=1}}},{"binary-search-bounds":21,"cubic-hermite":22}],21:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],22:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=6*i*i-6*i,s=3*i*i-4*i+1,l=-6*i*i+6*i,c=3*i*i-2*i;if(t.length){a||(a=new Array(t.length));for(var u=t.length-1;u>=0;--u)a[u]=o*t[u]+s*e[u]+l*r[u]+c*n[u];return a}return o*t+s*e+l*r[u]+c*n}function i(t,e,r,n,i,a){var o=i-1,s=i*i,l=o*o,c=(1+2*i)*l,u=i*l,f=s*(3-2*i),h=s*o;if(t.length){a||(a=new Array(t.length));for(var d=t.length-1;d>=0;--d)a[d]=c*t[d]+u*e[d]+f*r[d]+h*n[d];return a}return c*t+u*e+f*r+h*n}e.exports=i,e.exports.derivative=n},{}],23:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=i*l-a*s,t[1]=a*o-n*l,t[2]=n*s-i*o,t}e.exports=n},{}],24:[function(t,e,r){function n(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}e.exports=n},{}],25:[function(t,e,r){function n(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}e.exports=n},{}],26:[function(t,e,r){function n(t,e,r,n){var i=e[0],a=e[1],o=e[2];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t}e.exports=n},{}],27:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t}e.exports=n},{}],28:[function(t,e,r){"use strict";function n(t){this._components=t.slice(),this._time=[0],this.prevMatrix=t.slice(),this.nextMatrix=t.slice(),this.computedMatrix=t.slice(),this.computedInverse=t.slice(),this.computedEye=[0,0,0],this.computedUp=[0,0,0],this.computedCenter=[0,0,0],this.computedRadius=[0],this._limits=[-(1/0),1/0]}function i(t){t=t||{};var e=t.matrix||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return new n(e)}var a=t("binary-search-bounds"),o=t("mat4-interpolate"),s=t("gl-mat4/invert"),l=t("gl-mat4/rotateX"),c=t("gl-mat4/rotateY"),u=t("gl-mat4/rotateZ"),f=t("gl-mat4/lookAt"),h=t("gl-mat4/translate"),d=(t("gl-mat4/scale"),t("gl-vec3/normalize")),p=[0,0,0];e.exports=i;var g=n.prototype;g.recalcMatrix=function(t){var e=this._time,r=a.le(e,t),n=this.computedMatrix;if(!(0>r)){var i=this._components;if(r===e.length-1)for(var l=16*r,c=0;16>c;++c)n[c]=i[l++];else{for(var u=e[r+1]-e[r],l=16*r,f=this.prevMatrix,h=!0,c=0;16>c;++c)f[c]=i[l++];for(var p=this.nextMatrix,c=0;16>c;++c)p[c]=i[l++],h=h&&f[c]===p[c];if(1e-6>u||h)for(var c=0;16>c;++c)n[c]=f[c];else o(n,f,p,(t-e[r])/u)}var g=this.computedUp;g[0]=n[1],g[1]=n[5],g[2]=n[6],d(g,g);var v=this.computedInverse;s(v,n);var m=this.computedEye,y=v[15];m[0]=v[12]/y,m[1]=v[13]/y,m[2]=v[14]/y;for(var b=this.computedCenter,x=Math.exp(this.computedRadius[0]),c=0;3>c;++c)b[c]=m[c]-n[2+4*c]*x}},g.idle=function(t){if(!(tn;++n)e.push(e[r++]);this._time.push(t)}},g.flush=function(t){var e=a.gt(this._time,t)-2;0>e||(this._time.slice(0,e),this._components.slice(0,16*e))},g.lastT=function(){return this._time[this._time.length-1]},g.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||p,n=n||this.computedUp,this.setMatrix(t,f(this.computedMatrix,e,r,n));for(var i=0,a=0;3>a;++a)i+=Math.pow(r[a]-e[a],2);i=Math.log(Math.sqrt(i)),this.computedRadius[0]=i},g.rotate=function(t,e,r,n){this.recalcMatrix(t);var i=this.computedInverse;e&&c(i,i,e),r&&l(i,i,r),n&&u(i,i,n),this.setMatrix(t,s(this.computedMatrix,i))};var v=[0,0,0];g.pan=function(t,e,r,n){v[0]=-(e||0),v[1]=-(r||0),v[2]=-(n||0),this.recalcMatrix(t);var i=this.computedInverse;h(i,i,v),this.setMatrix(t,s(i,i))},g.translate=function(t,e,r,n){v[0]=e||0,v[1]=r||0,v[2]=n||0,this.recalcMatrix(t);var i=this.computedMatrix;h(i,i,v),this.setMatrix(t,i)},g.setMatrix=function(t,e){if(!(tr;++r)this._components.push(e[r])}},g.setDistance=function(t,e){this.computedRadius[0]=e},g.setDistanceLimits=function(t,e){var r=this._limits;r[0]=t,r[1]=e},g.getDistanceLimits=function(t){var e=this._limits;return t?(t[0]=e[0],t[1]=e[1],t):e}},{"binary-search-bounds":29,"gl-mat4/invert":96,"gl-mat4/lookAt":97,"gl-mat4/rotateX":101,"gl-mat4/rotateY":102,"gl-mat4/rotateZ":103,"gl-mat4/scale":104,"gl-mat4/translate":105,"gl-vec3/normalize":27,"mat4-interpolate":30}],29:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],30:[function(t,e,r){function n(t,e,r,n){if(0===u(e)||0===u(r))return!1;var i=c(e,h.translate,h.scale,h.skew,h.perspective,h.quaternion),a=c(r,d.translate,d.scale,d.skew,d.perspective,d.quaternion);return i&&a?(s(p.translate,h.translate,d.translate,n),s(p.skew,h.skew,d.skew,n),s(p.scale,h.scale,d.scale,n),s(p.perspective,h.perspective,d.perspective,n),f(p.quaternion,h.quaternion,d.quaternion,n),l(t,p.translate,p.scale,p.skew,p.perspective,p.quaternion),!0):!1}function i(){return{translate:a(),scale:a(1),skew:a(),perspective:o(),quaternion:o()}}function a(t){return[t||0,t||0,t||0]}function o(){return[0,0,0,1]}var s=t("gl-vec3/lerp"),l=t("mat4-recompose"),c=t("mat4-decompose"),u=t("gl-mat4/determinant"),f=t("quat-slerp"),h=i(),d=i(),p=i();e.exports=n},{"gl-mat4/determinant":92,"gl-vec3/lerp":26,"mat4-decompose":31,"mat4-recompose":33,"quat-slerp":34}],31:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}function i(t,e){t[0][0]=e[0],t[0][1]=e[1],t[0][2]=e[2],t[1][0]=e[4],t[1][1]=e[5],t[1][2]=e[6],t[2][0]=e[8],t[2][1]=e[9],t[2][2]=e[10]}function a(t,e,r,n,i){t[0]=e[0]*n+r[0]*i,t[1]=e[1]*n+r[1]*i,t[2]=e[2]*n+r[2]*i}var o=t("./normalize"),s=t("gl-mat4/create"),l=t("gl-mat4/clone"),c=t("gl-mat4/determinant"),u=t("gl-mat4/invert"),f=t("gl-mat4/transpose"),h={length:t("gl-vec3/length"),normalize:t("gl-vec3/normalize"),dot:t("gl-vec3/dot"),cross:t("gl-vec3/cross")},d=s(),p=s(),g=[0,0,0,0],v=[[0,0,0],[0,0,0],[0,0,0]],m=[0,0,0];e.exports=function(t,e,r,s,y,b){if(e||(e=[0,0,0]),r||(r=[0,0,0]),s||(s=[0,0,0]),y||(y=[0,0,0,1]),b||(b=[0,0,0,1]),!o(d,t))return!1;if(l(p,d),p[3]=0,p[7]=0,p[11]=0,p[15]=1,Math.abs(c(p)<1e-8))return!1;var x=d[3],_=d[7],w=d[11],k=d[12],A=d[13],M=d[14],T=d[15];if(0!==x||0!==_||0!==w){g[0]=x,g[1]=_,g[2]=w,g[3]=T;var E=u(p,p);if(!E)return!1;f(p,p),n(y,g,p)}else y[0]=y[1]=y[2]=0,y[3]=1;if(e[0]=k,e[1]=A,e[2]=M,i(v,d),r[0]=h.length(v[0]),h.normalize(v[0],v[0]),s[0]=h.dot(v[0],v[1]),a(v[1],v[1],v[0],1,-s[0]),r[1]=h.length(v[1]),h.normalize(v[1],v[1]),s[0]/=r[1],s[1]=h.dot(v[0],v[2]),a(v[2],v[2],v[0],1,-s[1]),s[2]=h.dot(v[1],v[2]),a(v[2],v[2],v[1],1,-s[2]),r[2]=h.length(v[2]),h.normalize(v[2],v[2]),s[1]/=r[2],s[2]/=r[2],h.cross(m,v[1],v[2]),h.dot(v[0],m)<0)for(var L=0;3>L;L++)r[L]*=-1,v[L][0]*=-1,v[L][1]*=-1,v[L][2]*=-1;return b[0]=.5*Math.sqrt(Math.max(1+v[0][0]-v[1][1]-v[2][2],0)),b[1]=.5*Math.sqrt(Math.max(1-v[0][0]+v[1][1]-v[2][2],0)),b[2]=.5*Math.sqrt(Math.max(1-v[0][0]-v[1][1]+v[2][2],0)),b[3]=.5*Math.sqrt(Math.max(1+v[0][0]+v[1][1]+v[2][2],0)),v[2][1]>v[1][2]&&(b[0]=-b[0]),v[0][2]>v[2][0]&&(b[1]=-b[1]),v[1][0]>v[0][1]&&(b[2]=-b[2]),!0}},{"./normalize":32,"gl-mat4/clone":90,"gl-mat4/create":91,"gl-mat4/determinant":92,"gl-mat4/invert":96,"gl-mat4/transpose":106,"gl-vec3/cross":23,"gl-vec3/dot":24,"gl-vec3/length":25,"gl-vec3/normalize":27}],32:[function(t,e,r){e.exports=function(t,e){var r=e[15];if(0===r)return!1;for(var n=1/r,i=0;16>i;i++)t[i]=e[i]*n;return!0}},{}],33:[function(t,e,r){var n={identity:t("gl-mat4/identity"),translate:t("gl-mat4/translate"),multiply:t("gl-mat4/multiply"),create:t("gl-mat4/create"),scale:t("gl-mat4/scale"),fromRotationTranslation:t("gl-mat4/fromRotationTranslation")},i=(n.create(),n.create());e.exports=function(t,e,r,a,o,s){return n.identity(t),n.fromRotationTranslation(t,s,e),t[3]=o[0],t[7]=o[1],t[11]=o[2],t[15]=o[3],n.identity(i),0!==a[2]&&(i[9]=a[2],n.multiply(t,t,i)),0!==a[1]&&(i[9]=0,i[8]=a[1],n.multiply(t,t,i)),0!==a[0]&&(i[8]=0,i[4]=a[0],n.multiply(t,t,i)),n.scale(t,t,r),t}},{"gl-mat4/create":91,"gl-mat4/fromRotationTranslation":94,"gl-mat4/identity":95,"gl-mat4/multiply":98,"gl-mat4/scale":104,"gl-mat4/translate":105}],34:[function(t,e,r){e.exports=t("gl-quat/slerp")},{"gl-quat/slerp":35}],35:[function(t,e,r){function n(t,e,r,n){var i,a,o,s,l,c=e[0],u=e[1],f=e[2],h=e[3],d=r[0],p=r[1],g=r[2],v=r[3];return a=c*d+u*p+f*g+h*v,0>a&&(a=-a,d=-d,p=-p,g=-g,v=-v),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n),t[0]=s*c+l*d,t[1]=s*u+l*p,t[2]=s*f+l*g,t[3]=s*h+l*v,t}e.exports=n},{}],36:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c){var u=e+a+c;if(f>0){var f=Math.sqrt(u+1);t[0]=.5*(o-l)/f,t[1]=.5*(s-n)/f,t[2]=.5*(r-a)/f,t[3]=.5*f}else{var h=Math.max(e,a,c),f=Math.sqrt(2*h-u+1);e>=h?(t[0]=.5*f,t[1]=.5*(i+r)/f,t[2]=.5*(s+n)/f,t[3]=.5*(o-l)/f):a>=h?(t[0]=.5*(r+i)/f,t[1]=.5*f,t[2]=.5*(l+o)/f,t[3]=.5*(s-n)/f):(t[0]=.5*(n+s)/f,t[1]=.5*(o+l)/f,t[2]=.5*f,t[3]=.5*(r-i)/f)}return t}e.exports=n},{}],37:[function(t,e,r){"use strict";function n(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function i(t,e,r,n){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2)+Math.pow(n,2))}function a(t,e){var r=e[0],n=e[1],a=e[2],o=e[3],s=i(r,n,a,o);s>1e-6?(t[0]=r/s,t[1]=n/s,t[2]=a/s,t[3]=o/s):(t[0]=t[1]=t[2]=0,t[3]=1)}function o(t,e,r){this.radius=l([r]),this.center=l(e),this.rotation=l(t),this.computedRadius=this.radius.curve(0),this.computedCenter=this.center.curve(0),this.computedRotation=this.rotation.curve(0),this.computedUp=[.1,0,0],this.computedEye=[.1,0,0],this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.recalcMatrix(0)}function s(t){t=t||{};var e=t.center||[0,0,0],r=t.rotation||[0,0,0,1],n=t.radius||1;e=[].slice.call(e,0,3),r=[].slice.call(r,0,4),a(r,r);var i=new o(r,e,Math.log(n));return i.setDistanceLimits(t.zoomMin,t.zoomMax),("eye"in t||"up"in t)&&i.lookAt(0,t.eye,t.center,t.up),i}e.exports=s;var l=t("filtered-vector"),c=t("gl-mat4/lookAt"),u=t("gl-mat4/fromQuat"),f=t("gl-mat4/invert"),h=t("./lib/quatFromFrame"),d=o.prototype;d.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())},d.recalcMatrix=function(t){this.radius.curve(t),this.center.curve(t),this.rotation.curve(t);var e=this.computedRotation;a(e,e);var r=this.computedMatrix;u(r,e);var n=this.computedCenter,i=this.computedEye,o=this.computedUp,s=Math.exp(this.computedRadius[0]);i[0]=n[0]+s*r[2],i[1]=n[1]+s*r[6],i[2]=n[2]+s*r[10],o[0]=r[1],o[1]=r[5],o[2]=r[9];for(var l=0;3>l;++l){for(var c=0,f=0;3>f;++f)c+=r[l+4*f]*i[f];r[12+l]=-c}},d.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;16>n;++n)e[n]=r[n];return e}return r},d.idle=function(t){this.center.idle(t),this.radius.idle(t),this.rotation.idle(t)},d.flush=function(t){this.center.flush(t),this.radius.flush(t),this.rotation.flush(t)},d.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=a[1],s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],f=a[4],h=a[8],d=u*o+f*s+h*l;u-=o*d,f-=s*d,h-=l*d;var p=n(u,f,h);u/=p,f/=p,h/=p;var g=a[2],v=a[6],m=a[10],y=g*o+v*s+m*l,b=g*u+v*f+m*h;g-=y*o+b*u,v-=y*s+b*f,m-=y*l+b*h;var x=n(g,v,m);g/=x,v/=x,m/=x;var _=u*e+o*r,w=f*e+s*r,k=h*e+l*r;this.center.move(t,_,w,k);var A=Math.exp(this.computedRadius[0]);A=Math.max(1e-4,A+i),this.radius.set(t,Math.log(A))},d.rotate=function(t,e,r,a){this.recalcMatrix(t),e=e||0,r=r||0;var o=this.computedMatrix,s=o[0],l=o[4],c=o[8],u=o[1],f=o[5],h=o[9],d=o[2],p=o[6],g=o[10],v=e*s+r*u,m=e*l+r*f,y=e*c+r*h,b=-(p*y-g*m),x=-(g*v-d*y),_=-(d*m-p*v),w=Math.sqrt(Math.max(0,1-Math.pow(b,2)-Math.pow(x,2)-Math.pow(_,2))),k=i(b,x,_,w);k>1e-6?(b/=k,x/=k,_/=k,w/=k):(b=x=_=0,w=1);var A=this.computedRotation,M=A[0],T=A[1],E=A[2],L=A[3],S=M*w+L*b+T*_-E*x,C=T*w+L*x+E*b-M*_,z=E*w+L*_+M*x-T*b,P=L*w-M*b-T*x-E*_;if(a){b=d,x=p,_=g;var R=Math.sin(a)/n(b,x,_);b*=R,x*=R,_*=R,w=Math.cos(e),S=S*w+P*b+C*_-z*x,C=C*w+P*x+z*b-S*_,z=z*w+P*_+S*x-C*b,P=P*w-S*b-C*x-z*_}var O=i(S,C,z,P);O>1e-6?(S/=O,C/=O,z/=O,P/=O):(S=C=z=0,P=1),this.rotation.set(t,S,C,z,P)},d.lookAt=function(t,e,r,n){this.recalcMatrix(t),r=r||this.computedCenter,e=e||this.computedEye,n=n||this.computedUp;var i=this.computedMatrix;c(i,e,r,n);var o=this.computedRotation;h(o,i[0],i[1],i[2],i[4],i[5],i[6],i[8],i[9],i[10]),a(o,o),this.rotation.set(t,o[0],o[1],o[2],o[3]);for(var s=0,l=0;3>l;++l)s+=Math.pow(r[l]-e[l],2);this.radius.set(t,.5*Math.log(Math.max(s,1e-6))),this.center.set(t,r[0],r[1],r[2])},d.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},d.setMatrix=function(t,e){var r=this.computedRotation;h(r,e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]),a(r,r),this.rotation.set(t,r[0],r[1],r[2],r[3]);var n=this.computedMatrix;f(n,e);var i=n[15];if(Math.abs(i)>1e-6){var o=n[12]/i,s=n[13]/i,l=n[14]/i;this.recalcMatrix(t);var c=Math.exp(this.computedRadius[0]);this.center.set(t,o-n[2]*c,s-n[6]*c,l-n[10]*c),this.radius.idle(t)}else this.center.idle(t),this.radius.idle(t)},d.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},d.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-(1/0),e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},d.getDistanceLimits=function(t){var e=this.radius.bounds; +return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},d.toJSON=function(){return this.recalcMatrix(this.lastT()),{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}},d.fromJSON=function(t){var e=this.lastT(),r=t.center;r&&this.center.set(e,r[0],r[1],r[2]);var n=t.rotation;n&&this.rotation.set(e,n[0],n[1],n[2],n[3]);var i=t.distance;i&&i>0&&this.radius.set(e,Math.log(i)),this.setDistanceLimits(t.zoomMin,t.zoomMax)}},{"./lib/quatFromFrame":36,"filtered-vector":20,"gl-mat4/fromQuat":93,"gl-mat4/invert":96,"gl-mat4/lookAt":97}],38:[function(t,e,r){"use strict";function n(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function i(t){return Math.min(1,Math.max(-1,t))}function a(t){var e=Math.abs(t[0]),r=Math.abs(t[1]),n=Math.abs(t[2]),i=[0,0,0];e>Math.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,s=0;3>s;++s)a+=t[s]*t[s],o+=i[s]*t[s];for(var s=0;3>s;++s)i[s]-=o/a*t[s];return h(i,i),i}function o(t,e,r,n,i,a,o,s){this.center=l(r),this.up=l(n),this.right=l(i),this.radius=l([a]),this.angle=l([o,s]),this.angle.bounds=[[-(1/0),-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var c=0;16>c;++c)this.computedMatrix[c]=.5;this.recalcMatrix(0)}function s(t){t=t||{};var e=t.center||[0,0,0],r=t.up||[0,1,0],i=t.right||a(r),s=t.radius||1,l=t.theta||0,c=t.phi||0;if(e=[].slice.call(e,0,3),r=[].slice.call(r,0,3),h(r,r),i=[].slice.call(i,0,3),h(i,i),"eye"in t){var u=t.eye,p=[u[0]-e[0],u[1]-e[1],u[2]-e[2]];f(i,p,r),n(i[0],i[1],i[2])<1e-6?i=a(r):h(i,i),s=n(p[0],p[1],p[2]);var g=d(r,p)/s,v=d(i,p)/s;c=Math.acos(g),l=Math.acos(v)}return s=Math.log(s),new o(t.zoomMin,t.zoomMax,e,r,i,s,l,c)}e.exports=s;var l=t("filtered-vector"),c=t("gl-mat4/invert"),u=t("gl-mat4/rotate"),f=t("gl-vec3/cross"),h=t("gl-vec3/normalize"),d=t("gl-vec3/dot"),p=o.prototype;p.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-(1/0),e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},p.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},p.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,i=0,a=0,o=0;3>o;++o)a+=e[o]*r[o],i+=e[o]*e[o];for(var s=Math.sqrt(i),l=0,o=0;3>o;++o)r[o]-=e[o]*a/i,l+=r[o]*r[o],e[o]/=s;for(var c=Math.sqrt(l),o=0;3>o;++o)r[o]/=c;var u=this.computedToward;f(u,e,r),h(u,u);for(var d=Math.exp(this.computedRadius[0]),p=this.computedAngle[0],g=this.computedAngle[1],v=Math.cos(p),m=Math.sin(p),y=Math.cos(g),b=Math.sin(g),x=this.computedCenter,_=v*y,w=m*y,k=b,A=-v*b,M=-m*b,T=y,E=this.computedEye,L=this.computedMatrix,o=0;3>o;++o){var S=_*r[o]+w*u[o]+k*e[o];L[4*o+1]=A*r[o]+M*u[o]+T*e[o],L[4*o+2]=S,L[4*o+3]=0}var C=L[1],z=L[5],P=L[9],R=L[2],O=L[6],I=L[10],N=z*I-P*O,j=P*R-C*I,F=C*O-z*R,D=n(N,j,F);N/=D,j/=D,F/=D,L[0]=N,L[4]=j,L[8]=F;for(var o=0;3>o;++o)E[o]=x[o]+L[2+4*o]*d;for(var o=0;3>o;++o){for(var l=0,B=0;3>B;++B)l+=L[o+4*B]*E[B];L[12+o]=-l}L[15]=1},p.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;16>n;++n)e[n]=r[n];return e}return r};var g=[0,0,0];p.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;g[0]=i[2],g[1]=i[6],g[2]=i[10];for(var a=this.computedUp,o=this.computedRight,s=this.computedToward,l=0;3>l;++l)i[4*l]=a[l],i[4*l+1]=o[l],i[4*l+2]=s[l];u(i,i,n,g);for(var l=0;3>l;++l)a[l]=i[4*l],o[l]=i[4*l+1];this.up.set(t,a[0],a[1],a[2]),this.right.set(t,o[0],o[1],o[2])}},p.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=(Math.exp(this.computedRadius[0]),a[1]),s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],f=a[4],h=a[8],d=u*o+f*s+h*l;u-=o*d,f-=s*d,h-=l*d;var p=n(u,f,h);u/=p,f/=p,h/=p;var g=u*e+o*r,v=f*e+s*r,m=h*e+l*r;this.center.move(t,g,v,m);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+i),this.radius.set(t,Math.log(y))},p.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},p.setMatrix=function(t,e,r,a){var o=1;"number"==typeof r&&(o=0|r),(0>o||o>3)&&(o=1);var s=(o+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var l=e[o],u=e[o+4],f=e[o+8];if(a){var h=Math.abs(l),d=Math.abs(u),p=Math.abs(f),g=Math.max(h,d,p);h===g?(l=0>l?-1:1,u=f=0):p===g?(f=0>f?-1:1,l=u=0):(u=0>u?-1:1,l=f=0)}else{var v=n(l,u,f);l/=v,u/=v,f/=v}var m=e[s],y=e[s+4],b=e[s+8],x=m*l+y*u+b*f;m-=l*x,y-=u*x,b-=f*x;var _=n(m,y,b);m/=_,y/=_,b/=_;var w=u*b-f*y,k=f*m-l*b,A=l*y-u*m,M=n(w,k,A);w/=M,k/=M,A/=M,this.center.jump(t,H,G,Y),this.radius.idle(t),this.up.jump(t,l,u,f),this.right.jump(t,m,y,b);var T,E;if(2===o){var L=e[1],S=e[5],C=e[9],z=L*m+S*y+C*b,P=L*w+S*k+C*A;T=0>N?-Math.PI/2:Math.PI/2,E=Math.atan2(P,z)}else{var R=e[2],O=e[6],I=e[10],N=R*l+O*u+I*f,j=R*m+O*y+I*b,F=R*w+O*k+I*A;T=Math.asin(i(N)),E=Math.atan2(F,j)}this.angle.jump(t,E,T),this.recalcMatrix(t);var D=e[2],B=e[6],U=e[10],V=this.computedMatrix;c(V,e);var q=V[15],H=V[12]/q,G=V[13]/q,Y=V[14]/q,X=Math.exp(this.computedRadius[0]);this.center.jump(t,H-D*X,G-B*X,Y-U*X)},p.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},p.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},p.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},p.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},p.lookAt=function(t,e,r,a){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter,a=a||this.computedUp;var o=a[0],s=a[1],l=a[2],c=n(o,s,l);if(!(1e-6>c)){o/=c,s/=c,l/=c;var u=e[0]-r[0],f=e[1]-r[1],h=e[2]-r[2],d=n(u,f,h);if(!(1e-6>d)){u/=d,f/=d,h/=d;var p=this.computedRight,g=p[0],v=p[1],m=p[2],y=o*g+s*v+l*m;g-=y*o,v-=y*s,m-=y*l;var b=n(g,v,m);if(!(.01>b&&(g=s*h-l*f,v=l*u-o*h,m=o*f-s*u,b=n(g,v,m),1e-6>b))){g/=b,v/=b,m/=b,this.up.set(t,o,s,l),this.right.set(t,g,v,m),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(d));var x=s*m-l*v,_=l*g-o*m,w=o*v-s*g,k=n(x,_,w);x/=k,_/=k,w/=k;var A=o*u+s*f+l*h,M=g*u+v*f+m*h,T=x*u+_*f+w*h,E=Math.asin(i(A)),L=Math.atan2(T,M),S=this.angle._state,C=S[S.length-1],z=S[S.length-2];C%=2*Math.PI;var P=Math.abs(C+2*Math.PI-L),R=Math.abs(C-L),O=Math.abs(C-2*Math.PI-L);R>P&&(C+=2*Math.PI),R>O&&(C-=2*Math.PI),this.angle.jump(this.angle.lastT(),C,z),this.angle.set(t,L,E)}}}}},{"filtered-vector":20,"gl-mat4/invert":96,"gl-mat4/rotate":100,"gl-vec3/cross":23,"gl-vec3/dot":24,"gl-vec3/normalize":27}],39:[function(t,e,r){"use strict";function n(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map(function(e){return t[e]}),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.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}function i(t){t=t||{};var e=t.eye||[0,0,1],r=t.center||[0,0,0],i=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],c=t.mode||"turntable",u=a(),f=o(),h=s();return u.setDistanceLimits(l[0],l[1]),u.lookAt(0,e,r,i),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,i),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,i),new n({turntable:u,orbit:f,matrix:h},c)}e.exports=i;var a=t("turntable-camera-controller"),o=t("orbit-camera-controller"),s=t("matrix-camera-controller"),l=n.prototype,c=[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]];c.forEach(function(t){for(var e=t[0],r=[],n=0;ne)){var r=this._active,n=this._controllerList[e],i=Math.max(r.lastT(),n.lastT());r.recalcMatrix(i),n.setMatrix(i,r.computedMatrix),this._active=n,this._mode=t,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}}},l.getMode=function(){return this._mode}},{"matrix-camera-controller":28,"orbit-camera-controller":37,"turntable-camera-controller":38}],40:[function(t,e,r){function n(t,e){return a(i(t,e))}e.exports=n;var i=t("alpha-complex"),a=t("simplicial-complex-boundary")},{"alpha-complex":41,"simplicial-complex-boundary":44}],41:[function(t,e,r){"use strict";function n(t,e){return i(e).filter(function(r){for(var n=new Array(r.length),i=0;ii;++i)r+=t[i]*e[i];return r}function i(t){var e=t.length;if(0===e)return[];var r=(t[0].length,o([t.length+1,t.length+1],1)),i=o([t.length+1],1);r[e][e]=0;for(var a=0;e>a;++a){for(var l=0;a>=l;++l)r[l][a]=r[a][l]=2*n(t[a],t[l]);i[a]=n(t[a],t[a])}for(var c=s(r,i),u=0,f=c[e+1],a=0;aa;++a){for(var f=c[a],d=0,l=0;ls;++s)r[s]+=t[a][s]*n[a];return r}var o=t("dup"),s=t("robust-linear-solve");a.barycenetric=i,e.exports=a},{dup:74,"robust-linear-solve":215}],44:[function(t,e,r){"use strict";function n(t){return a(i(t))}e.exports=n;var i=t("boundary-cells"),a=t("reduce-simplicial-complex")},{"boundary-cells":45,"reduce-simplicial-complex":48}],45:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=0,n=0;e>n;++n)r+=t[n].length;for(var i=new Array(r),a=0,n=0;e>n;++n)for(var o=t[n],s=o.length,l=0;s>l;++l)for(var c=i[a++]=new Array(s-1),u=1;s>u;++u)c[u-1]=o[(l+u)%s];return i}e.exports=n},{}],46:[function(t,e,r){"use strict";function n(t){for(var e=1,r=1;rn;++n)if(t[r]n;++n){var s=t[n],l=o(s);if(0!==l){if(r>0){var c=t[r-1];if(0===i(s,c)&&o(c)!==l){r-=1;continue}}t[r++]=s}}return t.length=r,t}var i=t("compare-cell"),a=t("compare-oriented-cell"),o=t("cell-orientation");e.exports=n},{"cell-orientation":46,"compare-cell":60,"compare-oriented-cell":47}],49:[function(t,e,r){"use strict";var n=function(){function t(t){return!Array.isArray(t)&&null!==t&&"object"==typeof t}function e(t,e,r){for(var n=(e-t)/Math.max(r-1,1),i=[],a=0;r>a;a++)i.push(t+a*n);return i}function r(){for(var t=[].slice.call(arguments),e=t.map(function(t){return t.length}),r=Math.min.apply(null,e),n=[],i=0;r>i;i++){n[i]=[];for(var a=0;aa;a++)i.push([t[a],e[a],r[a]]);return i}function i(t){function e(t){for(var n=0;n>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3])),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}function c(t,e){var r,n;if("string"!=typeof t)return t;if(r=[],"#"===t[0]?(t=t.substr(1),3===t.length&&(t+=t),n=parseInt(t,16),r[0]=n>>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3]),n[4]?r[3]=parseFloat(n[4]):r[3]=1),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}var u={},f=/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,.*)?\)$/,h=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,?\s*(.*)?\)$/;return u.isPlainObject=t,u.linspace=e,u.zip3=n,u.sum=i,u.zip=r,u.isEqual=s,u.copy2D=a,u.copy1D=o,u.str2RgbArray=l,u.str2RgbaArray=c,u};e.exports=n()},{}],50:[function(t,e,r){"use strict";"use restrict";function n(t){var e=32;return t&=-t,t&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}var i=32;r.INT_BITS=i,r.INT_MAX=2147483647,r.INT_MIN=-1<0)-(0>t)},r.abs=function(t){var e=t>>i-1;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(e>t)},r.max=function(t,e){return t^(t^e)&-(e>t)},r.isPow2=function(t){return!(t&t-1||!t)},r.log2=function(t){var e,r;return e=(t>65535)<<4,t>>>=e,r=(t>255)<<3,t>>>=r,e|=r,r=(t>15)<<2,t>>>=r,e|=r,r=(t>3)<<1,t>>>=r,e|=r,e|t>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return t-=t>>>1&1431655765,t=(858993459&t)+(t>>>2&858993459),16843009*(t+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,t&=15,27030>>>t&1};var a=new Array(256);!function(t){for(var e=0;256>e;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|a[t>>>16&255]<<8|a[t>>>24&255]},r.interleave2=function(t,e){return t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},r.deinterleave2=function(t,e){return t=t>>>e&1431655765,t=858993459&(t|t>>>1),t=252645135&(t|t>>>2),t=16711935&(t|t>>>4),t=65535&(t|t>>>16),t<<16>>16},r.interleave3=function(t,e,r){return t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t|=e<<1,r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),t|r<<2},r.deinterleave3=function(t,e){return t=t>>>e&1227133513,t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),t=1023&(t|t>>>16),t<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],51:[function(t,e,r){(function(e){"use strict";function n(){try{var t=new Uint8Array(1);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function i(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t){return this instanceof a?(a.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?o(this,t):"string"==typeof t?s(this,t,arguments.length>1?arguments[1]:"utf8"):l(this,t)):arguments.length>1?new a(t,arguments[1]):new a(t)}function o(t,e){if(t=g(t,0>e?0:0|v(e)),!a.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;r++)t[r]=0;return t}function s(t,e,r){"string"==typeof r&&""!==r||(r="utf8");var n=0|y(e,r);return t=g(t,n),t.write(e,r),t}function l(t,e){if(a.isBuffer(e))return c(t,e);if(K(e))return u(t,e);if(null==e)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(e.buffer instanceof ArrayBuffer)return f(t,e);if(e instanceof ArrayBuffer)return h(t,e)}return e.length?d(t,e):p(t,e)}function c(t,e){var r=0|v(e.length);return t=g(t,r),e.copy(t,0,0,r),t}function u(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function f(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function h(t,e){return e.byteLength,a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=a.prototype):t=f(t,new Uint8Array(e)),t}function d(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function p(t,e){var r,n=0;"Buffer"===e.type&&K(e.data)&&(r=e.data,n=0|v(r.length)),t=g(t,n);for(var i=0;n>i;i+=1)t[i]=255&r[i];return t}function g(t,e){a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=a.prototype):t.length=e;var r=0!==e&&e<=a.poolSize>>>1;return r&&(t.parent=$),t}function v(t){if(t>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function m(t,e){if(!(this instanceof m))return new m(t,e);var r=new a(t,e);return delete r.parent,r}function y(t,e){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(t).length;default:if(n)return q(t).length;e=(""+e).toLowerCase(),n=!0}}function b(t,e,r){var n=!1;if(e=0|e,r=void 0===r||r===1/0?this.length:0|r,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return z(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return S(this,e,r);case"binary":return C(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function x(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=e.length;if(a%2!==0)throw new Error("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;n>o;o++){var s=parseInt(e.substr(2*o,2),16);if(isNaN(s))throw new Error("Invalid hex string");t[r+o]=s}return o}function _(t,e,r,n){return X(q(e,t.length-r),t,r,n)}function w(t,e,r,n){return X(H(e),t,r,n)}function k(t,e,r,n){return w(t,e,r,n)}function A(t,e,r,n){return X(Y(e),t,r,n)}function M(t,e,r,n){return X(G(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;r>i;){var a=t[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(r>=i+s){var l,c,u,f;switch(s){case 1:128>a&&(o=a);break;case 2:l=t[i+1],128===(192&l)&&(f=(31&a)<<6|63&l,f>127&&(o=f));break;case 3:l=t[i+1],c=t[i+2],128===(192&l)&&128===(192&c)&&(f=(15&a)<<12|(63&l)<<6|63&c,f>2047&&(55296>f||f>57343)&&(o=f));break;case 4:l=t[i+1],c=t[i+2],u=t[i+3],128===(192&l)&&128===(192&c)&&128===(192&u)&&(f=(15&a)<<18|(63&l)<<12|(63&c)<<6|63&u,f>65535&&1114112>f&&(o=f))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return L(n)}function L(t){var e=t.length;if(Q>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Q));return r}function S(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function C(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function z(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",a=e;r>a;a++)i+=V(t[a]);return i}function P(t,e,r){for(var n=t.slice(e,r),i="",a=0;at)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!a.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>i||o>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range")}function I(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,a=Math.min(t.length-r,2);a>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function N(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,a=Math.min(t.length-r,4);a>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function j(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function F(t,e,r,n,i){return i||j(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,i){return i||j(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(t,e,r,n,52,8),r+8}function B(t){if(t=U(t).replace(J,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function U(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function V(t){return 16>t?"0"+t.toString(16):t.toString(16)}function q(t,e){e=e||1/0;for(var r,n=t.length,i=null,a=[],o=0;n>o;o++){if(r=t.charCodeAt(o),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,128>r){if((e-=1)<0)break;a.push(r)}else if(2048>r){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function H(t){for(var e=[],r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function Y(t){return W.toByteArray(B(t))}function X(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}var W=t("base64-js"),Z=t("ieee754"),K=t("isarray");r.Buffer=a,r.SlowBuffer=m,r.INSPECT_MAX_BYTES=50,a.poolSize=8192;var $={};a.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),a._augment=function(t){return t.__proto__=a.prototype,t},a.TYPED_ARRAY_SUPPORT?(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})):(a.prototype.length=void 0,a.prototype.parent=void 0),a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,e){if(!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);o>i&&t[i]===e[i];)++i;return i!==o&&(r=t[i],n=e[i]),n>r?-1:r>n?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!K(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new a(0);var r;if(void 0===e)for(e=0,r=0;r0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},a.prototype.compare=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:a.compare(this,t)},a.prototype.indexOf=function(t,e){function r(t,e,r){for(var n=-1,i=0;r+i2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,e);if(a.isBuffer(t))return r(this,t,e);if("number"==typeof t)return a.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):r(this,[t],e);throw new TypeError("val must be string, number or Buffer")},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite(e))e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var i=n;n=e,e=0|r,r=i}var a=this.length-e;if((void 0===r||r>a)&&(r=a),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return x(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":return w(this,t,e,r);case"binary":return k(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var n;if(a.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=a.prototype;else{var i=e-t;n=new a(i,void 0);for(var o=0;i>o;o++)n[o]=this[o+t]}return n.length&&(n.parent=this.parent||this),n},a.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||R(t,e,this.length);for(var n=this[t],i=1,a=0;++a0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||R(t,e,this.length);for(var n=this[t],i=1,a=0;++a=i&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||R(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a},a.prototype.readInt8=function(t,e){return e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),Z.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),Z.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),Z.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),Z.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,r,n){t=+t,e=0|e,r=0|r,n||O(this,t,e,r,Math.pow(2,8*r),0);var i=1,a=0;for(this[e]=255&t;++a=0&&(a*=256);)this[e+i]=t/a&255;return e+r},a.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):N(this,t,e,!0),e+4},a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=0,o=1,s=0>t?1:0;for(this[e]=255&t;++a>0)-s&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0>t?1:0;for(this[e+a]=255&t;--a>=0&&(o*=256);)this[e+a]=(t/o>>0)-s&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):N(this,t,e,!0),e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},a.prototype.writeFloatLE=function(t,e,r){return F(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return F(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length), t.length-er&&n>e)for(i=o-1;i>=0;i--)t[i+e]=this[i+r];else if(1e3>o||!a.TYPED_ARRAY_SUPPORT)for(i=0;o>i;i++)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},a.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new RangeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=q(t.toString()),a=i.length;for(n=e;r>n;n++)this[n]=i[n%a]}return this}};var J=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":52,ieee754:53,isarray:54}],52:[function(t,e,r){"use strict";function n(){var t,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=e.length;for(t=0;r>t;t++)l[t]=e[t];for(t=0;r>t;++t)c[e.charCodeAt(t)]=t;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63}function i(t){var e,r,n,i,a,o,s=t.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===t[s-2]?2:"="===t[s-1]?1:0,o=new u(3*s/4-a),n=a>0?s-4:s;var l=0;for(e=0,r=0;n>e;e+=4,r+=3)i=c[t.charCodeAt(e)]<<18|c[t.charCodeAt(e+1)]<<12|c[t.charCodeAt(e+2)]<<6|c[t.charCodeAt(e+3)],o[l++]=(16711680&i)>>16,o[l++]=(65280&i)>>8,o[l++]=255&i;return 2===a?(i=c[t.charCodeAt(e)]<<2|c[t.charCodeAt(e+1)]>>4,o[l++]=255&i):1===a&&(i=c[t.charCodeAt(e)]<<10|c[t.charCodeAt(e+1)]<<4|c[t.charCodeAt(e+2)]>>2,o[l++]=i>>8&255,o[l++]=255&i),o}function a(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function o(t,e,r){for(var n,i=[],o=e;r>o;o+=3)n=(t[o]<<16)+(t[o+1]<<8)+t[o+2],i.push(a(n));return i.join("")}function s(t){for(var e,r=t.length,n=r%3,i="",a=[],s=16383,c=0,u=r-n;u>c;c+=s)a.push(o(t,c,c+s>u?u:c+s));return 1===n?(e=t[r-1],i+=l[e>>2],i+=l[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=l[e>>10],i+=l[e>>4&63],i+=l[e<<2&63],i+="="),a.push(i),a.join("")}r.toByteArray=i,r.fromByteArray=s;var l=[],c=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],53:[function(t,e,r){r.read=function(t,e,r,n,i){var a,o,s=8*i-n-1,l=(1<>1,u=-7,f=r?i-1:0,h=r?-1:1,d=t[e+f];for(f+=h,a=d&(1<<-u)-1,d>>=-u,u+=s;u>0;a=256*a+t[e+f],f+=h,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+f],f+=h,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:(d?-1:1)*(1/0);o+=Math.pow(2,n),a-=c}return(d?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:a-1,p=n?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),e+=o+f>=1?h/l:h*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=u?(s=0,o=u):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,c-=8);t[r+d-p]|=128*g}},{}],54:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],55:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function a(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!a(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,l,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,l=0;n>l;l++)c[l].apply(this,a);return!0},n.prototype.addListener=function(t,e){var r;if(!i(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(r=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,a,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],a=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(s=a;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],56:[function(t,e,r){function n(){u=!1,s.length?c=s.concat(c):f=-1,c.length&&i()}function i(){if(!u){var t=setTimeout(n);u=!0;for(var e=c.length;e;){for(s=c,c=[];++f1)for(var r=1;rn;++n)e=t[n],e=e.toString(16),r+=("00"+e).substr(e.length);return r}function i(t){return"rgba("+t.join(",")+")"}var a=t("arraytools"),o=t("clone"),s=t("./colorScales");e.exports=function(t){var e,r,l,c,u,f,h,d,p,g,v,m,y,b=[],x=[],_=[],w=[];if(a.isPlainObject(t)||(t={}),p=t.nshades||72,d=t.format||"hex",h=t.colormap,h||(h="jet"),"string"==typeof h){if(h=h.toLowerCase(),!s[h])throw Error(h+" not a supported colorscale");f=o(s[h])}else{if(!Array.isArray(h))throw Error("unsupported colormap option",h);f=o(h)}if(f.length>p)throw new Error(h+" map requires nshades to be at least size "+f.length);for(v=Array.isArray(t.alpha)?2!==t.alpha.length?[1,1]:o(t.alpha):"number"==typeof t.alpha?[t.alpha,t.alpha]:[1,1],e=f.map(function(t){return Math.round(t.index*p)}),v[0]<0&&(v[0]=0),v[1]<0&&(v[0]=0),v[0]>1&&(v[0]=1),v[1]>1&&(v[0]=1),y=0;y=0&&r[3]<=1||(r[3]=v[0]+(v[1]-v[0])*m);for(y=0;yx;++x)if(i=y[x]-b[x])return i;return 0}}e.exports=i;var a=Math.min},{}],61:[function(t,e,r){"use strict";function n(t){var e=t.length;if(0===e)return[];if(1===e)return[[0]];var r=t[0].length;return 0===r?[]:1===r?i(t):2===r?a(t):o(t,r)}var i=t("./lib/ch1d"),a=t("./lib/ch2d"),o=t("./lib/chnd");e.exports=n},{"./lib/ch1d":62,"./lib/ch2d":63,"./lib/chnd":64}],62:[function(t,e,r){"use strict";function n(t){for(var e=0,r=0,n=1;nt[r][0]&&(r=n);return r>e?[[e],[r]]:e>r?[[r],[e]]:[[e]]}e.exports=n},{}],63:[function(t,e,r){"use strict";function n(t){var e=i(t),r=e.length;if(2>=r)return[];for(var n=new Array(r),a=e[r-1],o=0;r>o;++o){var s=e[o];n[o]=[a,s],a=s}return n}e.exports=n;var i=t("monotone-convex-hull-2d")},{"monotone-convex-hull-2d":66}],64:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),i=0;ii;++i)e.indexOf(i)<0&&(n[a++]=t[i]);return n}function i(t,e){for(var r=t.length,n=e.length,i=0;r>i;++i)for(var a=t[i],o=0;os)a[o]=e[s];else{s-=n;for(var l=0;n>l;++l)s>=e[l]&&(s+=1);a[o]=s}}return t}function a(t,e){try{return o(t,!0)}catch(r){var a=s(t);if(a.length<=e)return[];var l=n(t,a),c=o(l,!0);return i(c,a)}}e.exports=a;var o=t("incremental-convex-hull"),s=t("affine-hull")},{"affine-hull":65,"incremental-convex-hull":194}],65:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(e+1),n=0;n=i;++i){for(var o=new Array(e),s=0;e>s;++s)o[s]=Math.pow(i+1-n,s);r[i]=o}var l=a.apply(void 0,r);if(l)return!0}return!1}function i(t){var e=t.length;if(0===e)return[];if(1===e)return[0];for(var r=t[0].length,i=[t[0]],a=[0],o=1;e>o;++o)if(i.push(t[o]),n(i,r)){if(a.push(o),a.length===r+1)return a}else i.pop();return a}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":218}],66:[function(t,e,r){"use strict";function n(t){var e=t.length;if(3>e){for(var r=new Array(e),n=0;e>n;++n)r[n]=n;return 2===e&&t[0][0]===t[1][0]&&t[0][1]===t[1][1]?[0]:r}for(var a=new Array(e),n=0;e>n;++n)a[n]=n;a.sort(function(e,r){var n=t[e][0]-t[r][0];return n?n:t[e][1]-t[r][1]});for(var o=[a[0],a[1]],s=[a[0],a[1]],n=2;e>n;++n){for(var l=a[n],c=t[l],u=o.length;u>1&&i(t[o[u-2]],t[o[u-1]],c)<=0;)u-=1,o.pop();for(o.push(l),u=s.length;u>1&&i(t[s[u-2]],t[s[u-1]],c)>=0;)u-=1,s.pop();s.push(l)}for(var r=new Array(s.length+o.length-2),f=0,n=0,h=o.length;h>n;++n)r[f++]=o[n];for(var d=s.length-2;d>0;--d)r[f++]=s[d];return r}e.exports=n;var i=t("robust-orientation")[3]},{"robust-orientation":218}],67:[function(t,e,r){e.exports={AFG:"afghan",ALA:"\\b\\wland",ALB:"albania",DZA:"algeria",ASM:"^(?=.*americ).*samoa",AND:"andorra",AGO:"angola",AIA:"anguill?a",ATA:"antarctica",ATG:"antigua",ARG:"argentin",ARM:"armenia",ABW:"^(?!.*bonaire).*\\baruba",AUS:"australia",AUT:"^(?!.*hungary).*austria|\\baustri.*\\bemp",AZE:"azerbaijan",BHS:"bahamas",BHR:"bahrain",BGD:"bangladesh|^(?=.*east).*paki?stan",BRB:"barbados",BLR:"belarus|byelo",BEL:"^(?!.*luxem).*belgium",BLZ:"belize|^(?=.*british).*honduras",BEN:"benin|dahome",BMU:"bermuda",BTN:"bhutan",BOL:"bolivia",BES:"^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands",BIH:"herzegovina|bosnia",BWA:"botswana|bechuana",BVT:"bouvet",BRA:"brazil",IOT:"british.?indian.?ocean",BRN:"brunei",BGR:"bulgaria",BFA:"burkina|\\bfaso|upper.?volta",BDI:"burundi",KHM:"cambodia|kampuchea|khmer",CMR:"cameroon",CAN:"canada",CPV:"verde",CYM:"cayman",CAF:"\\bcentral.african.republic",TCD:"\\bchad",CHL:"\\bchile",CHN:"^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai).*china",CXR:"christmas",CCK:"\\bcocos|keeling",COL:"colombia",COM:"comoro",COD:"\\bdem.*congo|congo.*\\bdem|congo.*\\bdr|\\bdr.*congo|belgian.?congo|congo.?free.?state|kinshasa|zaire|l.opoldville|drc|droc|rdc",COG:"^(?!.*\\bdem)(?!.*\\bdr)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l.opoldville)(?!.*free).*\\bcongo",COK:"\\bcook",CRI:"costa.?rica",CIV:"ivoire|ivory",HRV:"croatia",CUB:"\\bcuba",CUW:"^(?!.*bonaire).*\\bcura(c|\xe7)ao",CYP:"cyprus",CZE:"^(?=.*rep).*czech|czechia|bohemia",CSK:"czechoslovakia",DNK:"denmark",DJI:"djibouti",DMA:"dominica(?!n)",DOM:"dominican.rep",ECU:"ecuador",EGY:"egypt",SLV:"el.?salvador",GNQ:"guine.*eq|eq.*guine|^(?=.*span).*guinea",ERI:"eritrea",EST:"estonia",ETH:"ethiopia|abyssinia",FLK:"falkland|malvinas",FRO:"faroe|faeroe",FJI:"fiji",FIN:"finland",FRA:"^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul",GUF:"^(?=.*french).*guiana",PYF:"french.?polynesia|tahiti",ATF:"french.?southern",GAB:"gabon",GMB:"gambia",GEO:"^(?!.*south).*georgia",DDR:"german.?democratic.?republic|democratic.?republic.*germany|east.germany",DEU:"^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german",GHA:"ghana|gold.?coast",GIB:"gibraltar",GRC:"greece|hellenic|hellas",GRL:"greenland",GRD:"grenada",GLP:"guadeloupe",GUM:"\\bguam",GTM:"guatemala",GGY:"guernsey",GIN:"^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea",GNB:"bissau|^(?=.*portu).*guinea",GUY:"guyana|british.?guiana",HTI:"haiti",HMD:"heard.*mcdonald",VAT:"holy.?see|vatican|papal.?st",HND:"^(?!.*brit).*honduras",HKG:"hong.?kong",HUN:"^(?!.*austr).*hungary",ISL:"iceland",IND:"india(?!.*ocea)",IDN:"indonesia",IRN:"\\biran|persia",IRQ:"\\biraq|mesopotamia",IRL:"ireland",IMN:"^(?=.*isle).*\\bman",ISR:"israel",ITA:"italy",JAM:"jamaica",JPN:"japan",JEY:"jersey",JOR:"jordan",KAZ:"kazak",KEN:"kenya|british.?east.?africa|east.?africa.?prot",KIR:"kiribati",PRK:"^(?=.*democrat).*\\bkorea|^(?=.*people).*\\bkorea|^(?=.*north).*\\bkorea|dprk",KOR:"^(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea",KWT:"kuwait",KGZ:"kyrgyz|kirghiz",LAO:"\\blaos?\\b",LVA:"latvia",LBN:"lebanon",LSO:"lesotho|basuto",LBR:"liberia",LBY:"libya",LIE:"liechtenstein",LTU:"lithuania",LUX:"^(?!.*belg).*luxem",MAC:"maca(o|u)",MKD:"macedonia|fyrom",MDG:"madagascar|malagasy",MWI:"malawi|nyasa",MYS:"malaysia",MDV:"maldive",MLI:"\\bmali\\b",MLT:"\\bmalta",MHL:"marshall",MTQ:"martinique",MRT:"mauritania",MUS:"mauritius",MYT:"\\bmayotte",MEX:"\\bmexic",FSM:"micronesia",MDA:"moldov|b(a|e)ssarabia",MCO:"monaco",MNG:"mongolia",MNE:"^(?!.*serbia).*montenegro",MSR:"montserrat",MAR:"morocco|\\bmaroc",MOZ:"mozambique",MMR:"myanmar|burma",NAM:"namibia",NRU:"nauru",NPL:"nepal",NLD:"^(?!.*\\bant)(?!.*\\bcarib).*netherlands",ANT:"^(?=.*\\bant).*(nether|dutch)",NCL:"new.?caledonia",NZL:"new.?zealand",NIC:"nicaragua",NER:"\\bniger(?!ia)",NGA:"nigeria",NIU:"niue",NFK:"norfolk",MNP:"mariana",NOR:"norway",OMN:"\\boman|trucial",PAK:"^(?!.*east).*paki?stan",PLW:"palau",PSE:"palestin|\\bgaza|west.?bank",PAN:"panama",PNG:"papua|new.?guinea",PRY:"paraguay",PER:"peru",PHL:"philippines",PCN:"pitcairn",POL:"poland",PRT:"portugal",PRI:"puerto.?rico",QAT:"qatar",REU:"r(e|\xe9)union",ROU:"r(o|u|ou)mania",RUS:"\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics",RWA:"rwanda",BLM:"barth(e|\xe9)lemy",SHN:"helena",KNA:"kitts|\\bnevis",LCA:"\\blucia",MAF:"^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)",SPM:"miquelon",VCT:"vincent",WSM:"^(?!.*amer).*samoa",SMR:"san.?marino",STP:"\\bs(a|\xe3)o.?tom(e|\xe9)",SAU:"\\bsa\\w*.?arabia",SEN:"senegal",SRB:"^(?!.*monte).*serbia",SYC:"seychell",SLE:"sierra",SGP:"singapore",SXM:"^(?!.*martin)(?!.*saba).*maarten",SVK:"^(?!.*cze).*slovak",SVN:"slovenia",SLB:"solomon",SOM:"somali",ZAF:"\\bs\\w*.?africa",SGS:"south.?georgia|sandwich",SSD:"\\bs\\w*.?sudan",ESP:"spain",LKA:"sri.?lanka|ceylon",SDN:"^(?!.*\\bs(?!u)).*sudan",SUR:"surinam|dutch.?guiana",SJM:"svalbard",SWZ:"swaziland",SWE:"sweden",CHE:"switz|swiss",SYR:"syria",TWN:"taiwan|taipei|formosa",TJK:"tajik",TZA:"tanzania",THA:"thailand|\\bsiam",TLS:"^(?=.*leste).*timor|^(?=.*east).*timor",TGO:"togo",TKL:"tokelau",TON:"tonga",TTO:"trinidad|tobago",TUN:"tunisia",TUR:"turkey",TKM:"turkmen",TCA:"turks",TUV:"tuvalu",UGA:"uganda",UKR:"ukrain",ARE:"emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em",GBR:"united.?kingdom|britain|^u\\.?k\\.?$",USA:"united.?states|\\bu\\.?s\\.?a\\.?\\b|\\bu\\.?s\\.?\\b(?!.*islands)",UMI:"minor.?outlying.?is",URY:"uruguay",UZB:"uzbek",VUT:"vanuatu|new.?hebrides",VEN:"venezuela",VNM:"^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam",VGB:"^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin",VIR:"^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin",WLF:"futuna|wallis",ESH:"western.sahara",YEM:"^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen",YMD:"^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen",YUG:"yugoslavia",ZMB:"zambia|northern.?rhodesia",EAZ:"zanzibar",ZWE:"zimbabwe|^(?!.*northern).*rhodesia"}},{}],68:[function(t,e,r){"use strict";function n(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function i(t){var e=new n;e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===o){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(i),ir.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,a(e)}var a=t("./lib/thunk.js");e.exports=i},{"./lib/thunk.js":70}],69:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],c=[],u=0,f=0;for(n=0;a>n;++n)c.push(["i",n,"=0"].join(""));for(i=0;o>i;++i)for(n=0;a>n;++n)f=u,u=t[n],0===n?c.push(["d",i,"s",n,"=t",i,"p",u].join("")):c.push(["d",i,"s",n,"=(t",i,"p",u,"-s",f,"*t",i,"p",f,")"].join(""));for(l.push("var "+c.join(",")),n=a-1;n>=0;--n)u=t[n],l.push(["for(i",n,"=0;i",n,"n;++n){for(f=u,u=t[n],i=0;o>i;++i)l.push(["p",i,"+=d",i,"s",n].join(""));s&&(n>0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",u,"]"].join(""))),l.push("}")}return l.join("\n")}function i(t,e,r,i){for(var a=e.length,o=r.arrayArgs.length,s=r.blockSize,l=r.indexArgs.length>0,c=[],u=0;o>u;++u)c.push(["var offset",u,"=p",u].join(""));for(var u=t;a>u;++u)c.push(["for(var j"+u+"=SS[",e[u],"]|0;j",u,">0;){"].join("")),c.push(["if(j",u,"<",s,"){"].join("")),c.push(["s",e[u],"=j",u].join("")),c.push(["j",u,"=0"].join("")),c.push(["}else{s",e[u],"=",s].join("")),c.push(["j",u,"-=",s,"}"].join("")),l&&c.push(["index[",e[u],"]=j",u].join(""));for(var u=0;o>u;++u){for(var f=["offset"+u],h=t;a>h;++h)f.push(["j",h,"*t",u,"p",e[h]].join(""));c.push(["p",u,"=(",f.join("+"),")"].join(""))}c.push(n(e,r,i));for(var u=t;a>u;++u)c.push("}");return c.join("\n")}function a(t){for(var e=0,r=t[0].length;r>e;){for(var n=1;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}function l(t,e){for(var r=e[1].length-Math.abs(t.arrayBlockIndices[0])|0,l=new Array(t.arrayArgs.length),u=new Array(t.arrayArgs.length),f=0;fy;++y)_.push(["s",y,"=SS[",y,"]"].join(""));for(var f=0;fy;++y)_.push(["t",f,"p",y,"=t",f,"[",p[f]+y,"]"].join(""));for(var y=0;y0&&_.push("shape=SS.slice(0)"),t.indexArgs.length>0){for(var w=new Array(r),f=0;r>f;++f)w[f]="0";_.push(["index=[",w.join(","),"]"].join(""))}for(var f=0;f3&&x.push(o(t.pre,t,u));var T=o(t.body,t,u),E=a(v);r>E?x.push(i(E,v[0],t,T)):x.push(n(v[0],t,T)),t.post.body.length>3&&x.push(o(t.post,t,u)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+x.join("\n")+"\n----------");var L=[t.funcName||"unnamed","_cwise_loop_",l[0].join("s"),"m",E,s(u)].join(""),S=new Function(["function ",L,"(",b.join(","),"){",x.join("\n"),"} return ",L].join(""));return S()}var c=t("uniq");e.exports=l},{uniq:238}],70:[function(t,e,r){"use strict";function n(t){var e=["'use strict'","var CACHED={}"],r=[],n=t.funcName+"_cwise_thunk";e.push(["return function ",n,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],c=[],u=0;u0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[u]))),c.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[u])+"]"))}t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex-->0;) {"), -e.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}"));for(var u=0;ut?-1:t>e?1:t>=e?0:NaN}function a(t){return null===t?NaN:+t}function o(t){return!isNaN(t)}function s(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}function l(t){return t.length}function c(t){for(var e=1;t*e%1;)e*=10;return e}function u(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function f(){this._=Object.create(null)}function h(t){return(t+="")===ko||t[0]===Ao?Ao+t:t}function d(t){return(t+="")[0]===Ao?t.slice(1):t}function p(t){return h(t)in this._}function g(t){return(t=h(t))in this._&&delete this._[t]}function v(){var t=[];for(var e in this._)t.push(d(e));return t}function m(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function b(){this._=Object.create(null)}function x(t){return t}function _(t,e,r){return function(){var n=r.apply(e,arguments);return n===e?t:n}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var r=0,n=Mo.length;n>r;++r){var i=Mo[r]+e;if(i in t)return i}}function k(){}function A(){}function M(t){function e(){for(var e,n=r,i=-1,a=n.length;++ir;r++)for(var i,a=t[r],o=0,s=a.length;s>o;o++)(i=a[o])&&e(i,o,r);return t}function Y(t){return Eo(t,Oo),t}function X(t){var e,r;return function(n,i,a){var o,s=t[a].update,l=s.length;for(a!=r&&(r=a,e=0),i>=e&&(e=i+1);!(o=s[e])&&++e0&&(t=t.slice(0,s));var c=Io.get(t);return c&&(t=c,l=K),s?e?i:n:e?k:a}function Z(t,e){return function(r){var n=co.event;co.event=r,e[0]=this.__data__;try{t.apply(this,e)}finally{co.event=n}}}function K(t,e){var r=Z(t,e);return function(t){var e=this,n=t.relatedTarget;n&&(n===e||8&n.compareDocumentPosition(e))||r.call(e,t)}}function Q(t){var r=".dragsuppress-"+ ++jo,i="click"+r,a=co.select(n(t)).on("touchmove"+r,T).on("dragstart"+r,T).on("selectstart"+r,T);if(null==No&&(No="onselectstart"in t?!1:w(t.style,"userSelect")),No){var o=e(t).style,s=o[No];o[No]="none"}return function(t){if(a.on(r,null),No&&(o[No]=s),t){var e=function(){a.on(i,null)};a.on(i,function(){T(),e()},!0),setTimeout(e,0)}}}function $(t,e){e.changedTouches&&(e=e.changedTouches[0]);var r=t.ownerSVGElement||t;if(r.createSVGPoint){var i=r.createSVGPoint();if(0>Fo){var a=n(t);if(a.scrollX||a.scrollY){r=co.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();Fo=!(o.f||o.e),r.remove()}}return Fo?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}function J(){return co.event.changedTouches[0].identifier}function tt(t){return t>0?1:0>t?-1:0}function et(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function rt(t){return t>1?0:-1>t?Uo:Math.acos(t)}function nt(t){return t>1?Ho:-1>t?-Ho:Math.asin(t)}function it(t){return((t=Math.exp(t))-1/t)/2}function at(t){return((t=Math.exp(t))+1/t)/2}function ot(t){return((t=Math.exp(2*t))-1)/(t+1)}function st(t){return(t=Math.sin(t/2))*t}function lt(){}function ct(t,e,r){return this instanceof ct?(this.h=+t,this.s=+e,void(this.l=+r)):arguments.length<2?t instanceof ct?new ct(t.h,t.s,t.l):kt(""+t,At,ct):new ct(t,e,r)}function ut(t,e,r){function n(t){return t>360?t-=360:0>t&&(t+=360),60>t?a+(o-a)*t/60:180>t?o:240>t?a+(o-a)*(240-t)/60:a}function i(t){return Math.round(255*n(t))}var a,o;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:0>e?0:e>1?1:e,r=0>r?0:r>1?1:r,o=.5>=r?r*(1+e):r+e-r*e,a=2*r-o,new bt(i(t+120),i(t),i(t-120))}function ft(t,e,r){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+r)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof dt?gt(t.l,t.a,t.b):gt((t=Mt((t=co.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,r)}function ht(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new dt(r,Math.cos(t*=Go)*e,Math.sin(t)*e)}function dt(t,e,r){return this instanceof dt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof dt?new dt(t.l,t.a,t.b):t instanceof ft?ht(t.h,t.c,t.l):Mt((t=bt(t)).r,t.g,t.b):new dt(t,e,r)}function pt(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return i=vt(i)*rs,n=vt(n)*ns,a=vt(a)*is,new bt(yt(3.2404542*i-1.5371385*n-.4985314*a),yt(-.969266*i+1.8760108*n+.041556*a),yt(.0556434*i-.2040259*n+1.0572252*a))}function gt(t,e,r){return t>0?new ft(Math.atan2(r,e)*Yo,Math.sqrt(e*e+r*r),t):new ft(NaN,NaN,t)}function vt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function mt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function bt(t,e,r){return this instanceof bt?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof bt?new bt(t.r,t.g,t.b):kt(""+t,bt,ut):new bt(t,e,r)}function xt(t){return new bt(t>>16,t>>8&255,255&t)}function _t(t){return xt(t)+""}function wt(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function kt(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(Et(i[0]),Et(i[1]),Et(i[2]))}return(a=ss.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o=o>>4|o,s=240&a,s=s>>4|s,l=15&a,l=l<<4|l):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function At(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=.5>l?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(r>e?6:0):e==o?(r-t)/s+2:(t-e)/s+4,n*=60):(n=NaN,i=l>0&&1>l?0:n),new ct(n,i,l)}function Mt(t,e,r){t=Tt(t),e=Tt(e),r=Tt(r);var n=mt((.4124564*t+.3575761*e+.1804375*r)/rs),i=mt((.2126729*t+.7151522*e+.072175*r)/ns),a=mt((.0193339*t+.119192*e+.9503041*r)/is);return dt(116*i-16,500*(n-i),200*(i-a))}function Tt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Et(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function Lt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,r,n){return 2===arguments.length&&"function"==typeof r&&(n=r,r=null),Ct(e,r,t,n)}}function Ct(t,e,r,n){function i(){var t,e=l.status;if(!e&&Pt(l)||e>=200&&300>e||304===e){try{t=r.call(a,l)}catch(n){return void o.error.call(a,n)}o.load.call(a,t)}else o.error.call(a,l)}var a={},o=co.dispatch("beforesend","progress","load","error"),s={},l=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(t)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(t){var e=co.event;co.event=t;try{o.progress.call(a,l)}finally{co.event=e}},a.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",a)},a.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",a):e},a.responseType=function(t){return arguments.length?(c=t,a):c},a.response=function(t){return r=t,a},["get","post"].forEach(function(t){a[t]=function(){return a.send.apply(a,[t].concat(fo(arguments)))}}),a.send=function(r,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),l.open(r,t,!0),null==e||"accept"in s||(s.accept=e+",*/*"),l.setRequestHeader)for(var u in s)l.setRequestHeader(u,s[u]);return null!=e&&l.overrideMimeType&&l.overrideMimeType(e),null!=c&&(l.responseType=c),null!=i&&a.on("error",i).on("load",function(t){i(null,t)}),o.beforesend.call(a,l),l.send(null==n?null:n),a},a.abort=function(){return l.abort(),a},co.rebind(a,o,"on"),null==n?a:a.get(zt(n))}function zt(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}function Pt(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Rt(t,e,r){var n=arguments.length;2>n&&(e=0),3>n&&(r=Date.now());var i=r+e,a={c:t,t:i,n:null};return cs?cs.n=a:ls=a,cs=a,us||(fs=clearTimeout(fs),us=1,hs(Ot)),a}function Ot(){var t=It(),e=Nt()-t;e>24?(isFinite(e)&&(clearTimeout(fs),fs=setTimeout(Ot,e)),us=0):(us=1,hs(Ot))}function It(){for(var t=Date.now(),e=ls;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Nt(){for(var t,e=ls,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}}function Dt(t){var e=t.decimal,r=t.thousands,n=t.grouping,i=t.currency,a=n&&r?function(t,e){for(var i=t.length,a=[],o=0,s=n[0],l=0;i>0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>e));)s=n[o=(o+1)%n.length];return a.reverse().join(r)}:x;return function(t){var r=ps.exec(t),n=r[1]||" ",o=r[2]||">",s=r[3]||"-",l=r[4]||"",c=r[5],u=+r[6],f=r[7],h=r[8],d=r[9],p=1,g="",v="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(c||"0"===n&&"="===o)&&(c=n="0",o="="),d){case"n":f=!0,d="g";break;case"%":p=100,v="%",d="f";break;case"p":p=100,v="%",d="r";break;case"b":case"o":case"x":case"X":"#"===l&&(g="0"+d.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,d="r"}"$"===l&&(g=i[0],v=i[1]),"r"!=d||h||(d="g"),null!=h&&("g"==d?h=Math.max(1,Math.min(21,h)):"e"!=d&&"f"!=d||(h=Math.max(0,Math.min(20,h)))),d=gs.get(d)||Bt;var b=c&&f;return function(t){var r=v;if(m&&t%1)return"";var i=0>t||0===t&&0>1/t?(t=-t,"-"):"-"===s?"":s;if(0>p){var l=co.formatPrefix(t,h);t=l.scale(t),r=l.symbol+v}else t*=p;t=d(t,h);var x,_,w=t.lastIndexOf(".");if(0>w){var k=y?t.lastIndexOf("e"):-1;0>k?(x=t,_=""):(x=t.substring(0,k),_=t.substring(k))}else x=t.substring(0,w),_=e+t.substring(w+1);!c&&f&&(x=a(x,1/0));var A=g.length+x.length+_.length+(b?0:i.length),M=u>A?new Array(A=u-A+1).join(n):"";return b&&(x=a(M+x,M.length?u-_.length:1/0)),i+=g,t=x+_,("<"===o?i+t+M:">"===o?M+i+t:"^"===o?M.substring(0,A>>=1)+i+t+M.substring(A):i+(b?t:M+t))+r}}}function Bt(t){return t+""}function Ut(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Vt(t,e,r){function n(e){var r=t(e),n=a(r,1);return n-e>e-r?r:n}function i(r){return e(r=t(new ms(r-1)),1),r}function a(t,r){return e(t=new ms(+t),r),t}function o(t,n,a){var o=i(t),s=[];if(a>1)for(;n>o;)r(o)%a||s.push(new Date(+o)),e(o,1);else for(;n>o;)s.push(new Date(+o)),e(o,1);return s}function s(t,e,r){try{ms=Ut;var n=new Ut;return n._=t,o(n,e,r)}finally{ms=Date}}t.floor=t,t.round=n,t.ceil=i,t.offset=a,t.range=o;var l=t.utc=qt(t);return l.floor=l,l.round=qt(n),l.ceil=qt(i),l.offset=qt(a),l.range=s,t}function qt(t){return function(e,r){try{ms=Ut;var n=new Ut;return n._=e,t(n,r)._}finally{ms=Date}}}function Ht(t){function e(t){function e(e){for(var r,i,a,o=[],s=-1,l=0;++ss;){if(n>=c)return-1;if(i=e.charCodeAt(s++),37===i){if(o=e.charAt(s++),a=S[o in bs?e.charAt(s++):o],!a||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}function n(t,e,r){w.lastIndex=0;var n=w.exec(e.slice(r));return n?(t.w=k.get(n[0].toLowerCase()),r+n[0].length):-1}function i(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.w=_.get(n[0].toLowerCase()),r+n[0].length):-1}function a(t,e,r){T.lastIndex=0;var n=T.exec(e.slice(r));return n?(t.m=E.get(n[0].toLowerCase()),r+n[0].length):-1}function o(t,e,r){A.lastIndex=0;var n=A.exec(e.slice(r));return n?(t.m=M.get(n[0].toLowerCase()),r+n[0].length):-1}function s(t,e,n){return r(t,L.c.toString(),e,n)}function l(t,e,n){return r(t,L.x.toString(),e,n)}function c(t,e,n){return r(t,L.X.toString(),e,n)}function u(t,e,r){var n=b.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)}var f=t.dateTime,h=t.date,d=t.time,p=t.periods,g=t.days,v=t.shortDays,m=t.months,y=t.shortMonths;e.utc=function(t){function r(t){try{ms=Ut;var e=new ms;return e._=t,n(e)}finally{ms=Date}}var n=e(t);return r.parse=function(t){try{ms=Ut;var e=n.parse(t);return e&&e._}finally{ms=Date}},r.toString=n.toString,r},e.multi=e.utc.multi=ue;var b=co.map(),x=Yt(g),_=Xt(g),w=Yt(v),k=Xt(v),A=Yt(m),M=Xt(m),T=Yt(y),E=Xt(y);p.forEach(function(t,e){b.set(t.toLowerCase(),e)});var L={a:function(t){return v[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return m[t.getMonth()]},c:e(f),d:function(t,e){return Gt(t.getDate(),e,2)},e:function(t,e){return Gt(t.getDate(),e,2)},H:function(t,e){return Gt(t.getHours(),e,2)},I:function(t,e){return Gt(t.getHours()%12||12,e,2)},j:function(t,e){return Gt(1+vs.dayOfYear(t),e,3)},L:function(t,e){return Gt(t.getMilliseconds(),e,3)},m:function(t,e){return Gt(t.getMonth()+1,e,2)},M:function(t,e){return Gt(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Gt(t.getSeconds(),e,2)},U:function(t,e){return Gt(vs.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Gt(vs.mondayOfYear(t),e,2)},x:e(h),X:e(d),y:function(t,e){return Gt(t.getFullYear()%100,e,2)},Y:function(t,e){return Gt(t.getFullYear()%1e4,e,4)},Z:le,"%":function(){return"%"}},S={a:n,A:i,b:a,B:o,c:s,d:re,e:re,H:ie,I:ie,j:ne,L:se,m:ee,M:ae,p:u,S:oe,U:Zt,w:Wt,W:Kt,x:l,X:c,y:$t,Y:Qt,Z:Jt,"%":ce};return e}function Gt(t,e,r){var n=0>t?"-":"",i=(n?-t:t)+"",a=i.length;return n+(r>a?new Array(r-a+1).join(e)+i:i)}function Yt(t){return new RegExp("^(?:"+t.map(co.requote).join("|")+")","i")}function Xt(t){for(var e=new f,r=-1,n=t.length;++r68?1900:2e3)}function ee(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function re(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function ne(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function ie(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function ae(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function oe(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function se(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function le(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=wo(e)/60|0,i=wo(e)%60;return r+Gt(n,"0",2)+Gt(i,"0",2)}function ce(t,e,r){_s.lastIndex=0;var n=_s.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function ue(t){for(var e=t.length,r=-1;++r=0?1:-1,s=o*r,l=Math.cos(e),c=Math.sin(e),u=a*c,f=i*l+u*Math.cos(s),h=u*o*Math.sin(s);Es.add(Math.atan2(h,f)),n=t,i=l,a=c}var e,r,n,i,a;Ls.point=function(o,s){Ls.point=t,n=(e=o)*Go,i=Math.cos(s=(r=s)*Go/2+Uo/4),a=Math.sin(s)},Ls.lineEnd=function(){t(e,r)}}function me(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function be(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function xe(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ke(t){return[Math.atan2(t[1],t[0]),nt(t[2])]}function Ae(t,e){return wo(t[0]-e[0])s;++s)i.point((r=t[s])[0],r[1]);return void i.lineEnd()}var l=new Oe(r,t,null,!0),c=new Oe(r,null,l,!1);l.o=c,a.push(l),o.push(c),l=new Oe(n,t,null,!1),c=new Oe(n,null,l,!0),l.o=c,a.push(l),o.push(c)}}),o.sort(e),Re(a),Re(o),a.length){for(var s=0,l=r,c=o.length;c>s;++s)o[s].e=l=!l;for(var u,f,h=a[0];;){for(var d=h,p=!0;d.v;)if((d=d.n)===h)return;u=d.z,i.lineStart();do{if(d.v=d.o.v=!0,d.e){if(p)for(var s=0,c=u.length;c>s;++s)i.point((f=u[s])[0],f[1]);else n(d.x,d.n.x,1,i);d=d.n}else{if(p){u=d.p.z;for(var s=u.length-1;s>=0;--s)i.point((f=u[s])[0],f[1])}else n(d.x,d.p.x,-1,i);d=d.p}d=d.o,u=d.z,p=!p}while(!d.v);i.lineEnd()}}}function Re(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n0){for(_||(a.polygonStart(),_=!0),a.lineStart();++o1&&2&e&&r.push(r.pop().concat(r.shift())),d.push(r.filter(Ne))}var d,p,g,v=e(a),m=i.invert(n[0],n[1]),y={point:o,lineStart:l,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=f,y.lineEnd=h,d=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=l,y.lineEnd=c,d=co.merge(d);var t=Ve(m,p);d.length?(_||(a.polygonStart(),_=!0),Pe(d,Fe,t,r,a)):t&&(_||(a.polygonStart(),_=!0),a.lineStart(),r(null,null,1,a),a.lineEnd()),_&&(a.polygonEnd(),_=!1),d=p=null},sphere:function(){a.polygonStart(),a.lineStart(),r(null,null,1,a),a.lineEnd(),a.polygonEnd()}},b=je(),x=e(b),_=!1;return y}}function Ne(t){return t.length>1}function je(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:k,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Fe(t,e){return((t=t.x)[0]<0?t[1]-Ho-Do:Ho-t[1])-((e=e.x)[0]<0?e[1]-Ho-Do:Ho-e[1])}function De(t){var e,r=NaN,n=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?Uo:-Uo,l=wo(a-r);wo(l-Uo)0?Ho:-Ho),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=Uo&&(wo(r-i)Do?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}function Ue(t,e,r,n){var i;if(null==t)i=r*Ho,n.point(-Uo,i),n.point(0,i),n.point(Uo,i),n.point(Uo,0),n.point(Uo,-i),n.point(0,-i),n.point(-Uo,-i),n.point(-Uo,0),n.point(-Uo,i);else if(wo(t[0]-e[0])>Do){var a=t[0]s;++s){var c=e[s],u=c.length;if(u)for(var f=c[0],h=f[0],d=f[1]/2+Uo/4,p=Math.sin(d),g=Math.cos(d),v=1;;){v===u&&(v=0),t=c[v];var m=t[0],y=t[1]/2+Uo/4,b=Math.sin(y),x=Math.cos(y),_=m-h,w=_>=0?1:-1,k=w*_,A=k>Uo,M=p*b;if(Es.add(Math.atan2(M*w*Math.sin(k),g*x+M*Math.cos(k))),a+=A?_+w*Vo:_,A^h>=r^m>=r){var T=be(me(f),me(t));we(T);var E=be(i,T);we(E);var L=(A^_>=0?-1:1)*nt(E[2]);(n>L||n===L&&(T[0]||T[1]))&&(o+=A^_>=0?1:-1)}if(!v++)break;h=m,p=b,g=x,f=t}}return(-Do>a||Do>a&&0>Es)^1&o}function qe(t){function e(t,e){return Math.cos(t)*Math.cos(e)>a}function r(t){var r,a,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(f,h){var d,p=[f,h],g=e(f,h),v=o?g?0:i(f,h):g?i(f+(0>f?Uo:-Uo),h):0;if(!r&&(c=l=g)&&t.lineStart(),g!==l&&(d=n(r,p),(Ae(r,d)||Ae(p,d))&&(p[0]+=Do,p[1]+=Do,g=e(p[0],p[1]))),g!==l)u=0,g?(t.lineStart(),d=n(p,r),t.point(d[0],d[1])):(d=n(r,p),t.point(d[0],d[1]),t.lineEnd()),r=d;else if(s&&r&&o^g){var m;v&a||!(m=n(p,r,!0))||(u=0,o?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||r&&Ae(r,p)||t.point(p[0],p[1]),r=p,l=g,a=v},lineEnd:function(){l&&t.lineEnd(),r=null},clean:function(){return u|(c&&l)<<1}}}function n(t,e,r){var n=me(t),i=me(e),o=[1,0,0],s=be(n,i),l=ye(s,s),c=s[0],u=l-c*c;if(!u)return!r&&t;var f=a*l/u,h=-a*c/u,d=be(o,s),p=_e(o,f),g=_e(s,h);xe(p,g);var v=d,m=ye(p,v),y=ye(v,v),b=m*m-y*(ye(p,p)-1);if(!(0>b)){var x=Math.sqrt(b),_=_e(v,(-m-x)/y);if(xe(_,p),_=ke(_),!r)return _;var w,k=t[0],A=e[0],M=t[1],T=e[1];k>A&&(w=k,k=A,A=w);var E=A-k,L=wo(E-Uo)E;if(!L&&M>T&&(w=M,M=T,T=w),S?L?M+T>0^_[1]<(wo(_[0]-k)Uo^(k<=_[0]&&_[0]<=A)){var C=_e(v,(-m+x)/y);return xe(C,p),[_,ke(C)]}}}function i(e,r){var n=o?t:Uo-t,i=0;return-n>e?i|=1:e>n&&(i|=2),-n>r?i|=4:r>n&&(i|=8),i}var a=Math.cos(t),o=a>0,s=wo(a)>Do,l=vr(t,6*Go);return Ie(e,r,l,o?[0,-t]:[-Uo,t-Uo])}function He(t,e,r,n){return function(i){var a,o=i.a,s=i.b,l=o.x,c=o.y,u=s.x,f=s.y,h=0,d=1,p=u-l,g=f-c;if(a=t-l,p||!(a>0)){if(a/=p,0>p){if(h>a)return;d>a&&(d=a)}else if(p>0){if(a>d)return;a>h&&(h=a)}if(a=r-l,p||!(0>a)){if(a/=p,0>p){if(a>d)return;a>h&&(h=a)}else if(p>0){if(h>a)return;d>a&&(d=a)}if(a=e-c,g||!(a>0)){if(a/=g,0>g){if(h>a)return;d>a&&(d=a)}else if(g>0){if(a>d)return;a>h&&(h=a)}if(a=n-c,g||!(0>a)){if(a/=g,0>g){if(a>d)return;a>h&&(h=a)}else if(g>0){if(h>a)return;d>a&&(d=a)}return h>0&&(i.a={x:l+h*p,y:c+h*g}),1>d&&(i.b={x:l+d*p,y:c+d*g}),i}}}}}}function Ge(t,e,r,n){function i(n,i){return wo(n[0]-t)0?0:3:wo(n[0]-r)0?2:1:wo(n[1]-e)0?1:0:i>0?3:2}function a(t,e){return o(t.x,e.x)}function o(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}return function(s){function l(t){for(var e=0,r=v.length,n=t[1],i=0;r>i;++i)for(var a,o=1,s=v[i],l=s.length,c=s[0];l>o;++o)a=s[o],c[1]<=n?a[1]>n&&et(c,a,t)>0&&++e:a[1]<=n&&et(c,a,t)<0&&--e,c=a;return 0!==e}function c(a,s,l,c){var u=0,f=0;if(null==a||(u=i(a,l))!==(f=i(s,l))||o(a,s)<0^l>0){do c.point(0===u||3===u?t:r,u>1?n:e);while((u=(u+l+4)%4)!==f)}else c.point(s[0],s[1])}function u(i,a){return i>=t&&r>=i&&a>=e&&n>=a}function f(t,e){u(t,e)&&s.point(t,e)}function h(){S.point=p,v&&v.push(m=[]),A=!0,k=!1,_=w=NaN}function d(){g&&(p(y,b),x&&k&&E.rejoin(),g.push(E.buffer())),S.point=f,k&&s.lineEnd()}function p(t,e){t=Math.max(-Vs,Math.min(Vs,t)),e=Math.max(-Vs,Math.min(Vs,e));var r=u(t,e);if(v&&m.push([t,e]),A)y=t,b=e,x=r,A=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&k)s.point(t,e);else{var n={a:{x:_,y:w},b:{x:t,y:e}};L(n)?(k||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),M=!1):r&&(s.lineStart(),s.point(t,e),M=!1)}_=t,w=e,k=r}var g,v,m,y,b,x,_,w,k,A,M,T=s,E=je(),L=He(t,e,r,n),S={point:f,lineStart:h,lineEnd:d,polygonStart:function(){s=E,g=[],v=[],M=!0},polygonEnd:function(){s=T,g=co.merge(g);var e=l([t,n]),r=M&&e,i=g.length;(r||i)&&(s.polygonStart(),r&&(s.lineStart(),c(null,null,1,s),s.lineEnd()),i&&Pe(g,a,e,c,s),s.polygonEnd()),g=v=m=null}};return S}}function Ye(t){var e=0,r=Uo/3,n=lr(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*Uo/180,r=t[1]*Uo/180):[e/Uo*180,r/Uo*180]},i}function Xe(t,e){function r(t,e){var r=Math.sqrt(a-2*i*Math.sin(e))/i;return[r*Math.sin(t*=i),o-r*Math.cos(t)]}var n=Math.sin(t),i=(n+Math.sin(e))/2,a=1+n*(2*i-n),o=Math.sqrt(a)/i;return r.invert=function(t,e){var r=o-e;return[Math.atan2(t,r)/i,nt((a-(t*t+r*r)*i*i)/(2*i))]},r}function We(){function t(t,e){Hs+=i*t-n*e,n=t,i=e}var e,r,n,i;Zs.point=function(a,o){Zs.point=t,e=n=a,r=i=o},Zs.lineEnd=function(){t(e,r)}}function Ze(t,e){Gs>t&&(Gs=t),t>Xs&&(Xs=t),Ys>e&&(Ys=e),e>Ws&&(Ws=e)}function Ke(){function t(t,e){o.push("M",t,",",e,a)}function e(t,e){o.push("M",t,",",e),s.point=r}function r(t,e){o.push("L",t,",",e)}function n(){s.point=t}function i(){o.push("Z")}var a=Qe(4.5),o=[],s={point:t,lineStart:function(){s.point=e},lineEnd:n,polygonStart:function(){s.lineEnd=i},polygonEnd:function(){s.lineEnd=n,s.point=t},pointRadius:function(t){return a=Qe(t),s},result:function(){if(o.length){var t=o.join("");return o=[],t}}};return s}function Qe(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function $e(t,e){zs+=t,Ps+=e,++Rs}function Je(){function t(t,n){var i=t-e,a=n-r,o=Math.sqrt(i*i+a*a);Os+=o*(e+t)/2,Is+=o*(r+n)/2,Ns+=o,$e(e=t,r=n)}var e,r;Qs.point=function(n,i){Qs.point=t,$e(e=n,r=i)}}function tr(){Qs.point=$e}function er(){function t(t,e){var r=t-n,a=e-i,o=Math.sqrt(r*r+a*a);Os+=o*(n+t)/2,Is+=o*(i+e)/2,Ns+=o,o=i*t-n*e,js+=o*(n+t),Fs+=o*(i+e),Ds+=3*o,$e(n=t,i=e)}var e,r,n,i;Qs.point=function(a,o){Qs.point=t,$e(e=n=a,r=i=o)},Qs.lineEnd=function(){t(e,r)}}function rr(t){function e(e,r){t.moveTo(e+o,r),t.arc(e,r,o,0,Vo); -}function r(e,r){t.moveTo(e,r),s.point=n}function n(e,r){t.lineTo(e,r)}function i(){s.point=e}function a(){t.closePath()}var o=4.5,s={point:e,lineStart:function(){s.point=r},lineEnd:i,polygonStart:function(){s.lineEnd=a},polygonEnd:function(){s.lineEnd=i,s.point=e},pointRadius:function(t){return o=t,s},result:k};return s}function nr(t){function e(t){return(s?n:r)(t)}function r(e){return or(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})}function n(e){function r(r,n){r=t(r,n),e.point(r[0],r[1])}function n(){b=NaN,A.point=a,e.lineStart()}function a(r,n){var a=me([r,n]),o=t(r,n);i(b,x,y,_,w,k,b=o[0],x=o[1],y=r,_=a[0],w=a[1],k=a[2],s,e),e.point(b,x)}function o(){A.point=r,e.lineEnd()}function l(){n(),A.point=c,A.lineEnd=u}function c(t,e){a(f=t,h=e),d=b,p=x,g=_,v=w,m=k,A.point=a}function u(){i(b,x,y,_,w,k,d,p,f,g,v,m,s,e),A.lineEnd=o,o()}var f,h,d,p,g,v,m,y,b,x,_,w,k,A={point:r,lineStart:n,lineEnd:o,polygonStart:function(){e.polygonStart(),A.lineStart=l},polygonEnd:function(){e.polygonEnd(),A.lineStart=n}};return A}function i(e,r,n,s,l,c,u,f,h,d,p,g,v,m){var y=u-e,b=f-r,x=y*y+b*b;if(x>4*a&&v--){var _=s+d,w=l+p,k=c+g,A=Math.sqrt(_*_+w*w+k*k),M=Math.asin(k/=A),T=wo(wo(k)-1)a||wo((y*C+b*z)/x-.5)>.3||o>s*d+l*p+c*g)&&(i(e,r,n,s,l,c,L,S,T,_/=A,w/=A,k,v,m),m.point(L,S),i(L,S,T,_,w,k,u,f,h,d,p,g,v,m))}}var a=.5,o=Math.cos(30*Go),s=16;return e.precision=function(t){return arguments.length?(s=(a=t*t)>0&&16,e):Math.sqrt(a)},e}function ir(t){var e=nr(function(e,r){return t([e*Yo,r*Yo])});return function(t){return cr(e(t))}}function ar(t){this.stream=t}function or(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sr(t){return lr(function(){return t})()}function lr(t){function e(t){return t=s(t[0]*Go,t[1]*Go),[t[0]*h+l,c-t[1]*h]}function r(t){return t=s.invert((t[0]-l)/h,(c-t[1])/h),t&&[t[0]*Yo,t[1]*Yo]}function n(){s=Ce(o=hr(m,y,b),a);var t=a(g,v);return l=d-t[0]*h,c=p+t[1]*h,i()}function i(){return u&&(u.valid=!1,u=null),e}var a,o,s,l,c,u,f=nr(function(t,e){return t=a(t,e),[t[0]*h+l,c-t[1]*h]}),h=150,d=480,p=250,g=0,v=0,m=0,y=0,b=0,_=Us,w=x,k=null,A=null;return e.stream=function(t){return u&&(u.valid=!1),u=cr(_(o,f(w(t)))),u.valid=!0,u},e.clipAngle=function(t){return arguments.length?(_=null==t?(k=t,Us):qe((k=+t)*Go),i()):k},e.clipExtent=function(t){return arguments.length?(A=t,w=t?Ge(t[0][0],t[0][1],t[1][0],t[1][1]):x,i()):A},e.scale=function(t){return arguments.length?(h=+t,n()):h},e.translate=function(t){return arguments.length?(d=+t[0],p=+t[1],n()):[d,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Go,v=t[1]%360*Go,n()):[g*Yo,v*Yo]},e.rotate=function(t){return arguments.length?(m=t[0]%360*Go,y=t[1]%360*Go,b=t.length>2?t[2]%360*Go:0,n()):[m*Yo,y*Yo,b*Yo]},co.rebind(e,f,"precision"),function(){return a=t.apply(this,arguments),e.invert=a.invert&&r,n()}}function cr(t){return or(t,function(e,r){t.point(e*Go,r*Go)})}function ur(t,e){return[t,e]}function fr(t,e){return[t>Uo?t-Vo:-Uo>t?t+Vo:t,e]}function hr(t,e,r){return t?e||r?Ce(pr(t),gr(e,r)):pr(t):e||r?gr(e,r):fr}function dr(t){return function(e,r){return e+=t,[e>Uo?e-Vo:-Uo>e?e+Vo:e,r]}}function pr(t){var e=dr(t);return e.invert=dr(-t),e}function gr(t,e){function r(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*n+s*i;return[Math.atan2(l*a-u*o,s*n-c*i),nt(u*a+l*o)]}var n=Math.cos(t),i=Math.sin(t),a=Math.cos(e),o=Math.sin(e);return r.invert=function(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*a-l*o;return[Math.atan2(l*a+c*o,s*n+u*i),nt(u*n-s*i)]},r}function vr(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=mr(r,i),a=mr(r,a),(o>0?a>i:i>a)&&(i+=o*Vo)):(i=t+o*Vo,a=t-.5*l);for(var c,u=i;o>0?u>a:a>u;u-=l)s.point((c=ke([r,-n*Math.cos(u),-n*Math.sin(u)]))[0],c[1])}}function mr(t,e){var r=me(e);r[0]-=t,we(r);var n=rt(-r[1]);return((-r[2]<0?-n:n)+2*Math.PI-Do)%(2*Math.PI)}function yr(t,e,r){var n=co.range(t,e-Do,r).concat(e);return function(t){return n.map(function(e){return[t,e]})}}function br(t,e,r){var n=co.range(t,e-Do,r).concat(e);return function(t){return n.map(function(e){return[e,t]})}}function xr(t){return t.source}function _r(t){return t.target}function wr(t,e,r,n){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(n),s=Math.sin(n),l=i*Math.cos(t),c=i*Math.sin(t),u=o*Math.cos(r),f=o*Math.sin(r),h=2*Math.asin(Math.sqrt(st(n-e)+i*o*st(r-t))),d=1/Math.sin(h),p=h?function(t){var e=Math.sin(t*=h)*d,r=Math.sin(h-t)*d,n=r*l+e*u,i=r*c+e*f,o=r*a+e*s;return[Math.atan2(i,n)*Yo,Math.atan2(o,Math.sqrt(n*n+i*i))*Yo]}:function(){return[t*Yo,e*Yo]};return p.distance=h,p}function kr(){function t(t,i){var a=Math.sin(i*=Go),o=Math.cos(i),s=wo((t*=Go)-e),l=Math.cos(s);$s+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=n*a-r*o*l)*s),r*a+n*o*l),e=t,r=a,n=o}var e,r,n;Js.point=function(i,a){e=i*Go,r=Math.sin(a*=Go),n=Math.cos(a),Js.point=t},Js.lineEnd=function(){Js.point=Js.lineEnd=k}}function Ar(t,e){function r(e,r){var n=Math.cos(e),i=Math.cos(r),a=t(n*i);return[a*i*Math.sin(e),a*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),i=e(n),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,n*o),Math.asin(n&&r*a/n)]},r}function Mr(t,e){function r(t,e){o>0?-Ho+Do>e&&(e=-Ho+Do):e>Ho-Do&&(e=Ho-Do);var r=o/Math.pow(i(e),a);return[r*Math.sin(a*t),o-r*Math.cos(a*t)]}var n=Math.cos(t),i=function(t){return Math.tan(Uo/4+t/2)},a=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(i(e)/i(t)),o=n*Math.pow(i(t),a)/a;return a?(r.invert=function(t,e){var r=o-e,n=tt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(o/n,1/a))-Ho]},r):Er}function Tr(t,e){function r(t,e){var r=a-e;return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}var n=Math.cos(t),i=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),a=n/i+t;return wo(i)i;i++){for(;n>1&&et(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function Rr(t,e){return t[0]-e[0]||t[1]-e[1]}function Or(t,e,r){return(r[0]-e[0])*(t[1]-e[1])<(r[1]-e[1])*(t[0]-e[0])}function Ir(t,e,r,n){var i=t[0],a=r[0],o=e[0]-i,s=n[0]-a,l=t[1],c=r[1],u=e[1]-l,f=n[1]-c,h=(s*(l-c)-f*(i-a))/(f*o-s*u);return[i+h*o,l+h*u]}function Nr(t){var e=t[0],r=t[t.length-1];return!(e[0]-r[0]||e[1]-r[1])}function jr(){an(this),this.edge=this.site=this.circle=null}function Fr(t){var e=fl.pop()||new jr;return e.site=t,e}function Dr(t){Zr(t),ll.remove(t),fl.push(t),an(t)}function Br(t){var e=t.circle,r=e.x,n=e.cy,i={x:r,y:n},a=t.P,o=t.N,s=[t];Dr(t);for(var l=a;l.circle&&wo(r-l.circle.x)u;++u)c=s[u],l=s[u-1],en(c.edge,l.site,c.site,i);l=s[0],c=s[f-1],c.edge=Jr(l.site,c.site,null,i),Wr(l),Wr(c)}function Ur(t){for(var e,r,n,i,a=t.x,o=t.y,s=ll._;s;)if(n=Vr(s,o)-a,n>Do)s=s.L;else{if(i=a-qr(s,o),!(i>Do)){n>-Do?(e=s.P,r=s):i>-Do?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=Fr(t);if(ll.insert(e,l),e||r){if(e===r)return Zr(e),r=Fr(e.site),ll.insert(l,r),l.edge=r.edge=Jr(e.site,l.site),Wr(e),void Wr(r);if(!r)return void(l.edge=Jr(e.site,l.site));Zr(e),Zr(r);var c=e.site,u=c.x,f=c.y,h=t.x-u,d=t.y-f,p=r.site,g=p.x-u,v=p.y-f,m=2*(h*v-d*g),y=h*h+d*d,b=g*g+v*v,x={x:(v*y-d*b)/m+u,y:(h*b-g*y)/m+f};en(r.edge,c,p,x),l.edge=Jr(c,t,null,x),r.edge=Jr(t,p,null,x),Wr(e),Wr(r)}}function Vr(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-(1/0);r=o.site;var s=r.x,l=r.y,c=l-e;if(!c)return s;var u=s-n,f=1/a-1/c,h=u/c;return f?(-h+Math.sqrt(h*h-2*f*(u*u/(-2*c)-l+c/2+i-a/2)))/f+n:(n+s)/2}function qr(t,e){var r=t.N;if(r)return Vr(r,e);var n=t.site;return n.y===e?n.x:1/0}function Hr(t){this.site=t,this.edges=[]}function Gr(t){for(var e,r,n,i,a,o,s,l,c,u,f=t[0][0],h=t[1][0],d=t[0][1],p=t[1][1],g=sl,v=g.length;v--;)if(a=g[v],a&&a.prepare())for(s=a.edges,l=s.length,o=0;l>o;)u=s[o].end(),n=u.x,i=u.y,c=s[++o%l].start(),e=c.x,r=c.y,(wo(n-e)>Do||wo(i-r)>Do)&&(s.splice(o,0,new rn(tn(a.site,u,wo(n-f)Do?{x:f,y:wo(e-f)Do?{x:wo(r-p)Do?{x:h,y:wo(e-h)Do?{x:wo(r-d)=-Bo)){var d=l*l+c*c,p=u*u+f*f,g=(f*d-c*p)/h,v=(l*p-u*d)/h,f=v+s,m=hl.pop()||new Xr;m.arc=t,m.site=i,m.x=g+o,m.y=f+Math.sqrt(g*g+v*v),m.cy=f,t.circle=m;for(var y=null,b=ul._;b;)if(m.yv||v>=s)return;if(h>p){if(a){if(a.y>=c)return}else a={x:v,y:l};r={x:v,y:c}}else{if(a){if(a.yn||n>1)if(h>p){if(a){if(a.y>=c)return}else a={x:(l-i)/n,y:l};r={x:(c-i)/n,y:c}}else{if(a){if(a.yd){if(a){if(a.x>=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xa||f>o||n>h||i>d)){if(p=t.point){var p,g=e-t.x,v=r-t.y,m=g*g+v*v;if(l>m){var y=Math.sqrt(l=m);n=e-y,i=r-y,a=e+y,o=r+y,s=p}}for(var b=t.nodes,x=.5*(u+h),_=.5*(f+d),w=e>=x,k=r>=_,A=k<<1|w,M=A+4;M>A;++A)if(t=b[3&A])switch(3&A){case 0:c(t,u,f,x,_);break;case 1:c(t,x,f,h,_);break;case 2:c(t,u,_,x,d);break;case 3:c(t,x,_,h,d)}}}(t,n,i,a,o),s}function mn(t,e){t=co.rgb(t),e=co.rgb(e);var r=t.r,n=t.g,i=t.b,a=e.r-r,o=e.g-n,s=e.b-i;return function(t){return"#"+wt(Math.round(r+a*t))+wt(Math.round(n+o*t))+wt(Math.round(i+s*t))}}function yn(t,e){var r,n={},i={};for(r in t)r in e?n[r]=_n(t[r],e[r]):i[r]=t[r];for(r in e)r in t||(i[r]=e[r]);return function(t){for(r in n)i[r]=n[r](t);return i}}function bn(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function xn(t,e){var r,n,i,a=pl.lastIndex=gl.lastIndex=0,o=-1,s=[],l=[];for(t+="",e+="";(r=pl.exec(t))&&(n=gl.exec(e));)(i=n.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:bn(r,n)})),a=gl.lastIndex;return an;++n)s[(r=l[n]).i]=r.x(t);return s.join("")})}function _n(t,e){for(var r,n=co.interpolators.length;--n>=0&&!(r=co.interpolators[n](t,e)););return r}function wn(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;s>r;++r)n.push(_n(t[r],e[r]));for(;a>r;++r)i[r]=t[r];for(;o>r;++r)i[r]=e[r];return function(t){for(r=0;s>r;++r)i[r]=n[r](t);return i}}function kn(t){return function(e){return 0>=e?0:e>=1?1:t(e)}}function An(t){return function(e){return 1-t(1-e)}}function Mn(t){return function(e){return.5*(.5>e?t(2*e):2-t(2-2*e))}}function Tn(t){return t*t}function En(t){return t*t*t}function Ln(t){if(0>=t)return 0;if(t>=1)return 1;var e=t*t,r=e*t;return 4*(.5>t?r:3*(t-e)+r-.75)}function Sn(t){return function(e){return Math.pow(e,t)}}function Cn(t){return 1-Math.cos(t*Ho)}function zn(t){return Math.pow(2,10*(t-1))}function Pn(t){return 1-Math.sqrt(1-t*t)}function Rn(t,e){var r;return arguments.length<2&&(e=.45),arguments.length?r=e/Vo*Math.asin(1/t):(t=1,r=e/4),function(n){return 1+t*Math.pow(2,-10*n)*Math.sin((n-r)*Vo/e)}}function On(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function In(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Nn(t,e){t=co.hcl(t),e=co.hcl(e);var r=t.h,n=t.c,i=t.l,a=e.h-r,o=e.c-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.c:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ht(r+a*t,n+o*t,i+s*t)+""}}function jn(t,e){t=co.hsl(t),e=co.hsl(e);var r=t.h,n=t.s,i=t.l,a=e.h-r,o=e.s-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.s:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ut(r+a*t,n+o*t,i+s*t)+""}}function Fn(t,e){t=co.lab(t),e=co.lab(e);var r=t.l,n=t.a,i=t.b,a=e.l-r,o=e.a-n,s=e.b-i;return function(t){return pt(r+a*t,n+o*t,i+s*t)+""}}function Dn(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function Bn(t){var e=[t.a,t.b],r=[t.c,t.d],n=Vn(e),i=Un(e,r),a=Vn(qn(r,e,-i))||0;e[0]*r[1]180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(Hn(r)+"rotate(",null,")")-2,x:bn(t,e)})):e&&r.push(Hn(r)+"rotate("+e+")")}function Xn(t,e,r,n){t!==e?n.push({i:r.push(Hn(r)+"skewX(",null,")")-2,x:bn(t,e)}):e&&r.push(Hn(r)+"skewX("+e+")")}function Wn(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(Hn(r)+"scale(",null,",",null,")");n.push({i:i-4,x:bn(t[0],e[0])},{i:i-2,x:bn(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(Hn(r)+"scale("+e+")")}function Zn(t,e){var r=[],n=[];return t=co.transform(t),e=co.transform(e),Gn(t.translate,e.translate,r,n),Yn(t.rotate,e.rotate,r,n),Xn(t.skew,e.skew,r,n),Wn(t.scale,e.scale,r,n),t=e=null,function(t){for(var e,i=-1,a=n.length;++i=0;)r.push(i[n])}function li(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++or;++r)(e=t[r][1])>i&&(n=r,i=e);return n}function bi(t){return t.reduce(xi,0)}function xi(t,e){return t+e[1]}function _i(t,e){return wi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wi(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function ki(t){return[co.min(t),co.max(t)]}function Ai(t,e){return t.value-e.value}function Mi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ti(t,e){t._pack_next=e,e._pack_prev=t}function Ei(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function Li(t){function e(t){u=Math.min(t.x-t.r,u),f=Math.max(t.x+t.r,f),h=Math.min(t.y-t.r,h),d=Math.max(t.y+t.r,d)}if((r=t.children)&&(c=r.length)){var r,n,i,a,o,s,l,c,u=1/0,f=-(1/0),h=1/0,d=-(1/0);if(r.forEach(Si),n=r[0],n.x=-n.r,n.y=0,e(n),c>1&&(i=r[1],i.x=i.r,i.y=0,e(i),c>2))for(a=r[2],Pi(n,i,a),e(a),Mi(n,a),n._pack_prev=a,Mi(a,i),i=n._pack_next,o=3;c>o;o++){Pi(n,i,a=r[o]);var p=0,g=1,v=1;for(s=i._pack_next;s!==i;s=s._pack_next,g++)if(Ei(s,a)){p=1;break}if(1==p)for(l=n._pack_prev;l!==s._pack_prev&&!Ei(l,a);l=l._pack_prev,v++);p?(v>g||g==v&&i.ro;o++)a=r[o],a.x-=m,a.y-=y,b=Math.max(b,a.r+Math.sqrt(a.x*a.x+a.y*a.y));t.r=b,r.forEach(Ci)}}function Si(t){t._pack_next=t._pack_prev=t}function Ci(t){delete t._pack_next,delete t._pack_prev}function zi(t,e,r,n){var i=t.children;if(t.x=e+=n*t.x,t.y=r+=n*t.y,t.r*=n,i)for(var a=-1,o=i.length;++a=0;)e=i[a],e.z+=r,e.m+=r,r+=e.s+(n+=e.c)}function Fi(t,e,r){return t.a.parent===e.parent?t.a:r}function Di(t){return 1+co.max(t,function(t){return t.y})}function Bi(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ui(t){var e=t.children;return e&&e.length?Ui(e[0]):t}function Vi(t){var e,r=t.children;return r&&(e=r.length)?Vi(r[e-1]):t}function qi(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Hi(t,e){var r=t.x+e[3],n=t.y+e[0],i=t.dx-e[1]-e[3],a=t.dy-e[0]-e[2];return 0>i&&(r+=i/2,i=0),0>a&&(n+=a/2,a=0),{x:r,y:n,dx:i,dy:a}}function Gi(t){var e=t[0],r=t[t.length-1];return r>e?[e,r]:[r,e]}function Yi(t){return t.rangeExtent?t.rangeExtent():Gi(t.range())}function Xi(t,e,r,n){var i=r(t[0],t[1]),a=n(e[0],e[1]);return function(t){return a(i(t))}}function Wi(t,e){var r,n=0,i=t.length-1,a=t[n],o=t[i];return a>o&&(r=n,n=i,i=r,r=a,a=o,o=r),t[n]=e.floor(a),t[i]=e.ceil(o),t}function Zi(t){return t?{floor:function(e){return Math.floor(e/t)*t},ceil:function(e){return Math.ceil(e/t)*t}}:Tl}function Ki(t,e,r,n){var i=[],a=[],o=0,s=Math.min(t.length,e.length)-1;for(t[s]2?Ki:Xi,l=n?Qn:Kn;return o=i(t,e,l,r),s=i(e,t,l,_n),a}function a(t){return o(t)}var o,s;return a.invert=function(t){return s(t)},a.domain=function(e){return arguments.length?(t=e.map(Number),i()):t},a.range=function(t){return arguments.length?(e=t,i()):e},a.rangeRound=function(t){return a.range(t).interpolate(Dn)},a.clamp=function(t){return arguments.length?(n=t,i()):n},a.interpolate=function(t){return arguments.length?(r=t,i()):r},a.ticks=function(e){return ea(t,e)},a.tickFormat=function(e,r){return ra(t,e,r)},a.nice=function(e){return Ji(t,e),i()},a.copy=function(){return Qi(t,e,r,n)},i()}function $i(t,e){return co.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ji(t,e){return Wi(t,Zi(ta(t,e)[2])),Wi(t,Zi(ta(t,e)[2])),t}function ta(t,e){null==e&&(e=10);var r=Gi(t),n=r[1]-r[0],i=Math.pow(10,Math.floor(Math.log(n/e)/Math.LN10)),a=e/n*i;return.15>=a?i*=10:.35>=a?i*=5:.75>=a&&(i*=2),r[0]=Math.ceil(r[0]/i)*i,r[1]=Math.floor(r[1]/i)*i+.5*i,r[2]=i,r}function ea(t,e){return co.range.apply(co,ta(t,e))}function ra(t,e,r){var n=ta(t,e);if(r){var i=ps.exec(r);if(i.shift(),"s"===i[8]){var a=co.formatPrefix(Math.max(wo(n[0]),wo(n[1])));return i[7]||(i[7]="."+na(a.scale(n[2]))),i[8]="f",r=co.format(i.join("")),function(t){return r(a.scale(t))+a.symbol}}i[7]||(i[7]="."+ia(i[8],n)),r=i.join("")}else r=",."+na(n[2])+"f";return co.format(r)}function na(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ia(t,e){var r=na(e[2]);return t in El?Math.abs(r-na(Math.max(wo(e[0]),wo(e[1]))))+ +("e"!==t):r-2*("%"===t)}function aa(t,e,r,n){function i(t){return(r?Math.log(0>t?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function a(t){return r?Math.pow(e,t):-Math.pow(e,-t)}function o(e){return t(i(e))}return o.invert=function(e){return a(t.invert(e))},o.domain=function(e){return arguments.length?(r=e[0]>=0,t.domain((n=e.map(Number)).map(i)),o):n},o.base=function(r){return arguments.length?(e=+r,t.domain(n.map(i)),o):e},o.nice=function(){var e=Wi(n.map(i),r?Math:Sl);return t.domain(e),n=e.map(a),o},o.ticks=function(){var t=Gi(n),o=[],s=t[0],l=t[1],c=Math.floor(i(s)),u=Math.ceil(i(l)),f=e%1?2:e;if(isFinite(u-c)){if(r){for(;u>c;c++)for(var h=1;f>h;h++)o.push(a(c)*h);o.push(a(c))}else for(o.push(a(c));c++0;h--)o.push(a(c)*h);for(c=0;o[c]l;u--);o=o.slice(c,u)}return o},o.tickFormat=function(t,r){if(!arguments.length)return Ll;arguments.length<2?r=Ll:"function"!=typeof r&&(r=co.format(r));var n=Math.max(1,e*t/o.ticks().length);return function(t){var o=t/a(Math.round(i(t)));return e-.5>o*e&&(o*=e),n>=o?r(t):""}},o.copy=function(){return aa(t.copy(),e,r,n)},$i(o,t)}function oa(t,e,r){function n(e){return t(i(e))}var i=sa(e),a=sa(1/e);return n.invert=function(e){return a(t.invert(e))},n.domain=function(e){return arguments.length?(t.domain((r=e.map(Number)).map(i)),n):r},n.ticks=function(t){return ea(r,t)},n.tickFormat=function(t,e){return ra(r,t,e)},n.nice=function(t){return n.domain(Ji(r,t))},n.exponent=function(o){return arguments.length?(i=sa(e=o),a=sa(1/e),t.domain(r.map(i)),n):e},n.copy=function(){return oa(t.copy(),e,r)},$i(n,t)}function sa(t){return function(e){return 0>e?-Math.pow(-e,t):Math.pow(e,t)}}function la(t,e){function r(r){return a[((i.get(r)||("range"===e.t?i.set(r,t.push(r)):NaN))-1)%a.length]}function n(e,r){return co.range(t.length).map(function(t){return e+r*t})}var i,a,o;return r.domain=function(n){if(!arguments.length)return t;t=[],i=new f;for(var a,o=-1,s=n.length;++or?[NaN,NaN]:[r>0?s[r-1]:t[0],re?NaN:e/a+t,[e,e+1/a]},n.copy=function(){return ua(t,e,r)},i()}function fa(t,e){function r(r){return r>=r?e[co.bisect(t,r)]:void 0}return r.domain=function(e){return arguments.length?(t=e,r):t},r.range=function(t){return arguments.length?(e=t,r):e},r.invertExtent=function(r){return r=e.indexOf(r),[t[r-1],t[r]]},r.copy=function(){return fa(t,e)},r}function ha(t){function e(t){return+t}return e.invert=e,e.domain=e.range=function(r){return arguments.length?(t=r.map(e),e):t},e.ticks=function(e){return ea(t,e)},e.tickFormat=function(e,r){return ra(t,e,r)},e.copy=function(){return ha(t)},e}function da(){return 0}function pa(t){return t.innerRadius}function ga(t){return t.outerRadius}function va(t){return t.startAngle}function ma(t){return t.endAngle}function ya(t){return t&&t.padAngle}function ba(t,e,r,n){return(t-r)*e-(e-n)*t>0?0:1}function xa(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,c=-s*a,u=t[0]+l,f=t[1]+c,h=e[0]+l,d=e[1]+c,p=(u+h)/2,g=(f+d)/2,v=h-u,m=d-f,y=v*v+m*m,b=r-n,x=u*d-h*f,_=(0>m?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*m-v*_)/y,k=(-x*v-m*_)/y,A=(x*m+v*_)/y,M=(-x*v+m*_)/y,T=w-p,E=k-g,L=A-p,S=M-g;return T*T+E*E>L*L+S*S&&(w=A,k=M),[[w-l,k-c],[w*r/b,k*r/b]]}function _a(t){function e(e){function o(){c.push("M",a(t(u),s))}for(var l,c=[],u=[],f=-1,h=e.length,d=Lt(r),p=Lt(n);++f1?t.join("L"):t+"Z"}function ka(t){return t.join("L")+"Z"}function Aa(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1&&i.push("H",n[0]),i.join("")}function Ma(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var c=2;c9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));for(s=-1;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}function Ua(t){return t.length<3?wa(t):t[0]+Ca(t,Ba(t))}function Va(t){for(var e,r,n,i=-1,a=t.length;++i=e?o(t-e):void(c.c=o)}function o(r){var i=p.active,a=p[i];a&&(a.timer.c=null,a.timer.t=NaN,--p.count,delete p[i],a.event&&a.event.interrupt.call(t,t.__data__,a.index));for(var o in p)if(n>+o){var f=p[o];f.timer.c=null,f.timer.t=NaN,--p.count,delete p[o]}c.c=s,Rt(function(){return c.c&&s(r||1)&&(c.c=null,c.t=NaN),1},0,l),p.active=n,g.event&&g.event.start.call(t,t.__data__,e),d=[],g.tween.forEach(function(r,n){(n=n.call(t,t.__data__,e))&&d.push(n)}),h=g.ease,u=g.duration}function s(i){for(var a=i/u,o=h(a),s=d.length;s>0;)d[--s].call(t,o);return a>=1?(g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[n]:delete t[r],1):void 0}var l,c,u,h,d,p=t[r]||(t[r]={active:0,count:0}),g=p[n];g||(l=i.time,c=Rt(a,0,l),g=p[n]={tween:new f,time:l,timer:c,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++p.count)}function ro(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate("+(isFinite(n)?n:r(t))+",0)"})}function no(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate(0,"+(isFinite(n)?n:r(t))+")"})}function io(t){return t.toISOString()}function ao(t,e,r){function n(e){return t(e)}function i(t,r){var n=t[1]-t[0],i=n/r,a=co.bisect(tc,i);return a==tc.length?[e.year,ta(t.map(function(t){return t/31536e6}),r)[2]]:a?e[i/tc[a-1]1?{floor:function(e){for(;r(e=t.floor(e));)e=oo(e-1);return e},ceil:function(e){for(;r(e=t.ceil(e));)e=oo(+e+1);return e}}:t))},n.ticks=function(t,e){var r=Gi(n.domain()),a=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return a&&(t=a[0],e=a[1]),t.range(r[0],oo(+r[1]+1),1>e?1:e)},n.tickFormat=function(){return r},n.copy=function(){return ao(t.copy(),e,r)},$i(n,t)}function oo(t){return new Date(t)}function so(t){return JSON.parse(t.responseText)}function lo(t){var e=ho.createRange();return e.selectNode(ho.body),e.createContextualFragment(t.responseText)}var co={version:"3.5.16"},uo=[].slice,fo=function(t){return uo.call(t)},ho=this.document;if(ho)try{fo(ho.documentElement.childNodes)[0].nodeType}catch(po){fo=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),ho)try{ho.createElement("DIV").style.setProperty("opacity",0,"")}catch(go){var vo=this.Element.prototype,mo=vo.setAttribute,yo=vo.setAttributeNS,bo=this.CSSStyleDeclaration.prototype,xo=bo.setProperty;vo.setAttribute=function(t,e){mo.call(this,t,e+"")},vo.setAttributeNS=function(t,e,r){yo.call(this,t,e,r+"")},bo.setProperty=function(t,e,r){xo.call(this,t,e+"",r)}}co.ascending=i,co.descending=function(t,e){return t>e?-1:e>t?1:e>=t?0:NaN},co.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},co.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},co.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}else{for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}return[r,i]},co.sum=function(t,e){var r,n=0,i=t.length,a=-1;if(1===arguments.length)for(;++a1?l/(u-1):void 0},co.deviation=function(){var t=co.variance.apply(this,arguments);return t?Math.sqrt(t):t};var _o=s(i);co.bisectLeft=_o.left,co.bisect=co.bisectRight=_o.right,co.bisector=function(t){return s(1===t.length?function(e,r){return i(t(e),r)}:t)},co.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,2>a&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},co.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},co.pairs=function(t){for(var e,r=0,n=t.length-1,i=t[0],a=new Array(0>n?0:n);n>r;)a[r]=[e=i,i=t[++r]];return a},co.transpose=function(t){if(!(i=t.length))return[];for(var e=-1,r=co.min(t,l),n=new Array(r);++e=0;)for(n=t[i],e=n.length;--e>=0;)r[--o]=n[e];return r};var wo=Math.abs;co.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r===1/0)throw new Error("infinite range");var n,i=[],a=c(wo(r)),o=-1;if(t*=a,e*=a,r*=a,0>r)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=a.length)return n?n.call(i,o):r?o.sort(r):o;for(var l,c,u,h,d=-1,p=o.length,g=a[s++],v=new f;++d=a.length)return t;var n=[],i=o[r++];return t.forEach(function(t,i){n.push({key:t,values:e(i,r)})}),i?n.sort(function(t,e){return i(t.key,e.key)}):n}var r,n,i={},a=[],o=[];return i.map=function(e,r){return t(r,e,0)},i.entries=function(r){return e(t(co.map,r,0),0)},i.key=function(t){return a.push(t),i},i.sortKeys=function(t){return o[a.length-1]=t,i},i.sortValues=function(t){return r=t,i},i.rollup=function(t){return n=t,i},i},co.set=function(t){var e=new b;if(t)for(var r=0,n=t.length;n>r;++r)e.add(t[r]);return e},u(b,{has:p,add:function(t){return this._[h(t+="")]=!0,t},remove:g,values:v,size:m,empty:y,forEach:function(t){for(var e in this._)t.call(this,d(e))}}),co.behavior={},co.rebind=function(t,e){for(var r,n=1,i=arguments.length;++n=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},co.event=null,co.requote=function(t){return t.replace(To,"\\$&")};var To=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Eo={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]},Lo=function(t,e){return e.querySelector(t)},So=function(t,e){return e.querySelectorAll(t)},Co=function(t,e){var r=t.matches||t[w(t,"matchesSelector")];return(Co=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(Lo=function(t,e){return Sizzle(t,e)[0]||null},So=Sizzle,Co=Sizzle.matchesSelector),co.selection=function(){return co.select(ho.documentElement)};var zo=co.selection.prototype=[];zo.select=function(t){var e,r,n,i,a=[];t=C(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Ro.hasOwnProperty(r)?{space:Ro[r],local:t}:t}},zo.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node();return t=co.ns.qualify(t),t.local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}for(e in t)this.each(P(e,t[e]));return this}return this.each(P(t,e))},zo.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=I(t)).length,i=-1;if(e=r.classList){for(;++ii){if("string"!=typeof t){2>i&&(e="");for(r in t)this.each(F(r,t[r],e));return this}if(2>i){var a=this.node();return n(a).getComputedStyle(a,null).getPropertyValue(t)}r=""}return this.each(F(t,e,r))},zo.property=function(t,e){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(e in t)this.each(D(e,t[e]));return this}return this.each(D(t,e))},zo.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},zo.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},zo.append=function(t){return t=B(t),this.select(function(){return this.appendChild(t.apply(this,arguments))})},zo.insert=function(t,e){return t=B(t),e=C(e),this.select(function(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)})},zo.remove=function(){return this.each(U)},zo.data=function(t,e){function r(t,r){var n,i,a,o=t.length,u=r.length,h=Math.min(o,u),d=new Array(u),p=new Array(u),g=new Array(o);if(e){var v,m=new f,y=new Array(o);for(n=-1;++nn;++n)p[n]=V(r[n]);for(;o>n;++n)g[n]=t[n]}p.update=d,p.parentNode=d.parentNode=g.parentNode=t.parentNode,s.push(p),l.push(d),c.push(g)}var n,i,a=-1,o=this.length;if(!arguments.length){for(t=new Array(o=(n=this[0]).length);++aa;a++){i.push(e=[]),e.parentNode=(r=this[a]).parentNode;for(var s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return S(i)},zo.order=function(){for(var t=-1,e=this.length;++t=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},zo.sort=function(t){t=H.apply(this,arguments);for(var e=-1,r=this.length;++et;t++)for(var r=this[t],n=0,i=r.length;i>n;n++){var a=r[n];if(a)return a}return null},zo.size=function(){var t=0;return G(this,function(){++t}),t};var Oo=[];co.selection.enter=Y,co.selection.enter.prototype=Oo,Oo.append=zo.append,Oo.empty=zo.empty,Oo.node=zo.node,Oo.call=zo.call,Oo.size=zo.size,Oo.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++sn){if("string"!=typeof t){2>n&&(e=!1);for(r in t)this.each(W(r,t[r],e));return this}if(2>n)return(n=this.node()["__on"+t])&&n._;r=!1}return this.each(W(t,e,r))};var Io=co.map({mouseenter:"mouseover",mouseleave:"mouseout"});ho&&Io.forEach(function(t){"on"+t in ho&&Io.remove(t)});var No,jo=0;co.mouse=function(t){return $(t,E())};var Fo=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;co.touch=function(t,e,r){if(arguments.length<3&&(r=e,e=E().changedTouches),e)for(var n,i=0,a=e.length;a>i;++i)if((n=e[i]).identifier===r)return $(t,n)},co.behavior.drag=function(){function t(){this.on("mousedown.drag",a).on("touchstart.drag",o)}function e(t,e,n,a,o){return function(){function s(){var t,r,n=e(h,g);n&&(t=n[0]-b[0],r=n[1]-b[1],p|=t|r,b=n,d({type:"drag",x:n[0]+c[0],y:n[1]+c[1],dx:t,dy:r}))}function l(){e(h,g)&&(m.on(a+v,null).on(o+v,null),y(p),d({type:"dragend"}))}var c,u=this,f=co.event.target.correspondingElement||co.event.target,h=u.parentNode,d=r.of(u,arguments),p=0,g=t(),v=".drag"+(null==g?"":"-"+g),m=co.select(n(f)).on(a+v,s).on(o+v,l),y=Q(f),b=e(h,g);i?(c=i.apply(u,arguments),c=[c.x-b[0],c.y-b[1]]):c=[0,0],d({type:"dragstart"})}}var r=L(t,"drag","dragstart","dragend"),i=null,a=e(k,co.mouse,n,"mousemove","mouseup"),o=e(J,co.touch,x,"touchmove","touchend");return t.origin=function(e){return arguments.length?(i=e,t):i},co.rebind(t,r,"on")},co.touches=function(t,e){return arguments.length<2&&(e=E().touches),e?fo(e).map(function(e){var r=$(t,e);return r.identifier=e.identifier,r}):[]};var Do=1e-6,Bo=Do*Do,Uo=Math.PI,Vo=2*Uo,qo=Vo-Do,Ho=Uo/2,Go=Uo/180,Yo=180/Uo,Xo=Math.SQRT2,Wo=2,Zo=4;co.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],c=e[2],u=s-i,f=l-a,h=u*u+f*f;if(Bo>h)n=Math.log(c/o)/Xo,r=function(t){return[i+t*u,a+t*f,o*Math.exp(Xo*t*n)]};else{var d=Math.sqrt(h),p=(c*c-o*o+Zo*h)/(2*o*Wo*d),g=(c*c-o*o-Zo*h)/(2*c*Wo*d),v=Math.log(Math.sqrt(p*p+1)-p),m=Math.log(Math.sqrt(g*g+1)-g);n=(m-v)/Xo,r=function(t){var e=t*n,r=at(v),s=o/(Wo*d)*(r*ot(Xo*e+v)-it(v));return[i+s*u,a+s*f,o*r/at(Xo*e+v)]}}return r.duration=1e3*n,r},co.behavior.zoom=function(){function t(t){t.on(z,f).on(Qo+".zoom",d).on("dblclick.zoom",p).on(O,h)}function e(t){return[(t[0]-A.x)/A.k,(t[1]-A.y)/A.k]}function r(t){return[t[0]*A.k+A.x,t[1]*A.k+A.y]}function i(t){A.k=Math.max(E[0],Math.min(E[1],t))}function a(t,e){e=r(e),A.x+=t[0]-e[0],A.y+=t[1]-e[1]}function o(e,r,n,o){e.__chart__={x:A.x,y:A.y,k:A.k},i(Math.pow(2,o)),a(v=r,n),e=co.select(e),S>0&&(e=e.transition().duration(S)),e.call(t.event)}function s(){_&&_.domain(x.range().map(function(t){return(t-A.x)/A.k}).map(x.invert)),k&&k.domain(w.range().map(function(t){return(t-A.y)/A.k}).map(w.invert))}function l(t){C++||t({type:"zoomstart"})}function c(t){s(),t({type:"zoom",scale:A.k,translate:[A.x,A.y]})}function u(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){s=1,a(co.mouse(i),h),c(o)}function r(){f.on(P,null).on(R,null),d(s),u(o)}var i=this,o=I.of(i,arguments),s=0,f=co.select(n(i)).on(P,t).on(R,r),h=e(co.mouse(i)),d=Q(i);Hl.call(i),l(o)}function h(){function t(){var t=co.touches(p);return d=A.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function r(){var e=co.event.target;co.select(e).on(x,n).on(_,s),w.push(e);for(var r=co.event.changedTouches,i=0,a=r.length;a>i;++i)v[r[i].identifier]=null;var l=t(),c=Date.now();if(1===l.length){if(500>c-b){var u=l[0];o(p,u,v[u.identifier],Math.floor(Math.log(A.k)/Math.LN2)+1),T()}b=c}else if(l.length>1){var u=l[0],f=l[1],h=u[0]-f[0],d=u[1]-f[1];m=h*h+d*d}}function n(){var t,e,r,n,o=co.touches(p);Hl.call(p);for(var s=0,l=o.length;l>s;++s,n=null)if(r=o[s],n=v[r.identifier]){if(e)break;t=r,e=n}if(n){var u=(u=r[0]-t[0])*u+(u=r[1]-t[1])*u,f=m&&Math.sqrt(u/m);t=[(t[0]+r[0])/2,(t[1]+r[1])/2],e=[(e[0]+n[0])/2,(e[1]+n[1])/2],i(f*d)}b=null,a(t,e),c(g)}function s(){if(co.event.touches.length){for(var e=co.event.changedTouches,r=0,n=e.length;n>r;++r)delete v[e[r].identifier];for(var i in v)return void t()}co.selectAll(w).on(y,null),k.on(z,f).on(O,h),M(),u(g)}var d,p=this,g=I.of(p,arguments),v={},m=0,y=".zoom-"+co.event.changedTouches[0].identifier,x="touchmove"+y,_="touchend"+y,w=[],k=co.select(p),M=Q(p);r(),l(g),k.on(z,null).on(O,r)}function d(){var t=I.of(this,arguments);y?clearTimeout(y):(Hl.call(this),g=e(v=m||co.mouse(this)),l(t)),y=setTimeout(function(){y=null,u(t)},50),T(),i(Math.pow(2,.002*Ko())*A.k),a(v,g),c(t)}function p(){var t=co.mouse(this),r=Math.log(A.k)/Math.LN2;o(this,t,e(t),co.event.shiftKey?Math.ceil(r)-1:Math.floor(r)+1)}var g,v,m,y,b,x,_,w,k,A={x:0,y:0,k:1},M=[960,500],E=$o,S=250,C=0,z="mousedown.zoom",P="mousemove.zoom",R="mouseup.zoom",O="touchstart.zoom",I=L(t,"zoomstart","zoom","zoomend");return Qo||(Qo="onwheel"in ho?(Ko=function(){return-co.event.deltaY*(co.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ho?(Ko=function(){return co.event.wheelDelta},"mousewheel"):(Ko=function(){return-co.event.detail},"MozMousePixelScroll")),t.event=function(t){t.each(function(){var t=I.of(this,arguments),e=A;Vl?co.select(this).transition().each("start.zoom",function(){A=this.__chart__||{x:0,y:0,k:1},l(t)}).tween("zoom:zoom",function(){var r=M[0],n=M[1],i=v?v[0]:r/2,a=v?v[1]:n/2,o=co.interpolateZoom([(i-A.x)/A.k,(a-A.y)/A.k,r/A.k],[(i-e.x)/e.k,(a-e.y)/e.k,r/e.k]);return function(e){var n=o(e),s=r/n[2];this.__chart__=A={x:i-n[0]*s,y:a-n[1]*s,k:s},c(t)}}).each("interrupt.zoom",function(){u(t)}).each("end.zoom",function(){u(t)}):(this.__chart__=A,l(t),c(t),u(t))})},t.translate=function(e){return arguments.length?(A={x:+e[0],y:+e[1],k:A.k},s(),t):[A.x,A.y]},t.scale=function(e){return arguments.length?(A={x:A.x,y:A.y,k:null},i(+e),s(),t):A.k},t.scaleExtent=function(e){return arguments.length?(E=null==e?$o:[+e[0],+e[1]],t):E},t.center=function(e){return arguments.length?(m=e&&[+e[0],+e[1]],t):m},t.size=function(e){return arguments.length?(M=e&&[+e[0],+e[1]],t):M},t.duration=function(e){return arguments.length?(S=+e,t):S},t.x=function(e){return arguments.length?(_=e,x=e.copy(),A={x:0,y:0,k:1},t):_},t.y=function(e){return arguments.length?(k=e,w=e.copy(),A={x:0,y:0,k:1},t):k},co.rebind(t,I,"on")};var Ko,Qo,$o=[0,1/0];co.color=lt,lt.prototype.toString=function(){return this.rgb()+""},co.hsl=ct;var Jo=ct.prototype=new lt;Jo.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,this.l/t)},Jo.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,t*this.l)},Jo.rgb=function(){return ut(this.h,this.s,this.l)},co.hcl=ft;var ts=ft.prototype=new lt;ts.brighter=function(t){return new ft(this.h,this.c,Math.min(100,this.l+es*(arguments.length?t:1)))},ts.darker=function(t){return new ft(this.h,this.c,Math.max(0,this.l-es*(arguments.length?t:1)))},ts.rgb=function(){return ht(this.h,this.c,this.l).rgb()},co.lab=dt;var es=18,rs=.95047,ns=1,is=1.08883,as=dt.prototype=new lt;as.brighter=function(t){return new dt(Math.min(100,this.l+es*(arguments.length?t:1)),this.a,this.b)},as.darker=function(t){return new dt(Math.max(0,this.l-es*(arguments.length?t:1)),this.a,this.b)},as.rgb=function(){return pt(this.l,this.a,this.b)},co.rgb=bt;var os=bt.prototype=new lt;os.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&i>e&&(e=i),r&&i>r&&(r=i),n&&i>n&&(n=i),new bt(Math.min(255,e/t),Math.min(255,r/t),Math.min(255,n/t))):new bt(i,i,i)},os.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new bt(t*this.r,t*this.g,t*this.b)},os.hsl=function(){return At(this.r,this.g,this.b)},os.toString=function(){return"#"+wt(this.r)+wt(this.g)+wt(this.b)};var ss=co.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ss.forEach(function(t,e){ss.set(t,xt(e))}),co.functor=Lt,co.xhr=St(x),co.dsv=function(t,e){function r(t,r,a){arguments.length<3&&(a=r,r=null);var o=Ct(t,e,null==r?n:i(r),a);return o.row=function(t){return arguments.length?o.response(null==(r=t)?n:i(t)):r},o}function n(t){return r.parse(t.responseText)}function i(t){return function(e){return r.parse(e.responseText,t)}}function a(e){return e.map(o).join(t)}function o(t){return s.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var s=new RegExp('["'+t+"\n]"),l=t.charCodeAt(0);return r.parse=function(t,e){var n;return r.parseRows(t,function(t,r){if(n)return n(t,r-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");n=e?function(t,r){return e(i(t),r)}:i})},r.parseRows=function(t,e){function r(){if(u>=c)return o;if(i)return i=!1,a;var e=u;if(34===t.charCodeAt(e)){for(var r=e;r++u;){var n=t.charCodeAt(u++),s=1;if(10===n)i=!0;else if(13===n)i=!0,10===t.charCodeAt(u)&&(++u,++s);else if(n!==l)continue;return t.slice(e,u-s)}return t.slice(e)}for(var n,i,a={},o={},s=[],c=t.length,u=0,f=0;(n=r())!==o;){for(var h=[];n!==a&&n!==o;)h.push(n),n=r();e&&null==(h=e(h,f++))||s.push(h)}return s},r.format=function(e){if(Array.isArray(e[0]))return r.formatRows(e);var n=new b,i=[];return e.forEach(function(t){for(var e in t)n.has(e)||i.push(n.add(e))}),[i.map(o).join(t)].concat(e.map(function(e){return i.map(function(t){return o(e[t])}).join(t)})).join("\n")},r.formatRows=function(t){return t.map(a).join("\n")},r},co.csv=co.dsv(",","text/csv"),co.tsv=co.dsv(" ","text/tab-separated-values");var ls,cs,us,fs,hs=this[w(this,"requestAnimationFrame")]||function(t){setTimeout(t,17)};co.timer=function(){Rt.apply(this,arguments)},co.timer.flush=function(){It(),Nt()},co.round=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)};var ds=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Ft);co.formatPrefix=function(t,e){var r=0;return(t=+t)&&(0>t&&(t*=-1),e&&(t=co.round(t,jt(t,e))),r=1+Math.floor(1e-12+Math.log(t)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),ds[8+r/3]};var ps=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,gs=co.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=co.round(t,jt(t,e))).toFixed(Math.max(0,Math.min(20,jt(t*(1+1e-15),e))))}}),vs=co.time={},ms=Date;Ut.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ys.setUTCDate.apply(this._,arguments)},setDay:function(){ys.setUTCDay.apply(this._,arguments)},setFullYear:function(){ys.setUTCFullYear.apply(this._,arguments)},setHours:function(){ys.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ys.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ys.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ys.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ys.setUTCSeconds.apply(this._,arguments)},setTime:function(){ys.setTime.apply(this._,arguments)}};var ys=Date.prototype;vs.year=Vt(function(t){return t=vs.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),vs.years=vs.year.range,vs.years.utc=vs.year.utc.range,vs.day=Vt(function(t){var e=new ms(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),vs.days=vs.day.range,vs.days.utc=vs.day.utc.range,vs.dayOfYear=function(t){var e=vs.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var r=vs[t]=Vt(function(t){return(t=vs.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){ -t.setDate(t.getDate()+7*Math.floor(e))},function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)-(r!==e)});vs[t+"s"]=r.range,vs[t+"s"].utc=r.utc.range,vs[t+"OfYear"]=function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)}}),vs.week=vs.sunday,vs.weeks=vs.sunday.range,vs.weeks.utc=vs.sunday.utc.range,vs.weekOfYear=vs.sundayOfYear;var bs={"-":"",_:" ",0:"0"},xs=/^\s*\d+/,_s=/^%/;co.locale=function(t){return{numberFormat:Dt(t),timeFormat:Ht(t)}};var ws=co.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});co.format=ws.numberFormat,co.geo={},fe.prototype={s:0,t:0,add:function(t){he(t,this.t,ks),he(ks.s,this.s,this),this.s?this.t+=ks.t:this.s=ks.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ks=new fe;co.geo.stream=function(t,e){t&&As.hasOwnProperty(t.type)?As[t.type](t,e):de(t,e)};var As={Feature:function(t,e){de(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++nt?4*Uo+t:t,Ls.lineStart=Ls.lineEnd=Ls.point=k}};co.geo.bounds=function(){function t(t,e){b.push(x=[u=t,h=t]),f>e&&(f=e),e>d&&(d=e)}function e(e,r){var n=me([e*Go,r*Go]);if(m){var i=be(m,n),a=[i[1],-i[0],0],o=be(a,i);we(o),o=ke(o);var l=e-p,c=l>0?1:-1,g=o[0]*Yo*c,v=wo(l)>180;if(v^(g>c*p&&c*e>g)){var y=o[1]*Yo;y>d&&(d=y)}else if(g=(g+360)%360-180,v^(g>c*p&&c*e>g)){var y=-o[1]*Yo;f>y&&(f=y)}else f>r&&(f=r),r>d&&(d=r);v?p>e?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e):h>=u?(u>e&&(u=e),e>h&&(h=e)):e>p?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e)}else t(e,r);m=n,p=e}function r(){_.point=e}function n(){x[0]=u,x[1]=h,_.point=t,m=null}function i(t,r){if(m){var n=t-p;y+=wo(n)>180?n+(n>0?360:-360):n}else g=t,v=r;Ls.point(t,r),e(t,r)}function a(){Ls.lineStart()}function o(){i(g,v),Ls.lineEnd(),wo(y)>Do&&(u=-(h=180)),x[0]=u,x[1]=h,m=null}function s(t,e){return(e-=t)<0?e+360:e}function l(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tEs?(u=-(h=180),f=-(d=90)):y>Do?d=90:-Do>y&&(f=-90),x[0]=u,x[1]=h}};return function(t){d=h=-(u=f=1/0),b=[],co.geo.stream(t,_);var e=b.length;if(e){b.sort(l);for(var r,n=1,i=b[0],a=[i];e>n;++n)r=b[n],c(r[0],i)||c(r[1],i)?(s(i[0],r[1])>s(i[0],i[1])&&(i[1]=r[1]),s(r[0],i[1])>s(i[0],i[1])&&(i[0]=r[0])):a.push(i=r);for(var o,r,p=-(1/0),e=a.length-1,n=0,i=a[e];e>=n;i=r,++n)r=a[n],(o=s(i[1],r[0]))>p&&(p=o,u=r[0],h=i[1])}return b=x=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[h,d]]}}(),co.geo.centroid=function(t){Ss=Cs=zs=Ps=Rs=Os=Is=Ns=js=Fs=Ds=0,co.geo.stream(t,Bs);var e=js,r=Fs,n=Ds,i=e*e+r*r+n*n;return Bo>i&&(e=Os,r=Is,n=Ns,Do>Cs&&(e=zs,r=Ps,n=Rs),i=e*e+r*r+n*n,Bo>i)?[NaN,NaN]:[Math.atan2(r,e)*Yo,nt(n/Math.sqrt(i))*Yo]};var Ss,Cs,zs,Ps,Rs,Os,Is,Ns,js,Fs,Ds,Bs={sphere:k,point:Me,lineStart:Ee,lineEnd:Le,polygonStart:function(){Bs.lineStart=Se},polygonEnd:function(){Bs.lineStart=Ee}},Us=Ie(ze,De,Ue,[-Uo,-Uo/2]),Vs=1e9;co.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),i=a(t),i.valid=!0,i},extent:function(s){return arguments.length?(a=Ge(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(co.geo.conicEqualArea=function(){return Ye(Xe)}).raw=Xe,co.geo.albers=function(){return co.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},co.geo.albersUsa=function(){function t(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}var e,r,n,i,a=co.geo.albers(),o=co.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=co.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};return t.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&.234>i&&n>=-.425&&-.214>n?o:i>=.166&&.234>i&&n>=-.214&&-.115>n?s:a).invert(t)},t.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},t.precision=function(e){return arguments.length?(a.precision(e),o.precision(e),s.precision(e),t):a.precision()},t.scale=function(e){return arguments.length?(a.scale(e),o.scale(.35*e),s.scale(e),t.translate(a.translate())):a.scale()},t.translate=function(e){if(!arguments.length)return a.translate();var c=a.scale(),u=+e[0],f=+e[1];return r=a.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(l).point,n=o.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+Do,f+.12*c+Do],[u-.214*c-Do,f+.234*c-Do]]).stream(l).point,i=s.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+Do,f+.166*c+Do],[u-.115*c-Do,f+.234*c-Do]]).stream(l).point,t},t.scale(1070)};var qs,Hs,Gs,Ys,Xs,Ws,Zs={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Hs=0,Zs.lineStart=We},polygonEnd:function(){Zs.lineStart=Zs.lineEnd=Zs.point=k,qs+=wo(Hs/2)}},Ks={point:Ze,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},Qs={point:$e,lineStart:Je,lineEnd:tr,polygonStart:function(){Qs.lineStart=er},polygonEnd:function(){Qs.point=$e,Qs.lineStart=Je,Qs.lineEnd=tr}};co.geo.path=function(){function t(t){return t&&("function"==typeof s&&a.pointRadius(+s.apply(this,arguments)),o&&o.valid||(o=i(a)),co.geo.stream(t,o)),a.result()}function e(){return o=null,t}var r,n,i,a,o,s=4.5;return t.area=function(t){return qs=0,co.geo.stream(t,i(Zs)),qs},t.centroid=function(t){return zs=Ps=Rs=Os=Is=Ns=js=Fs=Ds=0,co.geo.stream(t,i(Qs)),Ds?[js/Ds,Fs/Ds]:Ns?[Os/Ns,Is/Ns]:Rs?[zs/Rs,Ps/Rs]:[NaN,NaN]},t.bounds=function(t){return Xs=Ws=-(Gs=Ys=1/0),co.geo.stream(t,i(Ks)),[[Gs,Ys],[Xs,Ws]]},t.projection=function(t){return arguments.length?(i=(r=t)?t.stream||ir(t):x,e()):r},t.context=function(t){return arguments.length?(a=null==(n=t)?new Ke:new rr(t),"function"!=typeof s&&a.pointRadius(s),e()):n},t.pointRadius=function(e){return arguments.length?(s="function"==typeof e?e:(a.pointRadius(+e),+e),t):s},t.projection(co.geo.albersUsa()).context(null)},co.geo.transform=function(t){return{stream:function(e){var r=new ar(e);for(var n in t)r[n]=t[n];return r}}},ar.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},co.geo.projection=sr,co.geo.projectionMutator=lr,(co.geo.equirectangular=function(){return sr(ur)}).raw=ur.invert=ur,co.geo.rotation=function(t){function e(e){return e=t(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e}return t=hr(t[0]%360*Go,t[1]*Go,t.length>2?t[2]*Go:0),e.invert=function(e){return e=t.invert(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e},e},fr.invert=ur,co.geo.circle=function(){function t(){var t="function"==typeof n?n.apply(this,arguments):n,e=hr(-t[0]*Go,-t[1]*Go,0).invert,i=[];return r(null,null,1,{point:function(t,r){i.push(t=e(t,r)),t[0]*=Yo,t[1]*=Yo}}),{type:"Polygon",coordinates:[i]}}var e,r,n=[0,0],i=6;return t.origin=function(e){return arguments.length?(n=e,t):n},t.angle=function(n){return arguments.length?(r=vr((e=+n)*Go,i*Go),t):e},t.precision=function(n){return arguments.length?(r=vr(e*Go,(i=+n)*Go),t):i},t.angle(90)},co.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Go,i=t[1]*Go,a=e[1]*Go,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),c=Math.cos(i),u=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-l*f*s)*r),l*u+c*f*s)},co.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return co.range(Math.ceil(a/v)*v,i,v).map(h).concat(co.range(Math.ceil(c/m)*m,l,m).map(d)).concat(co.range(Math.ceil(n/p)*p,r,p).filter(function(t){return wo(t%v)>Do}).map(u)).concat(co.range(Math.ceil(s/g)*g,o,g).filter(function(t){return wo(t%m)>Do}).map(f))}var r,n,i,a,o,s,l,c,u,f,h,d,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[h(a).concat(d(l).slice(1),h(i).reverse().slice(1),d(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(a=+e[0][0],i=+e[1][0],c=+e[0][1],l=+e[1][1],a>i&&(e=a,a=i,i=e),c>l&&(e=c,c=l,l=e),t.precision(y)):[[a,c],[i,l]]},t.minorExtent=function(e){return arguments.length?(n=+e[0][0],r=+e[1][0],s=+e[0][1],o=+e[1][1],n>r&&(e=n,n=r,r=e),s>o&&(e=s,s=o,o=e),t.precision(y)):[[n,s],[r,o]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=yr(s,o,90),f=br(n,r,y),h=yr(c,l,90),d=br(a,i,y),t):y},t.majorExtent([[-180,-90+Do],[180,90-Do]]).minorExtent([[-180,-80-Do],[180,80+Do]])},co.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}var e,r,n=xr,i=_r;return t.distance=function(){return co.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},t.source=function(r){return arguments.length?(n=r,e="function"==typeof r?null:r,t):n},t.target=function(e){return arguments.length?(i=e,r="function"==typeof e?null:e,t):i},t.precision=function(){return arguments.length?t:0},t},co.geo.interpolate=function(t,e){return wr(t[0]*Go,t[1]*Go,e[0]*Go,e[1]*Go)},co.geo.length=function(t){return $s=0,co.geo.stream(t,Js),$s};var $s,Js={sphere:k,point:k,lineStart:kr,lineEnd:k,polygonStart:k,polygonEnd:k},tl=Ar(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(co.geo.azimuthalEqualArea=function(){return sr(tl)}).raw=tl;var el=Ar(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},x);(co.geo.azimuthalEquidistant=function(){return sr(el)}).raw=el,(co.geo.conicConformal=function(){return Ye(Mr)}).raw=Mr,(co.geo.conicEquidistant=function(){return Ye(Tr)}).raw=Tr;var rl=Ar(function(t){return 1/t},Math.atan);(co.geo.gnomonic=function(){return sr(rl)}).raw=rl,Er.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Ho]},(co.geo.mercator=function(){return Lr(Er)}).raw=Er;var nl=Ar(function(){return 1},Math.asin);(co.geo.orthographic=function(){return sr(nl)}).raw=nl;var il=Ar(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(co.geo.stereographic=function(){return sr(il)}).raw=il,Sr.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ho]},(co.geo.transverseMercator=function(){var t=Lr(Sr),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):(t=r(),[t[0],t[1],t[2]-90])},r([0,0,90])}).raw=Sr,co.geom={},co.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,i=Lt(r),a=Lt(n),o=t.length,s=[],l=[];for(e=0;o>e;e++)s.push([+i.call(this,t[e],e),+a.call(this,t[e],e),e]);for(s.sort(Rr),e=0;o>e;e++)l.push([s[e][0],-s[e][1]]);var c=Pr(s),u=Pr(l),f=u[0]===c[0],h=u[u.length-1]===c[c.length-1],d=[];for(e=c.length-1;e>=0;--e)d.push(t[s[c[e]][2]]);for(e=+f;e=n&&c.x<=a&&c.y>=i&&c.y<=o?[[n,o],[a,o],[a,i],[n,i]]:[];u.point=t[s]}),e}function r(t){return t.map(function(t,e){return{x:Math.round(a(t,e)/Do)*Do,y:Math.round(o(t,e)/Do)*Do,i:e}})}var n=Cr,i=zr,a=n,o=i,s=dl;return t?e(t):(e.links=function(t){return cn(r(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cn(r(t)).cells.forEach(function(r,n){for(var i,a,o=r.site,s=r.edges.sort(Yr),l=-1,c=s.length,u=s[c-1].edge,f=u.l===o?u.r:u.l;++l=c,h=n>=u,d=h<<1|f;t.leaf=!1,t=t.nodes[d]||(t.nodes[d]=pn()),f?i=c:s=c,h?o=u:l=u,a(t,e,r,n,i,o,s,l)}var u,f,h,d,p,g,v,m,y,b=Lt(s),x=Lt(l);if(null!=e)g=e,v=r,m=n,y=i;else if(m=y=-(g=v=1/0),f=[],h=[],p=t.length,o)for(d=0;p>d;++d)u=t[d],u.xm&&(m=u.x),u.y>y&&(y=u.y),f.push(u.x),h.push(u.y);else for(d=0;p>d;++d){var _=+b(u=t[d],d),w=+x(u,d);g>_&&(g=_),v>w&&(v=w),_>m&&(m=_),w>y&&(y=w),f.push(_),h.push(w)}var k=m-g,A=y-v;k>A?y=v+k:m=g+A;var M=pn();if(M.add=function(t){a(M,t,+b(t,++d),+x(t,d),g,v,m,y)},M.visit=function(t){gn(t,M,g,v,m,y)},M.find=function(t){return vn(M,t[0],t[1],g,v,m,y)},d=-1,null==e){for(;++d=0?t.slice(0,e):t,n=e>=0?t.slice(e+1):"in";return r=ml.get(r)||vl,n=yl.get(n)||x,kn(n(r.apply(null,uo.call(arguments,1))))},co.interpolateHcl=Nn,co.interpolateHsl=jn,co.interpolateLab=Fn,co.interpolateRound=Dn,co.transform=function(t){var e=ho.createElementNS(co.ns.prefix.svg,"g");return(co.transform=function(t){if(null!=t){e.setAttribute("transform",t);var r=e.transform.baseVal.consolidate()}return new Bn(r?r.matrix:bl)})(t)},Bn.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var bl={a:1,b:0,c:0,d:1,e:0,f:0};co.interpolateTransform=Zn,co.layout={},co.layout.bundle=function(){return function(t){for(var e=[],r=-1,n=t.length;++rs*s/m){if(g>l){var c=e.charge/l;t.px-=a*c,t.py-=o*c}return!0}if(e.point&&l&&g>l){var c=e.pointCharge/l;t.px-=a*c,t.py-=o*c}}return!e.charge}}function e(t){t.px=co.event.x,t.py=co.event.y,l.resume()}var r,n,i,a,o,s,l={},c=co.dispatch("start","tick","end"),u=[1,1],f=.9,h=xl,d=_l,p=-30,g=wl,v=.1,m=.64,y=[],b=[];return l.tick=function(){if((i*=.99)<.005)return r=null,c.end({type:"end",alpha:i=0}),!0;var e,n,l,h,d,g,m,x,_,w=y.length,k=b.length;for(n=0;k>n;++n)l=b[n],h=l.source,d=l.target,x=d.x-h.x,_=d.y-h.y,(g=x*x+_*_)&&(g=i*o[n]*((g=Math.sqrt(g))-a[n])/g,x*=g,_*=g,d.x-=x*(m=h.weight+d.weight?h.weight/(h.weight+d.weight):.5),d.y-=_*m,h.x+=x*(m=1-m),h.y+=_*m);if((m=i*v)&&(x=u[0]/2,_=u[1]/2,n=-1,m))for(;++n0?i=t:(r.c=null,r.t=NaN,r=null,c.end({type:"end",alpha:i=0})):t>0&&(c.start({type:"start",alpha:i=t}),r=Rt(l.tick)),l):i},l.start=function(){function t(t,n){if(!r){for(r=new Array(i),l=0;i>l;++l)r[l]=[];for(l=0;c>l;++l){var a=b[l];r[a.source.index].push(a.target),r[a.target.index].push(a.source)}}for(var o,s=r[e],l=-1,u=s.length;++le;++e)(n=y[e]).index=e,n.weight=0;for(e=0;c>e;++e)n=b[e],"number"==typeof n.source&&(n.source=y[n.source]),"number"==typeof n.target&&(n.target=y[n.target]),++n.source.weight,++n.target.weight;for(e=0;i>e;++e)n=y[e],isNaN(n.x)&&(n.x=t("x",f)),isNaN(n.y)&&(n.y=t("y",g)),isNaN(n.px)&&(n.px=n.x),isNaN(n.py)&&(n.py=n.y);if(a=[],"function"==typeof h)for(e=0;c>e;++e)a[e]=+h.call(this,b[e],e);else for(e=0;c>e;++e)a[e]=h;if(o=[],"function"==typeof d)for(e=0;c>e;++e)o[e]=+d.call(this,b[e],e);else for(e=0;c>e;++e)o[e]=d;if(s=[],"function"==typeof p)for(e=0;i>e;++e)s[e]=+p.call(this,y[e],e);else for(e=0;i>e;++e)s[e]=p;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return n||(n=co.behavior.drag().origin(x).on("dragstart.force",ei).on("drag.force",e).on("dragend.force",ri)),arguments.length?void this.on("mouseover.force",ni).on("mouseout.force",ii).call(n):n},co.rebind(l,c,"on")};var xl=20,_l=1,wl=1/0;co.layout.hierarchy=function(){function t(i){var a,o=[i],s=[];for(i.depth=0;null!=(a=o.pop());)if(s.push(a),(c=r.call(t,a,a.depth))&&(l=c.length)){for(var l,c,u;--l>=0;)o.push(u=c[l]),u.parent=a,u.depth=a.depth+1;n&&(a.value=0),a.children=c}else n&&(a.value=+n.call(t,a,a.depth)||0),delete a.children;return li(i,function(t){var r,i;e&&(r=t.children)&&r.sort(e),n&&(i=t.parent)&&(i.value+=t.value)}),s}var e=fi,r=ci,n=ui;return t.sort=function(r){return arguments.length?(e=r,t):e},t.children=function(e){return arguments.length?(r=e,t):r},t.value=function(e){return arguments.length?(n=e,t):n},t.revalue=function(e){return n&&(si(e,function(t){t.children&&(t.value=0)}),li(e,function(e){var r;e.children||(e.value=+n.call(t,e,e.depth)||0),(r=e.parent)&&(r.value+=e.value)})),e},t},co.layout.partition=function(){function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,c=-1;for(n=e.value?n/e.value:0;++cf?-1:1),p=co.sum(c),g=p?(f-l*d)/p:0,v=co.range(l),m=[];return null!=r&&v.sort(r===kl?function(t,e){return c[e]-c[t]}:function(t,e){return r(o[t],o[e])}),v.forEach(function(t){m[t]={data:o[t],value:s=c[t],startAngle:u,endAngle:u+=s*g+d,padAngle:h}}),m}var e=Number,r=kl,n=0,i=Vo,a=0;return t.value=function(r){return arguments.length?(e=r,t):e},t.sort=function(e){return arguments.length?(r=e,t):r},t.startAngle=function(e){return arguments.length?(n=e,t):n},t.endAngle=function(e){return arguments.length?(i=e,t):i},t.padAngle=function(e){return arguments.length?(a=e,t):a},t};var kl={};co.layout.stack=function(){function t(s,l){if(!(h=s.length))return s;var c=s.map(function(r,n){return e.call(t,r,n)}),u=c.map(function(e){return e.map(function(e,r){return[a.call(t,e,r),o.call(t,e,r)]})}),f=r.call(t,u,l);c=co.permute(c,f),u=co.permute(u,f);var h,d,p,g,v=n.call(t,u,l),m=c[0].length;for(p=0;m>p;++p)for(i.call(t,c[0][p],g=v[p],u[0][p][1]),d=1;h>d;++d)i.call(t,c[d][p],g+=u[d-1][p][1],u[d][p][1]);return s}var e=x,r=vi,n=mi,i=gi,a=di,o=pi;return t.values=function(r){return arguments.length?(e=r,t):e},t.order=function(e){return arguments.length?(r="function"==typeof e?e:Al.get(e)||vi,t):r},t.offset=function(e){return arguments.length?(n="function"==typeof e?e:Ml.get(e)||mi,t):n},t.x=function(e){return arguments.length?(a=e,t):a},t.y=function(e){return arguments.length?(o=e,t):o},t.out=function(e){return arguments.length?(i=e,t):i},t};var Al=co.map({"inside-out":function(t){var e,r,n=t.length,i=t.map(yi),a=t.map(bi),o=co.range(n).sort(function(t,e){return i[t]-i[e]}),s=0,l=0,c=[],u=[];for(e=0;n>e;++e)r=o[e],l>s?(s+=a[r],c.push(r)):(l+=a[r],u.push(r));return u.reverse().concat(c)},reverse:function(t){return co.range(t.length).reverse()},"default":vi}),Ml=co.map({silhouette:function(t){var e,r,n,i=t.length,a=t[0].length,o=[],s=0,l=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];n>s&&(s=n),o.push(n)}for(r=0;a>r;++r)l[r]=(s-o[r])/2;return l},wiggle:function(t){var e,r,n,i,a,o,s,l,c,u=t.length,f=t[0],h=f.length,d=[];for(d[0]=l=c=0,r=1;h>r;++r){for(e=0,i=0;u>e;++e)i+=t[e][r][1];for(e=0,a=0,s=f[r][0]-f[r-1][0];u>e;++e){for(n=0,o=(t[e][r][1]-t[e][r-1][1])/(2*s);e>n;++n)o+=(t[n][r][1]-t[n][r-1][1])/s;a+=o*t[e][r][1]}d[r]=l-=i?a/i*s:0,c>l&&(c=l)}for(r=0;h>r;++r)d[r]-=c;return d},expand:function(t){var e,r,n,i=t.length,a=t[0].length,o=1/i,s=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];if(n)for(e=0;i>e;e++)t[e][r][1]/=n;else for(e=0;i>e;e++)t[e][r][1]=o}for(r=0;a>r;++r)s[r]=0;return s},zero:mi});co.layout.histogram=function(){function t(t,a){for(var o,s,l=[],c=t.map(r,this),u=n.call(this,c,a),f=i.call(this,u,c,a),a=-1,h=c.length,d=f.length-1,p=e?1:1/h;++a0)for(a=-1;++a=u[0]&&s<=u[1]&&(o=l[co.bisect(f,s,1,d)-1],o.y+=p,o.push(t[a]));return l}var e=!0,r=Number,n=ki,i=_i;return t.value=function(e){return arguments.length?(r=e,t):r},t.range=function(e){return arguments.length?(n=Lt(e),t):n},t.bins=function(e){return arguments.length?(i="number"==typeof e?function(t){return wi(t,e)}:Lt(e),t):i},t.frequency=function(r){return arguments.length?(e=!!r,t):e},t},co.layout.pack=function(){function t(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],c=i[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,li(s,function(t){t.r=+u(t.value)}),li(s,Li),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/c))/2;li(s,function(t){t.r+=f}),li(s,Li),li(s,function(t){t.r-=f})}return zi(s,l/2,c/2,e?1:1/Math.max(2*s.r/l,2*s.r/c)),o}var e,r=co.layout.hierarchy().sort(Ai),n=0,i=[1,1];return t.size=function(e){return arguments.length?(i=e,t):i},t.radius=function(r){return arguments.length?(e=null==r||"function"==typeof r?r:+r,t):e},t.padding=function(e){return arguments.length?(n=+e,t):n},oi(t,r)},co.layout.tree=function(){function t(t,i){var u=o.call(this,t,i),f=u[0],h=e(f);if(li(h,r),h.parent.m=-h.z,si(h,n),c)si(f,a);else{var d=f,p=f,g=f;si(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=s(d,p)/2-d.x,m=l[0]/(p.x+s(p,d)/2+v),y=l[1]/(g.depth||1);si(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return u}function e(t){for(var e,r={A:null,children:[t]},n=[r];null!=(e=n.pop());)for(var i,a=e.children,o=0,s=a.length;s>o;++o)n.push((a[o]=i={_:a[o],parent:e,children:(i=a[o].children)&&i.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=i);return r.children[0]}function r(t){var e=t.children,r=t.parent.children,n=t.i?r[t.i-1]:null;if(e.length){ji(t);var a=(e[0].z+e[e.length-1].z)/2;n?(t.z=n.z+s(t._,n._),t.m=t.z-a):t.z=a}else n&&(t.z=n.z+s(t._,n._));t.parent.A=i(t,n,t.parent.A||r[0])}function n(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function i(t,e,r){if(e){for(var n,i=t,a=t,o=e,l=i.parent.children[0],c=i.m,u=a.m,f=o.m,h=l.m;o=Ii(o),i=Oi(i),o&&i;)l=Oi(l),a=Ii(a),a.a=t,n=o.z+f-i.z-c+s(o._,i._),n>0&&(Ni(Fi(o,t,r),t,n),c+=n,u+=n),f+=o.m,c+=i.m,h+=l.m,u+=a.m;o&&!Ii(a)&&(a.t=o,a.m+=f-u),i&&!Oi(l)&&(l.t=i,l.m+=c-h,r=t)}return r}function a(t){t.x*=l[0],t.y=t.depth*l[1]}var o=co.layout.hierarchy().sort(null).value(null),s=Ri,l=[1,1],c=null;return t.separation=function(e){return arguments.length?(s=e,t):s},t.size=function(e){return arguments.length?(c=null==(l=e)?a:null,t):c?null:l},t.nodeSize=function(e){return arguments.length?(c=null==(l=e)?null:a,t):c?l:null},oi(t,o)},co.layout.cluster=function(){function t(t,a){var o,s=e.call(this,t,a),l=s[0],c=0;li(l,function(t){var e=t.children;e&&e.length?(t.x=Bi(e),t.y=Di(e)):(t.x=o?c+=r(t,o):0,t.y=0,o=t)});var u=Ui(l),f=Vi(l),h=u.x-r(u,f)/2,d=f.x+r(f,u)/2;return li(l,i?function(t){t.x=(t.x-l.x)*n[0],t.y=(l.y-t.y)*n[1]}:function(t){t.x=(t.x-h)/(d-h)*n[0],t.y=(1-(l.y?t.y/l.y:1))*n[1]}),s}var e=co.layout.hierarchy().sort(null).value(null),r=Ri,n=[1,1],i=!1;return t.separation=function(e){return arguments.length?(r=e,t):r},t.size=function(e){return arguments.length?(i=null==(n=e),t):i?null:n},t.nodeSize=function(e){return arguments.length?(i=null!=(n=e),t):i?n:null},oi(t,e)},co.layout.treemap=function(){function t(t,e){for(var r,n,i=-1,a=t.length;++ie?0:e),r.area=isNaN(n)||0>=n?0:n}function e(r){var a=r.children;if(a&&a.length){var o,s,l,c=f(r),u=[],h=a.slice(),p=1/0,g="slice"===d?c.dx:"dice"===d?c.dy:"slice-dice"===d?1&r.depth?c.dy:c.dx:Math.min(c.dx,c.dy); -for(t(h,c.dx*c.dy/r.value),u.area=0;(l=h.length)>0;)u.push(o=h[l-1]),u.area+=o.area,"squarify"!==d||(s=n(u,g))<=p?(h.pop(),p=s):(u.area-=u.pop().area,i(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(i(u,g,c,!0),u.length=u.area=0),a.forEach(e)}}function r(e){var n=e.children;if(n&&n.length){var a,o=f(e),s=n.slice(),l=[];for(t(s,o.dx*o.dy/e.value),l.area=0;a=s.pop();)l.push(a),l.area+=a.area,null!=a.z&&(i(l,a.z?o.dx:o.dy,o,!s.length),l.length=l.area=0);n.forEach(r)}}function n(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++or&&(a=r),r>i&&(i=r));return n*=n,e*=e,n?Math.max(e*i*p/n,n/(e*a*p)):1/0}function i(t,e,r,n){var i,a=-1,o=t.length,s=r.x,c=r.y,u=e?l(t.area/e):0;if(e==r.dx){for((n||u>r.dy)&&(u=r.dy);++ar.dx)&&(u=r.dx);++ar&&(e=1),1>r&&(t=0),function(){var r,n,i;do r=2*Math.random()-1,n=2*Math.random()-1,i=r*r+n*n;while(!i||i>1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=co.random.normal.apply(co,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=co.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,r=0;t>r;r++)e+=Math.random();return e}}},co.scale={};var Tl={floor:x,ceil:x};co.scale.linear=function(){return Qi([0,1],[0,1],_n,!1)};var El={s:1,g:1,p:1,r:1,e:1};co.scale.log=function(){return aa(co.scale.linear().domain([0,1]),10,!0,[1,10])};var Ll=co.format(".0e"),Sl={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};co.scale.pow=function(){return oa(co.scale.linear(),1,[0,1])},co.scale.sqrt=function(){return co.scale.pow().exponent(.5)},co.scale.ordinal=function(){return la([],{t:"range",a:[[]]})},co.scale.category10=function(){return co.scale.ordinal().range(Cl)},co.scale.category20=function(){return co.scale.ordinal().range(zl)},co.scale.category20b=function(){return co.scale.ordinal().range(Pl)},co.scale.category20c=function(){return co.scale.ordinal().range(Rl)};var Cl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(_t),zl=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(_t),Pl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(_t),Rl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(_t);co.scale.quantile=function(){return ca([],[])},co.scale.quantize=function(){return ua(0,1,[0,1])},co.scale.threshold=function(){return fa([.5],[0,1])},co.scale.identity=function(){return ha([0,1])},co.svg={},co.svg.arc=function(){function t(){var t=Math.max(0,+r.apply(this,arguments)),c=Math.max(0,+n.apply(this,arguments)),u=o.apply(this,arguments)-Ho,f=s.apply(this,arguments)-Ho,h=Math.abs(f-u),d=u>f?0:1;if(t>c&&(p=c,c=t,t=p),h>=qo)return e(c,d)+(t?e(t,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,k,A,M,T=0,E=0,L=[];if((m=(+l.apply(this,arguments)||0)/2)&&(v=a===Ol?Math.sqrt(t*t+c*c):+a.apply(this,arguments),d||(E*=-1),c&&(E=nt(v/c*Math.sin(m))),t&&(T=nt(v/t*Math.sin(m)))),c){y=c*Math.cos(u+E),b=c*Math.sin(u+E),x=c*Math.cos(f-E),_=c*Math.sin(f-E);var S=Math.abs(f-u-2*E)<=Uo?0:1;if(E&&ba(y,b,x,_)===d^S){var C=(u+f)/2;y=c*Math.cos(C),b=c*Math.sin(C),x=_=null}}else y=b=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),A=t*Math.cos(u+T),M=t*Math.sin(u+T);var z=Math.abs(u-f+2*T)<=Uo?0:1;if(T&&ba(w,k,A,M)===1-d^z){var P=(u+f)/2;w=t*Math.cos(P),k=t*Math.sin(P),A=M=null}}else w=k=0;if(h>Do&&(p=Math.min(Math.abs(c-t)/2,+i.apply(this,arguments)))>.001){g=c>t^d?0:1;var R=p,O=p;if(Uo>h){var I=null==A?[w,k]:null==x?[y,b]:Ir([y,b],[A,M],[x,_],[w,k]),N=y-I[0],j=b-I[1],F=x-I[0],D=_-I[1],B=1/Math.sin(Math.acos((N*F+j*D)/(Math.sqrt(N*N+j*j)*Math.sqrt(F*F+D*D)))/2),U=Math.sqrt(I[0]*I[0]+I[1]*I[1]);O=Math.min(p,(t-U)/(B-1)),R=Math.min(p,(c-U)/(B+1))}if(null!=x){var V=xa(null==A?[w,k]:[A,M],[y,b],c,R,d),q=xa([x,_],[w,k],c,R,d);p===R?L.push("M",V[0],"A",R,",",R," 0 0,",g," ",V[1],"A",c,",",c," 0 ",1-d^ba(V[1][0],V[1][1],q[1][0],q[1][1]),",",d," ",q[1],"A",R,",",R," 0 0,",g," ",q[0]):L.push("M",V[0],"A",R,",",R," 0 1,",g," ",q[0])}else L.push("M",y,",",b);if(null!=A){var H=xa([y,b],[A,M],t,-O,d),G=xa([w,k],null==x?[y,b]:[x,_],t,-O,d);p===O?L.push("L",G[0],"A",O,",",O," 0 0,",g," ",G[1],"A",t,",",t," 0 ",d^ba(G[1][0],G[1][1],H[1][0],H[1][1]),",",1-d," ",H[1],"A",O,",",O," 0 0,",g," ",H[0]):L.push("L",G[0],"A",O,",",O," 0 0,",g," ",H[0])}else L.push("L",w,",",k)}else L.push("M",y,",",b),null!=x&&L.push("A",c,",",c," 0 ",S,",",d," ",x,",",_),L.push("L",w,",",k),null!=A&&L.push("A",t,",",t," 0 ",z,",",1-d," ",A,",",M);return L.push("Z"),L.join("")}function e(t,e){return"M0,"+t+"A"+t+","+t+" 0 1,"+e+" 0,"+-t+"A"+t+","+t+" 0 1,"+e+" 0,"+t}var r=pa,n=ga,i=da,a=Ol,o=va,s=ma,l=ya;return t.innerRadius=function(e){return arguments.length?(r=Lt(e),t):r},t.outerRadius=function(e){return arguments.length?(n=Lt(e),t):n},t.cornerRadius=function(e){return arguments.length?(i=Lt(e),t):i},t.padRadius=function(e){return arguments.length?(a=e==Ol?Ol:Lt(e),t):a},t.startAngle=function(e){return arguments.length?(o=Lt(e),t):o},t.endAngle=function(e){return arguments.length?(s=Lt(e),t):s},t.padAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.centroid=function(){var t=(+r.apply(this,arguments)+ +n.apply(this,arguments))/2,e=(+o.apply(this,arguments)+ +s.apply(this,arguments))/2-Ho;return[Math.cos(e)*t,Math.sin(e)*t]},t};var Ol="auto";co.svg.line=function(){return _a(x)};var Il=co.map({linear:wa,"linear-closed":ka,step:Aa,"step-before":Ma,"step-after":Ta,basis:Pa,"basis-open":Ra,"basis-closed":Oa,bundle:Ia,cardinal:Sa,"cardinal-open":Ea,"cardinal-closed":La,monotone:Ua});Il.forEach(function(t,e){e.key=t,e.closed=/-closed$/.test(t)});var Nl=[0,2/3,1/3,0],jl=[0,1/3,2/3,0],Fl=[0,1/6,2/3,1/6];co.svg.line.radial=function(){var t=_a(Va);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},Ma.reverse=Ta,Ta.reverse=Ma,co.svg.area=function(){return qa(x)},co.svg.area.radial=function(){var t=qa(Va);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},co.svg.chord=function(){function t(t,s){var l=e(this,a,t,s),c=e(this,o,t,s);return"M"+l.p0+n(l.r,l.p1,l.a1-l.a0)+(r(l,c)?i(l.r,l.p1,l.r,l.p0):i(l.r,l.p1,c.r,c.p0)+n(c.r,c.p1,c.a1-c.a0)+i(c.r,c.p1,l.r,l.p0))+"Z"}function e(t,e,r,n){var i=e.call(t,r,n),a=s.call(t,i,n),o=l.call(t,i,n)-Ho,u=c.call(t,i,n)-Ho;return{r:a,a0:o,a1:u,p0:[a*Math.cos(o),a*Math.sin(o)],p1:[a*Math.cos(u),a*Math.sin(u)]}}function r(t,e){return t.a0==e.a0&&t.a1==e.a1}function n(t,e,r){return"A"+t+","+t+" 0 "+ +(r>Uo)+",1 "+e}function i(t,e,r,n){return"Q 0,0 "+n}var a=xr,o=_r,s=Ha,l=va,c=ma;return t.radius=function(e){return arguments.length?(s=Lt(e),t):s},t.source=function(e){return arguments.length?(a=Lt(e),t):a},t.target=function(e){return arguments.length?(o=Lt(e),t):o},t.startAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.endAngle=function(e){return arguments.length?(c=Lt(e),t):c},t},co.svg.diagonal=function(){function t(t,i){var a=e.call(this,t,i),o=r.call(this,t,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return l=l.map(n),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var e=xr,r=_r,n=Ga;return t.source=function(r){return arguments.length?(e=Lt(r),t):e},t.target=function(e){return arguments.length?(r=Lt(e),t):r},t.projection=function(e){return arguments.length?(n=e,t):n},t},co.svg.diagonal.radial=function(){var t=co.svg.diagonal(),e=Ga,r=t.projection;return t.projection=function(t){return arguments.length?r(Ya(e=t)):e},t},co.svg.symbol=function(){function t(t,n){return(Dl.get(e.call(this,t,n))||Za)(r.call(this,t,n))}var e=Wa,r=Xa;return t.type=function(r){return arguments.length?(e=Lt(r),t):e},t.size=function(e){return arguments.length?(r=Lt(e),t):r},t};var Dl=co.map({circle:Za,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Ul)),r=e*Ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/Bl),r=e*Bl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/Bl),r=e*Bl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});co.svg.symbolTypes=Dl.keys();var Bl=Math.sqrt(3),Ul=Math.tan(30*Go);zo.transition=function(t){for(var e,r,n=Vl||++Yl,i=to(t),a=[],o=ql||{time:Date.now(),ease:Ln,delay:0,duration:250},s=-1,l=this.length;++sa;a++){i.push(e=[]);for(var r=this[a],s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return Qa(i,this.namespace,this.id)},Gl.tween=function(t,e){var r=this.id,n=this.namespace;return arguments.length<2?this.node()[n][r].tween.get(t):G(this,null==e?function(e){e[n][r].tween.remove(t)}:function(i){i[n][r].tween.set(t,e)})},Gl.attr=function(t,e){function r(){this.removeAttribute(s)}function n(){this.removeAttributeNS(s.space,s.local)}function i(t){return null==t?r:(t+="",function(){var e,r=this.getAttribute(s);return r!==t&&(e=o(r,t),function(t){this.setAttribute(s,e(t))})})}function a(t){return null==t?n:(t+="",function(){var e,r=this.getAttributeNS(s.space,s.local);return r!==t&&(e=o(r,t),function(t){this.setAttributeNS(s.space,s.local,e(t))})})}if(arguments.length<2){for(e in t)this.attr(e,t[e]);return this}var o="transform"==t?Zn:_n,s=co.ns.qualify(t);return $a(this,"attr."+t,e,s.local?a:i)},Gl.attrTween=function(t,e){function r(t,r){var n=e.call(this,t,r,this.getAttribute(i));return n&&function(t){this.setAttribute(i,n(t))}}function n(t,r){var n=e.call(this,t,r,this.getAttributeNS(i.space,i.local));return n&&function(t){this.setAttributeNS(i.space,i.local,n(t))}}var i=co.ns.qualify(t);return this.tween("attr."+t,i.local?n:r)},Gl.style=function(t,e,r){function i(){this.style.removeProperty(t)}function a(e){return null==e?i:(e+="",function(){var i,a=n(this).getComputedStyle(this,null).getPropertyValue(t);return a!==e&&(i=_n(a,e),function(e){this.style.setProperty(t,i(e),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof t){2>o&&(e="");for(r in t)this.style(r,t[r],e);return this}r=""}return $a(this,"style."+t,e,a)},Gl.styleTween=function(t,e,r){function i(i,a){var o=e.call(this,i,a,n(this).getComputedStyle(this,null).getPropertyValue(t));return o&&function(e){this.style.setProperty(t,o(e),r)}}return arguments.length<3&&(r=""),this.tween("style."+t,i)},Gl.text=function(t){return $a(this,"text",t,Ja)},Gl.remove=function(){var t=this.namespace;return this.each("end.transition",function(){var e;this[t].count<2&&(e=this.parentNode)&&e.removeChild(this)})},Gl.ease=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].ease:("function"!=typeof t&&(t=co.ease.apply(co,arguments)),G(this,function(n){n[r][e].ease=t}))},Gl.delay=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].delay:G(this,"function"==typeof t?function(n,i,a){n[r][e].delay=+t.call(n,n.__data__,i,a)}:(t=+t,function(n){n[r][e].delay=t}))},Gl.duration=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].duration:G(this,"function"==typeof t?function(n,i,a){n[r][e].duration=Math.max(1,t.call(n,n.__data__,i,a))}:(t=Math.max(1,t),function(n){n[r][e].duration=t}))},Gl.each=function(t,e){var r=this.id,n=this.namespace;if(arguments.length<2){var i=ql,a=Vl;try{Vl=r,G(this,function(e,i,a){ql=e[n][r],t.call(e,e.__data__,i,a)})}finally{ql=i,Vl=a}}else G(this,function(i){var a=i[n][r];(a.event||(a.event=co.dispatch("start","end","interrupt"))).on(t,e)});return this},Gl.transition=function(){for(var t,e,r,n,i=this.id,a=++Yl,o=this.namespace,s=[],l=0,c=this.length;c>l;l++){s.push(t=[]);for(var e=this[l],u=0,f=e.length;f>u;u++)(r=e[u])&&(n=r[o][i],eo(r,u,o,a,{time:n.time,ease:n.ease,delay:n.delay+n.duration,duration:n.duration})),t.push(r)}return Qa(s,o,a)},co.svg.axis=function(){function t(t){t.each(function(){var t,c=co.select(this),u=this.__chart__||r,f=this.__chart__=r.copy(),h=null==l?f.ticks?f.ticks.apply(f,s):f.domain():l,d=null==e?f.tickFormat?f.tickFormat.apply(f,s):x:e,p=c.selectAll(".tick").data(h,f),g=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Do),v=co.transition(p.exit()).style("opacity",Do).remove(),m=co.transition(p.order()).style("opacity",1),y=Math.max(i,0)+o,b=Yi(f),_=c.selectAll(".domain").data([0]),w=(_.enter().append("path").attr("class","domain"),co.transition(_));g.append("line"),g.append("text");var k,A,M,T,E=g.select("line"),L=m.select("line"),S=p.select("text").text(d),C=g.select("text"),z=m.select("text"),P="top"===n||"left"===n?-1:1;if("bottom"===n||"top"===n?(t=ro,k="x",M="y",A="x2",T="y2",S.attr("dy",0>P?"0em":".71em").style("text-anchor","middle"),w.attr("d","M"+b[0]+","+P*a+"V0H"+b[1]+"V"+P*a)):(t=no,k="y",M="x",A="y2",T="x2",S.attr("dy",".32em").style("text-anchor",0>P?"end":"start"),w.attr("d","M"+P*a+","+b[0]+"H0V"+b[1]+"H"+P*a)),E.attr(T,P*i),C.attr(M,P*y),L.attr(A,0).attr(T,P*i),z.attr(k,0).attr(M,P*y),f.rangeBand){var R=f,O=R.rangeBand()/2;u=f=function(t){return R(t)+O}}else u.rangeBand?u=f:v.call(t,f,u);g.call(t,u,f),m.call(t,f,f)})}var e,r=co.scale.linear(),n=Xl,i=6,a=6,o=3,s=[10],l=null;return t.scale=function(e){return arguments.length?(r=e,t):r},t.orient=function(e){return arguments.length?(n=e in Wl?e+"":Xl,t):n},t.ticks=function(){return arguments.length?(s=fo(arguments),t):s},t.tickValues=function(e){return arguments.length?(l=e,t):l},t.tickFormat=function(r){return arguments.length?(e=r,t):e},t.tickSize=function(e){var r=arguments.length;return r?(i=+e,a=+arguments[r-1],t):i},t.innerTickSize=function(e){return arguments.length?(i=+e,t):i},t.outerTickSize=function(e){return arguments.length?(a=+e,t):a},t.tickPadding=function(e){return arguments.length?(o=+e,t):o},t.tickSubdivide=function(){return arguments.length&&t},t};var Xl="bottom",Wl={top:1,right:1,bottom:1,left:1};co.svg.brush=function(){function t(n){n.each(function(){var n=co.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",a).on("touchstart.brush",a),o=n.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),n.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var s=n.selectAll(".resize").data(g,x);s.exit().remove(),s.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return Zl[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),s.style("display",t.empty()?"none":null);var l,f=co.transition(n),h=co.transition(o);c&&(l=Yi(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(f)),u&&(l=Yi(u),h.attr("y",l[0]).attr("height",l[1]-l[0]),i(f)),e(f)})}function e(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+f[+/e$/.test(t)]+","+h[+/^s/.test(t)]+")"})}function r(t){t.select(".extent").attr("x",f[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function i(t){t.select(".extent").attr("y",h[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function a(){function a(){32==co.event.keyCode&&(S||(b=null,z[0]-=f[1],z[1]-=h[1],S=2),T())}function g(){32==co.event.keyCode&&2==S&&(z[0]+=f[1],z[1]+=h[1],S=0,T())}function v(){var t=co.mouse(_),n=!1;x&&(t[0]+=x[0],t[1]+=x[1]),S||(co.event.altKey?(b||(b=[(f[0]+f[1])/2,(h[0]+h[1])/2]),z[0]=f[+(t[0]u?(i=n,n=u):i=u),g[0]!=n||g[1]!=i?(r?s=null:o=null,g[0]=n,g[1]=i,!0):void 0}function y(){v(),A.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),co.select("body").style("cursor",null),P.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),k({type:"brushend"})}var b,x,_=this,w=co.select(co.event.target),k=l.of(_,arguments),A=co.select(_),M=w.datum(),E=!/^(n|s)$/.test(M)&&c,L=!/^(e|w)$/.test(M)&&u,S=w.classed("extent"),C=Q(_),z=co.mouse(_),P=co.select(n(_)).on("keydown.brush",a).on("keyup.brush",g);if(co.event.changedTouches?P.on("touchmove.brush",v).on("touchend.brush",y):P.on("mousemove.brush",v).on("mouseup.brush",y),A.interrupt().selectAll("*").interrupt(),S)z[0]=f[0]-z[0],z[1]=h[0]-z[1];else if(M){var R=+/w$/.test(M),O=+/^n/.test(M);x=[f[1-R]-z[0],h[1-O]-z[1]],z[0]=f[R],z[1]=h[O]}else co.event.altKey&&(b=z.slice());A.style("pointer-events","none").selectAll(".resize").style("display",null),co.select("body").style("cursor",w.style("cursor")),k({type:"brushstart"}),v()}var o,s,l=L(t,"brushstart","brush","brushend"),c=null,u=null,f=[0,0],h=[0,0],d=!0,p=!0,g=Kl[0];return t.event=function(t){t.each(function(){var t=l.of(this,arguments),e={x:f,y:h,i:o,j:s},r=this.__chart__||e;this.__chart__=e,Vl?co.select(this).transition().each("start.brush",function(){o=r.i,s=r.j,f=r.x,h=r.y,t({type:"brushstart"})}).tween("brush:brush",function(){var r=wn(f,e.x),n=wn(h,e.y);return o=s=null,function(i){f=e.x=r(i),h=e.y=n(i),t({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=e.i,s=e.j,t({type:"brush",mode:"resize"}),t({type:"brushend"})}):(t({type:"brushstart"}),t({type:"brush",mode:"resize"}),t({type:"brushend"}))})},t.x=function(e){return arguments.length?(c=e,g=Kl[!c<<1|!u],t):c},t.y=function(e){return arguments.length?(u=e,g=Kl[!c<<1|!u],t):u},t.clamp=function(e){return arguments.length?(c&&u?(d=!!e[0],p=!!e[1]):c?d=!!e:u&&(p=!!e),t):c&&u?[d,p]:c?d:u?p:null},t.extent=function(e){var r,n,i,a,l;return arguments.length?(c&&(r=e[0],n=e[1],u&&(r=r[0],n=n[0]),o=[r,n],c.invert&&(r=c(r),n=c(n)),r>n&&(l=r,r=n,n=l),r==f[0]&&n==f[1]||(f=[r,n])),u&&(i=e[0],a=e[1],c&&(i=i[1],a=a[1]),s=[i,a],u.invert&&(i=u(i),a=u(a)),i>a&&(l=i,i=a,a=l),i==h[0]&&a==h[1]||(h=[i,a])),t):(c&&(o?(r=o[0],n=o[1]):(r=f[0],n=f[1],c.invert&&(r=c.invert(r),n=c.invert(n)),r>n&&(l=r,r=n,n=l))),u&&(s?(i=s[0],a=s[1]):(i=h[0],a=h[1],u.invert&&(i=u.invert(i),a=u.invert(a)),i>a&&(l=i,i=a,a=l))),c&&u?[[r,i],[n,a]]:c?[r,n]:u&&[i,a])},t.clear=function(){return t.empty()||(f=[0,0],h=[0,0],o=s=null),t},t.empty=function(){return!!c&&f[0]==f[1]||!!u&&h[0]==h[1]},co.rebind(t,l,"on")};var Zl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Kl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Ql=vs.format=ws.timeFormat,$l=Ql.utc,Jl=$l("%Y-%m-%dT%H:%M:%S.%LZ");Ql.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?io:Jl,io.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},io.toString=Jl.toString,vs.second=Vt(function(t){return new ms(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),vs.seconds=vs.second.range,vs.seconds.utc=vs.second.utc.range,vs.minute=Vt(function(t){return new ms(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),vs.minutes=vs.minute.range,vs.minutes.utc=vs.minute.utc.range,vs.hour=Vt(function(t){var e=t.getTimezoneOffset()/60;return new ms(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),vs.hours=vs.hour.range,vs.hours.utc=vs.hour.utc.range,vs.month=Vt(function(t){return t=vs.day(t),t.setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),vs.months=vs.month.range,vs.months.utc=vs.month.utc.range;var tc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],ec=[[vs.second,1],[vs.second,5],[vs.second,15],[vs.second,30],[vs.minute,1],[vs.minute,5],[vs.minute,15],[vs.minute,30],[vs.hour,1],[vs.hour,3],[vs.hour,6],[vs.hour,12],[vs.day,1],[vs.day,2],[vs.week,1],[vs.month,1],[vs.month,3],[vs.year,1]],rc=Ql.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",ze]]),nc={range:function(t,e,r){return co.range(Math.ceil(t/r)*r,+e,r).map(oo)},floor:x,ceil:x};ec.year=vs.year,vs.scale=function(){return ao(co.scale.linear(),ec,rc)};var ic=ec.map(function(t){return[t[0].utc,t[1]]}),ac=$l.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",ze]]);ic.year=vs.year.utc,vs.scale.utc=function(){return ao(co.scale.linear(),ic,ac)},co.text=St(function(t){return t.responseText}),co.json=function(t,e){return Ct(t,"application/json",so,e)},co.html=function(t,e){return Ct(t,"text/html",lo,e)},co.xml=St(function(t){return t.responseXML}),"function"==typeof t&&t.amd?(this.d3=co,t(co)):"object"==typeof r&&r.exports?r.exports=co:this.d3=co}()},{}],73:[function(t,e,r){"use strict";function n(t,e){this.point=t,this.index=e}function i(t,e){for(var r=t.point,n=e.point,i=r.length,a=0;i>a;++a){var o=n[a]-r[a];if(o)return o}return 0}function a(t,e,r){if(1===t)return r?[[-1,0]]:[];var n=e.map(function(t,e){return[t[0],e]});n.sort(function(t,e){return t[0]-e[0]});for(var i=new Array(t-1),a=1;t>a;++a){var o=n[a-1],s=n[a];i[a-1]=[o[1],s[1]]}return r&&i.push([-1,i[0][1]],[i[t-1][1],-1]),i}function o(t,e){var r=t.length;if(0===r)return[];var o=t[0].length;if(1>o)return[];if(1===o)return a(r,t,e);for(var c=new Array(r),u=1,f=0;r>f;++f){for(var h=t[f],d=new Array(o+1),p=0,g=0;o>g;++g){var v=h[g];d[g]=v,p+=v*v}d[o]=p,c[f]=new n(d,f),u=Math.max(p,u)}l(c,i),r=c.length;for(var m=new Array(r+o+1),y=new Array(r+o+1),b=(o+1)*(o+1)*u,x=new Array(o+1),f=0;o>=f;++f)x[f]=0;x[o]=b,m[0]=x.slice(),y[0]=-1;for(var f=0;o>=f;++f){var d=x.slice();d[f]=1,m[f+1]=d,y[f+1]=-1}for(var f=0;r>f;++f){var _=c[f];m[f+o+1]=_.point,y[f+o+1]=_.index}var w=s(m,!1);if(w=e?w.filter(function(t){for(var e=0,r=0;o>=r;++r){var n=y[t[r]];if(0>n&&++e>=2)return!1;t[r]=n}return!0}):w.filter(function(t){for(var e=0;o>=e;++e){var r=y[t[e]];if(0>r)return!1;t[e]=r}return!0}),1&o)for(var f=0;f=i)return[];var a,o=new Array(i);if(r===t.length-1)for(a=0;i>a;++a)o[a]=e;else for(a=0;i>a;++a)o[a]=n(t,e,r+1);return o}function i(t,e){var r,n;for(r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return i(0|t,e);break;case"object":if("number"==typeof t.length)return n(t,e,0)}return[]}e.exports=a},{}],75:[function(e,r,n){(function(n,i){(function(){"use strict";function a(t){return"function"==typeof t||"object"==typeof t&&null!==t}function o(t){return"function"==typeof t}function s(t){Y=t}function l(t){K=t}function c(){return function(){n.nextTick(p)}}function u(){return function(){G(p)}}function f(){var t=0,e=new J(p),r=document.createTextNode("");return e.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}function h(){var t=new MessageChannel;return t.port1.onmessage=p,function(){t.port2.postMessage(0)}}function d(){return function(){setTimeout(p,1)}}function p(){for(var t=0;Z>t;t+=2){var e=rt[t],r=rt[t+1];e(r),rt[t]=void 0,rt[t+1]=void 0}Z=0}function g(){try{var t=e,r=t("vertx");return G=r.runOnLoop||r.runOnContext,u()}catch(n){return d()}}function v(t,e){var r=this,n=r._state;if(n===ot&&!t||n===st&&!e)return this;var i=new this.constructor(y),a=r._result;if(n){var o=arguments[n-1];K(function(){O(n,i,o,a)})}else C(r,i,t,e);return i}function m(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var r=new e(y);return T(r,t),r}function y(){}function b(){return new TypeError("You cannot resolve a promise with itself")}function x(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return lt.error=e,lt}}function w(t,e,r,n){try{t.call(e,r,n)}catch(i){return i}}function k(t,e,r){K(function(t){var n=!1,i=w(r,e,function(r){n||(n=!0,e!==r?T(t,r):L(t,r))},function(e){n||(n=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&i&&(n=!0,S(t,i))},t)}function A(t,e){e._state===ot?L(t,e._result):e._state===st?S(t,e._result):C(e,void 0,function(e){T(t,e)},function(e){S(t,e)})}function M(t,e,r){e.constructor===t.constructor&&r===nt&&constructor.resolve===it?A(t,e):r===lt?S(t,lt.error):void 0===r?L(t,e):o(r)?k(t,e,r):L(t,e)}function T(t,e){t===e?S(t,b()):a(e)?M(t,e,_(e)):L(t,e)}function E(t){t._onerror&&t._onerror(t._result),z(t)}function L(t,e){t._state===at&&(t._result=e,t._state=ot,0!==t._subscribers.length&&K(z,t))}function S(t,e){t._state===at&&(t._state=st,t._result=e,K(E,t))}function C(t,e,r,n){var i=t._subscribers,a=i.length;t._onerror=null,i[a]=e,i[a+ot]=r,i[a+st]=n,0===a&&t._state&&K(z,t)}function z(t){var e=t._subscribers,r=t._state;if(0!==e.length){for(var n,i,a=t._result,o=0;oo;o++)C(n.resolve(t[o]),void 0,e,r);return i}function F(t){var e=this,r=new e(y);return S(r,t),r}function D(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function B(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function U(t){this._id=dt++,this._state=void 0,this._result=void 0,this._subscribers=[],y!==t&&("function"!=typeof t&&D(),this instanceof U?I(this,t):B())}function V(t,e){this._instanceConstructor=t,this.promise=new t(y),Array.isArray(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?L(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&L(this.promise,this._result))):S(this.promise,this._validationError())}function q(){var t;if("undefined"!=typeof i)t=i;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var r=t.Promise;r&&"[object Promise]"===Object.prototype.toString.call(r.resolve())&&!r.cast||(t.Promise=pt)}var H;H=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var G,Y,X,W=H,Z=0,K=function(t,e){rt[Z]=t,rt[Z+1]=e,Z+=2,2===Z&&(Y?Y(p):X())},Q="undefined"!=typeof window?window:void 0,$=Q||{},J=$.MutationObserver||$.WebKitMutationObserver,tt="undefined"!=typeof n&&"[object process]"==={}.toString.call(n),et="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,rt=new Array(1e3);X=tt?c():J?f():et?h():void 0===Q&&"function"==typeof e?g():d();var nt=v,it=m,at=void 0,ot=1,st=2,lt=new P,ct=new P,ut=N,ft=j,ht=F,dt=0,pt=U;U.all=ut,U.race=ft,U.resolve=it,U.reject=ht,U._setScheduler=s,U._setAsap=l,U._asap=K,U.prototype={constructor:U,then:nt,"catch":function(t){return this.then(null,t)}};var gt=V;V.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},V.prototype._enumerate=function(){for(var t=this.length,e=this._input,r=0;this._state===at&&t>r;r++)this._eachEntry(e[r],r)},V.prototype._eachEntry=function(t,e){var r=this._instanceConstructor,n=r.resolve;if(n===it){var i=_(t);if(i===nt&&t._state!==at)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(r===pt){var a=new r(y);M(a,t,i),this._willSettleAt(a,e)}else this._willSettleAt(new r(function(e){e(t)}),e)}else this._willSettleAt(n(t),e)},V.prototype._settledAt=function(t,e,r){var n=this.promise;n._state===at&&(this._remaining--,t===st?S(n,r):this._result[e]=r),0===this._remaining&&L(n,this._result)},V.prototype._willSettleAt=function(t,e){var r=this;C(t,void 0,function(t){r._settledAt(ot,e,t)},function(t){r._settledAt(st,e,t)})};var vt=q,mt={Promise:pt,polyfill:vt +e.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}"));for(var u=0;ut?-1:t>e?1:t>=e?0:NaN}function a(t){return null===t?NaN:+t}function o(t){return!isNaN(t)}function s(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}function l(t){return t.length}function c(t){for(var e=1;t*e%1;)e*=10;return e}function u(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function f(){this._=Object.create(null)}function h(t){return(t+="")===ko||t[0]===Ao?Ao+t:t}function d(t){return(t+="")[0]===Ao?t.slice(1):t}function p(t){return h(t)in this._}function g(t){return(t=h(t))in this._&&delete this._[t]}function v(){var t=[];for(var e in this._)t.push(d(e));return t}function m(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function b(){this._=Object.create(null)}function x(t){return t}function _(t,e,r){return function(){var n=r.apply(e,arguments);return n===e?t:n}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var r=0,n=Mo.length;n>r;++r){var i=Mo[r]+e;if(i in t)return i}}function k(){}function A(){}function M(t){function e(){for(var e,n=r,i=-1,a=n.length;++ir;r++)for(var i,a=t[r],o=0,s=a.length;s>o;o++)(i=a[o])&&e(i,o,r);return t}function Y(t){return Eo(t,Oo),t}function X(t){var e,r;return function(n,i,a){var o,s=t[a].update,l=s.length;for(a!=r&&(r=a,e=0),i>=e&&(e=i+1);!(o=s[e])&&++e0&&(t=t.slice(0,s));var c=Io.get(t);return c&&(t=c,l=K),s?e?i:n:e?k:a}function Z(t,e){return function(r){var n=co.event;co.event=r,e[0]=this.__data__;try{t.apply(this,e)}finally{co.event=n}}}function K(t,e){var r=Z(t,e);return function(t){var e=this,n=t.relatedTarget;n&&(n===e||8&n.compareDocumentPosition(e))||r.call(e,t)}}function $(t){var r=".dragsuppress-"+ ++jo,i="click"+r,a=co.select(n(t)).on("touchmove"+r,T).on("dragstart"+r,T).on("selectstart"+r,T);if(null==No&&(No="onselectstart"in t?!1:w(t.style,"userSelect")),No){var o=e(t).style,s=o[No];o[No]="none"}return function(t){if(a.on(r,null),No&&(o[No]=s),t){var e=function(){a.on(i,null)};a.on(i,function(){T(),e()},!0),setTimeout(e,0)}}}function Q(t,e){e.changedTouches&&(e=e.changedTouches[0]);var r=t.ownerSVGElement||t;if(r.createSVGPoint){var i=r.createSVGPoint();if(0>Fo){var a=n(t);if(a.scrollX||a.scrollY){r=co.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();Fo=!(o.f||o.e),r.remove()}}return Fo?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}function J(){return co.event.changedTouches[0].identifier}function tt(t){return t>0?1:0>t?-1:0}function et(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function rt(t){return t>1?0:-1>t?Uo:Math.acos(t)}function nt(t){return t>1?Ho:-1>t?-Ho:Math.asin(t)}function it(t){return((t=Math.exp(t))-1/t)/2}function at(t){return((t=Math.exp(t))+1/t)/2}function ot(t){return((t=Math.exp(2*t))-1)/(t+1)}function st(t){return(t=Math.sin(t/2))*t}function lt(){}function ct(t,e,r){return this instanceof ct?(this.h=+t,this.s=+e,void(this.l=+r)):arguments.length<2?t instanceof ct?new ct(t.h,t.s,t.l):kt(""+t,At,ct):new ct(t,e,r)}function ut(t,e,r){function n(t){return t>360?t-=360:0>t&&(t+=360),60>t?a+(o-a)*t/60:180>t?o:240>t?a+(o-a)*(240-t)/60:a}function i(t){return Math.round(255*n(t))}var a,o;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:0>e?0:e>1?1:e,r=0>r?0:r>1?1:r,o=.5>=r?r*(1+e):r+e-r*e,a=2*r-o,new bt(i(t+120),i(t),i(t-120))}function ft(t,e,r){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+r)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof dt?gt(t.l,t.a,t.b):gt((t=Mt((t=co.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,r)}function ht(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new dt(r,Math.cos(t*=Go)*e,Math.sin(t)*e)}function dt(t,e,r){return this instanceof dt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof dt?new dt(t.l,t.a,t.b):t instanceof ft?ht(t.h,t.c,t.l):Mt((t=bt(t)).r,t.g,t.b):new dt(t,e,r)}function pt(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return i=vt(i)*rs,n=vt(n)*ns,a=vt(a)*is,new bt(yt(3.2404542*i-1.5371385*n-.4985314*a),yt(-.969266*i+1.8760108*n+.041556*a),yt(.0556434*i-.2040259*n+1.0572252*a))}function gt(t,e,r){return t>0?new ft(Math.atan2(r,e)*Yo,Math.sqrt(e*e+r*r),t):new ft(NaN,NaN,t)}function vt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function mt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function bt(t,e,r){return this instanceof bt?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof bt?new bt(t.r,t.g,t.b):kt(""+t,bt,ut):new bt(t,e,r)}function xt(t){return new bt(t>>16,t>>8&255,255&t)}function _t(t){return xt(t)+""}function wt(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function kt(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(Et(i[0]),Et(i[1]),Et(i[2]))}return(a=ss.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o=o>>4|o,s=240&a,s=s>>4|s,l=15&a,l=l<<4|l):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function At(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=.5>l?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(r>e?6:0):e==o?(r-t)/s+2:(t-e)/s+4,n*=60):(n=NaN,i=l>0&&1>l?0:n),new ct(n,i,l)}function Mt(t,e,r){t=Tt(t),e=Tt(e),r=Tt(r);var n=mt((.4124564*t+.3575761*e+.1804375*r)/rs),i=mt((.2126729*t+.7151522*e+.072175*r)/ns),a=mt((.0193339*t+.119192*e+.9503041*r)/is);return dt(116*i-16,500*(n-i),200*(i-a))}function Tt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Et(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function Lt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,r,n){return 2===arguments.length&&"function"==typeof r&&(n=r,r=null),Ct(e,r,t,n)}}function Ct(t,e,r,n){function i(){var t,e=l.status;if(!e&&Pt(l)||e>=200&&300>e||304===e){try{t=r.call(a,l)}catch(n){return void o.error.call(a,n)}o.load.call(a,t)}else o.error.call(a,l)}var a={},o=co.dispatch("beforesend","progress","load","error"),s={},l=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(t)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(t){var e=co.event;co.event=t;try{o.progress.call(a,l)}finally{co.event=e}},a.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",a)},a.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",a):e},a.responseType=function(t){return arguments.length?(c=t,a):c},a.response=function(t){return r=t,a},["get","post"].forEach(function(t){a[t]=function(){return a.send.apply(a,[t].concat(fo(arguments)))}}),a.send=function(r,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),l.open(r,t,!0),null==e||"accept"in s||(s.accept=e+",*/*"),l.setRequestHeader)for(var u in s)l.setRequestHeader(u,s[u]);return null!=e&&l.overrideMimeType&&l.overrideMimeType(e),null!=c&&(l.responseType=c),null!=i&&a.on("error",i).on("load",function(t){i(null,t)}),o.beforesend.call(a,l),l.send(null==n?null:n),a},a.abort=function(){return l.abort(),a},co.rebind(a,o,"on"),null==n?a:a.get(zt(n))}function zt(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}function Pt(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Rt(t,e,r){var n=arguments.length;2>n&&(e=0),3>n&&(r=Date.now());var i=r+e,a={c:t,t:i,n:null};return cs?cs.n=a:ls=a,cs=a,us||(fs=clearTimeout(fs),us=1,hs(Ot)),a}function Ot(){var t=It(),e=Nt()-t;e>24?(isFinite(e)&&(clearTimeout(fs),fs=setTimeout(Ot,e)),us=0):(us=1,hs(Ot))}function It(){for(var t=Date.now(),e=ls;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Nt(){for(var t,e=ls,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}}function Dt(t){var e=t.decimal,r=t.thousands,n=t.grouping,i=t.currency,a=n&&r?function(t,e){for(var i=t.length,a=[],o=0,s=n[0],l=0;i>0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>e));)s=n[o=(o+1)%n.length];return a.reverse().join(r)}:x;return function(t){var r=ps.exec(t),n=r[1]||" ",o=r[2]||">",s=r[3]||"-",l=r[4]||"",c=r[5],u=+r[6],f=r[7],h=r[8],d=r[9],p=1,g="",v="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(c||"0"===n&&"="===o)&&(c=n="0",o="="),d){case"n":f=!0,d="g";break;case"%":p=100,v="%",d="f";break;case"p":p=100,v="%",d="r";break;case"b":case"o":case"x":case"X":"#"===l&&(g="0"+d.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,d="r"}"$"===l&&(g=i[0],v=i[1]),"r"!=d||h||(d="g"),null!=h&&("g"==d?h=Math.max(1,Math.min(21,h)):"e"!=d&&"f"!=d||(h=Math.max(0,Math.min(20,h)))),d=gs.get(d)||Bt;var b=c&&f;return function(t){var r=v;if(m&&t%1)return"";var i=0>t||0===t&&0>1/t?(t=-t,"-"):"-"===s?"":s;if(0>p){var l=co.formatPrefix(t,h);t=l.scale(t),r=l.symbol+v}else t*=p;t=d(t,h);var x,_,w=t.lastIndexOf(".");if(0>w){var k=y?t.lastIndexOf("e"):-1;0>k?(x=t,_=""):(x=t.substring(0,k),_=t.substring(k))}else x=t.substring(0,w),_=e+t.substring(w+1);!c&&f&&(x=a(x,1/0));var A=g.length+x.length+_.length+(b?0:i.length),M=u>A?new Array(A=u-A+1).join(n):"";return b&&(x=a(M+x,M.length?u-_.length:1/0)),i+=g,t=x+_,("<"===o?i+t+M:">"===o?M+i+t:"^"===o?M.substring(0,A>>=1)+i+t+M.substring(A):i+(b?t:M+t))+r}}}function Bt(t){return t+""}function Ut(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Vt(t,e,r){function n(e){var r=t(e),n=a(r,1);return n-e>e-r?r:n}function i(r){return e(r=t(new ms(r-1)),1),r}function a(t,r){return e(t=new ms(+t),r),t}function o(t,n,a){var o=i(t),s=[];if(a>1)for(;n>o;)r(o)%a||s.push(new Date(+o)),e(o,1);else for(;n>o;)s.push(new Date(+o)),e(o,1);return s}function s(t,e,r){try{ms=Ut;var n=new Ut;return n._=t,o(n,e,r)}finally{ms=Date}}t.floor=t,t.round=n,t.ceil=i,t.offset=a,t.range=o;var l=t.utc=qt(t);return l.floor=l,l.round=qt(n),l.ceil=qt(i),l.offset=qt(a),l.range=s,t}function qt(t){return function(e,r){try{ms=Ut;var n=new Ut;return n._=e,t(n,r)._}finally{ms=Date}}}function Ht(t){function e(t){function e(e){for(var r,i,a,o=[],s=-1,l=0;++ss;){if(n>=c)return-1;if(i=e.charCodeAt(s++),37===i){if(o=e.charAt(s++),a=S[o in bs?e.charAt(s++):o],!a||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}function n(t,e,r){w.lastIndex=0;var n=w.exec(e.slice(r));return n?(t.w=k.get(n[0].toLowerCase()),r+n[0].length):-1}function i(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.w=_.get(n[0].toLowerCase()),r+n[0].length):-1}function a(t,e,r){T.lastIndex=0;var n=T.exec(e.slice(r));return n?(t.m=E.get(n[0].toLowerCase()),r+n[0].length):-1}function o(t,e,r){A.lastIndex=0;var n=A.exec(e.slice(r));return n?(t.m=M.get(n[0].toLowerCase()),r+n[0].length):-1}function s(t,e,n){return r(t,L.c.toString(),e,n)}function l(t,e,n){return r(t,L.x.toString(),e,n)}function c(t,e,n){return r(t,L.X.toString(),e,n)}function u(t,e,r){var n=b.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)}var f=t.dateTime,h=t.date,d=t.time,p=t.periods,g=t.days,v=t.shortDays,m=t.months,y=t.shortMonths;e.utc=function(t){function r(t){try{ms=Ut;var e=new ms;return e._=t,n(e)}finally{ms=Date}}var n=e(t);return r.parse=function(t){try{ms=Ut;var e=n.parse(t);return e&&e._}finally{ms=Date}},r.toString=n.toString,r},e.multi=e.utc.multi=ue;var b=co.map(),x=Yt(g),_=Xt(g),w=Yt(v),k=Xt(v),A=Yt(m),M=Xt(m),T=Yt(y),E=Xt(y);p.forEach(function(t,e){b.set(t.toLowerCase(),e)});var L={a:function(t){return v[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return m[t.getMonth()]},c:e(f),d:function(t,e){return Gt(t.getDate(),e,2)},e:function(t,e){return Gt(t.getDate(),e,2)},H:function(t,e){return Gt(t.getHours(),e,2)},I:function(t,e){return Gt(t.getHours()%12||12,e,2)},j:function(t,e){return Gt(1+vs.dayOfYear(t),e,3)},L:function(t,e){return Gt(t.getMilliseconds(),e,3)},m:function(t,e){return Gt(t.getMonth()+1,e,2)},M:function(t,e){return Gt(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Gt(t.getSeconds(),e,2)},U:function(t,e){return Gt(vs.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Gt(vs.mondayOfYear(t),e,2)},x:e(h),X:e(d),y:function(t,e){return Gt(t.getFullYear()%100,e,2)},Y:function(t,e){return Gt(t.getFullYear()%1e4,e,4)},Z:le,"%":function(){return"%"}},S={a:n,A:i,b:a,B:o,c:s,d:re,e:re,H:ie,I:ie,j:ne,L:se,m:ee,M:ae,p:u,S:oe,U:Zt,w:Wt,W:Kt,x:l,X:c,y:Qt,Y:$t,Z:Jt,"%":ce};return e}function Gt(t,e,r){var n=0>t?"-":"",i=(n?-t:t)+"",a=i.length;return n+(r>a?new Array(r-a+1).join(e)+i:i)}function Yt(t){return new RegExp("^(?:"+t.map(co.requote).join("|")+")","i")}function Xt(t){for(var e=new f,r=-1,n=t.length;++r68?1900:2e3)}function ee(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function re(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function ne(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function ie(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function ae(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function oe(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function se(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function le(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=wo(e)/60|0,i=wo(e)%60;return r+Gt(n,"0",2)+Gt(i,"0",2)}function ce(t,e,r){_s.lastIndex=0;var n=_s.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function ue(t){for(var e=t.length,r=-1;++r=0?1:-1,s=o*r,l=Math.cos(e),c=Math.sin(e),u=a*c,f=i*l+u*Math.cos(s),h=u*o*Math.sin(s);Es.add(Math.atan2(h,f)),n=t,i=l,a=c}var e,r,n,i,a;Ls.point=function(o,s){Ls.point=t,n=(e=o)*Go,i=Math.cos(s=(r=s)*Go/2+Uo/4),a=Math.sin(s)},Ls.lineEnd=function(){t(e,r)}}function me(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function be(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function xe(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ke(t){return[Math.atan2(t[1],t[0]),nt(t[2])]}function Ae(t,e){return wo(t[0]-e[0])s;++s)i.point((r=t[s])[0],r[1]);return void i.lineEnd()}var l=new Oe(r,t,null,!0),c=new Oe(r,null,l,!1);l.o=c,a.push(l),o.push(c),l=new Oe(n,t,null,!1),c=new Oe(n,null,l,!0),l.o=c,a.push(l),o.push(c)}}),o.sort(e),Re(a),Re(o),a.length){for(var s=0,l=r,c=o.length;c>s;++s)o[s].e=l=!l;for(var u,f,h=a[0];;){for(var d=h,p=!0;d.v;)if((d=d.n)===h)return;u=d.z,i.lineStart();do{if(d.v=d.o.v=!0,d.e){if(p)for(var s=0,c=u.length;c>s;++s)i.point((f=u[s])[0],f[1]);else n(d.x,d.n.x,1,i);d=d.n}else{if(p){u=d.p.z;for(var s=u.length-1;s>=0;--s)i.point((f=u[s])[0],f[1])}else n(d.x,d.p.x,-1,i);d=d.p}d=d.o,u=d.z,p=!p}while(!d.v);i.lineEnd()}}}function Re(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n0){for(_||(a.polygonStart(),_=!0),a.lineStart();++o1&&2&e&&r.push(r.pop().concat(r.shift())),d.push(r.filter(Ne))}var d,p,g,v=e(a),m=i.invert(n[0],n[1]),y={point:o,lineStart:l,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=f,y.lineEnd=h,d=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=l,y.lineEnd=c,d=co.merge(d);var t=Ve(m,p);d.length?(_||(a.polygonStart(),_=!0),Pe(d,Fe,t,r,a)):t&&(_||(a.polygonStart(),_=!0),a.lineStart(),r(null,null,1,a),a.lineEnd()),_&&(a.polygonEnd(),_=!1),d=p=null},sphere:function(){a.polygonStart(),a.lineStart(),r(null,null,1,a),a.lineEnd(),a.polygonEnd()}},b=je(),x=e(b),_=!1;return y}}function Ne(t){return t.length>1}function je(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:k,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Fe(t,e){return((t=t.x)[0]<0?t[1]-Ho-Do:Ho-t[1])-((e=e.x)[0]<0?e[1]-Ho-Do:Ho-e[1])}function De(t){var e,r=NaN,n=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?Uo:-Uo,l=wo(a-r);wo(l-Uo)0?Ho:-Ho),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=Uo&&(wo(r-i)Do?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}function Ue(t,e,r,n){var i;if(null==t)i=r*Ho,n.point(-Uo,i),n.point(0,i),n.point(Uo,i),n.point(Uo,0),n.point(Uo,-i),n.point(0,-i),n.point(-Uo,-i),n.point(-Uo,0),n.point(-Uo,i);else if(wo(t[0]-e[0])>Do){var a=t[0]s;++s){var c=e[s],u=c.length;if(u)for(var f=c[0],h=f[0],d=f[1]/2+Uo/4,p=Math.sin(d),g=Math.cos(d),v=1;;){v===u&&(v=0),t=c[v];var m=t[0],y=t[1]/2+Uo/4,b=Math.sin(y),x=Math.cos(y),_=m-h,w=_>=0?1:-1,k=w*_,A=k>Uo,M=p*b;if(Es.add(Math.atan2(M*w*Math.sin(k),g*x+M*Math.cos(k))),a+=A?_+w*Vo:_,A^h>=r^m>=r){var T=be(me(f),me(t));we(T);var E=be(i,T);we(E);var L=(A^_>=0?-1:1)*nt(E[2]);(n>L||n===L&&(T[0]||T[1]))&&(o+=A^_>=0?1:-1)}if(!v++)break;h=m,p=b,g=x,f=t}}return(-Do>a||Do>a&&0>Es)^1&o}function qe(t){function e(t,e){return Math.cos(t)*Math.cos(e)>a}function r(t){var r,a,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(f,h){var d,p=[f,h],g=e(f,h),v=o?g?0:i(f,h):g?i(f+(0>f?Uo:-Uo),h):0;if(!r&&(c=l=g)&&t.lineStart(),g!==l&&(d=n(r,p),(Ae(r,d)||Ae(p,d))&&(p[0]+=Do,p[1]+=Do,g=e(p[0],p[1]))),g!==l)u=0,g?(t.lineStart(),d=n(p,r),t.point(d[0],d[1])):(d=n(r,p),t.point(d[0],d[1]),t.lineEnd()),r=d;else if(s&&r&&o^g){var m;v&a||!(m=n(p,r,!0))||(u=0,o?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||r&&Ae(r,p)||t.point(p[0],p[1]),r=p,l=g,a=v},lineEnd:function(){l&&t.lineEnd(),r=null},clean:function(){return u|(c&&l)<<1}}}function n(t,e,r){var n=me(t),i=me(e),o=[1,0,0],s=be(n,i),l=ye(s,s),c=s[0],u=l-c*c;if(!u)return!r&&t;var f=a*l/u,h=-a*c/u,d=be(o,s),p=_e(o,f),g=_e(s,h);xe(p,g);var v=d,m=ye(p,v),y=ye(v,v),b=m*m-y*(ye(p,p)-1);if(!(0>b)){var x=Math.sqrt(b),_=_e(v,(-m-x)/y);if(xe(_,p),_=ke(_),!r)return _;var w,k=t[0],A=e[0],M=t[1],T=e[1];k>A&&(w=k,k=A,A=w);var E=A-k,L=wo(E-Uo)E;if(!L&&M>T&&(w=M,M=T,T=w),S?L?M+T>0^_[1]<(wo(_[0]-k)Uo^(k<=_[0]&&_[0]<=A)){var C=_e(v,(-m+x)/y);return xe(C,p),[_,ke(C)]}}}function i(e,r){var n=o?t:Uo-t,i=0;return-n>e?i|=1:e>n&&(i|=2),-n>r?i|=4:r>n&&(i|=8),i}var a=Math.cos(t),o=a>0,s=wo(a)>Do,l=vr(t,6*Go);return Ie(e,r,l,o?[0,-t]:[-Uo,t-Uo])}function He(t,e,r,n){return function(i){var a,o=i.a,s=i.b,l=o.x,c=o.y,u=s.x,f=s.y,h=0,d=1,p=u-l,g=f-c;if(a=t-l,p||!(a>0)){if(a/=p,0>p){if(h>a)return;d>a&&(d=a)}else if(p>0){if(a>d)return;a>h&&(h=a)}if(a=r-l,p||!(0>a)){if(a/=p,0>p){if(a>d)return;a>h&&(h=a)}else if(p>0){if(h>a)return;d>a&&(d=a)}if(a=e-c,g||!(a>0)){if(a/=g,0>g){if(h>a)return;d>a&&(d=a)}else if(g>0){if(a>d)return;a>h&&(h=a)}if(a=n-c,g||!(0>a)){if(a/=g,0>g){if(a>d)return;a>h&&(h=a)}else if(g>0){if(h>a)return;d>a&&(d=a)}return h>0&&(i.a={x:l+h*p,y:c+h*g}),1>d&&(i.b={x:l+d*p,y:c+d*g}),i}}}}}}function Ge(t,e,r,n){function i(n,i){return wo(n[0]-t)0?0:3:wo(n[0]-r)0?2:1:wo(n[1]-e)0?1:0:i>0?3:2}function a(t,e){return o(t.x,e.x)}function o(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}return function(s){function l(t){for(var e=0,r=v.length,n=t[1],i=0;r>i;++i)for(var a,o=1,s=v[i],l=s.length,c=s[0];l>o;++o)a=s[o],c[1]<=n?a[1]>n&&et(c,a,t)>0&&++e:a[1]<=n&&et(c,a,t)<0&&--e,c=a;return 0!==e}function c(a,s,l,c){var u=0,f=0;if(null==a||(u=i(a,l))!==(f=i(s,l))||o(a,s)<0^l>0){do c.point(0===u||3===u?t:r,u>1?n:e);while((u=(u+l+4)%4)!==f)}else c.point(s[0],s[1])}function u(i,a){return i>=t&&r>=i&&a>=e&&n>=a}function f(t,e){u(t,e)&&s.point(t,e)}function h(){S.point=p,v&&v.push(m=[]),A=!0,k=!1,_=w=NaN}function d(){g&&(p(y,b),x&&k&&E.rejoin(),g.push(E.buffer())),S.point=f,k&&s.lineEnd()}function p(t,e){t=Math.max(-Vs,Math.min(Vs,t)),e=Math.max(-Vs,Math.min(Vs,e));var r=u(t,e);if(v&&m.push([t,e]),A)y=t,b=e,x=r,A=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&k)s.point(t,e);else{var n={a:{x:_,y:w},b:{x:t,y:e}};L(n)?(k||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),M=!1):r&&(s.lineStart(),s.point(t,e),M=!1)}_=t,w=e,k=r}var g,v,m,y,b,x,_,w,k,A,M,T=s,E=je(),L=He(t,e,r,n),S={point:f,lineStart:h,lineEnd:d,polygonStart:function(){s=E,g=[],v=[],M=!0},polygonEnd:function(){s=T,g=co.merge(g);var e=l([t,n]),r=M&&e,i=g.length;(r||i)&&(s.polygonStart(),r&&(s.lineStart(),c(null,null,1,s),s.lineEnd()),i&&Pe(g,a,e,c,s),s.polygonEnd()),g=v=m=null}};return S}}function Ye(t){var e=0,r=Uo/3,n=lr(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*Uo/180,r=t[1]*Uo/180):[e/Uo*180,r/Uo*180]},i}function Xe(t,e){function r(t,e){var r=Math.sqrt(a-2*i*Math.sin(e))/i;return[r*Math.sin(t*=i),o-r*Math.cos(t)]}var n=Math.sin(t),i=(n+Math.sin(e))/2,a=1+n*(2*i-n),o=Math.sqrt(a)/i;return r.invert=function(t,e){var r=o-e;return[Math.atan2(t,r)/i,nt((a-(t*t+r*r)*i*i)/(2*i))]},r}function We(){function t(t,e){Hs+=i*t-n*e,n=t,i=e}var e,r,n,i;Zs.point=function(a,o){Zs.point=t,e=n=a,r=i=o},Zs.lineEnd=function(){t(e,r)}}function Ze(t,e){Gs>t&&(Gs=t),t>Xs&&(Xs=t),Ys>e&&(Ys=e),e>Ws&&(Ws=e)}function Ke(){function t(t,e){o.push("M",t,",",e,a)}function e(t,e){o.push("M",t,",",e),s.point=r}function r(t,e){o.push("L",t,",",e)}function n(){s.point=t}function i(){o.push("Z")}var a=$e(4.5),o=[],s={point:t,lineStart:function(){s.point=e},lineEnd:n,polygonStart:function(){s.lineEnd=i},polygonEnd:function(){s.lineEnd=n,s.point=t},pointRadius:function(t){return a=$e(t),s},result:function(){if(o.length){var t=o.join("");return o=[],t}}};return s}function $e(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Qe(t,e){zs+=t,Ps+=e,++Rs}function Je(){function t(t,n){var i=t-e,a=n-r,o=Math.sqrt(i*i+a*a);Os+=o*(e+t)/2,Is+=o*(r+n)/2,Ns+=o,Qe(e=t,r=n)}var e,r;$s.point=function(n,i){$s.point=t,Qe(e=n,r=i)}}function tr(){$s.point=Qe}function er(){function t(t,e){var r=t-n,a=e-i,o=Math.sqrt(r*r+a*a);Os+=o*(n+t)/2,Is+=o*(i+e)/2,Ns+=o,o=i*t-n*e,js+=o*(n+t),Fs+=o*(i+e),Ds+=3*o,Qe(n=t,i=e)}var e,r,n,i;$s.point=function(a,o){$s.point=t,Qe(e=n=a,r=i=o)},$s.lineEnd=function(){t(e,r)}}function rr(t){function e(e,r){t.moveTo(e+o,r),t.arc(e,r,o,0,Vo); +}function r(e,r){t.moveTo(e,r),s.point=n}function n(e,r){t.lineTo(e,r)}function i(){s.point=e}function a(){t.closePath()}var o=4.5,s={point:e,lineStart:function(){s.point=r},lineEnd:i,polygonStart:function(){s.lineEnd=a},polygonEnd:function(){s.lineEnd=i,s.point=e},pointRadius:function(t){return o=t,s},result:k};return s}function nr(t){function e(t){return(s?n:r)(t)}function r(e){return or(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})}function n(e){function r(r,n){r=t(r,n),e.point(r[0],r[1])}function n(){b=NaN,A.point=a,e.lineStart()}function a(r,n){var a=me([r,n]),o=t(r,n);i(b,x,y,_,w,k,b=o[0],x=o[1],y=r,_=a[0],w=a[1],k=a[2],s,e),e.point(b,x)}function o(){A.point=r,e.lineEnd()}function l(){n(),A.point=c,A.lineEnd=u}function c(t,e){a(f=t,h=e),d=b,p=x,g=_,v=w,m=k,A.point=a}function u(){i(b,x,y,_,w,k,d,p,f,g,v,m,s,e),A.lineEnd=o,o()}var f,h,d,p,g,v,m,y,b,x,_,w,k,A={point:r,lineStart:n,lineEnd:o,polygonStart:function(){e.polygonStart(),A.lineStart=l},polygonEnd:function(){e.polygonEnd(),A.lineStart=n}};return A}function i(e,r,n,s,l,c,u,f,h,d,p,g,v,m){var y=u-e,b=f-r,x=y*y+b*b;if(x>4*a&&v--){var _=s+d,w=l+p,k=c+g,A=Math.sqrt(_*_+w*w+k*k),M=Math.asin(k/=A),T=wo(wo(k)-1)a||wo((y*C+b*z)/x-.5)>.3||o>s*d+l*p+c*g)&&(i(e,r,n,s,l,c,L,S,T,_/=A,w/=A,k,v,m),m.point(L,S),i(L,S,T,_,w,k,u,f,h,d,p,g,v,m))}}var a=.5,o=Math.cos(30*Go),s=16;return e.precision=function(t){return arguments.length?(s=(a=t*t)>0&&16,e):Math.sqrt(a)},e}function ir(t){var e=nr(function(e,r){return t([e*Yo,r*Yo])});return function(t){return cr(e(t))}}function ar(t){this.stream=t}function or(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sr(t){return lr(function(){return t})()}function lr(t){function e(t){return t=s(t[0]*Go,t[1]*Go),[t[0]*h+l,c-t[1]*h]}function r(t){return t=s.invert((t[0]-l)/h,(c-t[1])/h),t&&[t[0]*Yo,t[1]*Yo]}function n(){s=Ce(o=hr(m,y,b),a);var t=a(g,v);return l=d-t[0]*h,c=p+t[1]*h,i()}function i(){return u&&(u.valid=!1,u=null),e}var a,o,s,l,c,u,f=nr(function(t,e){return t=a(t,e),[t[0]*h+l,c-t[1]*h]}),h=150,d=480,p=250,g=0,v=0,m=0,y=0,b=0,_=Us,w=x,k=null,A=null;return e.stream=function(t){return u&&(u.valid=!1),u=cr(_(o,f(w(t)))),u.valid=!0,u},e.clipAngle=function(t){return arguments.length?(_=null==t?(k=t,Us):qe((k=+t)*Go),i()):k},e.clipExtent=function(t){return arguments.length?(A=t,w=t?Ge(t[0][0],t[0][1],t[1][0],t[1][1]):x,i()):A},e.scale=function(t){return arguments.length?(h=+t,n()):h},e.translate=function(t){return arguments.length?(d=+t[0],p=+t[1],n()):[d,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Go,v=t[1]%360*Go,n()):[g*Yo,v*Yo]},e.rotate=function(t){return arguments.length?(m=t[0]%360*Go,y=t[1]%360*Go,b=t.length>2?t[2]%360*Go:0,n()):[m*Yo,y*Yo,b*Yo]},co.rebind(e,f,"precision"),function(){return a=t.apply(this,arguments),e.invert=a.invert&&r,n()}}function cr(t){return or(t,function(e,r){t.point(e*Go,r*Go)})}function ur(t,e){return[t,e]}function fr(t,e){return[t>Uo?t-Vo:-Uo>t?t+Vo:t,e]}function hr(t,e,r){return t?e||r?Ce(pr(t),gr(e,r)):pr(t):e||r?gr(e,r):fr}function dr(t){return function(e,r){return e+=t,[e>Uo?e-Vo:-Uo>e?e+Vo:e,r]}}function pr(t){var e=dr(t);return e.invert=dr(-t),e}function gr(t,e){function r(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*n+s*i;return[Math.atan2(l*a-u*o,s*n-c*i),nt(u*a+l*o)]}var n=Math.cos(t),i=Math.sin(t),a=Math.cos(e),o=Math.sin(e);return r.invert=function(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*a-l*o;return[Math.atan2(l*a+c*o,s*n+u*i),nt(u*n-s*i)]},r}function vr(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=mr(r,i),a=mr(r,a),(o>0?a>i:i>a)&&(i+=o*Vo)):(i=t+o*Vo,a=t-.5*l);for(var c,u=i;o>0?u>a:a>u;u-=l)s.point((c=ke([r,-n*Math.cos(u),-n*Math.sin(u)]))[0],c[1])}}function mr(t,e){var r=me(e);r[0]-=t,we(r);var n=rt(-r[1]);return((-r[2]<0?-n:n)+2*Math.PI-Do)%(2*Math.PI)}function yr(t,e,r){var n=co.range(t,e-Do,r).concat(e);return function(t){return n.map(function(e){return[t,e]})}}function br(t,e,r){var n=co.range(t,e-Do,r).concat(e);return function(t){return n.map(function(e){return[e,t]})}}function xr(t){return t.source}function _r(t){return t.target}function wr(t,e,r,n){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(n),s=Math.sin(n),l=i*Math.cos(t),c=i*Math.sin(t),u=o*Math.cos(r),f=o*Math.sin(r),h=2*Math.asin(Math.sqrt(st(n-e)+i*o*st(r-t))),d=1/Math.sin(h),p=h?function(t){var e=Math.sin(t*=h)*d,r=Math.sin(h-t)*d,n=r*l+e*u,i=r*c+e*f,o=r*a+e*s;return[Math.atan2(i,n)*Yo,Math.atan2(o,Math.sqrt(n*n+i*i))*Yo]}:function(){return[t*Yo,e*Yo]};return p.distance=h,p}function kr(){function t(t,i){var a=Math.sin(i*=Go),o=Math.cos(i),s=wo((t*=Go)-e),l=Math.cos(s);Qs+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=n*a-r*o*l)*s),r*a+n*o*l),e=t,r=a,n=o}var e,r,n;Js.point=function(i,a){e=i*Go,r=Math.sin(a*=Go),n=Math.cos(a),Js.point=t},Js.lineEnd=function(){Js.point=Js.lineEnd=k}}function Ar(t,e){function r(e,r){var n=Math.cos(e),i=Math.cos(r),a=t(n*i);return[a*i*Math.sin(e),a*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),i=e(n),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,n*o),Math.asin(n&&r*a/n)]},r}function Mr(t,e){function r(t,e){o>0?-Ho+Do>e&&(e=-Ho+Do):e>Ho-Do&&(e=Ho-Do);var r=o/Math.pow(i(e),a);return[r*Math.sin(a*t),o-r*Math.cos(a*t)]}var n=Math.cos(t),i=function(t){return Math.tan(Uo/4+t/2)},a=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(i(e)/i(t)),o=n*Math.pow(i(t),a)/a;return a?(r.invert=function(t,e){var r=o-e,n=tt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(o/n,1/a))-Ho]},r):Er}function Tr(t,e){function r(t,e){var r=a-e;return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}var n=Math.cos(t),i=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),a=n/i+t;return wo(i)i;i++){for(;n>1&&et(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function Rr(t,e){return t[0]-e[0]||t[1]-e[1]}function Or(t,e,r){return(r[0]-e[0])*(t[1]-e[1])<(r[1]-e[1])*(t[0]-e[0])}function Ir(t,e,r,n){var i=t[0],a=r[0],o=e[0]-i,s=n[0]-a,l=t[1],c=r[1],u=e[1]-l,f=n[1]-c,h=(s*(l-c)-f*(i-a))/(f*o-s*u);return[i+h*o,l+h*u]}function Nr(t){var e=t[0],r=t[t.length-1];return!(e[0]-r[0]||e[1]-r[1])}function jr(){an(this),this.edge=this.site=this.circle=null}function Fr(t){var e=fl.pop()||new jr;return e.site=t,e}function Dr(t){Zr(t),ll.remove(t),fl.push(t),an(t)}function Br(t){var e=t.circle,r=e.x,n=e.cy,i={x:r,y:n},a=t.P,o=t.N,s=[t];Dr(t);for(var l=a;l.circle&&wo(r-l.circle.x)u;++u)c=s[u],l=s[u-1],en(c.edge,l.site,c.site,i);l=s[0],c=s[f-1],c.edge=Jr(l.site,c.site,null,i),Wr(l),Wr(c)}function Ur(t){for(var e,r,n,i,a=t.x,o=t.y,s=ll._;s;)if(n=Vr(s,o)-a,n>Do)s=s.L;else{if(i=a-qr(s,o),!(i>Do)){n>-Do?(e=s.P,r=s):i>-Do?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=Fr(t);if(ll.insert(e,l),e||r){if(e===r)return Zr(e),r=Fr(e.site),ll.insert(l,r),l.edge=r.edge=Jr(e.site,l.site),Wr(e),void Wr(r);if(!r)return void(l.edge=Jr(e.site,l.site));Zr(e),Zr(r);var c=e.site,u=c.x,f=c.y,h=t.x-u,d=t.y-f,p=r.site,g=p.x-u,v=p.y-f,m=2*(h*v-d*g),y=h*h+d*d,b=g*g+v*v,x={x:(v*y-d*b)/m+u,y:(h*b-g*y)/m+f};en(r.edge,c,p,x),l.edge=Jr(c,t,null,x),r.edge=Jr(t,p,null,x),Wr(e),Wr(r)}}function Vr(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-(1/0);r=o.site;var s=r.x,l=r.y,c=l-e;if(!c)return s;var u=s-n,f=1/a-1/c,h=u/c;return f?(-h+Math.sqrt(h*h-2*f*(u*u/(-2*c)-l+c/2+i-a/2)))/f+n:(n+s)/2}function qr(t,e){var r=t.N;if(r)return Vr(r,e);var n=t.site;return n.y===e?n.x:1/0}function Hr(t){this.site=t,this.edges=[]}function Gr(t){for(var e,r,n,i,a,o,s,l,c,u,f=t[0][0],h=t[1][0],d=t[0][1],p=t[1][1],g=sl,v=g.length;v--;)if(a=g[v],a&&a.prepare())for(s=a.edges,l=s.length,o=0;l>o;)u=s[o].end(),n=u.x,i=u.y,c=s[++o%l].start(),e=c.x,r=c.y,(wo(n-e)>Do||wo(i-r)>Do)&&(s.splice(o,0,new rn(tn(a.site,u,wo(n-f)Do?{x:f,y:wo(e-f)Do?{x:wo(r-p)Do?{x:h,y:wo(e-h)Do?{x:wo(r-d)=-Bo)){var d=l*l+c*c,p=u*u+f*f,g=(f*d-c*p)/h,v=(l*p-u*d)/h,f=v+s,m=hl.pop()||new Xr;m.arc=t,m.site=i,m.x=g+o,m.y=f+Math.sqrt(g*g+v*v),m.cy=f,t.circle=m;for(var y=null,b=ul._;b;)if(m.yv||v>=s)return;if(h>p){if(a){if(a.y>=c)return}else a={x:v,y:l};r={x:v,y:c}}else{if(a){if(a.yn||n>1)if(h>p){if(a){if(a.y>=c)return}else a={x:(l-i)/n,y:l};r={x:(c-i)/n,y:c}}else{if(a){if(a.yd){if(a){if(a.x>=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xa||f>o||n>h||i>d)){if(p=t.point){var p,g=e-t.x,v=r-t.y,m=g*g+v*v;if(l>m){var y=Math.sqrt(l=m);n=e-y,i=r-y,a=e+y,o=r+y,s=p}}for(var b=t.nodes,x=.5*(u+h),_=.5*(f+d),w=e>=x,k=r>=_,A=k<<1|w,M=A+4;M>A;++A)if(t=b[3&A])switch(3&A){case 0:c(t,u,f,x,_);break;case 1:c(t,x,f,h,_);break;case 2:c(t,u,_,x,d);break;case 3:c(t,x,_,h,d)}}}(t,n,i,a,o),s}function mn(t,e){t=co.rgb(t),e=co.rgb(e);var r=t.r,n=t.g,i=t.b,a=e.r-r,o=e.g-n,s=e.b-i;return function(t){return"#"+wt(Math.round(r+a*t))+wt(Math.round(n+o*t))+wt(Math.round(i+s*t))}}function yn(t,e){var r,n={},i={};for(r in t)r in e?n[r]=_n(t[r],e[r]):i[r]=t[r];for(r in e)r in t||(i[r]=e[r]);return function(t){for(r in n)i[r]=n[r](t);return i}}function bn(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function xn(t,e){var r,n,i,a=pl.lastIndex=gl.lastIndex=0,o=-1,s=[],l=[];for(t+="",e+="";(r=pl.exec(t))&&(n=gl.exec(e));)(i=n.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:bn(r,n)})),a=gl.lastIndex;return an;++n)s[(r=l[n]).i]=r.x(t);return s.join("")})}function _n(t,e){for(var r,n=co.interpolators.length;--n>=0&&!(r=co.interpolators[n](t,e)););return r}function wn(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;s>r;++r)n.push(_n(t[r],e[r]));for(;a>r;++r)i[r]=t[r];for(;o>r;++r)i[r]=e[r];return function(t){for(r=0;s>r;++r)i[r]=n[r](t);return i}}function kn(t){return function(e){return 0>=e?0:e>=1?1:t(e)}}function An(t){return function(e){return 1-t(1-e)}}function Mn(t){return function(e){return.5*(.5>e?t(2*e):2-t(2-2*e))}}function Tn(t){return t*t}function En(t){return t*t*t}function Ln(t){if(0>=t)return 0;if(t>=1)return 1;var e=t*t,r=e*t;return 4*(.5>t?r:3*(t-e)+r-.75)}function Sn(t){return function(e){return Math.pow(e,t)}}function Cn(t){return 1-Math.cos(t*Ho)}function zn(t){return Math.pow(2,10*(t-1))}function Pn(t){return 1-Math.sqrt(1-t*t)}function Rn(t,e){var r;return arguments.length<2&&(e=.45),arguments.length?r=e/Vo*Math.asin(1/t):(t=1,r=e/4),function(n){return 1+t*Math.pow(2,-10*n)*Math.sin((n-r)*Vo/e)}}function On(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function In(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Nn(t,e){t=co.hcl(t),e=co.hcl(e);var r=t.h,n=t.c,i=t.l,a=e.h-r,o=e.c-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.c:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ht(r+a*t,n+o*t,i+s*t)+""}}function jn(t,e){t=co.hsl(t),e=co.hsl(e);var r=t.h,n=t.s,i=t.l,a=e.h-r,o=e.s-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.s:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ut(r+a*t,n+o*t,i+s*t)+""}}function Fn(t,e){t=co.lab(t),e=co.lab(e);var r=t.l,n=t.a,i=t.b,a=e.l-r,o=e.a-n,s=e.b-i;return function(t){return pt(r+a*t,n+o*t,i+s*t)+""}}function Dn(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function Bn(t){var e=[t.a,t.b],r=[t.c,t.d],n=Vn(e),i=Un(e,r),a=Vn(qn(r,e,-i))||0;e[0]*r[1]180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(Hn(r)+"rotate(",null,")")-2,x:bn(t,e)})):e&&r.push(Hn(r)+"rotate("+e+")")}function Xn(t,e,r,n){t!==e?n.push({i:r.push(Hn(r)+"skewX(",null,")")-2,x:bn(t,e)}):e&&r.push(Hn(r)+"skewX("+e+")")}function Wn(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(Hn(r)+"scale(",null,",",null,")");n.push({i:i-4,x:bn(t[0],e[0])},{i:i-2,x:bn(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(Hn(r)+"scale("+e+")")}function Zn(t,e){var r=[],n=[];return t=co.transform(t),e=co.transform(e),Gn(t.translate,e.translate,r,n),Yn(t.rotate,e.rotate,r,n),Xn(t.skew,e.skew,r,n),Wn(t.scale,e.scale,r,n),t=e=null,function(t){for(var e,i=-1,a=n.length;++i=0;)r.push(i[n])}function li(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++or;++r)(e=t[r][1])>i&&(n=r,i=e);return n}function bi(t){return t.reduce(xi,0)}function xi(t,e){return t+e[1]}function _i(t,e){return wi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wi(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function ki(t){return[co.min(t),co.max(t)]}function Ai(t,e){return t.value-e.value}function Mi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ti(t,e){t._pack_next=e,e._pack_prev=t}function Ei(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function Li(t){function e(t){u=Math.min(t.x-t.r,u),f=Math.max(t.x+t.r,f),h=Math.min(t.y-t.r,h),d=Math.max(t.y+t.r,d)}if((r=t.children)&&(c=r.length)){var r,n,i,a,o,s,l,c,u=1/0,f=-(1/0),h=1/0,d=-(1/0);if(r.forEach(Si),n=r[0],n.x=-n.r,n.y=0,e(n),c>1&&(i=r[1],i.x=i.r,i.y=0,e(i),c>2))for(a=r[2],Pi(n,i,a),e(a),Mi(n,a),n._pack_prev=a,Mi(a,i),i=n._pack_next,o=3;c>o;o++){Pi(n,i,a=r[o]);var p=0,g=1,v=1;for(s=i._pack_next;s!==i;s=s._pack_next,g++)if(Ei(s,a)){p=1;break}if(1==p)for(l=n._pack_prev;l!==s._pack_prev&&!Ei(l,a);l=l._pack_prev,v++);p?(v>g||g==v&&i.ro;o++)a=r[o],a.x-=m,a.y-=y,b=Math.max(b,a.r+Math.sqrt(a.x*a.x+a.y*a.y));t.r=b,r.forEach(Ci)}}function Si(t){t._pack_next=t._pack_prev=t}function Ci(t){delete t._pack_next,delete t._pack_prev}function zi(t,e,r,n){var i=t.children;if(t.x=e+=n*t.x,t.y=r+=n*t.y,t.r*=n,i)for(var a=-1,o=i.length;++a=0;)e=i[a],e.z+=r,e.m+=r,r+=e.s+(n+=e.c)}function Fi(t,e,r){return t.a.parent===e.parent?t.a:r}function Di(t){return 1+co.max(t,function(t){return t.y})}function Bi(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ui(t){var e=t.children;return e&&e.length?Ui(e[0]):t}function Vi(t){var e,r=t.children;return r&&(e=r.length)?Vi(r[e-1]):t}function qi(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Hi(t,e){var r=t.x+e[3],n=t.y+e[0],i=t.dx-e[1]-e[3],a=t.dy-e[0]-e[2];return 0>i&&(r+=i/2,i=0),0>a&&(n+=a/2,a=0),{x:r,y:n,dx:i,dy:a}}function Gi(t){var e=t[0],r=t[t.length-1];return r>e?[e,r]:[r,e]}function Yi(t){return t.rangeExtent?t.rangeExtent():Gi(t.range())}function Xi(t,e,r,n){var i=r(t[0],t[1]),a=n(e[0],e[1]);return function(t){return a(i(t))}}function Wi(t,e){var r,n=0,i=t.length-1,a=t[n],o=t[i];return a>o&&(r=n,n=i,i=r,r=a,a=o,o=r),t[n]=e.floor(a),t[i]=e.ceil(o),t}function Zi(t){return t?{floor:function(e){return Math.floor(e/t)*t},ceil:function(e){return Math.ceil(e/t)*t}}:Tl}function Ki(t,e,r,n){var i=[],a=[],o=0,s=Math.min(t.length,e.length)-1;for(t[s]2?Ki:Xi,l=n?$n:Kn;return o=i(t,e,l,r),s=i(e,t,l,_n),a}function a(t){return o(t)}var o,s;return a.invert=function(t){return s(t)},a.domain=function(e){return arguments.length?(t=e.map(Number),i()):t},a.range=function(t){return arguments.length?(e=t,i()):e},a.rangeRound=function(t){return a.range(t).interpolate(Dn)},a.clamp=function(t){return arguments.length?(n=t,i()):n},a.interpolate=function(t){return arguments.length?(r=t,i()):r},a.ticks=function(e){return ea(t,e)},a.tickFormat=function(e,r){return ra(t,e,r)},a.nice=function(e){return Ji(t,e),i()},a.copy=function(){return $i(t,e,r,n)},i()}function Qi(t,e){return co.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ji(t,e){return Wi(t,Zi(ta(t,e)[2])),Wi(t,Zi(ta(t,e)[2])),t}function ta(t,e){null==e&&(e=10);var r=Gi(t),n=r[1]-r[0],i=Math.pow(10,Math.floor(Math.log(n/e)/Math.LN10)),a=e/n*i;return.15>=a?i*=10:.35>=a?i*=5:.75>=a&&(i*=2),r[0]=Math.ceil(r[0]/i)*i,r[1]=Math.floor(r[1]/i)*i+.5*i,r[2]=i,r}function ea(t,e){return co.range.apply(co,ta(t,e))}function ra(t,e,r){var n=ta(t,e);if(r){var i=ps.exec(r);if(i.shift(),"s"===i[8]){var a=co.formatPrefix(Math.max(wo(n[0]),wo(n[1])));return i[7]||(i[7]="."+na(a.scale(n[2]))),i[8]="f",r=co.format(i.join("")),function(t){return r(a.scale(t))+a.symbol}}i[7]||(i[7]="."+ia(i[8],n)),r=i.join("")}else r=",."+na(n[2])+"f";return co.format(r)}function na(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ia(t,e){var r=na(e[2]);return t in El?Math.abs(r-na(Math.max(wo(e[0]),wo(e[1]))))+ +("e"!==t):r-2*("%"===t)}function aa(t,e,r,n){function i(t){return(r?Math.log(0>t?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function a(t){return r?Math.pow(e,t):-Math.pow(e,-t)}function o(e){return t(i(e))}return o.invert=function(e){return a(t.invert(e))},o.domain=function(e){return arguments.length?(r=e[0]>=0,t.domain((n=e.map(Number)).map(i)),o):n},o.base=function(r){return arguments.length?(e=+r,t.domain(n.map(i)),o):e},o.nice=function(){var e=Wi(n.map(i),r?Math:Sl);return t.domain(e),n=e.map(a),o},o.ticks=function(){var t=Gi(n),o=[],s=t[0],l=t[1],c=Math.floor(i(s)),u=Math.ceil(i(l)),f=e%1?2:e;if(isFinite(u-c)){if(r){for(;u>c;c++)for(var h=1;f>h;h++)o.push(a(c)*h);o.push(a(c))}else for(o.push(a(c));c++0;h--)o.push(a(c)*h);for(c=0;o[c]l;u--);o=o.slice(c,u)}return o},o.tickFormat=function(t,r){if(!arguments.length)return Ll;arguments.length<2?r=Ll:"function"!=typeof r&&(r=co.format(r));var n=Math.max(1,e*t/o.ticks().length);return function(t){var o=t/a(Math.round(i(t)));return e-.5>o*e&&(o*=e),n>=o?r(t):""}},o.copy=function(){return aa(t.copy(),e,r,n)},Qi(o,t)}function oa(t,e,r){function n(e){return t(i(e))}var i=sa(e),a=sa(1/e);return n.invert=function(e){return a(t.invert(e))},n.domain=function(e){return arguments.length?(t.domain((r=e.map(Number)).map(i)),n):r},n.ticks=function(t){return ea(r,t)},n.tickFormat=function(t,e){return ra(r,t,e)},n.nice=function(t){return n.domain(Ji(r,t))},n.exponent=function(o){return arguments.length?(i=sa(e=o),a=sa(1/e),t.domain(r.map(i)),n):e},n.copy=function(){return oa(t.copy(),e,r)},Qi(n,t)}function sa(t){return function(e){return 0>e?-Math.pow(-e,t):Math.pow(e,t)}}function la(t,e){function r(r){return a[((i.get(r)||("range"===e.t?i.set(r,t.push(r)):NaN))-1)%a.length]}function n(e,r){return co.range(t.length).map(function(t){return e+r*t})}var i,a,o;return r.domain=function(n){if(!arguments.length)return t;t=[],i=new f;for(var a,o=-1,s=n.length;++or?[NaN,NaN]:[r>0?s[r-1]:t[0],re?NaN:e/a+t,[e,e+1/a]},n.copy=function(){return ua(t,e,r)},i()}function fa(t,e){function r(r){return r>=r?e[co.bisect(t,r)]:void 0}return r.domain=function(e){return arguments.length?(t=e,r):t},r.range=function(t){return arguments.length?(e=t,r):e},r.invertExtent=function(r){return r=e.indexOf(r),[t[r-1],t[r]]},r.copy=function(){return fa(t,e)},r}function ha(t){function e(t){return+t}return e.invert=e,e.domain=e.range=function(r){return arguments.length?(t=r.map(e),e):t},e.ticks=function(e){return ea(t,e)},e.tickFormat=function(e,r){return ra(t,e,r)},e.copy=function(){return ha(t)},e}function da(){return 0}function pa(t){return t.innerRadius}function ga(t){return t.outerRadius}function va(t){return t.startAngle}function ma(t){return t.endAngle}function ya(t){return t&&t.padAngle}function ba(t,e,r,n){return(t-r)*e-(e-n)*t>0?0:1}function xa(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,c=-s*a,u=t[0]+l,f=t[1]+c,h=e[0]+l,d=e[1]+c,p=(u+h)/2,g=(f+d)/2,v=h-u,m=d-f,y=v*v+m*m,b=r-n,x=u*d-h*f,_=(0>m?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*m-v*_)/y,k=(-x*v-m*_)/y,A=(x*m+v*_)/y,M=(-x*v+m*_)/y,T=w-p,E=k-g,L=A-p,S=M-g;return T*T+E*E>L*L+S*S&&(w=A,k=M),[[w-l,k-c],[w*r/b,k*r/b]]}function _a(t){function e(e){function o(){c.push("M",a(t(u),s))}for(var l,c=[],u=[],f=-1,h=e.length,d=Lt(r),p=Lt(n);++f1?t.join("L"):t+"Z"}function ka(t){return t.join("L")+"Z"}function Aa(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1&&i.push("H",n[0]),i.join("")}function Ma(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var c=2;c9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));for(s=-1;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}function Ua(t){return t.length<3?wa(t):t[0]+Ca(t,Ba(t))}function Va(t){for(var e,r,n,i=-1,a=t.length;++i=e?o(t-e):void(c.c=o)}function o(r){var i=p.active,a=p[i];a&&(a.timer.c=null,a.timer.t=NaN,--p.count,delete p[i],a.event&&a.event.interrupt.call(t,t.__data__,a.index));for(var o in p)if(n>+o){var f=p[o];f.timer.c=null,f.timer.t=NaN,--p.count,delete p[o]}c.c=s,Rt(function(){return c.c&&s(r||1)&&(c.c=null,c.t=NaN),1},0,l),p.active=n,g.event&&g.event.start.call(t,t.__data__,e),d=[],g.tween.forEach(function(r,n){(n=n.call(t,t.__data__,e))&&d.push(n)}),h=g.ease,u=g.duration}function s(i){for(var a=i/u,o=h(a),s=d.length;s>0;)d[--s].call(t,o);return a>=1?(g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[n]:delete t[r],1):void 0}var l,c,u,h,d,p=t[r]||(t[r]={active:0,count:0}),g=p[n];g||(l=i.time,c=Rt(a,0,l),g=p[n]={tween:new f,time:l,timer:c,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++p.count)}function ro(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate("+(isFinite(n)?n:r(t))+",0)"})}function no(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate(0,"+(isFinite(n)?n:r(t))+")"})}function io(t){return t.toISOString()}function ao(t,e,r){function n(e){return t(e)}function i(t,r){var n=t[1]-t[0],i=n/r,a=co.bisect(tc,i);return a==tc.length?[e.year,ta(t.map(function(t){return t/31536e6}),r)[2]]:a?e[i/tc[a-1]1?{floor:function(e){for(;r(e=t.floor(e));)e=oo(e-1);return e},ceil:function(e){for(;r(e=t.ceil(e));)e=oo(+e+1);return e}}:t))},n.ticks=function(t,e){var r=Gi(n.domain()),a=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return a&&(t=a[0],e=a[1]),t.range(r[0],oo(+r[1]+1),1>e?1:e)},n.tickFormat=function(){return r},n.copy=function(){return ao(t.copy(),e,r)},Qi(n,t)}function oo(t){return new Date(t)}function so(t){return JSON.parse(t.responseText)}function lo(t){var e=ho.createRange();return e.selectNode(ho.body),e.createContextualFragment(t.responseText)}var co={version:"3.5.16"},uo=[].slice,fo=function(t){return uo.call(t)},ho=this.document;if(ho)try{fo(ho.documentElement.childNodes)[0].nodeType}catch(po){fo=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),ho)try{ho.createElement("DIV").style.setProperty("opacity",0,"")}catch(go){var vo=this.Element.prototype,mo=vo.setAttribute,yo=vo.setAttributeNS,bo=this.CSSStyleDeclaration.prototype,xo=bo.setProperty;vo.setAttribute=function(t,e){mo.call(this,t,e+"")},vo.setAttributeNS=function(t,e,r){yo.call(this,t,e,r+"")},bo.setProperty=function(t,e,r){xo.call(this,t,e+"",r)}}co.ascending=i,co.descending=function(t,e){return t>e?-1:e>t?1:e>=t?0:NaN},co.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},co.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},co.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}else{for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}return[r,i]},co.sum=function(t,e){var r,n=0,i=t.length,a=-1;if(1===arguments.length)for(;++a1?l/(u-1):void 0},co.deviation=function(){var t=co.variance.apply(this,arguments);return t?Math.sqrt(t):t};var _o=s(i);co.bisectLeft=_o.left,co.bisect=co.bisectRight=_o.right,co.bisector=function(t){return s(1===t.length?function(e,r){return i(t(e),r)}:t)},co.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,2>a&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},co.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},co.pairs=function(t){for(var e,r=0,n=t.length-1,i=t[0],a=new Array(0>n?0:n);n>r;)a[r]=[e=i,i=t[++r]];return a},co.transpose=function(t){if(!(i=t.length))return[];for(var e=-1,r=co.min(t,l),n=new Array(r);++e=0;)for(n=t[i],e=n.length;--e>=0;)r[--o]=n[e];return r};var wo=Math.abs;co.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r===1/0)throw new Error("infinite range");var n,i=[],a=c(wo(r)),o=-1;if(t*=a,e*=a,r*=a,0>r)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=a.length)return n?n.call(i,o):r?o.sort(r):o;for(var l,c,u,h,d=-1,p=o.length,g=a[s++],v=new f;++d=a.length)return t;var n=[],i=o[r++];return t.forEach(function(t,i){n.push({key:t,values:e(i,r)})}),i?n.sort(function(t,e){return i(t.key,e.key)}):n}var r,n,i={},a=[],o=[];return i.map=function(e,r){return t(r,e,0)},i.entries=function(r){return e(t(co.map,r,0),0)},i.key=function(t){return a.push(t),i},i.sortKeys=function(t){return o[a.length-1]=t,i},i.sortValues=function(t){return r=t,i},i.rollup=function(t){return n=t,i},i},co.set=function(t){var e=new b;if(t)for(var r=0,n=t.length;n>r;++r)e.add(t[r]);return e},u(b,{has:p,add:function(t){return this._[h(t+="")]=!0,t},remove:g,values:v,size:m,empty:y,forEach:function(t){for(var e in this._)t.call(this,d(e))}}),co.behavior={},co.rebind=function(t,e){for(var r,n=1,i=arguments.length;++n=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},co.event=null,co.requote=function(t){return t.replace(To,"\\$&")};var To=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Eo={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]},Lo=function(t,e){return e.querySelector(t)},So=function(t,e){return e.querySelectorAll(t)},Co=function(t,e){var r=t.matches||t[w(t,"matchesSelector")];return(Co=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(Lo=function(t,e){return Sizzle(t,e)[0]||null},So=Sizzle,Co=Sizzle.matchesSelector),co.selection=function(){return co.select(ho.documentElement)};var zo=co.selection.prototype=[];zo.select=function(t){var e,r,n,i,a=[];t=C(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Ro.hasOwnProperty(r)?{space:Ro[r],local:t}:t}},zo.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node();return t=co.ns.qualify(t),t.local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}for(e in t)this.each(P(e,t[e]));return this}return this.each(P(t,e))},zo.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=I(t)).length,i=-1;if(e=r.classList){for(;++ii){if("string"!=typeof t){2>i&&(e="");for(r in t)this.each(F(r,t[r],e));return this}if(2>i){var a=this.node();return n(a).getComputedStyle(a,null).getPropertyValue(t)}r=""}return this.each(F(t,e,r))},zo.property=function(t,e){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(e in t)this.each(D(e,t[e]));return this}return this.each(D(t,e))},zo.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},zo.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},zo.append=function(t){return t=B(t),this.select(function(){return this.appendChild(t.apply(this,arguments))})},zo.insert=function(t,e){return t=B(t),e=C(e),this.select(function(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)})},zo.remove=function(){return this.each(U)},zo.data=function(t,e){function r(t,r){var n,i,a,o=t.length,u=r.length,h=Math.min(o,u),d=new Array(u),p=new Array(u),g=new Array(o);if(e){var v,m=new f,y=new Array(o);for(n=-1;++nn;++n)p[n]=V(r[n]);for(;o>n;++n)g[n]=t[n]}p.update=d,p.parentNode=d.parentNode=g.parentNode=t.parentNode,s.push(p),l.push(d),c.push(g)}var n,i,a=-1,o=this.length;if(!arguments.length){for(t=new Array(o=(n=this[0]).length);++aa;a++){i.push(e=[]),e.parentNode=(r=this[a]).parentNode;for(var s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return S(i)},zo.order=function(){for(var t=-1,e=this.length;++t=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},zo.sort=function(t){t=H.apply(this,arguments);for(var e=-1,r=this.length;++et;t++)for(var r=this[t],n=0,i=r.length;i>n;n++){var a=r[n];if(a)return a}return null},zo.size=function(){var t=0;return G(this,function(){++t}),t};var Oo=[];co.selection.enter=Y,co.selection.enter.prototype=Oo,Oo.append=zo.append,Oo.empty=zo.empty,Oo.node=zo.node,Oo.call=zo.call,Oo.size=zo.size,Oo.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++sn){if("string"!=typeof t){2>n&&(e=!1);for(r in t)this.each(W(r,t[r],e));return this}if(2>n)return(n=this.node()["__on"+t])&&n._;r=!1}return this.each(W(t,e,r))};var Io=co.map({mouseenter:"mouseover",mouseleave:"mouseout"});ho&&Io.forEach(function(t){"on"+t in ho&&Io.remove(t)});var No,jo=0;co.mouse=function(t){return Q(t,E())};var Fo=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;co.touch=function(t,e,r){if(arguments.length<3&&(r=e,e=E().changedTouches),e)for(var n,i=0,a=e.length;a>i;++i)if((n=e[i]).identifier===r)return Q(t,n)},co.behavior.drag=function(){function t(){this.on("mousedown.drag",a).on("touchstart.drag",o)}function e(t,e,n,a,o){return function(){function s(){var t,r,n=e(h,g);n&&(t=n[0]-b[0],r=n[1]-b[1],p|=t|r,b=n,d({type:"drag",x:n[0]+c[0],y:n[1]+c[1],dx:t,dy:r}))}function l(){e(h,g)&&(m.on(a+v,null).on(o+v,null),y(p),d({type:"dragend"}))}var c,u=this,f=co.event.target.correspondingElement||co.event.target,h=u.parentNode,d=r.of(u,arguments),p=0,g=t(),v=".drag"+(null==g?"":"-"+g),m=co.select(n(f)).on(a+v,s).on(o+v,l),y=$(f),b=e(h,g);i?(c=i.apply(u,arguments),c=[c.x-b[0],c.y-b[1]]):c=[0,0],d({type:"dragstart"})}}var r=L(t,"drag","dragstart","dragend"),i=null,a=e(k,co.mouse,n,"mousemove","mouseup"),o=e(J,co.touch,x,"touchmove","touchend");return t.origin=function(e){return arguments.length?(i=e,t):i},co.rebind(t,r,"on")},co.touches=function(t,e){return arguments.length<2&&(e=E().touches),e?fo(e).map(function(e){var r=Q(t,e);return r.identifier=e.identifier,r}):[]};var Do=1e-6,Bo=Do*Do,Uo=Math.PI,Vo=2*Uo,qo=Vo-Do,Ho=Uo/2,Go=Uo/180,Yo=180/Uo,Xo=Math.SQRT2,Wo=2,Zo=4;co.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],c=e[2],u=s-i,f=l-a,h=u*u+f*f;if(Bo>h)n=Math.log(c/o)/Xo,r=function(t){return[i+t*u,a+t*f,o*Math.exp(Xo*t*n)]};else{var d=Math.sqrt(h),p=(c*c-o*o+Zo*h)/(2*o*Wo*d),g=(c*c-o*o-Zo*h)/(2*c*Wo*d),v=Math.log(Math.sqrt(p*p+1)-p),m=Math.log(Math.sqrt(g*g+1)-g);n=(m-v)/Xo,r=function(t){var e=t*n,r=at(v),s=o/(Wo*d)*(r*ot(Xo*e+v)-it(v));return[i+s*u,a+s*f,o*r/at(Xo*e+v)]}}return r.duration=1e3*n,r},co.behavior.zoom=function(){function t(t){t.on(z,f).on($o+".zoom",d).on("dblclick.zoom",p).on(O,h)}function e(t){return[(t[0]-A.x)/A.k,(t[1]-A.y)/A.k]}function r(t){return[t[0]*A.k+A.x,t[1]*A.k+A.y]}function i(t){A.k=Math.max(E[0],Math.min(E[1],t))}function a(t,e){e=r(e),A.x+=t[0]-e[0],A.y+=t[1]-e[1]}function o(e,r,n,o){e.__chart__={x:A.x,y:A.y,k:A.k},i(Math.pow(2,o)),a(v=r,n),e=co.select(e),S>0&&(e=e.transition().duration(S)),e.call(t.event)}function s(){_&&_.domain(x.range().map(function(t){return(t-A.x)/A.k}).map(x.invert)),k&&k.domain(w.range().map(function(t){return(t-A.y)/A.k}).map(w.invert))}function l(t){C++||t({type:"zoomstart"})}function c(t){s(),t({type:"zoom",scale:A.k,translate:[A.x,A.y]})}function u(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){s=1,a(co.mouse(i),h),c(o)}function r(){f.on(P,null).on(R,null),d(s),u(o)}var i=this,o=I.of(i,arguments),s=0,f=co.select(n(i)).on(P,t).on(R,r),h=e(co.mouse(i)),d=$(i);Hl.call(i),l(o)}function h(){function t(){var t=co.touches(p);return d=A.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function r(){var e=co.event.target;co.select(e).on(x,n).on(_,s),w.push(e);for(var r=co.event.changedTouches,i=0,a=r.length;a>i;++i)v[r[i].identifier]=null;var l=t(),c=Date.now();if(1===l.length){if(500>c-b){var u=l[0];o(p,u,v[u.identifier],Math.floor(Math.log(A.k)/Math.LN2)+1),T()}b=c}else if(l.length>1){var u=l[0],f=l[1],h=u[0]-f[0],d=u[1]-f[1];m=h*h+d*d}}function n(){var t,e,r,n,o=co.touches(p);Hl.call(p);for(var s=0,l=o.length;l>s;++s,n=null)if(r=o[s],n=v[r.identifier]){if(e)break;t=r,e=n}if(n){var u=(u=r[0]-t[0])*u+(u=r[1]-t[1])*u,f=m&&Math.sqrt(u/m);t=[(t[0]+r[0])/2,(t[1]+r[1])/2],e=[(e[0]+n[0])/2,(e[1]+n[1])/2],i(f*d)}b=null,a(t,e),c(g)}function s(){if(co.event.touches.length){for(var e=co.event.changedTouches,r=0,n=e.length;n>r;++r)delete v[e[r].identifier];for(var i in v)return void t()}co.selectAll(w).on(y,null),k.on(z,f).on(O,h),M(),u(g)}var d,p=this,g=I.of(p,arguments),v={},m=0,y=".zoom-"+co.event.changedTouches[0].identifier,x="touchmove"+y,_="touchend"+y,w=[],k=co.select(p),M=$(p);r(),l(g),k.on(z,null).on(O,r)}function d(){var t=I.of(this,arguments);y?clearTimeout(y):(Hl.call(this),g=e(v=m||co.mouse(this)),l(t)),y=setTimeout(function(){y=null,u(t)},50),T(),i(Math.pow(2,.002*Ko())*A.k),a(v,g),c(t)}function p(){var t=co.mouse(this),r=Math.log(A.k)/Math.LN2;o(this,t,e(t),co.event.shiftKey?Math.ceil(r)-1:Math.floor(r)+1)}var g,v,m,y,b,x,_,w,k,A={x:0,y:0,k:1},M=[960,500],E=Qo,S=250,C=0,z="mousedown.zoom",P="mousemove.zoom",R="mouseup.zoom",O="touchstart.zoom",I=L(t,"zoomstart","zoom","zoomend");return $o||($o="onwheel"in ho?(Ko=function(){return-co.event.deltaY*(co.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ho?(Ko=function(){return co.event.wheelDelta},"mousewheel"):(Ko=function(){return-co.event.detail},"MozMousePixelScroll")),t.event=function(t){t.each(function(){var t=I.of(this,arguments),e=A;Vl?co.select(this).transition().each("start.zoom",function(){A=this.__chart__||{x:0,y:0,k:1},l(t)}).tween("zoom:zoom",function(){var r=M[0],n=M[1],i=v?v[0]:r/2,a=v?v[1]:n/2,o=co.interpolateZoom([(i-A.x)/A.k,(a-A.y)/A.k,r/A.k],[(i-e.x)/e.k,(a-e.y)/e.k,r/e.k]);return function(e){var n=o(e),s=r/n[2];this.__chart__=A={x:i-n[0]*s,y:a-n[1]*s,k:s},c(t)}}).each("interrupt.zoom",function(){u(t)}).each("end.zoom",function(){u(t)}):(this.__chart__=A,l(t),c(t),u(t))})},t.translate=function(e){return arguments.length?(A={x:+e[0],y:+e[1],k:A.k},s(),t):[A.x,A.y]},t.scale=function(e){return arguments.length?(A={x:A.x,y:A.y,k:null},i(+e),s(),t):A.k},t.scaleExtent=function(e){return arguments.length?(E=null==e?Qo:[+e[0],+e[1]],t):E},t.center=function(e){return arguments.length?(m=e&&[+e[0],+e[1]],t):m},t.size=function(e){return arguments.length?(M=e&&[+e[0],+e[1]],t):M},t.duration=function(e){return arguments.length?(S=+e,t):S},t.x=function(e){return arguments.length?(_=e,x=e.copy(),A={x:0,y:0,k:1},t):_},t.y=function(e){return arguments.length?(k=e,w=e.copy(),A={x:0,y:0,k:1},t):k},co.rebind(t,I,"on")};var Ko,$o,Qo=[0,1/0];co.color=lt,lt.prototype.toString=function(){return this.rgb()+""},co.hsl=ct;var Jo=ct.prototype=new lt;Jo.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,this.l/t)},Jo.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,t*this.l)},Jo.rgb=function(){return ut(this.h,this.s,this.l)},co.hcl=ft;var ts=ft.prototype=new lt;ts.brighter=function(t){return new ft(this.h,this.c,Math.min(100,this.l+es*(arguments.length?t:1)))},ts.darker=function(t){return new ft(this.h,this.c,Math.max(0,this.l-es*(arguments.length?t:1)))},ts.rgb=function(){return ht(this.h,this.c,this.l).rgb()},co.lab=dt;var es=18,rs=.95047,ns=1,is=1.08883,as=dt.prototype=new lt;as.brighter=function(t){return new dt(Math.min(100,this.l+es*(arguments.length?t:1)),this.a,this.b)},as.darker=function(t){return new dt(Math.max(0,this.l-es*(arguments.length?t:1)),this.a,this.b)},as.rgb=function(){return pt(this.l,this.a,this.b)},co.rgb=bt;var os=bt.prototype=new lt;os.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&i>e&&(e=i),r&&i>r&&(r=i),n&&i>n&&(n=i),new bt(Math.min(255,e/t),Math.min(255,r/t),Math.min(255,n/t))):new bt(i,i,i)},os.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new bt(t*this.r,t*this.g,t*this.b)},os.hsl=function(){return At(this.r,this.g,this.b)},os.toString=function(){return"#"+wt(this.r)+wt(this.g)+wt(this.b)};var ss=co.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ss.forEach(function(t,e){ss.set(t,xt(e))}),co.functor=Lt,co.xhr=St(x),co.dsv=function(t,e){function r(t,r,a){arguments.length<3&&(a=r,r=null);var o=Ct(t,e,null==r?n:i(r),a);return o.row=function(t){return arguments.length?o.response(null==(r=t)?n:i(t)):r},o}function n(t){return r.parse(t.responseText)}function i(t){return function(e){return r.parse(e.responseText,t)}}function a(e){return e.map(o).join(t)}function o(t){return s.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var s=new RegExp('["'+t+"\n]"),l=t.charCodeAt(0);return r.parse=function(t,e){var n;return r.parseRows(t,function(t,r){if(n)return n(t,r-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");n=e?function(t,r){return e(i(t),r)}:i})},r.parseRows=function(t,e){function r(){if(u>=c)return o;if(i)return i=!1,a;var e=u;if(34===t.charCodeAt(e)){for(var r=e;r++u;){var n=t.charCodeAt(u++),s=1;if(10===n)i=!0;else if(13===n)i=!0,10===t.charCodeAt(u)&&(++u,++s);else if(n!==l)continue;return t.slice(e,u-s)}return t.slice(e)}for(var n,i,a={},o={},s=[],c=t.length,u=0,f=0;(n=r())!==o;){for(var h=[];n!==a&&n!==o;)h.push(n),n=r();e&&null==(h=e(h,f++))||s.push(h)}return s},r.format=function(e){if(Array.isArray(e[0]))return r.formatRows(e);var n=new b,i=[];return e.forEach(function(t){for(var e in t)n.has(e)||i.push(n.add(e))}),[i.map(o).join(t)].concat(e.map(function(e){return i.map(function(t){return o(e[t])}).join(t)})).join("\n")},r.formatRows=function(t){return t.map(a).join("\n")},r},co.csv=co.dsv(",","text/csv"),co.tsv=co.dsv(" ","text/tab-separated-values");var ls,cs,us,fs,hs=this[w(this,"requestAnimationFrame")]||function(t){setTimeout(t,17)};co.timer=function(){Rt.apply(this,arguments)},co.timer.flush=function(){It(),Nt()},co.round=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)};var ds=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Ft);co.formatPrefix=function(t,e){var r=0;return(t=+t)&&(0>t&&(t*=-1),e&&(t=co.round(t,jt(t,e))),r=1+Math.floor(1e-12+Math.log(t)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),ds[8+r/3]};var ps=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,gs=co.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=co.round(t,jt(t,e))).toFixed(Math.max(0,Math.min(20,jt(t*(1+1e-15),e))))}}),vs=co.time={},ms=Date;Ut.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ys.setUTCDate.apply(this._,arguments)},setDay:function(){ys.setUTCDay.apply(this._,arguments)},setFullYear:function(){ys.setUTCFullYear.apply(this._,arguments)},setHours:function(){ys.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ys.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ys.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ys.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ys.setUTCSeconds.apply(this._,arguments)},setTime:function(){ys.setTime.apply(this._,arguments)}};var ys=Date.prototype;vs.year=Vt(function(t){return t=vs.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),vs.years=vs.year.range,vs.years.utc=vs.year.utc.range,vs.day=Vt(function(t){var e=new ms(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),vs.days=vs.day.range,vs.days.utc=vs.day.utc.range,vs.dayOfYear=function(t){var e=vs.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var r=vs[t]=Vt(function(t){return(t=vs.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){ +t.setDate(t.getDate()+7*Math.floor(e))},function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)-(r!==e)});vs[t+"s"]=r.range,vs[t+"s"].utc=r.utc.range,vs[t+"OfYear"]=function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)}}),vs.week=vs.sunday,vs.weeks=vs.sunday.range,vs.weeks.utc=vs.sunday.utc.range,vs.weekOfYear=vs.sundayOfYear;var bs={"-":"",_:" ",0:"0"},xs=/^\s*\d+/,_s=/^%/;co.locale=function(t){return{numberFormat:Dt(t),timeFormat:Ht(t)}};var ws=co.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});co.format=ws.numberFormat,co.geo={},fe.prototype={s:0,t:0,add:function(t){he(t,this.t,ks),he(ks.s,this.s,this),this.s?this.t+=ks.t:this.s=ks.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ks=new fe;co.geo.stream=function(t,e){t&&As.hasOwnProperty(t.type)?As[t.type](t,e):de(t,e)};var As={Feature:function(t,e){de(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++nt?4*Uo+t:t,Ls.lineStart=Ls.lineEnd=Ls.point=k}};co.geo.bounds=function(){function t(t,e){b.push(x=[u=t,h=t]),f>e&&(f=e),e>d&&(d=e)}function e(e,r){var n=me([e*Go,r*Go]);if(m){var i=be(m,n),a=[i[1],-i[0],0],o=be(a,i);we(o),o=ke(o);var l=e-p,c=l>0?1:-1,g=o[0]*Yo*c,v=wo(l)>180;if(v^(g>c*p&&c*e>g)){var y=o[1]*Yo;y>d&&(d=y)}else if(g=(g+360)%360-180,v^(g>c*p&&c*e>g)){var y=-o[1]*Yo;f>y&&(f=y)}else f>r&&(f=r),r>d&&(d=r);v?p>e?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e):h>=u?(u>e&&(u=e),e>h&&(h=e)):e>p?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e)}else t(e,r);m=n,p=e}function r(){_.point=e}function n(){x[0]=u,x[1]=h,_.point=t,m=null}function i(t,r){if(m){var n=t-p;y+=wo(n)>180?n+(n>0?360:-360):n}else g=t,v=r;Ls.point(t,r),e(t,r)}function a(){Ls.lineStart()}function o(){i(g,v),Ls.lineEnd(),wo(y)>Do&&(u=-(h=180)),x[0]=u,x[1]=h,m=null}function s(t,e){return(e-=t)<0?e+360:e}function l(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tEs?(u=-(h=180),f=-(d=90)):y>Do?d=90:-Do>y&&(f=-90),x[0]=u,x[1]=h}};return function(t){d=h=-(u=f=1/0),b=[],co.geo.stream(t,_);var e=b.length;if(e){b.sort(l);for(var r,n=1,i=b[0],a=[i];e>n;++n)r=b[n],c(r[0],i)||c(r[1],i)?(s(i[0],r[1])>s(i[0],i[1])&&(i[1]=r[1]),s(r[0],i[1])>s(i[0],i[1])&&(i[0]=r[0])):a.push(i=r);for(var o,r,p=-(1/0),e=a.length-1,n=0,i=a[e];e>=n;i=r,++n)r=a[n],(o=s(i[1],r[0]))>p&&(p=o,u=r[0],h=i[1])}return b=x=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[h,d]]}}(),co.geo.centroid=function(t){Ss=Cs=zs=Ps=Rs=Os=Is=Ns=js=Fs=Ds=0,co.geo.stream(t,Bs);var e=js,r=Fs,n=Ds,i=e*e+r*r+n*n;return Bo>i&&(e=Os,r=Is,n=Ns,Do>Cs&&(e=zs,r=Ps,n=Rs),i=e*e+r*r+n*n,Bo>i)?[NaN,NaN]:[Math.atan2(r,e)*Yo,nt(n/Math.sqrt(i))*Yo]};var Ss,Cs,zs,Ps,Rs,Os,Is,Ns,js,Fs,Ds,Bs={sphere:k,point:Me,lineStart:Ee,lineEnd:Le,polygonStart:function(){Bs.lineStart=Se},polygonEnd:function(){Bs.lineStart=Ee}},Us=Ie(ze,De,Ue,[-Uo,-Uo/2]),Vs=1e9;co.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),i=a(t),i.valid=!0,i},extent:function(s){return arguments.length?(a=Ge(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(co.geo.conicEqualArea=function(){return Ye(Xe)}).raw=Xe,co.geo.albers=function(){return co.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},co.geo.albersUsa=function(){function t(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}var e,r,n,i,a=co.geo.albers(),o=co.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=co.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};return t.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&.234>i&&n>=-.425&&-.214>n?o:i>=.166&&.234>i&&n>=-.214&&-.115>n?s:a).invert(t)},t.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},t.precision=function(e){return arguments.length?(a.precision(e),o.precision(e),s.precision(e),t):a.precision()},t.scale=function(e){return arguments.length?(a.scale(e),o.scale(.35*e),s.scale(e),t.translate(a.translate())):a.scale()},t.translate=function(e){if(!arguments.length)return a.translate();var c=a.scale(),u=+e[0],f=+e[1];return r=a.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(l).point,n=o.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+Do,f+.12*c+Do],[u-.214*c-Do,f+.234*c-Do]]).stream(l).point,i=s.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+Do,f+.166*c+Do],[u-.115*c-Do,f+.234*c-Do]]).stream(l).point,t},t.scale(1070)};var qs,Hs,Gs,Ys,Xs,Ws,Zs={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Hs=0,Zs.lineStart=We},polygonEnd:function(){Zs.lineStart=Zs.lineEnd=Zs.point=k,qs+=wo(Hs/2)}},Ks={point:Ze,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},$s={point:Qe,lineStart:Je,lineEnd:tr,polygonStart:function(){$s.lineStart=er},polygonEnd:function(){$s.point=Qe,$s.lineStart=Je,$s.lineEnd=tr}};co.geo.path=function(){function t(t){return t&&("function"==typeof s&&a.pointRadius(+s.apply(this,arguments)),o&&o.valid||(o=i(a)),co.geo.stream(t,o)),a.result()}function e(){return o=null,t}var r,n,i,a,o,s=4.5;return t.area=function(t){return qs=0,co.geo.stream(t,i(Zs)),qs},t.centroid=function(t){return zs=Ps=Rs=Os=Is=Ns=js=Fs=Ds=0,co.geo.stream(t,i($s)),Ds?[js/Ds,Fs/Ds]:Ns?[Os/Ns,Is/Ns]:Rs?[zs/Rs,Ps/Rs]:[NaN,NaN]},t.bounds=function(t){return Xs=Ws=-(Gs=Ys=1/0),co.geo.stream(t,i(Ks)),[[Gs,Ys],[Xs,Ws]]},t.projection=function(t){return arguments.length?(i=(r=t)?t.stream||ir(t):x,e()):r},t.context=function(t){return arguments.length?(a=null==(n=t)?new Ke:new rr(t),"function"!=typeof s&&a.pointRadius(s),e()):n},t.pointRadius=function(e){return arguments.length?(s="function"==typeof e?e:(a.pointRadius(+e),+e),t):s},t.projection(co.geo.albersUsa()).context(null)},co.geo.transform=function(t){return{stream:function(e){var r=new ar(e);for(var n in t)r[n]=t[n];return r}}},ar.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},co.geo.projection=sr,co.geo.projectionMutator=lr,(co.geo.equirectangular=function(){return sr(ur)}).raw=ur.invert=ur,co.geo.rotation=function(t){function e(e){return e=t(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e}return t=hr(t[0]%360*Go,t[1]*Go,t.length>2?t[2]*Go:0),e.invert=function(e){return e=t.invert(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e},e},fr.invert=ur,co.geo.circle=function(){function t(){var t="function"==typeof n?n.apply(this,arguments):n,e=hr(-t[0]*Go,-t[1]*Go,0).invert,i=[];return r(null,null,1,{point:function(t,r){i.push(t=e(t,r)),t[0]*=Yo,t[1]*=Yo}}),{type:"Polygon",coordinates:[i]}}var e,r,n=[0,0],i=6;return t.origin=function(e){return arguments.length?(n=e,t):n},t.angle=function(n){return arguments.length?(r=vr((e=+n)*Go,i*Go),t):e},t.precision=function(n){return arguments.length?(r=vr(e*Go,(i=+n)*Go),t):i},t.angle(90)},co.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Go,i=t[1]*Go,a=e[1]*Go,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),c=Math.cos(i),u=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-l*f*s)*r),l*u+c*f*s)},co.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return co.range(Math.ceil(a/v)*v,i,v).map(h).concat(co.range(Math.ceil(c/m)*m,l,m).map(d)).concat(co.range(Math.ceil(n/p)*p,r,p).filter(function(t){return wo(t%v)>Do}).map(u)).concat(co.range(Math.ceil(s/g)*g,o,g).filter(function(t){return wo(t%m)>Do}).map(f))}var r,n,i,a,o,s,l,c,u,f,h,d,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[h(a).concat(d(l).slice(1),h(i).reverse().slice(1),d(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(a=+e[0][0],i=+e[1][0],c=+e[0][1],l=+e[1][1],a>i&&(e=a,a=i,i=e),c>l&&(e=c,c=l,l=e),t.precision(y)):[[a,c],[i,l]]},t.minorExtent=function(e){return arguments.length?(n=+e[0][0],r=+e[1][0],s=+e[0][1],o=+e[1][1],n>r&&(e=n,n=r,r=e),s>o&&(e=s,s=o,o=e),t.precision(y)):[[n,s],[r,o]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=yr(s,o,90),f=br(n,r,y),h=yr(c,l,90),d=br(a,i,y),t):y},t.majorExtent([[-180,-90+Do],[180,90-Do]]).minorExtent([[-180,-80-Do],[180,80+Do]])},co.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}var e,r,n=xr,i=_r;return t.distance=function(){return co.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},t.source=function(r){return arguments.length?(n=r,e="function"==typeof r?null:r,t):n},t.target=function(e){return arguments.length?(i=e,r="function"==typeof e?null:e,t):i},t.precision=function(){return arguments.length?t:0},t},co.geo.interpolate=function(t,e){return wr(t[0]*Go,t[1]*Go,e[0]*Go,e[1]*Go)},co.geo.length=function(t){return Qs=0,co.geo.stream(t,Js),Qs};var Qs,Js={sphere:k,point:k,lineStart:kr,lineEnd:k,polygonStart:k,polygonEnd:k},tl=Ar(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(co.geo.azimuthalEqualArea=function(){return sr(tl)}).raw=tl;var el=Ar(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},x);(co.geo.azimuthalEquidistant=function(){return sr(el)}).raw=el,(co.geo.conicConformal=function(){return Ye(Mr)}).raw=Mr,(co.geo.conicEquidistant=function(){return Ye(Tr)}).raw=Tr;var rl=Ar(function(t){return 1/t},Math.atan);(co.geo.gnomonic=function(){return sr(rl)}).raw=rl,Er.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Ho]},(co.geo.mercator=function(){return Lr(Er)}).raw=Er;var nl=Ar(function(){return 1},Math.asin);(co.geo.orthographic=function(){return sr(nl)}).raw=nl;var il=Ar(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(co.geo.stereographic=function(){return sr(il)}).raw=il,Sr.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ho]},(co.geo.transverseMercator=function(){var t=Lr(Sr),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):(t=r(),[t[0],t[1],t[2]-90])},r([0,0,90])}).raw=Sr,co.geom={},co.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,i=Lt(r),a=Lt(n),o=t.length,s=[],l=[];for(e=0;o>e;e++)s.push([+i.call(this,t[e],e),+a.call(this,t[e],e),e]);for(s.sort(Rr),e=0;o>e;e++)l.push([s[e][0],-s[e][1]]);var c=Pr(s),u=Pr(l),f=u[0]===c[0],h=u[u.length-1]===c[c.length-1],d=[];for(e=c.length-1;e>=0;--e)d.push(t[s[c[e]][2]]);for(e=+f;e=n&&c.x<=a&&c.y>=i&&c.y<=o?[[n,o],[a,o],[a,i],[n,i]]:[];u.point=t[s]}),e}function r(t){return t.map(function(t,e){return{x:Math.round(a(t,e)/Do)*Do,y:Math.round(o(t,e)/Do)*Do,i:e}})}var n=Cr,i=zr,a=n,o=i,s=dl;return t?e(t):(e.links=function(t){return cn(r(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cn(r(t)).cells.forEach(function(r,n){for(var i,a,o=r.site,s=r.edges.sort(Yr),l=-1,c=s.length,u=s[c-1].edge,f=u.l===o?u.r:u.l;++l=c,h=n>=u,d=h<<1|f;t.leaf=!1,t=t.nodes[d]||(t.nodes[d]=pn()),f?i=c:s=c,h?o=u:l=u,a(t,e,r,n,i,o,s,l)}var u,f,h,d,p,g,v,m,y,b=Lt(s),x=Lt(l);if(null!=e)g=e,v=r,m=n,y=i;else if(m=y=-(g=v=1/0),f=[],h=[],p=t.length,o)for(d=0;p>d;++d)u=t[d],u.xm&&(m=u.x),u.y>y&&(y=u.y),f.push(u.x),h.push(u.y);else for(d=0;p>d;++d){var _=+b(u=t[d],d),w=+x(u,d);g>_&&(g=_),v>w&&(v=w),_>m&&(m=_),w>y&&(y=w),f.push(_),h.push(w)}var k=m-g,A=y-v;k>A?y=v+k:m=g+A;var M=pn();if(M.add=function(t){a(M,t,+b(t,++d),+x(t,d),g,v,m,y)},M.visit=function(t){gn(t,M,g,v,m,y)},M.find=function(t){return vn(M,t[0],t[1],g,v,m,y)},d=-1,null==e){for(;++d=0?t.slice(0,e):t,n=e>=0?t.slice(e+1):"in";return r=ml.get(r)||vl,n=yl.get(n)||x,kn(n(r.apply(null,uo.call(arguments,1))))},co.interpolateHcl=Nn,co.interpolateHsl=jn,co.interpolateLab=Fn,co.interpolateRound=Dn,co.transform=function(t){var e=ho.createElementNS(co.ns.prefix.svg,"g");return(co.transform=function(t){if(null!=t){e.setAttribute("transform",t);var r=e.transform.baseVal.consolidate()}return new Bn(r?r.matrix:bl)})(t)},Bn.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var bl={a:1,b:0,c:0,d:1,e:0,f:0};co.interpolateTransform=Zn,co.layout={},co.layout.bundle=function(){return function(t){for(var e=[],r=-1,n=t.length;++rs*s/m){if(g>l){var c=e.charge/l;t.px-=a*c,t.py-=o*c}return!0}if(e.point&&l&&g>l){var c=e.pointCharge/l;t.px-=a*c,t.py-=o*c}}return!e.charge}}function e(t){t.px=co.event.x,t.py=co.event.y,l.resume()}var r,n,i,a,o,s,l={},c=co.dispatch("start","tick","end"),u=[1,1],f=.9,h=xl,d=_l,p=-30,g=wl,v=.1,m=.64,y=[],b=[];return l.tick=function(){if((i*=.99)<.005)return r=null,c.end({type:"end",alpha:i=0}),!0;var e,n,l,h,d,g,m,x,_,w=y.length,k=b.length;for(n=0;k>n;++n)l=b[n],h=l.source,d=l.target,x=d.x-h.x,_=d.y-h.y,(g=x*x+_*_)&&(g=i*o[n]*((g=Math.sqrt(g))-a[n])/g,x*=g,_*=g,d.x-=x*(m=h.weight+d.weight?h.weight/(h.weight+d.weight):.5),d.y-=_*m,h.x+=x*(m=1-m),h.y+=_*m);if((m=i*v)&&(x=u[0]/2,_=u[1]/2,n=-1,m))for(;++n0?i=t:(r.c=null,r.t=NaN,r=null,c.end({type:"end",alpha:i=0})):t>0&&(c.start({type:"start",alpha:i=t}),r=Rt(l.tick)),l):i},l.start=function(){function t(t,n){if(!r){for(r=new Array(i),l=0;i>l;++l)r[l]=[];for(l=0;c>l;++l){var a=b[l];r[a.source.index].push(a.target),r[a.target.index].push(a.source)}}for(var o,s=r[e],l=-1,u=s.length;++le;++e)(n=y[e]).index=e,n.weight=0;for(e=0;c>e;++e)n=b[e],"number"==typeof n.source&&(n.source=y[n.source]),"number"==typeof n.target&&(n.target=y[n.target]),++n.source.weight,++n.target.weight;for(e=0;i>e;++e)n=y[e],isNaN(n.x)&&(n.x=t("x",f)),isNaN(n.y)&&(n.y=t("y",g)),isNaN(n.px)&&(n.px=n.x),isNaN(n.py)&&(n.py=n.y);if(a=[],"function"==typeof h)for(e=0;c>e;++e)a[e]=+h.call(this,b[e],e);else for(e=0;c>e;++e)a[e]=h;if(o=[],"function"==typeof d)for(e=0;c>e;++e)o[e]=+d.call(this,b[e],e);else for(e=0;c>e;++e)o[e]=d;if(s=[],"function"==typeof p)for(e=0;i>e;++e)s[e]=+p.call(this,y[e],e);else for(e=0;i>e;++e)s[e]=p;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return n||(n=co.behavior.drag().origin(x).on("dragstart.force",ei).on("drag.force",e).on("dragend.force",ri)),arguments.length?void this.on("mouseover.force",ni).on("mouseout.force",ii).call(n):n},co.rebind(l,c,"on")};var xl=20,_l=1,wl=1/0;co.layout.hierarchy=function(){function t(i){var a,o=[i],s=[];for(i.depth=0;null!=(a=o.pop());)if(s.push(a),(c=r.call(t,a,a.depth))&&(l=c.length)){for(var l,c,u;--l>=0;)o.push(u=c[l]),u.parent=a,u.depth=a.depth+1;n&&(a.value=0),a.children=c}else n&&(a.value=+n.call(t,a,a.depth)||0),delete a.children;return li(i,function(t){var r,i;e&&(r=t.children)&&r.sort(e),n&&(i=t.parent)&&(i.value+=t.value)}),s}var e=fi,r=ci,n=ui;return t.sort=function(r){return arguments.length?(e=r,t):e},t.children=function(e){return arguments.length?(r=e,t):r},t.value=function(e){return arguments.length?(n=e,t):n},t.revalue=function(e){return n&&(si(e,function(t){t.children&&(t.value=0)}),li(e,function(e){var r;e.children||(e.value=+n.call(t,e,e.depth)||0),(r=e.parent)&&(r.value+=e.value)})),e},t},co.layout.partition=function(){function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,c=-1;for(n=e.value?n/e.value:0;++cf?-1:1),p=co.sum(c),g=p?(f-l*d)/p:0,v=co.range(l),m=[];return null!=r&&v.sort(r===kl?function(t,e){return c[e]-c[t]}:function(t,e){return r(o[t],o[e])}),v.forEach(function(t){m[t]={data:o[t],value:s=c[t],startAngle:u,endAngle:u+=s*g+d,padAngle:h}}),m}var e=Number,r=kl,n=0,i=Vo,a=0;return t.value=function(r){return arguments.length?(e=r,t):e},t.sort=function(e){return arguments.length?(r=e,t):r},t.startAngle=function(e){return arguments.length?(n=e,t):n},t.endAngle=function(e){return arguments.length?(i=e,t):i},t.padAngle=function(e){return arguments.length?(a=e,t):a},t};var kl={};co.layout.stack=function(){function t(s,l){if(!(h=s.length))return s;var c=s.map(function(r,n){return e.call(t,r,n)}),u=c.map(function(e){return e.map(function(e,r){return[a.call(t,e,r),o.call(t,e,r)]})}),f=r.call(t,u,l);c=co.permute(c,f),u=co.permute(u,f);var h,d,p,g,v=n.call(t,u,l),m=c[0].length;for(p=0;m>p;++p)for(i.call(t,c[0][p],g=v[p],u[0][p][1]),d=1;h>d;++d)i.call(t,c[d][p],g+=u[d-1][p][1],u[d][p][1]);return s}var e=x,r=vi,n=mi,i=gi,a=di,o=pi;return t.values=function(r){return arguments.length?(e=r,t):e},t.order=function(e){return arguments.length?(r="function"==typeof e?e:Al.get(e)||vi,t):r},t.offset=function(e){return arguments.length?(n="function"==typeof e?e:Ml.get(e)||mi,t):n},t.x=function(e){return arguments.length?(a=e,t):a},t.y=function(e){return arguments.length?(o=e,t):o},t.out=function(e){return arguments.length?(i=e,t):i},t};var Al=co.map({"inside-out":function(t){var e,r,n=t.length,i=t.map(yi),a=t.map(bi),o=co.range(n).sort(function(t,e){return i[t]-i[e]}),s=0,l=0,c=[],u=[];for(e=0;n>e;++e)r=o[e],l>s?(s+=a[r],c.push(r)):(l+=a[r],u.push(r));return u.reverse().concat(c)},reverse:function(t){return co.range(t.length).reverse()},"default":vi}),Ml=co.map({silhouette:function(t){var e,r,n,i=t.length,a=t[0].length,o=[],s=0,l=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];n>s&&(s=n),o.push(n)}for(r=0;a>r;++r)l[r]=(s-o[r])/2;return l},wiggle:function(t){var e,r,n,i,a,o,s,l,c,u=t.length,f=t[0],h=f.length,d=[];for(d[0]=l=c=0,r=1;h>r;++r){for(e=0,i=0;u>e;++e)i+=t[e][r][1];for(e=0,a=0,s=f[r][0]-f[r-1][0];u>e;++e){for(n=0,o=(t[e][r][1]-t[e][r-1][1])/(2*s);e>n;++n)o+=(t[n][r][1]-t[n][r-1][1])/s;a+=o*t[e][r][1]}d[r]=l-=i?a/i*s:0,c>l&&(c=l)}for(r=0;h>r;++r)d[r]-=c;return d},expand:function(t){var e,r,n,i=t.length,a=t[0].length,o=1/i,s=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];if(n)for(e=0;i>e;e++)t[e][r][1]/=n;else for(e=0;i>e;e++)t[e][r][1]=o}for(r=0;a>r;++r)s[r]=0;return s},zero:mi});co.layout.histogram=function(){function t(t,a){for(var o,s,l=[],c=t.map(r,this),u=n.call(this,c,a),f=i.call(this,u,c,a),a=-1,h=c.length,d=f.length-1,p=e?1:1/h;++a0)for(a=-1;++a=u[0]&&s<=u[1]&&(o=l[co.bisect(f,s,1,d)-1],o.y+=p,o.push(t[a]));return l}var e=!0,r=Number,n=ki,i=_i;return t.value=function(e){return arguments.length?(r=e,t):r},t.range=function(e){return arguments.length?(n=Lt(e),t):n},t.bins=function(e){return arguments.length?(i="number"==typeof e?function(t){return wi(t,e)}:Lt(e),t):i},t.frequency=function(r){return arguments.length?(e=!!r,t):e},t},co.layout.pack=function(){function t(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],c=i[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,li(s,function(t){t.r=+u(t.value)}),li(s,Li),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/c))/2;li(s,function(t){t.r+=f}),li(s,Li),li(s,function(t){t.r-=f})}return zi(s,l/2,c/2,e?1:1/Math.max(2*s.r/l,2*s.r/c)),o}var e,r=co.layout.hierarchy().sort(Ai),n=0,i=[1,1];return t.size=function(e){return arguments.length?(i=e,t):i},t.radius=function(r){return arguments.length?(e=null==r||"function"==typeof r?r:+r,t):e},t.padding=function(e){return arguments.length?(n=+e,t):n},oi(t,r)},co.layout.tree=function(){function t(t,i){var u=o.call(this,t,i),f=u[0],h=e(f);if(li(h,r),h.parent.m=-h.z,si(h,n),c)si(f,a);else{var d=f,p=f,g=f;si(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=s(d,p)/2-d.x,m=l[0]/(p.x+s(p,d)/2+v),y=l[1]/(g.depth||1);si(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return u}function e(t){for(var e,r={A:null,children:[t]},n=[r];null!=(e=n.pop());)for(var i,a=e.children,o=0,s=a.length;s>o;++o)n.push((a[o]=i={_:a[o],parent:e,children:(i=a[o].children)&&i.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=i);return r.children[0]}function r(t){var e=t.children,r=t.parent.children,n=t.i?r[t.i-1]:null;if(e.length){ji(t);var a=(e[0].z+e[e.length-1].z)/2;n?(t.z=n.z+s(t._,n._),t.m=t.z-a):t.z=a}else n&&(t.z=n.z+s(t._,n._));t.parent.A=i(t,n,t.parent.A||r[0])}function n(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function i(t,e,r){if(e){for(var n,i=t,a=t,o=e,l=i.parent.children[0],c=i.m,u=a.m,f=o.m,h=l.m;o=Ii(o),i=Oi(i),o&&i;)l=Oi(l),a=Ii(a),a.a=t,n=o.z+f-i.z-c+s(o._,i._),n>0&&(Ni(Fi(o,t,r),t,n),c+=n,u+=n),f+=o.m,c+=i.m,h+=l.m,u+=a.m;o&&!Ii(a)&&(a.t=o,a.m+=f-u),i&&!Oi(l)&&(l.t=i,l.m+=c-h,r=t)}return r}function a(t){t.x*=l[0],t.y=t.depth*l[1]}var o=co.layout.hierarchy().sort(null).value(null),s=Ri,l=[1,1],c=null;return t.separation=function(e){return arguments.length?(s=e,t):s},t.size=function(e){return arguments.length?(c=null==(l=e)?a:null,t):c?null:l},t.nodeSize=function(e){return arguments.length?(c=null==(l=e)?null:a,t):c?l:null},oi(t,o)},co.layout.cluster=function(){function t(t,a){var o,s=e.call(this,t,a),l=s[0],c=0;li(l,function(t){var e=t.children;e&&e.length?(t.x=Bi(e),t.y=Di(e)):(t.x=o?c+=r(t,o):0,t.y=0,o=t)});var u=Ui(l),f=Vi(l),h=u.x-r(u,f)/2,d=f.x+r(f,u)/2;return li(l,i?function(t){t.x=(t.x-l.x)*n[0],t.y=(l.y-t.y)*n[1]}:function(t){t.x=(t.x-h)/(d-h)*n[0],t.y=(1-(l.y?t.y/l.y:1))*n[1]}),s}var e=co.layout.hierarchy().sort(null).value(null),r=Ri,n=[1,1],i=!1;return t.separation=function(e){return arguments.length?(r=e,t):r},t.size=function(e){return arguments.length?(i=null==(n=e),t):i?null:n},t.nodeSize=function(e){return arguments.length?(i=null!=(n=e),t):i?n:null},oi(t,e)},co.layout.treemap=function(){function t(t,e){for(var r,n,i=-1,a=t.length;++ie?0:e),r.area=isNaN(n)||0>=n?0:n}function e(r){var a=r.children;if(a&&a.length){var o,s,l,c=f(r),u=[],h=a.slice(),p=1/0,g="slice"===d?c.dx:"dice"===d?c.dy:"slice-dice"===d?1&r.depth?c.dy:c.dx:Math.min(c.dx,c.dy); +for(t(h,c.dx*c.dy/r.value),u.area=0;(l=h.length)>0;)u.push(o=h[l-1]),u.area+=o.area,"squarify"!==d||(s=n(u,g))<=p?(h.pop(),p=s):(u.area-=u.pop().area,i(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(i(u,g,c,!0),u.length=u.area=0),a.forEach(e)}}function r(e){var n=e.children;if(n&&n.length){var a,o=f(e),s=n.slice(),l=[];for(t(s,o.dx*o.dy/e.value),l.area=0;a=s.pop();)l.push(a),l.area+=a.area,null!=a.z&&(i(l,a.z?o.dx:o.dy,o,!s.length),l.length=l.area=0);n.forEach(r)}}function n(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++or&&(a=r),r>i&&(i=r));return n*=n,e*=e,n?Math.max(e*i*p/n,n/(e*a*p)):1/0}function i(t,e,r,n){var i,a=-1,o=t.length,s=r.x,c=r.y,u=e?l(t.area/e):0;if(e==r.dx){for((n||u>r.dy)&&(u=r.dy);++ar.dx)&&(u=r.dx);++ar&&(e=1),1>r&&(t=0),function(){var r,n,i;do r=2*Math.random()-1,n=2*Math.random()-1,i=r*r+n*n;while(!i||i>1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=co.random.normal.apply(co,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=co.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,r=0;t>r;r++)e+=Math.random();return e}}},co.scale={};var Tl={floor:x,ceil:x};co.scale.linear=function(){return $i([0,1],[0,1],_n,!1)};var El={s:1,g:1,p:1,r:1,e:1};co.scale.log=function(){return aa(co.scale.linear().domain([0,1]),10,!0,[1,10])};var Ll=co.format(".0e"),Sl={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};co.scale.pow=function(){return oa(co.scale.linear(),1,[0,1])},co.scale.sqrt=function(){return co.scale.pow().exponent(.5)},co.scale.ordinal=function(){return la([],{t:"range",a:[[]]})},co.scale.category10=function(){return co.scale.ordinal().range(Cl)},co.scale.category20=function(){return co.scale.ordinal().range(zl)},co.scale.category20b=function(){return co.scale.ordinal().range(Pl)},co.scale.category20c=function(){return co.scale.ordinal().range(Rl)};var Cl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(_t),zl=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(_t),Pl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(_t),Rl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(_t);co.scale.quantile=function(){return ca([],[])},co.scale.quantize=function(){return ua(0,1,[0,1])},co.scale.threshold=function(){return fa([.5],[0,1])},co.scale.identity=function(){return ha([0,1])},co.svg={},co.svg.arc=function(){function t(){var t=Math.max(0,+r.apply(this,arguments)),c=Math.max(0,+n.apply(this,arguments)),u=o.apply(this,arguments)-Ho,f=s.apply(this,arguments)-Ho,h=Math.abs(f-u),d=u>f?0:1;if(t>c&&(p=c,c=t,t=p),h>=qo)return e(c,d)+(t?e(t,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,k,A,M,T=0,E=0,L=[];if((m=(+l.apply(this,arguments)||0)/2)&&(v=a===Ol?Math.sqrt(t*t+c*c):+a.apply(this,arguments),d||(E*=-1),c&&(E=nt(v/c*Math.sin(m))),t&&(T=nt(v/t*Math.sin(m)))),c){y=c*Math.cos(u+E),b=c*Math.sin(u+E),x=c*Math.cos(f-E),_=c*Math.sin(f-E);var S=Math.abs(f-u-2*E)<=Uo?0:1;if(E&&ba(y,b,x,_)===d^S){var C=(u+f)/2;y=c*Math.cos(C),b=c*Math.sin(C),x=_=null}}else y=b=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),A=t*Math.cos(u+T),M=t*Math.sin(u+T);var z=Math.abs(u-f+2*T)<=Uo?0:1;if(T&&ba(w,k,A,M)===1-d^z){var P=(u+f)/2;w=t*Math.cos(P),k=t*Math.sin(P),A=M=null}}else w=k=0;if(h>Do&&(p=Math.min(Math.abs(c-t)/2,+i.apply(this,arguments)))>.001){g=c>t^d?0:1;var R=p,O=p;if(Uo>h){var I=null==A?[w,k]:null==x?[y,b]:Ir([y,b],[A,M],[x,_],[w,k]),N=y-I[0],j=b-I[1],F=x-I[0],D=_-I[1],B=1/Math.sin(Math.acos((N*F+j*D)/(Math.sqrt(N*N+j*j)*Math.sqrt(F*F+D*D)))/2),U=Math.sqrt(I[0]*I[0]+I[1]*I[1]);O=Math.min(p,(t-U)/(B-1)),R=Math.min(p,(c-U)/(B+1))}if(null!=x){var V=xa(null==A?[w,k]:[A,M],[y,b],c,R,d),q=xa([x,_],[w,k],c,R,d);p===R?L.push("M",V[0],"A",R,",",R," 0 0,",g," ",V[1],"A",c,",",c," 0 ",1-d^ba(V[1][0],V[1][1],q[1][0],q[1][1]),",",d," ",q[1],"A",R,",",R," 0 0,",g," ",q[0]):L.push("M",V[0],"A",R,",",R," 0 1,",g," ",q[0])}else L.push("M",y,",",b);if(null!=A){var H=xa([y,b],[A,M],t,-O,d),G=xa([w,k],null==x?[y,b]:[x,_],t,-O,d);p===O?L.push("L",G[0],"A",O,",",O," 0 0,",g," ",G[1],"A",t,",",t," 0 ",d^ba(G[1][0],G[1][1],H[1][0],H[1][1]),",",1-d," ",H[1],"A",O,",",O," 0 0,",g," ",H[0]):L.push("L",G[0],"A",O,",",O," 0 0,",g," ",H[0])}else L.push("L",w,",",k)}else L.push("M",y,",",b),null!=x&&L.push("A",c,",",c," 0 ",S,",",d," ",x,",",_),L.push("L",w,",",k),null!=A&&L.push("A",t,",",t," 0 ",z,",",1-d," ",A,",",M);return L.push("Z"),L.join("")}function e(t,e){return"M0,"+t+"A"+t+","+t+" 0 1,"+e+" 0,"+-t+"A"+t+","+t+" 0 1,"+e+" 0,"+t}var r=pa,n=ga,i=da,a=Ol,o=va,s=ma,l=ya;return t.innerRadius=function(e){return arguments.length?(r=Lt(e),t):r},t.outerRadius=function(e){return arguments.length?(n=Lt(e),t):n},t.cornerRadius=function(e){return arguments.length?(i=Lt(e),t):i},t.padRadius=function(e){return arguments.length?(a=e==Ol?Ol:Lt(e),t):a},t.startAngle=function(e){return arguments.length?(o=Lt(e),t):o},t.endAngle=function(e){return arguments.length?(s=Lt(e),t):s},t.padAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.centroid=function(){var t=(+r.apply(this,arguments)+ +n.apply(this,arguments))/2,e=(+o.apply(this,arguments)+ +s.apply(this,arguments))/2-Ho;return[Math.cos(e)*t,Math.sin(e)*t]},t};var Ol="auto";co.svg.line=function(){return _a(x)};var Il=co.map({linear:wa,"linear-closed":ka,step:Aa,"step-before":Ma,"step-after":Ta,basis:Pa,"basis-open":Ra,"basis-closed":Oa,bundle:Ia,cardinal:Sa,"cardinal-open":Ea,"cardinal-closed":La,monotone:Ua});Il.forEach(function(t,e){e.key=t,e.closed=/-closed$/.test(t)});var Nl=[0,2/3,1/3,0],jl=[0,1/3,2/3,0],Fl=[0,1/6,2/3,1/6];co.svg.line.radial=function(){var t=_a(Va);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},Ma.reverse=Ta,Ta.reverse=Ma,co.svg.area=function(){return qa(x)},co.svg.area.radial=function(){var t=qa(Va);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},co.svg.chord=function(){function t(t,s){var l=e(this,a,t,s),c=e(this,o,t,s);return"M"+l.p0+n(l.r,l.p1,l.a1-l.a0)+(r(l,c)?i(l.r,l.p1,l.r,l.p0):i(l.r,l.p1,c.r,c.p0)+n(c.r,c.p1,c.a1-c.a0)+i(c.r,c.p1,l.r,l.p0))+"Z"}function e(t,e,r,n){var i=e.call(t,r,n),a=s.call(t,i,n),o=l.call(t,i,n)-Ho,u=c.call(t,i,n)-Ho;return{r:a,a0:o,a1:u,p0:[a*Math.cos(o),a*Math.sin(o)],p1:[a*Math.cos(u),a*Math.sin(u)]}}function r(t,e){return t.a0==e.a0&&t.a1==e.a1}function n(t,e,r){return"A"+t+","+t+" 0 "+ +(r>Uo)+",1 "+e}function i(t,e,r,n){return"Q 0,0 "+n}var a=xr,o=_r,s=Ha,l=va,c=ma;return t.radius=function(e){return arguments.length?(s=Lt(e),t):s},t.source=function(e){return arguments.length?(a=Lt(e),t):a},t.target=function(e){return arguments.length?(o=Lt(e),t):o},t.startAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.endAngle=function(e){return arguments.length?(c=Lt(e),t):c},t},co.svg.diagonal=function(){function t(t,i){var a=e.call(this,t,i),o=r.call(this,t,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return l=l.map(n),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var e=xr,r=_r,n=Ga;return t.source=function(r){return arguments.length?(e=Lt(r),t):e},t.target=function(e){return arguments.length?(r=Lt(e),t):r},t.projection=function(e){return arguments.length?(n=e,t):n},t},co.svg.diagonal.radial=function(){var t=co.svg.diagonal(),e=Ga,r=t.projection;return t.projection=function(t){return arguments.length?r(Ya(e=t)):e},t},co.svg.symbol=function(){function t(t,n){return(Dl.get(e.call(this,t,n))||Za)(r.call(this,t,n))}var e=Wa,r=Xa;return t.type=function(r){return arguments.length?(e=Lt(r),t):e},t.size=function(e){return arguments.length?(r=Lt(e),t):r},t};var Dl=co.map({circle:Za,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Ul)),r=e*Ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/Bl),r=e*Bl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/Bl),r=e*Bl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});co.svg.symbolTypes=Dl.keys();var Bl=Math.sqrt(3),Ul=Math.tan(30*Go);zo.transition=function(t){for(var e,r,n=Vl||++Yl,i=to(t),a=[],o=ql||{time:Date.now(),ease:Ln,delay:0,duration:250},s=-1,l=this.length;++sa;a++){i.push(e=[]);for(var r=this[a],s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return $a(i,this.namespace,this.id)},Gl.tween=function(t,e){var r=this.id,n=this.namespace;return arguments.length<2?this.node()[n][r].tween.get(t):G(this,null==e?function(e){e[n][r].tween.remove(t)}:function(i){i[n][r].tween.set(t,e)})},Gl.attr=function(t,e){function r(){this.removeAttribute(s)}function n(){this.removeAttributeNS(s.space,s.local)}function i(t){return null==t?r:(t+="",function(){var e,r=this.getAttribute(s);return r!==t&&(e=o(r,t),function(t){this.setAttribute(s,e(t))})})}function a(t){return null==t?n:(t+="",function(){var e,r=this.getAttributeNS(s.space,s.local);return r!==t&&(e=o(r,t),function(t){this.setAttributeNS(s.space,s.local,e(t))})})}if(arguments.length<2){for(e in t)this.attr(e,t[e]);return this}var o="transform"==t?Zn:_n,s=co.ns.qualify(t);return Qa(this,"attr."+t,e,s.local?a:i)},Gl.attrTween=function(t,e){function r(t,r){var n=e.call(this,t,r,this.getAttribute(i));return n&&function(t){this.setAttribute(i,n(t))}}function n(t,r){var n=e.call(this,t,r,this.getAttributeNS(i.space,i.local));return n&&function(t){this.setAttributeNS(i.space,i.local,n(t))}}var i=co.ns.qualify(t);return this.tween("attr."+t,i.local?n:r)},Gl.style=function(t,e,r){function i(){this.style.removeProperty(t)}function a(e){return null==e?i:(e+="",function(){var i,a=n(this).getComputedStyle(this,null).getPropertyValue(t);return a!==e&&(i=_n(a,e),function(e){this.style.setProperty(t,i(e),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof t){2>o&&(e="");for(r in t)this.style(r,t[r],e);return this}r=""}return Qa(this,"style."+t,e,a)},Gl.styleTween=function(t,e,r){function i(i,a){var o=e.call(this,i,a,n(this).getComputedStyle(this,null).getPropertyValue(t));return o&&function(e){this.style.setProperty(t,o(e),r)}}return arguments.length<3&&(r=""),this.tween("style."+t,i)},Gl.text=function(t){return Qa(this,"text",t,Ja)},Gl.remove=function(){var t=this.namespace;return this.each("end.transition",function(){var e;this[t].count<2&&(e=this.parentNode)&&e.removeChild(this)})},Gl.ease=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].ease:("function"!=typeof t&&(t=co.ease.apply(co,arguments)),G(this,function(n){n[r][e].ease=t}))},Gl.delay=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].delay:G(this,"function"==typeof t?function(n,i,a){n[r][e].delay=+t.call(n,n.__data__,i,a)}:(t=+t,function(n){n[r][e].delay=t}))},Gl.duration=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].duration:G(this,"function"==typeof t?function(n,i,a){n[r][e].duration=Math.max(1,t.call(n,n.__data__,i,a))}:(t=Math.max(1,t),function(n){n[r][e].duration=t}))},Gl.each=function(t,e){var r=this.id,n=this.namespace;if(arguments.length<2){var i=ql,a=Vl;try{Vl=r,G(this,function(e,i,a){ql=e[n][r],t.call(e,e.__data__,i,a)})}finally{ql=i,Vl=a}}else G(this,function(i){var a=i[n][r];(a.event||(a.event=co.dispatch("start","end","interrupt"))).on(t,e)});return this},Gl.transition=function(){for(var t,e,r,n,i=this.id,a=++Yl,o=this.namespace,s=[],l=0,c=this.length;c>l;l++){s.push(t=[]);for(var e=this[l],u=0,f=e.length;f>u;u++)(r=e[u])&&(n=r[o][i],eo(r,u,o,a,{time:n.time,ease:n.ease,delay:n.delay+n.duration,duration:n.duration})),t.push(r)}return $a(s,o,a)},co.svg.axis=function(){function t(t){t.each(function(){var t,c=co.select(this),u=this.__chart__||r,f=this.__chart__=r.copy(),h=null==l?f.ticks?f.ticks.apply(f,s):f.domain():l,d=null==e?f.tickFormat?f.tickFormat.apply(f,s):x:e,p=c.selectAll(".tick").data(h,f),g=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Do),v=co.transition(p.exit()).style("opacity",Do).remove(),m=co.transition(p.order()).style("opacity",1),y=Math.max(i,0)+o,b=Yi(f),_=c.selectAll(".domain").data([0]),w=(_.enter().append("path").attr("class","domain"),co.transition(_));g.append("line"),g.append("text");var k,A,M,T,E=g.select("line"),L=m.select("line"),S=p.select("text").text(d),C=g.select("text"),z=m.select("text"),P="top"===n||"left"===n?-1:1;if("bottom"===n||"top"===n?(t=ro,k="x",M="y",A="x2",T="y2",S.attr("dy",0>P?"0em":".71em").style("text-anchor","middle"),w.attr("d","M"+b[0]+","+P*a+"V0H"+b[1]+"V"+P*a)):(t=no,k="y",M="x",A="y2",T="x2",S.attr("dy",".32em").style("text-anchor",0>P?"end":"start"),w.attr("d","M"+P*a+","+b[0]+"H0V"+b[1]+"H"+P*a)),E.attr(T,P*i),C.attr(M,P*y),L.attr(A,0).attr(T,P*i),z.attr(k,0).attr(M,P*y),f.rangeBand){var R=f,O=R.rangeBand()/2;u=f=function(t){return R(t)+O}}else u.rangeBand?u=f:v.call(t,f,u);g.call(t,u,f),m.call(t,f,f)})}var e,r=co.scale.linear(),n=Xl,i=6,a=6,o=3,s=[10],l=null;return t.scale=function(e){return arguments.length?(r=e,t):r},t.orient=function(e){return arguments.length?(n=e in Wl?e+"":Xl,t):n},t.ticks=function(){return arguments.length?(s=fo(arguments),t):s},t.tickValues=function(e){return arguments.length?(l=e,t):l},t.tickFormat=function(r){return arguments.length?(e=r,t):e},t.tickSize=function(e){var r=arguments.length;return r?(i=+e,a=+arguments[r-1],t):i},t.innerTickSize=function(e){return arguments.length?(i=+e,t):i},t.outerTickSize=function(e){return arguments.length?(a=+e,t):a},t.tickPadding=function(e){return arguments.length?(o=+e,t):o},t.tickSubdivide=function(){return arguments.length&&t},t};var Xl="bottom",Wl={top:1,right:1,bottom:1,left:1};co.svg.brush=function(){function t(n){n.each(function(){var n=co.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",a).on("touchstart.brush",a),o=n.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),n.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var s=n.selectAll(".resize").data(g,x);s.exit().remove(),s.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return Zl[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),s.style("display",t.empty()?"none":null);var l,f=co.transition(n),h=co.transition(o);c&&(l=Yi(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(f)),u&&(l=Yi(u),h.attr("y",l[0]).attr("height",l[1]-l[0]),i(f)),e(f)})}function e(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+f[+/e$/.test(t)]+","+h[+/^s/.test(t)]+")"})}function r(t){t.select(".extent").attr("x",f[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function i(t){t.select(".extent").attr("y",h[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function a(){function a(){32==co.event.keyCode&&(S||(b=null,z[0]-=f[1],z[1]-=h[1],S=2),T())}function g(){32==co.event.keyCode&&2==S&&(z[0]+=f[1],z[1]+=h[1],S=0,T())}function v(){var t=co.mouse(_),n=!1;x&&(t[0]+=x[0],t[1]+=x[1]),S||(co.event.altKey?(b||(b=[(f[0]+f[1])/2,(h[0]+h[1])/2]),z[0]=f[+(t[0]u?(i=n,n=u):i=u),g[0]!=n||g[1]!=i?(r?s=null:o=null,g[0]=n,g[1]=i,!0):void 0}function y(){v(),A.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),co.select("body").style("cursor",null),P.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),k({type:"brushend"})}var b,x,_=this,w=co.select(co.event.target),k=l.of(_,arguments),A=co.select(_),M=w.datum(),E=!/^(n|s)$/.test(M)&&c,L=!/^(e|w)$/.test(M)&&u,S=w.classed("extent"),C=$(_),z=co.mouse(_),P=co.select(n(_)).on("keydown.brush",a).on("keyup.brush",g);if(co.event.changedTouches?P.on("touchmove.brush",v).on("touchend.brush",y):P.on("mousemove.brush",v).on("mouseup.brush",y),A.interrupt().selectAll("*").interrupt(),S)z[0]=f[0]-z[0],z[1]=h[0]-z[1];else if(M){var R=+/w$/.test(M),O=+/^n/.test(M);x=[f[1-R]-z[0],h[1-O]-z[1]],z[0]=f[R],z[1]=h[O]}else co.event.altKey&&(b=z.slice());A.style("pointer-events","none").selectAll(".resize").style("display",null),co.select("body").style("cursor",w.style("cursor")),k({type:"brushstart"}),v()}var o,s,l=L(t,"brushstart","brush","brushend"),c=null,u=null,f=[0,0],h=[0,0],d=!0,p=!0,g=Kl[0];return t.event=function(t){t.each(function(){var t=l.of(this,arguments),e={x:f,y:h,i:o,j:s},r=this.__chart__||e;this.__chart__=e,Vl?co.select(this).transition().each("start.brush",function(){o=r.i,s=r.j,f=r.x,h=r.y,t({type:"brushstart"})}).tween("brush:brush",function(){var r=wn(f,e.x),n=wn(h,e.y);return o=s=null,function(i){f=e.x=r(i),h=e.y=n(i),t({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=e.i,s=e.j,t({type:"brush",mode:"resize"}),t({type:"brushend"})}):(t({type:"brushstart"}),t({type:"brush",mode:"resize"}),t({type:"brushend"}))})},t.x=function(e){return arguments.length?(c=e,g=Kl[!c<<1|!u],t):c},t.y=function(e){return arguments.length?(u=e,g=Kl[!c<<1|!u],t):u},t.clamp=function(e){return arguments.length?(c&&u?(d=!!e[0],p=!!e[1]):c?d=!!e:u&&(p=!!e),t):c&&u?[d,p]:c?d:u?p:null},t.extent=function(e){var r,n,i,a,l;return arguments.length?(c&&(r=e[0],n=e[1],u&&(r=r[0],n=n[0]),o=[r,n],c.invert&&(r=c(r),n=c(n)),r>n&&(l=r,r=n,n=l),r==f[0]&&n==f[1]||(f=[r,n])),u&&(i=e[0],a=e[1],c&&(i=i[1],a=a[1]),s=[i,a],u.invert&&(i=u(i),a=u(a)),i>a&&(l=i,i=a,a=l),i==h[0]&&a==h[1]||(h=[i,a])),t):(c&&(o?(r=o[0],n=o[1]):(r=f[0],n=f[1],c.invert&&(r=c.invert(r),n=c.invert(n)),r>n&&(l=r,r=n,n=l))),u&&(s?(i=s[0],a=s[1]):(i=h[0],a=h[1],u.invert&&(i=u.invert(i),a=u.invert(a)),i>a&&(l=i,i=a,a=l))),c&&u?[[r,i],[n,a]]:c?[r,n]:u&&[i,a])},t.clear=function(){return t.empty()||(f=[0,0],h=[0,0],o=s=null),t},t.empty=function(){return!!c&&f[0]==f[1]||!!u&&h[0]==h[1]},co.rebind(t,l,"on")};var Zl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Kl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],$l=vs.format=ws.timeFormat,Ql=$l.utc,Jl=Ql("%Y-%m-%dT%H:%M:%S.%LZ");$l.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?io:Jl,io.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},io.toString=Jl.toString,vs.second=Vt(function(t){return new ms(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),vs.seconds=vs.second.range,vs.seconds.utc=vs.second.utc.range,vs.minute=Vt(function(t){return new ms(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),vs.minutes=vs.minute.range,vs.minutes.utc=vs.minute.utc.range,vs.hour=Vt(function(t){var e=t.getTimezoneOffset()/60;return new ms(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),vs.hours=vs.hour.range,vs.hours.utc=vs.hour.utc.range,vs.month=Vt(function(t){return t=vs.day(t),t.setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),vs.months=vs.month.range,vs.months.utc=vs.month.utc.range;var tc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],ec=[[vs.second,1],[vs.second,5],[vs.second,15],[vs.second,30],[vs.minute,1],[vs.minute,5],[vs.minute,15],[vs.minute,30],[vs.hour,1],[vs.hour,3],[vs.hour,6],[vs.hour,12],[vs.day,1],[vs.day,2],[vs.week,1],[vs.month,1],[vs.month,3],[vs.year,1]],rc=$l.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",ze]]),nc={range:function(t,e,r){return co.range(Math.ceil(t/r)*r,+e,r).map(oo)},floor:x,ceil:x};ec.year=vs.year,vs.scale=function(){return ao(co.scale.linear(),ec,rc)};var ic=ec.map(function(t){return[t[0].utc,t[1]]}),ac=Ql.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",ze]]);ic.year=vs.year.utc,vs.scale.utc=function(){return ao(co.scale.linear(),ic,ac)},co.text=St(function(t){return t.responseText}),co.json=function(t,e){return Ct(t,"application/json",so,e)},co.html=function(t,e){return Ct(t,"text/html",lo,e)},co.xml=St(function(t){return t.responseXML}),"function"==typeof t&&t.amd?(this.d3=co,t(co)):"object"==typeof r&&r.exports?r.exports=co:this.d3=co}()},{}],73:[function(t,e,r){"use strict";function n(t,e){this.point=t,this.index=e}function i(t,e){for(var r=t.point,n=e.point,i=r.length,a=0;i>a;++a){var o=n[a]-r[a];if(o)return o}return 0}function a(t,e,r){if(1===t)return r?[[-1,0]]:[];var n=e.map(function(t,e){return[t[0],e]});n.sort(function(t,e){return t[0]-e[0]});for(var i=new Array(t-1),a=1;t>a;++a){var o=n[a-1],s=n[a];i[a-1]=[o[1],s[1]]}return r&&i.push([-1,i[0][1]],[i[t-1][1],-1]),i}function o(t,e){var r=t.length;if(0===r)return[];var o=t[0].length;if(1>o)return[];if(1===o)return a(r,t,e);for(var c=new Array(r),u=1,f=0;r>f;++f){for(var h=t[f],d=new Array(o+1),p=0,g=0;o>g;++g){var v=h[g];d[g]=v,p+=v*v}d[o]=p,c[f]=new n(d,f),u=Math.max(p,u)}l(c,i),r=c.length;for(var m=new Array(r+o+1),y=new Array(r+o+1),b=(o+1)*(o+1)*u,x=new Array(o+1),f=0;o>=f;++f)x[f]=0;x[o]=b,m[0]=x.slice(),y[0]=-1;for(var f=0;o>=f;++f){var d=x.slice();d[f]=1,m[f+1]=d,y[f+1]=-1}for(var f=0;r>f;++f){var _=c[f];m[f+o+1]=_.point,y[f+o+1]=_.index}var w=s(m,!1);if(w=e?w.filter(function(t){for(var e=0,r=0;o>=r;++r){var n=y[t[r]];if(0>n&&++e>=2)return!1;t[r]=n}return!0}):w.filter(function(t){for(var e=0;o>=e;++e){var r=y[t[e]];if(0>r)return!1;t[e]=r}return!0}),1&o)for(var f=0;f=i)return[];var a,o=new Array(i);if(r===t.length-1)for(a=0;i>a;++a)o[a]=e;else for(a=0;i>a;++a)o[a]=n(t,e,r+1);return o}function i(t,e){var r,n;for(r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return i(0|t,e);break;case"object":if("number"==typeof t.length)return n(t,e,0)}return[]}e.exports=a},{}],75:[function(e,r,n){(function(n,i){(function(){"use strict";function a(t){return"function"==typeof t||"object"==typeof t&&null!==t}function o(t){return"function"==typeof t}function s(t){Y=t}function l(t){K=t}function c(){return function(){n.nextTick(p)}}function u(){return function(){G(p)}}function f(){var t=0,e=new J(p),r=document.createTextNode("");return e.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}function h(){var t=new MessageChannel;return t.port1.onmessage=p,function(){t.port2.postMessage(0)}}function d(){return function(){setTimeout(p,1)}}function p(){for(var t=0;Z>t;t+=2){var e=rt[t],r=rt[t+1];e(r),rt[t]=void 0,rt[t+1]=void 0}Z=0}function g(){try{var t=e,r=t("vertx");return G=r.runOnLoop||r.runOnContext,u()}catch(n){return d()}}function v(t,e){var r=this,n=r._state;if(n===ot&&!t||n===st&&!e)return this;var i=new this.constructor(y),a=r._result;if(n){var o=arguments[n-1];K(function(){O(n,i,o,a)})}else C(r,i,t,e);return i}function m(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var r=new e(y);return T(r,t),r}function y(){}function b(){return new TypeError("You cannot resolve a promise with itself")}function x(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return lt.error=e,lt}}function w(t,e,r,n){try{t.call(e,r,n)}catch(i){return i}}function k(t,e,r){K(function(t){var n=!1,i=w(r,e,function(r){n||(n=!0,e!==r?T(t,r):L(t,r))},function(e){n||(n=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&i&&(n=!0,S(t,i))},t)}function A(t,e){e._state===ot?L(t,e._result):e._state===st?S(t,e._result):C(e,void 0,function(e){T(t,e)},function(e){S(t,e)})}function M(t,e,r){e.constructor===t.constructor&&r===nt&&constructor.resolve===it?A(t,e):r===lt?S(t,lt.error):void 0===r?L(t,e):o(r)?k(t,e,r):L(t,e)}function T(t,e){t===e?S(t,b()):a(e)?M(t,e,_(e)):L(t,e)}function E(t){t._onerror&&t._onerror(t._result),z(t)}function L(t,e){t._state===at&&(t._result=e,t._state=ot,0!==t._subscribers.length&&K(z,t))}function S(t,e){t._state===at&&(t._state=st,t._result=e,K(E,t))}function C(t,e,r,n){var i=t._subscribers,a=i.length;t._onerror=null,i[a]=e,i[a+ot]=r,i[a+st]=n,0===a&&t._state&&K(z,t)}function z(t){var e=t._subscribers,r=t._state;if(0!==e.length){for(var n,i,a=t._result,o=0;oo;o++)C(n.resolve(t[o]),void 0,e,r);return i}function F(t){var e=this,r=new e(y);return S(r,t),r}function D(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function B(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function U(t){this._id=dt++,this._state=void 0,this._result=void 0,this._subscribers=[],y!==t&&("function"!=typeof t&&D(),this instanceof U?I(this,t):B())}function V(t,e){this._instanceConstructor=t,this.promise=new t(y),Array.isArray(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?L(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&L(this.promise,this._result))):S(this.promise,this._validationError())}function q(){var t;if("undefined"!=typeof i)t=i;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var r=t.Promise;r&&"[object Promise]"===Object.prototype.toString.call(r.resolve())&&!r.cast||(t.Promise=pt)}var H;H=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var G,Y,X,W=H,Z=0,K=function(t,e){rt[Z]=t,rt[Z+1]=e,Z+=2,2===Z&&(Y?Y(p):X())},$="undefined"!=typeof window?window:void 0,Q=$||{},J=Q.MutationObserver||Q.WebKitMutationObserver,tt="undefined"!=typeof n&&"[object process]"==={}.toString.call(n),et="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,rt=new Array(1e3);X=tt?c():J?f():et?h():void 0===$&&"function"==typeof e?g():d();var nt=v,it=m,at=void 0,ot=1,st=2,lt=new P,ct=new P,ut=N,ft=j,ht=F,dt=0,pt=U;U.all=ut,U.race=ft,U.resolve=it,U.reject=ht,U._setScheduler=s,U._setAsap=l,U._asap=K,U.prototype={constructor:U,then:nt,"catch":function(t){return this.then(null,t)}};var gt=V;V.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},V.prototype._enumerate=function(){for(var t=this.length,e=this._input,r=0;this._state===at&&t>r;r++)this._eachEntry(e[r],r)},V.prototype._eachEntry=function(t,e){var r=this._instanceConstructor,n=r.resolve;if(n===it){var i=_(t);if(i===nt&&t._state!==at)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(r===pt){var a=new r(y);M(a,t,i),this._willSettleAt(a,e)}else this._willSettleAt(new r(function(e){e(t)}),e)}else this._willSettleAt(n(t),e)},V.prototype._settledAt=function(t,e,r){var n=this.promise;n._state===at&&(this._remaining--,t===st?S(n,r):this._result[e]=r),0===this._remaining&&L(n,this._result)},V.prototype._willSettleAt=function(t,e){var r=this;C(t,void 0,function(t){r._settledAt(ot,e,t)},function(t){r._settledAt(st,e,t)})};var vt=q,mt={Promise:pt,polyfill:vt };"function"==typeof t&&t.amd?t(function(){return mt}):"undefined"!=typeof r&&r.exports?r.exports=mt:"undefined"!=typeof this&&(this.ES6Promise=mt),vt()}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:56}],76:[function(t,e,r){"use strict";function n(t){for(var e,r=t.length,n=0;r>n;n++)if(e=t.charCodeAt(n),(9>e||e>13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(8192>e||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var r=t;if(t=+t,0===t&&n(r))return!1}else if("number"!==e)return!1;return 1>t-t}},{}],77:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.gl=t,this.type=e,this.handle=r,this.length=n,this.usage=i}function i(t,e,r,n,i,a){var o=i.length*i.BYTES_PER_ELEMENT;if(0>a)return t.bufferData(e,i,n),o;if(o+a>r)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function a(t,e){for(var r=l.malloc(t.length,e),n=t.length,i=0;n>i;++i)r[i]=t[i];return r}function o(t,e){for(var r=1,n=e.length-1;n>=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}function s(t,e,r,i){if(r=r||t.ARRAY_BUFFER,i=i||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.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(i!==t.DYNAMIC_DRAW&&i!==t.STATIC_DRAW&&i!==t.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 a=t.createBuffer(),o=new n(t,r,a,0,i);return o.update(e),o}var l=t("typedarray-pool"),c=t("ndarray-ops"),u=t("ndarray"),f=["uint8","uint8_clamped","uint16","uint32","int8","int16","int32","float32"],h=n.prototype;h.bind=function(){this.gl.bindBuffer(this.type,this.handle)},h.unbind=function(){this.gl.bindBuffer(this.type,null)},h.dispose=function(){this.gl.deleteBuffer(this.handle)},h.update=function(t,e){if("number"!=typeof e&&(e=-1),this.bind(),"object"==typeof t&&"undefined"!=typeof t.shape){var r=t.dtype;if(f.indexOf(r)<0&&(r="float32"),this.type===this.gl.ELEMENT_ARRAY_BUFFER){var n=gl.getExtension("OES_element_index_uint");r=n&&"uint16"!==r?"uint32":"uint16"}if(r===t.dtype&&o(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=i(this.gl,this.type,this.length,this.usage,t.data,e):this.length=i(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=l.malloc(t.size,r),h=u(s,t.shape);c.assign(h,t),0>e?this.length=i(this.gl,this.type,this.length,this.usage,s,e):this.length=i(this.gl,this.type,this.length,this.usage,s.subarray(0,t.size),e),l.free(s)}}else if(Array.isArray(t)){var d;d=this.type===this.gl.ELEMENT_ARRAY_BUFFER?a(t,"uint16"):a(t,"float32"),0>e?this.length=i(this.gl,this.type,this.length,this.usage,d,e):this.length=i(this.gl,this.type,this.length,this.usage,d.subarray(0,t.length),e),l.free(d)}else if("object"==typeof t&&"number"==typeof t.length)this.length=i(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");t=0|t,0>=t&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=s},{ndarray:212,"ndarray-ops":211,"typedarray-pool":237}],78:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.shader=e,this.buffer=r,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.color=[0,0,0,1]}function i(t,e){var r=a(t.gl,l.vertex,l.fragment),i=o(t.gl),s=new n(t,r,i);return s.update(e),t.addObject(s),s}var a=t("gl-shader"),o=t("gl-buffer"),s=t("typedarray-pool"),l=t("./lib/shaders");e.exports=i;var c=[[1,0,0,1,0,0],[1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,1,0,0],[1,0,0,1,0,0],[1,0,-1,0,0,1],[1,0,-1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,1],[1,0,-1,0,0,1],[-1,0,-1,0,0,1],[-1,0,-1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,1],[-1,0,-1,0,0,1],[0,1,1,0,0,0],[0,1,-1,0,0,0],[0,-1,-1,0,0,0],[0,-1,-1,0,0,0],[0,1,1,0,0,0],[0,-1,1,0,0,0],[0,1,0,-1,1,0],[0,1,0,-1,-1,0],[0,1,0,1,-1,0],[0,1,0,1,1,0],[0,1,0,-1,1,0],[0,1,0,1,-1,0],[0,-1,0,-1,1,0],[0,-1,0,-1,-1,0],[0,-1,0,1,-1,0],[0,-1,0,1,1,0],[0,-1,0,-1,1,0],[0,-1,0,1,-1,0]],u=n.prototype;u.draw=function(){var t=[1,0,0,0,1,0,0,0,1],e=[1,1];return function(){var r=this.plot,n=this.shader,i=this.buffer,a=this.bounds,o=this.numPoints;if(o){var s=r.gl,l=r.dataBox,u=r.viewBox,f=r.pixelRatio,h=a[2]-a[0],d=a[3]-a[1],p=l[2]-l[0],g=l[3]-l[1];t[0]=2*h/p,t[4]=2*d/g,t[6]=2*(a[0]-l[0])/p-1,t[7]=2*(a[1]-l[1])/g-1;var v=u[2]-u[0],m=u[3]-u[1];e[0]=2*f/v,e[1]=2*f/m,i.bind(),n.bind(),n.uniforms.viewTransform=t,n.uniforms.pixelScale=e,n.uniforms.color=this.color,n.attributes.position.pointer(s.FLOAT,!1,16,0),n.attributes.pixelOffset.pointer(s.FLOAT,!1,16,8),s.drawArrays(s.TRIANGLES,0,o*c.length)}}}(),u.drawPick=function(t){return t},u.pick=function(t,e){return null},u.update=function(t){t=t||{};var e,r,n,i=t.positions||[],a=t.errors||[],o=1;"lineWidth"in t&&(o=+t.lineWidth);var l=5;"capSize"in t&&(l=+t.capSize),this.color=(t.color||[0,0,0,1]).slice();var u=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=this.numPoints=i.length>>1;for(e=0;f>e;++e)r=i[2*e],n=i[2*e+1],u[0]=Math.min(r,u[0]),u[1]=Math.min(n,u[1]),u[2]=Math.max(r,u[2]),u[3]=Math.max(n,u[3]);u[2]===u[0]&&(u[2]+=1),u[3]===u[1]&&(u[3]+=1);var h=1/(u[2]-u[0]),d=1/(u[3]-u[1]),p=u[0],g=u[1],v=s.mallocFloat32(f*c.length*4),m=0;for(e=0;f>e;++e){r=i[2*e],n=i[2*e+1];for(var y=a[4*e],b=a[4*e+1],x=a[4*e+2],_=a[4*e+3],w=0;wA?A*=y:A>0&&(A*=b),0>M?M*=x:M>0&&(M*=_),v[m++]=h*(r-p+A),v[m++]=d*(n-g+M),v[m++]=o*k[2]+(l+o)*k[4],v[m++]=o*k[3]+(l+o)*k[5]}}this.buffer.update(v),s.free(v)},u.dispose=function(){this.plot.removeObject(this),this.shader.dispose(),this.buffer.dispose()}},{"./lib/shaders":79,"gl-buffer":77,"gl-shader":156,"typedarray-pool":237}],79:[function(t,e,r){e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 pixelOffset;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvoid main() {\n vec3 scrPosition = viewTransform * vec3(position, 1);\n gl_Position = vec4(\n scrPosition.xy + scrPosition.z * pixelScale * pixelOffset,\n 0,\n scrPosition.z);\n}\n",fragment:"precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"}},{}],80:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.shader=n,this.buffer=e,this.vao=r,this.pixelRatio=1,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.lineWidth=[1,1,1],this.capSize=[10,10,10],this.lineCount=[0,0,0],this.lineOffset=[0,0,0],this.opacity=1}function i(t,e){for(var r=0;3>r;++r)t[0][r]=Math.min(t[0][r],e[r]),t[1][r]=Math.max(t[1][r],e[r])}function a(t,e,r,n){for(var i=h[n],a=0;a=1},f.isTransparent=function(){return this.opacity<1},f.drawTransparent=f.draw=function(t){var e=this.gl,r=this.shader.uniforms;this.shader.bind();var n=r.view=t.view||u,i=r.projection=t.projection||u;r.model=t.model||u,r.clipBounds=this.clipBounds,r.opacity=this.opacity;var a=n[12],o=n[13],s=n[14],l=n[15],c=this.pixelRatio*(i[3]*a+i[7]*o+i[11]*s+i[15]*l)/e.drawingBufferHeight;this.vao.bind();for(var f=0;3>f;++f)e.lineWidth(this.lineWidth[f]),r.capSize=this.capSize[f]*c,e.drawArrays(e.LINES,this.lineOffset[f],this.lineCount[f]);this.vao.unbind()};var h=function(){for(var t=new Array(3),e=0;3>e;++e){for(var r=[],n=1;2>=n;++n)for(var i=-1;1>=i;i+=2){var a=(n+e)%3,o=[0,0,0];o[a]=i,r.push(o)}t[e]=r}return t}();f.update=function(t){t=t||{},"lineWidth"in t&&(this.lineWidth=t.lineWidth,Array.isArray(this.lineWidth)||(this.lineWidth=[this.lineWidth,this.lineWidth,this.lineWidth])),"capSize"in t&&(this.capSize=t.capSize,Array.isArray(this.capSize)||(this.capSize=[this.capSize,this.capSize,this.capSize])),"opacity"in t&&(this.opacity=t.opacity);var e=t.color||[[0,0,0],[0,0,0],[0,0,0]],r=t.position,n=t.error;if(Array.isArray(e[0])||(e=[e,e,e]),r&&n){var o=[],s=r.length,l=0;this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.lineCount=[0,0,0];for(var c=0;3>c;++c){this.lineOffset[c]=l;t:for(var u=0;s>u;++u){for(var f=r[u],h=0;3>h;++h)if(isNaN(f[h])||!isFinite(f[h]))continue t;var d=n[u],p=e[c];if(Array.isArray(p[0])&&(p=e[u]),3===p.length&&(p=[p[0],p[1],p[2],1]),!isNaN(d[0][c])&&!isNaN(d[1][c])){if(d[0][c]<0){var g=f.slice();g[c]+=d[0][c],o.push(f[0],f[1],f[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,g),l+=2+a(o,g,p,c)}if(d[1][c]>0){var g=f.slice();g[c]+=d[1][c],o.push(f[0],f[1],f[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,g),l+=2+a(o,g,p,c)}}}this.lineCount[c]=l-this.lineOffset[c]}this.buffer.update(o)}},f.dispose=function(){this.shader.dispose(),this.buffer.dispose(),this.vao.dispose()}},{"./shaders/index":81,"gl-buffer":77,"gl-vao":185}],81:[function(t,e,r){"use strict";var n=t("gl-shader"),i="precision mediump 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}",a="precision mediump float;\n#define GLSLIFY 1\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(fragPosition, clipBounds[0])) || any(greaterThan(fragPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = opacity * fragColor;\n}";e.exports=function(t){return n(t,i,a,null,[{name:"position",type:"vec3"},{name:"offset",type:"vec3"},{name:"color",type:"vec4"}])}},{"gl-shader":156}],82:[function(t,e,r){"use strict";function n(t){var e=t.getParameter(t.FRAMEBUFFER_BINDING),r=t.getParameter(t.RENDERBUFFER_BINDING),n=t.getParameter(t.TEXTURE_BINDING_2D);return[e,r,n]}function i(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function a(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);y=new Array(r+1);for(var n=0;r>=n;++n){for(var i=new Array(r),a=0;n>a;++a)i[a]=t.COLOR_ATTACHMENT0+a;for(var a=n;r>a;++a)i[a]=t.NONE;y[n]=i}}function o(t){switch(t){case p:throw new Error("gl-fbo: Framebuffer unsupported");case g:throw new Error("gl-fbo: Framebuffer incomplete attachment");case v:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case m:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function s(t,e,r,n,i,a){if(!n)return null;var o=d(t,e,r,i,n);return o.magFilter=t.NEAREST,o.minFilter=t.NEAREST,o.mipSamples=1,o.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,a,t.TEXTURE_2D,o.handle,0),o}function l(t,e,r,n,i){var a=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,a),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,a),a}function c(t){var e=n(t.gl),r=t.gl,a=t.handle=r.createFramebuffer(),c=t._shape[0],u=t._shape[1],f=t.color.length,h=t._ext,d=t._useStencil,p=t._useDepth,g=t._colorType;r.bindFramebuffer(r.FRAMEBUFFER,a);for(var v=0;f>v;++v)t.color[v]=s(r,c,u,g,r.RGBA,r.COLOR_ATTACHMENT0+v);0===f?(t._color_rb=l(r,c,u,r.RGBA4,r.COLOR_ATTACHMENT0),h&&h.drawBuffersWEBGL(y[0])):f>1&&h.drawBuffersWEBGL(y[f]);var m=r.getExtension("WEBGL_depth_texture");m?d?t.depth=s(r,c,u,m.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p&&(t.depth=s(r,c,u,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):p&&d?t._depth_rb=l(r,c,u,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p?t._depth_rb=l(r,c,u,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(t._depth_rb=l(r,c,u,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null);for(var v=0;vl;++l)this.color[l]=null;this._color_rb=null,this.depth=null,this._depth_rb=null,this._colorType=n,this._useDepth=a,this._useStencil=o;var u=this,f=[0|e,0|r];Object.defineProperties(f,{0:{get:function(){return u._shape[0]},set:function(t){return u.width=t}},1:{get:function(){return u._shape[1]},set:function(t){return u.height=t}}}),this._shapeVector=f,c(this)}function f(t,e,r){if(t._destroyed)throw new Error("gl-fbo: Can't resize destroyed FBO");if(t._shape[0]!==e||t._shape[1]!==r){var a=t.gl,s=a.getParameter(a.MAX_RENDERBUFFER_SIZE);if(0>e||e>s||0>r||r>s)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var l=n(a),c=0;ce||e>o||0>r||r>o)throw new Error("gl-fbo: Parameters are too large for FBO");n=n||{};var s=1;if("color"in n){if(s=Math.max(0|n.color,0),0>s)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(s>1){if(!i)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(s>t.getParameter(i.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+s+" draw buffers")}}var l=t.UNSIGNED_BYTE,c=t.getExtension("OES_texture_float");if(n.float&&s>0){if(!c)throw new Error("gl-fbo: Context does not support floating point textures");l=t.FLOAT}else n.preferFloat&&s>0&&c&&(l=t.FLOAT);var f=!0;"depth"in n&&(f=!!n.depth);var h=!1;return"stencil"in n&&(h=!!n.stencil),new u(t,e,r,l,s,f,h,i)}var d=t("gl-texture2d");e.exports=h;var p,g,v,m,y=null,b=u.prototype;Object.defineProperties(b,{shape:{get:function(){return this._destroyed?[0,0]:this._shapeVector},set:function(t){if(Array.isArray(t)||(t=[0|t,0|t]),2!==t.length)throw new Error("gl-fbo: Shape vector must be length 2");var e=0|t[0],r=0|t[1];return f(this,e,r),[e,r]},enumerable:!1},width:{get:function(){return this._destroyed?0:this._shape[0]},set:function(t){return t=0|t,f(this,t,this._shape[1]),t},enumerable:!1},height:{get:function(){return this._destroyed?0:this._shape[1]},set:function(t){return t=0|t,f(this,this._shape[0],t),t},enumerable:!1}}),b.bind=function(){if(!this._destroyed){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,this.handle),t.viewport(0,0,this._shape[0],this._shape[1])}},b.dispose=function(){if(!this._destroyed){this._destroyed=!0;var t=this.gl;t.deleteFramebuffer(this.handle),this.handle=null,this.depth&&(this.depth.dispose(),this.depth=null),this._depth_rb&&(t.deleteRenderbuffer(this._depth_rb),this._depth_rb=null);for(var e=0;e2&&!this.usingDashes){var C=this.mitreShader;C.bind();var z=C.uniforms;z.matrix=t,z.color=s,z.screenShape=e,z.radius=l*p,C.attributes.p.pointer(f.FLOAT,!1,48,0),f.drawArrays(f.POINTS,0,u/3|0)}}}}(),h.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0],r=[0,0,0,0];return function(n){var i=this.plot,a=this.pickShader,o=this.lineBuffer,s=this.pickBuffer,l=this.width,c=this.numPoints,u=this.bounds,f=this.vertCount,h=i.gl,d=i.viewBox,p=i.dataBox,g=i.pickPixelRatio,v=u[2]-u[0],m=u[3]-u[1],y=p[2]-p[0],b=p[3]-p[1],x=d[2]-d[0],_=d[3]-d[1];if(this.pickOffset=n,!f)return n+c;t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(u[0]-p[0])/y-1,t[7]=2*(u[1]-p[1])/b-1,e[0]=x,e[1]=_,r[0]=255&n,r[1]=n>>>8&255,r[2]=n>>>16&255,r[3]=n>>>24,a.bind();var w=a.uniforms;w.matrix=t,w.width=l*g,w.pickOffset=r,w.screenShape=e;var k=a.attributes;return o.bind(),k.a.pointer(h.FLOAT,!1,16,0),k.d.pointer(h.FLOAT,!1,16,8),s.bind(),k.pick0.pointer(h.UNSIGNED_BYTE,!1,8,0),k.pick1.pointer(h.UNSIGNED_BYTE,!1,8,4),h.drawArrays(h.TRIANGLES,0,f),n+c}}(),h.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.data;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},h.update=function(t){t=t||{};var e=this.plot.gl;!!t.connectGaps;this.color=(t.color||[0,0,1,1]).slice(),this.width=+(t.width||1),this.fill=(t.fill||[!1,!1,!1,!1]).slice(),this.fillColor=i(t.fillColor||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]);for(var r=t.dashes||[1],n=0,a=0;a1,this.dashPattern=l(e,c(o,[n,1,4],[1,0,0])),this.dashPattern.minFilter=e.NEAREST,this.dashPattern.magFilter=e.NEAREST,this.dashLength=n,u.free(o);var d=t.positions;this.data=d;var p=this.bounds;p[0]=p[1]=1/0,p[2]=p[3]=-(1/0);var g=this.numPoints=d.length>>>1;if(0!==g){for(var a=0;g>a;++a){var v=d[2*a],m=d[2*a+1];isNaN(v)||isNaN(m)||(p[0]=Math.min(p[0],v),p[1]=Math.min(p[1],m),p[2]=Math.max(p[2],v),p[3]=Math.max(p[3],m))}p[0]===p[2]&&(p[2]+=1),p[3]===p[1]&&(p[3]+=1);for(var y=u.mallocFloat32(24*(g-1)),b=u.mallocUint32(12*(g-1)),x=y.length,_=b.length,s=g,w=0;s>1;){var k=--s,v=d[2*s],m=d[2*s+1],A=k-1,M=d[2*A],T=d[2*A+1];if(!(isNaN(v)||isNaN(m)||isNaN(M)||isNaN(T))){w+=1,v=(v-p[0])/(p[2]-p[0]),m=(m-p[1])/(p[3]-p[1]),M=(M-p[0])/(p[2]-p[0]),T=(T-p[1])/(p[3]-p[1]);var E=M-v,L=T-m,S=k|1<<24,C=k-1,z=k,P=k-1|1<<24;y[--x]=-L,y[--x]=-E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=-L,y[--x]=-E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=L,y[--x]=E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=-L,y[--x]=-E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C}}this.vertCount=6*w,this.lineBuffer.update(y.subarray(x)),this.pickBuffer.update(b.subarray(_)),u.free(y),u.free(b)}},h.dispose=function(){this.plot.removeObject(this),this.lineBuffer.dispose(),this.pickBuffer.dispose(),this.lineShader.dispose(),this.mitreShader.dispose(),this.fillShader.dispose(),this.pickShader.dispose(),this.dashPattern.dispose()}},{"./lib/shaders":83,"gl-buffer":77,"gl-shader":156,"gl-texture2d":181,ndarray:212,"typedarray-pool":237}],85:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, nextPosition;\nattribute float arcLength, lineWidth;\nattribute vec4 color;\n\nuniform vec2 screenShape;\nuniform float pixelRatio;\nuniform mat4 model, view, projection;\n\nvarying vec4 fragColor;\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\n\nvoid main() {\n vec4 projected = projection * view * model * vec4(position, 1.0);\n vec4 tangentClip = projection * view * model * vec4(nextPosition - position, 0.0);\n vec2 tangent = normalize(screenShape * tangentClip.xy);\n vec2 offset = 0.5 * pixelRatio * lineWidth * vec2(tangent.y, -tangent.x) / screenShape;\n\n gl_Position = vec4(projected.xy + projected.w * offset, projected.zw);\n\n worldPosition = position;\n pixelArcLength = arcLength;\n fragColor = color;\n}\n",a="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\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",o="precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1_0(highp float v) {\n highp 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 highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp 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 highp 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\n\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId/255.0, encode_float_1_0(pixelArcLength).xyz);\n}",s=[{ name:"position",type:"vec3"},{name:"nextPosition",type:"vec3"},{name:"arcLength",type:"float"},{name:"lineWidth",type:"float"},{name:"color",type:"vec4"}];r.createShader=function(t){return n(t,i,a,null,s)},r.createPickShader=function(t){return n(t,i,o,null,s)}},{"gl-shader":156}],86:[function(t,e,r){"use strict";function n(t,e){for(var r=0,n=0;3>n;++n){var i=t[n]-e[n];r+=i*i}return Math.sqrt(r)}function i(t){for(var e=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],r=0;3>r;++r)e[0][r]=Math.max(t[0][r],e[0][r]),e[1][r]=Math.min(t[1][r],e[1][r]);return e}function a(t,e,r,n){this.arcLength=t,this.position=e,this.index=r,this.dataCoordinate=n}function o(t,e,r,n,i,a){this.gl=t,this.shader=e,this.pickShader=r,this.buffer=n,this.vao=i,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.points=[],this.arcLength=[],this.vertexCount=0,this.bounds=[[0,0,0],[0,0,0]],this.pickId=0,this.lineWidth=1,this.texture=a,this.dashScale=1,this.opacity=1,this.dirty=!0,this.pixelRatio=1}function s(t){var e=t.gl||t.scene&&t.scene.gl,r=g(e);r.attributes.position.location=0,r.attributes.nextPosition.location=1,r.attributes.arcLength.location=2,r.attributes.lineWidth.location=3,r.attributes.color.location=4;var n=v(e);n.attributes.position.location=0,n.attributes.nextPosition.location=1,n.attributes.arcLength.location=2,n.attributes.lineWidth.location=3,n.attributes.color.location=4;for(var i=l(e),a=c(e,[{buffer:i,size:3,offset:0,stride:48},{buffer:i,size:3,offset:12,stride:48},{buffer:i,size:1,offset:24,stride:48},{buffer:i,size:1,offset:28,stride:48},{buffer:i,size:4,offset:32,stride:48}]),s=d(new Array(1024),[256,1,4]),f=0;1024>f;++f)s.data[f]=255;var h=u(e,s);h.wrap=e.REPEAT;var p=new o(e,r,n,i,a,h);return p.update(t),p}e.exports=s;var l=t("gl-buffer"),c=t("gl-vao"),u=t("gl-texture2d"),f=t("glsl-read-float"),h=t("binary-search-bounds"),d=t("ndarray"),p=t("./lib/shaders"),g=p.createShader,v=p.createPickShader,m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],y=o.prototype;y.isTransparent=function(){return this.opacity<1},y.isOpaque=function(){return this.opacity>=1},y.pickSlots=1,y.setPickBase=function(t){this.pickId=t},y.drawTransparent=y.draw=function(t){var e=this.gl,r=this.shader,n=this.vao;r.bind(),r.uniforms={model:t.model||m,view:t.view||m,projection:t.projection||m,clipBounds:i(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},y.drawPick=function(t){var e=this.gl,r=this.pickShader,n=this.vao;r.bind(),r.uniforms={model:t.model||m,view:t.view||m,projection:t.projection||m,pickId:this.pickId,clipBounds:i(this.clipBounds),screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},y.update=function(t){var e,r;this.dirty=!0;var i=!!t.connectGaps;"dashScale"in t&&(this.dashScale=t.dashScale),"opacity"in t&&(this.opacity=+t.opacity);var a=t.position||t.positions;if(a){var o=t.color||t.colors||[0,0,0,1],s=t.lineWidth||1,l=[],c=[],u=[],f=0,p=0,g=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],v=!1;t:for(e=1;er;++r){if(isNaN(m[r])||isNaN(y[r])||!isFinite(m[r])||!isFinite(y[r])){if(!i&&l.length>0){for(var b=0;24>b;++b)l.push(l[l.length-12]);p+=2,v=!0}continue t}g[0][r]=Math.min(g[0][r],m[r],y[r]),g[1][r]=Math.max(g[1][r],m[r],y[r])}var x,_;Array.isArray(o[0])?(x=o[e-1],_=o[e]):x=_=o,3===x.length&&(x=[x[0],x[1],x[2],1]),3===_.length&&(_=[_[0],_[1],_[2],1]);var w;w=Array.isArray(s)?s[e-1]:s;var k=f;if(f+=n(m,y),v){for(r=0;2>r;++r)l.push(m[0],m[1],m[2],y[0],y[1],y[2],k,w,x[0],x[1],x[2],x[3]);p+=2,v=!1}l.push(m[0],m[1],m[2],y[0],y[1],y[2],k,w,x[0],x[1],x[2],x[3],m[0],m[1],m[2],y[0],y[1],y[2],k,-w,x[0],x[1],x[2],x[3],y[0],y[1],y[2],m[0],m[1],m[2],f,-w,_[0],_[1],_[2],_[3],y[0],y[1],y[2],m[0],m[1],m[2],f,w,_[0],_[1],_[2],_[3]),p+=4}if(this.buffer.update(l),c.push(f),u.push(a[a.length-1].slice()),this.bounds=g,this.vertexCount=p,this.points=u,this.arcLength=c,"dashes"in t){var A=t.dashes,M=A.slice();for(M.unshift(0),e=1;ee;++e){for(r=0;4>r;++r)T.set(e,0,r,0);1&h.le(M,M[M.length-1]*e/255)?T.set(e,0,0,0):T.set(e,0,0,255)}this.texture.setPixels(T)}}},y.dispose=function(){this.shader.dispose(),this.vao.dispose(),this.buffer.dispose()},y.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=f(t.value[0],t.value[1],t.value[2],0),r=h.le(this.arcLength,e);if(0>r)return null;if(r===this.arcLength.length-1)return new a(this.arcLength[this.arcLength.length-1],this.points[this.points.length-1].slice(),r);for(var n=this.points[r],i=this.points[Math.min(r+1,this.points.length-1)],o=(e-this.arcLength[r])/(this.arcLength[r+1]-this.arcLength[r]),s=1-o,l=[0,0,0],c=0;3>c;++c)l[c]=s*n[c]+o*i[c];var u=Math.min(.5>o?r:r+1,this.points.length-1);return new a(e,l,u,this.points[u])}},{"./lib/shaders":85,"binary-search-bounds":87,"gl-buffer":77,"gl-texture2d":181,"gl-vao":185,"glsl-read-float":88,ndarray:212}],87:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],88:[function(t,e,r){function n(t,e,r,n){return i[0]=n,i[1]=r,i[2]=e,i[3]=t,a[0]}e.exports=n;var i=new Uint8Array(4),a=new Float32Array(i.buffer)},{}],89:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=u*o-s*c,h=-u*a+s*l,d=c*a-o*l,p=r*f+n*h+i*d;return p?(p=1/p,t[0]=f*p,t[1]=(-u*n+i*c)*p,t[2]=(s*n-i*o)*p,t[3]=h*p,t[4]=(u*r-i*l)*p,t[5]=(-s*r+i*a)*p,t[6]=d*p,t[7]=(-c*r+n*l)*p,t[8]=(o*r-n*a)*p,t):null}e.exports=n},{}],90:[function(t,e,r){function n(t){var e=new Float32Array(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}e.exports=n},{}],91:[function(t,e,r){function n(){var t=new Float32Array(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],92:[function(t,e,r){function n(t){var e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],c=t[8],u=t[9],f=t[10],h=t[11],d=t[12],p=t[13],g=t[14],v=t[15],m=e*o-r*a,y=e*s-n*a,b=e*l-i*a,x=r*s-n*o,_=r*l-i*o,w=n*l-i*s,k=c*p-u*d,A=c*g-f*d,M=c*v-h*d,T=u*g-f*p,E=u*v-h*p,L=f*v-h*g;return m*L-y*E+b*T+x*M-_*A+w*k}e.exports=n},{}],93:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r+r,s=n+n,l=i+i,c=r*o,u=n*o,f=n*s,h=i*o,d=i*s,p=i*l,g=a*o,v=a*s,m=a*l;return t[0]=1-f-p,t[1]=u+m,t[2]=h-v,t[3]=0,t[4]=u-m,t[5]=1-c-p,t[6]=d+g,t[7]=0,t[8]=h+v,t[9]=d-g,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],94:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=n+n,l=i+i,c=a+a,u=n*s,f=n*l,h=n*c,d=i*l,p=i*c,g=a*c,v=o*s,m=o*l,y=o*c;return t[0]=1-(d+g),t[1]=f+y,t[2]=h-m,t[3]=0,t[4]=f-y,t[5]=1-(u+g),t[6]=p+v,t[7]=0,t[8]=h+m,t[9]=p-v,t[10]=1-(u+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}e.exports=n},{}],95:[function(t,e,r){function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],96:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],g=e[13],v=e[14],m=e[15],y=r*s-n*o,b=r*l-i*o,x=r*c-a*o,_=n*l-i*s,w=n*c-a*s,k=i*c-a*l,A=u*g-f*p,M=u*v-h*p,T=u*m-d*p,E=f*v-h*g,L=f*m-d*g,S=h*m-d*v,C=y*S-b*L+x*E+_*T-w*M+k*A;return C?(C=1/C,t[0]=(s*S-l*L+c*E)*C,t[1]=(i*L-n*S-a*E)*C,t[2]=(g*k-v*w+m*_)*C,t[3]=(h*w-f*k-d*_)*C,t[4]=(l*T-o*S-c*M)*C,t[5]=(r*S-i*T+a*M)*C,t[6]=(v*x-p*k-m*b)*C,t[7]=(u*k-h*x+d*b)*C,t[8]=(o*L-s*T+c*A)*C,t[9]=(n*T-r*L-a*A)*C,t[10]=(p*w-g*x+m*y)*C,t[11]=(f*x-u*w-d*y)*C,t[12]=(s*M-o*E-l*A)*C,t[13]=(r*E-n*M+i*A)*C,t[14]=(g*b-p*_-v*y)*C,t[15]=(u*_-f*b+h*y)*C,t):null}e.exports=n},{}],97:[function(t,e,r){function n(t,e,r,n){var a,o,s,l,c,u,f,h,d,p,g=e[0],v=e[1],m=e[2],y=n[0],b=n[1],x=n[2],_=r[0],w=r[1],k=r[2];return Math.abs(g-_)<1e-6&&Math.abs(v-w)<1e-6&&Math.abs(m-k)<1e-6?i(t):(f=g-_,h=v-w,d=m-k,p=1/Math.sqrt(f*f+h*h+d*d),f*=p,h*=p,d*=p,a=b*d-x*h,o=x*f-y*d,s=y*h-b*f,p=Math.sqrt(a*a+o*o+s*s),p?(p=1/p,a*=p,o*=p,s*=p):(a=0,o=0,s=0),l=h*s-d*o,c=d*a-f*s,u=f*o-h*a,p=Math.sqrt(l*l+c*c+u*u),p?(p=1/p,l*=p,c*=p,u*=p):(l=0,c=0,u=0),t[0]=a,t[1]=l,t[2]=f,t[3]=0,t[4]=o,t[5]=c,t[6]=h,t[7]=0,t[8]=s,t[9]=u,t[10]=d,t[11]=0,t[12]=-(a*g+o*v+s*m),t[13]=-(l*g+c*v+u*m),t[14]=-(f*g+h*v+d*m),t[15]=1,t)}var i=t("./identity");e.exports=n},{"./identity":95}],98:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],g=e[12],v=e[13],m=e[14],y=e[15],b=r[0],x=r[1],_=r[2],w=r[3];return t[0]=b*n+x*s+_*f+w*g,t[1]=b*i+x*l+_*h+w*v,t[2]=b*a+x*c+_*d+w*m,t[3]=b*o+x*u+_*p+w*y,b=r[4],x=r[5],_=r[6],w=r[7],t[4]=b*n+x*s+_*f+w*g,t[5]=b*i+x*l+_*h+w*v,t[6]=b*a+x*c+_*d+w*m,t[7]=b*o+x*u+_*p+w*y,b=r[8],x=r[9],_=r[10],w=r[11],t[8]=b*n+x*s+_*f+w*g,t[9]=b*i+x*l+_*h+w*v,t[10]=b*a+x*c+_*d+w*m,t[11]=b*o+x*u+_*p+w*y,b=r[12],x=r[13],_=r[14],w=r[15],t[12]=b*n+x*s+_*f+w*g,t[13]=b*i+x*l+_*h+w*v,t[14]=b*a+x*c+_*d+w*m,t[15]=b*o+x*u+_*p+w*y,t}e.exports=n},{}],99:[function(t,e,r){function n(t,e,r,n,i){var a=1/Math.tan(e/2),o=1/(n-i);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+n)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*n*o,t[15]=0,t}e.exports=n},{}],100:[function(t,e,r){function n(t,e,r,n){var i,a,o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w,k,A,M,T,E,L=n[0],S=n[1],C=n[2],z=Math.sqrt(L*L+S*S+C*C);return Math.abs(z)<1e-6?null:(z=1/z,L*=z,S*=z,C*=z,i=Math.sin(r),a=Math.cos(r),o=1-a,s=e[0],l=e[1],c=e[2],u=e[3],f=e[4],h=e[5],d=e[6],p=e[7],g=e[8],v=e[9],m=e[10],y=e[11],b=L*L*o+a,x=S*L*o+C*i,_=C*L*o-S*i,w=L*S*o-C*i,k=S*S*o+a,A=C*S*o+L*i,M=L*C*o+S*i,T=S*C*o-L*i,E=C*C*o+a,t[0]=s*b+f*x+g*_,t[1]=l*b+h*x+v*_,t[2]=c*b+d*x+m*_,t[3]=u*b+p*x+y*_,t[4]=s*w+f*k+g*A,t[5]=l*w+h*k+v*A,t[6]=c*w+d*k+m*A,t[7]=u*w+p*k+y*A,t[8]=s*M+f*T+g*E,t[9]=l*M+h*T+v*E,t[10]=c*M+d*T+m*E,t[11]=u*M+p*T+y*E,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}e.exports=n},{}],101:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+c*n,t[5]=o*i+u*n,t[6]=s*i+f*n,t[7]=l*i+h*n,t[8]=c*i-a*n,t[9]=u*i-o*n,t[10]=f*i-s*n,t[11]=h*i-l*n,t}e.exports=n},{}],102:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i-c*n,t[1]=o*i-u*n,t[2]=s*i-f*n,t[3]=l*i-h*n,t[8]=a*n+c*i,t[9]=o*n+u*i,t[10]=s*n+f*i,t[11]=l*n+h*i,t}e.exports=n},{}],103:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[4],u=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+c*n,t[1]=o*i+u*n,t[2]=s*i+f*n,t[3]=l*i+h*n,t[4]=c*i-a*n,t[5]=u*i-o*n,t[6]=f*i-s*n,t[7]=h*i-l*n,t}e.exports=n},{}],104:[function(t,e,r){function n(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}e.exports=n},{}],105:[function(t,e,r){function n(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g=r[0],v=r[1],m=r[2];return e===t?(t[12]=e[0]*g+e[4]*v+e[8]*m+e[12],t[13]=e[1]*g+e[5]*v+e[9]*m+e[13],t[14]=e[2]*g+e[6]*v+e[10]*m+e[14],t[15]=e[3]*g+e[7]*v+e[11]*m+e[15]):(n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],t[0]=n,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=c,t[7]=u,t[8]=f,t[9]=h,t[10]=d,t[11]=p,t[12]=n*g+s*v+f*m+e[12],t[13]=i*g+l*v+h*m+e[13],t[14]=a*g+c*v+d*m+e[14],t[15]=o*g+u*v+p*m+e[15]),t}e.exports=n},{}],106:[function(t,e,r){function n(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],a=e[6],o=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=a,t[11]=e[14],t[12]=i,t[13]=o,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}e.exports=n},{}],107:[function(t,e,r){"use strict";function n(t,e){for(var r=[0,0,0,0],n=0;4>n;++n)for(var i=0;4>i;++i)r[i]+=t[4*n+i]*e[n];return r}function i(t,e,r,i,a){for(var o=n(i,n(r,n(e,[t[0],t[1],t[2],1]))),s=0;3>s;++s)o[s]/=o[3];return[.5*a[0]*(1+o[0]),.5*a[1]*(1-o[1])]}function a(t,e){if(2===t.length){for(var r=0,n=0,i=0;2>i;++i)r+=Math.pow(e[i]-t[0][i],2),n+=Math.pow(e[i]-t[1][i],2);return r=Math.sqrt(r),n=Math.sqrt(n),1e-6>r+n?[1,0]:[n/(r+n),r/(n+r)]}if(3===t.length){var a=[0,0];return c(t[0],t[1],t[2],e,a),l(t,a)}return[]}function o(t,e){for(var r=[0,0,0],n=0;no;++o)r[o]+=a*i[o];return r}function s(t,e,r,n,s,l){if(1===t.length)return[0,t[0].slice()];for(var c=new Array(t.length),u=0;up;++p)d+=Math.pow(c[u][p]-e[p],2);h>d&&(h=d,f=u)}for(var g=a(c,e),v=0,u=0;3>u;++u){if(g[u]<-.001||g[u]>1.0001)return null;v+=g[u]}return Math.abs(v-1)>.001?null:[f,o(t,g),g]}var l=t("barycentric"),c=t("polytope-closest-point/lib/closest_point_2d.js");e.exports=s},{barycentric:110,"polytope-closest-point/lib/closest_point_2d.js":112}],108:[function(t,e,r){var n="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\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\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}",i="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(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\n\n\nfloat cookTorranceSpecular_1_1(\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_2_0(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\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\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(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\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 = cookTorranceSpecular_1_1(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}",a="precision mediump 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}",o="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}",s="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(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}",l="precision mediump 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}",c="precision mediump 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}",u="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if(any(lessThan(f_position, clipBounds[0])) || \n any(greaterThan(f_position, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId, f_id.xyz);\n}",f="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(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}",h="precision mediump 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}",d="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n";r.meshShader={vertex:n,fragment:i,attributes:[{name:"position",type:"vec3"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.wireShader={vertex:a,fragment:o,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.pointShader={vertex:s,fragment:l,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]},r.pickShader={vertex:c,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]},r.pointPickShader={vertex:f,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]},r.contourShader={vertex:h,fragment:d,attributes:[{name:"position",type:"vec3"}]}},{}],109:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w,k,A,M,T){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleColors=u,this.triangleNormals=h,this.triangleUVs=f,this.triangleIds=c,this.triangleVAO=d,this.triangleCount=0,this.lineWidth=1,this.edgePositions=p,this.edgeColors=v,this.edgeUVs=m,this.edgeIds=g,this.edgeVAO=y,this.edgeCount=0,this.pointPositions=b,this.pointColors=_,this.pointUVs=w,this.pointSizes=k,this.pointIds=x,this.pointVAO=A,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=M,this.contourVAO=T,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!0,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this._model=R,this._view=R,this._projection=R,this._resolution=[1,1]}function i(t){for(var e=w({colormap:t,nshades:256,format:"rgba"}),r=new Uint8Array(1024),n=0;256>n;++n){for(var i=e[n],a=0;3>a;++a)r[4*n+a]=i[a];r[4*n+3]=255*i[3]}return _(r,[256,256,4],[4,0,1])}function a(t,e,r){for(var n=new Array(e),i=0;e>i;++i)n[i]=0;for(var a=t.length,i=0;a>i;++i)for(var o=t[i],s=0;sn;++n)r[n]=t[n][2];return r}function s(t){var e=p(t,E);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.normal.location=4,e}function l(t){var e=p(t,L);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e}function c(t){var e=p(t,S);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.pointSize.location=4,e}function u(t){var e=p(t,C);return e.attributes.position.location=0,e.attributes.id.location=1,e}function f(t){var e=p(t,z);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.pointSize.location=4,e}function h(t){var e=p(t,P);return e.attributes.position.location=0,e}function d(t){var e=t.gl,r=s(e),i=l(e),a=c(e),o=u(e),d=f(e),p=h(e),y=m(e,_(new Uint8Array([255,255,255,255]),[1,1,4]));y.generateMipmap(),y.minFilter=e.LINEAR_MIPMAP_LINEAR,y.magFilter=e.LINEAR;var b=g(e),x=g(e),w=g(e),k=g(e),A=g(e),M=v(e,[{buffer:b,type:e.FLOAT,size:3},{buffer:A,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:x,type:e.FLOAT,size:4},{buffer:w,type:e.FLOAT,size:2},{buffer:k,type:e.FLOAT,size:3}]),T=g(e),E=g(e),L=g(e),S=g(e),C=v(e,[{buffer:T,type:e.FLOAT,size:3},{buffer:S,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:E,type:e.FLOAT,size:4},{buffer:L,type:e.FLOAT,size:2}]),z=g(e),P=g(e),R=g(e),O=g(e),I=g(e),N=v(e,[{buffer:z,type:e.FLOAT,size:3},{buffer:I,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:P,type:e.FLOAT,size:4},{buffer:R,type:e.FLOAT,size:2},{buffer:O,type:e.FLOAT,size:1}]),j=g(e),F=v(e,[{buffer:j,type:e.FLOAT,size:3}]),D=new n(e,y,r,i,a,o,d,p,b,A,x,w,k,M,T,S,E,L,C,z,I,P,R,O,N,j,F);return D.update(t),D}var p=t("gl-shader"),g=t("gl-buffer"),v=t("gl-vao"),m=t("gl-texture2d"),y=t("normals"),b=t("gl-mat4/multiply"),x=t("gl-mat4/invert"),_=t("ndarray"),w=t("colormap"),k=t("simplicial-complex-contour"),A=t("typedarray-pool"),M=t("./lib/shaders"),T=t("./lib/closest-point"),E=M.meshShader,L=M.wireShader,S=M.pointShader,C=M.pickShader,z=M.pointPickShader,P=M.contourShader,R=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],O=n.prototype;O.isOpaque=function(){return this.opacity>=1},O.isTransparent=function(){return this.opacity<1},O.pickSlots=1,O.setPickBase=function(t){this.pickId=t},O.highlight=function(t){if(!t||!this.contourEnable)return void(this.contourCount=0);for(var e=k(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=A.mallocFloat32(6*a),s=0,l=0;a>l;++l)for(var c=r[l],u=0;2>u;++u){var f=c[0];2===c.length&&(f=c[u]);for(var h=n[f][0],d=n[f][1],p=i[f],g=1-p,v=this.positions[h],m=this.positions[d],y=0;3>y;++y)o[s++]=p*v[y]+g*m[y]}this.contourCount=s/3|0,this.contourPositions.update(o.subarray(0,s)),A.free(o)},O.update=function(t){t=t||{};var e=this.gl;this.dirty=!0,"contourEnable"in t&&(this.contourEnable=t.contourEnable),"contourColor"in t&&(this.contourColor=t.contourColor),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"opacity"in t&&(this.opacity=t.opacity),t.texture?(this.texture.dispose(),this.texture=m(e,t.texture)):t.colormap&&(this.texture.shape=[256,256],this.texture.minFilter=e.LINEAR_MIPMAP_LINEAR,this.texture.magFilter=e.LINEAR,this.texture.setPixels(i(t.colormap)),this.texture.generateMipmap());var r=t.cells,n=t.positions;if(n&&r){var s=[],l=[],c=[],u=[],f=[],h=[],d=[],p=[],g=[],v=[],b=[],x=[],_=[],w=[];this.cells=r,this.positions=n;var k=t.vertexNormals,A=t.cellNormals;t.useFacetNormals&&!A&&(A=y.faceNormals(r,n)),A||k||(k=y.vertexNormals(r,n));var M=t.vertexColors,T=t.cellColors,E=t.meshColor||[1,1,1,1],L=t.vertexUVs,S=t.vertexIntensity,C=t.cellUVs,z=t.cellIntensity,P=1/0,R=-(1/0);if(!L&&!C)if(S)for(var O=0;OD;++D)!isNaN(F[D])&&isFinite(F[D])&&(this.bounds[0][D]=Math.min(this.bounds[0][D],F[D]),this.bounds[1][D]=Math.max(this.bounds[1][D],F[D]));var B=0,U=0,V=0;t:for(var O=0;OD;++D)if(isNaN(F[D])||!isFinite(F[D]))continue t;v.push(F[0],F[1],F[2]);var G;G=M?M[H]:T?T[O]:E,3===G.length?b.push(G[0],G[1],G[2],1):b.push(G[0],G[1],G[2],G[3]);var Y;Y=L?L[H]:S?[(S[H]-P)/(R-P),0]:C?C[O]:z?[(z[O]-P)/(R-P),0]:[(F[2]-P)/(R-P),0],x.push(Y[0],Y[1]),N?_.push(N[H]):_.push(j),w.push(O),V+=1;break;case 2:for(var D=0;2>D;++D)for(var H=q[D],F=n[H],X=0;3>X;++X)if(isNaN(F[X])||!isFinite(F[X]))continue t;for(var D=0;2>D;++D){var H=q[D],F=n[H];h.push(F[0],F[1],F[2]);var G;G=M?M[H]:T?T[O]:E,3===G.length?d.push(G[0],G[1],G[2],1):d.push(G[0],G[1],G[2],G[3]);var Y;Y=L?L[H]:S?[(S[H]-P)/(R-P),0]:C?C[O]:z?[(z[O]-P)/(R-P),0]:[(F[2]-P)/(R-P),0],p.push(Y[0],Y[1]),g.push(O)}U+=1;break;case 3:for(var D=0;3>D;++D)for(var H=q[D],F=n[H],X=0;3>X;++X)if(isNaN(F[X])||!isFinite(F[X]))continue t;for(var D=0;3>D;++D){var H=q[D],F=n[H];s.push(F[0],F[1],F[2]);var G;G=M?M[H]:T?T[O]:E,3===G.length?l.push(G[0],G[1],G[2],1):l.push(G[0],G[1],G[2],G[3]);var Y;Y=L?L[H]:S?[(S[H]-P)/(R-P),0]:C?C[O]:z?[(z[O]-P)/(R-P),0]:[(F[2]-P)/(R-P),0],u.push(Y[0],Y[1]);var W;W=k?k[H]:A[O],c.push(W[0],W[1],W[2]),f.push(O)}B+=1}}this.pointCount=V,this.edgeCount=U,this.triangleCount=B,this.pointPositions.update(v),this.pointColors.update(b),this.pointUVs.update(x),this.pointSizes.update(_),this.pointIds.update(new Uint32Array(w)),this.edgePositions.update(h),this.edgeColors.update(d),this.edgeUVs.update(p),this.edgeIds.update(new Uint32Array(g)),this.trianglePositions.update(s),this.triangleColors.update(l),this.triangleUVs.update(u),this.triangleNormals.update(c),this.triangleIds.update(new Uint32Array(f))}},O.drawTransparent=O.draw=function(t){t=t||{};for(var e=this.gl,r=t.model||R,n=t.view||R,i=t.projection||R,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;3>o;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);var s={model:r,view:n,projection:i,clipBounds:a,kambient:this.ambientLight,kdiffuse:this.diffuseLight,kspecular:this.specularLight,roughness:this.roughness,fresnel:this.fresnel,eyePosition:[0,0,0],lightPosition:[0,0,0],opacity:this.opacity,contourColor:this.contourColor,texture:0};this.texture.bind(0);var l=new Array(16);b(l,s.view,s.model),b(l,s.projection,l),x(l,l);for(var o=0;3>o;++o)s.eyePosition[o]=l[12+o]/l[15];for(var c=l[15],o=0;3>o;++o)c+=this.lightPosition[o]*l[4*o+3];for(var o=0;3>o;++o){for(var u=l[12+o],f=0;3>f;++f)u+=l[4*f+o]*this.lightPosition[f];s.lightPosition[o]=u/c}if(this.triangleCount>0){var h=this.triShader;h.bind(),h.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()}if(this.edgeCount>0&&this.lineWidth>0){var h=this.lineShader;h.bind(),h.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()}if(this.pointCount>0){var h=this.pointShader;h.bind(),h.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}if(this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0){var h=this.contourShader;h.bind(),h.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind()}},O.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||R,n=t.view||R,i=t.projection||R,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;3>o;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s={model:r,view:n,projection:i,clipBounds:a,pickId:this.pickId/255},l=this.pickShader;if(l.bind(),l.uniforms=s,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0){var l=this.pointPickShader;l.bind(),l.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}},O.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;for(var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions,i=new Array(r.length),a=0;ao;++o){for(var s=new Array(r+1),l=0;r>=l;++l)s[l]=t[l][o];i[o]=s}i[r]=new Array(r+1);for(var o=0;r>=o;++o)i[r][o]=1;for(var c=new Array(r+1),o=0;r>o;++o)c[o]=e[o];c[r]=1;var u=a(i,c),f=n(u[r+1]);0===f&&(f=1);for(var h=new Array(r+1),o=0;r>=o;++o)h[o]=n(u[o])/f;return h}e.exports=i;var a=t("robust-linear-solve")},{"robust-linear-solve":215}],111:[function(t,e,r){var n=1e-6;r.vertexNormals=function(t,e){for(var r=e.length,i=new Array(r),a=0;r>a;++a)i[a]=[0,0,0];for(var a=0;ay;++y)p[y]=f[y]-h[y],g+=p[y]*p[y],v[y]=d[y]-h[y],m+=v[y]*v[y];if(g*m>n)for(var b=i[l],x=1/Math.sqrt(g*m),y=0;3>y;++y){var _=(y+1)%3,w=(y+2)%3;b[y]+=x*(v[_]*p[w]-v[w]*p[_])}}for(var a=0;r>a;++a){for(var b=i[a],k=0,y=0;3>y;++y)k+=b[y]*b[y];if(k>n)for(var x=1/Math.sqrt(k),y=0;3>y;++y)b[y]*=x;else for(var y=0;3>y;++y)b[y]=0}return i},r.faceNormals=function(t,e){for(var r=t.length,i=new Array(r),a=0;r>a;++a){for(var o=t[a],s=new Array(3),l=0;3>l;++l)s[l]=e[o[l]];for(var c=new Array(3),u=new Array(3),l=0;3>l;++l)c[l]=s[1][l]-s[0][l],u[l]=s[2][l]-s[0][l];for(var f=new Array(3),h=0,l=0;3>l;++l){var d=(l+1)%3,p=(l+2)%3;f[l]=c[d]*u[p]-c[p]*u[d],h+=f[l]*f[l]}h=h>n?1/Math.sqrt(h):0;for(var l=0;3>l;++l)f[l]*=h;i[a]=f}return i}},{}],112:[function(t,e,r){"use strict";function n(t,e,r,n,s){i.length=x+_)if(0>x)0>_&&0>h?(_=0,-h>=c?(x=1,y=c+2*h+p):(x=-h/c,y=h*x+p)):(x=0,d>=0?(_=0,y=p):-d>=f?(_=1,y=f+2*d+p):(_=-d/f,y=d*_+p));else if(0>_)_=0,h>=0?(x=0,y=p):-h>=c?(x=1,y=c+2*h+p):(x=-h/c,y=h*x+p);else{var w=1/b;x*=w,_*=w,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p}else{var k,A,M,T;0>x?(k=u+h,A=f+d,A>k?(M=A-k,T=c-2*u+f,M>=T?(x=1,_=0,y=c+2*h+p):(x=M/T,_=1-x,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)):(x=0,0>=A?(_=1,y=f+2*d+p):d>=0?(_=0,y=p):(_=-d/f,y=d*_+p))):0>_?(k=u+d,A=c+h,A>k?(M=A-k,T=c-2*u+f,M>=T?(_=1,x=0,y=f+2*d+p):(_=M/T,x=1-_,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)):(_=0,0>=A?(x=1,y=c+2*h+p):h>=0?(x=0,y=p):(x=-h/c,y=h*x+p))):(M=f+d-u-h,0>=M?(x=0,_=1,y=f+2*d+p):(T=c-2*u+f,M>=T?(x=1,_=0,y=c+2*h+p):(x=M/T,_=1-x,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)))}for(var E=1-x-_,l=0;ly?0:y}var i=new Float64Array(4),a=new Float64Array(4),o=new Float64Array(4);e.exports=n},{}],113:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=0,n=0;e>n;++n)r=0|Math.max(r,t[n].length);return r-1}function i(t,e){for(var r=t.length,n=f.mallocUint8(r),i=0;r>i;++i)n[i]=t[i]o;++o)for(var s=t[o],e=s.length,l=0;e>l;++l)for(var c=0;l>c;++c){var d=s[c],p=s[l];i[a++]=0|Math.min(d,p),i[a++]=0|Math.max(d,p)}var g=a/2|0;h(u(i,[g,2]));for(var v=2,o=2;a>o;o+=2)i[o-2]===i[o]&&i[o-1]===i[o+1]||(i[v++]=i[o],i[v++]=i[o+1]);return u(i,[v/2|0,2])}function o(t,e,r,n){for(var i=t.data,a=t.shape[0],o=f.mallocDouble(a),s=0,l=0;a>l;++l){var c=i[2*l],h=i[2*l+1];if(r[c]!==r[h]){var d=e[c],p=e[h];i[2*s]=c,i[2*s+1]=h,o[s++]=(p-n)/(p-d)}}return t.shape[0]=s,u(o,[s])}function s(t,e){var r=f.mallocInt32(2*e),n=t.shape[0],i=t.data;r[0]=0;for(var a=0,o=0;n>o;++o){var s=i[2*o];if(s!==a){for(r[2*a+1]=o;++ai;++i)n[i]=[r[2*i],r[2*i+1]];return n}function c(t,e,r,c){r=r||0,"undefined"==typeof c&&(c=n(t));var u=t.length;if(0===u||1>c)return{cells:[],vertexIds:[],vertexWeights:[]};var h=i(e,+r),p=a(t,c),g=o(p,e,h,+r),v=s(p,0|e.length),m=d(c)(t,p.data,v,h),y=l(p),b=[].slice.call(g.data,0,g.shape[0]);return f.free(h),f.free(p.data),f.free(g.data),f.free(v),{cells:m,vertexIds:y,vertexWeights:b}}e.exports=c;var u=t("ndarray"),f=t("typedarray-pool"),h=t("ndarray-sort"),d=t("./lib/codegen")},{"./lib/codegen":114,ndarray:212,"ndarray-sort":117,"typedarray-pool":237}],114:[function(t,e,r){"use strict";function n(t){function e(t){if(!(t.length<=0)){c.push("R.push(");for(var e=0;e0&&c.push(","),c.push("[");for(var n=0;n0&&c.push(","),c.push("B(C,E,c[",i[0],"],c[",i[1],"])")}c.push("]")}c.push(");")}}var r=0,n=new Array(t+1);n[0]=[[]];for(var i=1;t>=i;++i)for(var s=n[i]=o(i),l=0;l>1,v=E[2*m+1];","if(v===b){return m}","if(b1;--i){t+1>i&&c.push("else "),c.push("if(l===",i,"){");for(var u=[],l=0;i>l;++l)u.push("(S[c["+l+"]]<<"+l+")");c.push("var M=",u.join("+"),";if(M===0||M===",(1<i;++i)n[i]=0,i===e&&(n[i]+=.5),i===r&&(n[i]+=.5);return n}function i(t,e){if(0===e||e===(1<=a;++a)if(e&1<=s;++s)~e&1<n;++n)r[n]=i(t,n);return r}e.exports=a;var o=t("convex-hull")},{"convex-hull":61}],116:[function(t,e,r){"use strict";function n(t){switch(t){case"uint8":return[l.mallocUint8,l.freeUint8];case"uint16":return[l.mallocUint16,l.freeUint16];case"uint32":return[l.mallocUint32,l.freeUint32];case"int8":return[l.mallocInt8,l.freeInt8];case"int16":return[l.mallocInt16,l.freeInt16];case"int32":return[l.mallocInt32,l.freeInt32];case"float32":return[l.mallocFloat,l.freeFloat];case"float64":return[l.mallocDouble,l.freeDouble];default:return null}}function i(t){for(var e=[],r=0;t>r;++r)e.push("s"+r);for(var r=0;t>r;++r)e.push("n"+r);for(var r=1;t>r;++r)e.push("d"+r);for(var r=1;t>r;++r)e.push("e"+r);for(var r=1;t>r;++r)e.push("f"+r);return e}function a(t,e){function r(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function a(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}var o=["'use strict'"],s=["ndarrayInsertionSort",t.join("d"),e].join(""),l=["left","right","data","offset"].concat(i(t.length)),c=n(e),u=["i,j,cptr,ptr=left*s0+offset"];if(t.length>1){for(var f=[],h=1;h1){o.push("dptr=0;sptr=ptr");for(var h=t.length-1;h>=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"left){","dptr=0","sptr=cptr-s0");for(var h=1;hb){break __l}"].join(""));for(var h=t.length-1;h>=1;--h)o.push("sptr+=e"+h,"dptr+=f"+h,"}");o.push("dptr=cptr;sptr=cptr-s0");for(var h=t.length-1;h>=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"left)&&("+r("cptr-s0")+">scratch)){",a("cptr",r("cptr-s0")),"cptr-=s0","}",a("cptr","scratch"));if(o.push("}"),t.length>1&&c&&o.push("free(scratch)"),o.push("} return "+s),c){var p=new Function("malloc","free",o.join("\n"));return p(c[0],c[1])}var p=new Function(o.join("\n"));return p()}function o(t,e,r){function a(t){return["(offset+",t,"*s0)"].join("")}function o(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function s(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}function l(e,r,n){if(1===e.length)_.push("ptr0="+a(e[0]));else for(var i=0;i=0;--i){var o=t[i];0!==o&&_.push(["for(i",o,"=0;i",o,"1)for(var i=0;i1?_.push("ptr_shift+=d"+o):_.push("ptr0+=d"+o),_.push("}"))}}function u(e,r,n,i){if(1===r.length)_.push("ptr0="+a(r[0]));else{for(var o=0;o1)for(var o=0;o=1;--o)n&&_.push("pivot_ptr+=f"+o),r.length>1?_.push("ptr_shift+=e"+o):_.push("ptr0+=e"+o),_.push("}")}function f(){t.length>1&&A&&_.push("free(pivot1)","free(pivot2)")}function h(e,r){var n="el"+e,i="el"+r;if(t.length>1){var s="__l"+ ++M;u(s,[n,i],!1,["comp=",o("ptr0"),"-",o("ptr1"),"\n","if(comp>0){tmp0=",n,";",n,"=",i,";",i,"=tmp0;break ",s,"}\n","if(comp<0){break ",s,"}"].join(""))}else _.push(["if(",o(a(n)),">",o(a(i)),"){tmp0=",n,";",n,"=",i,";",i,"=tmp0}"].join(""))}function d(e,r){t.length>1?l([e,r],!1,s("ptr0",o("ptr1"))):_.push(s(a(e),o(a(r))))}function p(e,r,n){if(t.length>1){var i="__l"+ ++M;u(i,[r],!0,[e,"=",o("ptr0"),"-pivot",n,"[pivot_ptr]\n","if(",e,"!==0){break ",i,"}"].join(""))}else _.push([e,"=",o(a(r)),"-pivot",n].join(""))}function g(e,r){t.length>1?l([e,r],!1,["tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1","tmp")].join("")):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1","tmp")].join(""))}function v(e,r,n){t.length>1?(l([e,r,n],!1,["tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1",o("ptr2")),"\n",s("ptr2","tmp")].join("")),_.push("++"+r,"--"+n)):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","ptr2=",a(n),"\n","++",r,"\n","--",n,"\n","tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1",o("ptr2")),"\n",s("ptr2","tmp")].join(""))}function m(t,e){g(t,e),_.push("--"+e)}function y(e,r,n){t.length>1?l([e,r],!0,[s("ptr0",o("ptr1")),"\n",s("ptr1",["pivot",n,"[pivot_ptr]"].join(""))].join("")):_.push(s(a(e),o(a(r))),s(a(r),"pivot"+n))}function b(e,r){_.push(["if((",r,"-",e,")<=",c,"){\n","insertionSort(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}else{\n",w,"(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}"].join(""))}function x(e,r,n){t.length>1?(_.push(["__l",++M,":while(true){"].join("")),l([e],!0,["if(",o("ptr0"),"!==pivot",r,"[pivot_ptr]){break __l",M,"}"].join("")),_.push(n,"}")):_.push(["while(",o(a(e)),"===pivot",r,"){",n,"}"].join(""))}var _=["'use strict'"],w=["ndarrayQuickSort",t.join("d"),e].join(""),k=["left","right","data","offset"].concat(i(t.length)),A=n(e),M=0;_.push(["function ",w,"(",k.join(","),"){"].join(""));var T=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1=0","comp_pivot2=0","comp=0"];if(t.length>1){for(var E=[],L=1;LL;++L)T.push("b_ptr"+L);T.push("ptr3","ptr4","ptr5","ptr6","ptr7","pivot_ptr","ptr_shift","elementSize="+E.join("*")),A?T.push("pivot1=malloc(elementSize)","pivot2=malloc(elementSize)"):T.push("pivot1=new Array(elementSize),pivot2=new Array(elementSize)")}else T.push("pivot1","pivot2");if(_.push("var "+T.join(",")),h(1,2),h(4,5),h(1,3),h(2,3),h(1,4),h(3,4),h(2,5),h(2,3),h(4,5),t.length>1?l(["el1","el2","el3","el4","el5","index1","index3","index5"],!0,["pivot1[pivot_ptr]=",o("ptr1"),"\n","pivot2[pivot_ptr]=",o("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",o("ptr0"),"\n","y=",o("ptr2"),"\n","z=",o("ptr4"),"\n",s("ptr5","x"),"\n",s("ptr6","y"),"\n",s("ptr7","z")].join("")):_.push(["pivot1=",o(a("el2")),"\n","pivot2=",o(a("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",o(a("el1")),"\n","y=",o(a("el3")),"\n","z=",o(a("el5")),"\n",s(a("index1"),"x"),"\n",s(a("index3"),"y"),"\n",s(a("index5"),"z")].join("")),d("index2","left"),d("index4","right"),_.push("if(pivots_are_equal){"),_.push("for(k=less;k<=great;++k){"),p("comp","k",1),_.push("if(comp===0){continue}"),_.push("if(comp<0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),_.push("while(true){"),p("comp","great",1),_.push("if(comp>0){"),_.push("great--"),_.push("}else if(comp<0){"),v("k","less","great"),_.push("break"),_.push("}else{"),m("k","great"),_.push("break"),_.push("}"),_.push("}"),_.push("}"),_.push("}"),_.push("}else{"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1<0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2>0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp>0){"),_.push("if(--greatindex5){"),x("less",1,"++less"),x("great",2,"--great"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1===0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2===0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp===0){"),_.push("if(--great1&&A){var S=new Function("insertionSort","malloc","free",_.join("\n"));return S(r,A[0],A[1])}var S=new Function("insertionSort",_.join("\n"));return S(r)}function s(t,e){var r=["'use strict'"],n=["ndarraySortWrapper",t.join("d"),e].join(""),s=["array"];r.push(["function ",n,"(",s.join(","),"){"].join(""));for(var l=["data=array.data,offset=array.offset|0,shape=array.shape,stride=array.stride"],u=0;u0?l.push(["d",v,"=s",v,"-d",p,"*n",p].join("")):l.push(["d",v,"=s",v].join("")),p=v);var d=t.length-1-u;0!==d&&(g>0?l.push(["e",d,"=s",d,"-e",g,"*n",g,",f",d,"=",f[d],"-f",g,"*n",g].join("")):l.push(["e",d,"=s",d,",f",d,"=",f[d]].join("")),g=d)}r.push("var "+l.join(","));var m=["0","n0-1","data","offset"].concat(i(t.length));r.push(["if(n0<=",c,"){","insertionSort(",m.join(","),")}else{","quickSort(",m.join(","),")}"].join("")),r.push("}return "+n);var y=new Function("insertionSort","quickSort",r.join("\n")),b=a(t,e),x=o(t,e,b);return y(b,x)}var l=t("typedarray-pool"),c=32;e.exports=s},{"typedarray-pool":237}],117:[function(t,e,r){"use strict";function n(t){var e=t.order,r=t.dtype,n=[e,r],o=n.join(":"),s=a[o];return s||(a[o]=s=i(e,r)),s(t),t}var i=t("./lib/compile_sort.js"),a={};e.exports=n},{"./lib/compile_sort.js":116}],118:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[0,0,0,1,1,0,1,1]),i=o(e,s.boxVert,s.lineFrag);return new n(t,r,i)}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawBox=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o){var s=this.plot,l=this.shader,c=s.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,l.uniforms.lo=t,l.uniforms.hi=e,l.uniforms.color=o,c.drawArrays(c.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":121,"gl-buffer":77,"gl-shader":156}],119:[function(t,e,r){"use strict";function n(t,e,r,n){this.plot=t,this.vbo=e,this.shader=r,this.tickShader=n,this.ticks=[[],[]]}function i(t,e){return t-e}function a(t){var e=t.gl,r=o(e),i=s(e,c.gridVert,c.gridFrag),a=s(e,c.tickVert,c.gridFrag),l=new n(t,r,i,a);return l}e.exports=a;var o=t("gl-buffer"),s=t("gl-shader"),l=t("binary-search-bounds"),c=t("./shaders"),u=n.prototype;u.draw=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){for(var n=this.plot,i=this.vbo,a=this.shader,o=this.ticks,s=n.gl,l=n._tickBounds,c=n.dataBox,u=n.viewBox,f=n.gridLineWidth,h=n.gridLineColor,d=n.gridLineEnable,p=n.pixelRatio,g=0;2>g;++g){var v=l[g],m=l[g+2],y=m-v,b=.5*(c[g+2]+c[g]),x=c[g+2]-c[g];e[g]=2*y/x,t[g]=2*(v-b)/x}a.bind(),i.bind(),a.attributes.dataCoord.pointer(),a.uniforms.dataShift=t,a.uniforms.dataScale=e;for(var _=0,g=0;2>g;++g){r[0]=r[1]=0,r[g]=1,a.uniforms.dataAxis=r,a.uniforms.lineWidth=f[g]/(u[g+2]-u[g])*p,a.uniforms.color=h[g];var w=6*o[g].length;d[g]&&w&&s.drawArrays(s.TRIANGLES,_,w),_+=w}}}(),u.drawTickMarks=function(){var t=[0,0],e=[0,0],r=[1,0],n=[0,1],a=[0,0],o=[0,0];return function(){for(var s=this.plot,c=this.vbo,u=this.tickShader,f=this.ticks,h=s.gl,d=s._tickBounds,p=s.dataBox,g=s.viewBox,v=s.pixelRatio,m=s.screenBox,y=m[2]-m[0],b=m[3]-m[1],x=g[2]-g[0],_=g[3]-g[1],w=0;2>w;++w){var k=d[w],A=d[w+2],M=A-k,T=.5*(p[w+2]+p[w]),E=p[w+2]-p[w];e[w]=2*M/E,t[w]=2*(k-T)/E}e[0]*=x/y,t[0]*=x/y,e[1]*=_/b,t[1]*=_/b,u.bind(),c.bind(),u.attributes.dataCoord.pointer();var L=u.uniforms;L.dataShift=t,L.dataScale=e;var S=s.tickMarkLength,C=s.tickMarkWidth,z=s.tickMarkColor,P=0,R=6*f[0].length,O=Math.min(l.ge(f[0],(p[0]-d[0])/(d[2]-d[0]),i),f[0].length),I=Math.min(l.gt(f[0],(p[2]-d[0])/(d[2]-d[0]),i),f[0].length),N=P+6*O,j=6*Math.max(0,I-O),F=Math.min(l.ge(f[1],(p[1]-d[1])/(d[3]-d[1]),i),f[1].length),D=Math.min(l.gt(f[1],(p[3]-d[1])/(d[3]-d[1]),i),f[1].length),B=R+6*F,U=6*Math.max(0,D-F);a[0]=2*(g[0]-S[1])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[1]*v/y,o[1]=C[1]*v/b,U&&(L.color=z[1],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,B,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[1]-S[0])/b-1,o[0]=C[0]*v/y,o[1]=S[0]*v/b,j&&(L.color=z[0],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,N,j)),a[0]=2*(g[2]+S[3])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[3]*v/y,o[1]=C[3]*v/b,U&&(L.color=z[3],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,B,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[3]+S[2])/b-1,o[0]=C[2]*v/y,o[1]=S[2]*v/b,j&&(L.color=z[2],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,N,j))}}(),u.update=function(){var t=[1,1,-1,-1,1,-1],e=[1,-1,1,1,-1,-1];return function(r){for(var n=r.ticks,i=r.bounds,a=new Float32Array(18*(n[0].length+n[1].length)),o=(this.plot.zeroLineEnable,0),s=[[],[]],l=0;2>l;++l)for(var c=s[l],u=n[l],f=i[l],h=i[l+2],d=0;dg;++g)a[o++]=p,a[o++]=t[g],a[o++]=e[g]}this.ticks=s,this.vbo.update(a)}}(),u.dispose=function(){this.vbo.dispose(),this.shader.dispose(),this.tickShader.dispose()}},{"./shaders":121,"binary-search-bounds":123,"gl-buffer":77,"gl-shader":156}],120:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[-1,-1,-1,1,1,-1,1,1]),i=o(e,s.lineVert,s.lineFrag),l=new n(t,r,i);return l}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawLine=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o,s){var l=this.plot,c=this.shader,u=l.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,c.uniforms.start=t,c.uniforms.end=e,c.uniforms.width=o*l.pixelRatio,c.uniforms.color=s,u.drawArrays(u.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":121,"gl-buffer":77,"gl-shader":156}],121:[function(t,e,r){"use strict";var n="precision lowp float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = vec4(color.xyz * color.w, color.w);\n}\n";e.exports={lineVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 start, end;\nuniform float width;\n\nvec2 perp(vec2 v) {\n return vec2(v.y, -v.x);\n}\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n vec2 delta = normalize(perp(start - end));\n vec2 offset = mix(start, end, 0.5 * (coord.y+1.0));\n gl_Position = vec4(screen(offset + 0.5 * width * delta * coord.x), 0, 1);\n}\n",lineFrag:n,textVert:"#define GLSLIFY 1\nattribute vec3 textCoordinate;\n\nuniform vec2 dataScale, dataShift, dataAxis, screenOffset, textScale;\nuniform float angle;\n\nvoid main() {\n float dataOffset = textCoordinate.z;\n vec2 glyphOffset = textCoordinate.xy;\n mat2 glyphMatrix = mat2(cos(angle), sin(angle), -sin(angle), cos(angle));\n vec2 screenCoordinate = dataAxis * (dataScale * dataOffset + dataShift) +\n glyphMatrix * glyphOffset * textScale + screenOffset;\n gl_Position = vec4(screenCoordinate, 0, 1);\n}\n",textFrag:n,gridVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale;\nuniform float lineWidth;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n pos += 10.0 * dataCoord.y * vec2(dataAxis.y, -dataAxis.x) + dataCoord.z * lineWidth;\n gl_Position = vec4(pos, 0, 1);\n}\n",gridFrag:n,boxVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 lo, hi;\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n gl_Position = vec4(screen(mix(lo, hi, coord)), 0, 1);\n}\n",tickVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale, screenOffset, tickScale;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n gl_Position = vec4(pos + tickScale*dataCoord.yz + screenOffset, 0, 1);\n}\n"}},{}],122:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r,this.tickOffset=[[],[]],this.tickX=[[],[]],this.labelOffset=[0,0],this.labelCount=[0,0]}function i(t){var e=t.gl,r=a(e),i=o(e,c.textVert,c.textFrag),s=new n(t,r,i);return s}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("text-cache"),l=t("binary-search-bounds"),c=t("./shaders"),u=n.prototype;u.drawTicks=function(){var t=[0,0],e=[0,0],r=[0,0];return function(n){var i=this.plot,a=this.shader,o=this.tickX[n],s=this.tickOffset[n],c=i.gl,u=i.viewBox,f=i.dataBox,h=i.screenBox,d=i.pixelRatio,p=i.tickEnable,g=i.tickPad,v=i.tickColor,m=i.tickAngle,y=(i.tickMarkLength,i.labelEnable),b=i.labelPad,x=i.labelColor,_=i.labelAngle,w=this.labelOffset[n],k=this.labelCount[n],A=l.lt(o,f[n]),M=l.le(o,f[n+2]);t[0]=t[1]=0,t[n]=1,e[n]=(u[2+n]+u[n])/(h[2+n]-h[n])-1;var T=2/h[2+(1^n)]-h[1^n];e[1^n]=T*u[1^n]-1,p[n]&&(e[1^n]-=T*d*g[n],M>A&&s[M]>s[A]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n],a.uniforms.angle=m[n],c.drawArrays(c.TRIANGLES,s[A],s[M]-s[A]))),y[n]&&k&&(e[1^n]-=T*d*b[n],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n],a.uniforms.angle=_[n],c.drawArrays(c.TRIANGLES,w,k)),e[1^n]=T*u[2+(1^n)]-1,p[n+2]&&(e[1^n]+=T*d*g[n+2],M>A&&s[M]>s[A]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n+2],a.uniforms.angle=m[n+2],c.drawArrays(c.TRIANGLES,s[A],s[M]-s[A]))),y[n+2]&&k&&(e[1^n]+=T*d*b[n+2],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n+2],a.uniforms.angle=_[n+2],c.drawArrays(c.TRIANGLES,w,k))}}(),u.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,i=r.gl,a=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,o=r.titleCenter,c=r.pixelRatio;if(this.titleCount){for(var u=0;2>u;++u)e[u]=2*(o[u]*c-a[u])/(a[2+u]-a[u])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,i.drawArrays(i.TRIANGLES,this.titleOffset,this.titleCount)}}}(),u.bind=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){var n=this.plot,i=this.shader,a=n._tickBounds,o=n.dataBox,s=n.screenBox,l=n.viewBox;i.bind();for(var c=0;2>c;++c){var u=a[c],f=a[c+2],h=f-u,d=.5*(o[c+2]+o[c]),p=o[c+2]-o[c],g=l[c],v=l[c+2],m=v-g,y=s[c],b=s[c+2],x=b-y;e[c]=2*h/p*m/x,t[c]=2*(u-d)/p*m/x}r[1]=2*n.pixelRatio/(s[3]-s[1]),r[0]=r[1]*(s[3]-s[1])/(s[2]-s[0]),i.uniforms.dataScale=e,i.uniforms.dataShift=t,i.uniforms.textScale=r,this.vbo.bind(),i.attributes.textCoordinate.pointer()}}(),u.update=function(t){for(var e=[],r=t.ticks,n=t.bounds,i=0;2>i;++i){for(var a=[Math.floor(e.length/3)],o=[-(1/0)],l=r[i],c=0;ci;++i){this.labelOffset[i]=Math.floor(e.length/3);for(var g=s(t.labelFont[i],t.labels[i]).data,p=t.labelSize[i],c=0;c>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],124:[function(t,e,r){"use strict";function n(t,e){this.gl=t,this.pickBuffer=e,this.screenBox=[0,0,t.drawingBufferWidth,t.drawingBufferHeight],this.viewBox=[0,0,0,0],this.dataBox=[-10,-10,10,10],this.gridLineEnable=[!0,!0],this.gridLineWidth=[1,1],this.gridLineColor=[[0,0,0,1],[0,0,0,1]],this.pixelRatio=1,this.tickMarkLength=[0,0,0,0],this.tickMarkWidth=[0,0,0,0],this.tickMarkColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.tickPad=[15,15,15,15],this.tickAngle=[0,0,0,0],this.tickEnable=[!0,!0,!0,!0],this.tickColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.labelPad=[15,15,15,15],this.labelAngle=[0,Math.PI/2,0,3*Math.PI/2],this.labelEnable=[!0,!0,!0,!0],this.labelColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.titleCenter=[0,0],this.titleEnable=!0,this.titleAngle=0,this.titleColor=[0,0,0,1],this.borderColor=[0,0,0,0],this.backgroundColor=[0,0,0,0],this.zeroLineEnable=[!0,!0],this.zeroLineWidth=[4,4],this.zeroLineColor=[[0,0,0,1],[0,0,0,1]],this.borderLineEnable=[!0,!0,!0,!0],this.borderLineWidth=[2,2,2,2],this.borderLineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.grid=null,this.text=null,this.line=null,this.box=null,this.objects=[],this.overlays=[],this._tickBounds=[1/0,1/0,-(1/0),-(1/0)],this.dirty=!1,this.pickDirty=!1,this.pickDelay=120,this.pickRadius=10,this._pickTimeout=null,this._drawPick=this.drawPick.bind(this),this._depthCounter=0}function i(t){for(var e=t.slice(),r=0;rp;++p)if(f[p]&&n[p]<=0&&n[p+2]>=0){var g=e[p]-n[p]*(e[p+2]-e[p])/(n[p+2]-n[p]);0===p?o.drawLine(g,e[1],g,e[3],d[p],h[p]):o.drawLine(e[0],g,e[2],g,d[p],h[p])}}for(var p=0;pp;++p)s.drawTicks(p);this.titleEnable&&s.drawTitle();for(var b=this.overlays,p=0;pc;++c){var u=s[c].slice(0);0!==u.length&&(u.sort(a),l[c]=Math.min(l[c],u[0].x),l[c+2]=Math.max(l[c+2],u[u.length-1].x))}this.grid.update({bounds:l,ticks:s}),this.text.update({bounds:l,ticks:s,labels:t.labels||["x","y"],labelSize:t.labelSize||[12,12],labelFont:t.labelFont||["sans-serif","sans-serif"],title:t.title||"",titleSize:t.titleSize||18,titleFont:t.titleFont||"sans-serif"}),this.setDirty()},h.dispose=function(){this.box.dispose(),this.grid.dispose(),this.text.dispose(),this.line.dispose();for(var t=this.objects.length-1;t>=0;--t)this.objects[t].dispose();this.objects.length=0;for(var t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},h.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},h.removeObject=function(t){for(var e=this.objects,r=0;rh;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){return n.setMode(t),n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s=1/t.clientHeight,l=s*(r-d),u=s*(a-p),f=h.flipX?1:-1,g=h.flipY?1:-1,v=Math.PI*h.rotateSpeed,m=i();if(1&e)o.shift?n.rotate(m,0,0,-l*v):n.rotate(m,f*v*l,-g*v*u,0);else if(2&e)n.pan(m,-h.translateSpeed*l*c,h.translateSpeed*u*c,0);else if(4&e){var y=h.zoomSpeed*u/window.innerHeight*(m-n.lastT())*50;n.pan(m,0,0,c*(Math.exp(y)-1))}d=r,p=a}),s(t,function(t,e,r){var a=h.flipX?1:-1,o=h.flipY?1:-1,s=i();if(Math.abs(t)>Math.abs(e))n.rotate(s,0,0,-t*a*Math.PI*h.rotateSpeed/window.innerWidth);else{var l=h.zoomSpeed*o*e/window.innerHeight*(s-n.lastT())/100;n.pan(s,0,0,c*(Math.exp(l)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":39,"mouse-change":200,"mouse-wheel":204,"right-now":214}],127:[function(t,e,r){!function(){"use strict";function t(e){e.permitHostObjects___&&e.permitHostObjects___(t)}function r(t){return!(t.substr(0,d.length)==d&&"___"===t.substr(t.length-3))}function n(t){if(t!==Object(t))throw new TypeError("Not an object: "+t);var e=t[p];if(e&&e.key===t)return e;if(h(t)){e={key:t};try{return f(t,p,{value:e,writable:!1,enumerable:!1,configurable:!1}),e}catch(r){return}}}function i(t){return t.prototype=null,Object.freeze(t)}function a(){y||"undefined"==typeof console||(y=!0,console.warn("WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future."))}if("undefined"==typeof ses||!ses.ok||ses.ok()){"undefined"!=typeof ses&&(ses.weakMapPermitHostObjects=t);var o=!1;if("function"==typeof WeakMap){var s=WeakMap;if("undefined"!=typeof navigator&&/Firefox/.test(navigator.userAgent));else{var l=new s,c=Object.freeze({});if(l.set(c,1),1===l.get(c))return void(e.exports=WeakMap);o=!0}}var u=(Object.prototype.hasOwnProperty,Object.getOwnPropertyNames),f=Object.defineProperty,h=Object.isExtensible,d="weakmap:",p=d+"ident:"+Math.random()+"___";if("undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues&&"function"==typeof ArrayBuffer&&"function"==typeof Uint8Array){var g=new ArrayBuffer(25),v=new Uint8Array(g);crypto.getRandomValues(v),p=d+"rand:"+Array.prototype.map.call(v,function(t){return(t%36).toString(36)}).join("")+"___"}if(f(Object,"getOwnPropertyNames",{value:function(t){return u(t).filter(r)}}),"getPropertyNames"in Object){var m=Object.getPropertyNames;f(Object,"getPropertyNames",{value:function(t){return m(t).filter(r)}})}!function(){var t=Object.freeze;f(Object,"freeze",{value:function(e){return n(e),t(e)}});var e=Object.seal;f(Object,"seal",{value:function(t){return n(t),e(t)}});var r=Object.preventExtensions;f(Object,"preventExtensions",{value:function(t){return n(t),r(t)}})}();var y=!1,b=0,x=function(){function t(t,e){var r,i=n(t);return i?c in i?i[c]:e:(r=s.indexOf(t),r>=0?l[r]:e)}function e(t){var e=n(t);return e?c in e:s.indexOf(t)>=0}function r(t,e){var r,i=n(t);return i?i[c]=e:(r=s.indexOf(t),r>=0?l[r]=e:(r=s.length,l[r]=e,s[r]=t)),this}function o(t){var e,r,i=n(t);return i?c in i&&delete i[c]:(e=s.indexOf(t),0>e?!1:(r=s.length-1,s[e]=void 0,l[e]=l[r],s[e]=s[r],s.length=r,l.length=r,!0))}this instanceof x||a();var s=[],l=[],c=b++;return Object.create(x.prototype,{get___:{value:i(t)},has___:{value:i(e)},set___:{value:i(r)},delete___:{value:i(o)}})};x.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},"delete":{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof s?!function(){function r(){function e(t,e){return u?c.has(t)?c.get(t):u.get___(t,e):c.get(t,e)}function r(t){return c.has(t)||(u?u.has___(t):!1)}function n(t){var e=!!c.delete(t);return u?u.delete___(t)||e:e}this instanceof x||a();var l,c=new s,u=void 0,f=!1;return l=o?function(t,e){return c.set(t,e),c.has(t)||(u||(u=new x),u.set(t,e)),this}:function(t,e){if(f)try{c.set(t,e)}catch(r){u||(u=new x),u.set___(t,e)}else c.set(t,e);return this},Object.create(x.prototype,{get___:{value:i(e)},has___:{value:i(r)},set___:{value:i(l)},delete___:{value:i(n)},permitHostObjects___:{value:i(function(e){if(e!==t)throw new Error("bogus call to permitHostObjects___");f=!0})}})}o&&"undefined"!=typeof Proxy&&(Proxy=void 0),r.prototype=x.prototype,e.exports=r,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=x)}}()},{}],128:[function(t,e,r){"use strict";function n(t){var e=s.get(t);if(!e||!t.isBuffer(e._triangleBuffer.buffer)){var r=a(t,new Float32Array([-1,-1,-1,4,4,-1]));e=o(t,[{buffer:r,type:t.FLOAT,size:2}]),e._triangleBuffer=r,s.set(t,e)}e.bind(),t.drawArrays(t.TRIANGLES,0,3),e.unbind()}var i="undefined"==typeof WeakMap?t("weak-map"):WeakMap,a=t("gl-buffer"),o=t("gl-vao"),s=new i;e.exports=n},{"gl-buffer":77,"gl-vao":185,"weak-map":127}],129:[function(t,e,r){"use strict";function n(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function i(t){this.gl=t,this.pixelRatio=1,this.bounds=[[-10,-10,-10],[10,10,10]],this.ticks=[[],[],[]],this.autoTicks=!0,this.tickSpacing=[1,1,1],this.tickEnable=[!0,!0,!0],this.tickFont=["sans-serif","sans-serif","sans-serif"],this.tickSize=[12,12,12],this.tickAngle=[0,0,0],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=[!0,!0,!0],this.labelFont="sans-serif",this.labelSize=[20,20,20],this.labelAngle=[0,0,0],this.labelColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.labelPad=[10,10,10],this.lineEnable=[!0,!0,!0],this.lineMirror=[!1,!1,!1],this.lineWidth=[1,1,1],this.lineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.lineTickEnable=[!0,!0,!0],this.lineTickMirror=[!1,!1,!1],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=[!0,!0,!0],this.gridWidth=[1,1,1],this.gridColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.zeroEnable=[!0,!0,!0],this.zeroLineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.zeroLineWidth=[2,2,2],this.backgroundEnable=[!1,!1,!1],this.backgroundColor=[[.8,.8,.8,.5],[.8,.8,.8,.5],[.8,.8,.8,.5]],this._firstInit=!0,this._text=null,this._lines=null,this._background=u(t)}function a(){this.primalOffset=[0,0,0],this.primalMinor=[0,0,0],this.mirrorOffset=[0,0,0],this.mirrorMinor=[0,0,0]}function o(t,e,r,n,i){for(var a=t.primalOffset,o=t.primalMinor,s=t.mirrorOffset,l=t.mirrorMinor,c=n[e],u=0;3>u;++u)if(e!==u){var f=a,h=s,d=o,p=l;c&1<0?(d[u]=-1,p[u]=0):(d[u]=0,p[u]=1)}}function s(t,e){var r=new i(t);return r.update(e),r}e.exports=s;var l=t("./lib/text.js"),c=t("./lib/lines.js"),u=t("./lib/background.js"),f=t("./lib/cube.js"),h=t("./lib/ticks.js"),d=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),p=i.prototype;p.update=function(t){function e(e,r,n){if(n in t){var i,a=t[n],o=this[n];(e?Array.isArray(a)&&Array.isArray(a[0]):Array.isArray(a))?this[n]=i=[r(a[0]),r(a[1]),r(a[2])]:this[n]=i=[r(a),r(a),r(a)];for(var s=0;3>s;++s)if(i[s]!==o[s])return!0}return!1}t=t||{};var r,n=e.bind(this,!1,Number),i=e.bind(this,!1,Boolean),a=e.bind(this,!1,String),o=e.bind(this,!0,function(t){if(Array.isArray(t)){if(3===t.length)return[+t[0],+t[1],+t[2],1];if(4===t.length)return[+t[0],+t[1],+t[2],+t[3]]}return[0,0,0,1]}),s=!1,u=!1;if("bounds"in t)for(var f=t.bounds,d=0;2>d;++d)for(var p=0;3>p;++p)f[d][p]!==this.bounds[d][p]&&(u=!0),this.bounds[d][p]=f[d][p];if("ticks"in t){r=t.ticks,s=!0,this.autoTicks=!1;for(var d=0;3>d;++d)this.tickSpacing[d]=0}else n("tickSpacing")&&(this.autoTicks=!0,u=!0);if(this._firstInit&&("ticks"in t||"tickSpacing"in t||(this.autoTicks=!0),u=!0,s=!0,this._firstInit=!1),u&&this.autoTicks&&(r=h.create(this.bounds,this.tickSpacing),s=!0),s){for(var d=0;3>d;++d)r[d].sort(function(t,e){return t.x-e.x});h.equal(r,this.ticks)?s=!1:this.ticks=r}i("tickEnable"),a("tickFont")&&(s=!0),n("tickSize"),n("tickAngle"),n("tickPad"),o("tickColor");var g=a("labels");a("labelFont")&&(g=!0),i("labelEnable"),n("labelSize"),n("labelPad"),o("labelColor"),i("lineEnable"),i("lineMirror"),n("lineWidth"),o("lineColor"),i("lineTickEnable"),i("lineTickMirror"),n("lineTickLength"),n("lineTickWidth"),o("lineTickColor"),i("gridEnable"),n("gridWidth"),o("gridColor"),i("zeroEnable"),o("zeroLineColor"),n("zeroLineWidth"),i("backgroundEnable"),o("backgroundColor"),this._text?this._text&&(g||s)&&this._text.update(this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont):this._text=l(this.gl,this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont),this._lines&&s&&(this._lines.dispose(),this._lines=null),this._lines||(this._lines=c(this.gl,this.bounds,this.ticks))};var g=[new a,new a,new a],v=[0,0,0],m={model:d,view:d,projection:d};p.isOpaque=function(){return!0},p.isTransparent=function(){return!1},p.drawTransparent=function(t){};var y=[0,0,0],b=[0,0,0],x=[0,0,0];p.draw=function(t){t=t||m;for(var e=this.gl,r=t.model||d,i=t.view||d,a=t.projection||d,s=this.bounds,l=f(r,i,a,s),c=l.cubeEdges,u=l.axis,h=i[12],p=i[13],_=i[14],w=i[15],k=this.pixelRatio*(a[3]*h+a[7]*p+a[11]*_+a[15]*w)/e.drawingBufferHeight,A=0;3>A;++A)this.lastCubeProps.cubeEdges[A]=c[A],this.lastCubeProps.axis[A]=u[A];for(var M=g,A=0;3>A;++A)o(g[A],A,this.bounds,c,u);for(var e=this.gl,T=v,A=0;3>A;++A)this.backgroundEnable[A]?T[A]=u[A]:T[A]=0;this._background.draw(r,i,a,s,T,this.backgroundColor),this._lines.bind(r,i,a,this);for(var A=0;3>A;++A){var E=[0,0,0];u[A]>0?E[A]=s[1][A]:E[A]=s[0][A];for(var L=0;2>L;++L){var S=(A+1+L)%3,C=(A+1+(1^L))%3;this.gridEnable[S]&&this._lines.drawGrid(S,C,this.bounds,E,this.gridColor[S],this.gridWidth[S]*this.pixelRatio)}for(var L=0;2>L;++L){var S=(A+1+L)%3,C=(A+1+(1^L))%3;this.zeroEnable[C]&&s[0][C]<=0&&s[1][C]>=0&&this._lines.drawZero(S,C,this.bounds,E,this.zeroLineColor[C],this.zeroLineWidth[C]*this.pixelRatio)}}for(var A=0;3>A;++A){this.lineEnable[A]&&this._lines.drawAxisLine(A,this.bounds,M[A].primalOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio),this.lineMirror[A]&&this._lines.drawAxisLine(A,this.bounds,M[A].mirrorOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio);for(var z=n(y,M[A].primalMinor),P=n(b,M[A].mirrorMinor),R=this.lineTickLength,L=0;3>L;++L){var O=k/r[5*L];z[L]*=R[L]*O,P[L]*=R[L]*O}this.lineTickEnable[A]&&this._lines.drawAxisTicks(A,M[A].primalOffset,z,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio),this.lineTickMirror[A]&&this._lines.drawAxisTicks(A,M[A].mirrorOffset,P,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio)}this._text.bind(r,i,a,this.pixelRatio);for(var A=0;3>A;++A){for(var I=M[A].primalMinor,N=n(x,M[A].primalOffset),L=0;3>L;++L)this.lineTickEnable[A]&&(N[L]+=k*I[L]*Math.max(this.lineTickLength[L],0)/r[5*L]);if(this.tickEnable[A]){for(var L=0;3>L;++L)N[L]+=k*I[L]*this.tickPad[L]/r[5*L];this._text.drawTicks(A,this.tickSize[A],this.tickAngle[A],N,this.tickColor[A])}if(this.labelEnable[A]){for(var L=0;3>L;++L)N[L]+=k*I[L]*this.labelPad[L]/r[5*L];N[A]+=.5*(s[0][A]+s[1][A]),this._text.drawLabel(A,this.labelSize[A],this.labelAngle[A],N,this.labelColor[A])}}},p.dispose=function(){this._text.dispose(),this._lines.dispose(),this._background.dispose(),this._lines=null,this._text=null,this._background=null,this.gl=null}},{"./lib/background.js":130,"./lib/cube.js":131,"./lib/lines.js":132,"./lib/text.js":134,"./lib/ticks.js":135}],130:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n}function i(t){for(var e=[],r=[],i=0,l=0;3>l;++l)for(var c=(l+1)%3,u=(l+2)%3,f=[0,0,0],h=[0,0,0],d=-1;1>=d;d+=2){r.push(i,i+2,i+1,i+1,i+2,i+3),f[l]=d,h[l]=d;for(var p=-1;1>=p;p+=2){f[c]=p;for(var g=-1;1>=g;g+=2)f[u]=g,e.push(f[0],f[1],f[2],h[0],h[1],h[2]),i+=1}var v=c;c=u,u=v}var m=a(t,new Float32Array(e)),y=a(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),b=o(t,[{buffer:m,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:m,type:t.FLOAT,size:3,offset:12,stride:24}],y),x=s(t);return x.attributes.position.location=0,x.attributes.normal.location=1,new n(t,m,b,x)}e.exports=i;var a=t("gl-buffer"),o=t("gl-vao"),s=t("./shaders").bg,l=n.prototype;l.draw=function(t,e,r,n,i,a){for(var o=!1,s=0;3>s;++s)o=o||i[s];if(o){var l=this.gl;l.enable(l.POLYGON_OFFSET_FILL),l.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:t,view:e,projection:r,bounds:n,enable:i,colors:a},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),l.disable(l.POLYGON_OFFSET_FILL)}},l.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders":133,"gl-buffer":77,"gl-vao":185}],131:[function(t,e,r){"use strict";function n(t,e,r){for(var n=0;4>n;++n){t[n]=r[12+n];for(var i=0;3>i;++i)t[n]+=e[i]*r[4*i+n]}}function i(t){for(var e=0;eg;++g){d[2]=a[g][2];for(var b=0;2>b;++b){d[1]=a[b][1];for(var x=0;2>x;++x)d[0]=a[x][0],n(f[l],d,u),l+=1}}for(var _=-1,g=0;8>g;++g){for(var w=f[g][3],k=0;3>k;++k)h[g][k]=f[g][k]/w;0>w&&(0>_?_=g:h[g][2]_){_=0;for(var A=0;3>A;++A){for(var M=(A+2)%3,T=(A+1)%3,E=-1,L=-1,S=0;2>S;++S){var C=S<E||0>L)L>E&&(_|=1<S;++S){var C=S<E&&(_|=1<g;++g)g!==_&&g!==O&&(0>I?I=g:h[I][1]>h[g][1]&&(I=g));for(var N=-1,g=0;3>g;++g){var j=I^1<N&&(N=j);var T=h[j];T[0]g;++g){var j=I^1<F&&(F=j);var T=h[j];T[0]>h[F][0]&&(F=j)}}var D=v;D[0]=D[1]=D[2]=0,D[o.log2(N^I)]=I&N,D[o.log2(I^F)]=I&F;var B=7^F;B===_||B===O?(B=7^N,D[o.log2(F^B)]=B&F):D[o.log2(N^B)]=B&N;for(var U=m,V=_,A=0;3>A;++A)V&1<t;++t)f[t]=[1,1,1,1],h[t]=[1,1,1]}();var g=[[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]],v=[1,1,1],m=[0,0,0],y={cubeEdges:v,axis:m}},{"bit-twiddle":50,"gl-mat4/invert":96,"gl-mat4/multiply":98,"robust-orientation":218,"split-polygon":137}],132:[function(t,e,r){"use strict";function n(t){return t[0]=t[1]=t[2]=0,t}function i(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function a(t,e,r,n,i,a,o,s){this.gl=t,this.vertBuffer=e,this.vao=r,this.shader=n,this.tickCount=i,this.tickOffset=a,this.gridCount=o,this.gridOffset=s}function o(t,e,r){var n=[],i=[0,0,0],o=[0,0,0],u=[0,0,0],f=[0,0,0];n.push(0,0,1,0,1,1,0,0,-1,0,0,-1,0,1,1,0,1,-1);for(var h=0;3>h;++h){for(var d=n.length/3|0,p=0;ph;++h)for(var p=u[h],g=2;g>=0;--g){var v=c[p[g]];s.push(l*v[0],-l*v[1],t)}}for(var s=(this.gl,[]),l=[0,0,0],c=[0,0,0],u=[0,0,0],d=[0,0,0],p=0;3>p;++p){u[p]=s.length/h|0,o(.5*(t[0][p]+t[1][p]),e[p],r),d[p]=(s.length/h|0)-u[p],l[p]=s.length/h|0;for(var g=0;g=0&&(i=r.length-n-1);var a=Math.pow(10,i),o=Math.round(t*e*a),s=o+"";if(s.indexOf("e")>=0)return s;var l=o/a,c=o%a;0>o?(l=0|-Math.ceil(l),c=0|-c):(l=0|Math.floor(l),c=0|c);var u=""+l;if(0>o&&(u="-"+u),i){for(var f=""+c;f.lengthi;++i){for(var a=[],o=(.5*(t[0][i]+t[1][i]),0);o*e[i]<=t[1][i];++o)a.push({x:o*e[i],text:n(e[i],o)});for(var o=-1;o*e[i]>=t[0][i];--o)a.push({x:o*e[i],text:n(e[i],o)});r.push(a)}return r}function a(t,e){for(var r=0;3>r;++r){if(t[r].length!==e[r].length)return!1;for(var n=0;na?a=0:a>1&&(a=1);for(var o=1-a,s=t.length,l=new Array(s),c=0;s>c;++c)l[c]=a*t[c]+o*r[c];return l}function a(t,e){for(var r=[],a=[],o=n(t[t.length-1],e),s=t[t.length-1],l=t[0],c=0;co&&u>0||o>0&&0>u){var f=i(s,u,l,o);r.push(f),a.push(f.slice())}0>u?a.push(l.slice()):u>0?r.push(l.slice()):(r.push(l.slice()),a.push(l.slice())),o=u}return{positive:r,negative:a}}function o(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;la&&c>0||a>0&&0>c)&&r.push(i(o,c,s,a)),c>=0&&r.push(s.slice()),a=c}return r}function s(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;la&&c>0||a>0&&0>c)&&r.push(i(o,c,s,a)),0>=c&&r.push(s.slice()),a=c}return r}var l=t("robust-dot-product"),c=t("robust-sum");e.exports=a,e.exports.positive=o,e.exports.negative=s},{"robust-dot-product":138,"robust-sum":221}],138:[function(t,e,r){"use strict";function n(t,e){for(var r=i(t[0],e[0]),n=1;na;++a){for(var o=p,s=g,l=0;3>l;++l)s[l]=o[l]=r[l];s[3]=o[3]=1,s[a]+=1,f(s,s,e),s[3]<0&&(t[a]=1/0),o[a]-=1,f(o,o,e),o[3]<0&&(t[a]=1/0);var c=(o[0]/o[3]-s[0]/s[3])*n,u=(o[1]/o[3]-s[1]/s[3])*i;t[a]=.25*Math.sqrt(c*c+u*u)}return t}function a(t,e,r,n,a){var f=e.model||h,p=e.view||h,g=e.projection||h,y=t.bounds,a=a||l(f,p,g,y),b=a.axis;a.edges;c(d,p,f),c(d,g,d);for(var x=v,_=0;3>_;++_)x[_].lo=1/0,x[_].hi=-(1/0),x[_].pixelsPerDataUnit=1/0;var w=o(u(d,d));u(d,d);for(var k=0;3>k;++k){var A=(k+1)%3,M=(k+2)%3,T=m;t:for(var _=0;2>_;++_){var E=[];if(b[k]<0!=!!_){T[k]=y[_][k];for(var L=0;2>L;++L){T[A]=y[L^_][A];for(var S=0;2>S;++S)T[M]=y[S^L^_][M],E.push(T.slice())}for(var L=0;LS;++S)x[S].lo=Math.min(x[S].lo,M[S]),x[S].hi=Math.max(x[S].hi,M[S]),S!==k&&(x[S].pixelsPerDataUnit=Math.min(x[S].pixelsPerDataUnit,Math.abs(C[S])))}}}return x}e.exports=a;var o=t("extract-frustum-planes"),s=t("split-polygon"),l=t("./lib/cube.js"),c=t("gl-mat4/multiply"),u=t("gl-mat4/transpose"),f=t("gl-vec4/transformMat4"),h=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),d=new Float32Array(16),p=[0,0,0,1],g=[0,0,0,1],v=[new n(1/0,-(1/0),1/0),new n(1/0,-(1/0),1/0),new n(1/0,-(1/0),1/0)],m=[0,0,0]},{"./lib/cube.js":131,"extract-frustum-planes":136,"gl-mat4/multiply":98,"gl-mat4/transpose":106,"gl-vec4/transformMat4":186,"split-polygon":137}],140:[function(t,e,r){"use strict";var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, color;\nattribute float weight;\n\nuniform mat4 model, view, projection;\nuniform vec3 coordinates[3];\nuniform vec4 colors[3];\nuniform vec2 screenShape;\nuniform float lineWidth;\n\nvarying vec4 fragColor;\n\nvoid main() {\n vec3 vertexPosition = mix(coordinates[0],\n mix(coordinates[2], coordinates[1], 0.5 * (position + 1.0)), abs(position));\n\n vec4 clipPos = projection * view * model * vec4(vertexPosition, 1.0);\n vec2 clipOffset = (projection * view * model * vec4(color, 0.0)).xy;\n vec2 delta = weight * clipOffset * screenShape;\n vec2 lineOffset = normalize(vec2(delta.y, -delta.x)) / screenShape;\n\n gl_Position = vec4(clipPos.xy + clipPos.w * 0.5 * lineWidth * lineOffset, clipPos.z, clipPos.w);\n fragColor = color.x * colors[0] + color.y * colors[1] + color.z * colors[2];\n}\n",a="precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}";e.exports=function(t){return n(t,i,a,null,[{name:"position",type:"vec3"},{name:"color",type:"vec3"},{name:"weight",type:"float"}])}},{"gl-shader":156}],141:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n,this.pixelRatio=1,this.bounds=[[-1e3,-1e3,-1e3],[1e3,1e3,1e3]],this.position=[0,0,0],this.lineWidth=[2,2,2],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.enabled=[!0,!0,!0],this.drawSides=[!0,!0,!0],this.axes=null}function i(t,e){function r(t,e,r,n,a,o){var s=[t,e,r,0,0,0,1];s[n+3]=1,s[n]=a,i.push.apply(i,s),s[6]=-1,i.push.apply(i,s),s[n]=o,i.push.apply(i,s),i.push.apply(i,s),s[6]=1,i.push.apply(i,s),s[n]=a,i.push.apply(i,s)}var i=[];r(0,0,0,0,0,1),r(0,0,0,1,0,1),r(0,0,0,2,0,1),r(1,0,0,1,-1,1),r(1,0,0,2,-1,1),r(0,1,0,0,-1,1),r(0,1,0,2,-1,1),r(0,0,1,0,-1,1),r(0,0,1,1,-1,1);var l=a(t,i),c=o(t,[{type:t.FLOAT,buffer:l,size:3,offset:0,stride:28},{type:t.FLOAT,buffer:l,size:3,offset:12,stride:28},{type:t.FLOAT,buffer:l,size:1,offset:24,stride:28}]),u=s(t);u.attributes.position.location=0,u.attributes.color.location=1,u.attributes.weight.location=2;var f=new n(t,l,c,u);return f.update(e),f}var a=t("gl-buffer"),o=t("gl-vao"),s=t("./shaders/index");e.exports=i;var l=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],c=n.prototype,u=[0,0,0],f=[0,0,0],h=[0,0];c.isTransparent=function(){return!1},c.drawTransparent=function(t){},c.draw=function(t){var e=this.gl,r=this.vao,n=this.shader;r.bind(),n.bind();var i,a=t.model||l,o=t.view||l,s=t.projection||l;this.axes&&(i=this.axes.lastCubeProps.axis);for(var c=u,d=f,p=0;3>p;++p)i&&i[p]<0?(c[p]=this.bounds[0][p],d[p]=this.bounds[1][p]):(c[p]=this.bounds[1][p],d[p]=this.bounds[0][p]);h[0]=e.drawingBufferWidth,h[1]=e.drawingBufferHeight,n.uniforms.model=a,n.uniforms.view=o,n.uniforms.projection=s,n.uniforms.coordinates=[this.position,c,d],n.uniforms.colors=this.colors,n.uniforms.screenShape=h;for(var p=0;3>p;++p)n.uniforms.lineWidth=this.lineWidth[p]*this.pixelRatio,this.enabled[p]&&(r.draw(e.TRIANGLES,6,6*p),this.drawSides[p]&&r.draw(e.TRIANGLES,12,18+12*p));r.unbind()},c.update=function(t){t&&("bounds"in t&&(this.bounds=t.bounds),"position"in t&&(this.position=t.position),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"colors"in t&&(this.colors=t.colors),"enabled"in t&&(this.enabled=t.enabled),"drawSides"in t&&(this.drawSides=t.drawSides))},c.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders/index":140,"gl-buffer":77,"gl-vao":185}],142:[function(t,e,r){"use strict";function n(){this.mouse=[-1,-1],this.screen=null,this.distance=1/0,this.index=null,this.dataCoordinate=null,this.dataPosition=null,this.object=null,this.data=null}function i(t,e){var r=null;try{r=t.getContext("webgl",e),r||(r=t.getContext("experimental-webgl",e))}catch(n){return null}return r}function a(t){var e=Math.round(Math.log(Math.abs(t))/Math.log(10));if(0>e){var r=Math.round(Math.pow(10,-e));return Math.ceil(t*r)/r}if(e>0){var r=Math.round(Math.pow(10,e));return Math.ceil(t/r)*r}return Math.ceil(t)}function o(t){return"boolean"==typeof t?t:!0}function s(t){function e(){if(!_&&H.autoResize){var t=w.parentNode,e=1,r=1;t&&t!==document.body?(e=t.clientWidth,r=t.clientHeight):(e=window.innerWidth,r=window.innerHeight);var n=0|Math.ceil(e*H.pixelRatio),i=0|Math.ceil(r*H.pixelRatio);if(n!==w.width||i!==w.height){w.width=n,w.height=i;var a=w.style;a.position=a.position||"absolute",a.left="0px",a.top="0px",a.width=e+"px",a.height=r+"px",F=!0}}}function r(){for(var t=O.length,e=j.length,r=0;e>r;++r)N[r]=0;t:for(var r=0;t>r;++r){var n=O[r],i=n.pickSlots;if(i){for(var a=0;e>a;++a)if(N[a]+i<255){I[r]=a,n.setPickBase(N[a]+1),N[a]+=i;continue t}var o=h(A,q);I[r]=e,j.push(o),N.push(i),n.setPickBase(1),e+=1}else I[r]=-1}for(;e>0&&0===N[e-1];)N.pop(),j.pop().dispose()}function s(){return H.contextLost?!0:void(A.isContextLost()&&(H.contextLost=!0,H.mouseListener.enabled=!1,H.selection.object=null,H.oncontextloss&&H.oncontextloss()))}function y(){if(!s()){A.colorMask(!0,!0,!0,!0),A.depthMask(!0),A.disable(A.BLEND),A.enable(A.DEPTH_TEST);for(var t=O.length,e=j.length,r=0;e>r;++r){var n=j[r];n.shape=G,n.begin();for(var i=0;t>i;++i)if(I[i]===r){var a=O[i];a.drawPick&&(a.pixelRatio=1,a.drawPick(V))}n.end()}}}function b(){if(!s()){e();var t=H.camera.tick();V.view=H.camera.matrix,F=F||t,D=D||t,z.pixelRatio=H.pixelRatio,R.pixelRatio=H.pixelRatio;var r=O.length,n=W[0],i=W[1];n[0]=n[1]=n[2]=1/0,i[0]=i[1]=i[2]=-(1/0);for(var o=0;r>o;++o){var l=O[o];l.pixelRatio=H.pixelRatio,l.axes=H.axes,F=F||!!l.dirty,D=D||!!l.dirty;var c=l.bounds;if(c)for(var f=c[0],h=c[1],d=0;3>d;++d)n[d]=Math.min(n[d],f[d]),i[d]=Math.max(i[d],h[d])}var g=H.bounds;if(H.autoBounds)for(var d=0;3>d;++d){if(i[d]d;++d)b=b||Z[0][d]!==g[0][d]||Z[1][d]!==g[1][d],Z[0][d]=g[0][d],Z[1][d]=g[1][d];if(b){for(var x=[0,0,0],o=0;3>o;++o)x[o]=a((g[1][o]-g[0][o])/10);z.autoTicks?z.update({bounds:g,tickSpacing:x}):z.update({bounds:g})}D=D||b,F=F||b;var _=A.drawingBufferWidth,w=A.drawingBufferHeight;q[0]=_,q[1]=w,G[0]=0|Math.max(_/H.pixelRatio,1),G[1]=0|Math.max(w/H.pixelRatio,1),v(B,H.fovy,_/w,H.zNear,H.zFar);for(var o=0;16>o;++o)U[o]=0;U[15]=1;for(var k=0,o=0;3>o;++o)k=Math.max(k,g[1][o]-g[0][o]);for(var o=0;3>o;++o)H.autoScale?U[5*o]=H.aspect[o]/(g[1][o]-g[0][o]):U[5*o]=1/k,H.autoCenter&&(U[12+o]=.5*-U[5*o]*(g[0][o]+g[1][o]));for(var o=0;r>o;++o){var l=O[o];l.axesBounds=g,H.clipToBounds&&(l.clipBounds=g)}if(T.object&&(H.snapToData?R.position=T.dataCoordinate:R.position=T.dataPosition,R.bounds=g),D&&(D=!1,y()),F){H.axesPixels=u(H.axes,V,_,w),H.onrender&&H.onrender(),A.bindFramebuffer(A.FRAMEBUFFER,null),A.viewport(0,0,_,w);var M=H.clearColor;A.clearColor(M[0],M[1],M[2],M[3]),A.clear(A.COLOR_BUFFER_BIT|A.DEPTH_BUFFER_BIT),A.depthMask(!0),A.colorMask(!0,!0,!0,!0),A.enable(A.DEPTH_TEST),A.depthFunc(A.LEQUAL),A.disable(A.BLEND),A.disable(A.CULL_FACE);var S=!1;z.enable&&(S=S||z.isTransparent(),z.draw(V)),R.axes=z,T.object&&R.draw(V),A.disable(A.CULL_FACE);for(var o=0;r>o;++o){var l=O[o];l.axes=z,l.pixelRatio=H.pixelRatio,l.isOpaque&&l.isOpaque()&&l.draw(V),l.isTransparent&&l.isTransparent()&&(S=!0)}if(S){E.shape=q,E.bind(),A.clear(A.DEPTH_BUFFER_BIT),A.colorMask(!1,!1,!1,!1),A.depthMask(!0),A.depthFunc(A.LESS),z.enable&&z.isTransparent()&&z.drawTransparent(V);for(var o=0;r>o;++o){var l=O[o];l.isOpaque&&l.isOpaque()&&l.draw(V)}A.enable(A.BLEND),A.blendEquation(A.FUNC_ADD),A.blendFunc(A.ONE,A.ONE_MINUS_SRC_ALPHA),A.colorMask(!0,!0,!0,!0),A.depthMask(!1),A.clearColor(0,0,0,0),A.clear(A.COLOR_BUFFER_BIT),z.isTransparent()&&z.drawTransparent(V);for(var o=0;r>o;++o){var l=O[o];l.isTransparent&&l.isTransparent()&&l.drawTransparent(V)}A.bindFramebuffer(A.FRAMEBUFFER,null),A.blendFunc(A.ONE,A.ONE_MINUS_SRC_ALPHA),A.disable(A.DEPTH_TEST),L.bind(),E.color[0].bind(0),L.uniforms.accumBuffer=0,p(A),A.disable(A.BLEND)}F=!1;for(var o=0;r>o;++o)O[o].dirty=!1}}}function x(){_||H.contextLost||(requestAnimationFrame(x),b())}t=t||{};var _=!1,w=(t.pixelRatio||parseFloat(window.devicePixelRatio),t.canvas);if(!w)if(w=document.createElement("canvas"),t.container){var k=t.container;k.appendChild(w)}else document.body.appendChild(w);var A=t.gl;if(A||(A=i(w,t.glOptions||{premultipliedAlpha:!0,antialias:!0})),!A)throw new Error("webgl not supported");var M=t.bounds||[[-10,-10,-10],[10,10,10]],T=new n,E=d(A,[A.drawingBufferWidth,A.drawingBufferHeight],{preferFloat:!0}),L=m(A),S=t.camera||{eye:[2,0,0],center:[0,0,0],up:[0,1,0],zoomMin:.1,zoomMax:100,mode:"turntable"},C=t.axes||{},z=c(A,C);z.enable=!C.disable;var P=t.spikes||{},R=f(A,P),O=[],I=[],N=[],j=[],F=!0,D=!0,B=new Array(16),U=new Array(16),V={view:null,projection:B,model:U},D=!0,q=[A.drawingBufferWidth,A.drawingBufferHeight],H={gl:A,contextLost:!1,pixelRatio:t.pixelRatio||parseFloat(window.devicePixelRatio),canvas:w,selection:T,camera:l(w,S),axes:z,axesPixels:null,spikes:R,bounds:M,objects:O,shape:q,aspect:t.aspectRatio||[1,1,1],pickRadius:t.pickRadius||10,zNear:t.zNear||.01,zFar:t.zFar||1e3,fovy:t.fovy||Math.PI/4,clearColor:t.clearColor||[0,0,0,0],autoResize:o(t.autoResize),autoBounds:o(t.autoBounds),autoScale:!!t.autoScale,autoCenter:o(t.autoCenter),clipToBounds:o(t.clipToBounds),snapToData:!!t.snapToData,onselect:t.onselect||null,onrender:t.onrender||null,onclick:t.onclick||null,cameraParams:V,oncontextloss:null,mouseListener:null},G=[A.drawingBufferWidth/H.pixelRatio|0,A.drawingBufferHeight/H.pixelRatio|0];H.autoResize&&e(),window.addEventListener("resize",e),H.update=function(t){_||(t=t||{},F=!0,D=!0)},H.add=function(t){_||(t.axes=z,O.push(t),I.push(-1),F=!0,D=!0,r())},H.remove=function(t){if(!_){var e=O.indexOf(t);0>e||(O.splice(e,1),I.pop(),F=!0,D=!0,r())}},H.dispose=function(){if(!_&&(_=!0,window.removeEventListener("resize",e),w.removeEventListener("webglcontextlost",s),H.mouseListener.enabled=!1,!H.contextLost)){z.dispose(),R.dispose();for(var t=0;ts;++s){var l=j[s].query(e,G[1]-r-1,H.pickRadius);if(l){if(l.distance>T.distance)continue;for(var c=0;i>c;++c){var u=O[c];if(I[c]===s){var f=u.pick(l);f&&(T.buttons=t,T.screen=l.coord,T.distance=l.distance,T.object=u,T.index=f.distance,T.dataPosition=f.position,T.dataCoordinate=f.dataCoordinate,T.data=f,o=!0)}}}}}a&&a!==T.object&&(a.highlight&&a.highlight(null),F=!0),T.object&&(T.object.highlight&&T.object.highlight(T.data),F=!0),o=o||T.object!==a,o&&H.onselect&&H.onselect(T),1&t&&!(1&X)&&H.onclick&&H.onclick(T),X=t}}),w.addEventListener("webglcontextlost",s);var W=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],Z=[W[0].slice(),W[1].slice()];return x(),H.redraw=function(){_||(F=!0,b())},H}e.exports=s;var l=t("3d-view-controls"),c=t("gl-axes3d"),u=t("gl-axes3d/properties"),f=t("gl-spikes3d"),h=t("gl-select-static"),d=t("gl-fbo"),p=t("a-big-triangle"),g=t("mouse-change"),v=t("gl-mat4/perspective"),m=t("./lib/shader")},{"./lib/shader":125,"3d-view-controls":126,"a-big-triangle":128,"gl-axes3d":129,"gl-axes3d/properties":139,"gl-fbo":82,"gl-mat4/perspective":99,"gl-select-static":155,"gl-spikes3d":141,"mouse-change":200}],143:[function(t,e,r){"use strict";e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n fragColor = color;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n",fragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n}\n",pickVertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 id;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\nuniform vec4 pickOffset;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n vec4 fragId = id + pickOffset;\n\n fragId.y += floor(fragId.x / 256.0);\n fragId.x -= floor(fragId.x / 256.0) * 256.0;\n\n fragId.z += floor(fragId.y / 256.0);\n fragId.y -= floor(fragId.y / 256.0) * 256.0;\n\n fragId.w += floor(fragId.z / 256.0);\n fragId.z -= floor(fragId.z / 256.0) * 256.0;\n\n fragColor = fragId / 255.0;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n",pickFragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = fragColor;\n}\n"}},{}],144:[function(t,e,r){"use strict";function n(t){if(t in h)return h[t];var e=u(t,{polygons:!0,font:"sans-serif",textAlign:"left",textBaseline:"alphabetic"}),r=[],n=[];e.forEach(function(t){t.forEach(function(t){for(var e=0;eo;++o)i[o]=Math.min(i[o],r[a+o]),i[2+o]=Math.max(i[2+o],r[a+o]);return h[t]={coords:r,normals:n,bounds:i}}function i(t,e,r,n,i,a,o){this.plot=t,this.shader=e,this.pickShader=r,this.positionBuffer=n,this.offsetBuffer=i,this.colorBuffer=a,this.idBuffer=o,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.numVertices=0,this.pickOffset=0,this.points=null}function a(t,e){var r=t.gl,n=o(r,f.vertex,f.fragment),a=o(r,f.pickVertex,f.pickFragment),l=s(r),c=s(r),u=s(r),h=s(r),d=new i(t,n,a,l,c,u,h);return d.update(e),t.addObject(d),d}e.exports=a;var o=t("gl-shader"),s=t("gl-buffer"),l=t("text-cache"),c=t("typedarray-pool"),u=t("vectorize-text"),f=t("./lib/shaders"),h={},d=i.prototype;!function(){function t(){var t=this.plot,n=this.bounds,i=t.viewBox,a=t.dataBox,o=t.pixelRatio,s=n[2]-n[0],l=n[3]-n[1],c=a[2]-a[0],u=a[3]-a[1];e[0]=2*s/c,e[4]=2*l/u,e[6]=2*(n[0]-a[0])/c-1,e[7]=2*(n[1]-a[1])/u-1;var f=i[2]-i[0],h=i[3]-i[1];r[0]=2*o/f,r[1]=2*o/h}var e=[1,0,0,0,1,0,0,0,1],r=[1,1];d.draw=function(){var n=this.plot,i=this.shader,a=this.numVertices;if(a){var o=n.gl;t.call(this),i.bind(),i.uniforms.pixelScale=r,i.uniforms.viewTransform=e,this.positionBuffer.bind(),i.attributes.position.pointer(),this.offsetBuffer.bind(),i.attributes.offset.pointer(),this.colorBuffer.bind(),i.attributes.color.pointer(o.UNSIGNED_BYTE,!0),o.drawArrays(o.TRIANGLES,0,a)}};var n=[0,0,0,0];d.drawPick=function(i){var a=this.plot,o=this.pickShader,s=this.numVertices,l=a.gl;if(this.pickOffset=i,!s)return i;for(var c=0;4>c;++c)n[c]=i>>8*c&255;return t.call(this),o.bind(),o.uniforms.pixelScale=r,o.uniforms.viewTransform=e,o.uniforms.pickOffset=n,this.positionBuffer.bind(),o.attributes.position.pointer(),this.offsetBuffer.bind(),o.attributes.offset.pointer(),this.idBuffer.bind(),o.attributes.id.pointer(l.UNSIGNED_BYTE,!1),l.drawArrays(l.TRIANGLES,0,s),i+this.numPoints}}(),d.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},d.update=function(t){t=t||{};var e=t.positions||[],r=t.colors||[],i=t.glyphs||[],a=t.sizes||[],o=t.borderWidths||[],s=t.borderColors||[];this.points=e;for(var u=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=0,h=0;h>1;for(var d=0;2>d;++d)u[d]=Math.min(u[d],e[2*h+d]),u[2+d]=Math.max(u[2+d],e[2*h+d])}u[0]===u[2]&&(u[2]+=1),u[3]===u[1]&&(u[3]+=1);for(var p=1/(u[2]-u[0]),g=1/(u[3]-u[1]),v=u[0],m=u[1],y=c.mallocFloat32(2*f),b=c.mallocFloat32(2*f),x=c.mallocUint8(4*f),_=c.mallocUint32(f),w=0,h=0;h=a?i(0,a-1,t,e,r,n):f(0,a-1,t,e,r,n)}function i(t,e,r,n,i,a){for(var o=t+1;e>=o;++o){for(var s=r[o],l=n[2*o],c=n[2*o+1],u=i[o],f=a[o],h=o;h>t;){var d=r[h-1],p=n[2*(h-1)];if((d-s||l-p)>=0)break;r[h]=d,n[2*h]=p,n[2*h+1]=n[2*h-1],i[h]=i[h-1],a[h]=a[h-1],h-=1}r[h]=s,n[2*h]=l,n[2*h+1]=c,i[h]=u,a[h]=f}}function a(t,e,r,n,i,a){var o=r[t],s=n[2*t],l=n[2*t+1],c=i[t],u=a[t];r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e],r[e]=o,n[2*e]=s,n[2*e+1]=l,i[e]=c,a[e]=u}function o(t,e,r,n,i,a){r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e]}function s(t,e,r,n,i,a,o){var s=n[t],l=i[2*t],c=i[2*t+1],u=a[t],f=o[t];n[t]=n[e],i[2*t]=i[2*e],i[2*t+1]=i[2*e+1],a[t]=a[e],o[t]=o[e],n[e]=n[r],i[2*e]=i[2*r],i[2*e+1]=i[2*r+1],a[e]=a[r],o[e]=o[r],n[r]=s,i[2*r]=l,i[2*r+1]=c,a[r]=u,o[r]=f}function l(t,e,r,n,i,a,o,s,l,c,u){s[t]=s[e],l[2*t]=l[2*e],l[2*t+1]=l[2*e+1],c[t]=c[e],u[t]=u[e],s[e]=r,l[2*e]=n,l[2*e+1]=i,c[e]=a,u[e]=o}function c(t,e,r,n,i){return(r[t]-r[e]||n[2*e]-n[2*t]||i[t]-i[e])<0}function u(t,e,r,n,i,a,o,s){return(e-a[t]||o[2*t]-r||i-s[t])<0}function f(t,e,r,n,d,p){var g=(e-t+1)/6|0,v=t+g,m=e-g,y=t+e>>1,b=y-g,x=y+g,_=v,w=b,k=y,A=x,M=m,T=t+1,E=e-1,L=0;c(_,w,r,n,d,p)&&(L=_,_=w,w=L),c(A,M,r,n,d,p)&&(L=A,A=M,M=L),c(_,k,r,n,d,p)&&(L=_,_=k,k=L),c(w,k,r,n,d,p)&&(L=w,w=k,k=L),c(_,A,r,n,d,p)&&(L=_,_=A,A=L),c(k,A,r,n,d,p)&&(L=k,k=A,A=L),c(w,M,r,n,d,p)&&(L=w,w=M,M=L),c(w,k,r,n,d,p)&&(L=w,w=k,k=L),c(A,M,r,n,d,p)&&(L=A,A=M,M=L);var S=r[w],C=n[2*w],z=n[2*w+1],P=d[w],R=p[w],O=r[A],I=n[2*A],N=n[2*A+1],j=d[A],F=p[A],D=_,B=k,U=M,V=v,q=y,H=m,G=r[D],Y=r[B],X=r[U];r[V]=G,r[q]=Y,r[H]=X;for(var W=0;2>W;++W){var Z=n[2*D+W],K=n[2*B+W],Q=n[2*U+W];n[2*V+W]=Z,n[2*q+W]=K,n[2*H+W]=Q}var $=d[D],J=d[B],tt=d[U];d[V]=$,d[q]=J,d[H]=tt;var et=p[D],rt=p[B],nt=p[U];p[V]=et,p[q]=rt,p[H]=nt,o(b,t,r,n,d,p),o(x,e,r,n,d,p);for(var it=T;E>=it;++it)if(u(it,S,C,z,P,r,n,d))it!==T&&a(it,T,r,n,d,p),++T;else if(!u(it,O,I,N,j,r,n,d))for(;;){if(u(E,O,I,N,j,r,n,d)){u(E,S,C,z,P,r,n,d)?(s(it,T,E,r,n,d,p),++T,--E):(a(it,E,r,n,d,p),--E);break}if(--E=T-2-t?i(t,T-2,r,n,d,p):f(t,T-2,r,n,d,p),h>=e-(E+2)?i(E+2,e,r,n,d,p):f(E+2,e,r,n,d,p),h>=E-T?i(T,E,r,n,d,p):f(T,E,r,n,d,p)}e.exports=n;var h=32},{}],148:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s){for(var l=r,c=r;n>c;++c){var u=t[2*c],f=t[2*c+1],h=e[c];u>=i&&o>=u&&f>=a&&s>=f&&(c===l?l+=1:(t[2*c]=t[2*l],t[2*c+1]=t[2*l+1],e[c]=e[l],t[2*l]=u,t[2*l+1]=f,e[l]=h,l+=1))}return l}function i(t,e,r){this.pixelSize=t,this.offset=e,this.count=r}function a(t,e,r,a){function l(i,a,o,s,c,u){var f=.5*o,h=s+1,d=c-s;r[_]=d,x[_++]=u;for(var p=0;2>p;++p)for(var g=0;2>g;++g){var v=i+p*f,m=a+g*f,y=n(t,e,h,c,v,m,v+f,m+f);if(y!==h){if(y-h>=Math.max(.9*d,32)){var b=c+s>>>1;l(v,m,f,h,b,u+1),h=b}l(v,m,f,h,y,u+1),h=y}}}var c=t.length>>>1;if(1>c)return[];for(var u=1/0,f=1/0,h=-(1/0),d=-(1/0),p=0;c>p;++p){var g=t[2*p],v=t[2*p+1];u=Math.min(u,g),h=Math.max(h,g),f=Math.min(f,v),d=Math.max(d,v),e[p]=p}u===h&&(h+=1+Math.abs(h)),f===d&&(d+=1+Math.abs(h));var m=1/(h-u),y=1/(d-f),b=Math.max(h-u,d-f);a=a||[0,0,0,0],a[0]=u,a[1]=f,a[2]=h,a[3]=d;var x=o.mallocInt32(c),_=0;l(u,f,b,0,c,0),s(x,t,e,r,c);for(var w=[],k=0,A=c,_=c-1;_>=0;--_){t[2*_]=(t[2*_]-u)*m,t[2*_+1]=(t[2*_+1]-f)*y;var M=x[_];M!==k&&(w.push(new i(b*Math.pow(.5,M),_+1,A-(_+1))),A=_+1,k=M)}return w.push(new i(b*Math.pow(.5,M+1),0,A)),o.free(x),w}var o=t("typedarray-pool"),s=t("./lib/sort");e.exports=a},{"./lib/sort":147,"typedarray-pool":237}],149:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.weightBuffer=n,this.shader=i,this.pickShader=a,this.scales=[],this.size=12,this.borderSize=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.pickOffset=0,this.points=null,this.xCoords=null}function i(t,e){var r=t.gl,i=o(r),s=o(r),l=o(r),c=a(r,u.pointVertex,u.pointFragment),f=a(r,u.pickVertex,u.pickFragment),h=new n(t,i,s,l,c,f);return h.update(e),t.addObject(h),h}var a=t("gl-shader"),o=t("gl-buffer"),s=t("binary-search-bounds"),l=t("snap-points-2d"),c=t("typedarray-pool"),u=t("./lib/shader");e.exports=i;var f=n.prototype;f.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.xCoords&&c.free(this.xCoords),this.plot.removeObject(this)},f.update=function(t){function e(e,r){return e in t?t[e]:r}t=t||{},this.size=e("size",12),this.color=e("color",[1,0,0,1]).slice(),this.borderSize=e("borderSize",1),this.borderColor=e("borderColor",[0,0,0,1]).slice(),this.xCoords&&c.free(this.xCoords);var r=t.positions,n=c.mallocFloat32(r.length),i=c.mallocInt32(r.length>>>1);n.set(r);var a=c.mallocFloat32(r.length);this.points=r,this.scales=l(n,i,a,this.bounds),this.offsetBuffer.update(n),this.pickBuffer.update(i),this.weightBuffer.update(a);for(var o=c.mallocFloat32(r.length>>>1),s=0,u=0;s>>1,this.pickOffset=0},f.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0,0,0];return function(r){var n=this.plot,i=this.pickShader,a=this.scales,o=this.offsetBuffer,l=this.pickBuffer,c=this.bounds,u=this.size,f=this.borderSize,h=n.gl,d=n.pickPixelRatio,p=n.viewBox,g=n.dataBox;if(0===this.pointCount)return r;var v=c[2]-c[0],m=c[3]-c[1],y=g[2]-g[0],b=g[3]-g[1],x=(p[2]-p[0])*d/n.pixelRatio,_=(p[3]-p[1])*d/n.pixelRatio,w=Math.min(y/x,b/_);t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(c[0]-g[0])/y-1,t[7]=2*(c[1]-g[1])/b-1,this.pickOffset=r,e[0]=255&r,e[1]=r>>8&255,e[2]=r>>16&255,e[3]=r>>24&255,i.bind(),i.uniforms.matrix=t,i.uniforms.color=this.color,i.uniforms.borderColor=this.borderColor,i.uniforms.pointSize=d*(u+f),i.uniforms.pickOffset=e,0===this.borderSize?i.uniforms.centerFraction=2:i.uniforms.centerFraction=u/(u+f+1.25),o.bind(),i.attributes.position.pointer(),l.bind(),i.attributes.pickId.pointer(h.UNSIGNED_BYTE);for(var k=this.xCoords,A=(g[0]-c[0]-w*u*d)/v,M=(g[2]-c[0]+w*u*d)/v,T=a.length-1;T>=0;--T){var E=a[T];if(!(E.pixelSize1)){var L=E.offset,S=E.count+L,C=s.ge(k,A,L,S-1),z=s.lt(k,M,C,S-1)+1;z>C&&h.drawArrays(h.POINTS,C,z-C)}}return r+this.pointCount}}(),f.draw=function(){var t=[1,0,0,0,1,0,0,0,1];return function(){var e=this.plot,r=this.shader,n=this.scales,i=this.offsetBuffer,a=this.bounds,o=this.size,l=this.borderSize,c=e.gl,u=e.pixelRatio,f=e.viewBox,h=e.dataBox;if(0!==this.pointCount){var d=a[2]-a[0],p=a[3]-a[1],g=h[2]-h[0],v=h[3]-h[1],m=f[2]-f[0],y=f[3]-f[1],b=Math.min(g/m,v/y);t[0]=2*d/g,t[4]=2*p/v,t[6]=2*(a[0]-h[0])/g-1,t[7]=2*(a[1]-h[1])/v-1,r.bind(),r.uniforms.matrix=t,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointSize=u*(o+l),r.uniforms.useWeight=1,0===this.borderSize?r.uniforms.centerFraction=2:r.uniforms.centerFraction=o/(o+l+1.25),i.bind(),r.attributes.position.pointer(),this.weightBuffer.bind(),r.attributes.weight.pointer();for(var x=this.xCoords,_=(h[0]-a[0]-b*o*u)/d,w=(h[2]-a[0]+b*o*u)/d,k=!0,A=n.length-1;A>=0;--A){var M=n[A];if(!(M.pixelSize1)){var T=M.offset,E=M.count+T,L=s.ge(x,_,T,E-1),S=s.lt(x,w,L,E-1)+1;S>L&&c.drawArrays(c.POINTS,L,S-L),k&&(k=!1,r.uniforms.useWeight=0)}}}}}(),f.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}}},{"./lib/shader":145,"binary-search-bounds":146,"gl-buffer":77,"gl-shader":156,"snap-points-2d":148,"typedarray-pool":237}],150:[function(t,e,r){"use strict";function n(t,e){var r=a[e];if(r||(r=a[e]={}),t in r)return r[t];for(var n=i(t,{textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),o=i(t,{triangles:!0,textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),s=[[1/0,1/0],[-(1/0),-(1/0)]],l=0;lu;++u)s[0][u]=Math.min(s[0][u],c[u]),s[1][u]=Math.max(s[1][u],c[u]);return r[t]=[o,n,s]}var i=t("vectorize-text");e.exports=n;var a={}},{"vectorize-text":239}],151:[function(t,e,r){function n(t,e){var r=i(t,e),n=r.attributes;return n.position.location=0,n.color.location=1,n.glyph.location=2,n.id.location=3,r}var i=t("gl-shader"),a="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1])) ) {\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}",o="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || any(greaterThan(position, clipBounds[1]))) {\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}",s="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) ||\n any(greaterThan(position, clipBounds[1])) ) {\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",l="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if(any(lessThan(dataCoordinate, fragClipBounds[0])) ||\n any(greaterThan(dataCoordinate, fragClipBounds[1])) ) {\n discard;\n } else {\n gl_FragColor = interpColor * opacity;\n }\n}\n",c="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if(any(lessThan(dataCoordinate, fragClipBounds[0])) || \n any(greaterThan(dataCoordinate, fragClipBounds[1])) ) {\n discard;\n } else {\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n }\n}",u=[{ -name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"glyph",type:"vec2"},{name:"id",type:"vec4"}],f={vertex:a,fragment:l,attributes:u},h={vertex:o,fragment:l,attributes:u},d={vertex:s,fragment:l,attributes:u},p={vertex:a,fragment:c,attributes:u},g={vertex:o,fragment:c,attributes:u},v={vertex:s,fragment:c,attributes:u};r.createPerspective=function(t){return n(t,f)},r.createOrtho=function(t){return n(t,h)},r.createProject=function(t){return n(t,d)},r.createPickPerspective=function(t){return n(t,p)},r.createPickOrtho=function(t){return n(t,g)},r.createPickProject=function(t){return n(t,v)}},{"gl-shader":156}],152:[function(t,e,r){"use strict";function n(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];return t[0]=e[0]*r+e[4]*n+e[8]*i+e[12]*a,t[1]=e[1]*r+e[5]*n+e[9]*i+e[13]*a,t[2]=e[2]*r+e[6]*n+e[10]*i+e[14]*a,t[3]=e[3]*r+e[7]*n+e[11]*i+e[15]*a,t}function i(t,e,r,i){return n(i,i,r),n(i,i,e),n(i,i,t)}function a(t,e){this.index=t,this.dataCoordinate=this.position=e}function o(t,e,r,n,i,o,s,l,c,u,f,h){this.gl=t,this.pixelRatio=1,this.shader=e,this.orthoShader=r,this.projectShader=n,this.pointBuffer=i,this.colorBuffer=o,this.glyphBuffer=s,this.idBuffer=l,this.vao=c,this.vertexCount=0,this.lineVertexCount=0,this.opacity=1,this.lineWidth=0,this.projectScale=[2/3,2/3,2/3],this.projectOpacity=[1,1,1],this.pickId=0,this.pickPerspectiveShader=u,this.pickOrthoShader=f,this.pickProjectShader=h,this.points=[],this._selectResult=new a(0,[0,0,0]),this.useOrtho=!0,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.axesProject=[!0,!0,!0],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.highlightId=[1,1,1,1],this.highlightScale=2,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.dirty=!0}function s(t){return t[0]=t[1]=t[2]=0,t}function l(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t}function c(t,e,r,n){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[r]=n,t}function u(t){for(var e=S,r=0;2>r;++r)for(var n=0;3>n;++n)e[r][n]=Math.max(Math.min(t[r][n],1e8),-1e8);return e}function f(t,e,r,n,a){var o,f=e.axesProject,h=e.gl,d=t.uniforms,p=r.model||x,g=r.view||x,v=r.projection||x,y=e.axesBounds,b=u(e.clipBounds);o=e.axes?e.axes.lastCubeProps.axis:[1,1,1],w[0]=2/h.drawingBufferWidth,w[1]=2/h.drawingBufferHeight,t.bind(),d.view=g,d.projection=v,d.screenSize=w,d.highlightId=e.highlightId,d.highlightScale=e.highlightScale,d.clipBounds=b,d.pickGroup=e.pickId/255,d.pixelRatio=e.pixelRatio;for(var _=0;3>_;++_)if(f[_]&&e.projectOpacity[_]<1===n){d.scale=e.projectScale[_],d.opacity=e.projectOpacity[_];for(var S=E,C=0;16>C;++C)S[C]=0;for(var C=0;4>C;++C)S[5*C]=1;S[5*_]=0,o[_]<0?S[12+_]=y[0][_]:S[12+_]=y[1][_],m(S,p,S),d.model=S;var z=(_+1)%3,P=(_+2)%3,R=s(k),O=s(A);R[z]=1,O[P]=1;var I=i(v,g,p,l(M,R)),N=i(v,g,p,l(T,O));if(Math.abs(I[1])>Math.abs(N[1])){var j=I;I=N,N=j,j=R,R=O,O=j;var F=z;z=P,P=F}I[0]<0&&(R[z]=-1),N[1]>0&&(O[P]=-1);for(var D=0,B=0,C=0;4>C;++C)D+=Math.pow(p[4*z+C],2),B+=Math.pow(p[4*P+C],2);R[z]/=Math.sqrt(D),O[P]/=Math.sqrt(B),d.axes[0]=R,d.axes[1]=O,d.fragClipBounds[0]=c(L,b[0],_,-1e8),d.fragClipBounds[1]=c(L,b[1],_,1e8),e.vao.draw(h.TRIANGLES,e.vertexCount),e.lineWidth>0&&(h.lineWidth(e.lineWidth),e.vao.draw(h.LINES,e.lineVertexCount,e.vertexCount))}}function h(t,e,r,n,i,a){var o=r.gl;if(r.vao.bind(),i===r.opacity<1||a){t.bind();var s=t.uniforms;s.model=n.model||x,s.view=n.view||x,s.projection=n.projection||x,w[0]=2/o.drawingBufferWidth,w[1]=2/o.drawingBufferHeight,s.screenSize=w,s.highlightId=r.highlightId,s.highlightScale=r.highlightScale,s.fragClipBounds=P,s.clipBounds=r.axes.bounds,s.opacity=r.opacity,s.pickGroup=r.pickId/255,s.pixelRatio=r.pixelRatio,r.vao.draw(o.TRIANGLES,r.vertexCount),r.lineWidth>0&&(o.lineWidth(r.lineWidth),r.vao.draw(o.LINES,r.lineVertexCount,r.vertexCount))}f(e,r,n,i,a),r.vao.unbind()}function d(t){var e=t.gl,r=y.createPerspective(e),n=y.createOrtho(e),i=y.createProject(e),a=y.createPickPerspective(e),s=y.createPickOrtho(e),l=y.createPickProject(e),c=p(e),u=p(e),f=p(e),h=p(e),d=g(e,[{buffer:c,size:3,type:e.FLOAT},{buffer:u,size:4,type:e.FLOAT},{buffer:f,size:2,type:e.FLOAT},{buffer:h,size:4,type:e.UNSIGNED_BYTE,normalized:!0}]),v=new o(e,r,n,i,c,u,f,h,d,a,s,l);return v.update(t),v}var p=t("gl-buffer"),g=t("gl-vao"),v=t("typedarray-pool"),m=t("gl-mat4/multiply"),y=t("./lib/shaders"),b=t("./lib/glyphs"),x=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];e.exports=d;var _=o.prototype;_.pickSlots=1,_.setPickBase=function(t){this.pickId=t},_.isTransparent=function(){if(this.opacity<1)return!0;for(var t=0;3>t;++t)if(this.axesProject[t]&&this.projectOpacity[t]<1)return!0;return!1},_.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;3>t;++t)if(this.axesProject[t]&&this.projectOpacity[t]>=1)return!0;return!1};var w=[0,0],k=[0,0,0],A=[0,0,0],M=[0,0,0,1],T=[0,0,0,1],E=x.slice(),L=[0,0,0],S=[[0,0,0],[0,0,0]],C=[-1e8,-1e8,-1e8],z=[1e8,1e8,1e8],P=[C,z];_.draw=function(t){var e=this.useOrtho?this.orthoShader:this.shader;h(e,this.projectShader,this,t,!1,!1)},_.drawTransparent=function(t){var e=this.useOrtho?this.orthoShader:this.shader;h(e,this.projectShader,this,t,!0,!1)},_.drawPick=function(t){var e=this.useOrtho?this.pickOrthoShader:this.pickPerspectiveShader;h(e,this.pickProjectShader,this,t,!1,!0)},_.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[2]+(t.value[1]<<8)+(t.value[0]<<16);if(e>=this.pointCount||0>e)return null;var r=this.points[e],n=this._selectResult;n.index=e;for(var i=0;3>i;++i)n.position[i]=n.dataCoordinate[i]=r[i];return n},_.highlight=function(t){if(t){var e=t.index,r=255&e,n=e>>8&255,i=e>>16&255;this.highlightId=[r/255,n/255,i/255,0]}else this.highlightId=[1,1,1,1]},_.update=function(t){if(t=t||{},"perspective"in t&&(this.useOrtho=!t.perspective),"orthographic"in t&&(this.useOrtho=!!t.orthographic),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"project"in t)if(Array.isArray(t.project))this.axesProject=t.project;else{var e=!!t.project;this.axesProject=[e,e,e]}if("projectScale"in t)if(Array.isArray(t.projectScale))this.projectScale=t.projectScale.slice();else{var r=+t.projectScale;this.projectScale=[r,r,r]}if("projectOpacity"in t)if(Array.isArray(t.projectOpacity))this.projectOpacity=t.projectOpacity.slice();else{var r=+t.projectOpacity;this.projectOpacity=[r,r,r]}"opacity"in t&&(this.opacity=t.opacity),this.dirty=!0;var n=t.position;if(n){var i=t.font||"normal",a=t.alignment||[0,0],o=[1/0,1/0,1/0],s=[-(1/0),-(1/0),-(1/0)],l=t.glyph,c=t.color,u=t.size,f=t.angle,h=t.lineColor,d=0,p=0,g=0,m=n.length;t:for(var y=0;m>y;++y){for(var x=n[y],_=0;3>_;++_)if(isNaN(x[_])||!isFinite(x[_]))continue t;var w;w=Array.isArray(l)?b(l[y],i):l?b(l,i):b("\u25cf",i);var k=w[0],A=w[1],M=w[2];p+=3*k.cells.length,g+=2*A.edges.length}var T=p+g,E=v.mallocFloat(3*T),L=v.mallocFloat(4*T),S=v.mallocFloat(2*T),C=v.mallocUint32(T),z=[0,a[1]],P=0,R=p,O=[0,0,0,1],I=[0,0,0,1],N=Array.isArray(c)&&Array.isArray(c[0]),j=Array.isArray(h)&&Array.isArray(h[0]);t:for(var y=0;m>y;++y){for(var x=n[y],_=0;3>_;++_){if(isNaN(x[_])||!isFinite(x[_])){d+=1;continue t}s[_]=Math.max(s[_],x[_]),o[_]=Math.min(o[_],x[_])}var w;w=Array.isArray(l)?b(l[y],i):l?b(l,i):b("\u25cf",i);var k=w[0],A=w[1],M=w[2];if(Array.isArray(c)){var F;if(F=N?c[y]:c,3===F.length){for(var _=0;3>_;++_)O[_]=F[_];O[3]=1}else if(4===F.length)for(var _=0;4>_;++_)O[_]=F[_]}else O[0]=O[1]=O[2]=0,O[3]=1;if(Array.isArray(h)){var F;if(F=j?h[y]:h,3===F.length){for(var _=0;3>_;++_)I[_]=F[_];I[_]=1}else if(4===F.length)for(var _=0;4>_;++_)I[_]=F[_]}else I[0]=I[1]=I[2]=0,I[3]=1;var D=.5;Array.isArray(u)?D=+u[y]:u?D=+u:this.useOrtho&&(D=12);var B=0;Array.isArray(f)?B=+f[y]:f&&(B=+f);for(var U=Math.cos(B),V=Math.sin(B),x=n[y],_=0;3>_;++_)s[_]=Math.max(s[_],x[_]),o[_]=Math.min(o[_],x[_]);a[0]<0?z[0]=a[0]*(1+M[1][0]):a[0]>0&&(z[0]=-a[0]*(1+M[0][0]));for(var q=k.cells,H=k.positions,_=0;_Y;++Y){for(var X=0;3>X;++X)E[3*P+X]=x[X];for(var X=0;4>X;++X)L[4*P+X]=O[X];C[P]=d;var W=H[G[Y]];S[2*P]=D*(U*W[0]-V*W[1]+z[0]),S[2*P+1]=D*(V*W[0]+U*W[1]+z[1]),P+=1}for(var q=A.edges,H=A.positions,_=0;_Y;++Y){for(var X=0;3>X;++X)E[3*R+X]=x[X];for(var X=0;4>X;++X)L[4*R+X]=I[X];C[R]=d;var W=H[G[Y]];S[2*R]=D*(U*W[0]-V*W[1]+z[0]),S[2*R+1]=D*(V*W[0]+U*W[1]+z[1]),R+=1}d+=1}this.vertexCount=p,this.lineVertexCount=g,this.pointBuffer.update(E),this.colorBuffer.update(L),this.glyphBuffer.update(S),this.idBuffer.update(new Uint32Array(C)),v.free(E),v.free(L),v.free(S),v.free(C),this.bounds=[o,s],this.points=n,this.pointCount=n.length}},_.dispose=function(){this.shader.dispose(),this.orthoShader.dispose(),this.pickPerspectiveShader.dispose(),this.pickOrthoShader.dispose(),this.vao.dispose(),this.pointBuffer.dispose(),this.colorBuffer.dispose(),this.glyphBuffer.dispose(),this.idBuffer.dispose()}},{"./lib/glyphs":150,"./lib/shaders":151,"gl-buffer":77,"gl-mat4/multiply":98,"gl-vao":185,"typedarray-pool":237}],153:[function(t,e,r){"use strict";r.boxVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n",r.boxFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"},{}],154:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.boxBuffer=e,this.boxShader=r,this.enabled=!0,this.selectBox=[1/0,1/0,-(1/0),-(1/0)],this.borderColor=[0,0,0,1],this.innerFill=!1,this.innerColor=[0,0,0,.25],this.outerFill=!0,this.outerColor=[0,0,0,.5],this.borderWidth=10}function i(t,e){var r=t.gl,i=o(r,[0,0,0,1,1,0,1,1]),l=a(r,s.boxVertex,s.boxFragment),c=new n(t,i,l);return c.update(e),t.addOverlay(c),c}var a=t("gl-shader"),o=t("gl-buffer"),s=t("./lib/shaders");e.exports=i;var l=n.prototype;l.draw=function(){if(this.enabled){var t=this.plot,e=this.selectBox,r=this.borderWidth,n=(this.innerFill,this.innerColor),i=(this.outerFill,this.outerColor),a=this.borderColor,o=t.box,s=t.screenBox,l=t.dataBox,c=t.viewBox,u=t.pixelRatio,f=(e[0]-l[0])*(c[2]-c[0])/(l[2]-l[0])+c[0],h=(e[1]-l[1])*(c[3]-c[1])/(l[3]-l[1])+c[1],d=(e[2]-l[0])*(c[2]-c[0])/(l[2]-l[0])+c[0],p=(e[3]-l[1])*(c[3]-c[1])/(l[3]-l[1])+c[1];if(f=Math.max(f,c[0]),h=Math.max(h,c[1]),d=Math.min(d,c[2]),p=Math.min(p,c[3]),!(f>d||h>p)){o.bind();var g=s[2]-s[0],v=s[3]-s[1];if(this.outerFill&&(o.drawBox(0,0,g,h,i),o.drawBox(0,h,f,p,i),o.drawBox(0,p,g,v,i),o.drawBox(d,h,g,p,i)),this.innerFill&&o.drawBox(f,h,d,p,n),r>0){var m=r*u;o.drawBox(f-m,h-m,d+m,h+m,a),o.drawBox(f-m,p-m,d+m,p+m,a),o.drawBox(f-m,h-m,f+m,p+m,a),o.drawBox(d-m,h-m,d+m,p+m,a)}}}},l.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},l.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":153,"gl-buffer":77,"gl-shader":156}],155:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.coord=[t,e],this.id=r,this.value=n,this.distance=i}function i(t,e,r){this.gl=t,this.fbo=e,this.buffer=r,this._readTimeout=null;var n=this;this._readCallback=function(){n.gl&&(e.bind(),t.readPixels(0,0,e.shape[0],e.shape[1],t.RGBA,t.UNSIGNED_BYTE,n.buffer),n._readTimeout=null)}}function a(t,e){var r=o(t,e),n=s.mallocUint8(e[0]*e[1]*4);return new i(t,r,n)}e.exports=a;var o=t("gl-fbo"),s=t("typedarray-pool"),l=t("ndarray"),c=t("bit-twiddle").nextPow2,u=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(255>_inline_31_arg0_||255>_inline_31_arg1_||255>_inline_31_arg2_||255>_inline_31_arg3_){var _inline_31_l=_inline_31_arg4_-_inline_31_arg6_[0],_inline_31_a=_inline_31_arg5_-_inline_31_arg6_[1],_inline_31_f=_inline_31_l*_inline_31_l+_inline_31_a*_inline_31_a;_inline_31_fthis.buffer.length){s.free(this.buffer);for(var n=this.buffer=s.mallocUint8(c(r*e*4)),i=0;r*e*4>i;++i)n[i]=255}return t}}}),f.begin=function(){var t=this.gl;this.shape;t&&(this.fbo.bind(),t.clearColor(1,1,1,1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT))},f.end=function(){var t=this.gl;t&&(t.bindFramebuffer(t.FRAMEBUFFER,null),this._readTimeout||clearTimeout(this._readTimeout),this._readTimeout=setTimeout(this._readCallback,1))},f.query=function(t,e,r){if(!this.gl)return null;var i=this.fbo.shape.slice();t=0|t,e=0|e,"number"!=typeof r&&(r=1);var a=0|Math.min(Math.max(t-r,0),i[0]),o=0|Math.min(Math.max(t+r,0),i[0]),s=0|Math.min(Math.max(e-r,0),i[1]),c=0|Math.min(Math.max(e+r,0),i[1]);if(a>=o||s>=c)return null;var f=[o-a,c-s],h=l(this.buffer,[f[0],f[1],4],[4,4*i[0],1],4*(a+i[0]*s)),d=u(h.hi(f[0],f[1],1),r,r),p=d[0],g=d[1];if(0>p||Math.pow(this.radius,2)=0){for(var A=0|k.type.charAt(k.type.length-1),M=new Array(A),T=0;A>T;++T)M[T]=_.length,x.push(k.name+"["+T+"]"),"number"==typeof k.location?_.push(k.location+T):Array.isArray(k.location)&&k.location.length===A&&"number"==typeof k.location[T]?_.push(0|k.location[T]):_.push(-1);b.push({name:k.name,type:k.type,locations:M})}else b.push({name:k.name,type:k.type,locations:[_.length]}),x.push(k.name),"number"==typeof k.location?_.push(0|k.location):_.push(-1)}for(var E=0,w=0;w<_.length;++w)if(_[w]<0){for(;_.indexOf(E)>=0;)E+=1;_[w]=E}var L=new Array(r.length);a(),d._relink=a,d.types={uniforms:l(r),attributes:l(n)},d.attributes=s(p,d,b,_),Object.defineProperty(d,"uniforms",o(p,d,r,L))},e.exports=a},{"./lib/GLError":157,"./lib/create-attributes":158,"./lib/create-uniforms":159,"./lib/reflect":160,"./lib/runtime-reflect":161,"./lib/shader-cache":162}],157:[function(t,e,r){function n(t,e,r){this.shortMessage=e||"",this.longMessage=r||"",this.rawError=t||"",this.message="gl-shader: "+(e||t||"")+(r?"\n"+r:""),this.stack=(new Error).stack}n.prototype=new Error,n.prototype.name="GLError",n.prototype.constructor=n,e.exports=n},{}],158:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}function i(t,e,r,i,a,o,s){for(var l=["gl","v"],c=[],u=0;a>u;++u)l.push("x"+u),c.push("x"+u);l.push("if(x0.length===void 0){return gl.vertexAttrib"+a+"f(v,"+c.join()+")}else{return gl.vertexAttrib"+a+"fv(v,x0)}");var f=Function.apply(null,l),h=new n(t,e,r,i,a,f);Object.defineProperty(o,s,{set:function(e){return t.disableVertexAttribArray(i[r]),f(t,i[r],e),e},get:function(){return h},enumerable:!0})}function a(t,e,r,n,a,o,s){for(var l=new Array(a),c=new Array(a),u=0;a>u;++u)i(t,e,r[u],n,a,l,u),c[u]=l[u];Object.defineProperty(l,"location",{set:function(t){if(Array.isArray(t))for(var e=0;a>e;++e)c[e].location=t[e];else for(var e=0;a>e;++e)c[e].location=t+e;return t},get:function(){for(var t=new Array(a),e=0;a>e;++e)t[e]=n[r[e]];return t},enumerable:!0}),l.pointer=function(e,i,o,s){e=e||t.FLOAT,i=!!i,o=o||a*a,s=s||0;for(var l=0;a>l;++l){var c=n[r[l]];t.vertexAttribPointer(c,a,e,i,o,s+l*a),t.enableVertexAttribArray(c)}};var f=new Array(a),h=t["vertexAttrib"+a+"fv"];Object.defineProperty(o,s,{set:function(e){for(var i=0;a>i;++i){var o=n[r[i]];if(t.disableVertexAttribArray(o),Array.isArray(e[0]))h.call(t,o,e[i]);else{for(var s=0;a>s;++s)f[s]=e[a*i+s];h.call(t,o,f)}}return e},get:function(){return l},enumerable:!0})}function o(t,e,r,n){for(var o={},l=0,c=r.length;c>l;++l){var u=r[l],f=u.name,h=u.type,d=u.locations;switch(h){case"bool":case"int":case"float":i(t,e,d[0],n,1,o,f);break;default:if(h.indexOf("vec")>=0){var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);i(t,e,d[0],n,p,o,f)}else{if(!(h.indexOf("mat")>=0))throw new s("","Unknown data type for attribute "+f+": "+h);var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);a(t,e,d,n,p,o,f)}}}return o}e.exports=o;var s=t("./GLError"),l=n.prototype;l.pointer=function(t,e,r,n){var i=this,a=i._gl,o=i._locations[i._index];a.vertexAttribPointer(o,i._dimension,t||a.FLOAT,!!e,r||0,n||0),a.enableVertexAttribArray(o)},l.set=function(t,e,r,n){return this._constFunc(this._locations[this._index],t,e,r,n)},Object.defineProperty(l,"location",{get:function(){return this._locations[this._index]},set:function(t){return t!==this._locations[this._index]&&(this._locations[this._index]=0|t,this._wrapper.program=null),0|t}})},{"./GLError":157}],159:[function(t,e,r){"use strict";function n(t){var e=new Function("y","return function(){return y}");return e(t)}function i(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e,r,a){function l(r){var n=new Function("gl","wrapper","locations","return function(){return gl.getUniform(wrapper.program,locations["+r+"])}");return n(t,e,a)}function c(t,e,r){switch(r){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+e+"],obj"+t+")";case"float":return"gl.uniform1f(locations["+e+"],obj"+t+")";default:var n=r.indexOf("vec");if(!(n>=0&&1>=n&&r.length===4+n)){if(0===r.indexOf("mat")&&4===r.length){var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+i+"fv(locations["+e+"],false,obj"+t+")"}throw new s("","Unknown uniform data type for "+name+": "+r)}var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+i+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+i+"fv(locations["+e+"],obj"+t+")";default:throw new s("","Unrecognized data type for vector "+name+": "+r)}}}function u(t,e){if("object"!=typeof e)return[[t,e]];var r=[];for(var n in e){var i=e[n],a=t;a+=parseInt(n)+""===n?"["+n+"]":"."+n,"object"==typeof i?r.push.apply(r,u(a,i)):r.push([a,i])}return r}function f(e){for(var n=["return function updateProperty(obj){"],i=u("",e),o=0;o=0&&1>=e&&t.length===4+e){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid data type");return"b"===t.charAt(0)?i(r,!1):i(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+t);return i(r*r,0)}throw new s("","Unknown uniform data type for "+name+": "+t)}}function d(t,e,i){if("object"==typeof i){var o=p(i);Object.defineProperty(t,e,{get:n(o),set:f(i),enumerable:!0,configurable:!1})}else a[i]?Object.defineProperty(t,e,{get:l(i),set:f(i),enumerable:!0,configurable:!1}):t[e]=h(r[i].type)}function p(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var c=1;ca;++a){var o=t.getActiveUniform(e,a);if(o){var s=n(t,o.type);if(o.size>1)for(var l=0;la;++a){var o=t.getActiveAttrib(e,a);o&&i.push({name:o.name,type:n(t,o.type)})}return i}r.uniforms=i,r.attributes=a;var o={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"},s=null},{}],162:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.id=t,this.src=e,this.type=r,this.shader=n,this.count=a,this.programs=[],this.cache=o}function i(t){this.gl=t,this.shaders=[{},{}],this.programs={}}function a(t,e,r){var n=t.createShader(e);if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){var i=t.getShaderInfoLog(n);try{var a=f(i,r,e)}catch(o){throw console.warn("Failed to format compiler error: "+o),new u(i,"Error compiling shader:\n"+i)}throw new u(i,a.short,a.long)}return n}function o(t,e,r,n,i){var a=t.createProgram();t.attachShader(a,e),t.attachShader(a,r);for(var o=0;on;++n){var a=t.programs[r[n]];a&&(delete t.programs[n],e.deleteProgram(a))}e.deleteShader(this.shader),delete t.shaders[this.type===e.FRAGMENT_SHADER|0][this.src]}};var g=i.prototype;g.getShaderReference=function(t,e){var r=this.gl,i=this.shaders[t===r.FRAGMENT_SHADER|0],o=i[e];if(o&&r.isShader(o.shader))o.count+=1;else{var s=a(r,t,e);o=i[e]=new n(p++,e,t,s,[],1,this)}return o},g.getProgram=function(t,e,r,n){var i=[t.id,e.id,r.join(":"),n.join(":")].join("@"),a=this.programs[i];return a&&this.gl.isProgram(a)||(this.programs[i]=a=o(this.gl,t.shader,e.shader,r,n),t.programs.push(i),e.programs.push(i)),a}},{"./GLError":157,"gl-format-compiler-error":163,"weakmap-shim":173}],163:[function(t,e,r){function n(t,e,r){"use strict";var n=o(e)||"of unknown name (see npm glsl-shader-name)",l="unknown type";void 0!==r&&(l=r===a.FRAGMENT_SHADER?"fragment":"vertex");for(var c=i("Error compiling %s shader %s:\n",l,n),u=i("%s%s",c,t),f=t.split("\n"),h={},d=0;ds;s++)if(g=i(t[s]),"string"===g)v[v.length]=t[s];else if("array"===g){if(c=t[s],c[2])for(n=e[d],l=0;l=0),c[8]){case"b":n=n.toString(2);break;case"c":n=String.fromCharCode(n);break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,c[6]?parseInt(c[6]):0);break;case"e":n=c[7]?n.toExponential(c[7]):n.toExponential();break;case"f":n=c[7]?parseFloat(n).toFixed(c[7]):parseFloat(n);break;case"g":n=c[7]?parseFloat(n).toPrecision(c[7]):parseFloat(n);break;case"o":n=n.toString(8);break;case"s":n=(n=String(n))&&c[7]?n.substring(0,c[7]):n;break;case"u":n>>>=0;break;case"x":n=n.toString(16);break;case"X":n=n.toString(16).toUpperCase()}o.json.test(c[8])?v[v.length]=n:(!o.number.test(c[8])||m&&!c[3]?y="":(y=m?"+":"-",n=n.toString().replace(o.sign,"")),f=c[4]?"0"===c[4]?"0":c[4].charAt(1):" ",h=c[6]-(y+n).length,u=c[6]&&h>0?a(f,h):"",v[v.length]=c[5]?y+n+u:"0"===f?y+u+n:u+y+n)}return v.join("")},r.cache={},r.parse=function(t){for(var e=t,r=[],n=[],i=0;e;){if(null!==(r=o.text.exec(e)))n[n.length]=r[0];else if(null!==(r=o.modulo.exec(e)))n[n.length]="%";else{if(null===(r=o.placeholder.exec(e)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){i|=1;var a=[],s=r[2],l=[];if(null===(l=o.key.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(a[a.length]=l[1];""!==(s=s.substring(l[0].length));)if(null!==(l=o.key_access.exec(s)))a[a.length]=l[1];else{if(null===(l=o.index_access.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");a[a.length]=l[1]}r[2]=a}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=r}e=e.substring(r[0].length)}return n};var s=function(t,e,n){return n=(e||[]).slice(0),n.splice(0,0,t),r.apply(null,n)};"undefined"!=typeof n?(n.sprintf=r,n.vsprintf=s):(e.sprintf=r,e.vsprintf=s,"function"==typeof t&&t.amd&&t(function(){return{sprintf:r,vsprintf:s}}))}("undefined"==typeof window?this:window)},{}],171:[function(t,e,r){function n(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:i(e,t)}}var i=t("./hidden-store.js");e.exports=n},{"./hidden-store.js":172}],172:[function(t,e,r){function n(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}e.exports=n},{}],173:[function(t,e,r){function n(){var t=i();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){t(e).value=r},has:function(e){return"value"in t(e)},"delete":function(e){return delete t(e).value}}}var i=t("./create-store.js");e.exports=n},{"./create-store.js":171}],174:[function(t,e,r){"use strict";function n(t){this.plot=t,this.enable=[!0,!0,!1,!1],this.width=[1,1,1,1],this.color=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.center=[1/0,1/0]}function i(t,e){var r=new n(t);return r.update(e),t.addOverlay(r),r}e.exports=i;var a=n.prototype;a.update=function(t){t=t||{},this.enable=(t.enable||[!0,!0,!1,!1]).slice(),this.width=(t.width||[1,1,1,1]).slice(),this.color=(t.color||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]).map(function(t){return t.slice()}),this.center=(t.center||[1/0,1/0]).slice(),this.plot.setOverlayDirty()},a.draw=function(){var t=this.enable,e=this.width,r=this.color,n=this.center,i=this.plot,a=i.line,o=i.dataBox,s=i.viewBox;if(a.bind(),o[0]<=n[0]&&n[0]<=o[2]&&o[1]<=n[1]&&n[1]<=o[3]){var l=s[0]+(n[0]-o[0])/(o[2]-o[0])*(s[2]-s[0]),c=s[1]+(n[1]-o[1])/(o[3]-o[1])*(s[3]-s[1]);t[0]&&a.drawLine(l,c,s[0],c,e[0],r[0]),t[1]&&a.drawLine(l,c,l,s[1],e[1],r[1]),t[2]&&a.drawLine(l,c,s[2],c,e[2],r[2]),t[3]&&a.drawLine(l,c,l,s[3],e[3],r[3])}},a.dispose=function(){this.plot.removeOverlay(this)}},{}],175:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute vec3 f;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 lightPosition, eyePosition;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n worldCoordinate = vec3(uv.zw, f.x);\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 //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",a="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(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\n\n\nfloat beckmannSpecular_1_1(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness) {\n return beckmannDistribution_2_0(dot(surfaceNormal, normalize(lightDirection + viewDirection)), roughness);\n}\n\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;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n if(kill > 0.0 ||\n any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n discard;\n }\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 = beckmannSpecular_1_1(L, V, N, roughness);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(colormap, vec2(value, value));\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",o="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\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",s="precision mediump float;\n#define GLSLIFY 1\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 any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n 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";r.createShader=function(t){var e=n(t,i,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createPickShader=function(t){var e=n(t,i,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createContourShader=function(t){var e=n(t,o,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e},r.createPickContourShader=function(t){var e=n(t,o,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e}},{"gl-shader":156}],176:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],177:[function(t,e,r){"use strict";function n(t){if(t in l)return l[t];for(var e=[],r=0;t>r;++r)e.push("out",r,"s=0.5*(inp",r,"l-inp",r,"r);");for(var n=["array"],i=["junk"],r=0;t>r;++r){n.push("array"),i.push("out"+r+"s");var a=o(t);a[r]=-1,n.push({array:0,offset:a.slice()}),a[r]=1,n.push({array:0,offset:a.slice()}),i.push("inp"+r+"l","inp"+r+"r")}return l[t]=s({args:n,pre:u,post:u,body:{body:e.join(""),args:i.map(function(t){return{name:t,lvalue:0===t.indexOf("out"),rvalue:0===t.indexOf("inp"),count:"junk"!==t|0}}),thisVars:[],localVars:[]},funcName:"fdTemplate"+t})}function i(t){function e(e){for(var r=a-e.length,n=[],i=[],s=[],l=0;a>l;++l)e.indexOf(l+1)>=0?s.push("0"):e.indexOf(-(l+1))>=0?s.push("s["+l+"]-1"):(s.push("-1"),n.push("1"),i.push("s["+l+"]-2"));var c=".lo("+n.join()+").hi("+i.join()+")";if(0===n.length&&(c=""),r>0){o.push("if(1");for(var l=0;a>l;++l)e.indexOf(l+1)>=0||e.indexOf(-(l+1))>=0||o.push("&&s[",l,"]>2");o.push("){grad",r,"(src.pick(",s.join(),")",c);for(var l=0;a>l;++l)e.indexOf(l+1)>=0||e.indexOf(-(l+1))>=0||o.push(",dst.pick(",s.join(),",",l,")",c);o.push(");")}for(var l=0;l1){dst.set(",s.join(),",",u,",0.5*(src.get(",h.join(),")-src.get(",d.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):o.push("if(s[",u,"]>1){diff(",f,",src.pick(",h.join(),")",c,",src.pick(",d.join(),")",c,");}else{zero(",f,");};");break;case"mirror":0===r?o.push("dst.set(",s.join(),",",u,",0);"):o.push("zero(",f,");");break;case"wrap":var p=s.slice(),g=s.slice();e[l]<0?(p[u]="s["+u+"]-2",g[u]="0"):(p[u]="s["+u+"]-1",g[u]="1"),0===r?o.push("if(s[",u,"]>2){dst.set(",s.join(),",",u,",0.5*(src.get(",p.join(),")-src.get(",g.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):o.push("if(s[",u,"]>2){diff(",f,",src.pick(",p.join(),")",c,",src.pick(",g.join(),")",c,");}else{zero(",f,");};");break;default:throw new Error("ndarray-gradient: Invalid boundary condition")}}r>0&&o.push("};")}var r=t.join(),i=c[r];if(i)return i;for(var a=t.length,o=["function gradient(dst,src){var s=src.shape.slice();"],s=0;1<s;++s){for(var u=[],d=0;a>d;++d)s&1<=s;++s)v.push("grad"+s),m.push(n(s));v.push(o.join(""));var y=Function.apply(void 0,v),i=y.apply(void 0,m);return l[r]=i,i}function a(t,e,r){if(Array.isArray(r)){if(r.length!==e.dimension)throw new Error("ndarray-gradient: invalid boundary conditions")}else r="string"==typeof r?o(e.dimension,r):o(e.dimension,"clamp");if(t.dimension!==e.dimension+1)throw new Error("ndarray-gradient: output dimension must be +1 input dimension");if(t.shape[e.dimension]!==e.dimension)throw new Error("ndarray-gradient: output shape must match input shape");for(var n=0;nr;++r)for(o=o||e.surfaceProject[r],n=0;3>n;++n)s=s||e.contourProject[r][n];for(r=0;3>r;++r){var l=D.projections[r];for(n=0;16>n;++n)l[n]=0;for(n=0;4>n;++n)l[5*n]=1;l[5*r]=0,l[12+r]=e.axesBounds[+(a[r]>0)][r],k(l,t.model,l);var c=D.clipBounds[r];for(i=0;2>i;++i)for(n=0;3>n;++n)c[i][n]=t.clipBounds[i][n];c[0][r]=-1e8,c[1][r]=1e8}return D.showSurface=o,D.showContour=s,D}function s(t,e){t=t||{};var r=this.gl;r.disable(r.CULL_FACE),this._colorMap.bind(0);var n=B;n.model=t.model||R,n.view=t.view||R,n.projection=t.projection||R,n.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]],n.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]],n.contourColor=this.contourColor[0],n.inverseModel=A(n.inverseModel,n.model);for(var i=0;2>i;++i)for(var a=n.clipBounds[i],s=0;3>s;++s)a[s]=Math.min(Math.max(this.clipBounds[i][s],-1e8),1e8);n.kambient=this.ambientLight,n.kdiffuse=this.diffuseLight,n.kspecular=this.specularLight,n.roughness=this.roughness,n.fresnel=this.fresnel,n.opacity=this.opacity,n.height=0,n.permutation=V;var l=U;for(k(l,n.view,n.model),k(l,n.projection,l),A(l,l),i=0;3>i;++i)n.eyePosition[i]=l[12+i]/l[15];var c=l[15];for(i=0;3>i;++i)c+=this.lightPosition[i]*l[4*i+3];for(i=0;3>i;++i){var u=l[12+i];for(s=0;3>s;++s)u+=l[4*s+i]*this.lightPosition[s];n.lightPosition[i]=u/c}var f=o(n,this);if(f.showSurface&&e===this.opacity<1){for(this._shader.bind(),this._shader.uniforms=n,this._vao.bind(),this.showSurface&&this._vertexCount&&this._vao.draw(r.TRIANGLES,this._vertexCount),i=0;3>i;++i)this.surfaceProject[i]&&this.vertexCount&&(this._shader.uniforms.model=f.projections[i],this._shader.uniforms.clipBounds=f.clipBounds[i],this._vao.draw(r.TRIANGLES,this._vertexCount));this._vao.unbind()}if(f.showContour&&!e){var h=this._contourShader;n.kambient=1,n.kdiffuse=0,n.kspecular=0,n.opacity=1,h.bind(),h.uniforms=n;var d=this._contourVAO;for(d.bind(),i=0;3>i;++i)for(h.uniforms.permutation=I[i],r.lineWidth(this.contourWidth[i]),s=0;si;++i)for(h.uniforms.model=f.projections[i],h.uniforms.clipBounds=f.clipBounds[i],s=0;3>s;++s)if(this.contourProject[i][s]){h.uniforms.permutation=I[s],r.lineWidth(this.contourWidth[s]);for(var p=0;pi;++i)if(0!==this._dynamicCounts[i])for(h.uniforms.model=n.model,h.uniforms.clipBounds=n.clipBounds,h.uniforms.permutation=I[i],r.lineWidth(this.dynamicWidth[i]),h.uniforms.contourColor=this.dynamicColor[i],h.uniforms.contourTint=this.dynamicTint[i],h.uniforms.height=this.dynamicLevel[i],d.draw(r.LINES,this._dynamicCounts[i],this._dynamicOffsets[i]),s=0;3>s;++s)this.contourProject[s][i]&&(h.uniforms.model=f.projections[s],h.uniforms.clipBounds=f.clipBounds[s],d.draw(r.LINES,this._dynamicCounts[i],this._dynamicOffsets[i]));d.unbind()}}function l(t,e){var r=e.shape.slice(),n=t.shape.slice();b.assign(t.lo(1,1).hi(r[0],r[1]),e),b.assign(t.lo(1).hi(r[0],1),e.hi(r[0],1)),b.assign(t.lo(1,n[1]-1).hi(r[0],1),e.lo(0,r[1]-1).hi(r[0],1)),b.assign(t.lo(0,1).hi(1,r[1]),e.hi(1)),b.assign(t.lo(n[0]-1,1).hi(1,r[1]),e.lo(r[0]-1)),t.set(0,0,e.get(0,0)),t.set(0,n[1]-1,e.get(0,r[1]-1)),t.set(n[0]-1,0,e.get(r[0]-1,0)),t.set(n[0]-1,n[1]-1,e.get(r[0]-1,r[1]-1))}function c(t,e){return Array.isArray(t)?[e(t[0]),e(t[1]),e(t[2])]:[e(t),e(t),e(t)]}function u(t){return Array.isArray(t)?3===t.length?[t[0],t[1],t[2],1]:[t[0],t[1],t[2],t[3]]:[0,0,0,1]}function f(t){if(Array.isArray(t)){if(Array.isArray(t))return[u(t[0]),u(t[1]),u(t[2])];var e=u(t);return[e.slice(),e.slice(),e.slice()]}}function h(t){var e=t.gl,r=L(e),n=C(e),i=S(e),o=z(e),s=p(e),l=g(e,[{buffer:s,size:4,stride:P,offset:0},{buffer:s,size:3,stride:P,offset:16},{buffer:s,size:3,stride:P,offset:28}]),c=p(e),u=g(e,[{buffer:c,size:4,stride:20,offset:0},{buffer:c,size:1,stride:20,offset:16}]),f=p(e),h=g(e,[{buffer:f,size:2,type:e.FLOAT}]),d=v(e,1,N,e.RGBA,e.UNSIGNED_BYTE);d.minFilter=e.LINEAR,d.magFilter=e.LINEAR;var m=new a(e,[0,0],[[0,0,0],[0,0,0]],r,n,s,l,d,i,o,c,u,f,h),y={levels:[[],[],[]]};for(var b in t)y[b]=t[b];return y.colormap=y.colormap||"jet",m.update(y),m}e.exports=h;var d=t("bit-twiddle"),p=t("gl-buffer"),g=t("gl-vao"),v=t("gl-texture2d"),m=t("typedarray-pool"),y=t("colormap"),b=t("ndarray-ops"),x=t("ndarray-pack"),_=t("ndarray"),w=t("surface-nets"),k=t("gl-mat4/multiply"),A=t("gl-mat4/invert"),M=t("binary-search-bounds"),T=t("ndarray-gradient"),E=t("./lib/shaders"),L=E.createShader,S=E.createContourShader,C=E.createPickShader,z=E.createPickContourShader,P=40,R=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],O=[[0,0],[0,1],[1,0],[1,1],[1,0],[0,1]],I=[[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 t=0;3>t;++t){var e=I[t],r=(t+1)%3,n=(t+2)%3;e[r+0]=1,e[n+3]=1,e[t+6]=1}}();var N=265,j=a.prototype;j.isTransparent=function(){return this.opacity<1},j.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;3>t;++t)if(this._contourCounts[t].length>0||this._dynamicCounts[t]>0)return!0;return!1},j.pickSlots=1,j.setPickBase=function(t){this.pickId=t};var F=[0,0,0],D={showSurface:!1,showContour:!1,projections:[R.slice(),R.slice(),R.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]},B={model:R,view:R,projection:R,inverseModel:R.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1e3,1e3,1e3],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1},U=R.slice(),V=[1,0,0,0,1,0,0,0,1];j.draw=function(t){return s.call(this,t,!1)},j.drawTransparent=function(t){return s.call(this,t,!0)};var q={model:R,view:R,projection:R,inverseModel:R,clipBounds:[[0,0,0],[0,0,0]],height:0,shape:[0,0],pickId:0,lowerBound:[0,0,0],upperBound:[0,0,0],zOffset:0,permutation:[1,0,0,0,1,0,0,0,1],lightPosition:[0,0,0],eyePosition:[0,0,0]};j.drawPick=function(t){t=t||{};var e=this.gl;e.disable(e.CULL_FACE);var r=q;r.model=t.model||R,r.view=t.view||R,r.projection=t.projection||R,r.shape=this._field[2].shape,r.pickId=this.pickId/255,r.lowerBound=this.bounds[0],r.upperBound=this.bounds[1],r.permutation=V;for(var n=0;2>n;++n)for(var i=r.clipBounds[n],a=0;3>a;++a)i[a]=Math.min(Math.max(this.clipBounds[n][a],-1e8),1e8);var s=o(r,this);if(s.showSurface){for(this._pickShader.bind(),this._pickShader.uniforms=r,this._vao.bind(),this._vao.draw(e.TRIANGLES,this._vertexCount),n=0;3>n;++n)this.surfaceProject[n]&&(this._pickShader.uniforms.model=s.projections[n],this._pickShader.uniforms.clipBounds=s.clipBounds[n],this._vao.draw(e.TRIANGLES,this._vertexCount));this._vao.unbind()}if(s.showContour){var l=this._contourPickShader;l.bind(),l.uniforms=r;var c=this._contourVAO;for(c.bind(),a=0;3>a;++a)for(e.lineWidth(this.contourWidth[a]),l.uniforms.permutation=I[a],n=0;nn;++n)for(l.uniforms.model=s.projections[n],l.uniforms.clipBounds=s.clipBounds[n],a=0;3>a;++a)if(this.contourProject[n][a]){l.uniforms.permutation=I[a],e.lineWidth(this.contourWidth[a]);for(var u=0;u>4)/16)/255,i=Math.floor(n),a=n-i,o=e[1]*(t.value[1]+(15&t.value[2])/16)/255,s=Math.floor(o),l=o-s;i+=1,s+=1;var c=r.position;c[0]=c[1]=c[2]=0;for(var u=0;2>u;++u)for(var f=u?a:1-a,h=0;2>h;++h)for(var d=h?l:1-l,p=i+u,g=s+h,v=f*d,m=0;3>m;++m)c[m]+=this._field[m].get(p,g)*v;for(var y=this._pickResult.level,b=0;3>b;++b)if(y[b]=M.le(this.contourLevels[b],c[b]),y[b]<0)this.contourLevels[b].length>0&&(y[b]=0);else if(y[b]Math.abs(_-c[b])&&(y[b]+=1)}for(r.index[0]=.5>a?i:i+1,r.index[1]=.5>l?s:s+1,r.uv[0]=n/e[0],r.uv[1]=o/e[1],m=0;3>m;++m)r.dataCoordinate[m]=this._field[m].get(r.index[0],r.index[1]);return r},j.update=function(t){t=t||{},this.dirty=!0,"contourWidth"in t&&(this.contourWidth=c(t.contourWidth,Number)),"showContour"in t&&(this.showContour=c(t.showContour,Boolean)),"showSurface"in t&&(this.showSurface=!!t.showSurface),"contourTint"in t&&(this.contourTint=c(t.contourTint,Boolean)),"contourColor"in t&&(this.contourColor=f(t.contourColor)),"contourProject"in t&&(this.contourProject=c(t.contourProject,function(t){return c(t,Boolean)})),"surfaceProject"in t&&(this.surfaceProject=t.surfaceProject),"dynamicColor"in t&&(this.dynamicColor=f(t.dynamicColor)),"dynamicTint"in t&&(this.dynamicTint=c(t.dynamicTint,Number)),"dynamicWidth"in t&&(this.dynamicWidth=c(t.dynamicWidth,Number)),"opacity"in t&&(this.opacity=t.opacity),"colorBounds"in t&&(this.colorBounds=t.colorBounds);var e=t.field||t.coords&&t.coords[2]||null,r=!1;if(e||(e=this._field[2].shape[0]||this._field[2].shape[2]?this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2):this._field[2].hi(0,0)),"field"in t||"coords"in t){var n=(e.shape[0]+2)*(e.shape[1]+2);n>this._field[2].data.length&&(m.freeFloat(this._field[2].data),this._field[2].data=m.mallocFloat(d.nextPow2(n))),this._field[2]=_(this._field[2].data,[e.shape[0]+2,e.shape[1]+2]),l(this._field[2],e),this.shape=e.shape.slice();for(var a=this.shape,o=0;2>o;++o)this._field[2].size>this._field[o].data.length&&(m.freeFloat(this._field[o].data),this._field[o].data=m.mallocFloat(this._field[2].size)),this._field[o]=_(this._field[o].data,[a[0]+2,a[1]+2]);if(t.coords){var s=t.coords;if(!Array.isArray(s)||3!==s.length)throw new Error("gl-surface: invalid coordinates for x/y");for(o=0;2>o;++o){var u=s[o];for(y=0;2>y;++y)if(u.shape[y]!==a[y])throw new Error("gl-surface: coords have incorrect shape");l(this._field[o],u)}}else if(t.ticks){var h=t.ticks;if(!Array.isArray(h)||2!==h.length)throw new Error("gl-surface: invalid ticks");for(o=0;2>o;++o){var p=h[o];if((Array.isArray(p)||p.length)&&(p=_(p)),p.shape[0]!==a[o])throw new Error("gl-surface: invalid tick length");var g=_(p.data,a);g.stride[o]=p.stride[0],g.stride[1^o]=0,l(this._field[o],g)}}else{for(o=0;2>o;++o){var v=[0,0];v[o]=1,this._field[o]=_(this._field[o].data,[a[0]+2,a[1]+2],v,0)}this._field[0].set(0,0,0);for(var y=0;yo;++o)T(x.pick(o),b[o],"mirror");var k=_(m.mallocFloat(3*b[2].size),[a[0]+2,a[1]+2,3]);for(o=0;oI?(I=Math.max(Math.abs(z),Math.abs(P),Math.abs(R)),1e-8>I?(R=1,P=z=0,I=1):I=1/I):I=1/Math.sqrt(I),k.set(o,y,0,z*I),k.set(o,y,1,P*I),k.set(o,y,2,R*I)}m.free(x.data);var N=[1/0,1/0,1/0],j=[-(1/0),-(1/0),-(1/0)],F=1/0,D=-(1/0),B=(a[0]-1)*(a[1]-1)*6,U=m.mallocFloat(d.nextPow2(10*B)),V=0,q=0;for(o=0;oH;++H)for(var G=0;2>G;++G)for(var Y=0;3>Y;++Y){var X=this._field[Y].get(1+o+H,1+y+G);if(isNaN(X)||!isFinite(X))continue t}for(Y=0;6>Y;++Y){var W=o+O[Y][0],Z=y+O[Y][1],K=this._field[0].get(W+1,Z+1),Q=this._field[1].get(W+1,Z+1);X=this._field[2].get(W+1,Z+1);var $=X;z=k.get(W+1,Z+1,0),P=k.get(W+1,Z+1,1),R=k.get(W+1,Z+1,2),t.intensity&&($=t.intensity.get(W,Z)),U[V++]=W,U[V++]=Z,U[V++]=K,U[V++]=Q,U[V++]=X,U[V++]=0,U[V++]=$,U[V++]=z,U[V++]=P,U[V++]=R,N[0]=Math.min(N[0],K),N[1]=Math.min(N[1],Q),N[2]=Math.min(N[2],X),F=Math.min(F,$),j[0]=Math.max(j[0],K),j[1]=Math.max(j[1],Q),j[2]=Math.max(j[2],X),D=Math.max(D,$),q+=1}}for(t.intensityBounds&&(F=+t.intensityBounds[0],D=+t.intensityBounds[1]),o=6;V>o;o+=10)U[o]=(U[o]-F)/(D-F);this._vertexCount=q, +}e.exports=n},{}],137:[function(t,e,r){"use strict";function n(t,e){var r=c(l(t,e),[e[e.length-1]]);return r[r.length-1]}function i(t,e,r,n){var i=n-e,a=-e/i;0>a?a=0:a>1&&(a=1);for(var o=1-a,s=t.length,l=new Array(s),c=0;s>c;++c)l[c]=a*t[c]+o*r[c];return l}function a(t,e){for(var r=[],a=[],o=n(t[t.length-1],e),s=t[t.length-1],l=t[0],c=0;co&&u>0||o>0&&0>u){var f=i(s,u,l,o);r.push(f),a.push(f.slice())}0>u?a.push(l.slice()):u>0?r.push(l.slice()):(r.push(l.slice()),a.push(l.slice())),o=u}return{positive:r,negative:a}}function o(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;la&&c>0||a>0&&0>c)&&r.push(i(o,c,s,a)),c>=0&&r.push(s.slice()),a=c}return r}function s(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;la&&c>0||a>0&&0>c)&&r.push(i(o,c,s,a)),0>=c&&r.push(s.slice()),a=c}return r}var l=t("robust-dot-product"),c=t("robust-sum");e.exports=a,e.exports.positive=o,e.exports.negative=s},{"robust-dot-product":138,"robust-sum":221}],138:[function(t,e,r){"use strict";function n(t,e){for(var r=i(t[0],e[0]),n=1;na;++a){for(var o=p,s=g,l=0;3>l;++l)s[l]=o[l]=r[l];s[3]=o[3]=1,s[a]+=1,f(s,s,e),s[3]<0&&(t[a]=1/0),o[a]-=1,f(o,o,e),o[3]<0&&(t[a]=1/0);var c=(o[0]/o[3]-s[0]/s[3])*n,u=(o[1]/o[3]-s[1]/s[3])*i;t[a]=.25*Math.sqrt(c*c+u*u)}return t}function a(t,e,r,n,a){var f=e.model||h,p=e.view||h,g=e.projection||h,y=t.bounds,a=a||l(f,p,g,y),b=a.axis;a.edges;c(d,p,f),c(d,g,d);for(var x=v,_=0;3>_;++_)x[_].lo=1/0,x[_].hi=-(1/0),x[_].pixelsPerDataUnit=1/0;var w=o(u(d,d));u(d,d);for(var k=0;3>k;++k){var A=(k+1)%3,M=(k+2)%3,T=m;t:for(var _=0;2>_;++_){var E=[];if(b[k]<0!=!!_){T[k]=y[_][k];for(var L=0;2>L;++L){T[A]=y[L^_][A];for(var S=0;2>S;++S)T[M]=y[S^L^_][M],E.push(T.slice())}for(var L=0;LS;++S)x[S].lo=Math.min(x[S].lo,M[S]),x[S].hi=Math.max(x[S].hi,M[S]),S!==k&&(x[S].pixelsPerDataUnit=Math.min(x[S].pixelsPerDataUnit,Math.abs(C[S])))}}}return x}e.exports=a;var o=t("extract-frustum-planes"),s=t("split-polygon"),l=t("./lib/cube.js"),c=t("gl-mat4/multiply"),u=t("gl-mat4/transpose"),f=t("gl-vec4/transformMat4"),h=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),d=new Float32Array(16),p=[0,0,0,1],g=[0,0,0,1],v=[new n(1/0,-(1/0),1/0),new n(1/0,-(1/0),1/0),new n(1/0,-(1/0),1/0)],m=[0,0,0]},{"./lib/cube.js":131,"extract-frustum-planes":136,"gl-mat4/multiply":98,"gl-mat4/transpose":106,"gl-vec4/transformMat4":186,"split-polygon":137}],140:[function(t,e,r){"use strict";var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, color;\nattribute float weight;\n\nuniform mat4 model, view, projection;\nuniform vec3 coordinates[3];\nuniform vec4 colors[3];\nuniform vec2 screenShape;\nuniform float lineWidth;\n\nvarying vec4 fragColor;\n\nvoid main() {\n vec3 vertexPosition = mix(coordinates[0],\n mix(coordinates[2], coordinates[1], 0.5 * (position + 1.0)), abs(position));\n\n vec4 clipPos = projection * view * model * vec4(vertexPosition, 1.0);\n vec2 clipOffset = (projection * view * model * vec4(color, 0.0)).xy;\n vec2 delta = weight * clipOffset * screenShape;\n vec2 lineOffset = normalize(vec2(delta.y, -delta.x)) / screenShape;\n\n gl_Position = vec4(clipPos.xy + clipPos.w * 0.5 * lineWidth * lineOffset, clipPos.z, clipPos.w);\n fragColor = color.x * colors[0] + color.y * colors[1] + color.z * colors[2];\n}\n",a="precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}";e.exports=function(t){return n(t,i,a,null,[{name:"position",type:"vec3"},{name:"color",type:"vec3"},{name:"weight",type:"float"}])}},{"gl-shader":156}],141:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n,this.pixelRatio=1,this.bounds=[[-1e3,-1e3,-1e3],[1e3,1e3,1e3]],this.position=[0,0,0],this.lineWidth=[2,2,2],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.enabled=[!0,!0,!0],this.drawSides=[!0,!0,!0],this.axes=null}function i(t,e){function r(t,e,r,n,a,o){var s=[t,e,r,0,0,0,1];s[n+3]=1,s[n]=a,i.push.apply(i,s),s[6]=-1,i.push.apply(i,s),s[n]=o,i.push.apply(i,s),i.push.apply(i,s),s[6]=1,i.push.apply(i,s),s[n]=a,i.push.apply(i,s)}var i=[];r(0,0,0,0,0,1),r(0,0,0,1,0,1),r(0,0,0,2,0,1),r(1,0,0,1,-1,1),r(1,0,0,2,-1,1),r(0,1,0,0,-1,1),r(0,1,0,2,-1,1),r(0,0,1,0,-1,1),r(0,0,1,1,-1,1);var l=a(t,i),c=o(t,[{type:t.FLOAT,buffer:l,size:3,offset:0,stride:28},{type:t.FLOAT,buffer:l,size:3,offset:12,stride:28},{type:t.FLOAT,buffer:l,size:1,offset:24,stride:28}]),u=s(t);u.attributes.position.location=0,u.attributes.color.location=1,u.attributes.weight.location=2;var f=new n(t,l,c,u);return f.update(e),f}var a=t("gl-buffer"),o=t("gl-vao"),s=t("./shaders/index");e.exports=i;var l=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],c=n.prototype,u=[0,0,0],f=[0,0,0],h=[0,0];c.isTransparent=function(){return!1},c.drawTransparent=function(t){},c.draw=function(t){var e=this.gl,r=this.vao,n=this.shader;r.bind(),n.bind();var i,a=t.model||l,o=t.view||l,s=t.projection||l;this.axes&&(i=this.axes.lastCubeProps.axis);for(var c=u,d=f,p=0;3>p;++p)i&&i[p]<0?(c[p]=this.bounds[0][p],d[p]=this.bounds[1][p]):(c[p]=this.bounds[1][p],d[p]=this.bounds[0][p]);h[0]=e.drawingBufferWidth,h[1]=e.drawingBufferHeight,n.uniforms.model=a,n.uniforms.view=o,n.uniforms.projection=s,n.uniforms.coordinates=[this.position,c,d],n.uniforms.colors=this.colors,n.uniforms.screenShape=h;for(var p=0;3>p;++p)n.uniforms.lineWidth=this.lineWidth[p]*this.pixelRatio,this.enabled[p]&&(r.draw(e.TRIANGLES,6,6*p),this.drawSides[p]&&r.draw(e.TRIANGLES,12,18+12*p));r.unbind()},c.update=function(t){t&&("bounds"in t&&(this.bounds=t.bounds),"position"in t&&(this.position=t.position),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"colors"in t&&(this.colors=t.colors),"enabled"in t&&(this.enabled=t.enabled),"drawSides"in t&&(this.drawSides=t.drawSides))},c.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders/index":140,"gl-buffer":77,"gl-vao":185}],142:[function(t,e,r){"use strict";function n(){this.mouse=[-1,-1],this.screen=null,this.distance=1/0,this.index=null,this.dataCoordinate=null,this.dataPosition=null,this.object=null,this.data=null}function i(t,e){var r=null;try{r=t.getContext("webgl",e),r||(r=t.getContext("experimental-webgl",e))}catch(n){return null}return r}function a(t){var e=Math.round(Math.log(Math.abs(t))/Math.log(10));if(0>e){var r=Math.round(Math.pow(10,-e));return Math.ceil(t*r)/r}if(e>0){var r=Math.round(Math.pow(10,e));return Math.ceil(t/r)*r}return Math.ceil(t)}function o(t){return"boolean"==typeof t?t:!0}function s(t){function e(){if(!_&&H.autoResize){var t=w.parentNode,e=1,r=1;t&&t!==document.body?(e=t.clientWidth,r=t.clientHeight):(e=window.innerWidth,r=window.innerHeight);var n=0|Math.ceil(e*H.pixelRatio),i=0|Math.ceil(r*H.pixelRatio);if(n!==w.width||i!==w.height){w.width=n,w.height=i;var a=w.style;a.position=a.position||"absolute",a.left="0px",a.top="0px",a.width=e+"px",a.height=r+"px",F=!0}}}function r(){for(var t=O.length,e=j.length,r=0;e>r;++r)N[r]=0;t:for(var r=0;t>r;++r){var n=O[r],i=n.pickSlots;if(i){for(var a=0;e>a;++a)if(N[a]+i<255){I[r]=a,n.setPickBase(N[a]+1),N[a]+=i;continue t}var o=h(A,q);I[r]=e,j.push(o),N.push(i),n.setPickBase(1),e+=1}else I[r]=-1}for(;e>0&&0===N[e-1];)N.pop(),j.pop().dispose()}function s(){return H.contextLost?!0:void(A.isContextLost()&&(H.contextLost=!0,H.mouseListener.enabled=!1,H.selection.object=null,H.oncontextloss&&H.oncontextloss()))}function y(){if(!s()){A.colorMask(!0,!0,!0,!0),A.depthMask(!0),A.disable(A.BLEND),A.enable(A.DEPTH_TEST);for(var t=O.length,e=j.length,r=0;e>r;++r){var n=j[r];n.shape=G,n.begin();for(var i=0;t>i;++i)if(I[i]===r){var a=O[i];a.drawPick&&(a.pixelRatio=1,a.drawPick(V))}n.end()}}}function b(){if(!s()){e();var t=H.camera.tick();V.view=H.camera.matrix,F=F||t,D=D||t,z.pixelRatio=H.pixelRatio,R.pixelRatio=H.pixelRatio;var r=O.length,n=W[0],i=W[1];n[0]=n[1]=n[2]=1/0,i[0]=i[1]=i[2]=-(1/0);for(var o=0;r>o;++o){var l=O[o];l.pixelRatio=H.pixelRatio,l.axes=H.axes,F=F||!!l.dirty,D=D||!!l.dirty;var c=l.bounds;if(c)for(var f=c[0],h=c[1],d=0;3>d;++d)n[d]=Math.min(n[d],f[d]),i[d]=Math.max(i[d],h[d])}var g=H.bounds;if(H.autoBounds)for(var d=0;3>d;++d){if(i[d]d;++d)b=b||Z[0][d]!==g[0][d]||Z[1][d]!==g[1][d],Z[0][d]=g[0][d],Z[1][d]=g[1][d];if(b){for(var x=[0,0,0],o=0;3>o;++o)x[o]=a((g[1][o]-g[0][o])/10);z.autoTicks?z.update({bounds:g,tickSpacing:x}):z.update({bounds:g})}D=D||b,F=F||b;var _=A.drawingBufferWidth,w=A.drawingBufferHeight;q[0]=_,q[1]=w,G[0]=0|Math.max(_/H.pixelRatio,1),G[1]=0|Math.max(w/H.pixelRatio,1),v(B,H.fovy,_/w,H.zNear,H.zFar);for(var o=0;16>o;++o)U[o]=0;U[15]=1;for(var k=0,o=0;3>o;++o)k=Math.max(k,g[1][o]-g[0][o]);for(var o=0;3>o;++o)H.autoScale?U[5*o]=H.aspect[o]/(g[1][o]-g[0][o]):U[5*o]=1/k,H.autoCenter&&(U[12+o]=.5*-U[5*o]*(g[0][o]+g[1][o]));for(var o=0;r>o;++o){var l=O[o];l.axesBounds=g,H.clipToBounds&&(l.clipBounds=g)}if(T.object&&(H.snapToData?R.position=T.dataCoordinate:R.position=T.dataPosition,R.bounds=g),D&&(D=!1,y()),F){H.axesPixels=u(H.axes,V,_,w),H.onrender&&H.onrender(),A.bindFramebuffer(A.FRAMEBUFFER,null),A.viewport(0,0,_,w);var M=H.clearColor;A.clearColor(M[0],M[1],M[2],M[3]),A.clear(A.COLOR_BUFFER_BIT|A.DEPTH_BUFFER_BIT),A.depthMask(!0),A.colorMask(!0,!0,!0,!0),A.enable(A.DEPTH_TEST),A.depthFunc(A.LEQUAL),A.disable(A.BLEND),A.disable(A.CULL_FACE);var S=!1;z.enable&&(S=S||z.isTransparent(),z.draw(V)),R.axes=z,T.object&&R.draw(V),A.disable(A.CULL_FACE);for(var o=0;r>o;++o){var l=O[o];l.axes=z,l.pixelRatio=H.pixelRatio,l.isOpaque&&l.isOpaque()&&l.draw(V),l.isTransparent&&l.isTransparent()&&(S=!0)}if(S){E.shape=q,E.bind(),A.clear(A.DEPTH_BUFFER_BIT),A.colorMask(!1,!1,!1,!1),A.depthMask(!0),A.depthFunc(A.LESS),z.enable&&z.isTransparent()&&z.drawTransparent(V);for(var o=0;r>o;++o){var l=O[o];l.isOpaque&&l.isOpaque()&&l.draw(V)}A.enable(A.BLEND),A.blendEquation(A.FUNC_ADD),A.blendFunc(A.ONE,A.ONE_MINUS_SRC_ALPHA),A.colorMask(!0,!0,!0,!0),A.depthMask(!1),A.clearColor(0,0,0,0),A.clear(A.COLOR_BUFFER_BIT),z.isTransparent()&&z.drawTransparent(V);for(var o=0;r>o;++o){var l=O[o];l.isTransparent&&l.isTransparent()&&l.drawTransparent(V)}A.bindFramebuffer(A.FRAMEBUFFER,null),A.blendFunc(A.ONE,A.ONE_MINUS_SRC_ALPHA),A.disable(A.DEPTH_TEST),L.bind(),E.color[0].bind(0),L.uniforms.accumBuffer=0,p(A),A.disable(A.BLEND)}F=!1;for(var o=0;r>o;++o)O[o].dirty=!1}}}function x(){_||H.contextLost||(requestAnimationFrame(x),b())}t=t||{};var _=!1,w=(t.pixelRatio||parseFloat(window.devicePixelRatio),t.canvas);if(!w)if(w=document.createElement("canvas"),t.container){var k=t.container;k.appendChild(w)}else document.body.appendChild(w);var A=t.gl;if(A||(A=i(w,t.glOptions||{premultipliedAlpha:!0,antialias:!0})),!A)throw new Error("webgl not supported");var M=t.bounds||[[-10,-10,-10],[10,10,10]],T=new n,E=d(A,[A.drawingBufferWidth,A.drawingBufferHeight],{preferFloat:!0}),L=m(A),S=t.camera||{eye:[2,0,0],center:[0,0,0],up:[0,1,0],zoomMin:.1,zoomMax:100,mode:"turntable"},C=t.axes||{},z=c(A,C);z.enable=!C.disable;var P=t.spikes||{},R=f(A,P),O=[],I=[],N=[],j=[],F=!0,D=!0,B=new Array(16),U=new Array(16),V={view:null,projection:B,model:U},D=!0,q=[A.drawingBufferWidth,A.drawingBufferHeight],H={gl:A,contextLost:!1,pixelRatio:t.pixelRatio||parseFloat(window.devicePixelRatio),canvas:w,selection:T,camera:l(w,S),axes:z,axesPixels:null,spikes:R,bounds:M,objects:O,shape:q,aspect:t.aspectRatio||[1,1,1],pickRadius:t.pickRadius||10,zNear:t.zNear||.01,zFar:t.zFar||1e3,fovy:t.fovy||Math.PI/4,clearColor:t.clearColor||[0,0,0,0],autoResize:o(t.autoResize),autoBounds:o(t.autoBounds),autoScale:!!t.autoScale,autoCenter:o(t.autoCenter),clipToBounds:o(t.clipToBounds),snapToData:!!t.snapToData,onselect:t.onselect||null,onrender:t.onrender||null,onclick:t.onclick||null,cameraParams:V,oncontextloss:null,mouseListener:null},G=[A.drawingBufferWidth/H.pixelRatio|0,A.drawingBufferHeight/H.pixelRatio|0];H.autoResize&&e(),window.addEventListener("resize",e),H.update=function(t){_||(t=t||{},F=!0,D=!0)},H.add=function(t){_||(t.axes=z,O.push(t),I.push(-1),F=!0,D=!0,r())},H.remove=function(t){if(!_){var e=O.indexOf(t);0>e||(O.splice(e,1),I.pop(),F=!0,D=!0,r())}},H.dispose=function(){if(!_&&(_=!0,window.removeEventListener("resize",e),w.removeEventListener("webglcontextlost",s),H.mouseListener.enabled=!1,!H.contextLost)){z.dispose(),R.dispose();for(var t=0;ts;++s){var l=j[s].query(e,G[1]-r-1,H.pickRadius);if(l){if(l.distance>T.distance)continue;for(var c=0;i>c;++c){var u=O[c];if(I[c]===s){var f=u.pick(l);f&&(T.buttons=t,T.screen=l.coord,T.distance=l.distance,T.object=u,T.index=f.distance,T.dataPosition=f.position,T.dataCoordinate=f.dataCoordinate,T.data=f,o=!0)}}}}}a&&a!==T.object&&(a.highlight&&a.highlight(null),F=!0),T.object&&(T.object.highlight&&T.object.highlight(T.data),F=!0),o=o||T.object!==a,o&&H.onselect&&H.onselect(T),1&t&&!(1&X)&&H.onclick&&H.onclick(T),X=t}}),w.addEventListener("webglcontextlost",s);var W=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],Z=[W[0].slice(),W[1].slice()];return x(),H.redraw=function(){_||(F=!0,b())},H}e.exports=s;var l=t("3d-view-controls"),c=t("gl-axes3d"),u=t("gl-axes3d/properties"),f=t("gl-spikes3d"),h=t("gl-select-static"),d=t("gl-fbo"),p=t("a-big-triangle"),g=t("mouse-change"),v=t("gl-mat4/perspective"),m=t("./lib/shader")},{"./lib/shader":125,"3d-view-controls":126,"a-big-triangle":128,"gl-axes3d":129,"gl-axes3d/properties":139,"gl-fbo":82,"gl-mat4/perspective":99,"gl-select-static":155,"gl-spikes3d":141,"mouse-change":200}],143:[function(t,e,r){"use strict";e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n fragColor = color;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n",fragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n}\n",pickVertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 id;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\nuniform vec4 pickOffset;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n vec4 fragId = id + pickOffset;\n\n fragId.y += floor(fragId.x / 256.0);\n fragId.x -= floor(fragId.x / 256.0) * 256.0;\n\n fragId.z += floor(fragId.y / 256.0);\n fragId.y -= floor(fragId.y / 256.0) * 256.0;\n\n fragId.w += floor(fragId.z / 256.0);\n fragId.z -= floor(fragId.z / 256.0) * 256.0;\n\n fragColor = fragId / 255.0;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n",pickFragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = fragColor;\n}\n"}},{}],144:[function(t,e,r){"use strict";function n(t){if(t in h)return h[t];var e=u(t,{polygons:!0,font:"sans-serif",textAlign:"left",textBaseline:"alphabetic"}),r=[],n=[];e.forEach(function(t){t.forEach(function(t){for(var e=0;eo;++o)i[o]=Math.min(i[o],r[a+o]),i[2+o]=Math.max(i[2+o],r[a+o]);return h[t]={coords:r,normals:n,bounds:i}}function i(t,e,r,n,i,a,o){this.plot=t,this.shader=e,this.pickShader=r,this.positionBuffer=n,this.offsetBuffer=i,this.colorBuffer=a,this.idBuffer=o,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.numVertices=0,this.pickOffset=0,this.points=null}function a(t,e){var r=t.gl,n=o(r,f.vertex,f.fragment),a=o(r,f.pickVertex,f.pickFragment),l=s(r),c=s(r),u=s(r),h=s(r),d=new i(t,n,a,l,c,u,h);return d.update(e),t.addObject(d),d}e.exports=a;var o=t("gl-shader"),s=t("gl-buffer"),l=t("text-cache"),c=t("typedarray-pool"),u=t("vectorize-text"),f=t("./lib/shaders"),h={},d=i.prototype;!function(){function t(){var t=this.plot,n=this.bounds,i=t.viewBox,a=t.dataBox,o=t.pixelRatio,s=n[2]-n[0],l=n[3]-n[1],c=a[2]-a[0],u=a[3]-a[1];e[0]=2*s/c,e[4]=2*l/u,e[6]=2*(n[0]-a[0])/c-1,e[7]=2*(n[1]-a[1])/u-1;var f=i[2]-i[0],h=i[3]-i[1];r[0]=2*o/f,r[1]=2*o/h}var e=[1,0,0,0,1,0,0,0,1],r=[1,1];d.draw=function(){var n=this.plot,i=this.shader,a=this.numVertices;if(a){var o=n.gl;t.call(this),i.bind(),i.uniforms.pixelScale=r,i.uniforms.viewTransform=e,this.positionBuffer.bind(),i.attributes.position.pointer(),this.offsetBuffer.bind(),i.attributes.offset.pointer(),this.colorBuffer.bind(),i.attributes.color.pointer(o.UNSIGNED_BYTE,!0),o.drawArrays(o.TRIANGLES,0,a)}};var n=[0,0,0,0];d.drawPick=function(i){var a=this.plot,o=this.pickShader,s=this.numVertices,l=a.gl;if(this.pickOffset=i,!s)return i;for(var c=0;4>c;++c)n[c]=i>>8*c&255;return t.call(this),o.bind(),o.uniforms.pixelScale=r,o.uniforms.viewTransform=e,o.uniforms.pickOffset=n,this.positionBuffer.bind(),o.attributes.position.pointer(),this.offsetBuffer.bind(),o.attributes.offset.pointer(),this.idBuffer.bind(),o.attributes.id.pointer(l.UNSIGNED_BYTE,!1),l.drawArrays(l.TRIANGLES,0,s),i+this.numPoints}}(),d.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},d.update=function(t){t=t||{};var e=t.positions||[],r=t.colors||[],i=t.glyphs||[],a=t.sizes||[],o=t.borderWidths||[],s=t.borderColors||[];this.points=e;for(var u=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=0,h=0;h>1;for(var d=0;2>d;++d)u[d]=Math.min(u[d],e[2*h+d]),u[2+d]=Math.max(u[2+d],e[2*h+d])}u[0]===u[2]&&(u[2]+=1),u[3]===u[1]&&(u[3]+=1);for(var p=1/(u[2]-u[0]),g=1/(u[3]-u[1]),v=u[0],m=u[1],y=c.mallocFloat32(2*f),b=c.mallocFloat32(2*f),x=c.mallocUint8(4*f),_=c.mallocUint32(f),w=0,h=0;h=a?i(0,a-1,t,e,r,n):f(0,a-1,t,e,r,n)}function i(t,e,r,n,i,a){for(var o=t+1;e>=o;++o){for(var s=r[o],l=n[2*o],c=n[2*o+1],u=i[o],f=a[o],h=o;h>t;){var d=r[h-1],p=n[2*(h-1)];if((d-s||l-p)>=0)break;r[h]=d,n[2*h]=p,n[2*h+1]=n[2*h-1],i[h]=i[h-1],a[h]=a[h-1],h-=1}r[h]=s,n[2*h]=l,n[2*h+1]=c,i[h]=u,a[h]=f}}function a(t,e,r,n,i,a){var o=r[t],s=n[2*t],l=n[2*t+1],c=i[t],u=a[t];r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e],r[e]=o,n[2*e]=s,n[2*e+1]=l,i[e]=c,a[e]=u}function o(t,e,r,n,i,a){r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e]}function s(t,e,r,n,i,a,o){var s=n[t],l=i[2*t],c=i[2*t+1],u=a[t],f=o[t];n[t]=n[e],i[2*t]=i[2*e],i[2*t+1]=i[2*e+1],a[t]=a[e],o[t]=o[e],n[e]=n[r],i[2*e]=i[2*r],i[2*e+1]=i[2*r+1],a[e]=a[r],o[e]=o[r],n[r]=s,i[2*r]=l,i[2*r+1]=c,a[r]=u,o[r]=f}function l(t,e,r,n,i,a,o,s,l,c,u){s[t]=s[e],l[2*t]=l[2*e],l[2*t+1]=l[2*e+1],c[t]=c[e],u[t]=u[e],s[e]=r,l[2*e]=n,l[2*e+1]=i,c[e]=a,u[e]=o}function c(t,e,r,n,i){return(r[t]-r[e]||n[2*e]-n[2*t]||i[t]-i[e])<0}function u(t,e,r,n,i,a,o,s){return(e-a[t]||o[2*t]-r||i-s[t])<0}function f(t,e,r,n,d,p){var g=(e-t+1)/6|0,v=t+g,m=e-g,y=t+e>>1,b=y-g,x=y+g,_=v,w=b,k=y,A=x,M=m,T=t+1,E=e-1,L=0;c(_,w,r,n,d,p)&&(L=_,_=w,w=L),c(A,M,r,n,d,p)&&(L=A,A=M,M=L),c(_,k,r,n,d,p)&&(L=_,_=k,k=L),c(w,k,r,n,d,p)&&(L=w,w=k,k=L),c(_,A,r,n,d,p)&&(L=_,_=A,A=L),c(k,A,r,n,d,p)&&(L=k,k=A,A=L),c(w,M,r,n,d,p)&&(L=w,w=M,M=L),c(w,k,r,n,d,p)&&(L=w,w=k,k=L),c(A,M,r,n,d,p)&&(L=A,A=M,M=L);var S=r[w],C=n[2*w],z=n[2*w+1],P=d[w],R=p[w],O=r[A],I=n[2*A],N=n[2*A+1],j=d[A],F=p[A],D=_,B=k,U=M,V=v,q=y,H=m,G=r[D],Y=r[B],X=r[U];r[V]=G,r[q]=Y,r[H]=X;for(var W=0;2>W;++W){var Z=n[2*D+W],K=n[2*B+W],$=n[2*U+W];n[2*V+W]=Z,n[2*q+W]=K,n[2*H+W]=$}var Q=d[D],J=d[B],tt=d[U];d[V]=Q,d[q]=J,d[H]=tt;var et=p[D],rt=p[B],nt=p[U];p[V]=et,p[q]=rt,p[H]=nt,o(b,t,r,n,d,p),o(x,e,r,n,d,p);for(var it=T;E>=it;++it)if(u(it,S,C,z,P,r,n,d))it!==T&&a(it,T,r,n,d,p),++T;else if(!u(it,O,I,N,j,r,n,d))for(;;){if(u(E,O,I,N,j,r,n,d)){u(E,S,C,z,P,r,n,d)?(s(it,T,E,r,n,d,p),++T,--E):(a(it,E,r,n,d,p),--E);break}if(--E=T-2-t?i(t,T-2,r,n,d,p):f(t,T-2,r,n,d,p),h>=e-(E+2)?i(E+2,e,r,n,d,p):f(E+2,e,r,n,d,p),h>=E-T?i(T,E,r,n,d,p):f(T,E,r,n,d,p)}e.exports=n;var h=32},{}],148:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s){for(var l=r,c=r;n>c;++c){var u=t[2*c],f=t[2*c+1],h=e[c];u>=i&&o>=u&&f>=a&&s>=f&&(c===l?l+=1:(t[2*c]=t[2*l],t[2*c+1]=t[2*l+1],e[c]=e[l],t[2*l]=u,t[2*l+1]=f,e[l]=h,l+=1))}return l}function i(t,e,r){this.pixelSize=t,this.offset=e,this.count=r}function a(t,e,r,a){function l(i,a,o,s,c,u){var f=.5*o,h=s+1,d=c-s;r[_]=d,x[_++]=u;for(var p=0;2>p;++p)for(var g=0;2>g;++g){var v=i+p*f,m=a+g*f,y=n(t,e,h,c,v,m,v+f,m+f);if(y!==h){if(y-h>=Math.max(.9*d,32)){var b=c+s>>>1;l(v,m,f,h,b,u+1),h=b}l(v,m,f,h,y,u+1),h=y}}}var c=t.length>>>1;if(1>c)return[];for(var u=1/0,f=1/0,h=-(1/0),d=-(1/0),p=0;c>p;++p){var g=t[2*p],v=t[2*p+1];u=Math.min(u,g),h=Math.max(h,g),f=Math.min(f,v),d=Math.max(d,v),e[p]=p}u===h&&(h+=1+Math.abs(h)),f===d&&(d+=1+Math.abs(h));var m=1/(h-u),y=1/(d-f),b=Math.max(h-u,d-f);a=a||[0,0,0,0],a[0]=u,a[1]=f,a[2]=h,a[3]=d;var x=o.mallocInt32(c),_=0;l(u,f,b,0,c,0),s(x,t,e,r,c);for(var w=[],k=0,A=c,_=c-1;_>=0;--_){t[2*_]=(t[2*_]-u)*m,t[2*_+1]=(t[2*_+1]-f)*y;var M=x[_];M!==k&&(w.push(new i(b*Math.pow(.5,M),_+1,A-(_+1))),A=_+1,k=M)}return w.push(new i(b*Math.pow(.5,M+1),0,A)),o.free(x),w}var o=t("typedarray-pool"),s=t("./lib/sort");e.exports=a},{"./lib/sort":147,"typedarray-pool":237}],149:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.weightBuffer=n,this.shader=i,this.pickShader=a,this.scales=[],this.size=12,this.borderSize=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.pickOffset=0,this.points=null,this.xCoords=null}function i(t,e){var r=t.gl,i=o(r),s=o(r),l=o(r),c=a(r,u.pointVertex,u.pointFragment),f=a(r,u.pickVertex,u.pickFragment),h=new n(t,i,s,l,c,f);return h.update(e),t.addObject(h),h}var a=t("gl-shader"),o=t("gl-buffer"),s=t("binary-search-bounds"),l=t("snap-points-2d"),c=t("typedarray-pool"),u=t("./lib/shader");e.exports=i;var f=n.prototype;f.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.xCoords&&c.free(this.xCoords),this.plot.removeObject(this)},f.update=function(t){function e(e,r){return e in t?t[e]:r}t=t||{},this.size=e("size",12),this.color=e("color",[1,0,0,1]).slice(),this.borderSize=e("borderSize",1),this.borderColor=e("borderColor",[0,0,0,1]).slice(),this.xCoords&&c.free(this.xCoords);var r=t.positions,n=c.mallocFloat32(r.length),i=c.mallocInt32(r.length>>>1);n.set(r);var a=c.mallocFloat32(r.length);this.points=r,this.scales=l(n,i,a,this.bounds),this.offsetBuffer.update(n),this.pickBuffer.update(i),this.weightBuffer.update(a);for(var o=c.mallocFloat32(r.length>>>1),s=0,u=0;s>>1,this.pickOffset=0},f.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0,0,0];return function(r){var n=this.plot,i=this.pickShader,a=this.scales,o=this.offsetBuffer,l=this.pickBuffer,c=this.bounds,u=this.size,f=this.borderSize,h=n.gl,d=n.pickPixelRatio,p=n.viewBox,g=n.dataBox;if(0===this.pointCount)return r;var v=c[2]-c[0],m=c[3]-c[1],y=g[2]-g[0],b=g[3]-g[1],x=(p[2]-p[0])*d/n.pixelRatio,_=(p[3]-p[1])*d/n.pixelRatio,w=Math.min(y/x,b/_);t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(c[0]-g[0])/y-1,t[7]=2*(c[1]-g[1])/b-1,this.pickOffset=r,e[0]=255&r,e[1]=r>>8&255,e[2]=r>>16&255,e[3]=r>>24&255,i.bind(),i.uniforms.matrix=t,i.uniforms.color=this.color,i.uniforms.borderColor=this.borderColor,i.uniforms.pointSize=d*(u+f),i.uniforms.pickOffset=e,0===this.borderSize?i.uniforms.centerFraction=2:i.uniforms.centerFraction=u/(u+f+1.25),o.bind(),i.attributes.position.pointer(),l.bind(),i.attributes.pickId.pointer(h.UNSIGNED_BYTE);for(var k=this.xCoords,A=(g[0]-c[0]-w*u*d)/v,M=(g[2]-c[0]+w*u*d)/v,T=a.length-1;T>=0;--T){var E=a[T];if(!(E.pixelSize1)){var L=E.offset,S=E.count+L,C=s.ge(k,A,L,S-1),z=s.lt(k,M,C,S-1)+1;z>C&&h.drawArrays(h.POINTS,C,z-C)}}return r+this.pointCount}}(),f.draw=function(){var t=[1,0,0,0,1,0,0,0,1];return function(){var e=this.plot,r=this.shader,n=this.scales,i=this.offsetBuffer,a=this.bounds,o=this.size,l=this.borderSize,c=e.gl,u=e.pixelRatio,f=e.viewBox,h=e.dataBox;if(0!==this.pointCount){var d=a[2]-a[0],p=a[3]-a[1],g=h[2]-h[0],v=h[3]-h[1],m=f[2]-f[0],y=f[3]-f[1],b=Math.min(g/m,v/y);t[0]=2*d/g,t[4]=2*p/v,t[6]=2*(a[0]-h[0])/g-1,t[7]=2*(a[1]-h[1])/v-1,r.bind(),r.uniforms.matrix=t,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointSize=u*(o+l),r.uniforms.useWeight=1,0===this.borderSize?r.uniforms.centerFraction=2:r.uniforms.centerFraction=o/(o+l+1.25),i.bind(),r.attributes.position.pointer(),this.weightBuffer.bind(),r.attributes.weight.pointer();for(var x=this.xCoords,_=(h[0]-a[0]-b*o*u)/d,w=(h[2]-a[0]+b*o*u)/d,k=!0,A=n.length-1;A>=0;--A){var M=n[A];if(!(M.pixelSize1)){var T=M.offset,E=M.count+T,L=s.ge(x,_,T,E-1),S=s.lt(x,w,L,E-1)+1;S>L&&c.drawArrays(c.POINTS,L,S-L),k&&(k=!1,r.uniforms.useWeight=0)}}}}}(),f.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}}},{"./lib/shader":145,"binary-search-bounds":146,"gl-buffer":77,"gl-shader":156,"snap-points-2d":148,"typedarray-pool":237}],150:[function(t,e,r){"use strict";function n(t,e){var r=a[e];if(r||(r=a[e]={}),t in r)return r[t];for(var n=i(t,{textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),o=i(t,{triangles:!0,textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),s=[[1/0,1/0],[-(1/0),-(1/0)]],l=0;lu;++u)s[0][u]=Math.min(s[0][u],c[u]),s[1][u]=Math.max(s[1][u],c[u]);return r[t]=[o,n,s]}var i=t("vectorize-text");e.exports=n;var a={}},{"vectorize-text":239}],151:[function(t,e,r){function n(t,e){var r=i(t,e),n=r.attributes;return n.position.location=0,n.color.location=1,n.glyph.location=2,n.id.location=3,r}var i=t("gl-shader"),a="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1])) ) {\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}",o="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || any(greaterThan(position, clipBounds[1]))) {\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}",s="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) ||\n any(greaterThan(position, clipBounds[1])) ) {\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",l="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if(any(lessThan(dataCoordinate, fragClipBounds[0])) ||\n any(greaterThan(dataCoordinate, fragClipBounds[1])) ) {\n discard;\n } else {\n gl_FragColor = interpColor * opacity;\n }\n}\n",c="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if(any(lessThan(dataCoordinate, fragClipBounds[0])) || \n any(greaterThan(dataCoordinate, fragClipBounds[1])) ) {\n discard;\n } else {\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n }\n}",u=[{ +name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"glyph",type:"vec2"},{name:"id",type:"vec4"}],f={vertex:a,fragment:l,attributes:u},h={vertex:o,fragment:l,attributes:u},d={vertex:s,fragment:l,attributes:u},p={vertex:a,fragment:c,attributes:u},g={vertex:o,fragment:c,attributes:u},v={vertex:s,fragment:c,attributes:u};r.createPerspective=function(t){return n(t,f)},r.createOrtho=function(t){return n(t,h)},r.createProject=function(t){return n(t,d)},r.createPickPerspective=function(t){return n(t,p)},r.createPickOrtho=function(t){return n(t,g)},r.createPickProject=function(t){return n(t,v)}},{"gl-shader":156}],152:[function(t,e,r){"use strict";function n(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];return t[0]=e[0]*r+e[4]*n+e[8]*i+e[12]*a,t[1]=e[1]*r+e[5]*n+e[9]*i+e[13]*a,t[2]=e[2]*r+e[6]*n+e[10]*i+e[14]*a,t[3]=e[3]*r+e[7]*n+e[11]*i+e[15]*a,t}function i(t,e,r,i){return n(i,i,r),n(i,i,e),n(i,i,t)}function a(t,e){this.index=t,this.dataCoordinate=this.position=e}function o(t,e,r,n,i,o,s,l,c,u,f,h){this.gl=t,this.pixelRatio=1,this.shader=e,this.orthoShader=r,this.projectShader=n,this.pointBuffer=i,this.colorBuffer=o,this.glyphBuffer=s,this.idBuffer=l,this.vao=c,this.vertexCount=0,this.lineVertexCount=0,this.opacity=1,this.lineWidth=0,this.projectScale=[2/3,2/3,2/3],this.projectOpacity=[1,1,1],this.pickId=0,this.pickPerspectiveShader=u,this.pickOrthoShader=f,this.pickProjectShader=h,this.points=[],this._selectResult=new a(0,[0,0,0]),this.useOrtho=!0,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.axesProject=[!0,!0,!0],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.highlightId=[1,1,1,1],this.highlightScale=2,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.dirty=!0}function s(t){return t[0]=t[1]=t[2]=0,t}function l(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t}function c(t,e,r,n){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[r]=n,t}function u(t){for(var e=S,r=0;2>r;++r)for(var n=0;3>n;++n)e[r][n]=Math.max(Math.min(t[r][n],1e8),-1e8);return e}function f(t,e,r,n,a){var o,f=e.axesProject,h=e.gl,d=t.uniforms,p=r.model||x,g=r.view||x,v=r.projection||x,y=e.axesBounds,b=u(e.clipBounds);o=e.axes?e.axes.lastCubeProps.axis:[1,1,1],w[0]=2/h.drawingBufferWidth,w[1]=2/h.drawingBufferHeight,t.bind(),d.view=g,d.projection=v,d.screenSize=w,d.highlightId=e.highlightId,d.highlightScale=e.highlightScale,d.clipBounds=b,d.pickGroup=e.pickId/255,d.pixelRatio=e.pixelRatio;for(var _=0;3>_;++_)if(f[_]&&e.projectOpacity[_]<1===n){d.scale=e.projectScale[_],d.opacity=e.projectOpacity[_];for(var S=E,C=0;16>C;++C)S[C]=0;for(var C=0;4>C;++C)S[5*C]=1;S[5*_]=0,o[_]<0?S[12+_]=y[0][_]:S[12+_]=y[1][_],m(S,p,S),d.model=S;var z=(_+1)%3,P=(_+2)%3,R=s(k),O=s(A);R[z]=1,O[P]=1;var I=i(v,g,p,l(M,R)),N=i(v,g,p,l(T,O));if(Math.abs(I[1])>Math.abs(N[1])){var j=I;I=N,N=j,j=R,R=O,O=j;var F=z;z=P,P=F}I[0]<0&&(R[z]=-1),N[1]>0&&(O[P]=-1);for(var D=0,B=0,C=0;4>C;++C)D+=Math.pow(p[4*z+C],2),B+=Math.pow(p[4*P+C],2);R[z]/=Math.sqrt(D),O[P]/=Math.sqrt(B),d.axes[0]=R,d.axes[1]=O,d.fragClipBounds[0]=c(L,b[0],_,-1e8),d.fragClipBounds[1]=c(L,b[1],_,1e8),e.vao.draw(h.TRIANGLES,e.vertexCount),e.lineWidth>0&&(h.lineWidth(e.lineWidth),e.vao.draw(h.LINES,e.lineVertexCount,e.vertexCount))}}function h(t,e,r,n,i,a){var o=r.gl;if(r.vao.bind(),i===r.opacity<1||a){t.bind();var s=t.uniforms;s.model=n.model||x,s.view=n.view||x,s.projection=n.projection||x,w[0]=2/o.drawingBufferWidth,w[1]=2/o.drawingBufferHeight,s.screenSize=w,s.highlightId=r.highlightId,s.highlightScale=r.highlightScale,s.fragClipBounds=P,s.clipBounds=r.axes.bounds,s.opacity=r.opacity,s.pickGroup=r.pickId/255,s.pixelRatio=r.pixelRatio,r.vao.draw(o.TRIANGLES,r.vertexCount),r.lineWidth>0&&(o.lineWidth(r.lineWidth),r.vao.draw(o.LINES,r.lineVertexCount,r.vertexCount))}f(e,r,n,i,a),r.vao.unbind()}function d(t){var e=t.gl,r=y.createPerspective(e),n=y.createOrtho(e),i=y.createProject(e),a=y.createPickPerspective(e),s=y.createPickOrtho(e),l=y.createPickProject(e),c=p(e),u=p(e),f=p(e),h=p(e),d=g(e,[{buffer:c,size:3,type:e.FLOAT},{buffer:u,size:4,type:e.FLOAT},{buffer:f,size:2,type:e.FLOAT},{buffer:h,size:4,type:e.UNSIGNED_BYTE,normalized:!0}]),v=new o(e,r,n,i,c,u,f,h,d,a,s,l);return v.update(t),v}var p=t("gl-buffer"),g=t("gl-vao"),v=t("typedarray-pool"),m=t("gl-mat4/multiply"),y=t("./lib/shaders"),b=t("./lib/glyphs"),x=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];e.exports=d;var _=o.prototype;_.pickSlots=1,_.setPickBase=function(t){this.pickId=t},_.isTransparent=function(){if(this.opacity<1)return!0;for(var t=0;3>t;++t)if(this.axesProject[t]&&this.projectOpacity[t]<1)return!0;return!1},_.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;3>t;++t)if(this.axesProject[t]&&this.projectOpacity[t]>=1)return!0;return!1};var w=[0,0],k=[0,0,0],A=[0,0,0],M=[0,0,0,1],T=[0,0,0,1],E=x.slice(),L=[0,0,0],S=[[0,0,0],[0,0,0]],C=[-1e8,-1e8,-1e8],z=[1e8,1e8,1e8],P=[C,z];_.draw=function(t){var e=this.useOrtho?this.orthoShader:this.shader;h(e,this.projectShader,this,t,!1,!1)},_.drawTransparent=function(t){var e=this.useOrtho?this.orthoShader:this.shader;h(e,this.projectShader,this,t,!0,!1)},_.drawPick=function(t){var e=this.useOrtho?this.pickOrthoShader:this.pickPerspectiveShader;h(e,this.pickProjectShader,this,t,!1,!0)},_.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[2]+(t.value[1]<<8)+(t.value[0]<<16);if(e>=this.pointCount||0>e)return null;var r=this.points[e],n=this._selectResult;n.index=e;for(var i=0;3>i;++i)n.position[i]=n.dataCoordinate[i]=r[i];return n},_.highlight=function(t){if(t){var e=t.index,r=255&e,n=e>>8&255,i=e>>16&255;this.highlightId=[r/255,n/255,i/255,0]}else this.highlightId=[1,1,1,1]},_.update=function(t){if(t=t||{},"perspective"in t&&(this.useOrtho=!t.perspective),"orthographic"in t&&(this.useOrtho=!!t.orthographic),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"project"in t)if(Array.isArray(t.project))this.axesProject=t.project;else{var e=!!t.project;this.axesProject=[e,e,e]}if("projectScale"in t)if(Array.isArray(t.projectScale))this.projectScale=t.projectScale.slice();else{var r=+t.projectScale;this.projectScale=[r,r,r]}if("projectOpacity"in t)if(Array.isArray(t.projectOpacity))this.projectOpacity=t.projectOpacity.slice();else{var r=+t.projectOpacity;this.projectOpacity=[r,r,r]}"opacity"in t&&(this.opacity=t.opacity),this.dirty=!0;var n=t.position;if(n){var i=t.font||"normal",a=t.alignment||[0,0],o=[1/0,1/0,1/0],s=[-(1/0),-(1/0),-(1/0)],l=t.glyph,c=t.color,u=t.size,f=t.angle,h=t.lineColor,d=0,p=0,g=0,m=n.length;t:for(var y=0;m>y;++y){for(var x=n[y],_=0;3>_;++_)if(isNaN(x[_])||!isFinite(x[_]))continue t;var w;w=Array.isArray(l)?b(l[y],i):l?b(l,i):b("\u25cf",i);var k=w[0],A=w[1],M=w[2];p+=3*k.cells.length,g+=2*A.edges.length}var T=p+g,E=v.mallocFloat(3*T),L=v.mallocFloat(4*T),S=v.mallocFloat(2*T),C=v.mallocUint32(T),z=[0,a[1]],P=0,R=p,O=[0,0,0,1],I=[0,0,0,1],N=Array.isArray(c)&&Array.isArray(c[0]),j=Array.isArray(h)&&Array.isArray(h[0]);t:for(var y=0;m>y;++y){for(var x=n[y],_=0;3>_;++_){if(isNaN(x[_])||!isFinite(x[_])){d+=1;continue t}s[_]=Math.max(s[_],x[_]),o[_]=Math.min(o[_],x[_])}var w;w=Array.isArray(l)?b(l[y],i):l?b(l,i):b("\u25cf",i);var k=w[0],A=w[1],M=w[2];if(Array.isArray(c)){var F;if(F=N?c[y]:c,3===F.length){for(var _=0;3>_;++_)O[_]=F[_];O[3]=1}else if(4===F.length)for(var _=0;4>_;++_)O[_]=F[_]}else O[0]=O[1]=O[2]=0,O[3]=1;if(Array.isArray(h)){var F;if(F=j?h[y]:h,3===F.length){for(var _=0;3>_;++_)I[_]=F[_];I[_]=1}else if(4===F.length)for(var _=0;4>_;++_)I[_]=F[_]}else I[0]=I[1]=I[2]=0,I[3]=1;var D=.5;Array.isArray(u)?D=+u[y]:u?D=+u:this.useOrtho&&(D=12);var B=0;Array.isArray(f)?B=+f[y]:f&&(B=+f);for(var U=Math.cos(B),V=Math.sin(B),x=n[y],_=0;3>_;++_)s[_]=Math.max(s[_],x[_]),o[_]=Math.min(o[_],x[_]);a[0]<0?z[0]=a[0]*(1+M[1][0]):a[0]>0&&(z[0]=-a[0]*(1+M[0][0]));for(var q=k.cells,H=k.positions,_=0;_Y;++Y){for(var X=0;3>X;++X)E[3*P+X]=x[X];for(var X=0;4>X;++X)L[4*P+X]=O[X];C[P]=d;var W=H[G[Y]];S[2*P]=D*(U*W[0]-V*W[1]+z[0]),S[2*P+1]=D*(V*W[0]+U*W[1]+z[1]),P+=1}for(var q=A.edges,H=A.positions,_=0;_Y;++Y){for(var X=0;3>X;++X)E[3*R+X]=x[X];for(var X=0;4>X;++X)L[4*R+X]=I[X];C[R]=d;var W=H[G[Y]];S[2*R]=D*(U*W[0]-V*W[1]+z[0]),S[2*R+1]=D*(V*W[0]+U*W[1]+z[1]),R+=1}d+=1}this.vertexCount=p,this.lineVertexCount=g,this.pointBuffer.update(E),this.colorBuffer.update(L),this.glyphBuffer.update(S),this.idBuffer.update(new Uint32Array(C)),v.free(E),v.free(L),v.free(S),v.free(C),this.bounds=[o,s],this.points=n,this.pointCount=n.length}},_.dispose=function(){this.shader.dispose(),this.orthoShader.dispose(),this.pickPerspectiveShader.dispose(),this.pickOrthoShader.dispose(),this.vao.dispose(),this.pointBuffer.dispose(),this.colorBuffer.dispose(),this.glyphBuffer.dispose(),this.idBuffer.dispose()}},{"./lib/glyphs":150,"./lib/shaders":151,"gl-buffer":77,"gl-mat4/multiply":98,"gl-vao":185,"typedarray-pool":237}],153:[function(t,e,r){"use strict";r.boxVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n",r.boxFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"},{}],154:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.boxBuffer=e,this.boxShader=r,this.enabled=!0,this.selectBox=[1/0,1/0,-(1/0),-(1/0)],this.borderColor=[0,0,0,1],this.innerFill=!1,this.innerColor=[0,0,0,.25],this.outerFill=!0,this.outerColor=[0,0,0,.5],this.borderWidth=10}function i(t,e){var r=t.gl,i=o(r,[0,0,0,1,1,0,1,1]),l=a(r,s.boxVertex,s.boxFragment),c=new n(t,i,l);return c.update(e),t.addOverlay(c),c}var a=t("gl-shader"),o=t("gl-buffer"),s=t("./lib/shaders");e.exports=i;var l=n.prototype;l.draw=function(){if(this.enabled){var t=this.plot,e=this.selectBox,r=this.borderWidth,n=(this.innerFill,this.innerColor),i=(this.outerFill,this.outerColor),a=this.borderColor,o=t.box,s=t.screenBox,l=t.dataBox,c=t.viewBox,u=t.pixelRatio,f=(e[0]-l[0])*(c[2]-c[0])/(l[2]-l[0])+c[0],h=(e[1]-l[1])*(c[3]-c[1])/(l[3]-l[1])+c[1],d=(e[2]-l[0])*(c[2]-c[0])/(l[2]-l[0])+c[0],p=(e[3]-l[1])*(c[3]-c[1])/(l[3]-l[1])+c[1];if(f=Math.max(f,c[0]),h=Math.max(h,c[1]),d=Math.min(d,c[2]),p=Math.min(p,c[3]),!(f>d||h>p)){o.bind();var g=s[2]-s[0],v=s[3]-s[1];if(this.outerFill&&(o.drawBox(0,0,g,h,i),o.drawBox(0,h,f,p,i),o.drawBox(0,p,g,v,i),o.drawBox(d,h,g,p,i)),this.innerFill&&o.drawBox(f,h,d,p,n),r>0){var m=r*u;o.drawBox(f-m,h-m,d+m,h+m,a),o.drawBox(f-m,p-m,d+m,p+m,a),o.drawBox(f-m,h-m,f+m,p+m,a),o.drawBox(d-m,h-m,d+m,p+m,a)}}}},l.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},l.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":153,"gl-buffer":77,"gl-shader":156}],155:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.coord=[t,e],this.id=r,this.value=n,this.distance=i}function i(t,e,r){this.gl=t,this.fbo=e,this.buffer=r,this._readTimeout=null;var n=this;this._readCallback=function(){n.gl&&(e.bind(),t.readPixels(0,0,e.shape[0],e.shape[1],t.RGBA,t.UNSIGNED_BYTE,n.buffer),n._readTimeout=null)}}function a(t,e){var r=o(t,e),n=s.mallocUint8(e[0]*e[1]*4);return new i(t,r,n)}e.exports=a;var o=t("gl-fbo"),s=t("typedarray-pool"),l=t("ndarray"),c=t("bit-twiddle").nextPow2,u=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(255>_inline_34_arg0_||255>_inline_34_arg1_||255>_inline_34_arg2_||255>_inline_34_arg3_){var _inline_34_l=_inline_34_arg4_-_inline_34_arg6_[0],_inline_34_a=_inline_34_arg5_-_inline_34_arg6_[1],_inline_34_f=_inline_34_l*_inline_34_l+_inline_34_a*_inline_34_a;_inline_34_fthis.buffer.length){s.free(this.buffer);for(var n=this.buffer=s.mallocUint8(c(r*e*4)),i=0;r*e*4>i;++i)n[i]=255}return t}}}),f.begin=function(){var t=this.gl;this.shape;t&&(this.fbo.bind(),t.clearColor(1,1,1,1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT))},f.end=function(){var t=this.gl;t&&(t.bindFramebuffer(t.FRAMEBUFFER,null),this._readTimeout||clearTimeout(this._readTimeout),this._readTimeout=setTimeout(this._readCallback,1))},f.query=function(t,e,r){if(!this.gl)return null;var i=this.fbo.shape.slice();t=0|t,e=0|e,"number"!=typeof r&&(r=1);var a=0|Math.min(Math.max(t-r,0),i[0]),o=0|Math.min(Math.max(t+r,0),i[0]),s=0|Math.min(Math.max(e-r,0),i[1]),c=0|Math.min(Math.max(e+r,0),i[1]);if(a>=o||s>=c)return null;var f=[o-a,c-s],h=l(this.buffer,[f[0],f[1],4],[4,4*i[0],1],4*(a+i[0]*s)),d=u(h.hi(f[0],f[1],1),r,r),p=d[0],g=d[1];if(0>p||Math.pow(this.radius,2)=0){for(var A=0|k.type.charAt(k.type.length-1),M=new Array(A),T=0;A>T;++T)M[T]=_.length,x.push(k.name+"["+T+"]"),"number"==typeof k.location?_.push(k.location+T):Array.isArray(k.location)&&k.location.length===A&&"number"==typeof k.location[T]?_.push(0|k.location[T]):_.push(-1);b.push({name:k.name,type:k.type,locations:M})}else b.push({name:k.name,type:k.type,locations:[_.length]}),x.push(k.name),"number"==typeof k.location?_.push(0|k.location):_.push(-1)}for(var E=0,w=0;w<_.length;++w)if(_[w]<0){for(;_.indexOf(E)>=0;)E+=1;_[w]=E}var L=new Array(r.length);a(),d._relink=a,d.types={uniforms:l(r),attributes:l(n)},d.attributes=s(p,d,b,_),Object.defineProperty(d,"uniforms",o(p,d,r,L))},e.exports=a},{"./lib/GLError":157,"./lib/create-attributes":158,"./lib/create-uniforms":159,"./lib/reflect":160,"./lib/runtime-reflect":161,"./lib/shader-cache":162}],157:[function(t,e,r){function n(t,e,r){this.shortMessage=e||"",this.longMessage=r||"",this.rawError=t||"",this.message="gl-shader: "+(e||t||"")+(r?"\n"+r:""),this.stack=(new Error).stack}n.prototype=new Error,n.prototype.name="GLError",n.prototype.constructor=n,e.exports=n},{}],158:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}function i(t,e,r,i,a,o,s){for(var l=["gl","v"],c=[],u=0;a>u;++u)l.push("x"+u),c.push("x"+u);l.push("if(x0.length===void 0){return gl.vertexAttrib"+a+"f(v,"+c.join()+")}else{return gl.vertexAttrib"+a+"fv(v,x0)}");var f=Function.apply(null,l),h=new n(t,e,r,i,a,f);Object.defineProperty(o,s,{set:function(e){return t.disableVertexAttribArray(i[r]),f(t,i[r],e),e},get:function(){return h},enumerable:!0})}function a(t,e,r,n,a,o,s){for(var l=new Array(a),c=new Array(a),u=0;a>u;++u)i(t,e,r[u],n,a,l,u),c[u]=l[u];Object.defineProperty(l,"location",{set:function(t){if(Array.isArray(t))for(var e=0;a>e;++e)c[e].location=t[e];else for(var e=0;a>e;++e)c[e].location=t+e;return t},get:function(){for(var t=new Array(a),e=0;a>e;++e)t[e]=n[r[e]];return t},enumerable:!0}),l.pointer=function(e,i,o,s){e=e||t.FLOAT,i=!!i,o=o||a*a,s=s||0;for(var l=0;a>l;++l){var c=n[r[l]];t.vertexAttribPointer(c,a,e,i,o,s+l*a),t.enableVertexAttribArray(c)}};var f=new Array(a),h=t["vertexAttrib"+a+"fv"];Object.defineProperty(o,s,{set:function(e){for(var i=0;a>i;++i){var o=n[r[i]];if(t.disableVertexAttribArray(o),Array.isArray(e[0]))h.call(t,o,e[i]);else{for(var s=0;a>s;++s)f[s]=e[a*i+s];h.call(t,o,f)}}return e},get:function(){return l},enumerable:!0})}function o(t,e,r,n){for(var o={},l=0,c=r.length;c>l;++l){var u=r[l],f=u.name,h=u.type,d=u.locations;switch(h){case"bool":case"int":case"float":i(t,e,d[0],n,1,o,f);break;default:if(h.indexOf("vec")>=0){var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);i(t,e,d[0],n,p,o,f)}else{if(!(h.indexOf("mat")>=0))throw new s("","Unknown data type for attribute "+f+": "+h);var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);a(t,e,d,n,p,o,f)}}}return o}e.exports=o;var s=t("./GLError"),l=n.prototype;l.pointer=function(t,e,r,n){var i=this,a=i._gl,o=i._locations[i._index];a.vertexAttribPointer(o,i._dimension,t||a.FLOAT,!!e,r||0,n||0),a.enableVertexAttribArray(o)},l.set=function(t,e,r,n){return this._constFunc(this._locations[this._index],t,e,r,n)},Object.defineProperty(l,"location",{get:function(){return this._locations[this._index]},set:function(t){return t!==this._locations[this._index]&&(this._locations[this._index]=0|t,this._wrapper.program=null),0|t}})},{"./GLError":157}],159:[function(t,e,r){"use strict";function n(t){var e=new Function("y","return function(){return y}");return e(t)}function i(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e,r,a){function l(r){var n=new Function("gl","wrapper","locations","return function(){return gl.getUniform(wrapper.program,locations["+r+"])}");return n(t,e,a)}function c(t,e,r){switch(r){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+e+"],obj"+t+")";case"float":return"gl.uniform1f(locations["+e+"],obj"+t+")";default:var n=r.indexOf("vec");if(!(n>=0&&1>=n&&r.length===4+n)){if(0===r.indexOf("mat")&&4===r.length){var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+i+"fv(locations["+e+"],false,obj"+t+")"}throw new s("","Unknown uniform data type for "+name+": "+r)}var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+i+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+i+"fv(locations["+e+"],obj"+t+")";default:throw new s("","Unrecognized data type for vector "+name+": "+r)}}}function u(t,e){if("object"!=typeof e)return[[t,e]];var r=[];for(var n in e){var i=e[n],a=t;a+=parseInt(n)+""===n?"["+n+"]":"."+n,"object"==typeof i?r.push.apply(r,u(a,i)):r.push([a,i])}return r}function f(e){for(var n=["return function updateProperty(obj){"],i=u("",e),o=0;o=0&&1>=e&&t.length===4+e){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid data type");return"b"===t.charAt(0)?i(r,!1):i(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+t);return i(r*r,0)}throw new s("","Unknown uniform data type for "+name+": "+t)}}function d(t,e,i){if("object"==typeof i){var o=p(i);Object.defineProperty(t,e,{get:n(o),set:f(i),enumerable:!0,configurable:!1})}else a[i]?Object.defineProperty(t,e,{get:l(i),set:f(i),enumerable:!0,configurable:!1}):t[e]=h(r[i].type)}function p(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var c=1;ca;++a){var o=t.getActiveUniform(e,a);if(o){var s=n(t,o.type);if(o.size>1)for(var l=0;la;++a){var o=t.getActiveAttrib(e,a);o&&i.push({name:o.name,type:n(t,o.type)})}return i}r.uniforms=i,r.attributes=a;var o={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"},s=null},{}],162:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.id=t,this.src=e,this.type=r,this.shader=n,this.count=a,this.programs=[],this.cache=o}function i(t){this.gl=t,this.shaders=[{},{}],this.programs={}}function a(t,e,r){var n=t.createShader(e);if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){var i=t.getShaderInfoLog(n);try{var a=f(i,r,e)}catch(o){throw console.warn("Failed to format compiler error: "+o),new u(i,"Error compiling shader:\n"+i)}throw new u(i,a.short,a.long)}return n}function o(t,e,r,n,i){var a=t.createProgram();t.attachShader(a,e),t.attachShader(a,r);for(var o=0;on;++n){var a=t.programs[r[n]];a&&(delete t.programs[n],e.deleteProgram(a))}e.deleteShader(this.shader),delete t.shaders[this.type===e.FRAGMENT_SHADER|0][this.src]}};var g=i.prototype;g.getShaderReference=function(t,e){var r=this.gl,i=this.shaders[t===r.FRAGMENT_SHADER|0],o=i[e];if(o&&r.isShader(o.shader))o.count+=1;else{var s=a(r,t,e);o=i[e]=new n(p++,e,t,s,[],1,this)}return o},g.getProgram=function(t,e,r,n){var i=[t.id,e.id,r.join(":"),n.join(":")].join("@"),a=this.programs[i];return a&&this.gl.isProgram(a)||(this.programs[i]=a=o(this.gl,t.shader,e.shader,r,n),t.programs.push(i),e.programs.push(i)),a}},{"./GLError":157,"gl-format-compiler-error":163,"weakmap-shim":173}],163:[function(t,e,r){function n(t,e,r){"use strict";var n=o(e)||"of unknown name (see npm glsl-shader-name)",l="unknown type";void 0!==r&&(l=r===a.FRAGMENT_SHADER?"fragment":"vertex");for(var c=i("Error compiling %s shader %s:\n",l,n),u=i("%s%s",c,t),f=t.split("\n"),h={},d=0;ds;s++)if(g=i(t[s]),"string"===g)v[v.length]=t[s];else if("array"===g){if(c=t[s],c[2])for(n=e[d],l=0;l=0),c[8]){case"b":n=n.toString(2);break;case"c":n=String.fromCharCode(n);break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,c[6]?parseInt(c[6]):0);break;case"e":n=c[7]?n.toExponential(c[7]):n.toExponential();break;case"f":n=c[7]?parseFloat(n).toFixed(c[7]):parseFloat(n);break;case"g":n=c[7]?parseFloat(n).toPrecision(c[7]):parseFloat(n);break;case"o":n=n.toString(8);break;case"s":n=(n=String(n))&&c[7]?n.substring(0,c[7]):n;break;case"u":n>>>=0;break;case"x":n=n.toString(16);break;case"X":n=n.toString(16).toUpperCase()}o.json.test(c[8])?v[v.length]=n:(!o.number.test(c[8])||m&&!c[3]?y="":(y=m?"+":"-",n=n.toString().replace(o.sign,"")),f=c[4]?"0"===c[4]?"0":c[4].charAt(1):" ",h=c[6]-(y+n).length,u=c[6]&&h>0?a(f,h):"",v[v.length]=c[5]?y+n+u:"0"===f?y+u+n:u+y+n)}return v.join("")},r.cache={},r.parse=function(t){for(var e=t,r=[],n=[],i=0;e;){if(null!==(r=o.text.exec(e)))n[n.length]=r[0];else if(null!==(r=o.modulo.exec(e)))n[n.length]="%";else{if(null===(r=o.placeholder.exec(e)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){i|=1;var a=[],s=r[2],l=[];if(null===(l=o.key.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(a[a.length]=l[1];""!==(s=s.substring(l[0].length));)if(null!==(l=o.key_access.exec(s)))a[a.length]=l[1];else{if(null===(l=o.index_access.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");a[a.length]=l[1]}r[2]=a}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=r}e=e.substring(r[0].length)}return n};var s=function(t,e,n){return n=(e||[]).slice(0),n.splice(0,0,t),r.apply(null,n)};"undefined"!=typeof n?(n.sprintf=r,n.vsprintf=s):(e.sprintf=r,e.vsprintf=s,"function"==typeof t&&t.amd&&t(function(){return{sprintf:r,vsprintf:s}}))}("undefined"==typeof window?this:window)},{}],171:[function(t,e,r){function n(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:i(e,t)}}var i=t("./hidden-store.js");e.exports=n},{"./hidden-store.js":172}],172:[function(t,e,r){function n(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}e.exports=n},{}],173:[function(t,e,r){function n(){var t=i();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){t(e).value=r},has:function(e){return"value"in t(e)},"delete":function(e){return delete t(e).value}}}var i=t("./create-store.js");e.exports=n},{"./create-store.js":171}],174:[function(t,e,r){"use strict";function n(t){this.plot=t,this.enable=[!0,!0,!1,!1],this.width=[1,1,1,1],this.color=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.center=[1/0,1/0]}function i(t,e){var r=new n(t);return r.update(e),t.addOverlay(r),r}e.exports=i;var a=n.prototype;a.update=function(t){t=t||{},this.enable=(t.enable||[!0,!0,!1,!1]).slice(),this.width=(t.width||[1,1,1,1]).slice(),this.color=(t.color||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]).map(function(t){return t.slice()}),this.center=(t.center||[1/0,1/0]).slice(),this.plot.setOverlayDirty()},a.draw=function(){var t=this.enable,e=this.width,r=this.color,n=this.center,i=this.plot,a=i.line,o=i.dataBox,s=i.viewBox;if(a.bind(),o[0]<=n[0]&&n[0]<=o[2]&&o[1]<=n[1]&&n[1]<=o[3]){var l=s[0]+(n[0]-o[0])/(o[2]-o[0])*(s[2]-s[0]),c=s[1]+(n[1]-o[1])/(o[3]-o[1])*(s[3]-s[1]);t[0]&&a.drawLine(l,c,s[0],c,e[0],r[0]),t[1]&&a.drawLine(l,c,l,s[1],e[1],r[1]),t[2]&&a.drawLine(l,c,s[2],c,e[2],r[2]),t[3]&&a.drawLine(l,c,l,s[3],e[3],r[3])}},a.dispose=function(){this.plot.removeOverlay(this)}},{}],175:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute vec3 f;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 lightPosition, eyePosition;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n worldCoordinate = vec3(uv.zw, f.x);\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 //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",a="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(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\n\n\nfloat beckmannSpecular_1_1(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness) {\n return beckmannDistribution_2_0(dot(surfaceNormal, normalize(lightDirection + viewDirection)), roughness);\n}\n\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;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n if(kill > 0.0 ||\n any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n discard;\n }\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 = beckmannSpecular_1_1(L, V, N, roughness);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(colormap, vec2(value, value));\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",o="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\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",s="precision mediump float;\n#define GLSLIFY 1\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 any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n 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";r.createShader=function(t){var e=n(t,i,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createPickShader=function(t){var e=n(t,i,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createContourShader=function(t){var e=n(t,o,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e},r.createPickContourShader=function(t){var e=n(t,o,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e}},{"gl-shader":156}],176:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],177:[function(t,e,r){"use strict";function n(t){if(t in l)return l[t];for(var e=[],r=0;t>r;++r)e.push("out",r,"s=0.5*(inp",r,"l-inp",r,"r);");for(var n=["array"],i=["junk"],r=0;t>r;++r){n.push("array"),i.push("out"+r+"s");var a=o(t);a[r]=-1,n.push({array:0,offset:a.slice()}),a[r]=1,n.push({array:0,offset:a.slice()}),i.push("inp"+r+"l","inp"+r+"r")}return l[t]=s({args:n,pre:u,post:u,body:{body:e.join(""),args:i.map(function(t){return{name:t,lvalue:0===t.indexOf("out"),rvalue:0===t.indexOf("inp"),count:"junk"!==t|0}}),thisVars:[],localVars:[]},funcName:"fdTemplate"+t})}function i(t){function e(e){for(var r=a-e.length,n=[],i=[],s=[],l=0;a>l;++l)e.indexOf(l+1)>=0?s.push("0"):e.indexOf(-(l+1))>=0?s.push("s["+l+"]-1"):(s.push("-1"),n.push("1"),i.push("s["+l+"]-2"));var c=".lo("+n.join()+").hi("+i.join()+")";if(0===n.length&&(c=""),r>0){o.push("if(1");for(var l=0;a>l;++l)e.indexOf(l+1)>=0||e.indexOf(-(l+1))>=0||o.push("&&s[",l,"]>2");o.push("){grad",r,"(src.pick(",s.join(),")",c);for(var l=0;a>l;++l)e.indexOf(l+1)>=0||e.indexOf(-(l+1))>=0||o.push(",dst.pick(",s.join(),",",l,")",c);o.push(");")}for(var l=0;l1){dst.set(",s.join(),",",u,",0.5*(src.get(",h.join(),")-src.get(",d.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):o.push("if(s[",u,"]>1){diff(",f,",src.pick(",h.join(),")",c,",src.pick(",d.join(),")",c,");}else{zero(",f,");};");break;case"mirror":0===r?o.push("dst.set(",s.join(),",",u,",0);"):o.push("zero(",f,");");break;case"wrap":var p=s.slice(),g=s.slice();e[l]<0?(p[u]="s["+u+"]-2",g[u]="0"):(p[u]="s["+u+"]-1",g[u]="1"),0===r?o.push("if(s[",u,"]>2){dst.set(",s.join(),",",u,",0.5*(src.get(",p.join(),")-src.get(",g.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):o.push("if(s[",u,"]>2){diff(",f,",src.pick(",p.join(),")",c,",src.pick(",g.join(),")",c,");}else{zero(",f,");};");break;default:throw new Error("ndarray-gradient: Invalid boundary condition")}}r>0&&o.push("};")}var r=t.join(),i=c[r];if(i)return i;for(var a=t.length,o=["function gradient(dst,src){var s=src.shape.slice();"],s=0;1<s;++s){for(var u=[],d=0;a>d;++d)s&1<=s;++s)v.push("grad"+s),m.push(n(s));v.push(o.join(""));var y=Function.apply(void 0,v),i=y.apply(void 0,m);return l[r]=i,i}function a(t,e,r){if(Array.isArray(r)){if(r.length!==e.dimension)throw new Error("ndarray-gradient: invalid boundary conditions")}else r="string"==typeof r?o(e.dimension,r):o(e.dimension,"clamp");if(t.dimension!==e.dimension+1)throw new Error("ndarray-gradient: output dimension must be +1 input dimension");if(t.shape[e.dimension]!==e.dimension)throw new Error("ndarray-gradient: output shape must match input shape");for(var n=0;nr;++r)for(o=o||e.surfaceProject[r],n=0;3>n;++n)s=s||e.contourProject[r][n];for(r=0;3>r;++r){var l=D.projections[r];for(n=0;16>n;++n)l[n]=0;for(n=0;4>n;++n)l[5*n]=1;l[5*r]=0,l[12+r]=e.axesBounds[+(a[r]>0)][r],k(l,t.model,l);var c=D.clipBounds[r];for(i=0;2>i;++i)for(n=0;3>n;++n)c[i][n]=t.clipBounds[i][n];c[0][r]=-1e8,c[1][r]=1e8}return D.showSurface=o,D.showContour=s,D}function s(t,e){t=t||{};var r=this.gl;r.disable(r.CULL_FACE),this._colorMap.bind(0);var n=B;n.model=t.model||R,n.view=t.view||R,n.projection=t.projection||R,n.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]],n.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]],n.contourColor=this.contourColor[0],n.inverseModel=A(n.inverseModel,n.model);for(var i=0;2>i;++i)for(var a=n.clipBounds[i],s=0;3>s;++s)a[s]=Math.min(Math.max(this.clipBounds[i][s],-1e8),1e8);n.kambient=this.ambientLight,n.kdiffuse=this.diffuseLight,n.kspecular=this.specularLight,n.roughness=this.roughness,n.fresnel=this.fresnel,n.opacity=this.opacity,n.height=0,n.permutation=V;var l=U;for(k(l,n.view,n.model),k(l,n.projection,l),A(l,l),i=0;3>i;++i)n.eyePosition[i]=l[12+i]/l[15];var c=l[15];for(i=0;3>i;++i)c+=this.lightPosition[i]*l[4*i+3];for(i=0;3>i;++i){var u=l[12+i];for(s=0;3>s;++s)u+=l[4*s+i]*this.lightPosition[s];n.lightPosition[i]=u/c}var f=o(n,this);if(f.showSurface&&e===this.opacity<1){for(this._shader.bind(),this._shader.uniforms=n,this._vao.bind(),this.showSurface&&this._vertexCount&&this._vao.draw(r.TRIANGLES,this._vertexCount),i=0;3>i;++i)this.surfaceProject[i]&&this.vertexCount&&(this._shader.uniforms.model=f.projections[i],this._shader.uniforms.clipBounds=f.clipBounds[i],this._vao.draw(r.TRIANGLES,this._vertexCount));this._vao.unbind()}if(f.showContour&&!e){var h=this._contourShader;n.kambient=1,n.kdiffuse=0,n.kspecular=0,n.opacity=1,h.bind(),h.uniforms=n;var d=this._contourVAO;for(d.bind(),i=0;3>i;++i)for(h.uniforms.permutation=I[i],r.lineWidth(this.contourWidth[i]),s=0;si;++i)for(h.uniforms.model=f.projections[i],h.uniforms.clipBounds=f.clipBounds[i],s=0;3>s;++s)if(this.contourProject[i][s]){h.uniforms.permutation=I[s],r.lineWidth(this.contourWidth[s]);for(var p=0;pi;++i)if(0!==this._dynamicCounts[i])for(h.uniforms.model=n.model,h.uniforms.clipBounds=n.clipBounds,h.uniforms.permutation=I[i],r.lineWidth(this.dynamicWidth[i]),h.uniforms.contourColor=this.dynamicColor[i],h.uniforms.contourTint=this.dynamicTint[i],h.uniforms.height=this.dynamicLevel[i],d.draw(r.LINES,this._dynamicCounts[i],this._dynamicOffsets[i]),s=0;3>s;++s)this.contourProject[s][i]&&(h.uniforms.model=f.projections[s],h.uniforms.clipBounds=f.clipBounds[s],d.draw(r.LINES,this._dynamicCounts[i],this._dynamicOffsets[i]));d.unbind()}}function l(t,e){var r=e.shape.slice(),n=t.shape.slice();b.assign(t.lo(1,1).hi(r[0],r[1]),e),b.assign(t.lo(1).hi(r[0],1),e.hi(r[0],1)),b.assign(t.lo(1,n[1]-1).hi(r[0],1),e.lo(0,r[1]-1).hi(r[0],1)),b.assign(t.lo(0,1).hi(1,r[1]),e.hi(1)),b.assign(t.lo(n[0]-1,1).hi(1,r[1]),e.lo(r[0]-1)),t.set(0,0,e.get(0,0)),t.set(0,n[1]-1,e.get(0,r[1]-1)),t.set(n[0]-1,0,e.get(r[0]-1,0)),t.set(n[0]-1,n[1]-1,e.get(r[0]-1,r[1]-1))}function c(t,e){return Array.isArray(t)?[e(t[0]),e(t[1]),e(t[2])]:[e(t),e(t),e(t)]}function u(t){return Array.isArray(t)?3===t.length?[t[0],t[1],t[2],1]:[t[0],t[1],t[2],t[3]]:[0,0,0,1]}function f(t){if(Array.isArray(t)){if(Array.isArray(t))return[u(t[0]),u(t[1]),u(t[2])];var e=u(t);return[e.slice(),e.slice(),e.slice()]}}function h(t){var e=t.gl,r=L(e),n=C(e),i=S(e),o=z(e),s=p(e),l=g(e,[{buffer:s,size:4,stride:P,offset:0},{buffer:s,size:3,stride:P,offset:16},{buffer:s,size:3,stride:P,offset:28}]),c=p(e),u=g(e,[{buffer:c,size:4,stride:20,offset:0},{buffer:c,size:1,stride:20,offset:16}]),f=p(e),h=g(e,[{buffer:f,size:2,type:e.FLOAT}]),d=v(e,1,N,e.RGBA,e.UNSIGNED_BYTE);d.minFilter=e.LINEAR,d.magFilter=e.LINEAR;var m=new a(e,[0,0],[[0,0,0],[0,0,0]],r,n,s,l,d,i,o,c,u,f,h),y={levels:[[],[],[]]};for(var b in t)y[b]=t[b];return y.colormap=y.colormap||"jet",m.update(y),m}e.exports=h;var d=t("bit-twiddle"),p=t("gl-buffer"),g=t("gl-vao"),v=t("gl-texture2d"),m=t("typedarray-pool"),y=t("colormap"),b=t("ndarray-ops"),x=t("ndarray-pack"),_=t("ndarray"),w=t("surface-nets"),k=t("gl-mat4/multiply"),A=t("gl-mat4/invert"),M=t("binary-search-bounds"),T=t("ndarray-gradient"),E=t("./lib/shaders"),L=E.createShader,S=E.createContourShader,C=E.createPickShader,z=E.createPickContourShader,P=40,R=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],O=[[0,0],[0,1],[1,0],[1,1],[1,0],[0,1]],I=[[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 t=0;3>t;++t){var e=I[t],r=(t+1)%3,n=(t+2)%3;e[r+0]=1,e[n+3]=1,e[t+6]=1}}();var N=265,j=a.prototype;j.isTransparent=function(){return this.opacity<1},j.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;3>t;++t)if(this._contourCounts[t].length>0||this._dynamicCounts[t]>0)return!0;return!1},j.pickSlots=1,j.setPickBase=function(t){this.pickId=t};var F=[0,0,0],D={showSurface:!1,showContour:!1,projections:[R.slice(),R.slice(),R.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]},B={model:R,view:R,projection:R,inverseModel:R.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1e3,1e3,1e3],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1},U=R.slice(),V=[1,0,0,0,1,0,0,0,1];j.draw=function(t){return s.call(this,t,!1)},j.drawTransparent=function(t){return s.call(this,t,!0)};var q={model:R,view:R,projection:R,inverseModel:R,clipBounds:[[0,0,0],[0,0,0]],height:0,shape:[0,0],pickId:0,lowerBound:[0,0,0],upperBound:[0,0,0],zOffset:0,permutation:[1,0,0,0,1,0,0,0,1],lightPosition:[0,0,0],eyePosition:[0,0,0]};j.drawPick=function(t){t=t||{};var e=this.gl;e.disable(e.CULL_FACE);var r=q;r.model=t.model||R,r.view=t.view||R,r.projection=t.projection||R,r.shape=this._field[2].shape,r.pickId=this.pickId/255,r.lowerBound=this.bounds[0],r.upperBound=this.bounds[1],r.permutation=V;for(var n=0;2>n;++n)for(var i=r.clipBounds[n],a=0;3>a;++a)i[a]=Math.min(Math.max(this.clipBounds[n][a],-1e8),1e8);var s=o(r,this);if(s.showSurface){for(this._pickShader.bind(),this._pickShader.uniforms=r,this._vao.bind(),this._vao.draw(e.TRIANGLES,this._vertexCount),n=0;3>n;++n)this.surfaceProject[n]&&(this._pickShader.uniforms.model=s.projections[n],this._pickShader.uniforms.clipBounds=s.clipBounds[n],this._vao.draw(e.TRIANGLES,this._vertexCount));this._vao.unbind()}if(s.showContour){var l=this._contourPickShader;l.bind(),l.uniforms=r;var c=this._contourVAO;for(c.bind(),a=0;3>a;++a)for(e.lineWidth(this.contourWidth[a]),l.uniforms.permutation=I[a],n=0;nn;++n)for(l.uniforms.model=s.projections[n],l.uniforms.clipBounds=s.clipBounds[n],a=0;3>a;++a)if(this.contourProject[n][a]){l.uniforms.permutation=I[a],e.lineWidth(this.contourWidth[a]);for(var u=0;u>4)/16)/255,i=Math.floor(n),a=n-i,o=e[1]*(t.value[1]+(15&t.value[2])/16)/255,s=Math.floor(o),l=o-s;i+=1,s+=1;var c=r.position;c[0]=c[1]=c[2]=0;for(var u=0;2>u;++u)for(var f=u?a:1-a,h=0;2>h;++h)for(var d=h?l:1-l,p=i+u,g=s+h,v=f*d,m=0;3>m;++m)c[m]+=this._field[m].get(p,g)*v;for(var y=this._pickResult.level,b=0;3>b;++b)if(y[b]=M.le(this.contourLevels[b],c[b]),y[b]<0)this.contourLevels[b].length>0&&(y[b]=0);else if(y[b]Math.abs(_-c[b])&&(y[b]+=1)}for(r.index[0]=.5>a?i:i+1,r.index[1]=.5>l?s:s+1,r.uv[0]=n/e[0],r.uv[1]=o/e[1],m=0;3>m;++m)r.dataCoordinate[m]=this._field[m].get(r.index[0],r.index[1]);return r},j.update=function(t){t=t||{},this.dirty=!0,"contourWidth"in t&&(this.contourWidth=c(t.contourWidth,Number)),"showContour"in t&&(this.showContour=c(t.showContour,Boolean)),"showSurface"in t&&(this.showSurface=!!t.showSurface),"contourTint"in t&&(this.contourTint=c(t.contourTint,Boolean)),"contourColor"in t&&(this.contourColor=f(t.contourColor)),"contourProject"in t&&(this.contourProject=c(t.contourProject,function(t){return c(t,Boolean)})),"surfaceProject"in t&&(this.surfaceProject=t.surfaceProject),"dynamicColor"in t&&(this.dynamicColor=f(t.dynamicColor)),"dynamicTint"in t&&(this.dynamicTint=c(t.dynamicTint,Number)),"dynamicWidth"in t&&(this.dynamicWidth=c(t.dynamicWidth,Number)),"opacity"in t&&(this.opacity=t.opacity),"colorBounds"in t&&(this.colorBounds=t.colorBounds);var e=t.field||t.coords&&t.coords[2]||null,r=!1;if(e||(e=this._field[2].shape[0]||this._field[2].shape[2]?this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2):this._field[2].hi(0,0)),"field"in t||"coords"in t){var n=(e.shape[0]+2)*(e.shape[1]+2);n>this._field[2].data.length&&(m.freeFloat(this._field[2].data),this._field[2].data=m.mallocFloat(d.nextPow2(n))),this._field[2]=_(this._field[2].data,[e.shape[0]+2,e.shape[1]+2]),l(this._field[2],e),this.shape=e.shape.slice();for(var a=this.shape,o=0;2>o;++o)this._field[2].size>this._field[o].data.length&&(m.freeFloat(this._field[o].data),this._field[o].data=m.mallocFloat(this._field[2].size)),this._field[o]=_(this._field[o].data,[a[0]+2,a[1]+2]);if(t.coords){var s=t.coords;if(!Array.isArray(s)||3!==s.length)throw new Error("gl-surface: invalid coordinates for x/y");for(o=0;2>o;++o){var u=s[o];for(y=0;2>y;++y)if(u.shape[y]!==a[y])throw new Error("gl-surface: coords have incorrect shape");l(this._field[o],u)}}else if(t.ticks){var h=t.ticks;if(!Array.isArray(h)||2!==h.length)throw new Error("gl-surface: invalid ticks");for(o=0;2>o;++o){var p=h[o];if((Array.isArray(p)||p.length)&&(p=_(p)),p.shape[0]!==a[o])throw new Error("gl-surface: invalid tick length");var g=_(p.data,a);g.stride[o]=p.stride[0],g.stride[1^o]=0,l(this._field[o],g)}}else{for(o=0;2>o;++o){var v=[0,0];v[o]=1,this._field[o]=_(this._field[o].data,[a[0]+2,a[1]+2],v,0)}this._field[0].set(0,0,0);for(var y=0;yo;++o)T(x.pick(o),b[o],"mirror");var k=_(m.mallocFloat(3*b[2].size),[a[0]+2,a[1]+2,3]);for(o=0;oI?(I=Math.max(Math.abs(z),Math.abs(P),Math.abs(R)),1e-8>I?(R=1,P=z=0,I=1):I=1/I):I=1/Math.sqrt(I),k.set(o,y,0,z*I),k.set(o,y,1,P*I),k.set(o,y,2,R*I)}m.free(x.data);var N=[1/0,1/0,1/0],j=[-(1/0),-(1/0),-(1/0)],F=1/0,D=-(1/0),B=(a[0]-1)*(a[1]-1)*6,U=m.mallocFloat(d.nextPow2(10*B)),V=0,q=0;for(o=0;oH;++H)for(var G=0;2>G;++G)for(var Y=0;3>Y;++Y){var X=this._field[Y].get(1+o+H,1+y+G);if(isNaN(X)||!isFinite(X))continue t}for(Y=0;6>Y;++Y){var W=o+O[Y][0],Z=y+O[Y][1],K=this._field[0].get(W+1,Z+1),$=this._field[1].get(W+1,Z+1);X=this._field[2].get(W+1,Z+1);var Q=X;z=k.get(W+1,Z+1,0),P=k.get(W+1,Z+1,1),R=k.get(W+1,Z+1,2),t.intensity&&(Q=t.intensity.get(W,Z)),U[V++]=W,U[V++]=Z,U[V++]=K,U[V++]=$,U[V++]=X,U[V++]=0,U[V++]=Q,U[V++]=z,U[V++]=P,U[V++]=R,N[0]=Math.min(N[0],K),N[1]=Math.min(N[1],$),N[2]=Math.min(N[2],X),F=Math.min(F,Q),j[0]=Math.max(j[0],K),j[1]=Math.max(j[1],$),j[2]=Math.max(j[2],X),D=Math.max(D,Q),q+=1}}for(t.intensityBounds&&(F=+t.intensityBounds[0],D=+t.intensityBounds[1]),o=6;V>o;o+=10)U[o]=(U[o]-F)/(D-F);this._vertexCount=q, this._coordinateBuffer.update(U.subarray(0,V)),m.freeFloat(U),m.free(k.data),this.bounds=[N,j],this.intensity=t.intensity||this._field[2],this.intensityBounds[0]===F&&this.intensityBounds[1]===D||(r=!0),this.intensityBounds=[F,D]}if("levels"in t){var J=t.levels;for(J=Array.isArray(J[0])?J.slice():[[],[],J],o=0;3>o;++o)J[o]=J[o].slice(),J.sort(function(t,e){return t-e});t:for(o=0;3>o;++o){if(J[o].length!==this.contourLevels[o].length){r=!0;break}for(y=0;yet;++et){J=this.contourLevels[et];var rt=[],nt=[],it=[0,0,0];for(o=0;oY;++Y){var st=at.positions[ot[Y]],lt=st[0],ct=0|Math.floor(lt),ut=lt-ct,ft=st[1],ht=0|Math.floor(ft),dt=ft-ht,pt=!1;e:for(var gt=0;3>gt;++gt){it[gt]=0;var vt=(et+gt+1)%3;for(H=0;2>H;++H){var mt=H?ut:1-ut;for(W=0|Math.min(Math.max(ct+H,0),a[0]),G=0;2>G;++G){var yt=G?dt:1-dt;if(Z=0|Math.min(Math.max(ht+G,0),a[1]),X=2>gt?this._field[vt].get(W,Z):(this.intensity.get(W,Z)-this.intensityBounds[0])/(this.intensityBounds[1]-this.intensityBounds[0]),!isFinite(X)||isNaN(X)){pt=!0;break e}var bt=mt*yt;it[gt]+=bt*X}}}if(pt){if(Y>0){for(var xt=0;5>xt;++xt)tt.pop();q-=1}continue t}tt.push(it[0],it[1],st[0],st[1],it[2]),q+=1}}nt.push(q)}this._contourOffsets[et]=rt,this._contourCounts[et]=nt}var _t=m.mallocFloat(tt.length);for(o=0;ot;++t)m.freeFloat(this._field[t].data)},j.highlight=function(t){if(!t)return this._dynamicCounts=[0,0,0],this.dyanamicLevel=[NaN,NaN,NaN],void(this.highlightLevel=[-1,-1,-1]);for(var e=0;3>e;++e)this.enableHighlight[e]?this.highlightLevel[e]=t.level[e]:this.highlightLevel[e]=-1;var r;if(r=this.snapToData?t.dataCoordinate:t.position,this.enableDynamic[0]&&r[0]!==this.dynamicLevel[0]||this.enableDynamic[1]&&r[1]!==this.dynamicLevel[1]||this.enableDynamic[2]&&r[2]!==this.dynamicLevel[2]){for(var n=0,i=this.shape,a=m.mallocFloat(12*i[0]*i[1]),o=0;3>o;++o)if(this.enableDynamic[o]){this.dynamicLevel[o]=r[o];var s=(o+1)%3,l=(o+2)%3,c=this._field[o],u=this._field[s],f=this._field[l],h=(this.intensity,w(c,r[o])),d=h.cells,p=h.positions;for(this._dynamicOffsets[o]=n,e=0;ev;++v){var y=p[g[v]],b=+y[0],x=0|b,_=0|Math.min(x+1,i[0]),k=b-x,A=1-k,M=+y[1],T=0|M,E=0|Math.min(T+1,i[1]),L=M-T,S=1-L,C=A*S,z=A*L,P=k*S,R=k*L,O=C*u.get(x,T)+z*u.get(x,E)+P*u.get(_,T)+R*u.get(_,E),I=C*f.get(x,T)+z*f.get(x,E)+P*f.get(_,T)+R*f.get(_,E);if(isNaN(O)||isNaN(I)){v&&(n-=1);break}a[2*n+0]=O,a[2*n+1]=I,n+=1}this._dynamicCounts[o]=n-this._dynamicOffsets[o]}else this.dynamicLevel[o]=NaN,this._dynamicCounts[o]=0;this._dynamicBuffer.update(a.subarray(0,2*n)),m.freeFloat(a)}}},{"./lib/shaders":175,"binary-search-bounds":176,"bit-twiddle":50,colormap:59,"gl-buffer":77,"gl-mat4/invert":96,"gl-mat4/multiply":98,"gl-texture2d":181,"gl-vao":185,ndarray:212,"ndarray-gradient":177,"ndarray-ops":211,"ndarray-pack":178,"surface-nets":231,"typedarray-pool":237}],181:[function(t,e,r){"use strict";function n(t){v=[t.LINEAR,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_NEAREST],m=[t.NEAREST,t.LINEAR,t.NEAREST_MIPMAP_NEAREST,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_LINEAR],y=[t.REPEAT,t.CLAMP_TO_EDGE,t.MIRRORED_REPEAT]}function i(t,e,r){var n=t.gl,i=n.getParameter(n.MAX_TEXTURE_SIZE);if(0>e||e>i||0>r||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function a(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}function o(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function s(t,e,r,n,i,a,s,l){var c=l.dtype,u=l.shape.slice();if(u.length<2||u.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var f=0,h=0,v=o(u,l.stride.slice());"float32"===c?f=t.FLOAT:"float64"===c?(f=t.FLOAT,v=!1,c="float32"):"uint8"===c?f=t.UNSIGNED_BYTE:(f=t.UNSIGNED_BYTE,v=!1,c="uint8");var m=1;if(2===u.length)h=t.LUMINANCE,u=[u[0],u[1],1],l=d(l.data,u,[l.stride[0],l.stride[1],1],l.offset);else{if(3!==u.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===u[2])h=t.ALPHA;else if(2===u[2])h=t.LUMINANCE_ALPHA;else if(3===u[2])h=t.RGB;else{if(4!==u[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");h=t.RGBA}m=u[2]}if(h!==t.LUMINANCE&&h!==t.ALPHA||i!==t.LUMINANCE&&i!==t.ALPHA||(h=i),h!==i)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=l.size,x=s.indexOf(n)<0;if(x&&s.push(n),f===a&&v)0===l.offset&&l.data.length===y?x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,l.data):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,l.data):x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,l.data.subarray(l.offset,l.offset+y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,l.data.subarray(l.offset,l.offset+y));else{var _;_=a===t.FLOAT?g.mallocFloat32(y):g.mallocUint8(y);var w=d(_,u,[u[2],u[2]*u[0],1]);f===t.FLOAT&&a===t.UNSIGNED_BYTE?b(w,l):p.assign(w,l),x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,_.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,_.subarray(0,y)),a===t.FLOAT?g.freeFloat32(_):g.freeUint8(_)}}function l(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function c(t,e,r,n,i){var o=t.getParameter(t.MAX_TEXTURE_SIZE);if(0>e||e>o||0>r||r>o)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var s=l(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new a(t,s,e,r,n,i)}function u(t,e,r,n){var i=l(t);return t.texImage2D(t.TEXTURE_2D,0,r,r,n,e),new a(t,i,0|e.width,0|e.height,r,n)}function f(t,e){var r=e.dtype,n=e.shape.slice(),i=t.getParameter(t.MAX_TEXTURE_SIZE);if(n[0]<0||n[0]>i||n[1]<0||n[1]>i)throw new Error("gl-texture2d: Invalid texture size");var s=o(n,e.stride.slice()),c=0;"float32"===r?c=t.FLOAT:"float64"===r?(c=t.FLOAT,s=!1,r="float32"):"uint8"===r?c=t.UNSIGNED_BYTE:(c=t.UNSIGNED_BYTE,s=!1,r="uint8");var u=0;if(2===n.length)u=t.LUMINANCE,n=[n[0],n[1],1],e=d(e.data,n,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==n.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===n[2])u=t.ALPHA;else if(2===n[2])u=t.LUMINANCE_ALPHA;else if(3===n[2])u=t.RGB;else{if(4!==n[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");u=t.RGBA}}c!==t.FLOAT||t.getExtension("OES_texture_float")||(c=t.UNSIGNED_BYTE,s=!1);var f,h,v=e.size;if(s)f=0===e.offset&&e.data.length===v?e.data:e.data.subarray(e.offset,e.offset+v);else{var m=[n[2],n[2]*n[0],1];h=g.malloc(v,r);var y=d(h,n,m,0);"float32"!==r&&"float64"!==r||c!==t.UNSIGNED_BYTE?p.assign(y,e):b(y,e),f=h.subarray(0,v)}var x=l(t);return t.texImage2D(t.TEXTURE_2D,0,u,n[0],n[1],0,u,c,f),s||g.free(h),new a(t,x,n[0],n[1],u,c)}function h(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");if(v||n(t),"number"==typeof arguments[1])return c(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return c(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1];if(e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof HTMLVideoElement||e instanceof ImageData)return u(t,e,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return f(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")}var d=t("ndarray"),p=t("ndarray-ops"),g=t("typedarray-pool");e.exports=h;var v=null,m=null,y=null,b=function(t,e){p.muls(t,e,255)},x=a.prototype;Object.defineProperties(x,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;2>e;++e)if(y.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return i(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return t=0|t,i(this,t,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t=0|t,i(this,this._shape[0],t),t}}}),x.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},x.dispose=function(){this.gl.deleteTexture(this.handle)},x.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},x.setPixels=function(t,e,r,n){var i=this.gl;if(this.bind(),Array.isArray(e)?(n=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),n=n||0,t instanceof HTMLCanvasElement||t instanceof ImageData||t instanceof HTMLImageElement||t instanceof HTMLVideoElement){var a=this._mipLevels.indexOf(n)<0;a?(i.texImage2D(i.TEXTURE_2D,0,this.format,this.format,this.type,t),this._mipLevels.push(n)):i.texSubImage2D(i.TEXTURE_2D,n,e,r,this.format,this.type,t)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>n||r+t.shape[0]>this._shape[0]>>>n||0>e||0>r)throw new Error("gl-texture2d: Texture dimensions are out of bounds");s(i,e,r,n,this.format,this.type,this._mipLevels,t)}}},{ndarray:212,"ndarray-ops":211,"typedarray-pool":237}],182:[function(t,e,r){"use strict";function n(t,e,r){e?e.bind():t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);var n=0|t.getParameter(t.MAX_VERTEX_ATTRIBS);if(r){if(r.length>n)throw new Error("gl-vao: Too many vertex attributes");for(var i=0;ii;++i)t.disableVertexAttribArray(i)}else{t.bindBuffer(t.ARRAY_BUFFER,null);for(var i=0;n>i;++i)t.disableVertexAttribArray(i)}}e.exports=n},{}],183:[function(t,e,r){"use strict";function n(t){this.gl=t,this._elements=null,this._attributes=null,this._elementsType=t.UNSIGNED_SHORT}function i(t){return new n(t)}var a=t("./do-bind.js");n.prototype.bind=function(){a(this.gl,this._elements,this._attributes)},n.prototype.update=function(t,e,r){this._elements=e,this._attributes=t,this._elementsType=r||this.gl.UNSIGNED_SHORT},n.prototype.dispose=function(){},n.prototype.unbind=function(){},n.prototype.draw=function(t,e,r){r=r||0;var n=this.gl;this._elements?n.drawElements(t,e,this._elementsType,r):n.drawArrays(t,r,e)},e.exports=i},{"./do-bind.js":182}],184:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.location=t,this.dimension=e,this.a=r,this.b=n,this.c=i,this.d=a}function i(t,e,r){this.gl=t,this._ext=e,this.handle=r,this._attribs=[],this._useElements=!1,this._elementsType=t.UNSIGNED_SHORT}function a(t,e){return new i(t,e,e.createVertexArrayOES())}var o=t("./do-bind.js");n.prototype.bind=function(t){switch(this.dimension){case 1:t.vertexAttrib1f(this.location,this.a);break;case 2:t.vertexAttrib2f(this.location,this.a,this.b);break;case 3:t.vertexAttrib3f(this.location,this.a,this.b,this.c);break;case 4:t.vertexAttrib4f(this.location,this.a,this.b,this.c,this.d)}},i.prototype.bind=function(){this._ext.bindVertexArrayOES(this.handle);for(var t=0;tF;){switch(e=F,B){case f:F=L();break;case h:F=E();break;case d:F=T();break;case p:F=S();break;case g:F=P();break;case w:F=z();break;case v:F=R();break;case u:F=O();break;case x:F=M();break;case c:F=A()}if(e!==F)switch(W[e]){case"\n":H=0,++q;break;default:++H}}return D+=F,W=W.slice(F),V}function n(t){return U.length&&e(U.join("")),B=_,e("(eof)"),V}function A(){return U=U.length?[]:U,"/"===N&&"*"===I?(G=D+F-1,B=f,N=I,F+1):"/"===N&&"/"===I?(G=D+F-1,B=h,N=I,F+1):"#"===I?(B=d,G=D+F,F):/\s/.test(I)?(B=x,G=D+F,F):(Y=/\d/.test(I),X=/[^\w_]/.test(I),G=D+F,B=Y?g:X?p:u,F)}function M(){return/[^\s]/g.test(I)?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function T(){return"\n"===I&&"\\"!==N?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function E(){return T()}function L(){return"/"===I&&"*"===N?(U.push(I),e(U.join("")),B=c,F+1):(U.push(I),N=I,F+1)}function S(){if("."===N&&/\d/.test(I))return B=v,F;if("/"===N&&"*"===I)return B=f,F;if("/"===N&&"/"===I)return B=h,F;if("."===I&&U.length){for(;C(U););return B=v,F}if(";"===I||")"===I||"("===I){if(U.length)for(;C(U););return e(I),B=c,F+1}var t=2===U.length&&"="!==I;if(/[\w_\d\s]/.test(I)||t){for(;C(U););return B=c,F}return U.push(I),N=I,F+1}function C(t){for(var r,n,i=0;;){if(r=a.indexOf(t.slice(0,t.length+i).join("")),n=a[r],-1===r){if(i--+t.length>0)continue;n=t.slice(0,1).join("")}return e(n),G+=n.length,U=U.slice(n.length),U.length}}function z(){return/[^a-fA-F0-9]/.test(I)?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function P(){return"."===I?(U.push(I),B=v,N=I,F+1):/[eE]/.test(I)?(U.push(I),B=v,N=I,F+1):"x"===I&&1===U.length&&"0"===U[0]?(B=w,U.push(I),N=I,F+1):/[^\d]/.test(I)?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function R(){return"f"===I&&(U.push(I),N=I,F+=1),/[eE]/.test(I)?(U.push(I),N=I,F+1):"-"===I&&/[eE]/.test(N)?(U.push(I),N=I,F+1):/[^\d]/.test(I)?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function O(){if(/[^\d\w_]/.test(I)){var t=U.join("");return B=K.indexOf(t)>-1?b:Z.indexOf(t)>-1?y:m,e(U.join("")),B=c,F}return U.push(I),N=I,F+1}var I,N,j,F=0,D=0,B=c,U=[],V=[],q=1,H=0,G=0,Y=!1,X=!1,W="";t=t||{};var Z=o,K=i;return"300 es"===t.version&&(Z=l,K=s),function(t){return V=[],null!==t?r(t):n()}}e.exports=n;var i=t("./lib/literals"),a=t("./lib/operators"),o=t("./lib/builtins"),s=t("./lib/literals-300es"),l=t("./lib/builtins-300es"),c=999,u=9999,f=0,h=1,d=2,p=3,g=4,v=5,m=6,y=7,b=8,x=9,_=10,w=11,k=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":189,"./lib/builtins-300es":188,"./lib/literals":191,"./lib/literals-300es":190,"./lib/operators":192}],188:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["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","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"])},{"./builtins":189}],189:[function(t,e,r){e.exports=["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"]},{}],190:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","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"])},{"./literals":191}],191:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","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","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"]},{}],192:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],193:[function(t,e,r){function n(t,e){var r=i(e),n=[];return n=n.concat(r(t)),n=n.concat(r(null))}var i=t("./index");e.exports=n},{"./index":187}],194:[function(t,e,r){"use strict";function n(t,e,r){this.vertices=t,this.adjacent=e,this.boundary=r,this.lastVisited=-1}function i(t,e,r){this.vertices=t,this.cell=e,this.index=r}function a(t,e){return u(t.vertices,e.vertices)}function o(t){for(var e=["function orient(){var tuple=this.tuple;return test("],r=0;t>=r;++r)r>0&&e.push(","),e.push("tuple[",r,"]");e.push(")}return orient");var n=new Function("test",e.join("")),i=c[t+1];return i||(i=c),n(i)}function s(t,e,r){this.dimension=t,this.vertices=e,this.simplices=r,this.interior=r.filter(function(t){return!t.boundary}),this.tuple=new Array(t+1);for(var n=0;t>=n;++n)this.tuple[n]=this.vertices[n];var i=f[t];i||(i=f[t]=o(t)),this.orient=i}function l(t,e){var r=t.length;if(0===r)throw new Error("Must have at least d+1 points");var i=t[0].length;if(i>=r)throw new Error("Must input at least d+1 points");var a=t.slice(0,i+1),o=c.apply(void 0,a);if(0===o)throw new Error("Input not in general position");for(var l=new Array(i+1),u=0;i>=u;++u)l[u]=u;0>o&&(l[0]=1,l[1]=0);for(var f=new n(l,new Array(i+1),!1),h=f.adjacent,d=new Array(i+2),u=0;i>=u;++u){for(var p=l.slice(),g=0;i>=g;++g)g===u&&(p[g]=-1);var v=p[0];p[0]=p[1],p[1]=v;var m=new n(p,new Array(i+1),!0);h[u]=m,d[u]=m}d[i+1]=f;for(var u=0;i>=u;++u)for(var p=h[u].vertices,y=h[u].adjacent,g=0;i>=g;++g){var b=p[g];if(0>b)y[g]=f;else for(var x=0;i>=x;++x)h[x].vertices.indexOf(b)<0&&(y[g]=h[x])}for(var _=new s(i,a,d),w=!!e,u=i+1;r>u;++u)_.insert(t[u],w);return _.boundary()}e.exports=l;var c=t("robust-orientation"),u=t("simplicial-complex").compareCells;n.prototype.flip=function(){var t=this.vertices[0];this.vertices[0]=this.vertices[1],this.vertices[1]=t;var e=this.adjacent[0];this.adjacent[0]=this.adjacent[1],this.adjacent[1]=e};var f=[],h=s.prototype;h.handleBoundaryDegeneracy=function(t,e){var r=this.dimension,n=this.vertices.length-1,i=this.tuple,a=this.vertices,o=[t];for(t.lastVisited=-n;o.length>0;){t=o.pop();for(var s=(t.vertices,t.adjacent),l=0;r>=l;++l){var c=s[l];if(c.boundary&&!(c.lastVisited<=-n)){for(var u=c.vertices,f=0;r>=f;++f){var h=u[f];0>h?i[f]=e:i[f]=a[h]}var d=this.orient();if(d>0)return c;c.lastVisited=-n,0===d&&o.push(c)}}}return null},h.walk=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,a=this.tuple,o=e?this.interior.length*Math.random()|0:this.interior.length-1,s=this.interior[o];t:for(;!s.boundary;){for(var l=s.vertices,c=s.adjacent,u=0;n>=u;++u)a[u]=i[l[u]];s.lastVisited=r;for(var u=0;n>=u;++u){var f=c[u];if(!(f.lastVisited>=r)){var h=a[u];a[u]=t;var d=this.orient();if(a[u]=h,0>d){s=f;continue t}f.boundary?f.lastVisited=-r:f.lastVisited=r}}return}return s},h.addPeaks=function(t,e){var r=this.vertices.length-1,o=this.dimension,s=this.vertices,l=this.tuple,c=this.interior,u=this.simplices,f=[e];e.lastVisited=r,e.vertices[e.vertices.indexOf(-1)]=r,e.boundary=!1,c.push(e);for(var h=[];f.length>0;){var e=f.pop(),d=e.vertices,p=e.adjacent,g=d.indexOf(r);if(!(0>g))for(var v=0;o>=v;++v)if(v!==g){var m=p[v];if(m.boundary&&!(m.lastVisited>=r)){var y=m.vertices;if(m.lastVisited!==-r){for(var b=0,x=0;o>=x;++x)y[x]<0?(b=x,l[x]=t):l[x]=s[y[x]];var _=this.orient();if(_>0){y[b]=r,m.boundary=!1,c.push(m),f.push(m),m.lastVisited=r;continue}m.lastVisited=-r}var w=m.adjacent,k=d.slice(),A=p.slice(),M=new n(k,A,!0);u.push(M);var T=w.indexOf(e);if(!(0>T)){w[T]=M,A[g]=m,k[v]=-1,A[v]=e,p[v]=M,M.flip();for(var x=0;o>=x;++x){var E=k[x];if(!(0>E||E===r)){for(var L=new Array(o-1),S=0,C=0;o>=C;++C){var z=k[C];0>z||C===x||(L[S++]=z)}h.push(new i(L,M,x))}}}}}}h.sort(a);for(var v=0;v+1O||0>I||(P.cell.adjacent[P.index]=R.cell,R.cell.adjacent[R.index]=P.cell)}},h.insert=function(t,e){var r=this.vertices;r.push(t);var n=this.walk(t,e);if(n){for(var i=this.dimension,a=this.tuple,o=0;i>=o;++o){var s=n.vertices[o];0>s?a[o]=t:a[o]=r[s]}var l=this.orient(a);0>l||(0!==l||(n=this.handleBoundaryDegeneracy(n,t)))&&this.addPeaks(t,n)}},h.boundary=function(){for(var t=this.dimension,e=[],r=this.simplices,n=r.length,i=0;n>i;++i){var a=r[i];if(a.boundary){for(var o=new Array(t),s=a.vertices,l=0,c=0,u=0;t>=u;++u)s[u]>=0?o[l++]=s[u]:c=1&u;if(c===(1&t)){var f=o[0];o[0]=o[1],o[1]=f}e.push(o)}}return e}},{"robust-orientation":218,"simplicial-complex":197}],195:[function(t,e,r){arguments[4][50][0].apply(r,arguments)},{dup:50}],196:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;t>e;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n;var i=n.prototype;Object.defineProperty(i,"length",{get:function(){return this.roots.length}}),i.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},i.find=function(t){for(var e=t,r=this.roots;r[t]!==t;)t=r[t];for(;r[e]!==t;){var n=r[e];r[e]=t,e=n}return t},i.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],197:[function(t,e,r){"use strict";"use restrict";function n(t){for(var e=0,r=Math.max,n=0,i=t.length;i>n;++n)e=r(e,t[n].length);return e-1}function i(t){for(var e=-1,r=Math.max,n=0,i=t.length;i>n;++n)for(var a=t[n],o=0,s=a.length;s>o;++o)e=r(e,a[o]);return e+1}function a(t){for(var e=new Array(t.length),r=0,n=t.length;n>r;++r)e[r]=t[r].slice(0);return e}function o(t,e){var r=t.length,n=t.length-e.length,i=Math.min;if(n)return n;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:var a=t[0]+t[1]-e[0]-e[1];return a?a:i(t[0],t[1])-i(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(a=o+t[2]-(s+e[2]))return a;var l=i(t[0],t[1]),c=i(e[0],e[1]),a=i(l,t[2])-i(c,e[2]);return a?a:i(l+t[2],o)-i(c+e[2],s);default:var u=t.slice(0);u.sort();var f=e.slice(0);f.sort();for(var h=0;r>h;++h)if(n=u[h]-f[h])return n;return 0}}function s(t,e){return o(t[0],e[0])}function l(t,e){if(e){for(var r=t.length,n=new Array(r),i=0;r>i;++i)n[i]=[t[i],e[i]];n.sort(s);for(var i=0;r>i;++i)t[i]=n[i][0],e[i]=n[i][1];return t}return t.sort(o),t}function c(t){if(0===t.length)return[];for(var e=1,r=t.length,n=1;r>n;++n){var i=t[n];if(o(i,t[n-1])){if(n===e){e++;continue}t[e++]=i}}return t.length=e,t}function u(t,e){for(var r=0,n=t.length-1,i=-1;n>=r;){var a=r+n>>1,s=o(t[a],e);0>=s?(0===s&&(i=a),r=a+1):s>0&&(n=a-1)}return i}function f(t,e){for(var r=new Array(t.length),n=0,i=r.length;i>n;++n)r[n]=[];for(var a=[],n=0,s=e.length;s>n;++n)for(var l=e[n],c=l.length,f=1,h=1<f;++f){a.length=b.popCount(f);for(var d=0,p=0;c>p;++p)f&1<g))for(;;)if(r[g++].push(n),g>=t.length||0!==o(t[g],a))break}return r}function h(t,e){if(!e)return f(c(p(t,0)),t,0);for(var r=new Array(e),n=0;e>n;++n)r[n]=[];for(var n=0,i=t.length;i>n;++n)for(var a=t[n],o=0,s=a.length;s>o;++o)r[a[o]].push(n); -return r}function d(t){for(var e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0|i.length,o=1,s=1<o;++o){for(var c=[],u=0;a>u;++u)o>>>u&1&&c.push(i[u]);e.push(c)}return l(e)}function p(t,e){if(0>e)return[];for(var r=[],n=(1<r;++r)for(var i=t[r],a=0,o=i.length;o>a;++a){for(var s=new Array(i.length-1),c=0,u=0;o>c;++c)c!==a&&(s[u++]=i[c]);e.push(s)}return l(e)}function v(t,e){for(var r=new x(e),n=0;nr;++r)e[r]=r;return e}e.exports=n},{}],199:[function(t,e,r){e.exports=function(t){return!(null==t||!(t._isBuffer||t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)))}},{}],200:[function(t,e,r){"use strict";function n(t,e){function r(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==g.alt,g.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==g.shift,g.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==g.control,g.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==g.meta,g.meta=!!t.metaKey),e}function n(t,n){var a=i.x(n),o=i.y(n);"buttons"in n&&(t=0|n.buttons),(t!==h||a!==d||o!==p||r(n))&&(h=0|t,d=a||0,p=o||0,e(h,d,p,g))}function a(t){n(0,t)}function o(){(h||d||p||g.shift||g.alt||g.meta||g.control)&&(d=p=0,h=0,g.shift=g.alt=g.control=g.meta=!1,e(0,0,0,g))}function s(t){r(t)&&e(h,d,p,g)}function l(t){0===i.buttons(t)?n(0,t):n(h,t)}function c(t){n(h|i.buttons(t),t)}function u(t){n(h&~i.buttons(t),t)}function f(){v||(v=!0,t.addEventListener("mousemove",l),t.addEventListener("mousedown",c),t.addEventListener("mouseup",u),t.addEventListener("mouseleave",a),t.addEventListener("mouseenter",a),t.addEventListener("mouseout",a),t.addEventListener("mouseover",a),t.addEventListener("blur",o),t.addEventListener("keyup",s),t.addEventListener("keydown",s),t.addEventListener("keypress",s),t!==window&&(window.addEventListener("blur",o),window.addEventListener("keyup",s),window.addEventListener("keydown",s),window.addEventListener("keypress",s)))}e||(e=t,t=window);var h=0,d=0,p=0,g={shift:!1,alt:!1,control:!1,meta:!1},v=!1;f();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return v},set:function(t){t&&f()},enumerable:!0},buttons:{get:function(){return h},enumerable:!0},x:{get:function(){return d},enumerable:!0},y:{get:function(){return p},enumerable:!0},mods:{get:function(){return g},enumerable:!0}}),m}e.exports=n;var i=t("mouse-event")},{"mouse-event":201}],201:[function(t,e,r){"use strict";function n(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<=0&&r=0&&r+1=0&&n=0&&n+1=0&&s=0&&s+1=0&&i=0&&i+1=0&&l=0&&l+1=0&&h=0&&h+1e;++e)r=+arguments[e+1],i[e]=Math.floor(r),a[e]=r-i[e],o[e]=0<=i[e]&&i[e]e;++e){for(c=1,u=t.offset,l=0;n>l;++l)if(e&1<r;++r){t[r]=o[(n+1)*n+r];for(var i=0;n>i;++i)t[r]+=o[(n+1)*i+r]*e[i]}for(var a=o[(n+1)*(n+1)-1],i=0;n>i;++i)a+=o[(n+1)*i+n]*e[i];for(var s=1/a,r=0;n>r;++r)t[r]*=s;return t}),t}var i=t("ndarray-warp"),a=t("gl-matrix-invert");e.exports=n},{"gl-matrix-invert":206,"ndarray-warp":209}],211:[function(t,e,r){"use strict";function n(t){if(!t)return s;for(var e=0;e>",rrshift:">>>"};!function(){for(var t in l){var e=l[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var c={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in c){var e=c[t];r[t]=a({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var u={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in u){var e=u[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var f=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=o({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=o({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=o({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":68}],212:[function(t,e,r){function n(t,e){return t[0]-e[0]}function i(){var t,e=this.stride,r=new Array(e.length);for(t=0;te&&(r="View_Nil"+t);var n="generic"===t;if(-1===e){var a="function "+r+"(a){this.data=a;};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+r+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+r+"(a){return new "+r+"(a);}",o=new Function(a);return o()}if(0===e){var a="function "+r+"(a,d) {this.data = a;this.offset = d};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+r+"_copy() {return new "+r+"(this.data,this.offset)};proto.pick=function "+r+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+r+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+r+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+r+"(a,b,c,d){return new "+r+"(a,d)}",o=new Function("TrivialArray",a);return o(f[t][0])}var a=["'use strict'"],s=l(e),c=s.map(function(t){return"i"+t}),u="this.offset+"+s.map(function(t){return"this.stride["+t+"]*i"+t}).join("+"),h=s.map(function(t){return"b"+t}).join(","),d=s.map(function(t){return"c"+t}).join(",");a.push("function "+r+"(a,"+h+","+d+",d){this.data=a","this.shape=["+h+"]","this.stride=["+d+"]","this.offset=d|0}","var proto="+r+".prototype","proto.dtype='"+t+"'","proto.dimension="+e),a.push("Object.defineProperty(proto,'size',{get:function "+r+"_size(){return "+s.map(function(t){return"this.shape["+t+"]"}).join("*"),"}})"),1===e?a.push("proto.order=[0]"):(a.push("Object.defineProperty(proto,'order',{get:"),4>e?(a.push("function "+r+"_order(){"),2===e?a.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+c.join(",")+",v){"),n?a.push("return this.data.set("+u+",v)}"):a.push("return this.data["+u+"]=v}"),a.push("proto.get=function "+r+"_get("+c.join(",")+"){"),n?a.push("return this.data.get("+u+")}"):a.push("return this.data["+u+"]}"),a.push("proto.index=function "+r+"_index(",c.join(),"){return "+u+"}"),a.push("proto.hi=function "+r+"_hi("+c.join(",")+"){return new "+r+"(this.data,"+s.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+s.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=s.map(function(t){return"a"+t+"=this.shape["+t+"]"}),g=s.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+c.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+g.join(","));for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){d=i"+v+"|0;b+=c"+v+"*d;a"+v+"-=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+c.join(",")+"){var "+s.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+s.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'){d=i"+v+"|0;if(d<0){c+=b"+v+"*(a"+v+"-1);a"+v+"=ceil(-a"+v+"/d)}else{a"+v+"=ceil(a"+v+"/d)}b"+v+"*=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"b"+t}).join(",")+",c)}");for(var m=new Array(e),y=new Array(e),v=0;e>v;++v)m[v]="a[i"+v+"]",y[v]="b[i"+v+"]";a.push("proto.transpose=function "+r+"_transpose("+c+"){"+c.map(function(t,e){return t+"=("+t+"===undefined?"+e+":"+t+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+r+"(this.data,"+m.join(",")+","+y.join(",")+",this.offset)}"),a.push("proto.pick=function "+r+"_pick("+c+"){var a=[],b=[],c=this.offset");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+s.map(function(t){return"shape["+t+"]"}).join(",")+","+s.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}");var o=new Function("CTOR_LIST","ORDER",a.join("\n"));return o(f[t],i)}function o(t){if(c(t))return"buffer";if(u)switch(Object.prototype.toString.call(t)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(t)?"array":"generic"}function s(t,e,r,n){if(void 0===t){var i=f.array[0];return i([])}"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var s=e.length;if(void 0===r){r=new Array(s);for(var l=s-1,c=1;l>=0;--l)r[l]=c,c*=e[l]}if(void 0===n){n=0;for(var l=0;s>l;++l)r[l]<0&&(n-=(e[l]-1)*r[l])}for(var u=o(t),h=f[u];h.length<=s+1;)h.push(a(u,h.length-1));var i=h[s+1];return i(t,e,r,n)}var l=t("iota-array"),c=t("is-buffer"),u="undefined"!=typeof Float64Array,f={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=s},{"iota-array":198,"is-buffer":199}],213:[function(t,e,r){"use strict";function n(t,e){if("string"!=typeof t)throw new TypeError("repeat-string expects a string.");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;for(i===t&&"undefined"!=typeof i||(i=t,a="");r>a.length&&e>0&&(1&e&&(a+=t),e>>=1);)t+=t;return a.substr(0,r)}var i,a="";e.exports=n},{}],214:[function(t,e,r){(function(t){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],215:[function(t,e,r){"use strict";function n(t){for(var e="robustLinearSolve"+t+"d",r=["function ",e,"(A,b){return ["],n=0;t>n;++n){r.push("det([");for(var i=0;t>i;++i){i>0&&r.push(","),r.push("[");for(var a=0;t>a;++a)a>0&&r.push(","),a===n?r.push("+b[",i,"]"):r.push("+A[",i,"][",a,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var o=new Function("det",r.join(""));return o(6>t?s[t]:s)}function i(){return[0]}function a(t,e){return[[e[0]],[t[0][0]]]}function o(){for(;c.lengthi;++i)t.push("s"+i),r.push("case ",i,":return s",i,"(A,b);");r.push("}var s=CACHE[A.length];if(!s)s=CACHE[A.length]=g(A.length);return s(A,b)}return dispatchLinearSolve"),t.push("CACHE","g",r.join(""));var a=Function.apply(void 0,t);e.exports=a.apply(void 0,c.concat([c,n]));for(var i=0;l>i;++i)e.exports[i]=c[i]}var s=t("robust-determinant"),l=6,c=[i,a];o()},{"robust-determinant":217}],216:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i];r=a+o;var s=r-a,l=o-s;l&&(t[--n]=r,r=l)}for(var c=0,i=n;e>i;++i){var a=t[i],o=r;r=a+o;var s=r-a,l=o-s;l&&(t[c++]=l)}return t[c++]=r,t.length=c,t}e.exports=n},{}],217:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m[",r,"][",n,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("");for(var e=[],r=0;rn;++n)t.push("det"+n),r.push("case ",n,":return det",n,"(m);");r.push("}var det=CACHE[m.length];if(!det)det=CACHE[m.length]=gen(m.length);return det(m);}return robustDeterminant"),t.push("CACHE","gen",r.join(""));var i=Function.apply(void 0,t);e.exports=i.apply(void 0,g.concat([g,l]));for(var n=0;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-1,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;rc;++c)0===(1&c)?e.push.apply(e,s(n(a,c))):r.push.apply(r,s(n(a,c))), -l.push("m"+c);var u=o(e),g=o(r),v="orientation"+t+"Exact",m=["function ",v,"(",l.join(),"){var p=",u,",n=",g,",d=sub(p,n);return d[d.length-1];};return ",v].join(""),y=new Function("sum","prod","scale","sub",m);return y(h,f,d,p)}function c(t){var e=_[t.length];return e||(e=_[t.length]=l(t.length)),e.apply(void 0,t)}function u(){for(;_.length<=g;)_.push(l(_.length));for(var t=[],r=["slow"],n=0;g>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;g>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var f=t("two-product"),h=t("robust-sum"),d=t("robust-scale"),p=t("robust-subtract"),g=5,v=1.1102230246251565e-16,m=(3+16*v)*v,y=(7+56*v)*v,b=l(3),x=l(4),_=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,r){var n,i=(t[1]-r[1])*(e[0]-r[0]),a=(t[0]-r[0])*(e[1]-r[1]),o=i-a;if(i>0){if(0>=a)return o;n=i+a}else{if(!(0>i))return o;if(a>=0)return o;n=-(i+a)}var s=m*n;return o>=s||-s>=o?o:b(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],d=a*c,p=o*l,g=o*s,v=i*c,m=i*l,b=a*s,_=u*(d-p)+f*(g-v)+h*(m-b),w=(Math.abs(d)+Math.abs(p))*Math.abs(u)+(Math.abs(g)+Math.abs(v))*Math.abs(f)+(Math.abs(m)+Math.abs(b))*Math.abs(h),k=y*w;return _>k||-_>k?_:x(t,e,r,n)}];u()},{"robust-scale":219,"robust-subtract":220,"robust-sum":221,"two-product":235}],219:[function(t,e,r){"use strict";function n(t,e){var r=t.length;if(1===r){var n=i(t[0],e);return n[0]?n:[n[1]]}var o=new Array(2*r),s=[.1,.1],l=[.1,.1],c=0;i(t[0],e,s),s[0]&&(o[c++]=s[0]);for(var u=1;r>u;++u){i(t[u],e,l);var f=s[1];a(f,l[0],s),s[0]&&(o[c++]=s[0]);var h=l[1],d=s[1],p=h+d,g=p-h,v=d-g;s[1]=p,v&&(o[c++]=v)}return s[1]&&(o[c++]=s[1]),0===c&&(o[c++]=0),o.length=c,o}var i=t("two-product"),a=t("two-sum");e.exports=n},{"two-product":235,"two-sum":236}],220:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],-e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=-e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=-e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=-e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],221:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],222:[function(t,e,r){"use strict";function n(t){return t.split("").map(function(t){return t in i?i[t]:""}).join("")}e.exports=n;var i={" ":" ",0:"\u2070",1:"\xb9",2:"\xb2",3:"\xb3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079","+":"\u207a","-":"\u207b",a:"\u1d43",b:"\u1d47",c:"\u1d9c",d:"\u1d48",e:"\u1d49",f:"\u1da0",g:"\u1d4d",h:"\u02b0",i:"\u2071",j:"\u02b2",k:"\u1d4f",l:"\u02e1",m:"\u1d50",n:"\u207f",o:"\u1d52",p:"\u1d56",r:"\u02b3",s:"\u02e2",t:"\u1d57",u:"\u1d58",v:"\u1d5b",w:"\u02b7",x:"\u02e3",y:"\u02b8",z:"\u1dbb"}},{}],223:[function(t,e,r){"use strict";function n(t){return"a"+t}function i(t){return"d"+t}function a(t,e){return"c"+t+"_"+e}function o(t){return"s"+t}function s(t,e){return"t"+t+"_"+e}function l(t){return"o"+t}function c(t){return"x"+t}function u(t){return"p"+t}function f(t,e){return"d"+t+"_"+e}function h(t){return"i"+t}function d(t,e){return"u"+t+"_"+e}function p(t){return"b"+t}function g(t){return"y"+t}function v(t){return"e"+t}function m(t){return"v"+t}function y(t,e,r){for(var n=0,i=0;t>i;++i)e&1<e;++e)F.push(u(e),"+=",d(e,x[t]),";");F.push("}")}function z(t){for(var e=t-1;e>=0;--e)S(e,0);for(var r=[],e=0;I>e;++e)L[e]?r.push(i(e)+".get("+u(e)+")"):r.push(i(e)+"["+u(e)+"]");for(var e=0;b>e;++e)r.push(c(e));F.push(k,"[",T,"++]=phase(",r.join(),");");for(var e=0;t>e;++e)C(e);for(var n=0;I>n;++n)F.push(u(n),"+=",d(n,x[t]),";")}function P(t){for(var e=0;I>e;++e)L[e]?F.push(a(e,0),"=",i(e),".get(",u(e),");"):F.push(a(e,0),"=",i(e),"[",u(e),"];");for(var r=[],e=0;I>e;++e)r.push(a(e,0));for(var e=0;b>e;++e)r.push(c(e));F.push(p(0),"=",k,"[",T,"]=phase(",r.join(),");");for(var n=1;1<n;++n)F.push(p(n),"=",k,"[",T,"+",v(n),"];");for(var o=[],n=1;1<n;++n)o.push("("+p(0)+"!=="+p(n)+")");F.push("if(",o.join("||"),"){");for(var s=[],e=0;N>e;++e)s.push(h(e));for(var e=0;I>e;++e){s.push(a(e,0));for(var n=1;1<n;++n)L[e]?F.push(a(e,n),"=",i(e),".get(",u(e),"+",f(e,n),");"):F.push(a(e,n),"=",i(e),"[",u(e),"+",f(e,n),"];"),s.push(a(e,n))}for(var e=0;1<e;++e)s.push(p(e));for(var e=0;b>e;++e)s.push(c(e));F.push("vertex(",s.join(),");",m(0),"=",w,"[",T,"]=",A,"++;");for(var l=(1<n;++n)if(0===(t&~(1<0;_=_-1&g)x.push(w+"["+T+"+"+v(_)+"]");x.push(m(0));for(var _=0;I>_;++_)1&n?x.push(a(_,l),a(_,g)):x.push(a(_,g),a(_,l));1&n?x.push(d,y):x.push(y,d);for(var _=0;b>_;++_)x.push(c(_));F.push("if(",d,"!==",y,"){","face(",x.join(),")}")}F.push("}",T,"+=1;")}function R(){for(var t=1;1<t;++t)F.push(E,"=",v(t),";",v(t),"=",g(t),";",g(t),"=",E,";")}function O(t,e){if(0>t)return void P(e);z(t),F.push("if(",o(x[t]),">0){",h(x[t]),"=1;"),O(t-1,e|1<r;++r)F.push(u(r),"+=",d(r,x[t]),";");t===N-1&&(F.push(T,"=0;"),R()),S(t,2),O(t-1,e),t===N-1&&(F.push("if(",h(x[N-1]),"&1){",T,"=0;}"),R()),C(t),F.push("}")}var I=L.length,N=x.length;if(2>N)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var j="extractContour"+x.join("_"),F=[],D=[],B=[],U=0;I>U;++U)B.push(n(U));for(var U=0;b>U;++U)B.push(c(U));for(var U=0;N>U;++U)D.push(o(U)+"="+n(0)+".shape["+U+"]|0");for(var U=0;I>U;++U){D.push(i(U)+"="+n(U)+".data",l(U)+"="+n(U)+".offset|0");for(var V=0;N>V;++V)D.push(s(U,V)+"="+n(U)+".stride["+V+"]|0")}for(var U=0;I>U;++U){D.push(u(U)+"="+l(U)),D.push(a(U,0));for(var V=1;1<V;++V){for(var q=[],H=0;N>H;++H)V&1<U;++U)for(var V=0;N>V;++V){var G=[s(U,x[V])];V>0&&G.push(s(U,x[V-1])+"*"+o(x[V-1])),D.push(d(U,x[V])+"=("+G.join("-")+")|0")}for(var U=0;N>U;++U)D.push(h(U)+"=0");D.push(A+"=0");for(var Y=["2"],U=N-2;U>=0;--U)Y.push(o(x[U]));D.push(M+"=("+Y.join("*")+")|0",k+"=mallocUint32("+M+")",w+"=mallocUint32("+M+")",T+"=0"),D.push(p(0)+"=0");for(var V=1;1<V;++V){for(var X=[],W=[],H=0;N>H;++H)V&1<n&&e("Must have at least one array argument");var i=t.scalarArguments||0;0>i&&e("Scalar arg count must be > 0"),"function"!=typeof t.vertex&&e("Must specify vertex creation function"),"function"!=typeof t.cell&&e("Must specify cell creation function"),"function"!=typeof t.phase&&e("Must specify phase function");for(var a=t.getters||[],o=new Array(n),s=0;n>s;++s)a.indexOf(s)>=0?o[s]=!0:o[s]=!1;return b(t.vertex,t.cell,t.phase,i,r,o)}var _=t("typedarray-pool");e.exports=x;var w="V",k="P",A="N",M="Q",T="X",E="T"},{"typedarray-pool":237}],224:[function(t,e,r){function n(t){if(0>t)return Number("0/0");for(var e=s[0],r=s.length-1;r>0;--r)e+=s[r]/(t+r);var n=t+o+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}var i=7,a=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],o=607/128,s=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];e.exports=function l(t){if(.5>t)return Math.PI/(Math.sin(Math.PI*t)*l(1-t));if(t>100)return Math.exp(n(t));t-=1;for(var e=a[0],r=1;i+2>r;r++)e+=a[r]/(t+r);var o=t+i+.5;return Math.sqrt(2*Math.PI)*Math.pow(o,t+.5)*Math.exp(-o)*e},e.exports.log=n},{}],225:[function(t,e,r){"use strict";function n(t){var e=t.length;if(i>e){for(var r=1,n=0;e>n;++n)for(var o=0;n>o;++o)if(t[n]n;++n)s[n]=0;for(var r=1,n=0;e>n;++n)if(!s[n]){var l=1;s[n]=1;for(var o=t[n];o!==n;o=t[o]){if(s[o])return a.freeUint8(s),0;l+=1,s[o]=1}1&l||(r=-r)}return a.freeUint8(s),r}e.exports=n;var i=32,a=t("typedarray-pool")},{"typedarray-pool":237}],226:[function(t,e,r){"use strict";function n(t){var e=t.length;switch(e){case 0:case 1:return 0;case 2:return t[1]}var r,n,i,s=a.mallocUint32(e),l=a.mallocUint32(e),c=0;for(o(t,l),i=0;e>i;++i)s[i]=t[i];for(i=e-1;i>0;--i)n=l[i],r=s[i],s[i]=s[n],s[n]=r,l[i]=l[r],l[r]=n,c=(c+r)*i;return a.freeUint32(l),a.freeUint32(s),c}function i(t,e,r){switch(t){case 0:return r?r:[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}r=r||new Array(t);var n,i,a,o=1;for(r[0]=0,a=1;t>a;++a)r[a]=a,o=o*a|0;for(a=t-1;a>0;--a)n=e/o|0,e=e-n*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}var a=t("typedarray-pool"),o=t("invert-permutation");r.rank=n,r.unrank=i},{"invert-permutation":227,"typedarray-pool":237}],227:[function(t,e,r){"use strict";function n(t,e){e=e||new Array(t.length);for(var r=0;rt)return[];if(0===t)return[[0]];for(var e=0|Math.round(o(t+1)),r=[],n=0;e>n;++n){for(var s=i.unrank(t,n),l=[0],c=0,u=0;u= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":68}],230:[function(t,e,r){"use strict";function n(t,e){var r=[];return e=+e||0,i(t.hi(t.shape[0]-1),r,e),r}e.exports=n;var i=t("./lib/zc-core")},{"./lib/zc-core":229}],231:[function(t,e,r){"use strict";function n(t,e){var r=t.length,n=["'use strict';"],i="surfaceNets"+t.join("_")+"d"+e;n.push("var contour=genContour({","order:[",t.join(),"],","scalarArguments: 3,","phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },"),"generic"===e&&n.push("getters:[0],");for(var a=[],l=[],c=0;r>c;++c)a.push("d"+c),l.push("d"+c);for(var c=0;1<c;++c)a.push("v"+c),l.push("v"+c);for(var c=0;1<c;++c)a.push("p"+c),l.push("p"+c);a.push("a","b","c"),l.push("a","c"),n.push("vertex:function vertexFunc(",a.join(),"){");for(var u=[],c=0;1<c;++c)u.push("(p"+c+"<<"+c+")");n.push("var m=(",u.join("+"),")|0;if(m===0||m===",(1<<(1<=1<<(1<>>7){");for(var c=0;1<<(1<c;++c){if(1<<(1<128&&c%128===0){f.length>0&&h.push("}}");var d="vExtra"+f.length;n.push("case ",c>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&c,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;r>b;++b)p[b]=[],g[b]=[],v[b]=0,m[b]=0;for(var b=0;1<b;++b)for(var x=0;r>x;++x){var _=b^1<b)&&!(c&1<<_)!=!(c&1<w?(p[x].push("-v"+b+"-v"+_),v[x]+=2):(p[x].push("v"+b+"+v"+_),v[x]-=2),y+=1;for(var k=0;r>k;++k)k!==x&&(_&1<x;++x)if(0===p[x].length)A.push("d"+x+"-0.5");else{var M="";v[x]<0?M=v[x]+"*c":v[x]>0&&(M="+"+v[x]+"*c");var T=.5*(p[x].length/y),E=.5+.5*(m[x]/y);A.push("d"+x+"-"+E+"-"+T+"*("+p[x].join("+")+M+")/("+g[x].join("+")+")")}h.push("a.push([",A.join(),"]);","break;")}n.push("}},"),f.length>0&&h.push("}}");for(var L=[],c=0;1<c;++c)L.push("v"+c);L.push("c0","c1","p0","p1","a","b","c"),n.push("cell:function cellFunc(",L.join(),"){");var S=s(r-1);n.push("if(p0){b.push(",S.map(function(t){return"["+t.map(function(t){return"v"+t})+"]"}).join(),")}else{b.push(",S.map(function(t){var e=t.slice();return e.reverse(),"["+e.map(function(t){return"v"+t})+"]"}).join(),")}}});function ",i,"(array,level){var verts=[],cells=[];contour(array,verts,cells,level);return {positions:verts,cells:cells};} return ",i,";");for(var c=0;co;++o)i[o]=[r[o]],a[o]=[o];return{positions:i,cells:a}}function a(t,e){if(t.dimension<=0)return{positions:[],cells:[]};if(1===t.dimension)return i(t,e);var r=t.order.join()+"-"+t.dtype,a=c[r],e=+e||0;return a||(a=c[r]=n(t.order,t.dtype)),a(t,e)}e.exports=a;var o=t("ndarray-extract-contour"),s=t("triangulate-hypercube"),l=t("zero-crossings"),c={}},{"ndarray-extract-contour":223,"triangulate-hypercube":228,"zero-crossings":230}],232:[function(t,e,r){(function(r){"use strict";function n(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;ol;++l){var c=r[s[l]];n[i++]=c[0],n[i++]=c[1]+1.4,a=Math.max(c[0],a)}return{data:n,shape:a}}function i(t,e){var r=s[t];r||(r=s[t]={" ":{data:new Float32Array(0),shape:.2}});var o=r[e];if(!o)if(e.length<=1||!/\d/.test(e))o=r[e]=n(a(e,{triangles:!0,font:t,textAlign:"left",textBaseline:"alphabetic"}));else{for(var l=e.split(/(\d|\s)/),c=new Array(l.length),u=0,f=0,h=0;h0&&(f+=.02);for(var d=new Float32Array(u),p=0,g=-.5*f,h=0;h.5?l/(2-a-o):l/(a+o),a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,l:s}}function o(t,e,r){function n(t,e,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?t+6*(e-t)*r:.5>r?e:2/3>r?t+(e-t)*(2/3-r)*6:t}var i,a,o;if(t=T(t,360),e=T(e,100),r=T(r,100),0===e)i=a=o=r;else{var s=.5>r?r*(1+e):r+e-r*e,l=2*r-s;i=n(l,s,t+1/3),a=n(l,s,t),o=n(l,s,t-1/3)}return{r:255*i,g:255*a,b:255*o}}function s(t,e,r){t=T(t,255),e=T(e,255),r=T(r,255);var n,i,a=q(t,e,r),o=V(t,e,r),s=a,l=a-o;if(i=0===a?0:l/a,a==o)n=0;else{switch(a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,v:s}}function l(t,e,r){t=6*T(t,360),e=T(e,100),r=T(r,100);var n=B.floor(t),i=t-n,a=r*(1-e),o=r*(1-i*e),s=r*(1-(1-i)*e),l=n%6,c=[r,o,a,a,s,r][l],u=[s,r,r,o,a,a][l],f=[a,a,s,r,r,o][l];return{r:255*c,g:255*u,b:255*f}}function c(t,e,r,n){var i=[z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function u(t,e,r,n){var i=[z(R(n)),z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return i.join("")}function f(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s-=r/100,n.s=E(n.s),e(n)}function h(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s+=r/100,n.s=E(n.s),e(n)}function d(t){return e(t).desaturate(100)}function p(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l+=r/100,n.l=E(n.l),e(n)}function g(t,r){r=0===r?0:r||10;var n=e(t).toRgb();return n.r=q(0,V(255,n.r-U(255*-(r/100)))),n.g=q(0,V(255,n.g-U(255*-(r/100)))),n.b=q(0,V(255,n.b-U(255*-(r/100)))),e(n)}function v(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l-=r/100,n.l=E(n.l),e(n)}function m(t,r){var n=e(t).toHsl(),i=(U(n.h)+r)%360;return n.h=0>i?360+i:i,e(n)}function y(t){var r=e(t).toHsl();return r.h=(r.h+180)%360,e(r)}function b(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+120)%360,s:r.s,l:r.l}),e({h:(n+240)%360,s:r.s,l:r.l})]}function x(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+90)%360,s:r.s,l:r.l}),e({h:(n+180)%360,s:r.s,l:r.l}),e({h:(n+270)%360,s:r.s,l:r.l})]}function _(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+72)%360,s:r.s,l:r.l}),e({h:(n+216)%360,s:r.s,l:r.l})]}function w(t,r,n){r=r||6,n=n||30;var i=e(t).toHsl(),a=360/n,o=[e(t)];for(i.h=(i.h-(a*r>>1)+720)%360;--r;)i.h=(i.h+a)%360,o.push(e(i));return o}function k(t,r){r=r||6;for(var n=e(t).toHsv(),i=n.h,a=n.s,o=n.v,s=[],l=1/r;r--;)s.push(e({h:i,s:a,v:o})),o=(o+l)%1;return s}function A(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}function M(t){return t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=1),t}function T(t,e){S(t)&&(t="100%");var r=C(t);return t=V(e,q(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),B.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function E(t){return V(1,q(0,t))}function L(t){return parseInt(t,16)}function S(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function C(t){return"string"==typeof t&&-1!=t.indexOf("%")}function z(t){return 1==t.length?"0"+t:""+t}function P(t){return 1>=t&&(t=100*t+"%"),t}function R(t){return Math.round(255*parseFloat(t)).toString(16)}function O(t){return L(t)/255}function I(t){t=t.replace(j,"").replace(F,"").toLowerCase();var e=!1;if(G[t])t=G[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=X.rgb.exec(t))?{r:r[1],g:r[2],b:r[3]}:(r=X.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=X.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=X.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=X.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=X.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=X.hex8.exec(t))?{a:O(r[1]),r:L(r[2]),g:L(r[3]),b:L(r[4]),format:e?"name":"hex8"}:(r=X.hex6.exec(t))?{r:L(r[1]),g:L(r[2]),b:L(r[3]),format:e?"name":"hex"}:(r=X.hex3.exec(t))?{r:L(r[1]+""+r[1]),g:L(r[2]+""+r[2]),b:L(r[3]+""+r[3]),format:e?"name":"hex"}:!1}function N(t){var e,r;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==r&&"large"!==r&&(r="small"),{level:e,size:r}}var j=/^\s+/,F=/\s+$/,D=0,B=Math,U=B.round,V=B.min,q=B.max,H=B.random;e.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,r,n,i,a,o=this.toRgb();return t=o.r/255,e=o.g/255,r=o.b/255,n=.03928>=t?t/12.92:Math.pow((t+.055)/1.055,2.4),i=.03928>=e?e/12.92:Math.pow((e+.055)/1.055,2.4),a=.03928>=r?r/12.92:Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*i+.0722*a},setAlpha:function(t){return this._a=M(t),this._roundA=U(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=a(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=a(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return u(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:U(this._r),g:U(this._g),b:U(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+U(this._r)+", "+U(this._g)+", "+U(this._b)+")":"rgba("+U(this._r)+", "+U(this._g)+", "+U(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:U(100*T(this._r,255))+"%",g:U(100*T(this._g,255))+"%",b:U(100*T(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%)":"rgba("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:Y[c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+u(this._r,this._g,this._b,this._a),n=r,i=this._gradientType?"GradientType = 1, ":"";if(t){var a=e(t);n=a.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+r+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0,i=!e&&n&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return i?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return e(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(p,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(v,arguments)},desaturate:function(){return this._applyModification(f,arguments)},saturate:function(){return this._applyModification(h,arguments)},greyscale:function(){return this._applyModification(d,arguments)},spin:function(){return this._applyModification(m,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(w,arguments)},complement:function(){return this._applyCombination(y,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(_,arguments)},triad:function(){return this._applyCombination(b,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},e.fromRatio=function(t,r){if("object"==typeof t){var n={};for(var i in t)t.hasOwnProperty(i)&&("a"===i?n[i]=t[i]:n[i]=P(t[i]));t=n}return e(t,r)},e.equals=function(t,r){return t&&r?e(t).toRgbString()==e(r).toRgbString():!1},e.random=function(){return e.fromRatio({r:H(),g:H(),b:H()})},e.mix=function(t,r,n){n=0===n?0:n||50;var i,a=e(t).toRgb(),o=e(r).toRgb(),s=n/100,l=2*s-1,c=o.a-a.a;i=l*c==-1?l:(l+c)/(1+l*c),i=(i+1)/2;var u=1-i,f={r:o.r*i+a.r*u,g:o.g*i+a.g*u,b:o.b*i+a.b*u,a:o.a*s+a.a*(1-s)};return e(f)},e.readability=function(t,r){var n=e(t),i=e(r);return(Math.max(n.getLuminance(),i.getLuminance())+.05)/(Math.min(n.getLuminance(),i.getLuminance())+.05)},e.isReadable=function(t,r,n){var i,a,o=e.readability(t,r);switch(a=!1,i=N(n),i.level+i.size){case"AAsmall":case"AAAlarge":a=o>=4.5;break;case"AAlarge":a=o>=3;break;case"AAAsmall":a=o>=7}return a},e.mostReadable=function(t,r,n){var i,a,o,s,l=null,c=0;n=n||{},a=n.includeFallbackColors,o=n.level,s=n.size;for(var u=0;uc&&(c=i,l=e(r[u]));return e.isReadable(t,l,{level:o,size:s})||!a?l:(n.includeFallbackColors=!1,e.mostReadable(t,["#fff","#000"],n))};var G=e.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Y=e.hexNames=A(G),X=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",r="(?:"+e+")|(?:"+t+")",n="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",i="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof r&&r.exports?r.exports=e:"function"==typeof t&&t.amd?t(function(){return e}):window.tinycolor=e}()},{}],234:[function(e,r,n){!function(e,i){"object"==typeof n&&"undefined"!=typeof r?i(n):"function"==typeof t&&t.amd?t(["exports"],i):i(e.topojson={})}(this,function(t){"use strict";function e(){}function r(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0),t[0]=(r+=t[0])*i+o,t[1]=(n+=t[1])*a+s}}function n(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0);var l=(t[0]-o)/i|0,c=(t[1]-s)/a|0;t[0]=l-r,t[1]=c-n,r=l,n=c}}function i(t,e){for(var r,n=t.length,i=n-e;i<--n;)r=t[i],t[i++]=t[n],t[n]=r}function a(t,e){for(var r=0,n=t.length;n>r;){var i=r+n>>>1;t[i]r;++r)for(var i=t[r],a=0|i.length,o=1,s=1<o;++o){for(var c=[],u=0;a>u;++u)o>>>u&1&&c.push(i[u]);e.push(c)}return l(e)}function p(t,e){if(0>e)return[];for(var r=[],n=(1<r;++r)for(var i=t[r],a=0,o=i.length;o>a;++a){for(var s=new Array(i.length-1),c=0,u=0;o>c;++c)c!==a&&(s[u++]=i[c]);e.push(s)}return l(e)}function v(t,e){for(var r=new x(e),n=0;nr;++r)e[r]=r;return e}e.exports=n},{}],199:[function(t,e,r){e.exports=function(t){return!(null==t||!(t._isBuffer||t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)))}},{}],200:[function(t,e,r){"use strict";function n(t,e){function r(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==g.alt,g.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==g.shift,g.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==g.control,g.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==g.meta,g.meta=!!t.metaKey),e}function n(t,n){var a=i.x(n),o=i.y(n);"buttons"in n&&(t=0|n.buttons),(t!==h||a!==d||o!==p||r(n))&&(h=0|t,d=a||0,p=o||0,e(h,d,p,g))}function a(t){n(0,t)}function o(){(h||d||p||g.shift||g.alt||g.meta||g.control)&&(d=p=0,h=0,g.shift=g.alt=g.control=g.meta=!1,e(0,0,0,g))}function s(t){r(t)&&e(h,d,p,g)}function l(t){0===i.buttons(t)?n(0,t):n(h,t)}function c(t){n(h|i.buttons(t),t)}function u(t){n(h&~i.buttons(t),t)}function f(){v||(v=!0,t.addEventListener("mousemove",l),t.addEventListener("mousedown",c),t.addEventListener("mouseup",u),t.addEventListener("mouseleave",a),t.addEventListener("mouseenter",a),t.addEventListener("mouseout",a),t.addEventListener("mouseover",a),t.addEventListener("blur",o),t.addEventListener("keyup",s),t.addEventListener("keydown",s),t.addEventListener("keypress",s),t!==window&&(window.addEventListener("blur",o),window.addEventListener("keyup",s),window.addEventListener("keydown",s),window.addEventListener("keypress",s)))}e||(e=t,t=window);var h=0,d=0,p=0,g={shift:!1,alt:!1,control:!1,meta:!1},v=!1;f();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return v},set:function(t){t&&f()},enumerable:!0},buttons:{get:function(){return h},enumerable:!0},x:{get:function(){return d},enumerable:!0},y:{get:function(){return p},enumerable:!0},mods:{get:function(){return g},enumerable:!0}}),m}e.exports=n;var i=t("mouse-event")},{"mouse-event":201}],201:[function(t,e,r){"use strict";function n(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<=0&&r=0&&r+1=0&&n=0&&n+1=0&&s=0&&s+1=0&&i=0&&i+1=0&&l=0&&l+1=0&&h=0&&h+1e;++e)r=+arguments[e+1],i[e]=Math.floor(r),a[e]=r-i[e],o[e]=0<=i[e]&&i[e]e;++e){for(c=1,u=t.offset,l=0;n>l;++l)if(e&1<r;++r){t[r]=o[(n+1)*n+r];for(var i=0;n>i;++i)t[r]+=o[(n+1)*i+r]*e[i]}for(var a=o[(n+1)*(n+1)-1],i=0;n>i;++i)a+=o[(n+1)*i+n]*e[i];for(var s=1/a,r=0;n>r;++r)t[r]*=s;return t}),t}var i=t("ndarray-warp"),a=t("gl-matrix-invert");e.exports=n},{"gl-matrix-invert":206,"ndarray-warp":209}],211:[function(t,e,r){"use strict";function n(t){if(!t)return s;for(var e=0;e>",rrshift:">>>"};!function(){for(var t in l){var e=l[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var c={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in c){var e=c[t];r[t]=a({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var u={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in u){var e=u[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var f=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=o({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=o({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=o({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":68}],212:[function(t,e,r){function n(t,e){return t[0]-e[0]}function i(){var t,e=this.stride,r=new Array(e.length);for(t=0;te&&(r="View_Nil"+t);var n="generic"===t;if(-1===e){var a="function "+r+"(a){this.data=a;};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+r+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+r+"(a){return new "+r+"(a);}",o=new Function(a);return o()}if(0===e){var a="function "+r+"(a,d) {this.data = a;this.offset = d};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+r+"_copy() {return new "+r+"(this.data,this.offset)};proto.pick=function "+r+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+r+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+r+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+r+"(a,b,c,d){return new "+r+"(a,d)}",o=new Function("TrivialArray",a);return o(f[t][0])}var a=["'use strict'"],s=l(e),c=s.map(function(t){return"i"+t}),u="this.offset+"+s.map(function(t){return"this.stride["+t+"]*i"+t}).join("+"),h=s.map(function(t){return"b"+t}).join(","),d=s.map(function(t){return"c"+t}).join(",");a.push("function "+r+"(a,"+h+","+d+",d){this.data=a","this.shape=["+h+"]","this.stride=["+d+"]","this.offset=d|0}","var proto="+r+".prototype","proto.dtype='"+t+"'","proto.dimension="+e),a.push("Object.defineProperty(proto,'size',{get:function "+r+"_size(){return "+s.map(function(t){return"this.shape["+t+"]"}).join("*"),"}})"),1===e?a.push("proto.order=[0]"):(a.push("Object.defineProperty(proto,'order',{get:"),4>e?(a.push("function "+r+"_order(){"),2===e?a.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+c.join(",")+",v){"),n?a.push("return this.data.set("+u+",v)}"):a.push("return this.data["+u+"]=v}"),a.push("proto.get=function "+r+"_get("+c.join(",")+"){"),n?a.push("return this.data.get("+u+")}"):a.push("return this.data["+u+"]}"),a.push("proto.index=function "+r+"_index(",c.join(),"){return "+u+"}"),a.push("proto.hi=function "+r+"_hi("+c.join(",")+"){return new "+r+"(this.data,"+s.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+s.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=s.map(function(t){return"a"+t+"=this.shape["+t+"]"}),g=s.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+c.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+g.join(","));for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){d=i"+v+"|0;b+=c"+v+"*d;a"+v+"-=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+c.join(",")+"){var "+s.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+s.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'){d=i"+v+"|0;if(d<0){c+=b"+v+"*(a"+v+"-1);a"+v+"=ceil(-a"+v+"/d)}else{a"+v+"=ceil(a"+v+"/d)}b"+v+"*=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"b"+t}).join(",")+",c)}");for(var m=new Array(e),y=new Array(e),v=0;e>v;++v)m[v]="a[i"+v+"]",y[v]="b[i"+v+"]";a.push("proto.transpose=function "+r+"_transpose("+c+"){"+c.map(function(t,e){return t+"=("+t+"===undefined?"+e+":"+t+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+r+"(this.data,"+m.join(",")+","+y.join(",")+",this.offset)}"),a.push("proto.pick=function "+r+"_pick("+c+"){var a=[],b=[],c=this.offset");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+s.map(function(t){return"shape["+t+"]"}).join(",")+","+s.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}");var o=new Function("CTOR_LIST","ORDER",a.join("\n"));return o(f[t],i)}function o(t){if(c(t))return"buffer";if(u)switch(Object.prototype.toString.call(t)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(t)?"array":"generic"}function s(t,e,r,n){if(void 0===t){var i=f.array[0];return i([])}"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var s=e.length;if(void 0===r){r=new Array(s);for(var l=s-1,c=1;l>=0;--l)r[l]=c,c*=e[l]}if(void 0===n){n=0;for(var l=0;s>l;++l)r[l]<0&&(n-=(e[l]-1)*r[l])}for(var u=o(t),h=f[u];h.length<=s+1;)h.push(a(u,h.length-1));var i=h[s+1];return i(t,e,r,n)}var l=t("iota-array"),c=t("is-buffer"),u="undefined"!=typeof Float64Array,f={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=s},{"iota-array":198,"is-buffer":199}],213:[function(t,e,r){"use strict";function n(t,e){if("string"!=typeof t)throw new TypeError("repeat-string expects a string.");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;for(i===t&&"undefined"!=typeof i||(i=t,a="");r>a.length&&e>0&&(1&e&&(a+=t),e>>=1);)t+=t;return a.substr(0,r)}var i,a="";e.exports=n},{}],214:[function(t,e,r){(function(t){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],215:[function(t,e,r){"use strict";function n(t){for(var e="robustLinearSolve"+t+"d",r=["function ",e,"(A,b){return ["],n=0;t>n;++n){r.push("det([");for(var i=0;t>i;++i){i>0&&r.push(","),r.push("[");for(var a=0;t>a;++a)a>0&&r.push(","),a===n?r.push("+b[",i,"]"):r.push("+A[",i,"][",a,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var o=new Function("det",r.join(""));return o(6>t?s[t]:s)}function i(){return[0]}function a(t,e){return[[e[0]],[t[0][0]]]}function o(){for(;c.lengthi;++i)t.push("s"+i),r.push("case ",i,":return s",i,"(A,b);");r.push("}var s=CACHE[A.length];if(!s)s=CACHE[A.length]=g(A.length);return s(A,b)}return dispatchLinearSolve"),t.push("CACHE","g",r.join(""));var a=Function.apply(void 0,t);e.exports=a.apply(void 0,c.concat([c,n]));for(var i=0;l>i;++i)e.exports[i]=c[i]}var s=t("robust-determinant"),l=6,c=[i,a];o()},{"robust-determinant":217}],216:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i];r=a+o;var s=r-a,l=o-s;l&&(t[--n]=r,r=l)}for(var c=0,i=n;e>i;++i){var a=t[i],o=r;r=a+o;var s=r-a,l=o-s;l&&(t[c++]=l)}return t[c++]=r,t.length=c,t}e.exports=n},{}],217:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m[",r,"][",n,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("");for(var e=[],r=0;rn;++n)t.push("det"+n),r.push("case ",n,":return det",n,"(m);");r.push("}var det=CACHE[m.length];if(!det)det=CACHE[m.length]=gen(m.length);return det(m);}return robustDeterminant"),t.push("CACHE","gen",r.join(""));var i=Function.apply(void 0,t);e.exports=i.apply(void 0,g.concat([g,l]));for(var n=0;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-1,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;rc;++c)0===(1&c)?e.push.apply(e,s(n(a,c))):r.push.apply(r,s(n(a,c))), +l.push("m"+c);var u=o(e),g=o(r),v="orientation"+t+"Exact",m=["function ",v,"(",l.join(),"){var p=",u,",n=",g,",d=sub(p,n);return d[d.length-1];};return ",v].join(""),y=new Function("sum","prod","scale","sub",m);return y(h,f,d,p)}function c(t){var e=_[t.length];return e||(e=_[t.length]=l(t.length)),e.apply(void 0,t)}function u(){for(;_.length<=g;)_.push(l(_.length));for(var t=[],r=["slow"],n=0;g>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;g>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var f=t("two-product"),h=t("robust-sum"),d=t("robust-scale"),p=t("robust-subtract"),g=5,v=1.1102230246251565e-16,m=(3+16*v)*v,y=(7+56*v)*v,b=l(3),x=l(4),_=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,r){var n,i=(t[1]-r[1])*(e[0]-r[0]),a=(t[0]-r[0])*(e[1]-r[1]),o=i-a;if(i>0){if(0>=a)return o;n=i+a}else{if(!(0>i))return o;if(a>=0)return o;n=-(i+a)}var s=m*n;return o>=s||-s>=o?o:b(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],d=a*c,p=o*l,g=o*s,v=i*c,m=i*l,b=a*s,_=u*(d-p)+f*(g-v)+h*(m-b),w=(Math.abs(d)+Math.abs(p))*Math.abs(u)+(Math.abs(g)+Math.abs(v))*Math.abs(f)+(Math.abs(m)+Math.abs(b))*Math.abs(h),k=y*w;return _>k||-_>k?_:x(t,e,r,n)}];u()},{"robust-scale":219,"robust-subtract":220,"robust-sum":221,"two-product":235}],219:[function(t,e,r){"use strict";function n(t,e){var r=t.length;if(1===r){var n=i(t[0],e);return n[0]?n:[n[1]]}var o=new Array(2*r),s=[.1,.1],l=[.1,.1],c=0;i(t[0],e,s),s[0]&&(o[c++]=s[0]);for(var u=1;r>u;++u){i(t[u],e,l);var f=s[1];a(f,l[0],s),s[0]&&(o[c++]=s[0]);var h=l[1],d=s[1],p=h+d,g=p-h,v=d-g;s[1]=p,v&&(o[c++]=v)}return s[1]&&(o[c++]=s[1]),0===c&&(o[c++]=0),o.length=c,o}var i=t("two-product"),a=t("two-sum");e.exports=n},{"two-product":235,"two-sum":236}],220:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],-e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=-e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=-e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=-e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],221:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],222:[function(t,e,r){"use strict";function n(t){return t.split("").map(function(t){return t in i?i[t]:""}).join("")}e.exports=n;var i={" ":" ",0:"\u2070",1:"\xb9",2:"\xb2",3:"\xb3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079","+":"\u207a","-":"\u207b",a:"\u1d43",b:"\u1d47",c:"\u1d9c",d:"\u1d48",e:"\u1d49",f:"\u1da0",g:"\u1d4d",h:"\u02b0",i:"\u2071",j:"\u02b2",k:"\u1d4f",l:"\u02e1",m:"\u1d50",n:"\u207f",o:"\u1d52",p:"\u1d56",r:"\u02b3",s:"\u02e2",t:"\u1d57",u:"\u1d58",v:"\u1d5b",w:"\u02b7",x:"\u02e3",y:"\u02b8",z:"\u1dbb"}},{}],223:[function(t,e,r){"use strict";function n(t){return"a"+t}function i(t){return"d"+t}function a(t,e){return"c"+t+"_"+e}function o(t){return"s"+t}function s(t,e){return"t"+t+"_"+e}function l(t){return"o"+t}function c(t){return"x"+t}function u(t){return"p"+t}function f(t,e){return"d"+t+"_"+e}function h(t){return"i"+t}function d(t,e){return"u"+t+"_"+e}function p(t){return"b"+t}function g(t){return"y"+t}function v(t){return"e"+t}function m(t){return"v"+t}function y(t,e,r){for(var n=0,i=0;t>i;++i)e&1<e;++e)F.push(u(e),"+=",d(e,x[t]),";");F.push("}")}function z(t){for(var e=t-1;e>=0;--e)S(e,0);for(var r=[],e=0;I>e;++e)L[e]?r.push(i(e)+".get("+u(e)+")"):r.push(i(e)+"["+u(e)+"]");for(var e=0;b>e;++e)r.push(c(e));F.push(k,"[",T,"++]=phase(",r.join(),");");for(var e=0;t>e;++e)C(e);for(var n=0;I>n;++n)F.push(u(n),"+=",d(n,x[t]),";")}function P(t){for(var e=0;I>e;++e)L[e]?F.push(a(e,0),"=",i(e),".get(",u(e),");"):F.push(a(e,0),"=",i(e),"[",u(e),"];");for(var r=[],e=0;I>e;++e)r.push(a(e,0));for(var e=0;b>e;++e)r.push(c(e));F.push(p(0),"=",k,"[",T,"]=phase(",r.join(),");");for(var n=1;1<n;++n)F.push(p(n),"=",k,"[",T,"+",v(n),"];");for(var o=[],n=1;1<n;++n)o.push("("+p(0)+"!=="+p(n)+")");F.push("if(",o.join("||"),"){");for(var s=[],e=0;N>e;++e)s.push(h(e));for(var e=0;I>e;++e){s.push(a(e,0));for(var n=1;1<n;++n)L[e]?F.push(a(e,n),"=",i(e),".get(",u(e),"+",f(e,n),");"):F.push(a(e,n),"=",i(e),"[",u(e),"+",f(e,n),"];"),s.push(a(e,n))}for(var e=0;1<e;++e)s.push(p(e));for(var e=0;b>e;++e)s.push(c(e));F.push("vertex(",s.join(),");",m(0),"=",w,"[",T,"]=",A,"++;");for(var l=(1<n;++n)if(0===(t&~(1<0;_=_-1&g)x.push(w+"["+T+"+"+v(_)+"]");x.push(m(0));for(var _=0;I>_;++_)1&n?x.push(a(_,l),a(_,g)):x.push(a(_,g),a(_,l));1&n?x.push(d,y):x.push(y,d);for(var _=0;b>_;++_)x.push(c(_));F.push("if(",d,"!==",y,"){","face(",x.join(),")}")}F.push("}",T,"+=1;")}function R(){for(var t=1;1<t;++t)F.push(E,"=",v(t),";",v(t),"=",g(t),";",g(t),"=",E,";")}function O(t,e){if(0>t)return void P(e);z(t),F.push("if(",o(x[t]),">0){",h(x[t]),"=1;"),O(t-1,e|1<r;++r)F.push(u(r),"+=",d(r,x[t]),";");t===N-1&&(F.push(T,"=0;"),R()),S(t,2),O(t-1,e),t===N-1&&(F.push("if(",h(x[N-1]),"&1){",T,"=0;}"),R()),C(t),F.push("}")}var I=L.length,N=x.length;if(2>N)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var j="extractContour"+x.join("_"),F=[],D=[],B=[],U=0;I>U;++U)B.push(n(U));for(var U=0;b>U;++U)B.push(c(U));for(var U=0;N>U;++U)D.push(o(U)+"="+n(0)+".shape["+U+"]|0");for(var U=0;I>U;++U){D.push(i(U)+"="+n(U)+".data",l(U)+"="+n(U)+".offset|0");for(var V=0;N>V;++V)D.push(s(U,V)+"="+n(U)+".stride["+V+"]|0")}for(var U=0;I>U;++U){D.push(u(U)+"="+l(U)),D.push(a(U,0));for(var V=1;1<V;++V){for(var q=[],H=0;N>H;++H)V&1<U;++U)for(var V=0;N>V;++V){var G=[s(U,x[V])];V>0&&G.push(s(U,x[V-1])+"*"+o(x[V-1])),D.push(d(U,x[V])+"=("+G.join("-")+")|0")}for(var U=0;N>U;++U)D.push(h(U)+"=0");D.push(A+"=0");for(var Y=["2"],U=N-2;U>=0;--U)Y.push(o(x[U]));D.push(M+"=("+Y.join("*")+")|0",k+"=mallocUint32("+M+")",w+"=mallocUint32("+M+")",T+"=0"),D.push(p(0)+"=0");for(var V=1;1<V;++V){for(var X=[],W=[],H=0;N>H;++H)V&1<n&&e("Must have at least one array argument");var i=t.scalarArguments||0;0>i&&e("Scalar arg count must be > 0"),"function"!=typeof t.vertex&&e("Must specify vertex creation function"),"function"!=typeof t.cell&&e("Must specify cell creation function"),"function"!=typeof t.phase&&e("Must specify phase function");for(var a=t.getters||[],o=new Array(n),s=0;n>s;++s)a.indexOf(s)>=0?o[s]=!0:o[s]=!1;return b(t.vertex,t.cell,t.phase,i,r,o)}var _=t("typedarray-pool");e.exports=x;var w="V",k="P",A="N",M="Q",T="X",E="T"},{"typedarray-pool":237}],224:[function(t,e,r){function n(t){if(0>t)return Number("0/0");for(var e=s[0],r=s.length-1;r>0;--r)e+=s[r]/(t+r);var n=t+o+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}var i=7,a=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],o=607/128,s=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];e.exports=function l(t){if(.5>t)return Math.PI/(Math.sin(Math.PI*t)*l(1-t));if(t>100)return Math.exp(n(t));t-=1;for(var e=a[0],r=1;i+2>r;r++)e+=a[r]/(t+r);var o=t+i+.5;return Math.sqrt(2*Math.PI)*Math.pow(o,t+.5)*Math.exp(-o)*e},e.exports.log=n},{}],225:[function(t,e,r){"use strict";function n(t){var e=t.length;if(i>e){for(var r=1,n=0;e>n;++n)for(var o=0;n>o;++o)if(t[n]n;++n)s[n]=0;for(var r=1,n=0;e>n;++n)if(!s[n]){var l=1;s[n]=1;for(var o=t[n];o!==n;o=t[o]){if(s[o])return a.freeUint8(s),0;l+=1,s[o]=1}1&l||(r=-r)}return a.freeUint8(s),r}e.exports=n;var i=32,a=t("typedarray-pool")},{"typedarray-pool":237}],226:[function(t,e,r){"use strict";function n(t){var e=t.length;switch(e){case 0:case 1:return 0;case 2:return t[1]}var r,n,i,s=a.mallocUint32(e),l=a.mallocUint32(e),c=0;for(o(t,l),i=0;e>i;++i)s[i]=t[i];for(i=e-1;i>0;--i)n=l[i],r=s[i],s[i]=s[n],s[n]=r,l[i]=l[r],l[r]=n,c=(c+r)*i;return a.freeUint32(l),a.freeUint32(s),c}function i(t,e,r){switch(t){case 0:return r?r:[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}r=r||new Array(t);var n,i,a,o=1;for(r[0]=0,a=1;t>a;++a)r[a]=a,o=o*a|0;for(a=t-1;a>0;--a)n=e/o|0,e=e-n*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}var a=t("typedarray-pool"),o=t("invert-permutation");r.rank=n,r.unrank=i},{"invert-permutation":227,"typedarray-pool":237}],227:[function(t,e,r){"use strict";function n(t,e){e=e||new Array(t.length);for(var r=0;rt)return[];if(0===t)return[[0]];for(var e=0|Math.round(o(t+1)),r=[],n=0;e>n;++n){for(var s=i.unrank(t,n),l=[0],c=0,u=0;u= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":68}],230:[function(t,e,r){"use strict";function n(t,e){var r=[];return e=+e||0,i(t.hi(t.shape[0]-1),r,e),r}e.exports=n;var i=t("./lib/zc-core")},{"./lib/zc-core":229}],231:[function(t,e,r){"use strict";function n(t,e){var r=t.length,n=["'use strict';"],i="surfaceNets"+t.join("_")+"d"+e;n.push("var contour=genContour({","order:[",t.join(),"],","scalarArguments: 3,","phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },"),"generic"===e&&n.push("getters:[0],");for(var a=[],l=[],c=0;r>c;++c)a.push("d"+c),l.push("d"+c);for(var c=0;1<c;++c)a.push("v"+c),l.push("v"+c);for(var c=0;1<c;++c)a.push("p"+c),l.push("p"+c);a.push("a","b","c"),l.push("a","c"),n.push("vertex:function vertexFunc(",a.join(),"){");for(var u=[],c=0;1<c;++c)u.push("(p"+c+"<<"+c+")");n.push("var m=(",u.join("+"),")|0;if(m===0||m===",(1<<(1<=1<<(1<>>7){");for(var c=0;1<<(1<c;++c){if(1<<(1<128&&c%128===0){f.length>0&&h.push("}}");var d="vExtra"+f.length;n.push("case ",c>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&c,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;r>b;++b)p[b]=[],g[b]=[],v[b]=0,m[b]=0;for(var b=0;1<b;++b)for(var x=0;r>x;++x){var _=b^1<b)&&!(c&1<<_)!=!(c&1<w?(p[x].push("-v"+b+"-v"+_),v[x]+=2):(p[x].push("v"+b+"+v"+_),v[x]-=2),y+=1;for(var k=0;r>k;++k)k!==x&&(_&1<x;++x)if(0===p[x].length)A.push("d"+x+"-0.5");else{var M="";v[x]<0?M=v[x]+"*c":v[x]>0&&(M="+"+v[x]+"*c");var T=.5*(p[x].length/y),E=.5+.5*(m[x]/y);A.push("d"+x+"-"+E+"-"+T+"*("+p[x].join("+")+M+")/("+g[x].join("+")+")")}h.push("a.push([",A.join(),"]);","break;")}n.push("}},"),f.length>0&&h.push("}}");for(var L=[],c=0;1<c;++c)L.push("v"+c);L.push("c0","c1","p0","p1","a","b","c"),n.push("cell:function cellFunc(",L.join(),"){");var S=s(r-1);n.push("if(p0){b.push(",S.map(function(t){return"["+t.map(function(t){return"v"+t})+"]"}).join(),")}else{b.push(",S.map(function(t){var e=t.slice();return e.reverse(),"["+e.map(function(t){return"v"+t})+"]"}).join(),")}}});function ",i,"(array,level){var verts=[],cells=[];contour(array,verts,cells,level);return {positions:verts,cells:cells};} return ",i,";");for(var c=0;co;++o)i[o]=[r[o]],a[o]=[o];return{positions:i,cells:a}}function a(t,e){if(t.dimension<=0)return{positions:[],cells:[]};if(1===t.dimension)return i(t,e);var r=t.order.join()+"-"+t.dtype,a=c[r],e=+e||0;return a||(a=c[r]=n(t.order,t.dtype)),a(t,e)}e.exports=a;var o=t("ndarray-extract-contour"),s=t("triangulate-hypercube"),l=t("zero-crossings"),c={}},{"ndarray-extract-contour":223,"triangulate-hypercube":228,"zero-crossings":230}],232:[function(t,e,r){(function(r){"use strict";function n(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;ol;++l){var c=r[s[l]];n[i++]=c[0],n[i++]=c[1]+1.4,a=Math.max(c[0],a)}return{data:n,shape:a}}function i(t,e){var r=s[t];r||(r=s[t]={" ":{data:new Float32Array(0),shape:.2}});var o=r[e];if(!o)if(e.length<=1||!/\d/.test(e))o=r[e]=n(a(e,{triangles:!0,font:t,textAlign:"left",textBaseline:"alphabetic"}));else{for(var l=e.split(/(\d|\s)/),c=new Array(l.length),u=0,f=0,h=0;h0&&(f+=.02);for(var d=new Float32Array(u),p=0,g=-.5*f,h=0;h.5?l/(2-a-o):l/(a+o),a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,l:s}}function o(t,e,r){function n(t,e,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?t+6*(e-t)*r:.5>r?e:2/3>r?t+(e-t)*(2/3-r)*6:t}var i,a,o;if(t=T(t,360),e=T(e,100),r=T(r,100),0===e)i=a=o=r;else{var s=.5>r?r*(1+e):r+e-r*e,l=2*r-s;i=n(l,s,t+1/3),a=n(l,s,t),o=n(l,s,t-1/3)}return{r:255*i,g:255*a,b:255*o}}function s(t,e,r){t=T(t,255),e=T(e,255),r=T(r,255);var n,i,a=q(t,e,r),o=V(t,e,r),s=a,l=a-o;if(i=0===a?0:l/a,a==o)n=0;else{switch(a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,v:s}}function l(t,e,r){t=6*T(t,360),e=T(e,100),r=T(r,100);var n=B.floor(t),i=t-n,a=r*(1-e),o=r*(1-i*e),s=r*(1-(1-i)*e),l=n%6,c=[r,o,a,a,s,r][l],u=[s,r,r,o,a,a][l],f=[a,a,s,r,r,o][l];return{r:255*c,g:255*u,b:255*f}}function c(t,e,r,n){var i=[z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function u(t,e,r,n){var i=[z(R(n)),z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return i.join("")}function f(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s-=r/100,n.s=E(n.s),e(n)}function h(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s+=r/100,n.s=E(n.s),e(n)}function d(t){return e(t).desaturate(100)}function p(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l+=r/100,n.l=E(n.l),e(n)}function g(t,r){r=0===r?0:r||10;var n=e(t).toRgb();return n.r=q(0,V(255,n.r-U(255*-(r/100)))),n.g=q(0,V(255,n.g-U(255*-(r/100)))),n.b=q(0,V(255,n.b-U(255*-(r/100)))),e(n)}function v(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l-=r/100,n.l=E(n.l),e(n)}function m(t,r){var n=e(t).toHsl(),i=(U(n.h)+r)%360;return n.h=0>i?360+i:i,e(n)}function y(t){var r=e(t).toHsl();return r.h=(r.h+180)%360,e(r)}function b(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+120)%360,s:r.s,l:r.l}),e({h:(n+240)%360,s:r.s,l:r.l})]}function x(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+90)%360,s:r.s,l:r.l}),e({h:(n+180)%360,s:r.s,l:r.l}),e({h:(n+270)%360,s:r.s,l:r.l})]}function _(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+72)%360,s:r.s,l:r.l}),e({h:(n+216)%360,s:r.s,l:r.l})]}function w(t,r,n){r=r||6,n=n||30;var i=e(t).toHsl(),a=360/n,o=[e(t)];for(i.h=(i.h-(a*r>>1)+720)%360;--r;)i.h=(i.h+a)%360,o.push(e(i));return o}function k(t,r){r=r||6;for(var n=e(t).toHsv(),i=n.h,a=n.s,o=n.v,s=[],l=1/r;r--;)s.push(e({h:i,s:a,v:o})),o=(o+l)%1;return s}function A(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}function M(t){return t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=1),t}function T(t,e){S(t)&&(t="100%");var r=C(t);return t=V(e,q(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),B.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function E(t){return V(1,q(0,t))}function L(t){return parseInt(t,16)}function S(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function C(t){return"string"==typeof t&&-1!=t.indexOf("%")}function z(t){return 1==t.length?"0"+t:""+t}function P(t){return 1>=t&&(t=100*t+"%"),t}function R(t){return Math.round(255*parseFloat(t)).toString(16)}function O(t){return L(t)/255}function I(t){t=t.replace(j,"").replace(F,"").toLowerCase();var e=!1;if(G[t])t=G[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=X.rgb.exec(t))?{r:r[1],g:r[2],b:r[3]}:(r=X.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=X.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=X.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=X.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=X.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=X.hex8.exec(t))?{a:O(r[1]),r:L(r[2]),g:L(r[3]),b:L(r[4]),format:e?"name":"hex8"}:(r=X.hex6.exec(t))?{r:L(r[1]),g:L(r[2]),b:L(r[3]),format:e?"name":"hex"}:(r=X.hex3.exec(t))?{r:L(r[1]+""+r[1]),g:L(r[2]+""+r[2]),b:L(r[3]+""+r[3]),format:e?"name":"hex"}:!1}function N(t){var e,r;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==r&&"large"!==r&&(r="small"),{level:e,size:r}}var j=/^\s+/,F=/\s+$/,D=0,B=Math,U=B.round,V=B.min,q=B.max,H=B.random;e.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,r,n,i,a,o=this.toRgb();return t=o.r/255,e=o.g/255,r=o.b/255,n=.03928>=t?t/12.92:Math.pow((t+.055)/1.055,2.4),i=.03928>=e?e/12.92:Math.pow((e+.055)/1.055,2.4),a=.03928>=r?r/12.92:Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*i+.0722*a},setAlpha:function(t){return this._a=M(t),this._roundA=U(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=a(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=a(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return u(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:U(this._r),g:U(this._g),b:U(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+U(this._r)+", "+U(this._g)+", "+U(this._b)+")":"rgba("+U(this._r)+", "+U(this._g)+", "+U(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:U(100*T(this._r,255))+"%",g:U(100*T(this._g,255))+"%",b:U(100*T(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%)":"rgba("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:Y[c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+u(this._r,this._g,this._b,this._a),n=r,i=this._gradientType?"GradientType = 1, ":"";if(t){var a=e(t);n=a.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+r+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0,i=!e&&n&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return i?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return e(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(p,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(v,arguments)},desaturate:function(){return this._applyModification(f,arguments)},saturate:function(){return this._applyModification(h,arguments)},greyscale:function(){return this._applyModification(d,arguments)},spin:function(){return this._applyModification(m,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(w,arguments)},complement:function(){return this._applyCombination(y,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(_,arguments)},triad:function(){return this._applyCombination(b,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},e.fromRatio=function(t,r){if("object"==typeof t){var n={};for(var i in t)t.hasOwnProperty(i)&&("a"===i?n[i]=t[i]:n[i]=P(t[i]));t=n}return e(t,r)},e.equals=function(t,r){return t&&r?e(t).toRgbString()==e(r).toRgbString():!1},e.random=function(){return e.fromRatio({r:H(),g:H(),b:H()})},e.mix=function(t,r,n){n=0===n?0:n||50;var i,a=e(t).toRgb(),o=e(r).toRgb(),s=n/100,l=2*s-1,c=o.a-a.a;i=l*c==-1?l:(l+c)/(1+l*c),i=(i+1)/2;var u=1-i,f={r:o.r*i+a.r*u,g:o.g*i+a.g*u,b:o.b*i+a.b*u,a:o.a*s+a.a*(1-s)};return e(f)},e.readability=function(t,r){var n=e(t),i=e(r);return(Math.max(n.getLuminance(),i.getLuminance())+.05)/(Math.min(n.getLuminance(),i.getLuminance())+.05)},e.isReadable=function(t,r,n){var i,a,o=e.readability(t,r);switch(a=!1,i=N(n),i.level+i.size){case"AAsmall":case"AAAlarge":a=o>=4.5;break;case"AAlarge":a=o>=3;break;case"AAAsmall":a=o>=7}return a},e.mostReadable=function(t,r,n){var i,a,o,s,l=null,c=0;n=n||{},a=n.includeFallbackColors,o=n.level,s=n.size;for(var u=0;uc&&(c=i,l=e(r[u]));return e.isReadable(t,l,{level:o,size:s})||!a?l:(n.includeFallbackColors=!1,e.mostReadable(t,["#fff","#000"],n))};var G=e.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Y=e.hexNames=A(G),X=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",r="(?:"+e+")|(?:"+t+")",n="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",i="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof r&&r.exports?r.exports=e:"function"==typeof t&&t.amd?t(function(){return e}):window.tinycolor=e}()},{}],234:[function(e,r,n){!function(e,i){"object"==typeof n&&"undefined"!=typeof r?i(n):"function"==typeof t&&t.amd?t(["exports"],i):i(e.topojson={})}(this,function(t){"use strict";function e(){}function r(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0),t[0]=(r+=t[0])*i+o,t[1]=(n+=t[1])*a+s}}function n(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0);var l=(t[0]-o)/i|0,c=(t[1]-s)/a|0;t[0]=l-r,t[1]=c-n,r=l,n=c}}function i(t,e){for(var r,n=t.length,i=n-e;i<--n;)r=t[i],t[i++]=t[n],t[n]=r}function a(t,e){for(var r=0,n=t.length;n>r;){var i=r+n>>>1;t[i]t?~t:t],a=0,o=n.length;o>a;++a)e.push(r=n[a].slice()),u(r,a);0>t&&i(e,o)}function a(t){return t=t.slice(),u(t,0),t}function o(t){for(var e=[],r=0,i=t.length;i>r;++r)n(t[r],e);return e.length<2&&e.push(e[0].slice()),e}function s(t){for(var e=o(t);e.length<4;)e.push(e[0].slice());return e}function l(t){return t.map(s)}function c(t){var e=t.type;return"GeometryCollection"===e?{type:e,geometries:t.geometries.map(c)}:e in h?{type:e,coordinates:h[e](t)}:null}var u=r(t.transform),f=t.arcs,h={Point:function(t){return a(t.coordinates)},MultiPoint:function(t){return t.coordinates.map(a)},LineString:function(t){return o(t.arcs)},MultiLineString:function(t){return t.arcs.map(o)},Polygon:function(t){return l(t.arcs)},MultiPolygon:function(t){return t.arcs.map(l)}};return c(e)}function c(t,e){function r(e){var r,n=t.arcs[0>e?~e:e],i=n[0];return t.transform?(r=[0,0],n.forEach(function(t){r[0]+=t[0],r[1]+=t[1]})):r=n[n.length-1],0>e?[r,i]:[i,r]}function n(t,e){for(var r in t){var n=t[r];delete e[n.start],delete n.start,delete n.end,n.forEach(function(t){i[0>t?~t:t]=1}),s.push(n)}}var i={},a={},o={},s=[],l=-1;return e.forEach(function(r,n){var i,a=t.arcs[0>r?~r:r];a.length<3&&!a[1][0]&&!a[1][1]&&(i=e[++l],e[l]=r,e[n]=i)}),e.forEach(function(t){var e,n,i=r(t),s=i[0],l=i[1];if(e=o[s])if(delete o[e.end],e.push(t),e.end=l,n=a[l]){delete a[n.start];var c=n===e?e:e.concat(n);a[c.start=e.start]=o[c.end=n.end]=c}else a[e.start]=o[e.end]=e;else if(e=a[l])if(delete a[e.start],e.unshift(t),e.start=s,n=o[s]){delete o[n.end];var u=n===e?e:n.concat(e);a[u.start=n.start]=o[u.end=e.end]=u}else a[e.start]=o[e.end]=e;else e=[t],a[e.start=s]=o[e.end=l]=e}),n(o,a),n(a,o),e.forEach(function(t){i[0>t?~t:t]||s.push([t])}),s}function u(t){return l(t,f.apply(this,arguments))}function f(t,e,r){function n(t){var e=0>t?~t:t;(u[e]||(u[e]=[])).push({i:t,g:l})}function i(t){t.forEach(n)}function a(t){t.forEach(i)}function o(t){"GeometryCollection"===t.type?t.geometries.forEach(o):t.type in f&&(l=t,f[t.type](t.arcs))}var s=[];if(arguments.length>1){var l,u=[],f={LineString:i,MultiLineString:a,Polygon:a,MultiPolygon:function(t){t.forEach(a)}};o(e),u.forEach(arguments.length<3?function(t){s.push(t[0].i)}:function(t){r(t[0].g,t[t.length-1].g)&&s.push(t[0].i)})}else for(var h=0,d=t.arcs.length;d>h;++h)s.push(h);return{type:"MultiLineString",arcs:c(t,s)}}function h(t){var e=t[0],r=t[1],n=t[2];return Math.abs((e[0]-n[0])*(r[1]-e[1])-(e[0]-r[0])*(n[1]-e[1]))}function d(t){for(var e,r=-1,n=t.length,i=t[n-1],a=0;++re?~e:e]||(i[e]=[])).push(t)})}),a.push(t)}function n(e){return d(l(t,{type:"Polygon",arcs:[e]}).coordinates[0])>0}var i={},a=[],o=[];return e.forEach(function(t){"Polygon"===t.type?r(t.arcs):"MultiPolygon"===t.type&&t.arcs.forEach(r)}),a.forEach(function(t){if(!t._){var e=[],r=[t];for(t._=1,o.push(e);t=r.pop();)e.push(t),t.forEach(function(t){t.forEach(function(t){i[0>t?~t:t].forEach(function(t){t._||(t._=1,r.push(t))})})})}}),a.forEach(function(t){delete t._}),{type:"MultiPolygon",arcs:o.map(function(e){var r,a=[];if(e.forEach(function(t){t.forEach(function(t){t.forEach(function(t){i[0>t?~t:t].length<2&&a.push(t)})})}),a=c(t,a),(r=a.length)>1)for(var o,s=n(e[0][0]),l=0;r>l;++l)if(s===n(a[l])){o=a[0],a[0]=a[l],a[l]=o;break}return a})}}function v(t){function e(t,e){t.forEach(function(t){0>t&&(t=~t);var r=i[t];r?r.push(e):i[t]=[e]})}function r(t,r){t.forEach(function(t){e(t,r)})}function n(t,e){"GeometryCollection"===t.type?t.geometries.forEach(function(t){n(t,e)}):t.type in s&&s[t.type](t.arcs,e)}var i={},o=t.map(function(){return[]}),s={LineString:e,MultiLineString:r,Polygon:r,MultiPolygon:function(t,e){t.forEach(function(t){r(t,e)})}};t.forEach(n);for(var l in i)for(var c=i[l],u=c.length,f=0;u>f;++f)for(var h=f+1;u>h;++h){var d,p=c[f],g=c[h];(d=o[p])[l=a(d,g)]!==g&&d.splice(l,0,g),(d=o[g])[l=a(d,p)]!==p&&d.splice(l,0,p)}return o}function m(t,e){return t[1][2]-e[1][2]}function y(){function t(t,e){for(;e>0;){var r=(e+1>>1)-1,i=n[r];if(m(t,i)>=0)break;n[i._=e]=i,n[t._=e=r]=t}}function e(t,e){for(;;){var r=e+1<<1,a=r-1,o=e,s=n[o];if(i>a&&m(n[a],s)<0&&(s=n[o=a]),i>r&&m(n[r],s)<0&&(s=n[o=r]),o===e)break;n[s._=e]=s,n[t._=e=o]=t}}var r={},n=[],i=0;return r.push=function(e){return t(n[e._=i]=e,i++),i},r.pop=function(){if(!(0>=i)){var t,r=n[0];return--i>0&&(t=n[i],e(n[t._=0]=t,0)),r}},r.remove=function(r){var a,o=r._;if(n[o]===r)return o!==--i&&(a=n[i],(m(a,r)<0?t:e)(n[a._=o]=a,o)),o},r}function b(t,e){function i(t){s.remove(t),t[1][2]=e(t),s.push(t)}var a=r(t.transform),o=n(t.transform),s=y();return e||(e=h),t.arcs.forEach(function(t){var r,n,l,c,u=[],f=0;for(n=0,l=t.length;l>n;++n)c=t[n],a(t[n]=[c[0],c[1],1/0],n);for(n=1,l=t.length-1;l>n;++n)r=t.slice(n-1,n+2),r[1][2]=e(r),u.push(r),s.push(r);for(n=0,l=u.length;l>n;++n)r=u[n],r.previous=u[n-1],r.next=u[n+1];for(;r=s.pop();){var h=r.previous,d=r.next;r[1][2]0?r.pop():new ArrayBuffer(t)}function s(t){return new Uint8Array(o(t),0,t)}function l(t){return new Uint16Array(o(2*t),0,t)}function c(t){return new Uint32Array(o(4*t),0,t)}function u(t){return new Int8Array(o(t),0,t)}function f(t){return new Int16Array(o(2*t),0,t)}function h(t){return new Int32Array(o(4*t),0,t)}function d(t){return new Float32Array(o(4*t),0,t)}function p(t){return new Float64Array(o(8*t),0,t)}function g(t){return x?new Uint8ClampedArray(o(t),0,t):s(t)}function v(t){return new DataView(o(t),0,t)}function m(t){t=y.nextPow2(t);var e=y.log2(t),r=k[e];return r.length>0?r.pop():new n(t)}var y=t("bit-twiddle"),b=t("dup");e.__TYPEDARRAY_POOL||(e.__TYPEDARRAY_POOL={UINT8:b([32,0]),UINT16:b([32,0]),UINT32:b([32,0]),INT8:b([32,0]),INT16:b([32,0]),INT32:b([32,0]),FLOAT:b([32,0]),DOUBLE:b([32,0]),DATA:b([32,0]),UINT8C:b([32,0]),BUFFER:b([32,0])});var x="undefined"!=typeof Uint8ClampedArray,_=e.__TYPEDARRAY_POOL;_.UINT8C||(_.UINT8C=b([32,0])),_.BUFFER||(_.BUFFER=b([32,0]));var w=_.DATA,k=_.BUFFER;r.free=function(t){if(n.isBuffer(t))k[y.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|y.log2(e);w[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=a,r.freeArrayBuffer=i,r.freeBuffer=function(t){k[y.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return o(t);switch(e){case"uint8":return s(t);case"uint16":return l(t);case"uint32":return c(t);case"int8":return u(t);case"int16":return f(t);case"int32":return h(t);case"float":case"float32":return d(t);case"double":case"float64":return p(t);case"uint8_clamped":return g(t);case"buffer":return m(t);case"data":case"dataview":return v(t);default:return null}return null},r.mallocArrayBuffer=o,r.mallocUint8=s,r.mallocUint16=l,r.mallocUint32=c,r.mallocInt8=u,r.mallocInt16=f,r.mallocInt32=h,r.mallocFloat32=r.mallocFloat=d,r.mallocFloat64=r.mallocDouble=p,r.mallocUint8Clamped=g,r.mallocDataView=v,r.mallocBuffer=m,r.clearCache=function(){for(var t=0;32>t;++t)_.UINT8[t].length=0,_.UINT16[t].length=0,_.UINT32[t].length=0,_.INT8[t].length=0,_.INT16[t].length=0,_.INT32[t].length=0,_.FLOAT[t].length=0,_.DOUBLE[t].length=0,_.UINT8C[t].length=0,w[t].length=0,k[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":50,buffer:51,dup:74}],238:[function(t,e,r){"use strict";function n(t,e){for(var r=1,n=t.length,i=t[0],a=t[0],o=1;n>o;++o)if(a=i,i=t[o],e(i,a)){if(o===r){r++;continue}t[r++]=i}return t.length=r,t}function i(t){for(var e=1,r=t.length,n=t[0],i=t[0],a=1;r>a;++a,i=n)if(i=n,n=t[a],n!==i){if(a===e){e++;continue}t[e++]=n}return t.length=e,t}function a(t,e,r){return 0===t.length?t:e?(r||t.sort(e),n(t,e)):(r||t.sort(),i(t))}e.exports=a},{}],239:[function(t,e,r){"use strict";function n(t,e){return"object"==typeof e&&null!==e||(e={}),i(t,e.canvas||a,e.context||o,e)}e.exports=n;var i=t("./lib/vtext"),a=null,o=null;"undefined"!=typeof document&&(a=document.createElement("canvas"),a.width=8192,a.height=1024,o=a.getContext("2d"))},{"./lib/vtext":240}],240:[function(t,e,r){"use strict";function n(t,e,r){for(var n=e.textAlign||"start",i=e.textBaseline||"alphabetic",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;s>l;++l)for(var c=t[l],u=0;2>u;++u)a[u]=0|Math.min(a[u],c[u]),o[u]=0|Math.max(o[u],c[u]);var f=0;switch(n){case"center":f=-.5*(a[0]+o[0]);break;case"right":case"end":f=-o[0];break;case"left":case"start":f=-a[0];break;default:throw new Error("vectorize-text: Unrecognized textAlign: '"+n+"'")}var h=0;switch(i){case"hanging":case"top":h=-a[1];break;case"middle":h=-.5*(a[1]+o[1]);break;case"alphabetic":case"ideographic":h=-3*r;break;case"bottom":h=-o[1];break;default:throw new Error("vectorize-text: Unrecoginized textBaseline: '"+i+"'")}var d=1/r;return"lineHeight"in e?d*=+e.lineHeight:"width"in e?d=e.width/(o[0]-a[0]):"height"in e&&(d=e.height/(o[1]-a[1])),t.map(function(t){return[d*(t[0]+f),d*(t[1]+h)]})}function i(t,e,r,n){var i=0|Math.ceil(e.measureText(r).width+2*n);if(i>8192)throw new Error("vectorize-text: String too long (sorry, this will get fixed later)");var a=3*n;t.heights)){if(n>i){var l=n;n=i,i=l,l=o,o=s,s=l}e.isConstraint(n,i)||a(t[n],t[i],t[o],t[s])<0&&r.push(n,i)}}function i(t,e){for(var r=[],i=t.length,o=e.stars,s=0;i>s;++s)for(var l=o[s],c=1;cu||e.isConstraint(s,u))){for(var f=l[c-1],h=-1,d=1;dh||a(t[s],t[u],t[f],t[h])<0&&r.push(s,u)}}for(;r.length>0;){for(var u=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],p=1;pf||0>h||a(t[s],t[u],t[f],t[h])>=0||(e.flip(s,u),n(t,e,r,f,s,h),n(t,e,r,s,h,f),n(t,e,r,h,u,f),n(t,e,r,u,f,h))}}var a=t("robust-in-sphere")[4];t("binary-search-bounds");e.exports=i},{"binary-search-bounds":246,"robust-in-sphere":247}],243:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function i(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}function a(t,e){for(var r=t.cells(),a=r.length,o=0;a>o;++o){var s=r[o],l=s[0],c=s[1],u=s[2];u>c?l>c&&(s[0]=c,s[1]=u,s[2]=l):l>u&&(s[0]=u,s[1]=l,s[2]=c)}r.sort(i);for(var f=new Array(a),o=0;oo;++o)for(var s=r[o],y=0;3>y;++y){var l=s[y],c=s[(y+1)%3],b=p[3*o+y]=m.locate(c,l,t.opposite(c,l)),x=g[3*o+y]=t.isConstraint(l,c);0>b&&(x?d.push(o):(h.push(o),f[o]=1),e&&v.push([c,l,-1]))}return m}function o(t,e,r){for(var n=0,i=0;i0||l.length>0;){for(;s.length>0;){var d=s.pop();if(c[d]!==-i){c[d]=i;for(var p=(u[d],0);3>p;++p){var g=h[3*d+p];g>=0&&0===c[g]&&(f[3*d+p]?l.push(g):(s.push(g),c[g]=i))}}}var v=l;l=s,s=v,l.length=0,i=-i}var m=o(u,c,e);return r?m.concat(n.boundary):m}var l=t("binary-search-bounds");e.exports=s;var c=n.prototype;c.locate=function(){var t=[0,0,0];return function(e,r,n){var a=e,o=r,s=n;return n>r?e>r&&(a=r,o=n,s=e):e>n&&(a=n,o=e,s=r),0>a?-1:(t[0]=a,t[1]=o,t[2]=s,l.eq(this.cells,t,i))}}()},{"binary-search-bounds":246}],244:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.a=t,this.b=e,this.idx=r,this.lowerIds=n,this.upperIds=i}function i(t,e,r,n){this.a=t,this.b=e,this.type=r,this.idx=n}function a(t,e){var r=t.a[0]-e.a[0]||t.a[1]-e.a[1]||t.type-e.type;return r?r:t.type!==p&&(r=d(t.a,t.b,e.b))?r:t.idx-e.idx}function o(t,e){return d(t.a,t.b,e)}function s(t,e,r,n,i){for(var a=h.lt(e,n,o),s=h.gt(e,n,o),l=a;s>l;++l){for(var c=e[l],u=c.lowerIds,f=u.length;f>1&&d(r[u[f-2]],r[u[f-1]],n)>0;)t.push([u[f-1],u[f-2],i]),f-=1;u.length=f,u.push(i);for(var p=c.upperIds,f=p.length;f>1&&d(r[p[f-2]],r[p[f-1]],n)<0;)t.push([p[f-2],p[f-1],i]),f-=1;p.length=f,p.push(i)}}function l(t,e){var r;return(r=t.a[0]f;++f)l.push(new i(t[f],null,p,f));for(var f=0;o>f;++f){var h=e[f],d=t[h[0]],m=t[h[1]];d[0]m[0]&&l.push(new i(m,d,v,f),new i(d,m,g,f))}l.sort(a);for(var y=l[0].a[0]-(1+Math.abs(l[0].a[0]))*Math.pow(2,-52),b=[new n([y,1],[y,0],-1,[],[],[],[])],x=[],f=0,_=l.length;_>f;++f){var w=l[f],k=w.type;k===p?s(x,b,t,w.a,w.idx):k===v?c(b,t,w):u(b,t,w)}return x}var h=t("binary-search-bounds"),d=t("robust-orientation")[3],p=0,g=1,v=2;e.exports=f},{"binary-search-bounds":246,"robust-orientation":218}],245:[function(t,e,r){"use strict";function n(t,e){this.stars=t,this.edges=e}function i(t,e,r){for(var n=1,i=t.length;i>n;n+=2)if(t[n-1]===e&&t[n]===r)return t[n-1]=t[i-2],t[n]=t[i-1],void(t.length=i-2)}function a(t,e){for(var r=new Array(t),i=0;t>i;++i)r[i]=[];return new n(r,e)}var o=t("binary-search-bounds");e.exports=a;var s=n.prototype;s.isConstraint=function(){function t(t,e){return t[0]-e[0]||t[1]-e[1]}var e=[0,0];return function(r,n){return e[0]=Math.min(r,n),e[1]=Math.max(r,n),o.eq(this.edges,e,t)>=0}}(),s.removeTriangle=function(t,e,r){var n=this.stars;i(n[t],e,r),i(n[e],r,t),i(n[r],t,e)},s.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},s.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;i>n;n+=2)if(r[n]===t)return r[n-1];return-1},s.flip=function(t,e){var r=this.opposite(t,e),n=this.opposite(e,t);this.removeTriangle(t,e,r),this.removeTriangle(e,t,n),this.addTriangle(t,n,r),this.addTriangle(e,r,n)},s.edges=function(){for(var t=this.stars,e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0,o=i.length;o>a;a+=2)e.push([i[a],i[a+1]]);return e},s.cells=function(){for(var t=this.stars,e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0,o=i.length;o>a;a+=2){var s=i[a],l=i[a+1];rr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-2,"]"].join("")}return e}function a(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",a(t.slice(0,e)),",",a(t.slice(e)),")"].join("")}function o(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return o(e,t)}function s(t){return t&!0?"-":""}function l(t){if(2===t.length)return[["diff(",o(t[0][0],t[1][1]),",",o(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;rn;++n)r.push(["prod(m",t,"[",n,"],m",t,"[",n,"])"].join(""));return a(r)}function u(t){for(var e=[],r=[],o=i(t),s=0;t>s;++s)o[0][s]="1",o[t-1][s]="w"+s;for(var s=0;t>s;++s)0===(1&s)?e.push.apply(e,l(n(o,s))):r.push.apply(r,l(n(o,s)));for(var u=a(e),f=a(r),h="exactInSphere"+t,d=[],s=0;t>s;++s)d.push("m"+s);for(var p=["function ",h,"(",d.join(),"){"],s=0;t>s;++s){p.push("var w",s,"=",c(s,t),";");for(var g=0;t>g;++g)g!==s&&p.push("var w",s,"m",g,"=scale(w",s,",m",g,"[0]);")}p.push("var p=",u,",n=",f,",d=diff(p,n);return d[d.length-1];}return ",h);var x=new Function("sum","diff","prod","scale",p.join(""));return x(m,y,v,b)}function f(){return 0}function h(){return 0}function d(){return 0}function p(t){var e=_[t.length];return e||(e=_[t.length]=u(t.length)),e.apply(void 0,t)}function g(){for(;_.length<=x;)_.push(u(_.length));for(var t=[],r=["slow"],n=0;x>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function testInSphere(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;x>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var v=t("two-product"),m=t("robust-sum"),y=t("robust-subtract"),b=t("robust-scale"),x=6,_=[f,h,d];g()},{"robust-scale":219,"robust-subtract":220,"robust-sum":221,"two-product":235}],248:[function(t,e,r){"use strict";function n(t){var e=x(t),r=b(y(e),t);return 0>r?[e,w(e,1/0)]:r>0?[w(e,-(1/0)),e]:[e,e]}function i(t,e){for(var r=new Array(e.length),n=0;n=t.length)return o[e-t.length];var r=t[e];return[y(r[0]),y(r[1])]}for(var o=[],s=0;s=0;--s){var g=n[s],c=g[0],v=e[c],m=v[0],x=v[1],w=t[m],A=t[x];if((w[0]-A[0]||w[1]-A[1])<0){var M=m;m=x,x=M}v[0]=m;var T,E=v[1]=g[1];for(i&&(T=v[2]);s>0&&n[s-1][0]===c;){var g=n[--s],L=g[1];i?e.push([E,L,T]):e.push([E,L]),E=L}i?e.push([E,x,T]):e.push([E,x])}return o}function c(t,e,r){for(var i=t.length+e.length,a=new g(i),o=r,s=0;ss;++s){var p=a.find(s);p===s?(d[s]=f,t[f++]=t[s]):(h=!1,d[s]=-1)}if(t.length=f,h)return null;for(var s=0;i>s;++s)d[s]<0&&(d[s]=d[a.find(s)]);return d}function u(t,e){return t[0]-e[0]||t[1]-e[1]}function f(t,e){var r=t[0]-e[0]||t[1]-e[1];return r?r:t[2]e[2]?1:0}function h(t,e,r){if(0!==t.length){if(e)for(var n=0;n0||d.length>0}function p(t,e,r){var n,i=!1;if(r){n=e;for(var a=new Array(e.length),o=0;o0?r=r.shln(f):0>f&&(u=u.shln(-f)),l(r,u)}var i=t("./is-rat"),a=t("./lib/is-bn"),o=t("./lib/num-to-bn"),s=t("./lib/str-to-bn"),l=t("./lib/rationalize"),c=t("./div");e.exports=n},{"./div":252,"./is-rat":254,"./lib/is-bn":258,"./lib/num-to-bn":259,"./lib/rationalize":260,"./lib/str-to-bn":261}],254:[function(t,e,r){"use strict";function n(t){return Array.isArray(t)&&2===t.length&&i(t[0])&&i(t[1])}var i=t("./lib/is-bn");e.exports=n},{"./lib/is-bn":258}],255:[function(t,e,r){"use strict";function n(t){return t.cmp(new i(0))}var i=t("bn.js");e.exports=n},{"bn.js":263}],256:[function(t,e,r){"use strict";function n(t){var e=t.length,r=t.words,n=0;if(1===e)n=r[0];else if(2===e)n=r[0]+67108864*r[1];else for(var n=0,i=0;e>i;i++){var a=r[i];n+=a*Math.pow(67108864,i)}return t.sign?-n:n}e.exports=n},{}],257:[function(t,e,r){"use strict";function n(t){var e=a(i.lo(t));if(32>e)return e;var r=a(i.hi(t));return r>20?52:r+32}var i=t("double-bits"),a=t("bit-twiddle").countTrailingZeros;e.exports=n},{"bit-twiddle":50,"double-bits":274}],258:[function(t,e,r){"use strict";function n(t){return t&&"object"==typeof t&&Boolean(t.words)}t("bn.js");e.exports=n},{"bn.js":263}],259:[function(t,e,r){"use strict";function n(t){var e=a.exponent(t);return 52>e?new i(t):new i(t*Math.pow(2,52-e)).shln(e-52)}var i=t("bn.js"),a=t("double-bits");e.exports=n},{"bn.js":263,"double-bits":274}],260:[function(t,e,r){"use strict";function n(t,e){var r=a(t),n=a(e);if(0===r)return[i(0),i(1)];if(0===n)return[i(0),i(0)];0>n&&(t=t.neg(),e=e.neg());var o=t.gcd(e);return o.cmpn(1)?[t.div(o),e.div(o)]:[t,e]}var i=t("./num-to-bn"),a=t("./bn-sign");e.exports=n},{"./bn-sign":255,"./num-to-bn":259}],261:[function(t,e,r){"use strict";function n(t){return new i(t)}var i=t("bn.js");e.exports=n},{"bn.js":263}],262:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[0]),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":260}],263:[function(t,e,r){!function(t,e){"use strict";function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){return null!==t&&"object"==typeof t&&Array.isArray(t.words)?t:(this.sign=!1,this.words=null,this.length=0,this.red=null,"le"!==e&&"be"!==e||(r=e,e=10),void(null!==t&&this._init(t||0,e||10,r||"be")))}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),a=e;i>a;a++){var o=t.charCodeAt(a)-48;n<<=4,n|=o>=49&&54>=o?o-49+10:o>=17&&22>=o?o-17+10:15&o}return n}function o(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;a>o;o++){var s=t.charCodeAt(o)-48;i*=n,i+=s>=49?s-49+10:s>=17?s-17+10:s}return i}function s(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).ishln(this.n).isub(this.p),this.tmp=this._tmp()}function l(){s.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function c(){s.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function u(){s.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function f(){s.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function h(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function d(t){h.call(this,t),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).ishln(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.sign=!0,this.minv=this.minv.mod(this.r)}"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26,i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&36>=e),t=t.toString().replace(/\s+/g,"");var i=0;"-"===t[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.sign=!0),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initNumber=function(t,e,n){0>t&&(this.sign=!0,t=-t),67108864>t?(this.words=[67108863&t],this.length=1):4503599627370496>t?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(9007199254740992>t),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3){var s=t[i]|t[i-1]<<8|t[i-2]<<16;this.words[o]|=s<>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}else if("le"===n)for(var i=0,o=0;i>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}return this.strip()},i.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6){var o=a(t,r,r+6);this.words[i]|=o<>>26-n&4194303,n+=24,n>=26&&(n-=26,i++)}if(r+6!==e){var o=a(t,e,r+6);this.words[i]|=o<>>26-n&4194303}this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;67108863>=i;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,s=a%n,l=Math.min(a,a-s)+r,c=0,u=r;l>u;u+=n)c=o(t,u,u+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){for(var f=1,c=o(t,u,t.length,e),u=0;s>u;u++)f*=e;this.imuln(f),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},i.prototype.inspect=function(){return(this.red?""};var p=["","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"],g=[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],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176]; -i.prototype.toString=function(t,e){if(t=t||10,16===t||"hex"===t){for(var n="",i=0,e=0|e||1,a=0,o=0;o>>24-i&16777215,n=0!==a||o!==this.length-1?p[6-l.length]+l+n:l+n,i+=2,i>=26&&(i-=26,o--)}for(0!==a&&(n=a.toString(16)+n);n.length%e!==0;)n="0"+n;return this.sign&&(n="-"+n),n}if(t===(0|t)&&t>=2&&36>=t){var c=g[t],u=v[t],n="",f=this.clone();for(f.sign=!1;0!==f.cmpn(0);){var h=f.modn(u).toString(t);f=f.idivn(u),n=0!==f.cmpn(0)?p[c-h.length]+h+n:h+n}return 0===this.cmpn(0)&&(n="0"+n),this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(t){this.strip();var e=new Array(this.byteLength());e[0]=0;var r=this.clone();if("le"!==t)for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[e.length-n-1]=i}else for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[n]=i}return e},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0===(8191&e)&&(r+=13,e>>>=13),0===(127&e)&&(r+=7,e>>>=7),0===(15&e)&&(r+=4,e>>>=4),0===(3&e)&&(r+=2,e>>>=2),0===(1&e)&&r++,r},i.prototype.bitLength=function(){var t=0,e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.iand=function(t){this.sign=this.sign&&t.sign;var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.ixor=function(t){this.sign=this.sign||t.sign;var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);for(var n=t/26|0,i=t%26;this.length<=n;)this.words[this.length++]=0;return e?this.words[n]=this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26}for(;0!==i&&a>>26}if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(t.sign){t.sign=!1;var e=this.iadd(t);return t.sign=!0,e._normSign()}if(this.sign)return this.sign=!1,this.iadd(t),this.sign=!0,this._normSign();var r=this.cmp(t);if(0===r)return this.sign=!1,this.length=1,this.words[0]=0,this;var n,i;r>0?(n=this,i=t):(n=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e}for(;0!==a&&o>26,this.words[o]=67108863&e}if(0===a&&o>>26,a=67108863&r,o=Math.min(n,t.length-1),s=Math.max(0,n-this.length+1);o>=s;s++){var l=n-s,c=0|this.words[l],u=0|t.words[s],f=c*u,h=67108863&f;i=i+(f/67108864|0)|0,h=h+a|0,a=67108863&h,i=i+(h>>>26)|0}e.words[n]=a,r=i}return 0!==r?e.words[n]=r:e.length--,e.strip()},i.prototype._bigMulTo=function(t,e){e.sign=t.sign!==this.sign,e.length=this.length+t.length;for(var r=0,n=0,i=0;i=l;l++){var c=i-l,u=0|this.words[c],f=0|t.words[l],h=u*f,d=67108863&h;a=a+(h/67108864|0)|0,d=d+o|0,o=67108863&d,a=a+(d>>>26)|0,n+=a>>>26,a&=67108863}e.words[i]=o,r=a,a=n}return 0!==r?e.words[i]=r:e.length--,e.strip()},i.prototype.mulTo=function(t,e){var r;return r=this.length+t.length<63?this._smallMulTo(t,e):this._bigMulTo(t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.imul=function(t){if(0===this.cmpn(0)||0===t.cmpn(0))return this.words[0]=0,this.length=1,this;var e=this.length,r=t.length;this.sign=t.sign!==this.sign,this.length=this.length+t.length,this.words[this.length-1]=0;for(var n=this.length-2;n>=0;n--){for(var i=0,a=0,o=Math.min(n,r-1),s=Math.max(0,n-e+1);o>=s;s++){var l=n-s,c=this.words[l],u=t.words[s],f=c*u,h=67108863&f;i+=f/67108864|0,h+=a,a=67108863&h,i+=h>>>26}this.words[n]=a,this.words[n+1]+=i,i=0}for(var i=0,l=1;l>>26}return this.strip()},i.prototype.imuln=function(t){r("number"==typeof t);for(var e=0,n=0;n>=26,e+=i/67108864|0,e+=a>>>26,this.words[n]=67108863&a}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.ishln=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=67108863>>>26-e<<26-e;if(0!==e){for(var a=0,o=0;o>>26-e}a&&(this.words[o]=a,this.length++)}if(0!==n){for(var o=this.length-1;o>=0;o--)this.words[o+n]=this.words[o];for(var o=0;n>o;o++)this.words[o]=0;this.length+=n}return this.strip()},i.prototype.ishrn=function(t,e,n){r("number"==typeof t&&t>=0);var i;i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<c;c++)l.words[c]=this.words[c];l.length=o}if(0===o);else if(this.length>o){this.length-=o;for(var c=0;c=0&&(0!==u||c>=i);c--){var f=this.words[c];this.words[c]=u<<26-a|f>>>a,u=f&s}return l&&0!==u&&(l.words[l.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<t?this.isubn(-t):this.sign?1===this.length&&this.words[0]=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),0>t)return this.iaddn(-t);if(this.sign)return this.sign=!1,this.iaddn(t),this.sign=!0,this;this.words[0]-=t;for(var e=0;e>26)-(c/67108864|0),this.words[i+n]=67108863&l}for(;i>26,this.words[i+n]=67108863&l}if(0===s)return this.strip();r(-1===s),s=0;for(var i=0;i>26,this.words[i]=67108863&l}return this.sign=!0,this.strip()},i.prototype._wordDiv=function(t,e){var r=this.length-t.length,n=this.clone(),a=t,o=a.words[a.length-1],s=this._countBits(o);r=26-s,0!==r&&(a=a.shln(r),n.ishln(r),o=a.words[a.length-1]);var l,c=n.length-a.length;if("mod"!==e){l=new i(null),l.length=c+1,l.words=new Array(l.length);for(var u=0;u=0;h--){var d=67108864*n.words[a.length+h]+n.words[a.length+h-1];for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(a,d,h);n.sign;)d--,n.sign=!1,n._ishlnsubmul(a,1,h),0!==n.cmpn(0)&&(n.sign=!n.sign);l&&(l.words[h]=d)}return l&&l.strip(),n.strip(),"div"!==e&&0!==r&&n.ishrn(r),{div:l?l:null,mod:n}},i.prototype.divmod=function(t,e){if(r(0!==t.cmpn(0)),this.sign&&!t.sign){var n,a,o=this.neg().divmod(t,e);return"mod"!==e&&(n=o.div.neg()),"div"!==e&&(a=0===o.mod.cmpn(0)?o.mod:t.sub(o.mod)),{div:n,mod:a}}if(!this.sign&&t.sign){var n,o=this.divmod(t.neg(),e);return"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}}return this.sign&&t.sign?this.neg().divmod(t.neg(),e):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e)},i.prototype.div=function(t){return this.divmod(t,"div").div},i.prototype.mod=function(t){return this.divmod(t,"mod").mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(0===e.mod.cmpn(0))return e.div;var r=e.div.sign?e.mod.isub(t):e.mod,n=t.shrn(1),i=t.andln(1),a=r.cmp(n);return 0>a||1===i&&0===a?e.div:e.div.sign?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(67108863>=t);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+this.words[i])%t;return n},i.prototype.idivn=function(t){r(67108863>=t);for(var e=0,n=this.length-1;n>=0;n--){var i=this.words[n]+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=new i(0),l=new i(1),c=0;e.isEven()&&n.isEven();)e.ishrn(1),n.ishrn(1),++c;for(var u=n.clone(),f=e.clone();0!==e.cmpn(0);){for(;e.isEven();)e.ishrn(1),a.isEven()&&o.isEven()?(a.ishrn(1),o.ishrn(1)):(a.iadd(u).ishrn(1),o.isub(f).ishrn(1));for(;n.isEven();)n.ishrn(1),s.isEven()&&l.isEven()?(s.ishrn(1),l.ishrn(1)):(s.iadd(u).ishrn(1),l.isub(f).ishrn(1));e.cmp(n)>=0?(e.isub(n),a.isub(s),o.isub(l)):(n.isub(e),s.isub(a),l.isub(o))}return{a:s,b:l,gcd:n.ishln(c)}},i.prototype._invmp=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(;e.isEven();)e.ishrn(1),a.isEven()?a.ishrn(1):a.iadd(s).ishrn(1);for(;n.isEven();)n.ishrn(1),o.isEven()?o.ishrn(1):o.iadd(s).ishrn(1);e.cmp(n)>=0?(e.isub(n),a.isub(o)):(n.isub(e),o.isub(a))}return 0===e.cmpn(1)?a:o},i.prototype.gcd=function(t){if(0===this.cmpn(0))return t.clone();if(0===t.cmpn(0))return this.clone();var e=this.clone(),r=t.clone();e.sign=!1,r.sign=!1;for(var n=0;e.isEven()&&r.isEven();n++)e.ishrn(1),r.ishrn(1);for(;;){for(;e.isEven();)e.ishrn(1);for(;r.isEven();)r.ishrn(1);var i=e.cmp(r);if(0>i){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.ishln(n)},i.prototype.invm=function(t){return this.egcd(t).a.mod(t)},i.prototype.isEven=function(){return 0===(1&this.words[0])},i.prototype.isOdd=function(){return 1===(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<a;a++)this.words[a]=0;return this.words[n]|=i,this.length=n+1,this}for(var o=i,a=n;0!==o&&a>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.cmpn=function(t){var e=0>t;if(e&&(t=-t),this.sign&&!e)return-1;if(!this.sign&&e)return 1;t&=67108863,this.strip();var r;if(this.length>1)r=1;else{var n=this.words[0];r=n===t?0:t>n?-1:1}return this.sign&&(r=-r),r},i.prototype.cmp=function(t){if(this.sign&&!t.sign)return-1;if(!this.sign&&t.sign)return 1;var e=this.ucmp(t);return this.sign?-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length=0;r--){var n=this.words[r],i=t.words[r];if(n!==i){i>n?e=-1:n>i&&(e=1);break}}return e},i.red=function(t){return new h(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};s.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},s.prototype.ireduce=function(t){var e,r=t;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),e=r.bitLength();while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},s.prototype.split=function(t,e){t.ishrn(this.n,0,e)},s.prototype.imulK=function(t){return t.imul(this.k)},n(l,s),l.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;n>i;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var a=t.words[9];e.words[e.length++]=a&r;for(var i=10;i>>22,a=o}t.words[i-10]=a>>>22,t.length-=9},l.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e,r=0,n=0;n>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function y(t){if(m[t])return m[t];var y;if("k256"===t)y=new l;else if("p224"===t)y=new c;else if("p192"===t)y=new u;else{if("p25519"!==t)throw new Error("Unknown prime "+t);y=new f}return m[t]=y,y},h.prototype._verify1=function(t){r(!t.sign,"red works only with positives"),r(t.red,"red works only with red numbers")},h.prototype._verify2=function(t,e){r(!t.sign&&!e.sign,"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},h.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.mod(this.m)._forceRed(this)},h.prototype.neg=function(t){var e=t.clone();return e.sign=!e.sign,e.iadd(this.m)._forceRed(this)},h.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},h.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},h.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},h.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},h.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.shln(e))},h.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},h.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},h.prototype.isqr=function(t){return this.imul(t,t)},h.prototype.sqr=function(t){return this.mul(t,t)},h.prototype.sqrt=function(t){if(0===t.cmpn(0))return t.clone();var e=this.m.andln(3);if(r(e%2===1),3===e){var n=this.m.add(new i(1)).ishrn(2),a=this.pow(t,n);return a}for(var o=this.m.subn(1),s=0;0!==o.cmpn(0)&&0===o.andln(1);)s++,o.ishrn(1);r(0!==o.cmpn(0));var l=new i(1).toRed(this),c=l.redNeg(),u=this.m.subn(1).ishrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,o),a=this.pow(t,o.addn(1).ishrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(l);){for(var g=d,v=0;0!==g.cmp(l);v++)g=g.redSqr();r(p>v);var m=this.pow(h,new i(1).ishln(p-v-1));a=a.redMul(m),h=m.redSqr(),d=d.redMul(h),p=v}return a},h.prototype.invm=function(t){var e=t._invmp(this.m);return e.sign?(e.sign=!1,this.imod(e).redNeg()):this.imod(e)},h.prototype.pow=function(t,e){var r=[];if(0===e.cmpn(0))return new i(1);for(var n=e.clone();0!==n.cmpn(0);)r.push(n.andln(1)),n.ishrn(1);for(var a=t,o=0;o=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},d.prototype.mul=function(t,e){if(0===t.cmpn(0)||0===e.cmpn(0))return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).ishrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},d.prototype.invm=function(t){var e=this.imod(t._invmp(this.m).mul(this.r2));return e._forceRed(this)}}("undefined"==typeof e||e,this)},{}],264:[function(t,e,r){"use strict";function n(t){return i(t[0])*i(t[1])}var i=t("./lib/bn-sign");e.exports=n},{"./lib/bn-sign":255}],265:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":260}],266:[function(t,e,r){"use strict";function n(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var n=e.divmod(r),o=n.div,s=i(o),l=n.mod;if(0===l.cmpn(0))return s;if(s){var c=a(s)+4,u=i(l.shln(c).divRound(r));return 0>s&&(u=-u),s+u*Math.pow(2,-c)}var f=r.bitLength()-l.bitLength()+53,u=i(l.shln(f).divRound(r));return 1023>f?u*Math.pow(2,-f):(u*=Math.pow(2,-1023),u*Math.pow(2,1023-f))}var i=t("./lib/bn-to-num"),a=t("./lib/ctz");e.exports=n},{"./lib/bn-to-num":256,"./lib/ctz":257}],267:[function(t,e,r){"use strict";function n(t,e){for(var r=0;t>r;++r)if(!(e[r]<=e[r+t]))return!0;return!1}function i(t,e,r,i){for(var a=0,o=0,s=0,l=t.length;l>s;++s){var c=t[s];if(!n(e,c)){for(var u=0;2*e>u;++u)r[a++]=c[u];i[o++]=s}}return o}function a(t,e,r,n){var a=t.length,o=e.length;if(!(0>=a||0>=o)){var s=t[0].length>>>1;if(!(0>=s)){var l,c=f.mallocDouble(2*s*a),u=f.mallocInt32(a);if(a=i(t,s,c,u),a>0){if(1===s&&n)h.init(a),l=h.sweepComplete(s,r,0,a,c,u,0,a,c,u);else{var p=f.mallocDouble(2*s*o),g=f.mallocInt32(o);o=i(e,s,p,g),o>0&&(h.init(a+o),l=1===s?h.sweepBipartite(s,r,0,a,c,u,0,o,p,g):d(s,r,n,a,c,u,o,p,g),f.free(p),f.free(g))}f.free(c),f.free(u)}return l}}}function o(t,e){u.push([t,e])}function s(t){return u=[],a(t,t,o,!0),u}function l(t,e){return u=[],a(t,e,o,!1),u}function c(t,e,r){switch(arguments.length){case 1:return s(t);case 2:return"function"==typeof e?a(t,t,e,!0):l(t,e);case 3:return a(t,e,r,!1);default:throw new Error("box-intersect: Invalid arguments")}}e.exports=c;var u,f=t("typedarray-pool"),h=t("./lib/sweep"),d=t("./lib/intersect")},{"./lib/intersect":269,"./lib/sweep":273,"typedarray-pool":237}],268:[function(t,e,r){"use strict";function n(t,e,r){var n="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),i=["function ",n,"(",w.join(),"){","var ",c,"=2*",a,";"],l="for(var i="+u+","+p+"="+c+"*"+u+";i<"+f+";++i,"+p+"+="+c+"){var x0="+h+"["+o+"+"+p+"],x1="+h+"["+o+"+"+p+"+"+a+"],xi="+d+"[i];",k="for(var j="+g+","+b+"="+c+"*"+g+";j<"+v+";++j,"+b+"+="+c+"){var y0="+m+"["+o+"+"+b+"],"+(r?"y1="+m+"["+o+"+"+b+"+"+a+"],":"")+"yi="+y+"[j];";return t?i.push(l,_,":",k):i.push(k,_,":",l),r?i.push("if(y1"+v+"-"+g+"){"),t?(e(!0,!1),o.push("}else{"),e(!1,!1)):(o.push("if("+l+"){"),e(!0,!0),o.push("}else{"),e(!0,!1),o.push("}}else{if("+l+"){"),e(!1,!0),o.push("}else{"),e(!1,!1),o.push("}")),o.push("}}return "+r);var s=i.join("")+o.join(""),c=new Function(s);return c()}var a="d",o="ax",s="vv",l="fp",c="es",u="rs",f="re",h="rb",d="ri",p="rp",g="bs",v="be",m="bb",y="bi",b="bp",x="rv",_="Q",w=[a,o,s,u,f,h,d,g,v,m,y];r.partial=i(!1),r.full=i(!0)},{}],269:[function(t,e,r){"use strict";function n(t,e){var r=8*c.log2(e+1)*(t+1)|0,n=c.nextPow2(M*r);L.lengthS&&(l.free(S),S=l.mallocDouble(i))}function i(t,e,r,n,i,a,o,s,l){var c=M*t;L[c]=e,L[c+1]=r,L[c+2]=n,L[c+3]=i,L[c+4]=a,L[c+5]=o;var u=T*t;S[u]=s,S[u+1]=l}function a(t,e,r,n,i,a,o,s,l,c,u){var f=2*t,h=l*f,d=c[h+e];t:for(var p=i,g=i*f;a>p;++p,g+=f){var v=o[g+e],m=o[g+e+t];if(!(v>d||d>m||n&&d===v)){for(var y=s[p],b=e+1;t>b;++b){var v=o[g+b],m=o[g+b+t],x=c[h+b],_=c[h+b+t];if(x>m||v>_)continue t}var w;if(w=n?r(u,y):r(y,u),void 0!==w)return w}}}function o(t,e,r,n,i,a,o,s,l,c){var u=2*t,f=s*u,h=l[f+e];t:for(var d=n,p=n*u;i>d;++d,p+=u){var g=o[d];if(g!==c){var v=a[p+e],m=a[p+e+t];if(!(v>h||h>m)){for(var y=e+1;t>y;++y){var v=a[p+y],m=a[p+y+t],b=l[f+y],x=l[f+y+t];if(b>m||v>x)continue t}var _=r(g,c);if(void 0!==_)return _}}}}function s(t,e,r,s,l,c,u,g,E){n(t,s+u);var C,z=0,P=2*t;for(i(z++,0,0,s,0,u,r?16:0,-(1/0),1/0),r||i(z++,0,0,u,0,s,1,-(1/0),1/0);z>0;){z-=1;var R=z*M,O=L[R],I=L[R+1],N=L[R+2],j=L[R+3],F=L[R+4],D=L[R+5],B=z*T,U=S[B],V=S[B+1],q=1&D,H=!!(16&D),G=l,Y=c,X=g,W=E;if(q&&(G=g,Y=E,X=l,W=c),!(2&D&&(N=_(t,O,I,N,G,Y,V),I>=N)||4&D&&(I=w(t,O,I,N,G,Y,U),I>=N))){var Z=N-I,K=F-j;if(H){if(y>t*Z*(Z+K)){if(C=d.scanComplete(t,O,e,I,N,G,Y,j,F,X,W),void 0!==C)return C;continue}}else{if(t*Math.min(Z,K)t*Z*K){if(C=d.scanBipartite(t,O,e,q,I,N,G,Y,j,F,X,W),void 0!==C)return C;continue}}var Q=b(t,O,I,N,G,Y,U,V);if(Q>I)if(v>t*(Q-I)){if(C=h(t,O+1,e,I,Q,G,Y,j,F,X,W),void 0!==C)return C}else if(O===t-2){if(C=q?d.sweepBipartite(t,e,j,F,X,W,I,Q,G,Y):d.sweepBipartite(t,e,I,Q,G,Y,j,F,X,W),void 0!==C)return C}else i(z++,O+1,I,Q,j,F,q,-(1/0),1/0),i(z++,O+1,j,F,I,Q,1^q,-(1/0),1/0);if(N>Q){var $=p(t,O,j,F,X,W),J=X[P*$+O],tt=x(t,O,$,F,X,W,J);if(F>tt&&i(z++,O,Q,N,tt,F,(4|q)+(H?16:0),J,V),$>j&&i(z++,O,Q,N,j,$,(2|q)+(H?16:0),U,J),$+1===tt){if(C=H?o(t,O,e,Q,N,G,Y,$,X,W[$]):a(t,O,e,q,Q,N,G,Y,$,X,W[$]),void 0!==C)return C}else if(tt>$){var et;if(H){if(et=k(t,O,Q,N,G,Y,J),et>Q){var rt=x(t,O,Q,et,G,Y,J);if(O===t-2){if(rt>Q&&(C=d.sweepComplete(t,e,Q,rt,G,Y,$,tt,X,W),void 0!==C))return C;if(et>rt&&(C=d.sweepBipartite(t,e,rt,et,G,Y,$,tt,X,W),void 0!==C))return C}else rt>Q&&i(z++,O+1,Q,rt,$,tt,16,-(1/0),1/0),et>rt&&(i(z++,O+1,rt,et,$,tt,0,-(1/0),1/0),i(z++,O+1,$,tt,rt,et,1,-(1/0),1/0))}}else et=q?A(t,O,Q,N,G,Y,J):k(t,O,Q,N,G,Y,J),et>Q&&(O===t-2?C=q?d.sweepBipartite(t,e,$,tt,X,W,Q,et,G,Y):d.sweepBipartite(t,e,Q,et,G,Y,$,tt,X,W):(i(z++,O+1,Q,et,$,tt,q,-(1/0),1/0),i(z++,O+1,$,tt,Q,et,1^q,-(1/0),1/0)))}}}}}e.exports=s;var l=t("typedarray-pool"),c=t("bit-twiddle"),u=t("./brute"),f=u.partial,h=u.full,d=t("./sweep"),p=t("./median"),g=t("./partition"),v=128,m=1<<22,y=1<<22,b=g("!(lo>=p0)&&!(p1>=hi)",["p0","p1"]),x=g("lo===p0",["p0"]),_=g("lol;++l,s+=o)for(var c=i[s],u=l,f=o*(l-1);u>r&&i[f+e]>c;--u,f-=o){for(var h=f,d=f+o,p=0;o>p;++p,++h,++d){var g=i[h];i[h]=i[d],i[d]=g}var v=a[u];a[u]=a[u-1],a[u-1]=v}}function i(t,e,r,i,a,l){if(r+1>=i)return r;for(var c=r,u=i,f=i+r>>>1,h=2*t,d=f,p=a[h*f+e];u>c;){if(s>u-c){n(t,e,c,u,a,l),p=a[h*f+e];break}var g=u-c,v=Math.random()*g+c|0,m=a[h*v+e],y=Math.random()*g+c|0,b=a[h*y+e],x=Math.random()*g+c|0,_=a[h*x+e];b>=m?_>=b?(d=y,p=b):m>=_?(d=v,p=m):(d=x,p=_):b>=_?(d=y,p=b):_>=m?(d=v,p=m):(d=x,p=_);for(var w=h*(u-1),k=h*d,A=0;h>A;++A,++w,++k){var M=a[w];a[w]=a[k],a[k]=M}var T=l[u-1];l[u-1]=l[d],l[d]=T,d=o(t,e,c,u-1,a,l,p);for(var w=h*(u-1),k=h*d,A=0;h>A;++A,++w,++k){var M=a[w];a[w]=a[k],a[k]=M}var T=l[u-1];if(l[u-1]=l[d],l[d]=T,d>f){for(u=d-1;u>c&&a[h*(u-1)+e]===p;)u-=1;u+=1}else{if(!(f>d))break;for(c=d+1;u>c&&a[h*c+e]===p;)c+=1}}return o(t,e,r,f,a,l,a[h*f+e])}e.exports=i;var a=t("./partition"),o=a("lo=0&&n.push("lo=e[k+n]"),t.indexOf("hi")>=0&&n.push("hi=e[k+o]"),r.push(i.replace("_",n.join()).replace("$",t)),Function.apply(void 0,r)}e.exports=n;var i="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 _;if($)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"},{}],272:[function(t,e,r){"use strict";function n(t,e){4*h>=e?i(0,e-1,t):f(0,e-1,t)}function i(t,e,r){for(var n=2*(t+1),i=t+1;e>=i;++i){for(var a=r[n++],o=r[n++],s=i,l=n-2;s-- >t;){var c=r[l-2],u=r[l-1];if(a>c)break;if(c===a&&o>u)break;r[l]=c,r[l+1]=u,l-=2}r[l]=a,r[l+1]=o}}function a(t,e,r){t*=2,e*=2;var n=r[t],i=r[t+1];r[t]=r[e],r[t+1]=r[e+1],r[e]=n,r[e+1]=i}function o(t,e,r){t*=2,e*=2,r[t]=r[e],r[t+1]=r[e+1]}function s(t,e,r,n){t*=2,e*=2,r*=2;var i=n[t],a=n[t+1];n[t]=n[e],n[t+1]=n[e+1],n[e]=n[r],n[e+1]=n[r+1],n[r]=i,n[r+1]=a}function l(t,e,r,n,i){t*=2,e*=2,i[t]=i[e],i[e]=r,i[t+1]=i[e+1],i[e+1]=n}function c(t,e,r){t*=2,e*=2;var n=r[t],i=r[e];return i>n?!1:n===i?r[t+1]>r[e+1]:!0}function u(t,e,r,n){t*=2;var i=n[t];return e>i?!0:i===e?n[t+1]>1,v=g-n,m=g+n,y=d,b=v,x=g,_=m,w=p,k=t+1,A=e-1,M=0;c(y,b,r)&&(M=y,y=b,b=M),c(_,w,r)&&(M=_,_=w,w=M),c(y,x,r)&&(M=y,y=x,x=M),c(b,x,r)&&(M=b,b=x,x=M),c(y,_,r)&&(M=y,y=_,_=M),c(x,_,r)&&(M=x,x=_,_=M),c(b,w,r)&&(M=b,b=w,w=M),c(b,x,r)&&(M=b,b=x,x=M),c(_,w,r)&&(M=_,_=w,w=M);for(var T=r[2*b],E=r[2*b+1],L=r[2*_],S=r[2*_+1],C=2*y,z=2*x,P=2*w,R=2*d,O=2*g,I=2*p,N=0;2>N;++N){var j=r[C+N],F=r[z+N],D=r[P+N];r[R+N]=j,r[O+N]=F,r[I+N]=D}o(v,t,r),o(m,e,r);for(var B=k;A>=B;++B)if(u(B,T,E,r))B!==k&&a(B,k,r),++k;else if(!u(B,L,S,r))for(;;){if(u(A,L,S,r)){u(A,T,E,r)?(s(B,k,A,r),++k,--A):(a(B,A,r),--A);break}if(--A=k-2-t?i(t,k-2,r):f(t,k-2,r),h>=e-(A+2)?i(A+2,e,r):f(A+2,e,r),h>=A-k?i(k,A,r):f(k,A,r)}e.exports=n;var h=32},{}],273:[function(t,e,r){"use strict";function n(t){var e=f.nextPow2(t);g.lengthk;++k){var A=s[k],M=b*k;_[p++]=o[M+x],_[p++]=-(A+1),_[p++]=o[M+w],_[p++]=A}for(var k=l;c>k;++k){var A=f[k]+d,T=b*k;_[p++]=u[T+x],_[p++]=-A,_[p++]=u[T+w],_[p++]=A}var E=p>>>1;h(_,E);for(var L=0,S=0,k=0;E>k;++k){var C=0|_[2*k+1];if(C>=d)C=C-d|0,i(m,y,S--,C);else if(C>=0)i(g,v,L--,C);else if(-d>=C){C=-C-d|0;for(var z=0;L>z;++z){var P=e(g[z],C);if(void 0!==P)return P}a(m,y,S++,C); +i.prototype.toString=function(t,e){if(t=t||10,16===t||"hex"===t){for(var n="",i=0,e=0|e||1,a=0,o=0;o>>24-i&16777215,n=0!==a||o!==this.length-1?p[6-l.length]+l+n:l+n,i+=2,i>=26&&(i-=26,o--)}for(0!==a&&(n=a.toString(16)+n);n.length%e!==0;)n="0"+n;return this.sign&&(n="-"+n),n}if(t===(0|t)&&t>=2&&36>=t){var c=g[t],u=v[t],n="",f=this.clone();for(f.sign=!1;0!==f.cmpn(0);){var h=f.modn(u).toString(t);f=f.idivn(u),n=0!==f.cmpn(0)?p[c-h.length]+h+n:h+n}return 0===this.cmpn(0)&&(n="0"+n),this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(t){this.strip();var e=new Array(this.byteLength());e[0]=0;var r=this.clone();if("le"!==t)for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[e.length-n-1]=i}else for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[n]=i}return e},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0===(8191&e)&&(r+=13,e>>>=13),0===(127&e)&&(r+=7,e>>>=7),0===(15&e)&&(r+=4,e>>>=4),0===(3&e)&&(r+=2,e>>>=2),0===(1&e)&&r++,r},i.prototype.bitLength=function(){var t=0,e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.iand=function(t){this.sign=this.sign&&t.sign;var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.ixor=function(t){this.sign=this.sign||t.sign;var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);for(var n=t/26|0,i=t%26;this.length<=n;)this.words[this.length++]=0;return e?this.words[n]=this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26}for(;0!==i&&a>>26}if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(t.sign){t.sign=!1;var e=this.iadd(t);return t.sign=!0,e._normSign()}if(this.sign)return this.sign=!1,this.iadd(t),this.sign=!0,this._normSign();var r=this.cmp(t);if(0===r)return this.sign=!1,this.length=1,this.words[0]=0,this;var n,i;r>0?(n=this,i=t):(n=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e}for(;0!==a&&o>26,this.words[o]=67108863&e}if(0===a&&o>>26,a=67108863&r,o=Math.min(n,t.length-1),s=Math.max(0,n-this.length+1);o>=s;s++){var l=n-s,c=0|this.words[l],u=0|t.words[s],f=c*u,h=67108863&f;i=i+(f/67108864|0)|0,h=h+a|0,a=67108863&h,i=i+(h>>>26)|0}e.words[n]=a,r=i}return 0!==r?e.words[n]=r:e.length--,e.strip()},i.prototype._bigMulTo=function(t,e){e.sign=t.sign!==this.sign,e.length=this.length+t.length;for(var r=0,n=0,i=0;i=l;l++){var c=i-l,u=0|this.words[c],f=0|t.words[l],h=u*f,d=67108863&h;a=a+(h/67108864|0)|0,d=d+o|0,o=67108863&d,a=a+(d>>>26)|0,n+=a>>>26,a&=67108863}e.words[i]=o,r=a,a=n}return 0!==r?e.words[i]=r:e.length--,e.strip()},i.prototype.mulTo=function(t,e){var r;return r=this.length+t.length<63?this._smallMulTo(t,e):this._bigMulTo(t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.imul=function(t){if(0===this.cmpn(0)||0===t.cmpn(0))return this.words[0]=0,this.length=1,this;var e=this.length,r=t.length;this.sign=t.sign!==this.sign,this.length=this.length+t.length,this.words[this.length-1]=0;for(var n=this.length-2;n>=0;n--){for(var i=0,a=0,o=Math.min(n,r-1),s=Math.max(0,n-e+1);o>=s;s++){var l=n-s,c=this.words[l],u=t.words[s],f=c*u,h=67108863&f;i+=f/67108864|0,h+=a,a=67108863&h,i+=h>>>26}this.words[n]=a,this.words[n+1]+=i,i=0}for(var i=0,l=1;l>>26}return this.strip()},i.prototype.imuln=function(t){r("number"==typeof t);for(var e=0,n=0;n>=26,e+=i/67108864|0,e+=a>>>26,this.words[n]=67108863&a}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.ishln=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=67108863>>>26-e<<26-e;if(0!==e){for(var a=0,o=0;o>>26-e}a&&(this.words[o]=a,this.length++)}if(0!==n){for(var o=this.length-1;o>=0;o--)this.words[o+n]=this.words[o];for(var o=0;n>o;o++)this.words[o]=0;this.length+=n}return this.strip()},i.prototype.ishrn=function(t,e,n){r("number"==typeof t&&t>=0);var i;i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<c;c++)l.words[c]=this.words[c];l.length=o}if(0===o);else if(this.length>o){this.length-=o;for(var c=0;c=0&&(0!==u||c>=i);c--){var f=this.words[c];this.words[c]=u<<26-a|f>>>a,u=f&s}return l&&0!==u&&(l.words[l.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<t?this.isubn(-t):this.sign?1===this.length&&this.words[0]=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),0>t)return this.iaddn(-t);if(this.sign)return this.sign=!1,this.iaddn(t),this.sign=!0,this;this.words[0]-=t;for(var e=0;e>26)-(c/67108864|0),this.words[i+n]=67108863&l}for(;i>26,this.words[i+n]=67108863&l}if(0===s)return this.strip();r(-1===s),s=0;for(var i=0;i>26,this.words[i]=67108863&l}return this.sign=!0,this.strip()},i.prototype._wordDiv=function(t,e){var r=this.length-t.length,n=this.clone(),a=t,o=a.words[a.length-1],s=this._countBits(o);r=26-s,0!==r&&(a=a.shln(r),n.ishln(r),o=a.words[a.length-1]);var l,c=n.length-a.length;if("mod"!==e){l=new i(null),l.length=c+1,l.words=new Array(l.length);for(var u=0;u=0;h--){var d=67108864*n.words[a.length+h]+n.words[a.length+h-1];for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(a,d,h);n.sign;)d--,n.sign=!1,n._ishlnsubmul(a,1,h),0!==n.cmpn(0)&&(n.sign=!n.sign);l&&(l.words[h]=d)}return l&&l.strip(),n.strip(),"div"!==e&&0!==r&&n.ishrn(r),{div:l?l:null,mod:n}},i.prototype.divmod=function(t,e){if(r(0!==t.cmpn(0)),this.sign&&!t.sign){var n,a,o=this.neg().divmod(t,e);return"mod"!==e&&(n=o.div.neg()),"div"!==e&&(a=0===o.mod.cmpn(0)?o.mod:t.sub(o.mod)),{div:n,mod:a}}if(!this.sign&&t.sign){var n,o=this.divmod(t.neg(),e);return"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}}return this.sign&&t.sign?this.neg().divmod(t.neg(),e):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e)},i.prototype.div=function(t){return this.divmod(t,"div").div},i.prototype.mod=function(t){return this.divmod(t,"mod").mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(0===e.mod.cmpn(0))return e.div;var r=e.div.sign?e.mod.isub(t):e.mod,n=t.shrn(1),i=t.andln(1),a=r.cmp(n);return 0>a||1===i&&0===a?e.div:e.div.sign?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(67108863>=t);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+this.words[i])%t;return n},i.prototype.idivn=function(t){r(67108863>=t);for(var e=0,n=this.length-1;n>=0;n--){var i=this.words[n]+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=new i(0),l=new i(1),c=0;e.isEven()&&n.isEven();)e.ishrn(1),n.ishrn(1),++c;for(var u=n.clone(),f=e.clone();0!==e.cmpn(0);){for(;e.isEven();)e.ishrn(1),a.isEven()&&o.isEven()?(a.ishrn(1),o.ishrn(1)):(a.iadd(u).ishrn(1),o.isub(f).ishrn(1));for(;n.isEven();)n.ishrn(1),s.isEven()&&l.isEven()?(s.ishrn(1),l.ishrn(1)):(s.iadd(u).ishrn(1),l.isub(f).ishrn(1));e.cmp(n)>=0?(e.isub(n),a.isub(s),o.isub(l)):(n.isub(e),s.isub(a),l.isub(o))}return{a:s,b:l,gcd:n.ishln(c)}},i.prototype._invmp=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(;e.isEven();)e.ishrn(1),a.isEven()?a.ishrn(1):a.iadd(s).ishrn(1);for(;n.isEven();)n.ishrn(1),o.isEven()?o.ishrn(1):o.iadd(s).ishrn(1);e.cmp(n)>=0?(e.isub(n),a.isub(o)):(n.isub(e),o.isub(a))}return 0===e.cmpn(1)?a:o},i.prototype.gcd=function(t){if(0===this.cmpn(0))return t.clone();if(0===t.cmpn(0))return this.clone();var e=this.clone(),r=t.clone();e.sign=!1,r.sign=!1;for(var n=0;e.isEven()&&r.isEven();n++)e.ishrn(1),r.ishrn(1);for(;;){for(;e.isEven();)e.ishrn(1);for(;r.isEven();)r.ishrn(1);var i=e.cmp(r);if(0>i){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.ishln(n)},i.prototype.invm=function(t){return this.egcd(t).a.mod(t)},i.prototype.isEven=function(){return 0===(1&this.words[0])},i.prototype.isOdd=function(){return 1===(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<a;a++)this.words[a]=0;return this.words[n]|=i,this.length=n+1,this}for(var o=i,a=n;0!==o&&a>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.cmpn=function(t){var e=0>t;if(e&&(t=-t),this.sign&&!e)return-1;if(!this.sign&&e)return 1;t&=67108863,this.strip();var r;if(this.length>1)r=1;else{var n=this.words[0];r=n===t?0:t>n?-1:1}return this.sign&&(r=-r),r},i.prototype.cmp=function(t){if(this.sign&&!t.sign)return-1;if(!this.sign&&t.sign)return 1;var e=this.ucmp(t);return this.sign?-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length=0;r--){var n=this.words[r],i=t.words[r];if(n!==i){i>n?e=-1:n>i&&(e=1);break}}return e},i.red=function(t){return new h(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};s.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},s.prototype.ireduce=function(t){var e,r=t;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),e=r.bitLength();while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},s.prototype.split=function(t,e){t.ishrn(this.n,0,e)},s.prototype.imulK=function(t){return t.imul(this.k)},n(l,s),l.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;n>i;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var a=t.words[9];e.words[e.length++]=a&r;for(var i=10;i>>22,a=o}t.words[i-10]=a>>>22,t.length-=9},l.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e,r=0,n=0;n>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function y(t){if(m[t])return m[t];var y;if("k256"===t)y=new l;else if("p224"===t)y=new c;else if("p192"===t)y=new u;else{if("p25519"!==t)throw new Error("Unknown prime "+t);y=new f}return m[t]=y,y},h.prototype._verify1=function(t){r(!t.sign,"red works only with positives"),r(t.red,"red works only with red numbers")},h.prototype._verify2=function(t,e){r(!t.sign&&!e.sign,"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},h.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.mod(this.m)._forceRed(this)},h.prototype.neg=function(t){var e=t.clone();return e.sign=!e.sign,e.iadd(this.m)._forceRed(this)},h.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},h.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},h.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},h.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},h.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.shln(e))},h.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},h.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},h.prototype.isqr=function(t){return this.imul(t,t)},h.prototype.sqr=function(t){return this.mul(t,t)},h.prototype.sqrt=function(t){if(0===t.cmpn(0))return t.clone();var e=this.m.andln(3);if(r(e%2===1),3===e){var n=this.m.add(new i(1)).ishrn(2),a=this.pow(t,n);return a}for(var o=this.m.subn(1),s=0;0!==o.cmpn(0)&&0===o.andln(1);)s++,o.ishrn(1);r(0!==o.cmpn(0));var l=new i(1).toRed(this),c=l.redNeg(),u=this.m.subn(1).ishrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,o),a=this.pow(t,o.addn(1).ishrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(l);){for(var g=d,v=0;0!==g.cmp(l);v++)g=g.redSqr();r(p>v);var m=this.pow(h,new i(1).ishln(p-v-1));a=a.redMul(m),h=m.redSqr(),d=d.redMul(h),p=v}return a},h.prototype.invm=function(t){var e=t._invmp(this.m);return e.sign?(e.sign=!1,this.imod(e).redNeg()):this.imod(e)},h.prototype.pow=function(t,e){var r=[];if(0===e.cmpn(0))return new i(1);for(var n=e.clone();0!==n.cmpn(0);)r.push(n.andln(1)),n.ishrn(1);for(var a=t,o=0;o=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},d.prototype.mul=function(t,e){if(0===t.cmpn(0)||0===e.cmpn(0))return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).ishrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},d.prototype.invm=function(t){var e=this.imod(t._invmp(this.m).mul(this.r2));return e._forceRed(this)}}("undefined"==typeof e||e,this)},{}],264:[function(t,e,r){"use strict";function n(t){return i(t[0])*i(t[1])}var i=t("./lib/bn-sign");e.exports=n},{"./lib/bn-sign":255}],265:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":260}],266:[function(t,e,r){"use strict";function n(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var n=e.divmod(r),o=n.div,s=i(o),l=n.mod;if(0===l.cmpn(0))return s;if(s){var c=a(s)+4,u=i(l.shln(c).divRound(r));return 0>s&&(u=-u),s+u*Math.pow(2,-c)}var f=r.bitLength()-l.bitLength()+53,u=i(l.shln(f).divRound(r));return 1023>f?u*Math.pow(2,-f):(u*=Math.pow(2,-1023),u*Math.pow(2,1023-f))}var i=t("./lib/bn-to-num"),a=t("./lib/ctz");e.exports=n},{"./lib/bn-to-num":256,"./lib/ctz":257}],267:[function(t,e,r){"use strict";function n(t,e){for(var r=0;t>r;++r)if(!(e[r]<=e[r+t]))return!0;return!1}function i(t,e,r,i){for(var a=0,o=0,s=0,l=t.length;l>s;++s){var c=t[s];if(!n(e,c)){for(var u=0;2*e>u;++u)r[a++]=c[u];i[o++]=s}}return o}function a(t,e,r,n){var a=t.length,o=e.length;if(!(0>=a||0>=o)){var s=t[0].length>>>1;if(!(0>=s)){var l,c=f.mallocDouble(2*s*a),u=f.mallocInt32(a);if(a=i(t,s,c,u),a>0){if(1===s&&n)h.init(a),l=h.sweepComplete(s,r,0,a,c,u,0,a,c,u);else{var p=f.mallocDouble(2*s*o),g=f.mallocInt32(o);o=i(e,s,p,g),o>0&&(h.init(a+o),l=1===s?h.sweepBipartite(s,r,0,a,c,u,0,o,p,g):d(s,r,n,a,c,u,o,p,g),f.free(p),f.free(g))}f.free(c),f.free(u)}return l}}}function o(t,e){u.push([t,e])}function s(t){return u=[],a(t,t,o,!0),u}function l(t,e){return u=[],a(t,e,o,!1),u}function c(t,e,r){switch(arguments.length){case 1:return s(t);case 2:return"function"==typeof e?a(t,t,e,!0):l(t,e);case 3:return a(t,e,r,!1);default:throw new Error("box-intersect: Invalid arguments")}}e.exports=c;var u,f=t("typedarray-pool"),h=t("./lib/sweep"),d=t("./lib/intersect")},{"./lib/intersect":269,"./lib/sweep":273,"typedarray-pool":237}],268:[function(t,e,r){"use strict";function n(t,e,r){var n="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),i=["function ",n,"(",w.join(),"){","var ",c,"=2*",a,";"],l="for(var i="+u+","+p+"="+c+"*"+u+";i<"+f+";++i,"+p+"+="+c+"){var x0="+h+"["+o+"+"+p+"],x1="+h+"["+o+"+"+p+"+"+a+"],xi="+d+"[i];",k="for(var j="+g+","+b+"="+c+"*"+g+";j<"+v+";++j,"+b+"+="+c+"){var y0="+m+"["+o+"+"+b+"],"+(r?"y1="+m+"["+o+"+"+b+"+"+a+"],":"")+"yi="+y+"[j];";return t?i.push(l,_,":",k):i.push(k,_,":",l),r?i.push("if(y1"+v+"-"+g+"){"),t?(e(!0,!1),o.push("}else{"),e(!1,!1)):(o.push("if("+l+"){"),e(!0,!0),o.push("}else{"),e(!0,!1),o.push("}}else{if("+l+"){"),e(!1,!0),o.push("}else{"),e(!1,!1),o.push("}")),o.push("}}return "+r);var s=i.join("")+o.join(""),c=new Function(s);return c()}var a="d",o="ax",s="vv",l="fp",c="es",u="rs",f="re",h="rb",d="ri",p="rp",g="bs",v="be",m="bb",y="bi",b="bp",x="rv",_="Q",w=[a,o,s,u,f,h,d,g,v,m,y];r.partial=i(!1),r.full=i(!0)},{}],269:[function(t,e,r){"use strict";function n(t,e){var r=8*c.log2(e+1)*(t+1)|0,n=c.nextPow2(M*r);L.lengthS&&(l.free(S),S=l.mallocDouble(i))}function i(t,e,r,n,i,a,o,s,l){var c=M*t;L[c]=e,L[c+1]=r,L[c+2]=n,L[c+3]=i,L[c+4]=a,L[c+5]=o;var u=T*t;S[u]=s,S[u+1]=l}function a(t,e,r,n,i,a,o,s,l,c,u){var f=2*t,h=l*f,d=c[h+e];t:for(var p=i,g=i*f;a>p;++p,g+=f){var v=o[g+e],m=o[g+e+t];if(!(v>d||d>m||n&&d===v)){for(var y=s[p],b=e+1;t>b;++b){var v=o[g+b],m=o[g+b+t],x=c[h+b],_=c[h+b+t];if(x>m||v>_)continue t}var w;if(w=n?r(u,y):r(y,u),void 0!==w)return w}}}function o(t,e,r,n,i,a,o,s,l,c){var u=2*t,f=s*u,h=l[f+e];t:for(var d=n,p=n*u;i>d;++d,p+=u){var g=o[d];if(g!==c){var v=a[p+e],m=a[p+e+t];if(!(v>h||h>m)){for(var y=e+1;t>y;++y){var v=a[p+y],m=a[p+y+t],b=l[f+y],x=l[f+y+t];if(b>m||v>x)continue t}var _=r(g,c);if(void 0!==_)return _}}}}function s(t,e,r,s,l,c,u,g,E){n(t,s+u);var C,z=0,P=2*t;for(i(z++,0,0,s,0,u,r?16:0,-(1/0),1/0),r||i(z++,0,0,u,0,s,1,-(1/0),1/0);z>0;){z-=1;var R=z*M,O=L[R],I=L[R+1],N=L[R+2],j=L[R+3],F=L[R+4],D=L[R+5],B=z*T,U=S[B],V=S[B+1],q=1&D,H=!!(16&D),G=l,Y=c,X=g,W=E;if(q&&(G=g,Y=E,X=l,W=c),!(2&D&&(N=_(t,O,I,N,G,Y,V),I>=N)||4&D&&(I=w(t,O,I,N,G,Y,U),I>=N))){var Z=N-I,K=F-j;if(H){if(y>t*Z*(Z+K)){if(C=d.scanComplete(t,O,e,I,N,G,Y,j,F,X,W),void 0!==C)return C;continue}}else{if(t*Math.min(Z,K)t*Z*K){if(C=d.scanBipartite(t,O,e,q,I,N,G,Y,j,F,X,W),void 0!==C)return C;continue}}var $=b(t,O,I,N,G,Y,U,V);if($>I)if(v>t*($-I)){if(C=h(t,O+1,e,I,$,G,Y,j,F,X,W),void 0!==C)return C}else if(O===t-2){if(C=q?d.sweepBipartite(t,e,j,F,X,W,I,$,G,Y):d.sweepBipartite(t,e,I,$,G,Y,j,F,X,W),void 0!==C)return C}else i(z++,O+1,I,$,j,F,q,-(1/0),1/0),i(z++,O+1,j,F,I,$,1^q,-(1/0),1/0);if(N>$){var Q=p(t,O,j,F,X,W),J=X[P*Q+O],tt=x(t,O,Q,F,X,W,J);if(F>tt&&i(z++,O,$,N,tt,F,(4|q)+(H?16:0),J,V),Q>j&&i(z++,O,$,N,j,Q,(2|q)+(H?16:0),U,J),Q+1===tt){if(C=H?o(t,O,e,$,N,G,Y,Q,X,W[Q]):a(t,O,e,q,$,N,G,Y,Q,X,W[Q]),void 0!==C)return C}else if(tt>Q){var et;if(H){if(et=k(t,O,$,N,G,Y,J),et>$){var rt=x(t,O,$,et,G,Y,J);if(O===t-2){if(rt>$&&(C=d.sweepComplete(t,e,$,rt,G,Y,Q,tt,X,W),void 0!==C))return C;if(et>rt&&(C=d.sweepBipartite(t,e,rt,et,G,Y,Q,tt,X,W),void 0!==C))return C}else rt>$&&i(z++,O+1,$,rt,Q,tt,16,-(1/0),1/0),et>rt&&(i(z++,O+1,rt,et,Q,tt,0,-(1/0),1/0),i(z++,O+1,Q,tt,rt,et,1,-(1/0),1/0))}}else et=q?A(t,O,$,N,G,Y,J):k(t,O,$,N,G,Y,J),et>$&&(O===t-2?C=q?d.sweepBipartite(t,e,Q,tt,X,W,$,et,G,Y):d.sweepBipartite(t,e,$,et,G,Y,Q,tt,X,W):(i(z++,O+1,$,et,Q,tt,q,-(1/0),1/0),i(z++,O+1,Q,tt,$,et,1^q,-(1/0),1/0)))}}}}}e.exports=s;var l=t("typedarray-pool"),c=t("bit-twiddle"),u=t("./brute"),f=u.partial,h=u.full,d=t("./sweep"),p=t("./median"),g=t("./partition"),v=128,m=1<<22,y=1<<22,b=g("!(lo>=p0)&&!(p1>=hi)",["p0","p1"]),x=g("lo===p0",["p0"]),_=g("lol;++l,s+=o)for(var c=i[s],u=l,f=o*(l-1);u>r&&i[f+e]>c;--u,f-=o){for(var h=f,d=f+o,p=0;o>p;++p,++h,++d){var g=i[h];i[h]=i[d],i[d]=g}var v=a[u];a[u]=a[u-1],a[u-1]=v}}function i(t,e,r,i,a,l){if(r+1>=i)return r;for(var c=r,u=i,f=i+r>>>1,h=2*t,d=f,p=a[h*f+e];u>c;){if(s>u-c){n(t,e,c,u,a,l),p=a[h*f+e];break}var g=u-c,v=Math.random()*g+c|0,m=a[h*v+e],y=Math.random()*g+c|0,b=a[h*y+e],x=Math.random()*g+c|0,_=a[h*x+e];b>=m?_>=b?(d=y,p=b):m>=_?(d=v,p=m):(d=x,p=_):b>=_?(d=y,p=b):_>=m?(d=v,p=m):(d=x,p=_);for(var w=h*(u-1),k=h*d,A=0;h>A;++A,++w,++k){var M=a[w];a[w]=a[k],a[k]=M}var T=l[u-1];l[u-1]=l[d],l[d]=T,d=o(t,e,c,u-1,a,l,p);for(var w=h*(u-1),k=h*d,A=0;h>A;++A,++w,++k){var M=a[w];a[w]=a[k],a[k]=M}var T=l[u-1];if(l[u-1]=l[d],l[d]=T,d>f){for(u=d-1;u>c&&a[h*(u-1)+e]===p;)u-=1;u+=1}else{if(!(f>d))break;for(c=d+1;u>c&&a[h*c+e]===p;)c+=1}}return o(t,e,r,f,a,l,a[h*f+e])}e.exports=i;var a=t("./partition"),o=a("lo=0&&n.push("lo=e[k+n]"),t.indexOf("hi")>=0&&n.push("hi=e[k+o]"),r.push(i.replace("_",n.join()).replace("$",t)),Function.apply(void 0,r)}e.exports=n;var i="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 _;if($)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"},{}],272:[function(t,e,r){"use strict";function n(t,e){4*h>=e?i(0,e-1,t):f(0,e-1,t)}function i(t,e,r){for(var n=2*(t+1),i=t+1;e>=i;++i){for(var a=r[n++],o=r[n++],s=i,l=n-2;s-- >t;){var c=r[l-2],u=r[l-1];if(a>c)break;if(c===a&&o>u)break;r[l]=c,r[l+1]=u,l-=2}r[l]=a,r[l+1]=o}}function a(t,e,r){t*=2,e*=2;var n=r[t],i=r[t+1];r[t]=r[e],r[t+1]=r[e+1],r[e]=n,r[e+1]=i}function o(t,e,r){t*=2,e*=2,r[t]=r[e],r[t+1]=r[e+1]}function s(t,e,r,n){t*=2,e*=2,r*=2;var i=n[t],a=n[t+1];n[t]=n[e],n[t+1]=n[e+1],n[e]=n[r],n[e+1]=n[r+1],n[r]=i,n[r+1]=a}function l(t,e,r,n,i){t*=2,e*=2,i[t]=i[e],i[e]=r,i[t+1]=i[e+1],i[e+1]=n}function c(t,e,r){t*=2,e*=2;var n=r[t],i=r[e];return i>n?!1:n===i?r[t+1]>r[e+1]:!0}function u(t,e,r,n){t*=2;var i=n[t];return e>i?!0:i===e?n[t+1]>1,v=g-n,m=g+n,y=d,b=v,x=g,_=m,w=p,k=t+1,A=e-1,M=0;c(y,b,r)&&(M=y,y=b,b=M),c(_,w,r)&&(M=_,_=w,w=M),c(y,x,r)&&(M=y,y=x,x=M),c(b,x,r)&&(M=b,b=x,x=M),c(y,_,r)&&(M=y,y=_,_=M),c(x,_,r)&&(M=x,x=_,_=M),c(b,w,r)&&(M=b,b=w,w=M),c(b,x,r)&&(M=b,b=x,x=M),c(_,w,r)&&(M=_,_=w,w=M);for(var T=r[2*b],E=r[2*b+1],L=r[2*_],S=r[2*_+1],C=2*y,z=2*x,P=2*w,R=2*d,O=2*g,I=2*p,N=0;2>N;++N){var j=r[C+N],F=r[z+N],D=r[P+N];r[R+N]=j,r[O+N]=F,r[I+N]=D}o(v,t,r),o(m,e,r);for(var B=k;A>=B;++B)if(u(B,T,E,r))B!==k&&a(B,k,r),++k;else if(!u(B,L,S,r))for(;;){if(u(A,L,S,r)){u(A,T,E,r)?(s(B,k,A,r),++k,--A):(a(B,A,r),--A);break}if(--A=k-2-t?i(t,k-2,r):f(t,k-2,r),h>=e-(A+2)?i(A+2,e,r):f(A+2,e,r),h>=A-k?i(k,A,r):f(k,A,r)}e.exports=n;var h=32},{}],273:[function(t,e,r){"use strict";function n(t){var e=f.nextPow2(t);g.lengthk;++k){var A=s[k],M=b*k;_[p++]=o[M+x],_[p++]=-(A+1),_[p++]=o[M+w],_[p++]=A}for(var k=l;c>k;++k){var A=f[k]+d,T=b*k;_[p++]=u[T+x],_[p++]=-A,_[p++]=u[T+w],_[p++]=A}var E=p>>>1;h(_,E);for(var L=0,S=0,k=0;E>k;++k){var C=0|_[2*k+1];if(C>=d)C=C-d|0,i(m,y,S--,C);else if(C>=0)i(g,v,L--,C);else if(-d>=C){C=-C-d|0;for(var z=0;L>z;++z){var P=e(g[z],C);if(void 0!==P)return P}a(m,y,S++,C); }else{C=-C-1|0;for(var z=0;S>z;++z){var P=e(C,m[z]);if(void 0!==P)return P}a(g,v,L++,C)}}}function s(t,e,r,n,o,s,l,c,u,f){for(var d=0,p=2*t,w=t-1,k=p-1,A=r;n>A;++A){var M=s[A]+1<<1,T=p*A;_[d++]=o[T+w],_[d++]=-M,_[d++]=o[T+k],_[d++]=M}for(var A=l;c>A;++A){var M=f[A]+1<<1,E=p*A;_[d++]=u[E+w],_[d++]=1|-M,_[d++]=u[E+k],_[d++]=1|M}var L=d>>>1;h(_,L);for(var S=0,C=0,z=0,A=0;L>A;++A){var P=0|_[2*A+1],R=1&P;if(L-1>A&&P>>1===_[2*A+3]>>1&&(R=2,A+=1),0>P){for(var O=-(P>>1)-1,I=0;z>I;++I){var N=e(b[I],O);if(void 0!==N)return N}if(0!==R)for(var I=0;S>I;++I){var N=e(g[I],O);if(void 0!==N)return N}if(1!==R)for(var I=0;C>I;++I){var N=e(m[I],O);if(void 0!==N)return N}0===R?a(g,v,S++,O):1===R?a(m,y,C++,O):2===R&&a(b,x,z++,O)}else{var O=(P>>1)-1;0===R?i(g,v,S--,O):1===R?i(m,y,C--,O):2===R&&i(b,x,z--,O)}}}function l(t,e,r,n,o,s,l,c,u,f,p,m){var y=0,b=2*t,x=e,w=e+t,k=1,A=1;n?A=d:k=d;for(var M=o;s>M;++M){var T=M+k,E=b*M;_[y++]=l[E+x],_[y++]=-T,_[y++]=l[E+w],_[y++]=T}for(var M=u;f>M;++M){var T=M+A,L=b*M;_[y++]=p[L+x],_[y++]=-T}var S=y>>>1;h(_,S);for(var C=0,M=0;S>M;++M){var z=0|_[2*M+1];if(0>z){var T=-z,P=!1;if(T>=d?(P=!n,T-=d):(P=!!n,T-=1),P)a(g,v,C++,T);else{var R=m[T],O=b*T,I=p[O+e+1],N=p[O+e+1+t];t:for(var j=0;C>j;++j){var F=g[j],D=b*F;if(!(NB;++B)if(p[O+B+t]y;++y){var b=y+d,x=p*y;_[f++]=a[x+v],_[f++]=-b,_[f++]=a[x+m],_[f++]=b}for(var y=s;l>y;++y){var b=y+1,w=p*y;_[f++]=c[w+v],_[f++]=-b}var k=f>>>1;h(_,k);for(var A=0,y=0;k>y;++y){var M=0|_[2*y+1];if(0>M){var b=-M;if(b>=d)g[A++]=b-d;else{b-=1;var T=u[b],E=p*b,L=c[E+e+1],S=c[E+e+1+t];t:for(var C=0;A>C;++C){var z=g[C],P=o[z];if(P===T)break;var R=p*z;if(!(SO;++O)if(c[E+O+t]=0;--C)if(g[C]===b){for(var O=C+1;A>O;++O)g[O-1]=g[O];break}--A}}}e.exports={init:n,sweepBipartite:o,sweepComplete:s,scanBipartite:l,scanComplete:c};var u=t("typedarray-pool"),f=t("bit-twiddle"),h=t("./sort"),d=1<<28,p=1024,g=u.mallocInt32(p),v=u.mallocInt32(p),m=u.mallocInt32(p),y=u.mallocInt32(p),b=u.mallocInt32(p),x=u.mallocInt32(p),_=u.mallocDouble(8*p)},{"./sort":272,"bit-twiddle":50,"typedarray-pool":237}],274:[function(t,e,r){(function(t){function r(t,e){return d[0]=t,d[1]=e,h[0]}function n(t){return h[0]=t,d[0]}function i(t){return h[0]=t,d[1]}function a(t,e){return d[1]=t,d[0]=e,h[0]}function o(t){return h[0]=t,d[1]}function s(t){return h[0]=t,d[0]}function l(t,e){return p.writeUInt32LE(t,0,!0),p.writeUInt32LE(e,4,!0),p.readDoubleLE(0,!0)}function c(t){return p.writeDoubleLE(t,0,!0),p.readUInt32LE(0,!0)}function u(t){return p.writeDoubleLE(t,0,!0),p.readUInt32LE(4,!0)}var f=!1;if("undefined"!=typeof Float64Array){var h=new Float64Array(1),d=new Uint32Array(h.buffer);h[0]=1,f=!0,1072693248===d[1]?(e.exports=function(t){return h[0]=t,[d[0],d[1]]},e.exports.pack=r,e.exports.lo=n,e.exports.hi=i):1072693248===d[0]?(e.exports=function(t){return h[0]=t,[d[1],d[0]]},e.exports.pack=a,e.exports.lo=o,e.exports.hi=s):f=!1}if(!f){var p=new t(8);e.exports=function(t){return p.writeDoubleLE(t,0,!0),[p.readUInt32LE(0,!0),p.readUInt32LE(4,!0)]},e.exports.pack=l,e.exports.lo=c,e.exports.hi=u}e.exports.sign=function(t){return e.exports.hi(t)>>>31},e.exports.exponent=function(t){var r=e.exports.hi(t);return(r<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){var r=e.exports.hi(t);return!(2146435072&r)}}).call(this,t("buffer").Buffer)},{buffer:51}],275:[function(t,e,r){"use strict";function n(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return 0>e?-a:a;var r=i.hi(t),n=i.lo(t);return e>t==t>0?n===o?(r+=1,n=0):n+=1:0===n?(n=o,r-=1):n-=1,i.pack(n,r)}var i=t("double-bits"),a=Math.pow(2,-1074),o=-1>>>0;e.exports=n},{"double-bits":274}],276:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),a=0;r>a;++a)n[a]=i(t[a],e[a]);return n}var i=t("big-rat/add");e.exports=n},{"big-rat/add":250}],277:[function(t,e,r){"use strict";function n(t){for(var e=new Array(t.length),r=0;rs;++s)o[s]=a(t[s],r);return o}var i=t("big-rat"),a=t("big-rat/mul");e.exports=n},{"big-rat":253,"big-rat/mul":262}],279:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),a=0;r>a;++a)n[a]=i(t[a],e[a]);return n}var i=t("big-rat/sub");e.exports=n},{"big-rat/sub":265}],280:[function(t,e,r){"use strict";function n(t,e,r,n){for(var i=0;2>i;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),c=r[i],u=n[i],f=Math.min(c,u),h=Math.max(c,u);if(s>h||f>l)return!1}return!0}function i(t,e,r,i){var o=a(t,r,i),s=a(e,r,i);if(o>0&&s>0||0>o&&0>s)return!1;var l=a(r,t,e),c=a(i,t,e);return l>0&&c>0||0>l&&0>c?!1:0===o&&0===s&&0===l&&0===c?n(t,e,r,i):!0}e.exports=i;var a=t("robust-orientation")[3]},{"robust-orientation":218}],281:[function(t,e,r){arguments[4][196][0].apply(r,arguments)},{dup:196}],282:[function(t,e,r){"use strict";function n(t,e){for(var r=i(t,e.length),n=new Array(e.length),a=new Array(e.length),o=[],s=0;s=l&&o.push(s)}for(;o.length>0;){var c=o.pop();n[c]=!1;for(var u=r[c],s=0;sn;++n){var a=t[n];e=Math.max(e,a[0],a[1])}e=(0|e)+1}e=0|e;for(var o=new Array(e),n=0;e>n;++n)o[n]=[];for(var n=0;r>n;++n){var a=t[n];o[a[0]].push(a[1]),o[a[1]].push(a[0])}for(var s=0;e>s;++s)i(o[s],function(t,e){return t-e});return o}e.exports=n;var i=t("uniq")},{uniq:238}],284:[function(t,e,r){"use strict";function n(t,e){function r(t,e){var r=c[e][t[e]];r.splice(r.indexOf(t),1)}function n(t,n,a){for(var o,s,l,u=0;2>u;++u)if(c[u][n].length>0){o=c[u][n][0],l=u;break}s=o[1^l];for(var f=0;2>f;++f)for(var h=c[f][n],d=0;d0&&(o=p,s=g,l=f)}return a?s:(o&&r(o,l),s)}function a(t,a){var o=c[a][t][0],s=[t];r(o,a);for(var l=o[1^a];;){for(;l!==t;)s.push(l),l=n(s[s.length-2],l,!1);if(c[0][t].length+c[1][t].length===0)break;var u=s[s.length-1],f=t,h=s[1],d=n(u,f,!0);if(i(e[u],e[f],e[h],e[d])<0)break;s.push(t),l=n(u,f)}return s}function o(t,e){return e[1]===e[e.length-1]}for(var s=0|e.length,l=t.length,c=[new Array(s),new Array(s)],u=0;s>u;++u)c[0][u]=[],c[1][u]=[];for(var u=0;l>u;++u){var f=t[u];c[0][f[0]].push(f),c[1][f[1]].push(f)}for(var h=[],u=0;s>u;++u)c[0][u].length+c[1][u].length===0&&h.push([u]);for(var u=0;s>u;++u)for(var d=0;2>d;++d){for(var p=[];c[d][u].length>0;){var g=(c[0][u].length,a(u,d));o(p,g)?p.push.apply(p,g):(p.length>0&&h.push(p),p=g)}p.length>0&&h.push(p)}return h}e.exports=n;var i=t("compare-angle")},{"compare-angle":285}],285:[function(t,e,r){"use strict";function n(t,e,r){var n=s(t[0],-e[0]),i=s(t[1],-e[1]),a=s(r[0],-e[0]),o=s(r[1],-e[1]),u=c(l(n,a),l(i,o));return u[u.length-1]>=0}function i(t,e,r,i){var s=a(e,r,i);if(0===s){var l=o(a(t,e,r)),c=o(a(t,e,i));if(l===c){if(0===l){var u=n(t,e,r),f=n(t,e,i);return u===f?0:u?1:-1}return 0}return 0===c?l>0?-1:n(t,e,i)?-1:1:0===l?c>0?1:n(t,e,r)?1:-1:o(c-l)}var h=a(t,e,r);if(h>0)return s>0&&a(t,e,i)>0?1:-1;if(0>h)return s>0||a(t,e,i)>0?1:-1;var d=a(t,e,i);return d>0?1:n(t,e,r)?1:-1}e.exports=i;var a=t("robust-orientation"),o=t("signum"),s=t("two-sum"),l=t("robust-product"),c=t("robust-sum")},{"robust-orientation":218,"robust-product":286,"robust-sum":221,signum:287,"two-sum":236}],286:[function(t,e,r){"use strict";function n(t,e){if(1===t.length)return a(e,t[0]);if(1===e.length)return a(t,e[0]);if(0===t.length||0===e.length)return[0];var r=[0];if(t.lengtht?-1:t>0?1:0}},{}],288:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],289:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}function i(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function a(t,e){var r=p(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function o(t,e){var r=t.intervals([]);r.push(e),a(t,r)}function s(t,e){var r=t.intervals([]),n=r.indexOf(e);return 0>n?y:(r.splice(n,1),a(t,r),b)}function l(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function u(t,e){for(var r=0;r>1],a=[],o=[],s=[],r=0;r3*(e+1)?o(this,t):this.left.insert(t):this.left=p([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?o(this,t):this.right.insert(t):this.right=p([t]);else{var r=m.ge(this.leftPoints,t,h),n=m.ge(this.rightPoints,t,d);this.leftPoints.splice(r,0,t),this.rightPoints.splice(n,0,t)}},_.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1))return s(this,t);var n=this.left.remove(t);return n===x?(this.left=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(t[0]>this.mid){if(!this.right)return y;var a=this.left?this.left.count:0;if(4*a>3*(e-1))return s(this,t);var n=this.right.remove(t);return n===x?(this.right=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(1===this.count)return this.leftPoints[0]===t?x:y;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var o=this,l=this.left;l.right;)o=l,l=l.right;if(o===this)l.right=this.right;else{var c=this.left,n=this.right;o.count-=l.count,o.right=l.left,l.left=c,l.right=n}i(this,l),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?i(this,this.left):i(this,this.right);return b}for(var c=m.ge(this.leftPoints,t,h);cthis.mid){if(this.right){var r=this.right.queryPoint(t,e);if(r)return r}return c(this.rightPoints,t,e)}return u(this.leftPoints,e)},_.queryInterval=function(t,e,r){if(tthis.mid&&this.right){var n=this.right.queryInterval(t,e,r);if(n)return n}return ethis.mid?c(this.rightPoints,t,r):u(this.leftPoints,r)};var w=g.prototype;w.insert=function(t){this.root?this.root.insert(t):this.root=new n(t[0],null,null,[t],[t])},w.remove=function(t){if(this.root){var e=this.root.remove(t);return e===x&&(this.root=null),e!==y}return!1},w.queryPoint=function(t,e){return this.root?this.root.queryPoint(t,e):void 0},w.queryInterval=function(t,e,r){return e>=t&&this.root?this.root.queryInterval(t,e,r):void 0},Object.defineProperty(w,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(w,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":288}],290:[function(t,e,r){"use strict";function n(t,e){var r,n;if(e[0][0]e[1][0])){var i=Math.min(t[0][1],t[1][1]),o=Math.max(t[0][1],t[1][1]),s=Math.min(e[0][1],e[1][1]),l=Math.max(e[0][1],e[1][1]);return s>o?o-s:i>l?i-l:o-l}r=e[1],n=e[0]}var c,u;t[0][1]e[1][0]))return n(e,t);r=e[1],i=e[0]}var o,s;if(t[0][0]t[1][0]))return-n(t,e);o=t[1],s=t[0]}var l=a(r,i,s),c=a(r,i,o);if(0>l){if(0>=c)return l}else if(l>0){if(c>=0)return l}else if(c)return c;if(l=a(s,o,i),c=a(s,o,r),0>l){if(0>=c)return l}else if(l>0){if(c>=0)return l}else if(c)return c;return i[0]-s[0]}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":218}],291:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function i(t){return new n(t._color,t.key,t.value,t.left,t.right,t._count)}function a(t,e){return new n(t,e.key,e.value,e.left,e.right,e._count)}function o(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function s(t,e){this._compare=t,this.root=e}function l(t,e){if(e.left){var r=l(t,e.left);if(r)return r}var r=t(e.key,e.value);return r?r:e.right?l(t,e.right):void 0}function c(t,e,r,n){var i=e(t,n.key);if(0>=i){if(n.left){var a=c(t,e,r,n.left);if(a)return a}var a=r(n.key,n.value);if(a)return a}return n.right?c(t,e,r,n.right):void 0}function u(t,e,r,n,i){var a,o=r(t,i.key),s=r(e,i.key);if(0>=o){if(i.left&&(a=u(t,e,r,n,i.left)))return a;if(s>0&&(a=n(i.key,i.value)))return a}return s>0&&i.right?u(t,e,r,n,i.right):void 0}function f(t,e){this.tree=t,this._stack=e}function h(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function d(t){for(var e,r,n,s,l=t.length-1;l>=0;--l){if(e=t[l],0===l)return void(e._color=m);if(r=t[l-1],r.left===e){if(n=r.right,n.right&&n.right._color===v){if(n=r.right=i(n),s=n.right=i(n.right),r.right=n.left,n.left=r,n.right=s,n._color=r._color,e._color=m,r._color=m,s._color=m,o(r),o(n),l>1){var c=t[l-2];c.left===r?c.left=n:c.right=n}return void(t[l-1]=n)}if(n.left&&n.left._color===v){if(n=r.right=i(n),s=n.left=i(n.left),r.right=s.left,n.left=s.right,s.left=r,s.right=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var c=t[l-2];c.left===r?c.left=s:c.right=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.right=a(v,n));r.right=a(v,n);continue}if(n=i(n),r.right=n.left,n.left=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var c=t[l-2];c.left===r?c.left=n:c.right=n}t[l-1]=n,t[l]=r,l+11){var c=t[l-2];c.right===r?c.right=n:c.left=n}return void(t[l-1]=n)}if(n.right&&n.right._color===v){if(n=r.left=i(n),s=n.right=i(n.right),r.left=s.right,n.right=s.left,s.right=r,s.left=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var c=t[l-2];c.right===r?c.right=s:c.left=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.left=a(v,n));r.left=a(v,n);continue}if(n=i(n),r.left=n.right,n.right=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var c=t[l-2];c.right===r?c.right=n:c.left=n}t[l-1]=n,t[l]=r,l+1t?-1:t>e?1:0}function g(t){return new s(t||p,null)}e.exports=g;var v=0,m=1,y=s.prototype;Object.defineProperty(y,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(y,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(y,"length",{get:function(){return this.root?this.root._count:0}}),y.insert=function(t,e){for(var r=this._compare,i=this.root,l=[],c=[];i;){var u=r(t,i.key);l.push(i),c.push(u),i=0>=u?i.left:i.right}l.push(new n(v,t,e,null,null,1));for(var f=l.length-2;f>=0;--f){var i=l[f];c[f]<=0?l[f]=new n(i._color,i.key,i.value,l[f+1],i.right,i._count+1):l[f]=new n(i._color,i.key,i.value,i.left,l[f+1],i._count+1)}for(var f=l.length-1;f>1;--f){var h=l[f-1],i=l[f];if(h._color===m||i._color===m)break;var d=l[f-2];if(d.left===h)if(h.left===i){var p=d.right;if(!p||p._color!==v){if(d._color=v,d.left=h.right,h._color=m,h.right=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.left===d?g.left=h:g.right=h}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else{var p=d.right;if(!p||p._color!==v){if(h.right=i.left,d._color=v,d.left=i.right,i._color=m,i.left=h,i.right=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.left===d?g.left=i:g.right=i}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else if(h.right===i){var p=d.left;if(!p||p._color!==v){if(d._color=v,d.right=h.left,h._color=m,h.left=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.right===d?g.right=h:g.left=h}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}else{var p=d.left;if(!p||p._color!==v){if(h.left=i.right,d._color=v,d.right=i.left,i._color=m,i.right=h,i.left=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.right===d?g.right=i:g.left=i}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}}return l[0]._color=m,new s(r,l[0])},y.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return l(t,this.root);case 2:return c(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return u(e,r,this._compare,t,this.root)}},Object.defineProperty(y,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(y,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),y.at=function(t){if(0>t)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},y.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>=a&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>a&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new f(this,n);r=0>=i?r.left:r.right}return new f(this,[])},y.remove=function(t){var e=this.find(t);return e?e.remove():this},y.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=0>=n?r.left:r.right}};var b=f.prototype;Object.defineProperty(b,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(b,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),b.clone=function(){return new f(this.tree,this._stack.slice())},b.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new n(r._color,r.key,r.value,r.left,r.right,r._count);for(var i=t.length-2;i>=0;--i){var r=t[i];r.left===t[i+1]?e[i]=new n(r._color,r.key,r.value,e[i+1],r.right,r._count):e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count)}if(r=e[e.length-1],r.left&&r.right){var a=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var o=e[a-1];e.push(new n(r._color,o.key,o.value,r.left,r.right,r._count)),e[a-1].key=r.key,e[a-1].value=r.value;for(var i=e.length-2;i>=a;--i)r=e[i],e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count);e[a-1].left=e[a]}if(r=e[e.length-1],r._color===v){var l=e[e.length-2];l.left===r?l.left=null:l.right===r&&(l.right=null),e.pop();for(var i=0;i0?this._stack[this._stack.length-1].key:void 0},enumerable:!0}),Object.defineProperty(b,"value",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1].value:void 0},enumerable:!0}),Object.defineProperty(b,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),b.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),b.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),i=e[e.length-1];r[r.length-1]=new n(i._color,i.key,t,i.left,i.right,i._count);for(var a=e.length-2;a>=0;--a)i=e[a],i.left===e[a+1]?r[a]=new n(i._color,i.key,i.value,r[a+1],i.right,i._count):r[a]=new n(i._color,i.key,i.value,i.left,r[a+1],i._count);return new s(this.tree._compare,r[0])},b.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],292:[function(t,e,r){"use strict";function n(t,e,r){this.slabs=t,this.coordinates=e,this.horizontal=r}function i(t,e){return t.y-e}function a(t,e){for(var r=null;t;){var n,i,o=t.key;o[0][0]s)t=t.left;else if(s>0)if(e[0]!==o[1][0])r=t,t=t.right;else{var l=a(t.right,e);if(l)return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l=a(t.right,e);if(l)return l;t=t.left}}return r}function o(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function s(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}function l(t){for(var e=t.length,r=2*e,i=new Array(r),a=0;e>a;++a){var l=t[a],c=l[0][0]a;){for(var v=i[a].x,m=[];r>a;){var y=i[a];if(y.x!==v)break;a+=1,y.segment[0][0]===y.x&&y.segment[1][0]===y.x?y.create&&(y.segment[0][1]e)return-1;var r=(this.slabs[e],a(this.slabs[e],t)),n=-1;if(r&&(n=r.value),this.coordinates[e]===t[0]){var o=null;if(r&&(o=r.key),e>0){var s=a(this.slabs[e-1],t);s&&(o?h(s.key,o)>0&&(o=s.key,n=s.value):(n=s.value,o=s.key))}var l=this.horizontal[e];if(l.length>0){var u=c.ge(l,t[1],i);if(u=l.length)return n;d=l[u]}}if(d.start)if(o){var p=f(o[0],o[1],[t[0],d.y]);o[0][0]>o[1][0]&&(p=-p),p>0&&(n=d.index)}else n=d.index;else d.y!==t[1]&&(n=d.index)}}}return n}},{"./lib/order-segments":290,"binary-search-bounds":288,"functional-red-black-tree":291,"robust-orientation":218}],293:[function(t,e,r){function n(){return!0}function i(t){return function(e,r){var i=t[e];return i?!!i.queryPoint(r,n):!1}}function a(t){for(var e={},r=0;rn)return 1;var i=t[n];if(!i){if(!(n>0&&e[n]===r[0]))return 1;i=t[n-1]}for(var a=1;i;){var o=i.key,s=f(r,o[0],o[1]);if(o[0][0]s)i=i.left;else{if(!(s>0))return 0;a=-1,i=i.right}else if(s>0)i=i.left;else{if(!(0>s))return 0;a=1,i=i.right}}return a}}function s(t){return 1}function l(t){return function(e){return t(e[0],e[1])?0:1}}function c(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}function u(t){for(var e=t.length,r=[],n=[],i=0;e>i;++i)for(var u=t[i],f=u.length,d=f-1,p=0;f>p;d=p++){var g=u[d],v=u[p];g[0]===v[0]?n.push([g,v]):r.push([g,v])}if(0===r.length)return 0===n.length?s:l(a(n));var m=h(r),y=o(m.slabs,m.coordinates);return 0===n.length?y:c(a(n),y)}e.exports=u;var f=t("robust-orientation")[3],h=t("slab-decomposition"),d=t("interval-tree-1d"),p=t("binary-search-bounds")},{"binary-search-bounds":288,"interval-tree-1d":289,"robust-orientation":218,"slab-decomposition":292}],294:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function i(t){for(var e=new Array(t),r=0;t>r;++r)e[r]=[];return e}function a(t,e){function r(t){for(var r=t.length,n=[0],i=0;r>i;++i){var a=e[t[i]],o=e[t[(i+1)%r]],s=c(-a[0],a[1]),l=c(-a[0],o[1]),f=c(o[0],a[1]),h=c(o[0],o[1]);n=u(n,u(u(s,l),u(f,h)))}return n[n.length-1]>0}function a(t){for(var e=t.length,r=0;e>r;++r)if(!O[t[r]])return!1;return!0}var d=h(t,e);t=d[0],e=d[1];for(var p=e.length,g=(t.length,o(t,e.length)),v=0;p>v;++v)if(g[v].length%2===1)throw new Error("planar-graph-to-polyline: graph must be manifold");var m=s(t,e);m=m.filter(r);for(var y=m.length,b=new Array(y),x=new Array(y),v=0;y>v;++v){b[v]=v;var _=new Array(y),w=m[v].map(function(t){return e[t]}),k=l([w]),A=0;t:for(var M=0;y>M;++M)if(_[M]=0,v!==M){for(var T=m[M],E=T.length,L=0;E>L;++L){var S=k(e[T[L]]);if(0!==S){0>S&&(_[M]=1,A+=1);continue t}}_[M]=1,A+=1}x[v]=[A,v,_]}x.sort(function(t,e){return e[0]-t[0]});for(var v=0;y>v;++v)for(var _=x[v],C=_[1],z=_[2],M=0;y>M;++M)z[M]&&(b[M]=C);for(var P=i(y),v=0;y>v;++v)P[v].push(b[v]),P[b[v]].push(v);for(var R={},O=n(p,!1),v=0;y>v;++v)for(var T=m[v],E=T.length,M=0;E>M;++M){var I=T[M],N=T[(M+1)%E],j=Math.min(I,N)+":"+Math.max(I,N);if(j in R){var F=R[j];P[F].push(v),P[v].push(F),O[I]=O[N]=!0}else R[j]=v}for(var D=[],B=n(y,-1),v=0;y>v;++v)b[v]!==v||a(m[v])?B[v]=-1:(D.push(v),B[v]=0);for(var d=[];D.length>0;){var U=D.pop(),V=P[U];f(V,function(t,e){return t-e});var q,H=V.length,G=B[U];if(0===G){var T=m[U];q=[T]}for(var v=0;H>v;++v){var Y=V[v];if(!(B[Y]>=0)&&(B[Y]=1^G,D.push(Y),0===G)){var T=m[Y];a(T)||(T.reverse(),q.push(T))}}0===G&&d.push(q)}return d}e.exports=a;var o=t("edges-to-adjacency-list"),s=t("planar-dual"),l=t("point-in-big-polygon"),c=t("two-product"),u=t("robust-sum"),f=t("uniq"),h=t("./lib/trim-leaves")},{"./lib/trim-leaves":282,"edges-to-adjacency-list":283,"planar-dual":284,"point-in-big-polygon":293,"robust-sum":221,"two-product":235,uniq:238}],295:[function(t,e,r){arguments[4][50][0].apply(r,arguments)},{dup:50}],296:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;t>e;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n,n.prototype.length=function(){return this.roots.length},n.prototype.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},n.prototype.find=function(t){for(var e=this.roots;e[t]!==t;){var r=e[t];e[t]=e[r],t=r}return t},n.prototype.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],297:[function(t,e,r){arguments[4][197][0].apply(r,arguments)},{"bit-twiddle":295,dup:197,"union-find":296}],298:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.abs(a(t,e,r)),i=Math.sqrt(Math.pow(e[0]-r[0],2)+Math.pow(e[1]-r[1],2));return n/i}function i(t,e,r){function i(t){if(x[t])return 1/0;var r=m[t],i=y[t];return 0>r||0>i?1/0:n(e[t],e[r],e[i])}function a(t,e){var r=M[t],n=M[e];M[t]=n,M[e]=r,T[r]=e,T[n]=t}function s(t){return b[M[t]]}function l(t){return 1&t?t-1>>1:(t>>1)-1}function c(t){for(var e=s(t);;){var r=e,n=2*t+1,i=2*(t+1),o=t;if(L>n){var l=s(n);r>l&&(o=n,r=l)}if(L>i){var c=s(i);r>c&&(o=i)}if(o===t)return t;a(t,o),t=o}}function u(t){for(var e=s(t);t>0;){var r=l(t);if(r>=0){var n=s(r);if(n>e){a(t,r),t=r;continue}}return t}}function f(){if(L>0){var t=M[0];return a(0,L-1),L-=1,c(0),t}return-1}function h(t,e){var r=M[t];return b[r]===e?t:(b[r]=-(1/0),u(t),f(),b[r]=e,L+=1,u(L-1))}function d(t){if(!x[t]){x[t]=!0;var e=m[t],r=y[t];m[r]>=0&&(m[r]=e),y[e]>=0&&(y[e]=r),T[e]>=0&&h(T[e],i(e)),T[r]>=0&&h(T[r],i(r))}}function p(t,e){if(t[e]<0)return e;var r=e,n=e;do{var i=t[n];if(!x[n]||0>i||i===n)break;if(n=i,i=t[n],!x[n]||0>i||i===n)break;n=i,r=t[r]}while(r!==n);for(var a=e;a!==n;a=t[a])t[a]=n;return n}for(var g=e.length,v=t.length,m=new Array(g),y=new Array(g),b=new Array(g),x=new Array(g),_=0;g>_;++_)m[_]=y[_]=-1,b[_]=1/0,x[_]=!1;for(var _=0;v>_;++_){var w=t[_];if(2!==w.length)throw new Error("Input must be a graph");var k=w[1],A=w[0];-1!==y[A]?y[A]=-2:y[A]=k,-1!==m[k]?m[k]=-2:m[k]=A}for(var M=[],T=new Array(g),_=0;g>_;++_){var E=b[_]=i(_);1/0>E?(T[_]=M.length,M.push(_)):T[_]=-1}for(var L=M.length,_=L>>1;_>=0;--_)c(_);for(;;){var S=f();if(0>S||b[S]>r)break;d(S)}for(var C=[],_=0;g>_;++_)x[_]||(T[_]=C.length,C.push(e[_].slice()));var z=(C.length,[]);return t.forEach(function(t){var e=p(m,t[0]),r=p(y,t[1]);if(e>=0&&r>=0&&e!==r){var n=T[e],i=T[r];n!==i&&z.push([n,i])}}),o.unique(o.normalize(z)),{positions:C,edges:z}}e.exports=i;var a=t("robust-orientation"),o=t("simplicial-complex")},{"robust-orientation":218,"simplicial-complex":297}],299:[function(t,e,r){"use strict";e.exports=["",{ -path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],300:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:o({},i,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":373,"../../plots/cartesian/constants":404,"../../plots/font_attributes":417,"./arrow_paths":299}],301:[function(t,e,r){"use strict";function n(t,e){function r(e,r){return c.coerce(t,n,v.layoutAttributes,e,r)}var n={};r("opacity"),r("align"),r("bgcolor");var i=r("bordercolor"),a=f.opacity(i);r("borderpad");var o=r("borderwidth"),s=r("showarrow");s&&(r("arrowcolor",a?n.bordercolor:f.defaultLine),r("arrowhead"),r("arrowsize"),r("arrowwidth",2*(a&&o||1)),r("ax"),r("ay"),c.noneOrAll(t,n,["ax","ay"])),r("text",s?" ":"new text"),r("textangle"),c.coerceFont(r,"font",e.font);for(var l=["x","y"],h=0;2>h;h++){var d=l[h],p={_fullLayout:e},g=u.coerceRef(t,n,p,d),m=.5;if("paper"!==g){var y=u.getFromId(p,g);if(m=y.range[0]+m*(y.range[1]-y.range[0]),-1!==["date","category"].indexOf(y.type)&&"string"==typeof t[d]){var b;"date"===y.type?(b=c.dateTime2ms(t[d]),b!==!1&&(t[d]=b)):(y._categories||[]).length&&(b=y._categories.indexOf(t[d]),-1!==b&&(t[d]=b))}}r(d,m),s||r(d+"anchor")}return c.noneOrAll(t,n,["x","y"]),n}function i(t){var e=t._fullLayout;e.annotations.forEach(function(e){var r=u.getFromId(t,e.xref),n=u.getFromId(t,e.yref);if(r||n){var i=(e._xsize||0)/2,a=e._xshift||0,o=(e._ysize||0)/2,s=e._yshift||0,l=i-a,c=i+a,f=o-s,h=o+s;if(e.showarrow){var d=3*e.arrowsize*e.arrowwidth;l=Math.max(l,d),c=Math.max(c,d),f=Math.max(f,d),h=Math.max(h,d)}r&&r.autorange&&u.expand(r,[r.l2c(e.x)],{ppadplus:c,ppadminus:l}),n&&n.autorange&&u.expand(n,[n.l2c(e.y)],{ppadplus:h,ppadminus:f})}})}function a(t,e,r,n,i,a,o,s){var l=r-t,c=i-t,u=o-i,f=n-e,h=a-e,d=s-a,p=l*d-u*f;if(0===p)return null;var g=(c*d-u*h)/p,v=(c*f-l*h)/p;return 0>v||v>1||0>g||g>1?null:{x:t+l*g,y:e+f*g}}var o=t("d3"),s=t("fast-isnumeric"),l=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),h=t("../drawing"),d=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var r=t.annotations||[],i=e.annotations=[],a=0;at?"left":t>2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var n=W.select(".annotation-math-group"),i=!n.empty(),s=h.bBox((i?n:tt).node()),d=s.width,m=s.height,y=Math.round(d+2*Q),b=Math.round(m+2*Q);U._w=d,U._h=m;var x=!1;if(["x","y"].forEach(function(e){var n,i=u.getFromId(t,U[e+"ref"]||e),a=(G+("x"===e?0:90))*Math.PI/180,o=y*Math.abs(Math.cos(a))+b*Math.abs(Math.sin(a)),s=U[e+"anchor"];if(i){if(!i.autorange&&(U[e]-i.range[0])*(U[e]-i.range[1])>0)return void(x=!0);H[e]=i._offset+i.l2p(U[e]),n=.5}else n=U[e],"y"===e&&(n=1-n),H[e]="x"===e?S.l+S.w*n:S.t+S.h*n;var l=0;l=U.showarrow?U["a"+e]:o*r(n,s),H[e]+=l,U["_"+e+"type"]=i&&i.type,U["_"+e+"size"]=o,U["_"+e+"shift"]=l}),x)return void W.remove();var w,k;U.showarrow&&(w=c.constrain(H.x-U.ax,1,_.width-1),k=c.constrain(H.y-U.ay,1,_.height-1)),H.x=c.constrain(H.x,1,_.width-1),H.y=c.constrain(H.y,1,_.height-1);var A=Q-s.top,M=Q-s.left;i?n.select("svg").attr({x:Q-1,y:Q}):(tt.attr({x:M,y:A}),tt.selectAll("tspan.line").attr({y:A,x:M})),$.call(h.setRect,Z/2,Z/2,y-Z,b-Z);var T=Math.round(H.x-y/2),E=Math.round(H.y-b/2);W.attr("transform","translate("+T+", "+E+")");var L="annotations["+e+"]",C=function(r,n){o.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var i=H.x+r,s=H.y+n,u=c.rotationXYMatrix(G,i,s),d=c.apply2DTransform(u),p=c.apply2DTransform2(u),m=$.attr("width")/2,y=$.attr("height")/2,b=[[i-m,s-y,i-m,s+y],[i-m,s+y,i+m,s+y],[i+m,s+y,i+m,s-y],[i+m,s-y,i-m,s-y]].map(p);if(!b.reduce(function(t,e){return t^!!a(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){b.forEach(function(t){var e=a(i,s,w,k,t[0],t[1],t[2],t[3]);e&&(i=e.x,s=e.y)});var x=U.arrowwidth,_=U.arrowcolor,A=Y.append("g").style({opacity:f.opacity(_)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),M=A.append("path").attr("d","M"+i+","+s+"L"+w+","+k).style("stroke-width",x+"px").call(f.stroke,f.rgb(_));v.arrowhead(M,U.arrowhead,"end",U.arrowsize);var T=A.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(i-w)+","+(s-k),transform:"translate("+w+","+k+")"}).style("stroke-width",x+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var E,C,z;g.init({element:T.node(),prepFn:function(){C=Number(W.attr("x")),z=Number(W.attr("y")),E={},V&&V.autorange&&(E[V._name+".autorange"]=!0),q&&q.autorange&&(E[q._name+".autorange"]=!0)},moveFn:function(t,e){A.attr("transform","translate("+t+","+e+")");var r=d(C,z),n=r[0]+t,i=r[1]+e;W.call(h.setPosition,n,i),E[L+".x"]=V?U.x+t/V._m:(w+t-S.l)/S.w,E[L+".y"]=q?U.y+e/q._m:1-(k+e-S.t)/S.h,X.attr({transform:"rotate("+G+","+n+","+i+")"})},doneFn:function(e){if(e){l.relayout(t,E);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}};U.showarrow&&C(0,0);var z=c.rotationXYMatrix(G,H.x,H.y),P=c.apply2DTransform(z);if(t._context.editable){var R,O,I;g.init({element:W.node(),prepFn:function(){R=Number(W.attr("x")),O=Number(W.attr("y")),I={}},moveFn:function(t,e){W.call(h.setPosition,R+t,O+e);var r="pointer";if(U.showarrow)I[L+".ax"]=U.ax+t,I[L+".ay"]=U.ay+e,C(t,e);else{if(V)I[L+".x"]=U.x+t/V._m;else{var n=U._xsize/S.w,i=U.x+U._xshift/S.w-n/2;I[L+".x"]=g.align(i+t/S.w,n,0,1,U.xanchor)}if(q)I[L+".y"]=U.y+e/q._m;else{var a=U._ysize/S.h,o=U.y-U._yshift/S.h-a/2;I[L+".y"]=g.align(o-e/S.h,a,0,1,U.yanchor)}V&&q||(r=g.cursor(V?.5:I[L+".x"],q?.5:I[L+".y"],U.xanchor,U.yanchor))}var s=P(R,O),l=s[0]+t,c=s[1]+e;W.call(h.setPosition,l,c),X.attr({transform:"rotate("+G+","+l+","+c+")"}),p(W,r)},doneFn:function(e){if(p(W),e){l.relayout(t,I);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}var b,x=t.layout,_=t._fullLayout;if(!s(e)||-1===e){if(!e&&Array.isArray(i))return x.annotations=i,v.supplyLayoutDefaults(x,_),void v.drawAll(t);if("remove"===i)return delete x.annotations,_.annotations=[],void v.drawAll(t);if(r&&"add"!==i){for(b=0;b<_.annotations.length;b++)v.draw(t,b,r,i);return}e=_.annotations.length,_.annotations.push({})}if(!r&&i){if("remove"===i){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),x.annotations.splice(e,1),b=e;b<_.annotations.length;b++)_._infolayer.selectAll('.annotation[data-index="'+(b+1)+'"]').attr("data-index",String(b)),v.draw(t,b);return}if("add"===i||c.isPlainObject(i)){_.annotations.splice(e,0,{});var w=c.isPlainObject(i)?c.extendFlat({},i):{text:"New text"};for(x.annotations?x.annotations.splice(e,0,w):x.annotations=[w],b=_.annotations.length-1;b>e;b--)_._infolayer.selectAll('.annotation[data-index="'+(b-1)+'"]').attr("data-index",String(b)),v.draw(t,b)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=x.annotations[e],A=_.annotations[e];if(k){var M={xref:k.xref,yref:k.yref},T={};"string"==typeof r&&r?T[r]=i:c.isPlainObject(r)&&(T=r);var E=Object.keys(T);for(b=0;bb;b++){var z=C[b];if(void 0===T[z]&&void 0!==k[z]){var P=u.getFromId(t,u.coerceRef(M,{},t,z)),R=u.getFromId(t,u.coerceRef(k,{},t,z)),O=k[z],I=A["_"+z+"type"];if(void 0!==T[z+"ref"]){var N="auto"===k[z+"anchor"],j="x"===z?S.w:S.h,F=(A["_"+z+"size"]||0)/(2*j);if(P&&R)O=(O-P.range[0])/(P.range[1]-P.range[0]),O=R.range[0]+O*(R.range[1]-R.range[0]);else if(P){if(O=(O-P.range[0])/(P.range[1]-P.range[0]),O=P.domain[0]+O*(P.domain[1]-P.domain[0]),N){var D=O+F,B=O-F;2/3>O+B?O=B:O+D>4/3&&(O=D)}}else R&&(N&&(1/3>O?O+=F:O>2/3&&(O-=F)),O=(O-R.domain[0])/(R.domain[1]-R.domain[0]),O=R.range[0]+O*(R.range[1]-R.range[0]))}R&&R===P&&I&&("log"===I&&"log"!==R.type?O=Math.pow(10,O):"log"!==I&&"log"===R.type&&(O=O>0?Math.log(O)/Math.LN10:void 0)),k[z]=O}}var U=n(k,_);_.annotations[e]=U;var V=u.getFromId(t,U.xref),q=u.getFromId(t,U.yref),H={x:0,y:0},G=+U.textangle||0,Y=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",U.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:U})}),X=Y.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),W=X.append("g"),Z=U.borderwidth,K=U.borderpad,Q=Z+K,$=W.append("rect").attr("class","bg").style("stroke-width",Z+"px").call(f.stroke,U.bordercolor).call(f.fill,U.bgcolor),J=U.font,tt=W.append("text").classed("annotation",!0).attr("data-unformatted",U.text).text(U.text);t._context.editable?tt.call(d.makeEditable,W).call(m).on("edit",function(r){U.text=r,this.attr({"data-unformatted":U.text}),this.call(m);var n={};n["annotations["+e+"].text"]=U.text,V&&V.autorange&&(n[V._name+".autorange"]=!0),q&&q.autorange&&(n[q._name+".autorange"]=!0),l.relayout(t,n)}):tt.call(m),X.attr({transform:"rotate("+G+","+H.x+","+H.y+")"}).call(h.setPosition,H.x,H.y)}},v.arrowhead=function(t,e,r,n){s(n)||(n=1);var i=t.node(),a=v.ARROWPATHS[e||0];if(a){"string"==typeof r&&r||(r="end");var l,c,u,d,p=(h.getPx(t,"stroke-width")||1)*n,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=r.indexOf("start")>=0,b=r.indexOf("end")>=0,x=a.backoff*p;if("line"===i.nodeName){if(l={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(l.y-c.y,l.x-c.x),d=u+Math.PI,x){var _=x*Math.cos(u),w=x*Math.sin(u);y&&(l.x-=_,l.y-=w,t.attr({x1:l.x,y1:l.y})),b&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===i.nodeName){var k=i.getTotalLength(),A="";if(y){var M=i.getPointAtLength(0),T=i.getPointAtLength(.1);u=Math.atan2(M.y-T.y,M.x-T.x),l=i.getPointAtLength(Math.min(x,k)),x&&(A="0px,"+x+"px,")}if(b){var E=i.getPointAtLength(k),L=i.getPointAtLength(k-.1);if(d=Math.atan2(E.y-L.y,E.x-L.x),c=i.getPointAtLength(Math.max(0,k-x)),x){var S=A?2*x:x;A+=k-S+"px,"+k+"px"}}else A&&(A+=k+"px");A&&t.style("stroke-dasharray",A)}var C=function(r,n){e>5&&(n=0),o.select(i.parentElement).append("path").attr({"class":t.attr("class"),d:a.path,transform:"translate("+r.x+","+r.y+")rotate("+180*n/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(l,u),b&&C(c,d)}},v.calcAutorange=function(t){var e=t._fullLayout,r=e.annotations;if(r.length&&t._fullData.length){var n={};r.forEach(function(t){n[t.xref]=!0,n[t.yref]=!0});var a=u.list(t).filter(function(t){return t.autorange&&n[t._id]});if(a.length)return c.syncOrAsync([v.drawAll,i],t)}}},{"../../lib":378,"../../lib/setcursor":386,"../../lib/svg_text_utils":390,"../../plotly":396,"../../plots/cartesian/axes":399,"../color":303,"../dragelement":323,"../drawing":325,"./arrow_paths":299,"./attributes":300,d3:72,"fast-isnumeric":76}],302:[function(t,e,r){"use strict";r.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],r.defaultLine="#444",r.lightLine="#eee",r.background="#fff",r.lightFraction=1e3/11},{}],303:[function(t,e,r){"use strict";function n(t){if(a(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var r=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!r)return t;var n=r[1].trim().split(/\s*[\s,]\s*/),i="a"===e.charAt(3)&&4===n.length;if(!i&&3!==n.length)return t;for(var o=0;o=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}var i=t("tinycolor2"),a=t("fast-isnumeric"),o=e.exports={},s=t("./attributes");o.defaults=s.defaults,o.defaultLine=s.defaultLine,o.lightLine=s.lightLine,o.background=s.background,o.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},o.rgb=function(t){return o.tinyRGB(i(t))},o.opacity=function(t){return t?i(t).getAlpha():0},o.addOpacity=function(t,e){var r=i(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},o.combine=function(t,e){var r=i(t).toRgb();if(1===r.a)return i(t).toRgbString();var n=i(e||o.background).toRgb(),a=1===n.a?n:{r:255*(1-n.a)+n.r*n.a,g:255*(1-n.a)+n.g*n.a,b:255*(1-n.a)+n.b*n.a},s={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return i(s).toRgbString()},o.stroke=function(t,e){var r=i(e);t.style({stroke:o.tinyRGB(r),"stroke-opacity":r.getAlpha()})},o.fill=function(t,e){var r=i(e);t.style({fill:o.tinyRGB(r),"fill-opacity":r.getAlpha()})},o.clean=function(t){if(t&&"object"==typeof t){var e,r,i,a,s=Object.keys(t);for(e=0;el&&(a[1]-=(ot-l)/2)):r.node()&&!r.classed("js-placeholder")&&(ot=h.bBox(e.node()).height),ot){if(ot+=5,"top"===x.titleside)$.domain[1]-=ot/M.h,a[1]*=-1;else{$.domain[0]+=ot/M.h;var u=Math.max(1,r.selectAll("tspan.line").size());a[1]+=(1-u)*l}e.attr("transform","translate("+a+")"),$.setScale()}}it.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(M.h*(1-$.domain[1]))+")");var f=it.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var r=[0===e?E[0]:(S[e]+S[e-1])/2,e===S.length-1?E[1]:(S[e]+S[e+1])/2].map($.c2p).map(Math.round);e!==S.length-1&&(r[1]+=r[1]>r[0]?1:-1);var a=z(t).replace("e-",""),o=i(a).toHexString();n.select(this).attr({x:Y,width:Math.max(D,2),y:n.min(r),height:Math.max(n.max(r)-n.min(r),2),fill:o})});var d=it.select(".cblines").selectAll("path.cbline").data(x.line.color&&x.line.width?L:[]);return d.enter().append("path").classed("cbline",!0),d.exit().remove(),d.each(function(t){n.select(this).attr("d","M"+Y+","+(Math.round($.c2p(t))+x.line.width/2%1)+"h"+D).call(h.lineGroupStyle,x.line.width,C(t),x.line.dash)}),$._axislayer.selectAll("g."+$._id+"tick,path").remove(),$._pos=Y+D+(x.outlinewidth||0)/2-("outside"===x.ticks?1:0),$.side="right",c.syncOrAsync([function(){return s.doTicks(t,$,!0)},function(){if(-1===["top","bottom"].indexOf(x.titleside)){var e=$.titlefont.size,r=$._offset+$._length/2,i=M.l+($.position||0)*M.w+("right"===$.side?10+e*($.showticklabels?1:.5):-10-e*($.showticklabels?.5:0));w("h"+$._id+"title",{avoid:{selection:n.select(t).selectAll("g."+$._id+"tick"),side:x.titleside,offsetLeft:M.l,offsetTop:M.t,maxShift:A.width},attributes:{x:i,y:r,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,r){var n,i=b();n=o.traceIs(i,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var a={propContainer:$,propName:n,traceIndex:i.index,dfltName:"colorscale",containerGroup:it.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;it.selectAll("."+s+",."+s+"-math-group").remove(),p.draw(t,e,u(a,r||{}))}function k(){var r=D+x.outlinewidth/2+h.bBox($._axislayer.node()).width;if(N=at.select("text"),N.node()&&!N.classed("js-placeholder")){var n,i=at.select(".h"+$._id+"title-math-group").node();n=i&&-1!==["top","bottom"].indexOf(x.titleside)?h.bBox(i).width:h.bBox(at.node()).right-Y-M.l,r=Math.max(r,n)}var a=2*x.xpad+r+x.borderwidth+x.outlinewidth/2,s=Z-K;it.select(".cbbg").attr({x:Y-x.xpad-(x.borderwidth+x.outlinewidth)/2,y:K-H,width:Math.max(a,2),height:Math.max(s+2*H,2)}).call(d.fill,x.bgcolor).call(d.stroke,x.bordercolor).style({"stroke-width":x.borderwidth}),it.selectAll(".cboutline").attr({x:Y,y:K+x.ypad+("top"===x.titleside?ot:0),width:Math.max(D,2),height:Math.max(s-2*x.ypad-ot,2)}).call(d.stroke,x.outlinecolor).style({fill:"None","stroke-width":x.outlinewidth});var l=({center:.5,right:1}[x.xanchor]||0)*a;it.attr("transform","translate("+(M.l-l)+","+M.t+")"),o.autoMargin(t,e,{x:x.x,y:x.y,l:a*({right:1,center:.5}[x.xanchor]||0),r:a*({left:1,center:.5}[x.xanchor]||0),t:s*({bottom:1,middle:.5}[x.yanchor]||0),b:s*({top:1,middle:.5}[x.yanchor]||0)})}var A=t._fullLayout,M=A._size;if("function"!=typeof x.fillcolor&&"function"!=typeof x.line.color)return void A._infolayer.selectAll("g."+e).remove();var T,E=n.extent(("function"==typeof x.fillcolor?x.fillcolor:x.line.color).domain()),L=[],S=[],C="function"==typeof x.line.color?x.line.color:function(){return x.line.color},z="function"==typeof x.fillcolor?x.fillcolor:function(){return x.fillcolor},P=x.levels.end+x.levels.size/100,R=x.levels.size,O=1.001*E[0]-.001*E[1],I=1.001*E[1]-.001*E[0];for(T=x.levels.start;0>(T-P)*R;T+=R)T>O&&I>T&&L.push(T);if("function"==typeof x.fillcolor)if(x.filllevels)for(P=x.filllevels.end+x.filllevels.size/100,R=x.filllevels.size,T=x.filllevels.start;0>(T-P)*R;T+=R)T>E[0]&&T1){var nt=Math.pow(10,Math.floor(Math.log(rt)/Math.LN10));tt*=nt*c.roundUp(rt/nt,[2,5,10]),(Math.abs(x.levels.start)/x.levels.size+1e-6)%1<2e-6&&($.tick0=0)}$.dtick=tt}$.domain=[W+G,W+V-G],$.setScale();var it=A._infolayer.selectAll("g."+e).data([0]);it.enter().append("g").classed(e,!0).each(function(){var t=n.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),it.attr("transform","translate("+Math.round(M.l)+","+Math.round(M.t)+")");var at=it.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(M.l)+",-"+Math.round(M.t)+")");$._axislayer=it.select(".cbaxis");var ot=0;if(-1!==["top","bottom"].indexOf(x.titleside)){var st,lt=M.l+(x.x+q)*M.w,ct=$.titlefont.size;st="top"===x.titleside?(1-(W+V-G))*M.h+M.t+3+.75*ct:(1-(W+G))*M.h+M.t-3-.25*ct,w($._id+"title",{attributes:{x:lt,y:st,"text-anchor":"start"}})}var ut=c.syncOrAsync([o.previousPromises,_,o.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,ht,dt;l.init({element:it.node(),prepFn:function(){ft=it.attr("transform"),f(it)},moveFn:function(t,e){it.attr("transform",ft+" translate("+t+","+e+")"),ht=l.align(X+t/M.w,B,0,1,x.xanchor),dt=l.align(W-e/M.h,V,0,1,x.yanchor);var r=l.getCursor(ht,dt,x.xanchor,x.yanchor);f(it,r)},doneFn:function(e){f(it),e&&void 0!==ht&&void 0!==dt&&a.restyle(t,{"colorbar.x":ht,"colorbar.y":dt},b().index)}})}return ut}function b(){var r,n,i=e.substr(2);for(r=0;ru*f?i.RdBu:u>=0?i.Reds:i.Blues,l.colorscale=h,s.reversescale&&(h=a(h)),s.colorscale=h)}},{"../../lib":378,"./flip_scale":313,"./scales":320}],311:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":320}],312:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,c,u){var f=u.prefix,h=u.cLetter,d=f.slice(0,f.length-1),p=f?i.nestedProperty(t,d).get()||{}:t,g=f?i.nestedProperty(e,d).get()||{}:e,v=p[h+"min"],m=p[h+"max"],y=p.colorscale,b=n(v)&&n(m)&&m>v;c(f+h+"auto",!b),c(f+h+"min"),c(f+h+"max");var x;void 0!==y&&(x=!s(y)),c(f+"autocolorscale",x);var _=c(f+"colorscale"),w=c(f+"reversescale");if(w&&(g.colorscale=l(_)),"marker.line."!==f){var k;f&&(k=a(p));var A=c(f+"showscale",k);A&&o(p,g,r)}}},{"../../lib":378,"../colorbar/defaults":305,"../colorbar/has_colorbar":307,"./flip_scale":313,"./is_valid_scale":317,"fast-isnumeric":76}],313:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=t.length,n=new Array(r),i=r-1,a=0;i>=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],314:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return e||(e=i),t?("string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e):e}},{"./default_scale":311,"./is_valid_scale_array":318,"./scales":320}],315:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(Array.isArray(o))for(var l=0;lh;h++)l=t[h],u[h]=e+l[0]*(r-e),f[h]=i(l[1]).toRgb();var d=n.scale.linear().domain(u).interpolate(n.interpolateObject).range(f);return function(t){if(a(t)){var n=o.constrain(t,e,r),l=d(n);return i(l).toRgbString()}return i(t).isValid()?t:s.defaultLine}}},{"../../lib":378,"../color":303,d3:72,"fast-isnumeric":76,tinycolor2:233}],320:[function(t,e,r){"use strict";e.exports={Greys:[[0,"rgb(0,0,0)"],[1,"rgb(255,255,255)"]],YlGnBu:[[0,"rgb(8,29,88)"],[.125,"rgb(37,52,148)"],[.25,"rgb(34,94,168)"],[.375,"rgb(29,145,192)"],[.5,"rgb(65,182,196)"],[.625,"rgb(127,205,187)"],[.75,"rgb(199,233,180)"],[.875,"rgb(237,248,217)"],[1,"rgb(255,255,217)"]],Greens:[[0,"rgb(0,68,27)"],[.125,"rgb(0,109,44)"],[.25,"rgb(35,139,69)"],[.375,"rgb(65,171,93)"],[.5,"rgb(116,196,118)"],[.625,"rgb(161,217,155)"],[.75,"rgb(199,233,192)"],[.875,"rgb(229,245,224)"],[1,"rgb(247,252,245)"]],YlOrRd:[[0,"rgb(128,0,38)"],[.125,"rgb(189,0,38)"],[.25,"rgb(227,26,28)"],[.375,"rgb(252,78,42)"],[.5,"rgb(253,141,60)"],[.625,"rgb(254,178,76)"],[.75,"rgb(254,217,118)"],[.875,"rgb(255,237,160)"],[1,"rgb(255,255,204)"]], -Bluered:[[0,"rgb(0,0,255)"],[1,"rgb(255,0,0)"]],RdBu:[[0,"rgb(5,10,172)"],[.35,"rgb(106,137,247)"],[.5,"rgb(190,190,190)"],[.6,"rgb(220,170,132)"],[.7,"rgb(230,145,90)"],[1,"rgb(178,10,28)"]],Reds:[[0,"rgb(220,220,220)"],[.2,"rgb(245,195,157)"],[.4,"rgb(245,160,105)"],[1,"rgb(178,10,28)"]],Blues:[[0,"rgb(5,10,172)"],[.35,"rgb(40,60,190)"],[.5,"rgb(70,100,245)"],[.6,"rgb(90,120,245)"],[.7,"rgb(106,137,247)"],[1,"rgb(220,220,220)"]],Picnic:[[0,"rgb(0,0,255)"],[.1,"rgb(51,153,255)"],[.2,"rgb(102,204,255)"],[.3,"rgb(153,204,255)"],[.4,"rgb(204,204,255)"],[.5,"rgb(255,255,255)"],[.6,"rgb(255,204,255)"],[.7,"rgb(255,153,255)"],[.8,"rgb(255,102,204)"],[.9,"rgb(255,102,102)"],[1,"rgb(255,0,0)"]],Rainbow:[[0,"rgb(150,0,90)"],[.125,"rgb(0,0,200)"],[.25,"rgb(0,25,255)"],[.375,"rgb(0,152,255)"],[.5,"rgb(44,255,150)"],[.625,"rgb(151,255,0)"],[.75,"rgb(255,234,0)"],[.875,"rgb(255,111,0)"],[1,"rgb(255,0,0)"]],Portland:[[0,"rgb(12,51,131)"],[.25,"rgb(10,136,186)"],[.5,"rgb(242,211,56)"],[.75,"rgb(242,143,56)"],[1,"rgb(217,30,30)"]],Jet:[[0,"rgb(0,0,131)"],[.125,"rgb(0,60,170)"],[.375,"rgb(5,255,255)"],[.625,"rgb(255,255,0)"],[.875,"rgb(250,0,0)"],[1,"rgb(128,0,0)"]],Hot:[[0,"rgb(0,0,0)"],[.3,"rgb(230,0,0)"],[.6,"rgb(255,210,0)"],[1,"rgb(255,255,255)"]],Blackbody:[[0,"rgb(0,0,0)"],[.2,"rgb(230,0,0)"],[.4,"rgb(230,210,0)"],[.7,"rgb(255,255,255)"],[1,"rgb(160,200,255)"]],Earth:[[0,"rgb(0,0,130)"],[.1,"rgb(0,180,180)"],[.2,"rgb(40,210,40)"],[.4,"rgb(230,230,50)"],[.6,"rgb(120,70,20)"],[1,"rgb(255,255,255)"]],Electric:[[0,"rgb(0,0,0)"],[.15,"rgb(30,0,100)"],[.4,"rgb(120,0,100)"],[.6,"rgb(160,90,0)"],[.8,"rgb(230,200,0)"],[1,"rgb(255,250,220)"]],Viridis:[[0,"#440154"],[.06274509803921569,"#48186a"],[.12549019607843137,"#472d7b"],[.18823529411764706,"#424086"],[.25098039215686274,"#3b528b"],[.3137254901960784,"#33638d"],[.3764705882352941,"#2c728e"],[.4392156862745098,"#26828e"],[.5019607843137255,"#21918c"],[.5647058823529412,"#1fa088"],[.6274509803921569,"#28ae80"],[.6901960784313725,"#3fbc73"],[.7529411764705882,"#5ec962"],[.8156862745098039,"#84d44b"],[.8784313725490196,"#addc30"],[.9411764705882353,"#d8e219"],[1,"#fde725"]]}},{}],321:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i){var a=(t-r)/(n-r),o=a+e/(n-r),s=(a+o)/2;return"left"===i||"bottom"===i?a:"center"===i||"middle"===i?s:"right"===i||"top"===i?o:2/3-s>a?a:o>4/3-s?o:s}},{}],322:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":378}],323:[function(t,e,r){"use strict";function n(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function i(t){t._dragging=!1,t._replotPending&&a.plot(t)}var a=t("../../plotly"),o=t("../../lib"),s=t("../../plots/cartesian/constants"),l=e.exports={};l.align=t("./align"),l.getCursor=t("./cursor");var c=t("./unhover");l.unhover=c.wrapped,l.unhoverRaw=c.raw,l.init=function(t){function e(e){return p._dragged=!1,p._dragging=!0,c=e.clientX,u=e.clientY,d=e.target,f=(new Date).getTime(),f-p._mouseDownTimev&&(g=Math.max(g-1,1)),t.doneFn&&t.doneFn(p._dragged,g),!p._dragged){var r=document.createEvent("MouseEvents");r.initEvent("click",!0,!0),d.dispatchEvent(r)}return i(p),p._dragged=!1,o.pauseEvent(e)}var c,u,f,h,d,p=o.getPlotDiv(t.element)||{},g=1,v=s.DBLCLICKDELAY;p._mouseDownTime||(p._mouseDownTime=0),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":378,"../../plotly":396,"../../plots/cartesian/constants":404,"./align":321,"./cursor":322,"./unhover":324}],324:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=e.exports={};i.wrapped=function(t,e,r){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),i.raw(t,e,r)},i.raw=function(t,e){var r=t._fullLayout;e||(e={}),e.target&&n.triggerHandler(t,"plotly_beforehover",e)===!1||(r._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":372}],325:[function(t,e,r){"use strict";function n(t,e,r,n){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],c=Math.pow(a*a+o*o,x/2),u=Math.pow(s*s+l*l,x/2),f=(u*u*a-c*c*s)*n,h=(u*u*o-c*c*l)*n,d=3*u*(c+u),p=3*c*(c+u);return[[i.round(e[0]+(d&&f/d),2),i.round(e[1]+(d&&h/d),2)],[i.round(e[0]-(p&&f/p),2),i.round(e[1]-(p&&h/p),2)]]}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../plots/plots"),s=t("../color"),l=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../traces/scatter/subtypes"),d=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,r,n){e&&e.family&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},p.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},p.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},p.setRect=function(t,e,r,n,i){t.call(p.setPosition,e,r).call(p.setSize,n,i)},p.translatePoints=function(t,e,r){t.each(function(t){var n=t.xp||e.c2p(t.x),o=t.yp||r.c2p(t.y),s=i.select(this);a(n)&&a(o)?"text"===this.nodeName?s.attr("x",n).attr("y",o):s.attr("transform","translate("+n+","+o+")"):s.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:1>e?1:Math.round(e):r||0},p.lineGroupStyle=function(t,e,r,n){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=n||a.dash||"";i.select(this).call(s.stroke,r||a.color).call(p.dashLine,l,o)})},p.dashLine=function(t,e,r){var n=Math.max(r,3);"solid"===e?e="":"dot"===e?e=n+"px,"+n+"px":"dash"===e?e=3*n+"px,"+3*n+"px":"longdash"===e?e=5*n+"px,"+5*n+"px":"dashdot"===e?e=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===e&&(e=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var r=i.select(this);try{r.call(s.fill,e[0].trace.fillcolor)}catch(n){console.log(n,t),r.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var r=e.marker,n=r.line;if(o.traceIs(e,"symbols")){var a=d(e);t.attr("d",function(t){var n;n="various"===t.ms||"various"===r.size?3:h.isBubble(e)?a(t.ms):(r.size||6)/2,t.mrc=n;var i=p.symbolNumber(t.mx||r.symbol)||0,o=i%100;return t.om=i%200>=100,p.symbolFuncs[o](n)+(i>=200?m:"")}).style("opacity",function(t){return(t.mo+1||r.opacity+1)-1})}var l=(e._input||{}).marker||{},c=p.tryColorscale(r,l,""),u=p.tryColorscale(r,l,"line.");t.each(function(t){var e,a,o;t.so?(o=n.outlierwidth,a=n.outliercolor,e=r.outliercolor):(o=(t.mlw+1||n.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,a="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(n.color)?s.defaultLine:n.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(r.color)?s.defaultLine:r.color||"rgba(0,0,0,0)");var l=i.select(this);t.om?l.call(s.stroke,e).style({"stroke-width":(o||1)+"px",fill:"none"}):(l.style("stroke-width",o+"px").call(s.fill,e),o&&l.call(s.stroke,a))})}},p.tryColorscale=function(t,e,r){var n=c.nestedProperty(t,r+"color").get(),i=c.nestedProperty(t,r+"colorscale").get(),o=c.nestedProperty(t,r+"cauto").get(),s=c.nestedProperty(t,r+"cmin"),u=c.nestedProperty(t,r+"cmax"),f=s.get(),h=u.get();return i&&Array.isArray(n)?(!o&&a(f)&&a(h)||(f=1/0,h=-(1/0),n.forEach(function(t){a(t)&&(f>t&&(f=+t),t>h&&(h=+t))}),f>h&&(f=0,h=1),s.set(f),u.set(h),c.nestedProperty(e,r+"cmin").set(f),c.nestedProperty(e,r+"cmax").set(h)),l.makeScaleFunction(i,f,h)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},b=1.3;p.textPointStyle=function(t,e){t.each(function(t){var r=i.select(this),n=t.tx||e.text;if(!n||Array.isArray(n))return void r.remove();var o=t.tp||e.textposition,s=-1!==o.indexOf("top")?"top":-1!==o.indexOf("bottom")?"bottom":"middle",l=-1!==o.indexOf("left")?"end":-1!==o.indexOf("right")?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=a(c)&&c>0?c:0,r.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",l).text(n).call(u.convertToTspans);var h=i.select(this.parentNode),d=r.selectAll("tspan.line"),g=((d[0].length||1)-1)*b+1,v=y[l]*f,m=.75*c+y[s]*f+(y[s]-1)*g*c/2;h.attr("transform","translate("+v+","+m+")"),g>1&&d.attr({x:r.attr("x"),y:r.attr("y")})})};var x=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,i="M"+t[0],a=[];for(r=1;rr;r++)o.push(n(t[r-1],t[r],t[r+1],e));for(o.push(n(t[a-1],t[a],t[0],e)),r=1;a>=r;r++)i+="C"+o[r-1][1]+" "+o[r][0]+" "+t[r];return i+="C"+o[a][1]+" "+o[0][0]+" "+t[0]+"Z"};var _={hv:function(t,e){return"H"+i.round(e[0],2)+"V"+i.round(e[1],2)},vh:function(t,e){return"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},hvh:function(t,e){return"H"+i.round((t[0]+e[0])/2,2)+"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},vhv:function(t,e){return"V"+i.round((t[1]+e[1])/2,2)+"H"+i.round(e[0],2)+"V"+i.round(e[1],2)}},w=function(t,e){return"L"+i.round(e[0],2)+","+i.round(e[1],2)};p.steps=function(t){var e=_[t]||w;return function(t){for(var r="M"+i.round(t[0][0],2)+","+i.round(t[0][1],2),n=1;n=A&&(i.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(l),c.extendFlat({},l)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var r="#"+e,n=i.select("base");n.size()&&n.attr("href")&&(r=window.location.href+r),t.attr("clip-path","url("+r+")")}},{"../../constants/xmlns_namespaces":366,"../../lib":378,"../../lib/svg_text_utils":390,"../../plots/plots":447,"../../traces/scatter/make_bubble_size_func":559,"../../traces/scatter/subtypes":565,"../color":303,"../colorscale":316,"./symbol_defs":326,d3:72,"fast-isnumeric":76}],326:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+","+r+"H"+e+"L0,-"+i+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+",-"+r+"H"+e+"L0,"+i+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M"+r+",-"+e+"V"+e+"L-"+i+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+r+",-"+e+"V"+e+"L"+i+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(t*-.309,2),o=n.round(.809*t,2);return"M"+e+","+a+"L"+r+","+o+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(e*-.309,2),c=n.round(.118*e,2),u=n.round(.809*e,2),f=n.round(.382*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+c+"L"+o+","+u+"L0,"+f+"L-"+o+","+u+"L-"+a+","+c+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:72}],327:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],328:[function(t,e,r){"use strict";function n(t,e,r,n){var a=e["error_"+n]||{},l=a.visible&&-1!==["linear","log"].indexOf(r.type),c=[];if(l){for(var u=s(a),f=0;fs;s++)o[s]={x:r[s],y:i[s]};return o[0].trace=t,n.calc({calcdata:[o],_fullLayout:e}),o},n.plot=t("./plot"),n.style=t("./style"),n.hoverInfo=function(t,e,r){(e.error_y||{}).visible&&(r.yerr=t.yh-t.y,e.error_y.symmetric||(r.yerrneg=t.y-t.ys)),(e.error_x||{}).visible&&(r.xerr=t.xh-t.x,e.error_x.symmetric||(r.xerrneg=t.x-t.xs))}},{"./attributes":327,"./calc":328,"./defaults":330,"./plot":332,"./style":333}],332:[function(t,e,r){"use strict";function n(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};return void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0))),void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0))),n}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),s=t("../../traces/scatter/subtypes");e.exports=function(t,e){var r=e.x(),l=e.y();t.each(function(t){var e=t[0].trace,c=e.error_x||{},u=e.error_y||{},f=s.hasMarkers(e)&&e.marker.maxdisplayed>0;if(u.visible||c.visible){var h=i.select(this).selectAll("g.errorbar").data(o.identity);h.enter().append("g").classed("errorbar",!0),h.each(function(t){var e=i.select(this),o=n(t,r,l);if(!f||t.vis){var s;if(u.visible&&a(o.x)&&a(o.yh)&&a(o.ys)){var h=u.width;s="M"+(o.x-h)+","+o.yh+"h"+2*h+"m-"+h+",0V"+o.ys,o.noYS||(s+="m-"+h+",0h"+2*h),e.append("path").classed("yerror",!0).attr("d",s)}if(c.visible&&a(o.y)&&a(o.xh)&&a(o.xs)){var d=(c.copy_ystyle?u:c).width;s="M"+o.xh+","+(o.y-d)+"v"+2*d+"m0,-"+d+"H"+o.xs,o.noXS||(s+="m0,-"+d+"v"+2*d),e.append("path").classed("xerror",!0).attr("d",s)}}})}})}},{"../../lib":378,"../../traces/scatter/subtypes":565,d3:72,"fast-isnumeric":76}],333:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":303,d3:72}],334:[function(t,e,r){"use strict";r.isRightAnchor=function(t){return"right"===t.xanchor||"auto"===t.xanchor&&t.x>=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],335:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:a({},n,{}),traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":373,"../../plots/font_attributes":417,"../color/attributes":302}],336:[function(t,e,r){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],337:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/plots"),a=t("./attributes"),o=t("./helpers");e.exports=function(t,e,r){function s(t,e){return n.coerce(l,c,a,t,e)}for(var l=t.legend||{},c=e.legend={},u=0,f="normal",h=0;h1);p!==!1&&(s("bgcolor",e.paper_bgcolor),s("bordercolor"),s("borderwidth"),n.coerceFont(s,"font",e.font),s("traceorder",f),o.isGrouped(e.legend)&&s("tracegroupgap"),s("x"),s("xanchor"),s("y"),s("yanchor"),n.noneOrAll(l,c,["x","y"]))}},{"../../lib":378,"../../plots/plots":447,"./attributes":335,"./helpers":340}],338:[function(t,e,r){"use strict";function n(t,e,r,n,o){function c(t){l.util.convertToTspans(t,function(){e.firstRender&&(i(e,o),a(e))}),t.selectAll("tspan.line").attr({x:t.attr("x")})}var f=e._fullLayout,d=r[0].trace,p=u.traceIs(d,"pie"),g=d.index,v=p?r[0].label:d.name,m=s.select(t).selectAll("text.legendtext").data([0]);m.enter().append("text").classed("legendtext",!0),m.attr({x:40,y:0,"data-unformatted":v}).style("text-anchor","start").classed("user-select-none",!0).call(h.font,f.legend.font).text(v),e._context.editable&&!p?m.call(l.util.makeEditable).call(c).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(c),this.text()||(t=" "),l.restyle(e,"name",t,g)}):m.call(c)}function i(t,e){var r=t._fullLayout,n=r.legend,i=n.borderwidth;n.width=0,n.height=0,e.each(function(t){var e,r,a=t[0].trace,o=s.select(this),l=o.selectAll(".legendtoggle"),c=o.selectAll(".legendtext"),u=o.selectAll(".legendtext>tspan"),f=1.3*n.font.size,d=u[0].length||1,p=c.node()&&h.bBox(c.node()).width,g=o.select("g[class*=math-group]");if(!a.showlegend)return void o.remove();if(g.node()){var v=h.bBox(g.node());f=v.height,p=v.width,g.attr("transform","translate(0,"+f/4+")")}else e=f*(.3+(1-d)/2),c.attr("y",e),u.attr("y",e);r=Math.max(f*d,16)+3,o.attr("transform","translate("+i+","+(5+i+n.height+r/2)+")"),l.attr({x:0,y:-r/2,height:r}),n.height+=r,n.width=Math.max(n.width,p||0)}),n.width+=45+2*i,n.height+=10+2*i,m.isGrouped(n)&&(n.height+=(n._lgroupsLength-1)*n.tracegroupgap),e.selectAll(".legendtoggle").attr("width",(t._context.editable?0:n.width)+40),n.width=Math.ceil(n.width),n.height=Math.ceil(n.height)}function a(t){var e=t._fullLayout,r=e.legend,n="left";y.isRightAnchor(r)?n="right":y.isCenterAnchor(r)&&(n="center");var i="top";y.isBottomAnchor(r)?i="bottom":y.isMiddleAnchor(r)&&(i="middle"),u.autoMargin(t,"legend",{x:r.x,y:r.y,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:r.height*({top:1,middle:.5}[i]||0),t:r.height*({bottom:1,middle:.5}[i]||0)})}function o(t){var e=t._fullLayout,r=e.legend,n="left";y.isRightAnchor(r)?n="right":y.isCenterAnchor(r)&&(n="center"),u.autoMargin(t,"legend",{x:r.x,y:.5,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:0,t:0})}var s=t("d3"),l=t("../../plotly"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../dragelement"),h=t("../drawing"),d=t("../color"),p=t("./constants"),g=t("./get_legend_data"),v=t("./style"),m=t("./helpers"),y=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e),T.attr("transform","translate(0, "+e+")"),E.call(h.setRect,x.width,t,p.scrollBarWidth,p.scrollBarHeight),A.select("rect").attr({y:x.borderwidth-e})}var r=t._fullLayout,b="legend"+r._uid;if(r._infolayer&&t.calcdata){var x=r.legend,_=r.showlegend&&g(t.calcdata,x),w=r.hiddenlabels||[];if(!r.showlegend||!_.length)return r._infolayer.selectAll(".legend").remove(),r._topdefs.select("#"+b).remove(),void u.autoMargin(t,"legend");"undefined"==typeof t.firstRender?t.firstRender=!0:t.firstRender&&(t.firstRender=!1);var k=r._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({"class":"legend","pointer-events":"all"});var A=r._topdefs.selectAll("#"+b).data([0]);A.enter().append("clipPath").attr("id",b).append("rect");var M=k.selectAll("rect.bg").data([0]);M.enter().append("rect").attr({"class":"bg","shape-rendering":"crispEdges"}).call(d.stroke,x.bordercolor).call(d.fill,x.bgcolor).style("stroke-width",x.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var E=k.selectAll("rect.scrollbar").data([0]);E.enter().append("rect").attr({"class":"scrollbar",rx:20,ry:2,width:0,height:0}).call(d.fill,"#808BA4");var L=T.selectAll("g.groups").data(_);L.enter().append("g").attr("class","groups"),L.exit().remove(),m.isGrouped(x)&&L.attr("transform",function(t,e){return"translate(0,"+e*x.tracegroupgap+")"});var S=L.selectAll("g.traces").data(c.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(v).style("opacity",function(t){var e=t[0].trace;return u.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(e,r){n(this,t,e,r,S);var i=s.select(this).selectAll("rect").data([0]);i.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(d.fill,"rgba(0,0,0,0)"),i.on("click",function(){if(!t._dragged){var r,n,i=t._fullData,a=e[0].trace,o=a.legendgroup,s=[];if(u.traceIs(a,"pie")){var c=e[0].label,f=w.slice(),h=f.indexOf(c);-1===h?f.push(c):f.splice(h,1),l.relayout(t,"hiddenlabels",f)}else{if(""===o)s=[a.index];else for(var d=0;dz?o(t):a(t);var P=r._size,R=P.l+P.w*x.x,O=P.t+P.h*(1-x.y);y.isRightAnchor(x)?R-=x.width:y.isCenterAnchor(x)&&(R-=x.width/2),y.isBottomAnchor(x)?O-=x.height:y.isMiddleAnchor(x)&&(O-=x.height/2);var I=x.height,N=P.h;I>N?(O=P.t,I=N):(O>z&&(O=z-I),C>O&&(O=C),I=Math.min(z-O,x.height)),k.attr("transform","translate("+R+","+O+")"), -M.attr({width:x.width-x.borderwidth,height:I-x.borderwidth,x:x.borderwidth/2,y:x.borderwidth/2});var j=T.attr("data-scroll")||0;if(T.attr("transform","translate(0, "+j+")"),A.select("rect").attr({width:x.width-2*x.borderwidth,height:I-2*x.borderwidth,x:x.borderwidth-j,y:x.borderwidth}),T.call(h.setClipUrl,b),x.height-I>0&&!t._context.staticPlot){M.attr({width:x.width-2*x.borderwidth+p.scrollBarWidth+p.scrollBarMargin}),A.select("rect").attr({width:x.width-2*x.borderwidth+p.scrollBarWidth+p.scrollBarMargin}),t.firstRender&&e(p.scrollBarMargin,0);var F=I-p.scrollBarHeight-2*p.scrollBarMargin,D=x.height-I,B=p.scrollBarMargin,U=0;e(B,U),k.on("wheel",null),k.on("wheel",function(){U=c.constrain(T.attr("data-scroll")-s.event.deltaY/F*D,-D,0),B=p.scrollBarMargin-U/D*F,e(B,U),s.event.preventDefault()}),E.on(".drag",null),T.on(".drag",null);var V=s.behavior.drag().on("drag",function(){B=c.constrain(s.event.y-p.scrollBarHeight/2,p.scrollBarMargin,p.scrollBarMargin+F),U=-(B-p.scrollBarMargin)/F*D,e(B,U)});E.call(V),T.call(V)}if(t._context.editable){var q,H,G,Y;k.classed("cursor-move",!0),f.init({element:k.node(),prepFn:function(){var t=c.getTranslate(k);G=t.x,Y=t.y},moveFn:function(t,e){var r=G+t,n=Y+e,i="translate("+r+", "+n+")";k.attr("transform",i),q=f.align(r,0,P.l,P.l+P.w,x.xanchor),H=f.align(n,0,P.t+P.h,P.t,x.yanchor)},doneFn:function(e){e&&void 0!==q&&void 0!==H&&l.relayout(t,{"legend.x":q,"legend.y":H})}})}}}},{"../../lib":378,"../../plotly":396,"../../plots/plots":447,"../color":303,"../dragelement":323,"../drawing":325,"./anchor_utils":334,"./constants":336,"./get_legend_data":339,"./helpers":340,"./style":342,d3:72}],339:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("./helpers");e.exports=function(t,e){function r(t,r){if(""!==t&&i.isGrouped(e))-1===l.indexOf(t)?(l.push(t),c=!0,s[t]=[[r]]):s[t].push([r]);else{var n="~~i"+f;l.push(n),s[n]=[[r]],f++}}var a,o,s={},l=[],c=!1,u={},f=0;for(a=0;aa;a++)m=s[l[a]],y[a]=i.isReversed(e)?m.reverse():m;else{for(y=[new Array(b)],a=0;b>a;a++)m=s[l[a]][0],y[0][i.isReversed(e)?b-a-1:a]=m;b=1}return e._lgroupsLength=b,y}},{"../../plots/plots":447,"./helpers":340}],340:[function(t,e,r){"use strict";var n=t("../../plots/plots");r.legendGetsTrace=function(t){return t.visible&&n.traceIs(t,"showLegend")},r.isGrouped=function(t){return-1!==(t.traceorder||"").indexOf("grouped")},r.isReversed=function(t){return-1!==(t.traceorder||"").indexOf("reversed")}},{"../../plots/plots":447}],341:[function(t,e,r){"use strict";var n=e.exports={};n.layoutAttributes=t("./attributes"),n.supplyLayoutDefaults=t("./defaults"),n.draw=t("./draw"),n.style=t("./style")},{"./attributes":335,"./defaults":337,"./draw":338,"./style":342}],342:[function(t,e,r){"use strict";function n(t){var e=t[0].trace,r=e.visible&&e.fill&&"none"!==e.fill,n=d.hasLines(e),i=l.select(this).select(".legendfill").selectAll("path").data(r?[t]:[]);i.enter().append("path").classed("js-fill",!0),i.exit().remove(),i.attr("d","M5,0h30v6h-30z").call(f.fillGroupStyle);var a=l.select(this).select(".legendlines").selectAll("path").data(n?[t]:[]);a.enter().append("path").classed("js-line",!0).attr("d","M5,0h30"),a.exit().remove(),a.call(f.lineGroupStyle)}function i(t){function e(t,e,r){var n=c.nestedProperty(o,t).get(),i=Array.isArray(n)&&e?e(n):n;if(r){if(ir[1])return r[1]}return i}function r(t){return t[0]}var n,i,a=t[0],o=a.trace,s=d.hasMarkers(o),u=d.hasText(o),h=d.hasLines(o);if(s||u||h){var p={},g={};s&&(p.mc=e("marker.color",r),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",r),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),h&&(g.line={width:e("line.width",r,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",r),p.ts=10,p.tc=e("textfont.color",r),p.tf=e("textfont.family",r)),n=[c.minExtend(a,p)],i=c.minExtend(o,g)}var v=l.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(s?n:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,i),s&&(n[0].mrc=3);var y=v.selectAll("g.pointtext").data(u?n:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,i)}function a(t){var e=t[0].trace,r=e.marker||{},n=r.line||{},i=l.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);i.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),i.exit().remove(),i.each(function(t){var e=(t.mlw+1||n.width+1)-1,i=l.select(this);i.style("stroke-width",e+"px").call(h.fill,t.mc||r.color),e&&i.call(h.stroke,t.mlc||n.color)})}function o(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);r.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.each(function(t){var r=(t.lw+1||e.line.width+1)-1,n=l.select(this);n.style("stroke-width",r+"px").call(h.fill,t.fc||e.fillcolor),r&&n.call(h.stroke,t.lc||e.line.color)})}function s(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);r.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.size()&&r.call(p,t[0],e)}var l=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),h=t("../color"),d=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=l.select(this),r=e.selectAll("g.legendfill").data([t]);r.enter().append("g").classed("legendfill",!0);var n=e.selectAll("g.legendlines").data([t]);n.enter().append("g").classed("legendlines",!0);var i=e.selectAll("g.legendsymbols").data([t]);i.enter().append("g").classed("legendsymbols",!0),i.style("opacity",t[0].trace.opacity),i.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(a).each(o).each(s).each(n).each(i)}},{"../../lib":378,"../../plots/plots":447,"../../traces/pie/style_one":544,"../../traces/scatter/subtypes":565,"../color":303,"../drawing":325,d3:72}],343:[function(t,e,r){"use strict";function n(t,e){var r=e.currentTarget,n=r.getAttribute("data-attr"),i=r.getAttribute("data-val")||!0,a=t._fullLayout,o={};if("zoom"===n){for(var s,l,u="in"===i?.5:2,h=(1+u)/2,d=(1-u)/2,p=c.Axes.list(t,null,!0),v=0;vy;y++){var b=s[y];h=m[b]={};for(var x=0;x1)return n(["resetViews","toggleHover"]),o(v,r);u&&(n(["zoom3d","pan3d","orbitRotation","tableRotation"]),n(["resetCameraDefault3d","resetCameraLastSave3d"]),n(["hoverClosest3d"])),h&&(n(["zoomInGeo","zoomOutGeo","resetGeo"]),n(["hoverClosestGeo"]));var m=i(s),y=[];return((c||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(c||g)&&a(l)&&(y.push("select2d"),y.push("lasso2d")),y.length&&n(y),!c&&!p||m||g||n(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&d?n(["toggleHover"]):p?n(["hoverClosestGl2d"]):c?n(["hoverClosestCartesian","hoverCompareCartesian"]):d&&n(["hoverClosestPie"]),o(v,r)}function i(t){for(var e=l.Axes.list({_fullLayout:t},null,!0),r=!0,n=0;n0);if(h){var d=i(e,r,s);l("x",d[0]),l("y",d[1]),a.noneOrAll(t,e,["x","y"]),l("xanchor"),l("yanchor"),a.coerceFont(l,"font",r.font),l("bgcolor"),l("bordercolor"),l("borderwidth")}}},{"../../lib":378,"./attributes":346,"./button_attributes":347,"./constants":348}],350:[function(t,e,r){"use strict";function n(t){for(var e=m.list(t,"x",!0),r=[],n=0;nr){var i=r;r=e,e=i}s.setAttributes(x,{"data-min":e,"data-max":r}),s.setAttributes(z,{x:e,width:r-e}),s.setAttributes(k,{width:e}),s.setAttributes(A,{x:r,width:h-r}),s.setAttributes(M,{transform:"translate("+(e-p-1)+")"}),s.setAttributes(L,{transform:"translate("+r+")"});var o=f.range[0],l=f.range[1],c=l-o,u=e/h*c+o,d=r/h*c+o;window.requestAnimationFrame?window.requestAnimationFrame(function(){n.relayout(t,"xaxis.range",[u,d])}):setTimeout(function(){n.relayout(t,"xaxis.range",[u,d])},16)}var c=t._fullLayout,u=c._infolayer.selectAll("g.range-slider"),f=c.xaxis.rangeslider,h=c._size.w,d=(c.height-c.margin.b-c.margin.t)*f.thickness,p=2,g=Math.floor(f.borderwidth/2),v=c.margin.l,m=c.height-d-c.margin.b,y=0,b=h,x=document.createElementNS(o,"g");s.setAttributes(x,{"class":"range-slider","data-min":y,"data-max":b,"pointer-events":"all",transform:"translate("+v+","+m+")"});var _=document.createElementNS(o,"rect"),w=f.borderwidth%2===0?f.borderwidth:f.borderwidth-1;s.setAttributes(_,{fill:f.bgcolor,stroke:f.bordercolor,"stroke-width":f.borderwidth,height:d+w,width:h+w,transform:"translate(-"+g+", -"+g+")","shape-rendering":"crispEdges"});var k=document.createElementNS(o,"rect");s.setAttributes(k,{x:0,width:y,height:d,fill:"rgba(0,0,0,0.4)"});var A=document.createElementNS(o,"rect");s.setAttributes(A,{x:b,width:h-b,height:d,fill:"rgba(0,0,0,0.4)"});var M=document.createElementNS(o,"g"),T=document.createElementNS(o,"rect"),E=document.createElementNS(o,"rect");s.setAttributes(M,{transform:"translate("+(y-p-1)+")"}),s.setAttributes(T,{width:10,height:d,x:-6,fill:"transparent",cursor:"col-resize"}),s.setAttributes(E,{width:p,height:d/2,y:d/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(M,[E,T]);var L=document.createElementNS(o,"g"),S=document.createElementNS(o,"rect"),C=document.createElementNS(o,"rect");s.setAttributes(L,{transform:"translate("+b+")"}),s.setAttributes(S,{width:10,height:d,x:-2,fill:"transparent",cursor:"col-resize"}),s.setAttributes(C,{width:p,height:d/2,y:d/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(L,[C,S]);var z=document.createElementNS(o,"rect");s.setAttributes(z,{x:y,width:b-y,height:d,cursor:"ew-resize",fill:"transparent"}),x.addEventListener("mousedown",function(t){function e(t){var e=+t.clientX-a;switch(i){case z:x.style.cursor="ew-resize",r(+l+e,+s+e);break;case T:x.style.cursor="col-resize",r(+s+e,+l);break;case S:x.style.cursor="col-resize",r(+s,+l+e);break;default:x.style.cursor="ew-resize",r(o,o+e)}}function n(){window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",n),x.style.cursor="auto"}var i=t.target,a=t.clientX,o=a-x.getBoundingClientRect().left,s=x.getAttribute("data-min"),l=x.getAttribute("data-max");window.addEventListener("mousemove",e),window.addEventListener("mouseup",n)}),f.range||(f.range=i.getAutoRange(c.xaxis));var P=l(t,h,d);s.appendChildren(x,[_,P,k,A,z,M,L]),e(c.xaxis.range[0],c.xaxis.range[1]),u.data([0]).enter().append(function(){return f.setRange=e,x})}},{"../../constants/xmlns_namespaces":366,"../../lib":378,"../../plotly":396,"../../plots/cartesian/axes":399,"./helpers":356,"./range_plot":358}],355:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(t,e){return n.coerce(s,l,i,t,e)}if(t[r].rangeslider){var s="object"==typeof t[r].rangeslider?t[r].rangeslider:{},l=e[r].rangeslider={};if(o("bgcolor"),o("bordercolor"),o("borderwidth"),o("thickness"),o("visible"),o("range"),l.range&&!e[r].autorange){var c=l.range,u=e[r].range;c[0]=Math.min(c[0],u[0]),c[1]=Math.max(c[1],u[1])}else e[r]._needsExpand=!0;l.visible&&a.forEach(function(t){var r=e[t]||{};r.fixedrange=!0,e[t]=r})}}},{"../../lib":378,"./attributes":353}],356:[function(t,e,r){"use strict";r.setAttributes=function(t,e){for(var r in e)t.setAttribute(r,e[r])},r.appendChildren=function(t,e){for(var r=0;rl;l++){var c=s[l],u={_fullLayout:e},f=x.coerceRef(t,n,u,c);if("path"!==o){var h=.25,d=.75;if("paper"!==f){var p=x.getFromId(u,f),g=a(p);h=g(p.range[0]+h*(p.range[1]-p.range[0])),d=g(p.range[0]+d*(p.range[1]-p.range[0]))}r(c+"0",h),r(c+"1",d)}}return"path"===o?r("path"):b.noneOrAll(t,n,["x0","x1","y0","y1"]),n}function i(t){return"category"===t.type?t.c2l:t.d2l}function a(t){return"category"===t.type?t.l2c:t.l2d}function o(t,e){t.layout.shapes=e,k.supplyLayoutDefaults(t.layout,t._fullLayout),k.drawAll(t)}function s(t){delete t.layout.shapes,t._fullLayout.shapes=[],k.drawAll(t)}function l(t,e,r){for(var n=0;ne;i--)h(t,i).selectAll('[data-index="'+(i-1)+'"]').attr("data-index",i),k.draw(t,i)}function f(t,e,r,o){function s(e){var r=e.append("path").attr(z).style("opacity",S.opacity).call(_.stroke,P).call(_.fill,S.fillcolor).call(w.dashLine,S.line.dash,S.line.width);C&&r.call(w.setClipUrl,"clip"+t._fullLayout._uid+C)}var l,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},p={};"string"==typeof r&&r?p[r]=o:b.isPlainObject(r)&&(p=r);var v=Object.keys(p);for(l=0;ll;l++){var k=y[l];if(void 0===p[k]&&void 0!==u[k]){var A,M=k.charAt(0),T=x.getFromId(t,x.coerceRef(f,{},t,M)),E=x.getFromId(t,x.coerceRef(u,{},t,M)),L=u[k];void 0!==p[M+"ref"]&&(T?(A=i(T)(L),L=(A-T.range[0])/(T.range[1]-T.range[0])):L=(L-E.domain[0])/(E.domain[1]-E.domain[0]),E?(A=E.range[0]+L*(E.range[1]-E.range[0]),L=a(E)(A)):L=T.domain[0]+L*(T.domain[1]-T.domain[0])),u[k]=L}}var S=n(u,t._fullLayout);t._fullLayout.shapes[e]=S;var C,z={"data-index":e,"fill-rule":"evenodd",d:g(t,S)},P=S.line.width?S.line.color:"rgba(0,0,0,0)";if("below"!==S.layer)C=(S.xref+S.yref).replace(/paper/g,""),s(t._fullLayout._shapeUpperLayer);else if("paper"===S.xref&&"paper"===S.yref)C="",s(t._fullLayout._shapeLowerLayer);else{var R,O=t._fullLayout._plots||{},I=Object.keys(O);for(l=0,c=I.length;c>l;l++)R=O[I[l]],C=I[l],d(t,S,R.id)&&s(R.shapelayer)}}}function h(t,e){var r=t._fullLayout.shapes[e],n=t._fullLayout._shapeUpperLayer;return r?"below"===r.layer&&(n="paper"===r.xref&&"paper"===r.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._subplotShapeLayer):console.log("getShapeLayer: undefined shape: index",e),n}function d(t,e,r){var n=y.Axes.getFromId(t,r,"x")._id,i=y.Axes.getFromId(t,r,"y")._id;return"below"===e.layer&&(n===e.xref||i===e.yref)}function p(t){return function(e){return t(e.replace("_"," "))}}function g(t,e){var r,n,a,o,s=e.type,l=x.getFromId(t,e.xref),c=x.getFromId(t,e.yref),u=t._fullLayout._size;if(l?(r=i(l),n=function(t){return l._offset+l.l2p(r(t,!0))}):n=function(t){return u.l+u.w*t},c?(a=i(c),o=function(t){return c._offset+c.l2p(a(t,!0))}):o=function(t){return u.t+u.h*(1-t)},"path"===s)return l&&"date"===l.type&&(n=p(n)),c&&"date"===c.type&&(o=p(o)),k.convertPath(e.path,n,o);var f=n(e.x0),h=n(e.x1),d=o(e.y0),g=o(e.y1);if("line"===s)return"M"+f+","+d+"L"+h+","+g;if("rect"===s)return"M"+f+","+d+"H"+h+"V"+g+"H"+f+"Z";var v=(f+h)/2,m=(d+g)/2,y=Math.abs(v-f),b=Math.abs(m-d),_="A"+y+","+b,w=v+y+","+m,A=v+","+(m-b);return"M"+w+_+" 0 1,1 "+A+_+" 0 0,1 "+w+"Z"}function v(t,e,r,n,i){var a="category"===t.type?Number:t.d2c;if(void 0!==e)return[a(e),a(r)];if(n){var o,s,l,c,u,f=1/0,h=-(1/0),d=n.match(A);for("date"===t.type&&(a=p(a)),o=0;ou&&(f=u),u>h&&(h=u)));return h>=f?[f,h]:void 0}}var m=t("fast-isnumeric"),y=t("../../plotly"),b=t("../../lib"),x=t("../../plots/cartesian/axes"),_=t("../color"),w=t("../drawing"),k=e.exports={};k.layoutAttributes=t("./attributes"),k.supplyLayoutDefaults=function(t,e){for(var r=t.shapes||[],i=e.shapes=[],a=0;as&&(t="X"),t});return n>s&&(l=l.replace(/[\s,]*X.*/,""),console.log("ignoring extra params in segment "+t)),i+l})},k.calcAutorange=function(t){var e,r,n,i,a,o=t._fullLayout,s=o.shapes;if(s.length&&t._fullData.length)for(e=0;eh?r=h:(u.left-=b.offsetLeft,u.right-=b.offsetLeft,u.top-=b.offsetTop,u.bottom-=b.offsetTop,b.selection.each(function(){var t=l.bBox(this);s.bBoxIntersect(u,t,c)&&(r=Math.max(r,o*(t[b.side]-u[a])+c))}),r=Math.min(h,r)),r>0||0>h){var d={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[b.side];e.attr("transform","translate("+d+")")}}}function p(){E=0,L=!0,S=z,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)})}var g=r.propContainer,v=r.propName,m=r.traceIndex,y=r.dfltName,b=r.avoid||{},x=r.attributes,_=r.transform,w=r.containerGroup,k=t._fullLayout,A=g.titlefont.family,M=g.titlefont.size,T=g.titlefont.color,E=1,L=!1,S=g.title.trim();""===S&&(E=0),S.match(/Click to enter .+ title/)&&(E=.2,L=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var z="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==m?a.restyle(t,v,e,m):a.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(x).selectAll("tspan.line").attr(x)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",L)}},{"../../lib":378,"../../lib/svg_text_utils":390,"../../plotly":396,"../../plots/plots":447,"../color":303,"../drawing":325,d3:72,"fast-isnumeric":76}],362:[function(t,e,r){"use strict";var n=e.exports={};n.projNames={equirectangular:"equirectangular",mercator:"mercator",orthographic:"orthographic","natural earth":"naturalEarth",kavrayskiy7:"kavrayskiy7",miller:"miller",robinson:"robinson",eckert4:"eckert4","azimuthal equal area":"azimuthalEqualArea","azimuthal equidistant":"azimuthalEquidistant","conic equal area":"conicEqualArea","conic conformal":"conicConformal","conic equidistant":"conicEquidistant",gnomonic:"gnomonic",stereographic:"stereographic",mollweide:"mollweide",hammer:"hammer","transverse mercator":"transverseMercator","albers usa":"albersUsa"},n.axesNames=["lonaxis","lataxis"],n.lonaxisSpan={orthographic:180,"azimuthal equal area":360,"azimuthal equidistant":360,"conic conformal":180,gnomonic:160,stereographic:180,"transverse mercator":180,"*":360},n.lataxisSpan={"conic conformal":150,stereographic:179.5,"*":180},n.scopeDefaults={world:{lonaxisRange:[-180,180],lataxisRange:[-90,90],projType:"equirectangular",projRotate:[0,0,0]},usa:{lonaxisRange:[-180,-50],lataxisRange:[15,80],projType:"albers usa"},europe:{lonaxisRange:[-30,60],lataxisRange:[30,80],projType:"conic conformal",projRotate:[15,0,0],projParallels:[0,60]},asia:{lonaxisRange:[22,160],lataxisRange:[-15,55],projType:"mercator",projRotate:[0,0,0]},africa:{lonaxisRange:[-30,60],lataxisRange:[-40,40],projType:"mercator",projRotate:[0,0,0]},"north america":{lonaxisRange:[-180,-45],lataxisRange:[5,85],projType:"conic conformal",projRotate:[-100,0,0],projParallels:[29.5,45.5]},"south america":{lonaxisRange:[-100,-30],lataxisRange:[-60,15],projType:"mercator",projRotate:[0,0,0]}},n.clipPad=.001,n.precision=.1,n.landColor="#F0DC82",n.waterColor="#3399FF",n.locationmodeToLayer={"ISO-3":"countries","USA-states":"subunits","country names":"countries"},n.sphereSVG={type:"Sphere"},n.fillLayers=["ocean","land","lakes"],n.lineLayers=["subunits","countries","coastlines","rivers","frame"],n.baseLayers=["ocean","land","lakes","subunits","countries","coastlines","rivers","lataxis","lonaxis","frame"],n.layerNameToAdjective={ocean:"ocean",land:"land",lakes:"lake",subunits:"subunit",countries:"country",coastlines:"coastline",rivers:"river",frame:"frame"},n.baseLayersOverChoropleth=["rivers","lakes"]},{}],363:[function(t,e,r){"use strict";e.exports={solid:[1],dot:[1,1],dash:[4,1],longdash:[8,1],dashdot:[4,1,1,1],longdashdot:[8,1,1,1]}},{}],364:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],365:[function(t,e,r){"use strict";e.exports={circle:"\u25cf","circle-open":"\u25cb",square:"\u25a0","square-open":"\u25a1",diamond:"\u25c6","diamond-open":"\u25c7",cross:"+",x:"\u274c"}},{}],366:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],367:[function(t,e,r){"use strict";var n=t("./plotly");r.version="1.10.1",r.plot=n.plot,r.newPlot=n.newPlot,r.restyle=n.restyle,r.relayout=n.relayout,r.redraw=n.redraw,r.extendTraces=n.extendTraces,r.prependTraces=n.prependTraces,r.addTraces=n.addTraces,r.deleteTraces=n.deleteTraces,r.moveTraces=n.moveTraces,r.purge=n.purge,r.setPlotConfig=t("./plot_api/set_plot_config"),r.register=n.register,r.Icons=t("../build/ploticon"),r.Plots=n.Plots,r.Fx=n.Fx,r.Snapshot=n.Snapshot,r.PlotSchema=n.PlotSchema,r.Queue=n.Queue,r.d3=t("d3")},{"../build/ploticon":2,"./plot_api/set_plot_config":395,"./plotly":396,d3:72}],368:[function(t,e,r){"use strict";"undefined"!=typeof MathJax?(r.MathJax=!0,MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:!0,displayAlign:"left",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]}}),MathJax.Hub.Configured()):r.MathJax=!1},{}],369:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){Array.isArray(t)&&(e[r]=t[n])}},{}],370:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("./nested_property"),o=t("../components/colorscale/get_scale"),s=(Object.keys(t("../components/colorscale/scales")),/^([2-9]|[1-9][0-9]+)$/);r.valObjects={data_array:{coerceFunction:function(t,e,r){Array.isArray(t)?e.set(t):void 0!==r&&e.set(r)}},enumerated:{coerceFunction:function(t,e,r,n){n.coerceNumber&&(t=+t),-1===n.values.indexOf(t)?e.set(r):e.set(t)}},"boolean":{coerceFunction:function(t,e,r){t===!0||t===!1?e.set(t):e.set(r)}},number:{coerceFunction:function(t,e,r,i){!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if(n.strict===!0&&"string"!=typeof t)return void e.set(r);var i=String(t);void 0===t||n.noBlank===!0&&!i?e.set(r):e.set(i)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r){var n=r.length;return"string"==typeof t&&t.substr(0,n)===r&&s.test(t.substr(n))?void e.set(t):void e.set(r)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"!=typeof t)return void e.set(r);if(-1!==n.extras.indexOf(t))return void e.set(t);for(var i=t.split("+"),a=0;a2)return!1;var l=o[0].split("-");if(l.length>3||3!==l.length&&o[1])return!1;if(4===l[0].length)r=Number(l[0]);else{if(2!==l[0].length)return!1;var c=(new Date).getFullYear();r=((Number(l[0])-c+70)%100+200)%100+c-70}return s(r)?1===l.length?new Date(r,0,1).getTime():(n=Number(l[1])-1,l[1].length>2||!(n>=0&&11>=n)?!1:2===l.length?new Date(r,n,1).getTime():(i=Number(l[2]),l[2].length>2||!(i>=1&&31>=i)?!1:(i=new Date(r,n,i).getTime(),o[1]?(l=o[1].split(":"),l.length>3?!1:(a=Number(l[0]),l[0].length>2||!(a>=0&&23>=a)?!1:(i+=36e5*a,1===l.length?i:(n=Number(l[1]),l[1].length>2||!(n>=0&&59>=n)?!1:(i+=6e4*n,2===l.length?i:(t=Number(l[2]),t>=0&&60>t?i+1e3*t:!1)))))):i))):!1},r.isDateTime=function(t){return r.dateTime2ms(t)!==!1},r.ms2DateTime=function(t,e){if("undefined"==typeof o)return void console.log("d3 is not defined");e||(e=0);var r=new Date(t),i=o.time.format("%Y-%m-%d")(r);return 7776e6>e?(i+=" "+n(r.getHours(),2),432e6>e&&(i+=":"+n(r.getMinutes(),2),108e5>e&&(i+=":"+n(r.getSeconds(),2),3e5>e&&(i+="."+n(r.getMilliseconds(),3)))),i.replace(/([:\s]00)*\.?[0]*$/,"")):i};var l={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},c={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},u=o.time.format.utc,f={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(u),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(u)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(u)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){c[t].forEach(function(e){f[t].D.push(u(e)),["H","I","D"].forEach(function(r){l[r].forEach(function(n){var i=f[t][r];i.push(u(e+"~"+n)),i.push(u(n+"~"+e))})})})});var h=/[a-z]*/g,d=function(t){return t.substr(0,3)},p=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,g=/[\s,\/\-\.\(\)]+/g,v=/~?([ap])~?m(~|$)/,m=function(t,e){return e+"m "},y=/\d\d\d\d/,b=/(^|~)[a-z]{3}/,x=/[ap]m/,_=/:/,w=/q([1-4])/,k=["31~mar","30~jun","30~sep","31~dec"],A=function(t,e){return k[e-1]},M=/ ?([+\-]\d\d:?\d\d|Z)$/;r.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(h,d).replace(p,"").replace(g,"~").replace(v,m).replace(w,A).trim().replace(M,"");var e,r,n=null,o=i(t),s=a(t);e=f[o][s],r=e.length;for(var l=0;r>l&&!(n=e[l].parse(t));l++);if(!(n instanceof Date))return!1;var c=n.getTimezoneOffset();return n.setTime(n.getTime()+60*c*1e3),n}},{d3:72,"fast-isnumeric":76}],372:[function(t,e,r){"use strict";var n=t("events").EventEmitter,i={init:function(t){if(t._ev instanceof n)return t;var e=new n;return t._ev=e,t.on=e.on.bind(e),t.once=e.once.bind(e),t.removeListener=e.removeListener.bind(e),t.removeAllListeners=e.removeAllListeners.bind(e),t.emit=function(r,n){"undefined"!=typeof jQuery&&jQuery(t).trigger(r,n),e.emit(r,n)},t},triggerHandler:function(t,e,r){var n,i;"undefined"!=typeof jQuery&&(n=jQuery(t).triggerHandler(e,r));var a=t._ev;if(!a)return n;var o=a._events[e];if(!o)return n;"function"==typeof o&&(o=[o]);for(var s=o.pop(),l=0;lp;p++){o=t[p];for(s in o)l=h[s],c=o[s],e&&c&&(i(c)||(u=a(c)))?(u?(u=!1,f=l&&a(l)?l:[]):f=l&&i(l)?l:{},h[s]=n([f,c],e,r)):("undefined"!=typeof c||r)&&(h[s]=c)}return h}var i=t("./is_plain_object.js"),a=Array.isArray;r.extendFlat=function(){return n(arguments,!1,!1)},r.extendDeep=function(){return n(arguments,!0,!1)},r.extendDeepAll=function(){return n(arguments,!0,!0)}},{"./is_plain_object.js":379}],374:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=0;ry;y++)f=s(p,y),d=l(e,y),m[y]=n(f,d);else m=n(p,e);return m}var s=t("tinycolor2"),l=t("fast-isnumeric"),c=t("../components/colorscale/make_scale_function"),u=t("../components/color/attributes").defaultLine,f=t("./str2rgbarray"),h=1;e.exports=o},{"../components/color/attributes":302,"../components/colorscale/make_scale_function":319,"./str2rgbarray":389,"fast-isnumeric":76,tinycolor2:233}],377:[function(t,e,r){"use strict";function n(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(e>r)break;t=t.slice(0,e)+l(t.slice(e+5,r))+t.slice(r+6)}return t}function i(t){return t.replace(/\/g,"\n")}function a(t){return t.replace(/\<.*\>/g,"")}function o(t){for(var e=0;(e=t.indexOf("&",e))>=0;){var r=t.indexOf(";",e);if(e>r)e+=1;else{var n=c[t.slice(e+1,r)];t=n?t.slice(0,e)+n+t.slice(r+1):t.slice(0,e)+t.slice(r+1)}}return t}function s(t){return""+o(a(n(i(t))))}var l=t("superscript-text"),c={mu:"\u03bc",amp:"&",lt:"<",gt:">"};e.exports=s},{"superscript-text":222}],378:[function(t,e,r){"use strict";var n=t("d3"),i=e.exports={};i.nestedProperty=t("./nested_property"),i.isPlainObject=t("./is_plain_object");var a=t("./coerce");i.valObjects=a.valObjects,i.coerce=a.coerce,i.coerce2=a.coerce2,i.coerceFont=a.coerceFont;var o=t("./dates");i.dateTime2ms=o.dateTime2ms,i.isDateTime=o.isDateTime,i.ms2DateTime=o.ms2DateTime,i.parseDate=o.parseDate;var s=t("./search");i.findBin=s.findBin,i.sorterAsc=s.sorterAsc,i.sorterDes=s.sorterDes,i.distinctVals=s.distinctVals,i.roundUp=s.roundUp;var l=t("./stats");i.aggNums=l.aggNums,i.len=l.len,i.mean=l.mean,i.variance=l.variance,i.stdev=l.stdev,i.interp=l.interp;var c=t("./matrix");i.init2dArray=c.init2dArray,i.transposeRagged=c.transposeRagged,i.dot=c.dot,i.translationMatrix=c.translationMatrix,i.rotationMatrix=c.rotationMatrix,i.rotationXYMatrix=c.rotationXYMatrix,i.apply2DTransform=c.apply2DTransform,i.apply2DTransform2=c.apply2DTransform2;var u=t("./extend");i.extendFlat=u.extendFlat,i.extendDeep=u.extendDeep,i.extendDeepAll=u.extendDeepAll,i.notifier=t("./notifier"),i.swapAttrs=function(t,e,r,n){r||(r="x"),n||(n="y");for(var a=0;ar?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},i.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},i.identity=function(t){return t},i.randstr=function f(t,e,r){if(r||(r=16),void 0===e&&(e=24),0>=e)return"0";var n,i,a,o=Math.log(Math.pow(2,e))/Math.log(r),s="";for(n=2;o===1/0;n*=2)o=Math.log(Math.pow(2,e/n))/Math.log(r)*n;var l=o-Math.floor(o);for(n=0;n-1||c!==1/0&&c>=Math.pow(2,e)?f(t,e,r):s},i.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={};return r.optionList=[],r._newoption=function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)},r["_"+e]=t,r},i.smooth=function(t,e){if(e=Math.round(e)||0,2>e)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,c=new Array(l),u=new Array(o);for(r=0;l>r;r++)c[r]=(1-Math.cos(Math.PI*(r+1)/e))/(2*e);for(r=0;o>r;r++){for(a=0,n=0;l>n;n++)i=r+n+1-e,-o>i?i-=s*Math.round(i/s):i>=s&&(i-=s*Math.floor(i/s)),0>i?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*c[n];u[r]=a}return u},i.promiseError=function(t){console.log(t,t.stack)},i.syncOrAsync=function(t,e,r){function n(){return i.markTime("async done "+o.name),i.syncOrAsync(t,e,r)}for(var a,o;t.length;){if(o=t.splice(0,1)[0],a=o(e),a&&a.then)return a.then(n).then(void 0,i.promiseError);i.markTime("sync done "+o.name)}return r&&r(e)},i.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},i.noneOrAll=function(t,e,r){if(t){var n,i,a=!1,o=!0;for(n=0;ni;i++)e[i][r]=t[i]},i.minExtend=function(t,e){var r={};"object"!=typeof e&&(e={});var n,a,o,s=3,l=Object.keys(t);for(n=0;nn;n++)r[n]=new Array(e);return r},r.transposeRagged=function(t){var e,r,n=0,i=t.length;for(e=0;i>e;e++)n=Math.max(n,t[e].length);var a=new Array(n);for(e=0;n>e;e++)for(a[e]=new Array(i),r=0;i>r;r++)a[e][r]=t[r][e];return a},r.dot=function(t,e){if(!t.length||!e.length||t.length!==e.length)return null;var n,i,a=t.length;if(t[0].length)for(n=new Array(a),i=0;a>i;i++)n[i]=r.dot(t[i],e);else if(e[0].length){var o=r.transposeRagged(e);for(n=new Array(o.length),i=0;ii;i++)n+=t[i]*e[i];return n},r.translationMatrix=function(t,e){return[[1,0,t],[0,1,e],[0,0,1]]},r.rotationMatrix=function(t){var e=t*Math.PI/180;return[[Math.cos(e),-Math.sin(e),0],[Math.sin(e),Math.cos(e),0],[0,0,1]]},r.rotationXYMatrix=function(t,e,n){return r.dot(r.dot(r.translationMatrix(e,n),r.rotationMatrix(t)),r.translationMatrix(-e,-n))},r.apply2DTransform=function(t){return function(){var e=arguments;3===e.length&&(e=e[0]);var n=1===arguments.length?e[0]:[e[0],e[1]];return r.dot(t,[n[0],n[1],1]).slice(0,2)}},r.apply2DTransform2=function(t){var e=r.apply2DTransform(t);return function(t){return e(t.slice(0,2)).concat(e(t.slice(2,4)))}}},{}],381:[function(t,e,r){"use strict";function n(t,e){return function(){var r,i,a,o,s,l=t;for(o=0;o=0;e--){if(n=t[e],o=!1,Array.isArray(n))for(r=n.length-1;r>=0;r--)c(n[r])?o?n[r]=void 0:n.pop():o=!0;else if("object"==typeof n&&null!==n)for(a=Object.keys(n),o=!1,r=a.length-1;r>=0;r--)c(n[a[r]])&&!i(n[a[r]],a[r])?delete n[a[r]]:o=!0;if(o)return}}function c(t){return void 0===t||null===t?!0:"object"!=typeof t?!1:Array.isArray(t)?!t.length:!Object.keys(t).length}function u(t,e,r){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:r,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,l=e.split(".");sr||r>a||o>n||n>s?!1:!e||!c(t)}function r(t,e){var r=t[0],l=t[1];if(i>r||r>a||o>l||l>s)return!1;var c,u,f,h,d,p=n.length,g=n[0][0],v=n[0][1],m=0;for(c=1;p>c;c++)if(u=g,f=v,g=n[c][0],v=n[c][1],h=Math.min(u,g),!(h>r||r>Math.max(u,g)||l>Math.max(f,v)))if(l=l&&r!==h&&m++}return m%2===1}var n=t.slice(),i=n[0][0],a=i,o=n[0][1],s=o;n.push(n[0]);for(var l=1;la;a++)if(o=[t[a][0]-l[0],t[a][1]-l[1]],s=n(o,c),0>s||s>u||Math.abs(n(o,h))>i)return!0;return!1};i.filter=function(t,e){function r(r){t.push(r);var s=n.length,l=i;n.splice(o+1);for(var c=l+1;c1){var s=t.pop();r(s)}return{addPt:r,raw:t,filtered:n}}},{"./matrix":380}],384:[function(t,e,r){"use strict";function n(t,e){for(var r,n=[],a=0;a=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;rt}function i(t,e){return e>=t}function a(t,e){return t>e}function o(t,e){return t>=e}var s=t("fast-isnumeric");r.findBin=function(t,e,r){if(s(e.start))return r?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var l,c,u=0,f=e.length,h=0;for(c=e[e.length-1]>=e[0]?r?n:i:r?o:a;f>u&&h++<100;)l=Math.floor((u+f)/2),c(e[l],t)?u=l+1:f=l;return h>90&&console.log("Long binary search..."),u-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;n>s;s++)e[s+1]>e[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,c=r?Math.ceil:Math.floor;a>i&&o++<100;)n=c((i+a)/2),e[n]<=t?i=n+s:a=n-l;return e[i]}},{"fast-isnumeric":76}],386:[function(t,e,r){"use strict";e.exports=function(t,e){(t.attr("class")||"").split(" ").forEach(function(e){0===e.indexOf("cursor-")&&t.classed(e,!1)}),e&&t.classed("cursor-"+e,!0)}},{}],387:[function(t,e,r){"use strict";var n=t("../components/color"),i=function(){};e.exports=function(t){for(var e in t)"function"==typeof t[e]&&(t[e]=i);t.destroy=function(){t.container.parentNode.removeChild(t.container)};var r=document.createElement("div");return r.textContent="Webgl is not supported by your browser - visit http://get.webgl.org for more info",r.style.cursor="pointer",r.style.fontSize="24px",r.style.color=n.defaults[0],t.container.appendChild(r),t.container.style.background="#FFFFFF",t.container.onclick=function(){window.open("http://get.webgl.org")},!1}},{"../components/color":303}],388:[function(t,e,r){"use strict";var n=t("fast-isnumeric");r.aggNums=function(t,e,i,a){var o,s;if(a||(a=i.length),n(e)||(e=!1),Array.isArray(i[0])){for(s=new Array(a),o=0;a>o;o++)s[o]=r.aggNums(t,e,i[o]);i=s}for(o=0;a>o;o++)n(e)?n(i[o])&&(e=t(+e,+i[o])):e=i[o];return e},r.len=function(t){return r.aggNums(function(t){return t+1},0,t)},r.mean=function(t,e){return e||(e=r.len(t)),r.aggNums(function(t,e){return t+e},0,t)/e},r.variance=function(t,e,i){return e||(e=r.len(t)),n(i)||(i=r.mean(t,e)),r.aggNums(function(t,e){return t+Math.pow(e-i,2)},0,t)/e},r.stdev=function(t,e,n){return Math.sqrt(r.variance(t,e,n))},r.interp=function(t,e){if(!n(e))throw"n should be a finite number";if(e=e*t.length-.5,0>e)return t[0];if(e>t.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"fast-isnumeric":76}],389:[function(t,e,r){"use strict";function n(t){return t=i(t),a.str2RgbaArray(t.toRgbString())}var i=t("tinycolor2"),a=t("arraytools");e.exports=n},{arraytools:49,tinycolor2:233}],390:[function(t,e,r){"use strict";function n(t,e){return t.node().getBoundingClientRect()[e]}function i(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function a(t,e,r){var n="math-output-"+l.Lib.randstr([],64),a=c.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(i(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,a.node()],function(){var e=c.select("body").select("#MathJax_SVG_glyphs");if(a.select(".MathJax_SVG").empty()||!a.select("svg").node())console.log("There was an error in the tex syntax.",t),r();else{var n=a.select("svg").node().getBoundingClientRect();r(a.select(".MathJax_SVG"),e,n)}a.remove()})}function o(t){for(var e=l.util.html_entity_decode(t),r=e.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),r=e&&e[2].toLowerCase(),n=h[r];if(void 0!==n){var i=e[1],a=e[3],o=a.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===r){if(i)return"";if("href"!==a.substr(0,4).toLowerCase())return"";var s=document.createElement("a");return s.href=a.substr(4).replace(/["'=]/g,""),-1===d.indexOf(s.protocol)?"":'"}if("br"===r)return"
";if(i)return"sup"===r?'':"sub"===r?'':"";var c=""}return l.util.xml_entity_encode(t).replace(/");i>0;i=r.indexOf("
",i+1))n.push(i);var a=0;n.forEach(function(t){for(var e=t+a,n=r.slice(0,e),i="",o=n.length-1;o>=0;o--){var s=n[o].match(/<(\/?).*>/i);if(s&&"
"!==n[o]){s[1]||(i=n[o]);break}}i&&(r.splice(e+1,0,i),r.splice(e,0,""),a+=2)});var o=r.join(""),s=o.split(/
/gi);return s.length>1&&(r=s.map(function(t,e){return''+t+""})),r.join("")}function s(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-c.top+"px",left:a()-c.left+"px","z-index":1e3}),this}}var l=t("../plotly"),c=t("d3"),u=t("../constants/xmlns_namespaces"),f=e.exports={};c.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),r=(new DOMParser).parseFromString(e,"application/xml"),n=r.documentElement.firstChild;n;)this.node().appendChild(this.node().ownerDocument.importNode(n,!0)),n=n.nextSibling;return r.querySelector("parsererror")?(console.log(r.querySelector("parsererror div").textContent),null):c.select(this.node().lastChild)},f.html_entity_decode=function(t){var e=c.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),r},f.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},f.convertToTspans=function(t,e){function r(){d.empty()||(p=u.attr("class")+"-math",d.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),h=t.appendSVG(s),h||t.text(i),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(u)}var i=t.text(),s=o(i),u=t,f=!u.attr("data-notex")&&s.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),h=i,d=c.select(u.node().parentNode);if(!d.empty()){var p=u.attr("class")?u.attr("class").split(" ")[0]:"text";p+="-math",d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=l.Lib.getPlotDiv(u.node());(v&&v._promises||[]).push(new Promise(function(t){u.style({visibility:"hidden"});var i={fontSize:parseInt(u.style("font-size"),10)};a(f[2],i,function(i,a,o){d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove();var s=i&&i.select("svg");if(!s||!s.node())return r(),void t();var l=d.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});l.node().appendChild(s.node()),a&&a.node()&&s.node().insertBefore(a.node().cloneNode(!0),s.node().firstChild),s.attr({"class":p,height:o.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=u.style("fill")||"black";s.select("g").attr({fill:c,stroke:c});var f=n(s,"width"),h=n(s,"height"),g=+u.attr("x")-f*{start:0,middle:.5,end:1}[u.attr("text-anchor")||"start"],v=parseInt(u.style("font-size"),10)||n(u,"height"),m=-v/4;"y"===p[0]?(l.attr({transform:"rotate("+[-90,+u.attr("x"),+u.attr("y")]+") translate("+[-f/2,m-h/2]+")"}),s.attr({x:+u.attr("x"),y:+u.attr("y")})):"l"===p[0]?s.attr({x:u.attr("x"),y:m-h/2}):"a"===p[0]?s.attr({x:0,y:m}):s.attr({x:g,y:+u.attr("y")+m-h/2}),e&&e.call(u,l),t(l)})}))}else r();return t}};var h={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},d=["http:","https:","mailto:"],p=new RegExp("]*)?/?>","g");f.plainText=function(t){return(t||"").replace(p," ")},f.makeEditable=function(t,e,r){function n(){a(),o.style({opacity:0});var t,e=h.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0})}function i(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}function a(){var t=c.select(l.Lib.getPlotDiv(o.node())),e=t.select(".svg-container"),n=e.append("div");n.classed("plugin-editable editable",!0).style({position:"absolute","font-family":o.style("font-family")||"Arial","font-size":o.style("font-size")||12,color:r.fill||o.style("fill")||"black",opacity:1,"background-color":r.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(o.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(r.text||o.attr("data-unformatted")).call(s(o,e,r)).on("blur",function(){o.text(this.textContent).style({opacity:1});var t,e=c.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0});var r=this.textContent;c.select(this).transition().duration(0).remove(),c.select(document).on("mouseup",null),u.edit.call(o,r)}).on("focus",function(){var t=this;c.select(document).on("mouseup",function(){return c.event.target===t?!1:void(document.activeElement===n.node()&&n.node().blur())})}).on("keyup",function(){27===c.event.which?(o.style({opacity:1}),c.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),u.cancel.call(o,this.textContent)):(u.input.call(o,this.textContent),c.select(this).call(s(o,e,r)))}).on("keydown",function(){13===c.event.which&&this.blur()}).call(i)}r||(r={});var o=this,u=c.dispatch("edit","input","cancel"),f=c.select(this.node()).style({"pointer-events":"all"}),h=e||f;return e&&f.style({"pointer-events":"none"}),r.immediate?n():h.on("click",n),c.rebind(this,u,"on")}},{"../constants/xmlns_namespaces":366,"../plotly":396,d3:72}],391:[function(t,e,r){"use strict";var n=e.exports={},i=t("../constants/geo_constants").locationmodeToLayer,a=t("topojson").feature;n.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},n.getTopojsonPath=function(t,e){return t+e+".json"},n.getTopojsonFeatures=function(t,e){var r=i[t.locationmode],n=e.objects[r];return a(e,n).features}},{"../constants/geo_constants":362,topojson:234}],392:[function(t,e,r){"use strict";function n(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function i(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function a(t,e){t._context||(t._context=R.extendFlat({},P.defaultConfig));var r=t._context;e&&(Object.keys(e).forEach(function(t){t in r&&("setBackground"===t&&"opaque"===e[t]?r[t]=i:r[t]=e[t])}),e.plot3dPixelRatio&&!r.plotGlPixelRatio&&(r.plotGlPixelRatio=r.plot3dPixelRatio)),r.staticPlot&&(r.editable=!1,r.autosizable=!1,r.scrollZoom=!1,r.doubleClick=!1,r.showTips=!1,r.showLink=!1,r.displayModeBar=!1)}function o(t,e,r){var n=S.select(t).selectAll(".plot-container").data([0]);n.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=n.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e),r&&(t.layout=r),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(w(t,{}),t._fullLayout.autosize=r.autosize=!0),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var a=t.framework.svg(),o=1,s=t._fullLayout.title;""!==s&&s||(o=0);var l="Click to enter title",c=function(){this.call(P.util.convertToTspans)},u=a.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":s}),s&&s!==l||(o=.2,u.attr({"data-unformatted":l}).text(l).style({opacity:o}).on("mouseover.opacity",function(){S.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){S.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),N.addLinks(t),Promise.resolve()}function s(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var n=P.Axes.list({_fullLayout:t});for(e=0;ee;e++){var o=t.annotations[e];o.ref&&("paper"===o.ref?(o.xref="paper",o.yref="paper"):"data"===o.ref&&(o.xref="x",o.yref="y"),delete o.ref),l(o,"xref"),l(o,"yref")}void 0===t.shapes||Array.isArray(t.shapes)||(console.log("shapes must be an array"),delete t.shapes);var s=(t.shapes||[]).length;for(e=0;s>e;e++){var c=t.shapes[e];l(c,"xref"),l(c,"yref")}var u=t.legend;u&&(u.x>3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var h=N.getSubplotIds(t,"gl3d");for(e=0;er;++r)b[r]=v[e]+m*y[2+4*r];d.camera={eye:{x:b[0],y:b[1],z:b[2]},center:{x:v[0],y:v[1],z:v[2]},up:{x:y[1],y:y[5],z:y[9]}},delete d.cameraposition}}return R.markTime("finished rest of cleanLayout, starting color"),F.clean(t),R.markTime("finished cleanLayout color.clean"),t}function l(t,e){var r=t[e],n=e.charAt(0);r&&"paper"!==r&&(t[e]=P.Axes.cleanId(r,n))}function c(t,e){for(var r=[],n=(t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid})),i=0;ia&&(s=R.randstr(n),-1!==r.indexOf(s));a++);o.uid=R.randstr(n),n.push(o.uid)}if(r.push(o.uid),"histogramy"===o.type&&"xbins"in o&&!("ybins"in o)&&(o.ybins=o.xbins,delete o.xbins),o.error_y&&"opacity"in o.error_y){var l=F.defaults,c=o.error_y.color||(N.traceIs(o,"bar")?F.defaultLine:l[i%l.length]);o.error_y.color=F.addOpacity(F.rgb(c),F.opacity(c)*o.error_y.opacity),delete o.error_y.opacity}if("bardir"in o&&("h"!==o.bardir||!N.traceIs(o,"bar")&&"histogram"!==o.type.substr(0,9)||(o.orientation="h",x(o)),delete o.bardir),"histogramy"===o.type&&x(o),"histogramx"!==o.type&&"histogramy"!==o.type||(o.type="histogram"),"scl"in o&&(o.colorscale=o.scl,delete o.scl),"reversescl"in o&&(o.reversescale=o.reversescl,delete o.reversescl),o.xaxis&&(o.xaxis=P.Axes.cleanId(o.xaxis,"x")),o.yaxis&&(o.yaxis=P.Axes.cleanId(o.yaxis,"y")),N.traceIs(o,"gl3d")&&o.scene&&(o.scene=N.subplotsRegistry.gl3d.cleanId(o.scene)),N.traceIs(o,"pie")||(Array.isArray(o.textposition)?o.textposition=o.textposition.map(u):o.textposition&&(o.textposition=u(o.textposition))),N.traceIs(o,"2dMap")&&("YIGnBu"===o.colorscale&&(o.colorscale="YlGnBu"),"YIOrRd"===o.colorscale&&(o.colorscale="YlOrRd")),N.traceIs(o,"markerColorscale")&&o.marker){var h=o.marker;"YIGnBu"===h.colorscale&&(h.colorscale="YlGnBu"),"YIOrRd"===h.colorscale&&(h.colorscale="YlOrRd")}if("surface"===o.type&&R.isPlainObject(o.contours)){var d=["x","y","z"];for(a=0;an?a.push(i+n):a.push(n);return a}function p(t,e,r){var n,i;for(n=0;n=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||0>i&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function g(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),p(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&p(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function v(t,e,r){var n,i;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),n=0;n=0&&l0){var s=_(t._boundingBoxMargins),l=s.left+s.right,c=s.bottom+s.top,u=a._container.node().getBoundingClientRect(),f=1-2*o.frameMargins;i=Math.round(f*(u.width-l)),n=Math.round(f*(u.height-c))}else r=window.getComputedStyle(t),n=parseFloat(r.height)||a.height,i=parseFloat(r.width)||a.width;return Math.abs(a.width-i)>1||Math.abs(a.height-n)>1?(a.height=t.layout.height=n,a.width=t.layout.width=i):"initial"!==a.autosize&&(delete e.autosize,a.autosize=t.layout.autosize=!0),N.sanitizeMargins(a),e}function k(t){var e=S.select(t),r=t._fullLayout;if(r._hasGL3D&&N.subplotsRegistry.gl3d.initAxes(t),r._container=e.selectAll(".plot-container").data([0]),r._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),r._paperdiv=r._container.selectAll(".svg-container").data([0]),r._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===r.autosize&&(w(t,{}),r.autosize=!0,t.layout.autosize=!0),r._glcontainer=r._paperdiv.selectAll(".gl-container").data([0]),r._glcontainer.enter().append("div").classed("gl-container",!0),r._geocontainer=r._paperdiv.selectAll(".geo-container").data([0]),r._geocontainer.enter().append("div").classed("geo-container",!0),r._paperdiv.selectAll(".main-svg").remove(),r._paper=r._paperdiv.insert("svg",":first-child").classed("main-svg",!0),r._toppaper=r._paperdiv.append("svg").classed("main-svg",!0),!r._uid){var n=[];S.selectAll("defs").each(function(){this.id&&n.push(this.id.split("-")[1])}),r._uid=R.randstr(n)}r._paperdiv.selectAll(".main-svg").attr(X.svgAttrs),r._defs=r._paper.append("defs").attr("id","defs-"+r._uid),r._topdefs=r._toppaper.append("defs").attr("id","topdefs-"+r._uid),r._draggers=r._paper.append("g").classed("draglayer",!0),r._shapeLowerLayer=r._paper.append("g").classed("shapelayer shapelayer-below",!0);var i=P.Axes.getSubplots(t);i.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,i),r._hasCartesian&&M(t,i),r._ternarylayer=r._paper.append("g").classed("ternarylayer",!0),r._subplotShapeLayer=r._paper.selectAll(".shapelayer-subplot"),r._shapeUpperLayer=r._paper.append("g").classed("shapelayer shapelayer-above",!0),r._pielayer=r._paper.append("g").classed("pielayer",!0),r._glimages=r._paper.append("g").classed("glimages",!0),r._geoimages=r._paper.append("g").classed("geoimages",!0),r._infolayer=r._toppaper.append("g").classed("infolayer",!0),r._zoomlayer=r._toppaper.append("g").classed("zoomlayer",!0),r._hoverlayer=r._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var a=R.syncOrAsync([T,function(){return P.Axes.doTicks(t,"redraw")},j.init],t);return a&&a.then&&t._promises.push(a),a}function A(t,e){function r(e,r){return function(){return P.Axes.getFromId(t,e,r)}}for(var n,i,a=t._fullLayout._plots={},o=0;o0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),A=w===_;x?t.framework===k&&!b&&A||(t.framework=k,k(t)):A?b&&k(t):(t.framework=k,k(t)),b&&P.Axes.saveRangeInitial(t);var M=t._fullLayout,E=!t.calcdata||t.calcdata.length!==(t.data||[]).length;E&&h(t);for(var L=0;LG.range[0]?[1,2]:[2,1]);else{var X=G.range[0],W=G.range[1];"log"===O?(0>=X&&0>=W&&i(V+".autorange",!0),0>=X?X=W/1e6:0>=W&&(W=X/1e6),i(V+".range[0]",Math.log(X)/Math.LN10),i(V+".range[1]",Math.log(W)/Math.LN10)):(i(V+".range[0]",Math.pow(10,X)),i(V+".range[1]",Math.pow(10,W)))}else i(V+".autorange",!0)}if("reverse"===D)q.range?q.range.reverse():(i(V+".autorange",!0),q.range=[1,0]),H.autorange?_=!0:x=!0;else if("annotations"===z.parts[0]||"shapes"===z.parts[0]){var Z=z.parts[1],K=z.parts[0],Q=p[K]||[],$=P[R.titleCase(K)],J=Q[Z]||{};2===z.parts.length&&("add"===v[C]||R.isPlainObject(v[C])?E[C]="remove":"remove"===v[C]?-1===Z?(E[K]=Q,delete E[C]):E[C]=J:console.log("???",v)),!a(J,"x")&&!a(J,"y")||R.containsAny(C,["color","opacity","align","dash"])||(_=!0),$.draw(t,Z,z.parts.slice(2).join("."),v[C]),delete v[C]}else 0===z.parts[0].indexOf("scene")?x=!0:0===z.parts[0].indexOf("geo")?x=!0:0===z.parts[0].indexOf("ternary")?x=!0:!g._hasGL2D||-1===C.indexOf("axis")&&"plot_bgcolor"!==z.parts[0]?"hiddenlabels"===C?_=!0:-1!==z.parts[0].indexOf("legend")?m=!0:-1!==C.indexOf("title")?y=!0:-1!==z.parts[0].indexOf("bgcolor")?b=!0:z.parts.length>1&&R.containsAny(z.parts[1],["tick","exponent","grid","zeroline"])?y=!0:-1!==C.indexOf(".linewidth")&&-1!==C.indexOf("axis")?y=b=!0:z.parts.length>1&&-1!==z.parts[1].indexOf("line")?b=!0:z.parts.length>1&&"mirror"===z.parts[1]?y=b=!0:"margin.pad"===C?y=b=!0:"margin"===z.parts[0]||"autorange"===z.parts[1]||"rangemode"===z.parts[1]||"type"===z.parts[1]||"domain"===z.parts[1]||C.match(/^(bar|box|font)/)?_=!0:-1!==["hovermode","dragmode"].indexOf(C)?k=!0:-1===["hovermode","dragmode","height","width","autosize"].indexOf(C)&&(x=!0):x=!0,z.set(O)}I&&I.add(t,tt,[t,E],tt,[t,M]),v.autosize&&(v=w(t,v)),(v.height||v.width||v.autosize)&&(_=!0);var et=Object.keys(v),rt=[N.previousPromises];if(x||_)rt.push(function(){return t.layout=void 0,_&&(t.calcdata=void 0),P.plot(t,"",p)});else if(et.length&&(N.supplyDefaults(t),g=t._fullLayout,m&&rt.push(function(){return U.draw(t),N.previousPromises(t)}),b&&rt.push(T),y&&rt.push(function(){return P.Axes.doTicks(t,"redraw"),L(t),N.previousPromises(t)}),k)){var nt;for(Y(t),nt=N.getSubplotIds(g,"gl3d"),d=0;dc&&u>e&&(void 0===i[r]?a[f]=E.tickText(t,e):a[f]=s(t,e,String(i[r])),f++);return f=864e5?t._tickround="d":r>=36e5?t._tickround="H":r>=6e4?t._tickround="M":r>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(r/2)/Math.LN10);else{x(r)||(r=Number(r.substr(1))),t._tickround=2-Math.floor(Math.log(r)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var n=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(n)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((n-1)/3):t._tickexponent=n)}else"M"===r.charAt(0)?t._tickround=2===r.length?"m":"y":t._tickround=null}function o(t,e){var r=t.match(V),n=new Date(e);if(r){var i=Math.min(+r[1]||6,6),a=String(e/1e3%1+2.0000005).substr(2,i).replace(/0+$/,"")||"0";return b.time.format(t.replace(V,a))(n)}return b.time.format(t)(n)}function s(t,e,r){var n=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}function l(t,e,r,n){var i,a=e.x,s=t._tickround,l=new Date(a),c="";r&&t.hoverformat?i=o(t.hoverformat,a):t.tickformat?i=o(t.tickformat,a):(n&&(x(s)?s+=2:s={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[s]),"y"===s?i=N(l):"m"===s?i=j(l):(a!==t._tmin||r||(c="
"+N(l)),"d"===s?i=F(l):"H"===s?i=D(l):(a!==t._tmin||r||(c="
"+F(l)+", "+N(l)),i=B(l),"M"!==s&&(i+=U(l),"S"!==s&&(i+=h(y(a/1e3,1),t,"none",r).substr(1)))))),e.text=i+c}function c(t,e,r,n,i){var a=t.dtick,o=e.x;if(!n||"string"==typeof a&&"L"===a.charAt(0)||(a="L3"),t.tickformat||"string"==typeof a&&"L"===a.charAt(0))e.text=h(Math.pow(10,o),t,i,n);else if(x(a)||"D"===a.charAt(0)&&y(o+.01,1)<.1)if(-1!==["e","E","power"].indexOf(t.exponentformat)){var s=Math.round(o);0===s?e.text=1:1===s?e.text="10":s>1?e.text="10"+s+"":e.text="10\u2212"+-s+"",e.fontSize*=1.25}else e.text=h(Math.pow(10,o),t,"","fakehover"),"D1"===a&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==a.charAt(0))throw"unrecognized dtick "+String(a);e.text=String(Math.round(Math.pow(10,y(o,1)))),e.fontSize*=.75}if("D1"===t.dtick){var l=String(e.text).charAt(0);"0"!==l&&"1"!==l||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(0>o?.5:.25)))}}function u(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r=""),e.text=String(r)}function f(t,e,r,n,i){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide"),e.text=h(e.x,t,i,n)}function h(t,e,r,n){var i=0>t,o=e._tickround,s=r||e.exponentformat||"B",l=e._tickexponent,c=e.tickformat;if(n){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:x(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};a(u),o=(Number(u._tickround)||0)+4,l=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return b.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-o)/2;if("none"===s&&(l=0),t=Math.abs(t),f>t)t="0",i=!1;else{if(t+=f,l&&(t*=Math.pow(10,-l),o+=l),0===o)t=String(Math.floor(t));else if(0>o){t=String(Math.round(t)),t=t.substr(0,t.length+o);for(var h=o;0>h;h++)t+="0"}else{t=String(t);var p=t.indexOf(".")+1;p&&(t=t.substr(0,p+o).replace(/\.?0+$/,""))}t=d(t,e._gd._fullLayout.separators)}if(l&&"hide"!==s){var g;g=0>l?"\u2212"+-l:"power"!==s?"+"+l:String(l),"e"===s||("SI"===s||"B"===s)&&(l>12||-15>l)?t+="e"+g:"E"===s?t+="E"+g:"power"===s?t+="×10"+g+"":"B"===s&&9===l?t+="B":"SI"!==s&&"B"!==s||(t+=q[l/3+5])}return i?"\u2212"+t:t}function d(t,e){var r=e.charAt(0),n=e.charAt(1),i=t.split("."),a=i[0],o=i.length>1?r+i[1]:"";if(n&&(i.length>1||a.length>4))for(;H.test(a);)a=a.replace(H,"$1"+n+"$2");return a+o}function p(t,e){var r,n,i=[];for(r=0;r1)for(n=1;n2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},E.getAutoRange=function(t){var e,r=[],n=t._min[0].val,i=t._max[0].val;for(e=1;e0&&u>0&&f/u>h&&(l=o,c=s,h=f/u);return n===i?r=d?[n+1,"normal"!==t.rangemode?0:n-1]:["normal"!==t.rangemode?0:n-1,n+1]:h&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode&&l.val>=0?l={val:0,pad:0}:"nonnegative"===t.rangemode&&(l.val-h*l.pad<0&&(l={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),h=(c.val-l.val)/(t._length-l.pad-c.pad)),r=[l.val-h*l.pad,c.val+h*c.pad],r[0]===r[1]&&(r=[r[0]-1,r[0]+1]),d&&r.reverse()),r},E.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=E.getAutoRange(t);var r=t._gd.layout[t._name];r||(t._gd.layout[t._name]=r={}),r!==t&&(r.range=t.range.slice(),r.autorange=t.autorange)}},E.saveRangeInitial=function(t,e){for(var r=E.list(t,"",!0),n=!1,i=0;ip&&(p=g/10),c=t.c2l(p),u=t.c2l(g),y&&(c=Math.min(0,c),u=Math.max(0,u)),n(c)){for(d=!0,o=0;o=h?d=!1:s.val>=c&&s.pad<=h&&(t._min.splice(o,1),o--);d&&t._min.push({val:c,pad:y&&0===c?0:h})}if(n(u)){for(d=!0,o=0;o=u&&s.pad>=f?d=!1:s.val<=u&&s.pad<=f&&(t._max.splice(o,1),o--);d&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),r||(r={}),t._m||t.setScale();var a,o,s,l,c,u,f,h,d,p,g,v=e.length,m=r.padded?.05*t._length:0,y=r.tozero&&("linear"===t.type||"-"===t.type),b=n((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),_=n((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),w=n(r.vpadplus||r.vpad),k=n(r.vpadminus||r.vpad);for(a=0;6>a;a++)i(a);for(a=v-1;a>5;a--)i(a)}},E.autoBin=function(t,e,r,n){function i(t){return(1+100*(t-d)/f.dtick)%100<2}var a=w.aggNums(Math.min,null,t),o=w.aggNums(Math.max,null,t);if("category"===e.type)return{start:a-.5,end:o+.5,size:1};var s;if(r)s=(o-a)/r;else{var l=w.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(l.minDiff)/Math.LN10)),u=c*w.roundUp(l.minDiff/c,[.9,1.9,4.9,9.9],!0);s=Math.max(u,2*w.stdev(t)/Math.pow(t.length,n?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[a,o]};E.autoTicks(f,s);var h,d=E.tickIncrement(E.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;yg&&(p>.3*b||i(a)||i(o))){var _=f.dtick/2;d+=a>d+_?_:-_}var k=1+Math.floor((o-d)/f.dtick);h=d+k*f.dtick}else for(h=d;o>=h;)h=E.tickIncrement(h,f.dtick);return{start:d,end:h,size:f.dtick}},E.calcTicks=function(t){if("array"===t.tickmode)return n(t);if("auto"===t.tickmode||!t.dtick){var e,r=t.nticks;r||("category"===t.type?(e=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/e):(e="y"===t._id.charAt(0)?40:80,r=w.constrain(t._length/e,4,9)+1)),E.autoTicks(t,Math.abs(t.range[1]-t.range[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),a(t),t._tmin=E.tickFirst(t);var i=t.range[1]=s:s>=l)&&(o.push(l),!(o.length>1e3));l=E.tickIncrement(l,t.dtick,i));t._tmax=o[o.length-1];for(var c=new Array(o.length),u=0;u157788e5?(e/=315576e5,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*i(e,r,C)):e>12096e5?(e/=26298e5,t.dtick="M"+i(e,1,z)):e>432e5?(t.dtick=i(e,864e5,R),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=i(e,36e5,z):e>3e4?t.dtick=i(e,6e4,P):e>500?t.dtick=i(e,1e3,P):(r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,C));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var n=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/n,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+i(e,r,C)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,C));if(0===t.dtick&&(t.dtick=1),!x(t.dtick)&&"string"!=typeof t.dtick){var a=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(a)}},E.tickIncrement=function(t,e,r){var n=r?-1:1;if(x(e))return t+n*e;var i=e.charAt(0),a=n*Number(e.substr(1));if("M"===i){var o=new Date(t);return o.setMonth(o.getMonth()+a)}if("L"===i)return Math.log(Math.pow(10,t)+a)/Math.LN10;if("D"===i){var s="D2"===e?I:O,l=t+.01*n,c=w.roundUp(y(l,1),s,r);return Math.floor(l)+Math.log(b.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},E.tickFirst=function(t){var e=t.range[1]n:n>c;)c=E.tickIncrement(c,i,e);return c}if("L"===u)return Math.log(r((Math.pow(10,n)-a)/f)*f+a)/Math.LN10;if("D"===u){var h="D2"===i?I:O,d=w.roundUp(y(n,1),h,e);return Math.floor(n)+Math.log(b.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(i)};var N=b.time.format("%Y"),j=b.time.format("%b %Y"),F=b.time.format("%b %-d"),D=b.time.format("%b %-d %Hh"),B=b.time.format("%H:%M"),U=b.time.format(":%S"),V=/%(\d?)f/g;E.tickText=function(t,e,r){function n(n){var i;return void 0===n?!0:r?"none"===n:(i={first:t._tmin,last:t._tmax}[n],"all"!==n&&e!==i)}var i,a,o=s(t,e),h="array"===t.tickmode,d=r||h;if(h&&Array.isArray(t.ticktext)){var p=Math.abs(t.range[1]-t.range[0])/1e4;for(a=0;a1&&er&&(M=90),i(u,M)}c._lastangle=M}return o(e),e+" done"}function l(){c._boundingBox=r.node().getBoundingClientRect()}var u=r.selectAll("g."+C).data(y,S);if(!c.showticklabels||!x(n))return u.remove(),void o(e);var f,h,p,m,_;"x"===v?(_="bottom"===B?1:-1,f=function(t){return t.dx+I*_},m=n+(O+R)*_,h=function(t){return t.dy+m+t.fontSize*("bottom"===B?1:-.5)},p=function(t){return x(t)&&0!==t&&180!==t?0>t*_?"end":"start":"middle"}):(_="right"===B?1:-1,h=function(t){return t.dy+t.fontSize/2-I*_},f=function(t){return t.dx+n+(O+R+(90===Math.abs(c.tickangle)?t.fontSize/2:0))*_},p=function(t){return x(t)&&90===Math.abs(t)?"middle":"right"===B?"start":"end"});var A=0,M=0,E=[];u.enter().append("g").classed(C,1).append("text").attr("text-anchor","middle").each(function(e){var r=b.select(this),n=t._promises.length;r.call(T.setPosition,f(e),h(e)).call(T.font,e.font,e.fontSize,e.fontColor).text(e.text).call(k.convertToTspans),n=t._promises[n],n?E.push(t._promises.pop().then(function(){i(r,c.tickangle)})):i(r,c.tickangle)}),u.exit().remove(),u.each(function(t){A=Math.max(A,t.fontSize)}),i(u,c._lastangle||c.tickangle);var L=w.syncOrAsync([a,s,l]);return L&&L.then&&t._promises.push(L),L}function o(e){if(!r){var n,i,a,o,s=L.getFromId(t,e),l=b.select(t).selectAll("g."+e+"tick"),c={selection:l,side:s.side},f=e.charAt(0),h=t._fullLayout._size,d=1.5,p=s.titlefont.size;if(l.size()){var g=b.select(l.node().parentNode).attr("transform").match(/translate\(([-\.\d]+),([-\.\d]+)\)/);g&&(c.offsetLeft=+g[1],c.offsetTop=+g[2])}"x"===f?(i="free"===s.anchor?{_offset:h.t+(1-(s.position||0))*h.h,_length:0}:L.getFromId(t,s.anchor),a=s._offset+s._length/2,o=i._offset+("top"===s.side?-10-p*(d+(s.showticklabels?1:0)):i._length+10+p*(d+(s.showticklabels?1.5:.5))),s.rangeslider&&s.rangeslider.visible&&s._boundingBox&&(o+=(u.height-u.margin.b-u.margin.t)*s.rangeslider.thickness+s._boundingBox.height),c.side||(c.side="bottom")):(i="free"===s.anchor?{_offset:h.l+(s.position||0)*h.w,_length:0}:L.getFromId(t,s.anchor),o=s._offset+s._length/2,a=i._offset+("right"===s.side?i._length+10+p*(d+(s.showticklabels?1:.5)):-10-p*(d+(s.showticklabels?.5:0))),n={rotate:"-90",offset:0},c.side||(c.side="left")),A.draw(t,e+"title",{propContainer:s,propName:s._name+".title",dfltName:f.toUpperCase()+" axis",avoid:c,transform:n,attributes:{x:a,y:o,"text-anchor":"middle"}})}}function s(t,e){return t.visible!==!0||t.xaxis+t.yaxis!==e?!1:_.Plots.traceIs(t,"bar")&&t.orientation==={x:"h",y:"v"}[v]?!0:t.fill&&t.fill.charAt(t.fill.length-1)===v}function l(e,r,i){var a=e.gridlayer,o=e.zerolinelayer,l=e["hidegrid"+v]?[]:V,u=c._gridpath||"M0,0"+("x"===v?"v":"h")+r._length,f=a.selectAll("path."+z).data(c.showgrid===!1?[]:l,S);if(f.enter().append("path").classed(z,1).classed("crisp",1).attr("d",u).each(function(t){c.zeroline&&("linear"===c.type||"-"===c.type)&&Math.abs(t.x)g;g++){var y=c.mirrors[o._id+h[g]];"ticks"!==y&&"labels"!==y||(f[g]=!0)}return void 0!==n[2]&&(f[2]=!0),f.forEach(function(t,e){var r=n[e],i=U[e];t&&x(r)&&(d+=p(r+R*i,i*c.ticklen))}),i(r,d),l(e,o,t),a(r,n[3])}}).filter(function(t){return t&&t.then});return H.length?Promise.all(H):0},E.swap=function(t,e){for(var r=p(t,e),n=0;n2*n}function u(t){for(var e,r=Math.max(1,(t.length-1)/1e3),n=0,i=0,a=0;a2*n}var f=t("fast-isnumeric"),h=t("tinycolor2").mix,d=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),b=t("./tick_label_defaults"),x=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),A=t("./axis_ids");e.exports=function(t,e,r,i){function a(r,n){return d.coerce2(t,e,v,r,n)}var o=i.letter,s=i.font||{},l="Click to enter "+(i.title||o.toUpperCase()+" axis")+" title";i.name&&(e._name=i.name,e._id=A.name2id(i.name));var c=r("type");"-"===c&&(n(e,i.data),"-"===e.type?e.type="linear":c=t.type=e.type),e._initialCategories="category"===c?w(o,t.categoryorder,t.categoryarray,i.data):[],_(e);var u=r("color"),p=u===t.color?u:s.color;r("title",l),d.coerceFont(r,"titlefont",{family:s.family,size:Math.round(1.2*s.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),M=r("autorange",!k);M&&r("rangemode");var T=r("range",[-1,"x"===o?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),d.noneOrAll(t.range,e.range,[0,1]),r("fixedrange"),m(t,e,r,c),b(t,e,r,c,i),y(t,e,r,i),x(t,e,r);var E=a("linecolor",u),L=a("linewidth"),S=r("showline",!!E||!!L);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&r("mirror");var C=a("gridcolor",h(u,i.bgColor,g).toRgbString()),z=a("gridwidth"),P=r("showgrid",i.showGrid||!!C||!!z);P||(delete e.gridcolor,delete e.gridwidth);var R=a("zerolinecolor",u),O=a("zerolinewidth"),I=r("zeroline",i.showGrid||!!R||!!O);return I||(delete e.zerolinecolor,delete e.zerolinewidth),e}},{"../../components/color/attributes":302,"../../lib":378,"../plots":447,"./axis_ids":401,"./category_order_defaults":402,"./clean_datum":403,"./layout_attributes":408,"./ordered_categories":410,"./set_convert":413,"./tick_label_defaults":414,"./tick_mark_defaults":415,"./tick_value_defaults":416,"fast-isnumeric":76,tinycolor2:233}],401:[function(t,e,r){"use strict";function n(t,e,r){function n(t,r){for(var n=Object.keys(t),i=/^[xyz]axis[0-9]*/,a=[],o=0;o0;-1===i.indexOf(t.categoryorder)&&a?r("categoryorder","array"):"array"!==t.categoryorder||a?r("categoryorder"):(t.categoryorder="trace",r("categoryorder"))}}},{"./layout_attributes":408}],403:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return i.ms2DateTime(t);if("string"!=typeof t&&!n(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){console.log(e,t)}return t}},{"../../lib":378,"fast-isnumeric":76}],404:[function(t,e,r){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:100,BENDPX:1.5}},{}],405:[function(t,e,r){"use strict";function n(t,e){var r,n=t.range[e],i=Math.abs(n-t.range[1-e]);return"date"===t.type?c.ms2DateTime(n,i):"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,o.format("."+r+"g")(Math.pow(10,n))):(r=Math.floor(Math.log(Math.abs(n))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,o.format("."+String(r)+"g")(n))}function i(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function a(t){o.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var o=t("d3"),s=t("tinycolor2"),l=t("../../plotly"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../components/color"),h=t("../../components/drawing"),d=t("../../lib/setcursor"),p=t("../../components/dragelement"),g=t("./axes"),v=t("./select"),m=t("./constants"),y=!0;e.exports=function(t,e,r,o,b,x,_,w){function k(t,e){for(var r=0;r.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+ht+", "+dt+")").attr("d",ot+"Z"),ut=ft.append("path").attr("class","zoombox-corners").style({fill:f.background,stroke:f.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+ht+", "+dt+")").attr("d","M0,0Z"),T();for(var a=0;ai?(lt="",it.r=it.l,it.t=it.b,ut.attr("d","M0,0Z")):(it.t=0,it.b=V,lt="x",ut.attr("d","M"+(it.l-.5)+","+(nt-H-.5)+"h-3v"+(2*H+1)+"h3ZM"+(it.r+.5)+","+(nt-H-.5)+"h3v"+(2*H+1)+"h-3Z")):!Z||i.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),ut.transition().style("opacity",1).duration(200),st=!0)}function L(t,e,r){var n,i,a;for(n=0;nzoom back out","long"),y=!1)))}function C(e,r){var i=1===(_+w).length;if(e)I();else if(2!==r||i){if(1===r&&i){var a=_?B[0]:D[0],o="s"===_||"w"===w?0:1,s=a._name+".range["+o+"]",c=n(a,o),f="left",h="middle";if(a.fixedrange)return;_?(h="n"===_?"top":"bottom","right"===a.side&&(f="right")):"e"===w&&(f="right"),J.call(u.makeEditable,null,{immediate:!0,background:j.paper_bgcolor,text:String(c),fill:a.tickfont?a.tickfont.color:"#444",horizontalAlign:f,verticalAlign:h}).on("edit",function(e){var r="category"===a.type?a.c2l(e):a.d2l(e);void 0!==r&&l.relayout(t,s,r)})}}else O()}function z(e){function r(t,e,r){if(!t.fixedrange){A(t.range);var n=t.range,i=n[0]+(n[1]-n[0])*e;t.range=[i+(n[0]-i)*r,i+(n[1]-i)*r]}}if(t._context.scrollZoom||j._enablescrollzoom){var n=t.querySelector(".plotly");if(!(n.scrollHeight-n.clientHeight>10||n.scrollWidth-n.clientWidth>10)){clearTimeout(gt);var i=-e.deltaY;if(isFinite(i)||(i=e.wheelDelta/10),!isFinite(i))return void console.log("did not find wheel motion attributes",e);var a,o=Math.exp(-Math.min(Math.max(i,-20),20)/100),s=mt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-s.left)/s.width,u=pt[0]+pt[2]*l,f=(s.bottom-e.clientY)/s.height,h=pt[1]+pt[3]*(1-f);if(w){for(a=0;a=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function i(t,e,r){for(var i=1-e,a=0,o=0;o0;n--)r.push(e);return r}function i(t,e){for(var r=[],n=0;nj||j>D.width||0>F||F>D.height)return _.unhoverRaw(t,e)}else j="xpx"in e?e.xpx:p[0]._length/2,F="ypx"in e?e.ypx:v[0]._length/2;if(x="xval"in e?n(d,e.xval):i(p,j),A="yval"in e?n(d,e.yval):i(v,F),!g(x[0])||!g(A[0]))return console.log("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var B=1/0;for(T=0;T1||-1!==L.hoverinfo.indexOf("name")?L.name:void 0,index:!1,distance:Math.min(B,k.MAXDIST),color:b.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},O=I.length,"array"===C){var U=e[T];"pointNumber"in U?(R.index=U.pointNumber,C="closest"):(C="","xval"in U&&(z=U.xval,C="x"),"yval"in U&&(P=U.yval,C=C?"closest":"y"))}else z=x[S],P=A[S];if(L._module&&L._module.hoverPoints){var V=L._module.hoverPoints(R,z,P,C);if(V)for(var q,H=0;HO&&(I.splice(0,O),B=I[0].distance)}if(0===I.length)return _.unhoverRaw(t,e);var G="y"===y&&N.length>1;I.sort(function(t,e){return t.distance-e.distance});var Y=b.combine(a.plot_bgcolor||b.background,a.paper_bgcolor),X={hovermode:y,rotateLabels:G,bgColor:Y,container:a._hoverlayer,outerContainer:a._paperdiv},W=c(I,X);u(I,G?"xa":"ya"),f(W,G);var Z=t._hoverdata,K=[];for(M=0;M128?"#000":b.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,r=u.textContent||"",r.length>15&&(r=r.substr(0,12)+"...")}void 0!==t.extraText&&(n+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(n+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(n+="y: "+t.yLabel+"
"),n+=(n?"z: ":"")+t.zLabel):M&&t[i+"Label"]===g?n=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(n=t.yLabel):n=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(n+=(n?"
":"")+t.text),""===n&&(""===r&&e.remove(),n=r);var f=e.select("text.nums").style("fill",c).call(x.setPosition,0,0).text(n).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(x.setPosition,0,0);var h=e.select("text.name"),v=0;r&&r!==n?(h.style("fill",l).text(r).call(x.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),h.selectAll("tspan.line").call(x.setPosition,0,0),v=h.node().getBoundingClientRect().width+2*P):(h.remove(),e.select("rect").remove()),e.select("path").style({fill:l,stroke:c});var m,k,E=f.node().getBoundingClientRect(),L=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),R=Math.abs(t.y1-t.y0),O=E.width+z+P+v;t.ty0=_-E.top,t.bx=E.width+2*P,t.by=E.height+2*P,t.anchor="start",t.txwidth=E.width,t.tx2width=v,t.offset=0,a?(t.pos=L,m=A>=S+R/2+O,k=S-R/2-O>=0,"top"!==t.idealAlign&&m||!k?m?(S+=R/2,t.anchor="start"):t.anchor="middle":(S-=R/2,t.anchor="end")):(t.pos=S,m=w>=L+C/2+O,k=L-C/2-O>=0,"left"!==t.idealAlign&&m||!k?m?(L+=C/2,t.anchor="start"):t.anchor="middle":(L-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&h.attr("text-anchor",t.anchor),e.attr("transform","translate("+L+","+S+")"+(a?"rotate("+T+")":""))}),S}function u(t,e){function r(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(.01>a)){if(-.01>i){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos>e.pmax-1&&(l.del=!0,c--);for(o=0;o=c);o++)if(l=t[o],l.pos=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos+l.dp+l.size>e.pmax&&(l.del=!0,c--)}}}for(var n,i,a,o,s,l,c,u=0,f=t.map(function(t,r){var n=t[e];return[{i:r,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===n._id.charAt(0)?L:1)/2,pmin:n._offset,pmax:n._offset+n._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(s=d.length-1;s>=0;s--)d[s].dp+=i;for(h.push.apply(h,d),f.splice(o+1,1),c=0,s=h.length-1;s>=0;s--)c+=h[s].dp;for(a=c/h.length,s=h.length-1;s>=0;s--)h[s].dp-=a;n=!1}else o++}f.forEach(r)}for(o=f.length-1;o>=0;o--){var v=f[o];for(s=v.length-1;s>=0;s--){var m=v[s],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var r=d.select(this);if(t.del)return void r.remove();var n="end"===t.anchor?-1:1,i=r.select("text.nums"),a={start:1,end:-1,middle:0}[t.anchor],o=a*(z+P),s=o+a*(t.txwidth+P),l=0,c=t.offset;"middle"===t.anchor&&(o-=t.tx2width/2,s-=t.tx2width/2),e&&(c*=-C,l=t.offset*S),r.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(n*z+l)+","+(z+c)+"v"+(t.by/2-z)+"h"+n*t.bx+"v-"+t.by+"H"+(n*z+l)+"V"+(c-z)+"Z"),i.call(x.setPosition,o+l,c+t.ty0-t.by/2+P).selectAll("tspan.line").attr({x:i.attr("x"),y:i.attr("y")}),t.tx2width&&(r.select("text.name, text.name tspan.line").call(x.setPosition,s+a*P+l,c+t.ty0-t.by/2+P),r.select("rect").call(x.setRect,s+(a-1)*t.tx2width/2+l,c-t.by/2-1,t.tx2width,t.by+2))})}function h(t,e,r){if(!e.target)return!1;if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}var d=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),b=t("../../components/color"),x=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),A=t("./dragbox"),M=e.exports={};M.unhover=_.unhover,M.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},M.supplyLayoutDefaults=function(t,e,r){function n(r,n){return v.coerce(t,e,M.layoutAttributes,r,n)}n("dragmode");var i;if(e._hasCartesian){var a=e._isHoriz=M.isHoriz(r);i=a?"y":"x"}else i="closest";n("hovermode",i)},M.isHoriz=function(t){for(var e=!0,r=0;rt._lastHoverTime+k.HOVERMINTIME?(o(t,e,r),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){o(t,e,r),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},M.getDistanceFunction=function(t,e,r,n){return"closest"===t?n||a(e,r):"x"===t?e:r},M.getClosest=function(t,e,r){if(r.index!==!1)r.index>=0&&r.indext*e||0===t?k.MAXDIST*(.6-.3/Math.max(3,Math.abs(t-e))):1/0}},{"../../components/color":303,"../../components/dragelement":323,"../../components/drawing":325,"../../lib":378,"../../lib/events":372,"../../lib/svg_text_utils":390,"./axes":399,"./constants":404,"./dragbox":405,d3:72,"fast-isnumeric":76,tinycolor2:233}],407:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../plots"),a=t("./constants");r.name="cartesian",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex=a.idRegex,r.attrRegex=a.attrRegex,r.attributes=t("./attributes"),r.plot=function(t){function e(t,e){for(var r=[],n=0;nf[1]-.01&&(e.domain=[0,1]),i.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":378,"fast-isnumeric":76}],412:[function(t,e,r){"use strict";function n(t){return t._id}var i=t("../../lib/polygon"),a=t("../../components/color"),o=t("./axes"),s=t("./constants"),l=i.filter,c=i.tester,u=s.MINSELECT;e.exports=function(t,e,r,i,f){function h(t){var e="y"===t._id.charAt(0)?1:0;return function(r){return t.p2d(r[e])}}function d(t,e){return t-e}var p,g=i.gd._fullLayout._zoomlayer,v=i.element.getBoundingClientRect(),m=i.plotinfo.x()._offset,y=i.plotinfo.y()._offset,b=e-v.left,x=r-v.top,_=b,w=x,k="M"+b+","+x,A=i.xaxes[0]._length,M=i.yaxes[0]._length,T=i.xaxes.map(n),E=i.yaxes.map(n),L=i.xaxes.concat(i.yaxes);"lasso"===f&&(p=l([[b,x]],s.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",k+"Z");var C,z,P,R,O,I=g.append("path").attr("class","zoombox-corners").style({fill:a.background,stroke:a.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),N=[],j=i.gd,F=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(0>=e&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-3*u*Math.abs(n-i))}return o.BADNUM}function r(t){return Math.pow(10,t)}function c(t){return i(t)?Number(t):o.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?r:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,r=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var n=l.getFromId(t._gd,t.overlaying);t.domain=n.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;2>e;e++)i(t.range[e])||(t.range[e]=i(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=r.t+(1-t.domain[1])*r.h,t._length=r.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=r.l+t.domain[0]*r.w,t._length=r.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw a.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return i(e)?n.round(t._b+t._m*e,2):o.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,r){return t.l2p(t.c2l(e,r))},t.p2c=function(e){return t.l2c(t.p2l(e))},-1!==["linear","log","-"].indexOf(t.type))t.c2d=c,t.d2c=function(t){return t=s(t),i(t)?Number(t):o.BADNUM},t.d2l=function(e,r){return"log"===t.type?t.c2l(t.d2c(e),r):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return i(t)?a.ms2DateTime(t):o.BADNUM},t.d2c=function(t){return i(t)?Number(t):a.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(a.dateTime2ms);!i(t.range[0])&&i(f[0])&&(t.range[0]=f[0]),!i(t.range[1])&&i(f[1])&&(t.range[1]=f[1])}catch(h){console.log(h,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&-1===t._categories.indexOf(e)&&t._categories.push(e);var r=t._categories.indexOf(e);return-1===r?o.BADNUM:r},t.d2l=t.d2c);t.makeCalcdata=function(e,r){var n,i,a;if(r in e)for(n=e[r],i=new Array(n.length),a=0;an?"0":"1.0"}var r=this.framework,n=r.select("g.choroplethlayer"),i=r.select("g.scattergeolayer"),a=this.projection,o=this.path,s=this.clipAngle;r.selectAll("path.basepath").attr("d",o),r.selectAll("path.graticulepath").attr("d",o),n.selectAll("path.choroplethlocation").attr("d",o),n.selectAll("path.basepath").attr("d",o),i.selectAll("path.js-line").attr("d",o),null!==s?(i.selectAll("path.point").style("opacity",e).attr("transform",t),i.selectAll("text").style("opacity",e).attr("transform",t)):(i.selectAll("path.point").attr("transform",t),i.selectAll("text").attr("transform",t))}},{"../../components/color":303,"../../components/drawing":325,"../../constants/geo_constants":362,"../../constants/xmlns_namespaces":366,"../../lib/filter_visible":374,"../../lib/topojson_utils":391,"../../plots/cartesian/axes":399,"./projections":425,"./set_scale":426,"./zoom":427,"./zoom_reset":428,d3:72,topojson:234}],419:[function(t,e,r){"use strict";var n=t("./geo"),i=t("../../plots/plots");r.name="geo",r.attr="geo",r.idRoot="geo",r.idRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"geo");void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var o=0;o=n}function a(t,e){for(var r=e[0],n=e[1],i=!1,a=0,o=t.length,s=o-1;o>a;s=a++){var l=t[a],c=l[0],u=l[1],f=t[s],h=f[0],d=f[1];u>n^d>n&&(h-c)*(n-u)/(d-u)+c>r&&(i=!i)}return i}function o(t){return t>1?L:-1>t?-L:Math.asin(t)}function s(t,e){var r=(2+L)*Math.sin(e);e/=2;for(var n=0,i=1/0;10>n&&Math.abs(i)>M;n++){var a=Math.cos(e);e-=i=(e+Math.sin(e)*(a+2)-r)/(2*a*(1+a))}return[2/Math.sqrt(E*(4+E))*t*(1+Math.cos(e)),2*Math.sqrt(E/(4+E))*Math.sin(e)]}function l(t,e){function r(r,n){var i=R(r/e,n);return i[0]*=t,i}return arguments.length<2&&(e=t),1===e?R:e===1/0?u:(r.invert=function(r,n){var i=R.invert(r/t,n);return i[0]*=e,i},r)}function c(){var t=2,e=P(l),r=e(t);return r.coefficient=function(r){return arguments.length?e(t=+r):t},r}function u(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function f(t,e){return[3*t/(2*E)*Math.sqrt(E*E/3-e*e),e]}function h(t,e){return[t,1.25*Math.log(Math.tan(E/4+.4*e))]}function d(t){return function(e){var r,n=t*Math.sin(e),i=30;do e-=r=(e+Math.sin(e)-n)/(1+Math.cos(e));while(Math.abs(r)>M&&--i>0);return e/2}}function p(t,e,r){function n(r,n){return[t*r*Math.cos(n=i(n)),e*Math.sin(n)]}var i=d(r);return n.invert=function(n,i){var a=o(i/e);return[n/(t*Math.cos(a)),o((2*a+Math.sin(2*a))/r)]},n}function g(t,e){var r=e*e,n=r*r;return[t*(.8707-.131979*r+n*(-.013791+n*(.003971*r-.001529*n))),e*(1.007226+r*(.015085+n*(-.044475+.028874*r-.005916*n)))]}function v(t,e){var r,n=Math.min(18,36*Math.abs(e)/E),i=Math.floor(n),a=n-i,o=(r=I[i])[0],s=r[1],l=(r=I[++i])[0],c=r[1],u=(r=I[Math.min(19,++i)])[0],f=r[1];return[t*(l+a*(u-o)/2+a*a*(u-2*l+o)/2),(e>0?L:-L)*(c+a*(f-s)/2+a*a*(f-2*c+s)/2)]}function m(t,e){return[t*Math.cos(e),e]}i.geo.project=function(t,r){var n=r.stream;if(!n)throw new Error("not yet supported");return(t&&y.hasOwnProperty(t.type)?y[t.type]:e)(t,n)};var y={Feature:t,FeatureCollection:function(e,r){return{type:"FeatureCollection",features:e.features.map(function(e){return t(e,r)})}}},b=[],x=[],_={point:function(t,e){b.push([t,e])},result:function(){var t=b.length?b.length<2?{type:"Point",coordinates:b[0]}:{type:"MultiPoint",coordinates:b}:null;return b=[],t}},w={lineStart:r,point:function(t,e){b.push([t,e])},lineEnd:function(){b.length&&(x.push(b),b=[])},result:function(){var t=x.length?x.length<2?{type:"LineString",coordinates:x[0]}:{type:"MultiLineString",coordinates:x}:null;return x=[],t}},k={polygonStart:r,lineStart:r,point:function(t,e){b.push([t,e])},lineEnd:function(){var t=b.length;if(t){do b.push(b[0].slice());while(++t<4);x.push(b),b=[]}},polygonEnd:r,result:function(){if(!x.length)return null;var t=[],e=[];return x.forEach(function(r){n(r)?t.push([r]):e.push(r)}),e.forEach(function(e){var r=e[0];t.some(function(t){return a(t[0],r)?(t.push(e),!0):void 0})||t.push([e])}),x=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},A={Point:_,MultiPoint:_,LineString:w,MultiLineString:w,Polygon:k,MultiPolygon:k,Sphere:k},M=1e-6,T=M*M,E=Math.PI,L=E/2,S=(Math.sqrt(E),E/180),C=180/E,z=i.geo.projection,P=i.geo.projectionMutator;i.geo.interrupt=function(t){function e(e,r){for(var n=0>r?-1:1,i=l[+(0>r)],a=0,o=i.length-1;o>a&&e>i[a][2][0];++a);var s=t(e-i[a][1][0],r);return s[0]+=t(i[a][1][0],n*r>n*i[a][0][1]?i[a][0][1]:r)[0],s}function r(){s=l.map(function(e){return e.map(function(e){var r,n=t(e[0][0],e[0][1])[0],i=t(e[2][0],e[2][1])[0],a=t(e[1][0],e[0][1])[1],o=t(e[1][0],e[1][1])[1];return a>o&&(r=a,a=o,o=r),[[n,a],[i,o]]})})}function n(){for(var t=1e-6,e=[],r=0,n=l[0].length;n>r;++r){var o=l[0][r],s=180*o[0][0]/E,c=180*o[0][1]/E,u=180*o[1][1]/E,f=180*o[2][0]/E,h=180*o[2][1]/E;e.push(a([[s+t,c+t],[s+t,u-t],[f-t,u-t],[f-t,h+t]],30))}for(var r=l[1].length-1;r>=0;--r){var o=l[1][r],s=180*o[0][0]/E,c=180*o[0][1]/E,u=180*o[1][1]/E,f=180*o[2][0]/E,h=180*o[2][1]/E;e.push(a([[f-t,h-t],[f-t,u+t],[s+t,u+t],[s+t,c-t]],30))}return{type:"Polygon",coordinates:[i.merge(e)]}}function a(t,e){for(var r,n,i,a=-1,o=t.length,s=t[0],l=[];++ac;++c)l.push([s[0]+c*n,s[1]+c*i]);s=r}return l.push(r),l}function o(t,e){return Math.abs(t[0]-e[0])n)],a=l[+(0>n)],c=0,u=i.length;u>c;++c){var f=i[c];if(f[0][0]<=r&&rM&&--i>0);return[t/(.8707+(a=n*n)*(-.131979+a*(-.013791+a*a*a*(.003971-.001529*a)))),n]},(i.geo.naturalEarth=function(){return z(g)}).raw=g;var I=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];I.forEach(function(t){t[1]*=1.0144}),v.invert=function(t,e){var r=e/L,n=90*r,i=Math.min(18,Math.abs(n/5)),a=Math.max(0,Math.floor(i));do{var o=I[a][1],s=I[a+1][1],l=I[Math.min(19,a+2)][1],c=l-o,u=l-2*s+o,f=2*(Math.abs(r)-s)/c,h=u/c,d=f*(1-h*f*(1-2*h*f));if(d>=0||1===a){n=(e>=0?5:-5)*(d+i);var p,g=50;do i=Math.min(18,Math.abs(n)/5),a=Math.floor(i),d=i-a,o=I[a][1],s=I[a+1][1],l=I[Math.min(19,a+2)][1],n-=(p=(e>=0?L:-L)*(s+d*(l-o)/2+d*d*(l-2*s+o)/2)-e)*C;while(Math.abs(p)>T&&--g>0);break}}while(--a>=0);var v=I[a][0],m=I[a+1][0],y=I[Math.min(19,a+2)][0];return[t/(m+d*(y-v)/2+d*d*(y-2*m+v)/2),n*S]},(i.geo.robinson=function(){return z(v)}).raw=v,m.invert=function(t,e){return[t/Math.cos(e),e]},(i.geo.sinusoidal=function(){return z(m)}).raw=m}var i=t("d3");e.exports=n},{d3:72}],426:[function(t,e,r){"use strict";function n(t,e){var r=t.projection,n=t.lonaxis,o=t.lataxis,l=t.domain,c=t.framewidth||0,u=e.w*(l.x[1]-l.x[0]),f=e.h*(l.y[1]-l.y[0]),h=n.range[0]+s,d=n.range[1]-s,p=o.range[0]+s,g=o.range[1]-s,v=n._fullRange[0]+s,m=n._fullRange[1]-s,y=o._fullRange[0]+s,b=o._fullRange[1]-s;r._translate0=[e.l+u/2,e.t+f/2];var x=d-h,_=g-p,w=[h+x/2,p+_/2],k=r._rotate;r._center=[w[0]+k[0],w[1]+k[1]];var A=function(e){function n(t){return Math.min(_*u/(t[1][0]-t[0][0]),_*f/(t[1][1]-t[0][1]))}var o,s,l,x,_=e.scale(),w=r._translate0,k=i(h,p,d,g),A=i(v,y,m,b);l=a(e,k),o=n(l),x=a(e,A),r._fullScale=n(x),e.scale(o),l=a(e,k),s=[w[0]-l[0][0]+c,w[1]-l[0][1]+c],r._translate=s,e.translate(s),l=a(e,k),t._isAlbersUsa||e.clipExtent(l),o=r.scale*o,r._scale=o,t._width=Math.round(l[1][0])+c,t._height=Math.round(l[1][1])+c,t._marginX=(u-Math.round(l[1][0]))/2,t._marginY=(f-Math.round(l[1][1]))/2};return A}function i(t,e,r,n){var i=(r-t)/4;return{type:"Polygon",coordinates:[[[t,e],[t,n],[t+i,n],[t+2*i,n],[t+3*i,n],[r,n],[r,e],[r-i,e],[r-2*i,e],[r-3*i,e],[t,e]]]}}function a(t,e){return o.geo.path().projection(t).bounds(e)}var o=t("d3"),s=t("../../constants/geo_constants").clipPad;e.exports=n},{"../../constants/geo_constants":362,d3:72}],427:[function(t,e,r){"use strict";function n(t,e){var r;return(r=e._isScoped?a:e._clipAngle?s:o)(t,e.projection)}function i(t,e){var r=e._fullScale;return _.behavior.zoom().translate(t.translate()).scale(t.scale()).scaleExtent([.5*r,100*r])}function a(t,e){function r(){_.select(this).style(A)}function n(){o.scale(_.event.scale).translate(_.event.translate),t.render()}function a(){_.select(this).style(M)}var o=t.projection,s=i(o,e);return s.on("zoomstart",r).on("zoom",n).on("zoomend",a),s}function o(t,e){function r(t){return v.invert(t)}function n(t){var e=v(r(t));return Math.abs(e[0]-t[0])>y||Math.abs(e[1]-t[1])>y}function a(){_.select(this).style(A),l=_.mouse(this),c=v.rotate(),u=v.translate(),f=c,h=r(l)}function o(){return d=_.mouse(this),n(l)?(m.scale(v.scale()),void m.translate(v.translate())):(v.scale(_.event.scale),v.translate([u[0],_.event.translate[1]]),h?r(d)&&(g=r(d),p=[f[0]+(g[0]-h[0]),c[1],c[2]],v.rotate(p),f=p):(l=d,h=r(l)),void t.render())}function s(){_.select(this).style(M)}var l,c,u,f,h,d,p,g,v=t.projection,m=i(v,e),y=2;return m.on("zoomstart",a).on("zoom",o).on("zoomend",s),m}function s(t,e){function r(t){m++||t({type:"zoomstart"})}function n(t){t({type:"zoom"})}function a(t){--m||t({type:"zoomend"})}var o,s=t.projection,d={r:s.rotate(),k:s.scale()},p=i(s,e),g=x(p,"zoomstart","zoom","zoomend"),m=0,y=p.on;return p.on("zoomstart",function(){_.select(this).style(A);var t=_.mouse(this),e=s.rotate(),i=e,a=s.translate(),m=c(e);o=l(s,t),y.call(p,"zoom",function(){var r=_.mouse(this);if(s.scale(d.k=_.event.scale),o){if(l(s,r)){s.rotate(e).translate(a);var c=l(s,r),p=f(o,c),y=v(u(m,p)),b=d.r=h(y,o,i);isFinite(b[0])&&isFinite(b[1])&&isFinite(b[2])||(b=i),s.rotate(b),i=b}}else t=r,o=l(s,t);n(g.of(this,arguments))}),r(g.of(this,arguments))}).on("zoomend",function(){_.select(this).style(M),y.call(p,"zoom",null),a(g.of(this,arguments))}).on("zoom.redraw",function(){t.render()}),_.rebind(p,g,"on")}function l(t,e){var r=t.invert(e);return r&&isFinite(r[0])&&isFinite(r[1])&&m(r)}function c(t){var e=.5*t[0]*w,r=.5*t[1]*w,n=.5*t[2]*w,i=Math.sin(e),a=Math.cos(e),o=Math.sin(r),s=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return[a*s*c+i*o*l,i*s*c-a*o*l,a*o*c+i*s*l,a*s*l-i*o*c]}function u(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=e[0],s=e[1],l=e[2],c=e[3];return[r*o-n*s-i*l-a*c,r*s+n*o+i*c-a*l,r*l-n*c+i*o+a*s,r*c+n*l-i*s+a*o]}function f(t,e){if(t&&e){var r=b(t,e),n=Math.sqrt(y(r,r)),i=.5*Math.acos(Math.max(-1,Math.min(1,y(t,e)))),a=Math.sin(i)/n;return n&&[Math.cos(i),r[2]*a,-r[1]*a,r[0]*a]}}function h(t,e,r){var n=g(e,2,t[0]);n=g(n,1,t[1]),n=g(n,0,t[2]-r[2]);var i,a,o=e[0],s=e[1],l=e[2],c=n[0],u=n[1],f=n[2],h=Math.atan2(s,o)*k,p=Math.sqrt(o*o+s*s);Math.abs(u)>p?(a=(u>0?90:-90)-h,i=0):(a=Math.asin(u/p)*k-h,i=Math.sqrt(p*p-u*u));var v=180-a-2*h,m=(Math.atan2(f,c)-Math.atan2(l,i))*k,y=(Math.atan2(f,c)-Math.atan2(l,-i))*k,b=d(r[0],r[1],a,m),x=d(r[0],r[1],v,y);return x>=b?[a,m,r[2]]:[v,y,r[2]]}function d(t,e,r,n){var i=p(r-t),a=p(n-e);return Math.sqrt(i*i+a*a)}function p(t){return(t%360+540)%360-180}function g(t,e,r){var n=r*w,i=t.slice(),a=0===e?1:0,o=2===e?1:2,s=Math.cos(n),l=Math.sin(n);return i[a]=t[a]*s-t[o]*l,i[o]=t[o]*s+t[a]*l,i}function v(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*k,Math.asin(Math.max(-1,Math.min(1,2*(t[0]*t[2]-t[3]*t[1]))))*k,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*k]}function m(t){var e=t[0]*w,r=t[1]*w,n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function y(t,e){for(var r=0,n=0,i=t.length;i>n;++n)r+=t[n]*e[n];return r}function b(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function x(t){for(var e=0,r=arguments.length,n=[];++ed;++d){for(e=c[d],r=t[this.scene[e]._name],n=/Click to enter .+ title/.test(r.title)?"":r.title,p=0;2>=p;p+=2)this.labelEnable[d+p]=!1,this.labels[d+p]=o(n),this.labelColor[d+p]=s(r.titlefont.color),this.labelFont[d+p]=r.titlefont.family,this.labelSize[d+p]=r.titlefont.size,this.labelPad[d+p]=this.getLabelPad(e,r),this.tickEnable[d+p]=!1,this.tickColor[d+p]=s((r.tickfont||{}).color),this.tickAngle[d+p]="auto"===r.tickangle?0:Math.PI*-r.tickangle/180,this.tickPad[d+p]=this.getTickPad(r),this.tickMarkLength[d+p]=0,this.tickMarkWidth[d+p]=r.tickwidth||0,this.tickMarkColor[d+p]=s(r.tickcolor),this.borderLineEnable[d+p]=!1,this.borderLineColor[d+p]=s(r.linecolor),this.borderLineWidth[d+p]=r.linewidth||0;u=this.hasSharedAxis(r),a=this.hasAxisInDfltPos(e,r)&&!u,l=this.hasAxisInAltrPos(e,r)&&!u,i=r.mirror||!1,f=u?-1!==String(i).indexOf("all"):!!i,h=u?"allticks"===i:-1!==String(i).indexOf("ticks"),a?this.labelEnable[d]=!0:l&&(this.labelEnable[d+2]=!0),a?this.tickEnable[d]=r.showticklabels:l&&(this.tickEnable[d+2]=r.showticklabels),(a||f)&&(this.borderLineEnable[d]=r.showline),(l||f)&&(this.borderLineEnable[d+2]=r.showline),(a||h)&&(this.tickMarkLength[d]=this.getTickMarkLength(r)),(l||h)&&(this.tickMarkLength[d+2]=this.getTickMarkLength(r)),this.gridLineEnable[d]=r.showgrid,this.gridLineColor[d]=s(r.gridcolor),this.gridLineWidth[d]=r.gridwidth,this.zeroLineEnable[d]=r.zeroline,this.zeroLineColor[d]=s(r.zerolinecolor),this.zeroLineWidth[d]=r.zerolinewidth}},l.hasSharedAxis=function(t){var e=this.scene,r=a.Plots.getSubplotIds(e.fullLayout,"gl2d"),n=a.Axes.findSubplotsWithAxis(r,t);return 0!==n.indexOf(e.id)},l.hasAxisInDfltPos=function(t,e){var r=e.side;return"xaxis"===t?"bottom"===r:"yaxis"===t?"left"===r:void 0},l.hasAxisInAltrPos=function(t,e){var r=e.side;return"xaxis"===t?"top"===r:"yaxis"===t?"right"===r:void 0},l.getLabelPad=function(t,e){var r=1.5,n=e.titlefont.size,i=e.showticklabels;return"xaxis"===t?"top"===e.side?-10+n*(r+(i?1:0)):-10+n*(r+(i?.5:0)):"yaxis"===t?"right"===e.side?10+n*(r+(i?1:.5)):10+n*(r+(i?.5:0)):void 0},l.getTickPad=function(t){return"outside"===t.ticks?10+t.ticklen:15},l.getTickMarkLength=function(t){if(!t.ticks)return 0;var e=t.ticklen;return"inside"===t.ticks?-e:e},e.exports=i},{"../../lib/html2unicode":377,"../../lib/str2rgbarray":389,"../../plotly":396}],431:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("./scene2d"),a=n.Plots;r.name="gl2d",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex={x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},r.attrRegex={x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},r.attributes=t("../cartesian/attributes"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,n=a.getSubplotIds(e,"gl2d"),o=0;or;++r){var n=t[r],i=e[r];if(n.length!==i.length)return!0;for(var a=0;ao;++o,--s)for(var l=0;r>l;++l)for(var c=0;4>c;++c){var u=i[4*(r*o+l)+c];i[4*(r*o+l)+c]=i[4*(r*s+l)+c],i[4*(r*s+l)+c]=u}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticPlot&&this.container.removeChild(a),p},m.computeTickMarks=function(){this.xaxis._length=this.glplot.viewBox[2]-this.glplot.viewBox[0],this.yaxis._length=this.glplot.viewBox[3]-this.glplot.viewBox[1];for(var t=[s.calcTicks(this.xaxis),s.calcTicks(this.yaxis)],e=0;2>e;++e)for(var r=0;rk;++k)w[k]=Math.min(w[k],a.bounds[k]),w[k+2]=Math.max(w[k+2],a.bounds[k+2])}var A;for(n=0;2>n;++n)w[n]>w[n+2]&&(w[n]=-1,w[n+2]=1),A=this[v[n]],A._length=y.viewBox[n+2]-y.viewBox[n],s.doAutoRange(A);y.ticks=this.computeTickMarks();var M=this.xaxis.range,T=this.yaxis.range;y.dataBox=[M[0],T[0],M[1],T[1]],y.merge(r),o.update(y),this.glplot.draw()},m.draw=function(){if(!this.stopped){requestAnimationFrame(this.redraw);var t=this.glplot,e=this.camera,r=e.mouseListener,n=this.fullLayout;this.cameraChanged();var i=r.x*t.pixelRatio,a=this.canvas.height-t.pixelRatio*r.y;if(e.boxEnabled&&"zoom"===n.dragmode)this.selectBox.enabled=!0,this.selectBox.selectBox=[Math.min(e.boxStart[0],e.boxEnd[0]),Math.min(e.boxStart[1],e.boxEnd[1]),Math.max(e.boxStart[0],e.boxEnd[0]),Math.max(e.boxStart[1],e.boxEnd[1])],t.setDirty();else{this.selectBox.enabled=!1;var o=n._size,s=this.xaxis.domain,c=this.yaxis.domain,u=t.pick(i/t.pixelRatio+o.l+s[0]*o.w,a/t.pixelRatio-(o.t+(1-c[1])*o.h));if(u&&n.hovermode){var f=u.object._trace.handlePick(u);if(f&&(!this.lastPickResult||this.lastPickResult.trace!==f.trace||this.lastPickResult.dataCoord[0]!==f.dataCoord[0]||this.lastPickResult.dataCoord[1]!==f.dataCoord[1])){var h=this.lastPickResult=f;this.spikes.update({center:u.dataCoord}),h.screenCoord=[((t.viewBox[2]-t.viewBox[0])*(u.dataCoord[0]-t.dataBox[0])/(t.dataBox[2]-t.dataBox[0])+t.viewBox[0])/t.pixelRatio,(this.canvas.height-(t.viewBox[3]-t.viewBox[1])*(u.dataCoord[1]-t.dataBox[1])/(t.dataBox[3]-t.dataBox[1])-t.viewBox[1])/t.pixelRatio];var d=h.hoverinfo;if("all"!==d){var p=d.split("+");-1===p.indexOf("x")&&(h.traceCoord[0]=void 0),-1===p.indexOf("y")&&(h.traceCoord[1]=void 0),-1===p.indexOf("z")&&(h.traceCoord[2]=void 0),-1===p.indexOf("text")&&(h.textLabel=void 0),-1===p.indexOf("name")&&(h.name=void 0)}l.loneHover({x:h.screenCoord[0],y:h.screenCoord[1],xLabel:this.hoverFormatter("xaxis",h.traceCoord[0]),yLabel:this.hoverFormatter("yaxis",h.traceCoord[1]),zLabel:h.traceCoord[2],text:h.textLabel,name:h.name,color:h.color},{container:this.svgContainer}),this.lastPickResult={dataCoord:u.dataCoord}}}else!u&&this.lastPickResult&&(this.spikes.update({}),this.lastPickResult=null,l.loneUnhover(this.svgContainer))}t.draw()}},m.hoverFormatter=function(t,e){if(void 0!==e){var r=this[t];return s.tickText(r,r.c2l(e),"hover").text}}},{"../../lib/html2unicode":377,"../../lib/show_no_webgl_msg":387,"../../plots/cartesian/axes":399,"../../plots/cartesian/graph_interact":406,"./camera":429,"./convert":430,"gl-plot2d":124,"gl-select-box":154,"gl-spikes2d":174}],433:[function(t,e,r){"use strict";function n(t,e){t=t||document.body,e=e||{};var r=[.01,1/0];"distanceLimits"in e&&(r[0]=e.distanceLimits[0],r[1]=e.distanceLimits[1]),"zoomMin"in e&&(r[0]=e.zoomMin),"zoomMax"in e&&(r[1]=e.zoomMax);var n=a({center:e.center||[0,0,0],up:e.up||[0,1,0],eye:e.eye||[0,0,10],mode:e.mode||"orbit",distanceLimits:r}),l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0,u=t.clientWidth,f=t.clientHeight,h={keyBindingMode:"rotate",view:n,element:t,delay:e.delay||16,rotateSpeed:e.rotateSpeed||1,zoomSpeed:e.zoomSpeed||1,translateSpeed:e.translateSpeed||1,flipX:!!e.flipX,flipY:!!e.flipY,modes:n.modes,tick:function(){var e=i(),r=this.delay,a=e-2*r;n.idle(e-r),n.recalcMatrix(a),n.flush(e-(100+2*r));for(var o=!0,s=n.computedMatrix,h=0;16>h;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){var e=n.computedUp.slice(),r=n.computedEye.slice(),a=n.computedCenter.slice();if(n.setMode(t),"turntable"===t){var o=i();n._active.lookAt(o,r,a,e),n._active.lookAt(o+500,r,a,[0,0,1]),n._active.flush(o)}return n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s="rotate"===h.keyBindingMode,l="pan"===h.keyBindingMode,u="zoom"===h.keyBindingMode,f=!!o.control,g=!!o.alt,v=!!o.shift,m=!!(1&e),y=!!(2&e),b=!!(4&e),x=1/t.clientHeight,_=x*(r-d),w=x*(a-p),k=h.flipX?1:-1,A=h.flipY?1:-1,M=i(),T=Math.PI*h.rotateSpeed;if((s&&m&&!f&&!g&&!v||m&&!f&&!g&&v)&&n.rotate(M,k*T*_,-A*T*w,0),(l&&m&&!f&&!g&&!v||y||m&&f&&!g&&!v)&&n.pan(M,-h.translateSpeed*_*c,h.translateSpeed*w*c,0),u&&m&&!f&&!g&&!v||b||m&&!f&&g&&!v){var E=-h.zoomSpeed*w/window.innerHeight*(M-n.lastT())*100;n.pan(M,0,0,c*(Math.exp(E)-1))}return d=r,p=a,!0}),s(t,function(t,e){var r=h.flipX?1:-1,a=h.flipY?1:-1,o=i();if(Math.abs(t)>Math.abs(e))n.rotate(o,0,0,-t*r*Math.PI*h.rotateSpeed/window.innerWidth);else{var s=-h.zoomSpeed*a*e/window.innerHeight*(o-n.lastT())/100;n.pan(o,0,0,c*(Math.exp(s)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":39,"mouse-change":200,"mouse-wheel":204,"right-now":214}],434:[function(t,e,r){"use strict";var n=t("./scene"),i=t("../plots"),a=["xaxis","yaxis","zaxis"];r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"gl3d");e._paperdiv.style({width:e.width+"px",height:e.height+"px"}),t._context.setBackground(t,e.paper_bgcolor);for(var o=0;ol;++l){var c=a[l],u=s[c];u._gd=t}}},{"../plots":447,"./layout/attributes":435,"./layout/defaults":439,"./layout/layout_attributes":440,"./scene":444,"./set_convert":445}],435:[function(t,e,r){"use strict";e.exports={scene:{valType:"subplotid",dflt:"scene"}}},{}],436:[function(t,e,r){"use strict";var n=t("../../../components/color"),i=t("../../cartesian/layout_attributes"),a=t("../../../lib/extend").extendFlat;e.exports={showspikes:{valType:"boolean",dflt:!0},spikesides:{valType:"boolean",dflt:!0},spikethickness:{valType:"number",min:0,dflt:2},spikecolor:{valType:"color",dflt:n.defaultLine},showbackground:{valType:"boolean",dflt:!1},backgroundcolor:{valType:"color",dflt:"rgba(204, 204, 204, 0.5)"},showaxeslabels:{valType:"boolean",dflt:!0},color:i.color,categoryorder:i.categoryorder,categoryarray:i.categoryarray,title:i.title,titlefont:i.titlefont,type:i.type,autorange:i.autorange,rangemode:i.rangemode,range:i.range,fixedrange:i.fixedrange,tickmode:i.tickmode,nticks:i.nticks,tick0:i.tick0,dtick:i.dtick,tickvals:i.tickvals,ticktext:i.ticktext,ticks:i.ticks,mirror:i.mirror,ticklen:i.ticklen,tickwidth:i.tickwidth,tickcolor:i.tickcolor,showticklabels:i.showticklabels,tickfont:i.tickfont,tickangle:i.tickangle,tickprefix:i.tickprefix,showtickprefix:i.showtickprefix,ticksuffix:i.ticksuffix,showticksuffix:i.showticksuffix,showexponent:i.showexponent,exponentformat:i.exponentformat,tickformat:i.tickformat,hoverformat:i.hoverformat,showline:i.showline,linecolor:i.linecolor,linewidth:i.linewidth,showgrid:i.showgrid,gridcolor:a({},i.gridcolor,{dflt:"rgb(204, 204, 204)"}),gridwidth:i.gridwidth,zeroline:i.zeroline,zerolinecolor:i.zerolinecolor,zerolinewidth:i.zerolinewidth}},{"../../../components/color":303,"../../../lib/extend":373,"../../cartesian/layout_attributes":408}],437:[function(t,e,r){"use strict";var n=t("tinycolor2").mix,i=t("../../../lib"),a=t("./axis_attributes"),o=t("../../cartesian/axis_defaults"),s=["xaxis","yaxis","zaxis"],l=function(){},c=13600/187;e.exports=function(t,e,r){function u(t,e){return i.coerce(f,h,a,t,e)}for(var f,h,d=0;dr;++r){var n=t[c[r]];e.labels[r]=o(n.title),"titlefont"in n&&(n.titlefont.color&&(e.labelColor[r]=s(n.titlefont.color)),n.titlefont.family&&(e.labelFont[r]=n.titlefont.family),n.titlefont.size&&(e.labelSize[r]=n.titlefont.size)),"showline"in n&&(e.lineEnable[r]=n.showline),"linecolor"in n&&(e.lineColor[r]=s(n.linecolor)),"linewidth"in n&&(e.lineWidth[r]=n.linewidth),"showgrid"in n&&(e.gridEnable[r]=n.showgrid),"gridcolor"in n&&(e.gridColor[r]=s(n.gridcolor)),"gridwidth"in n&&(e.gridWidth[r]=n.gridwidth),"log"===n.type?e.zeroEnable[r]=!1:"zeroline"in n&&(e.zeroEnable[r]=n.zeroline),"zerolinecolor"in n&&(e.zeroLineColor[r]=s(n.zerolinecolor)),"zerolinewidth"in n&&(e.zeroLineWidth[r]=n.zerolinewidth),"ticks"in n&&n.ticks?e.lineTickEnable[r]=!0:e.lineTickEnable[r]=!1,"ticklen"in n&&(e.lineTickLength[r]=e._defaultLineTickLength[r]=n.ticklen),"tickcolor"in n&&(e.lineTickColor[r]=s(n.tickcolor)),"tickwidth"in n&&(e.lineTickWidth[r]=n.tickwidth),"tickangle"in n&&(e.tickAngle[r]="auto"===n.tickangle?0:Math.PI*-n.tickangle/180),"showticklabels"in n&&(e.tickEnable[r]=n.showticklabels),"tickfont"in n&&(n.tickfont.color&&(e.tickColor[r]=s(n.tickfont.color)),n.tickfont.family&&(e.tickFont[r]=n.tickfont.family),n.tickfont.size&&(e.tickSize[r]=n.tickfont.size)),"mirror"in n?-1!==["ticks","all","allticks"].indexOf(n.mirror)?(e.lineTickMirror[r]=!0,e.lineMirror[r]=!0):n.mirror===!0?(e.lineTickMirror[r]=!1,e.lineMirror[r]=!0):(e.lineTickMirror[r]=!1,e.lineMirror[r]=!1):e.lineMirror[r]=!1,"showbackground"in n&&n.showbackground!==!1?(e.backgroundEnable[r]=!0,e.backgroundColor[r]=s(n.backgroundcolor)):e.backgroundEnable[r]=!1}},e.exports=i},{"../../../lib/html2unicode":377,"../../../lib/str2rgbarray":389,arraytools:49}],439:[function(t,e,r){"use strict";function n(t,e,r,n){for(var a=r("bgcolor"),l=i.combine(a,n.paper_bgcolor),c=Object.keys(o.camera),u=0;ue;++e){var r=t[o[e]];this.enabled[e]=r.showspikes,this.colors[e]=a(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness}},e.exports=i},{"../../../lib/str2rgbarray":389}],442:[function(t,e,r){"use strict";function n(t){for(var e=new Array(3),r=0;3>r;++r){for(var n=t[r],i=new Array(n.length),a=0;au;++u){var f=i[s[u]];if(f._length=(r[u].hi-r[u].lo)*r[u].pixelsPerDataUnit/t.dataScale[u],Math.abs(f._length)===1/0)c[u]=[];else{f.range[0]=r[u].lo/t.dataScale[u],f.range[1]=r[u].hi/t.dataScale[u],f._m=1/(t.dataScale[u]*r[u].pixelsPerDataUnit),f.range[0]===f.range[1]&&(f.range[0]-=1,f.range[1]+=1);var h=f.tickmode;if("auto"===f.tickmode){f.tickmode="linear";var d=f.nticks||a.Lib.constrain(f._length/40,4,9);a.Axes.autoTicks(f,Math.abs(f.range[1]-f.range[0])/d)}for(var p=a.Axes.calcTicks(f),g=0;gu;++u){l[u]=.5*(t.glplot.bounds[0][u]+t.glplot.bounds[1][u]);for(var g=0;2>g;++g)e.bounds[g][u]=t.glplot.bounds[g][u]}t.contourLevels=n(c)}e.exports=i;var a=t("../../../plotly"),o=t("../../../lib/html2unicode"),s=["xaxis","yaxis","zaxis"],l=[0,0,0]},{"../../../lib/html2unicode":377,"../../../plotly":396}],443:[function(t,e,r){"use strict";function n(t,e){var r,n,i=[0,0,0,0];for(r=0;4>r;++r)for(n=0;4>n;++n)i[n]+=t[4*r+n]*e[r];return i}function i(t,e){var r=n(t.projection,n(t.view,n(t.model,[e[0],e[1],e[2],1])));return r}e.exports=i},{}],444:[function(t,e,r){"use strict";function n(t){function e(e,r){if("string"==typeof r)return r;var n=t.fullSceneLayout[e];return d.tickText(n,n.c2l(r),"hover").text}var r=t.svgContainer,n=t.container.getBoundingClientRect(),i=n.width,a=n.height;r.setAttributeNS(null,"viewBox","0 0 "+i+" "+a),r.setAttributeNS(null,"width",i),r.setAttributeNS(null,"height",a),w(t),t.glplot.axes.update(t.axesOptions);for(var o=Object.keys(t.traces),s=null,l=t.glplot.selection,c=0;ca;++a){var u=l[A[a]];b(u)}t?Array.isArray(t)||(t=[t]):t=[];for(var f=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],a=0;ao;++o)f[0][o]>f[1][o]?d[o]=1:f[1][o]===f[0][o]?d[o]=1:d[o]=1/(f[1][o]-f[0][o]);this.dataScale=d;for(var a=0;aa;++a){var u=l[A[a]],_=u.type;if(_ in x?(x[_].acc*=d[a],x[_].count+=1):x[_]={acc:d[a],count:1},u.autorange){for(m[0][a]=1/0,m[1][a]=-(1/0),o=0;om[1][a])m[0][a]=-1,m[1][a]=1;else{var k=m[1][a]-m[0][a];m[0][a]-=k/32,m[1][a]+=k/32}}else{var M=l[A[a]].range;m[0][a]=M[0],m[1][a]=M[1]}m[0][a]===m[1][a]&&(m[0][a]-=1,m[1][a]+=1),y[a]=m[1][a]-m[0][a],this.glplot.bounds[0][a]=m[0][a]*d[a],this.glplot.bounds[1][a]=m[1][a]*d[a]}for(var T=[1,1,1],a=0;3>a;++a){var u=l[A[a]],_=u.type,E=x[_];T[a]=Math.pow(E.acc,1/E.count)/d[a]}var L,S=4;if("auto"===l.aspectmode)L=Math.max.apply(null,T)/Math.min.apply(null,T)<=S?T:[1,1,1];else if("cube"===l.aspectmode)L=[1,1,1];else if("data"===l.aspectmode)L=T;else{if("manual"!==l.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var C=l.aspectratio;L=[C.x,C.y,C.z]}l.aspectratio.x=c.aspectratio.x=L[0],l.aspectratio.y=c.aspectratio.y=L[1],l.aspectratio.z=c.aspectratio.z=L[2],this.glplot.aspect=L;var z=l.domain||null,P=e._size||null;if(z&&P){var R=this.container.style;R.position="absolute",R.left=P.l+z.x[0]*P.w+"px",R.top=P.t+(1-z.y[1])*P.h+"px",R.width=P.w*(z.x[1]-z.x[0])+"px",R.height=P.h*(z.y[1]-z.y[0])+"px"}this.glplot.redraw()}},k.destroy=function(){this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null},k.setCameraToDefault=function(){this.setCamera({eye:{x:1.25,y:1.25,z:1.25},center:{x:0,y:0,z:0},up:{x:0,y:0,z:1}})},k.getCamera=function(){this.glplot.camera.view.recalcMatrix(this.camera.view.lastT());var t=this.glplot.camera.up,e=this.glplot.camera.center,r=this.glplot.camera.eye;return{up:{x:t[0],y:t[1],z:t[2]},center:{x:e[0],y:e[1],z:e[2]},eye:{x:r[0],y:r[1],z:r[2]}}},k.setCamera=function(t){function e(t){return[[t.eye.x,t.eye.y,t.eye.z],[t.center.x,t.center.y,t.center.z],[t.up.x,t.up.y,t.up.z]]}var r={};r[this.id]=t,this.glplot.camera.lookAt.apply(this,e(t)),this.graphDiv.emit("plotly_relayout",r)},k.saveCamera=function(t){function e(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return t[i[r]][a[n]]===e[i[r]][a[n]]}var r=this.getCamera(),n=f.nestedProperty(t,this.id+".camera"),i=n.get(),a=!1;if(void 0===i)a=!0;else for(var o=0;3>o;o++)for(var s=0;3>s;s++)if(!e(r,i,o,s)){a=!0;break}return a&&n.set(r),a},k.updateFx=function(t,e){var r=this.camera;r&&("orbit"===t?(r.mode="orbit",r.keyBindingMode="rotate"):"turntable"===t?(r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate"):r.keyBindingMode=t),this.fullSceneLayout.hovermode=e},k.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(l),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,n=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var i=new Uint8Array(r*n*4);e.readPixels(0,0,r,n,e.RGBA,e.UNSIGNED_BYTE,i);for(var a=0,o=n-1;o>a;++a,--o)for(var s=0;r>s;++s)for(var c=0;4>c;++c){var u=i[4*(r*a+s)+c];i[4*(r*a+s)+c]=i[4*(r*o+s)+c],i[4*(r*o+s)+c]=u}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticMode&&this.container.removeChild(l),p},e.exports=a},{"../../lib":378,"../../lib/show_no_webgl_msg":387,"../../lib/str2rgbarray":389,"../../plots/cartesian/axes":399,"../../plots/cartesian/graph_interact":406,"../../plots/plots":447,"./camera":433,"./layout/convert":438,"./layout/spikes":441,"./layout/tick_marks":442,"./project":443,"./set_convert":445,"gl-plot3d":142}],445:[function(t,e,r){"use strict";var n=t("../cartesian/axes"),i=function(){};e.exports=function(t){n.setConvert(t),t.setScale=i}},{"../cartesian/axes":399}],446:[function(t,e,r){"use strict";var n=t("../plotly"),i=t("./font_attributes"),a=t("../components/color/attributes"),o=n.Lib.extendFlat;e.exports={font:{family:o({},i.family,{dflt:'"Open Sans", verdana, arial, sans-serif'}),size:o({},i.size,{dflt:12}),color:o({},i.color,{dflt:a.defaultLine})},title:{valType:"string",dflt:"Click to enter Plot title"},titlefont:o({},i,{}),autosize:{valType:"enumerated",values:[!0,!1,"initial"]},width:{valType:"number",min:10,dflt:700},height:{valType:"number",min:10,dflt:450},margin:{l:{valType:"number",min:0,dflt:80},r:{valType:"number",min:0,dflt:80},t:{valType:"number",min:0,dflt:100},b:{valType:"number",min:0,dflt:80},pad:{valType:"number",min:0,dflt:0},autoexpand:{valType:"boolean",dflt:!0}},paper_bgcolor:{valType:"color",dflt:a.background},plot_bgcolor:{valType:"color",dflt:a.background},separators:{valType:"string",dflt:".,"},hidesources:{valType:"boolean",dflt:!1},smith:{valType:"enumerated",values:[!1],dflt:!1},showlegend:{valType:"boolean"},_hasCartesian:{valType:"boolean",dflt:!1},_hasGL3D:{valType:"boolean",dflt:!1},_hasGeo:{valType:"boolean",dflt:!1},_hasPie:{valType:"boolean",dflt:!1},_hasGL2D:{ -valType:"boolean",dflt:!1},_hasTernary:{valType:"boolean",dflt:!1},_composedModules:{"*":"Fx"},_nestedModules:{xaxis:"Axes",yaxis:"Axes",scene:"gl3d",geo:"geo",legend:"Legend",annotations:"Annotations",shapes:"Shapes",ternary:"ternary"}}},{"../components/color/attributes":302,"../plotly":396,"./font_attributes":417}],447:[function(t,e,r){"use strict";function n(t){return"object"==typeof t&&(t=t.type),t}function i(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#","class":"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){f.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}function a(t,e){for(var r,n=Object.keys(e),i=0;i=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var s=r.select(".js-link-to-tool"),l=r.select(".js-link-spacer"),c=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&i(t,s),l.text(s.text()&&c.text()?" - ":"")},f.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",r=o.select(t).append("div").attr("id","hiddenform").style("display","none"),n=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),i=n.append("input").attr({type:"text",name:"data"});return i.node().value=f.graphJson(t,!1,"keepdata"),n.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1},f.supplyDefaults=function(t){var e,r,n,i,o,s,c=t._fullLayout||{},u=t._fullLayout={},h=t.layout||{},d=t._fullData||[],p=t._fullData=[],g=t.data||[],v=t._modules=[];for(f.supplyLayoutGlobalDefaults(h,u),u._dataLength=g.length,e=0;ea&&(e=(r-1)/(i.l+i.r),i.l=Math.floor(e*i.l),i.r=Math.floor(e*i.r)),0>o&&(e=(n-1)/(i.t+i.b),i.t=Math.floor(e*i.t),i.b=Math.floor(e*i.b))}},f.autoMargin=function(t,e,r){var n=t._fullLayout;if(n._pushmargin||(n._pushmargin={}),n.margin.autoexpand!==!1){if(r){var i=void 0===r.pad?12:r.pad;r.l+r.r>.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0),n._pushmargin[e]={l:{val:r.x,size:r.l+i},r:{val:r.x,size:r.r+i},b:{val:r.y,size:r.b+i},t:{val:r.y,size:r.t+i}}}else delete n._pushmargin[e];t._replotting||f.doAutoMargin(t)}},f.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var r=e._size,n=JSON.stringify(r),i=Math.max(e.margin.l||0,0),a=Math.max(e.margin.r||0,0),o=Math.max(e.margin.t||0,0),c=Math.max(e.margin.b||0,0),u=e._pushmargin;return e.margin.autoexpand!==!1&&(u.base={l:{val:0,size:i},r:{val:1,size:a},t:{val:1,size:o},b:{val:0,size:c}},Object.keys(u).forEach(function(t){var r=u[t].l||{},n=u[t].b||{},l=r.val,f=r.size,h=n.val,d=n.size;Object.keys(u).forEach(function(t){if(s(f)&&u[t].r){var r=u[t].r.val,n=u[t].r.size;if(r>l){var p=(f*r+(n-e.width)*l)/(r-l),g=(n*(1-l)+(f-e.width)*(1-r))/(r-l);p>=0&&g>=0&&p+g>i+a&&(i=p,a=g)}}if(s(d)&&u[t].t){var v=u[t].t.val,m=u[t].t.size;if(v>h){var y=(d*v+(m-e.height)*h)/(v-h),b=(m*(1-h)+(d-e.height)*(1-v))/(v-h);y>=0&&b>=0&&y+b>c+o&&(c=y,o=b)}}})})),r.l=Math.round(i),r.r=Math.round(a),r.t=Math.round(o),r.b=Math.round(c),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,t._replotting||"{}"===n||n===JSON.stringify(e._size)?void 0:l.plot(t)},f.graphJson=function(t,e,r,n,i){function a(t){if("function"==typeof t)return null;if(c.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0&&!c.isPlainObject(t.stream))continue}else if("keepall"!==r&&(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0))continue;i[e]=a(t[e])}return i}return Array.isArray(t)?t.map(a):t&&t.getTime?c.ms2DateTime(t):t}(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&f.supplyDefaults(t);var o=i?t._fullData:t.data,s=i?t._fullLayout:t.layout,l={data:(o||[]).map(function(t){var r=a(t);return e&&delete r.fit,r})};return e||(l.layout=a(s)),t.framework&&t.framework.isPolar&&(l=t.framework.getConfig()),"object"===n?l:JSON.stringify(l)}},{"../components/color":303,"../lib":378,"../plotly":396,"./attributes":397,"./font_attributes":417,"./layout_attributes":446,d3:72,"fast-isnumeric":76}],448:[function(t,e,r){"use strict";var n=t("../../traces/scatter/attributes"),i=n.marker;e.exports={r:n.r,t:n.t,marker:{color:i.color,size:i.size,symbol:i.symbol,opacity:i.opacity}}},{"../../traces/scatter/attributes":546}],449:[function(t,e,r){"use strict";function n(t,e){var r={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return a({},e,r)}var i=t("../cartesian/layout_attributes"),a=t("../../lib/extend").extendFlat,o=a({},i.domain,{});e.exports={radialaxis:n("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:o,orientation:{valType:"number"}}),angularaxis:n("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:o}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":373,"../cartesian/layout_attributes":408}],450:[function(t,e,r){var n=t("../../plotly"),i=t("d3"),a=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},o=n.Lib.extendDeepAll;a.Axis=function(){function t(t){r=t||r;var c=l.data,f=l.layout;return("string"==typeof r||r.nodeName)&&(r=i.select(r)),r.datum(c).each(function(t,r){function l(t,e){return s(t)%360+f.orientation}var c=t.slice();u={data:a.util.cloneJson(c),layout:a.util.cloneJson(f)};var h=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[h],h=(h+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:i.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var d=c.filter(function(t,e){var r=t.visible;return"undefined"==typeof r||r===!0}),p=!1,g=d.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=i.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var r=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,n){t.yStack=[r],m.push(r),r=a.util.sumArrays(t.r,r)}),t.values});d=i.merge(y)}d.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var b=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;b=Math.max(10,b);var x,_=[f.margin.left+b,f.margin.top+b];if(p){var w=i.max(a.util.sumArrays(a.util.arrayLast(d).r[0],a.util.arrayLast(m)));x=[0,w]}else x=i.extent(a.util.flattenArray(d.map(function(t,e){return t.r})));f.radialAxis.domain!=a.DATAEXTENT&&(x[0]=0),n=i.scale.linear().domain(f.radialAxis.domain!=a.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:x).range([0,b]),u.layout.radialAxis.domain=n.domain();var k,A=a.util.flattenArray(d.map(function(t,e){return t.t})),M="string"==typeof A[0];M&&(A=a.util.deduplicate(A),k=A.slice(),A=i.range(A.length),d=d.map(function(t,e){var r=t;return t.t=[A],p&&(r.yStack=t.yStack),r}));var T=d.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===d.length,E=null===f.needsEndSpacing?M||!T:f.needsEndSpacing,L=f.angularAxis.domain&&f.angularAxis.domain!=a.DATAEXTENT&&!M&&f.angularAxis.domain[0]>=0,S=L?f.angularAxis.domain:i.extent(A),C=Math.abs(A[1]-A[0]);T&&!M&&(C=0);var z=S.slice();E&&M&&(z[1]+=C);var P=f.angularAxis.ticksCount||4;P>8&&(P=P/(P/8)+P%8),f.angularAxis.ticksStep&&(P=(z[1]-z[0])/P);var R=f.angularAxis.ticksStep||(z[1]-z[0])/(P*(f.minorTicks+1));k&&(R=Math.max(Math.round(R),1)),z[2]||(z[2]=R);var O=i.range.apply(this,z);if(O=O.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=i.scale.linear().domain(z.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=s.domain(),u.layout.angularAxis.endPadding=E?C:0,e=i.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var I="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",N=(new DOMParser).parseFromString(I,"application/xml"),j=this.appendChild(this.ownerDocument.importNode(N.documentElement,!0));e=i.select(j)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var F,D=e.select(".chart-group"),B={fill:"none",stroke:f.tickColor},U={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){F=e.select(".legend-group").attr({transform:"translate("+[b,f.margin.top]+")"}).style({display:"block"});var V=d.map(function(t,e){var r=a.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});a.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:o({},a.Legend.defaultConfig().legendConfig,{container:F,elements:V,reverseOrder:f.legend.reverseOrder})})();var q=F.node().getBBox();b=Math.min(f.width-q.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,b=Math.max(10,b),_=[f.margin.left+b,f.margin.top+b],n.range([0,b]),u.layout.radialAxis.domain=n.domain(),F.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else F=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),D.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(f.width-(f.margin.left+f.margin.right+2*b+(q?q.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*b))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),e.select(".outer-group").attr("transform","translate("+H+")"),f.title){var G=e.select("g.title-group text").style(U).text(f.title),Y=G.node().getBBox();G.attr({x:_[0]-Y.width/2,y:_[1]-b-20})}var X=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var W=X.selectAll("circle.grid-circle").data(n.ticks(5));W.enter().append("circle").attr({"class":"grid-circle"}).style(B),W.attr("r",n),W.exit().remove()}X.select("circle.outside-circle").attr({r:b}).style(B);var Z=e.select("circle.background-circle").attr({r:b}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var K=i.svg.axis().scale(n).ticks(5).tickSize(5);X.call(K).attr({transform:"rotate("+f.radialAxis.orientation+")"}),X.selectAll(".domain").style(B),X.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(U).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,U["font-size"]]+")":"translate("+[0,U["font-size"]]+")"}}),X.selectAll("g>line").style({stroke:"black"})}var Q=e.select(".angular.axis-group").selectAll("g.angular-tick").data(O),$=Q.enter().append("g").classed("angular-tick",!0);Q.attr({transform:function(t,e){return"rotate("+l(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),Q.exit().remove(),$.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(B),$.selectAll(".minor").style({stroke:f.minorTickColor}),Q.select("line.grid-line").attr({x1:f.tickLength?b-f.tickLength:0,x2:b}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),$.append("text").classed("axis-text",!0).style(U);var J=Q.select("text.axis-text").attr({x:b+f.labelOffset,dy:".35em",transform:function(t,e){var r=l(t,e),n=b+f.labelOffset,i=f.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?270>r&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(180>=r&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(U);f.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=i.max(D.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));F.attr({transform:"translate("+[b+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,rt=e.select("g.geometry-group").selectAll("g.geometry").data(d);if(rt.enter().append("g").attr({"class":function(t,e){return"geometry geometry"+e}}),rt.exit().remove(),d[0]||et){var nt=[];d.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=s,r.container=rt.filter(function(t,r){return r==e}),r.geometry=t.geometry,r.orientation=f.orientation,r.direction=f.direction,r.index=e,nt.push({data:t,geometryConfig:r})});var it=i.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(nt),at=[];it.forEach(function(t,e){"unstacked"===t.key?at=at.concat(t.values.map(function(t,e){return[t]})):at.push(t.values)}),at.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return o(a[r].defaultConfig(),t)});a[r]().config(n)()})}var ot,st,lt=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=a.tooltipPanel().config({container:ct,fontSize:8})(),ft=a.tooltipPanel().config({container:ct,fontSize:8})(),ht=a.tooltipPanel().config({container:ct,hasTick:!0})();if(!M){var dt=lt.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});D.on("mousemove.angular-guide",function(t,e){var r=a.util.getMousePos(Z).angle;dt.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-f.orientation)%360;ot=s.invert(n);var i=a.util.convertToCartesian(b+12,r+180);ut.text(a.util.round(ot)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){lt.select("line").style({opacity:0})})}var pt=lt.select("circle").style({stroke:"grey",fill:"none"});D.on("mousemove.radial-guide",function(t,e){var r=a.util.getMousePos(Z).radius;pt.attr({r:r}).style({opacity:.5}),st=n.invert(a.util.getMousePos(Z).radius);var i=a.util.convertToCartesian(r,f.radialAxis.orientation);ft.text(a.util.round(st)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),ht.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,r){var n=i.select(this),o=n.style("fill"),s="black",l=n.style("opacity")||1;if(n.attr({"data-opacity":l}),"none"!=o){n.attr({"data-fill":o}),s=i.hsl(o).darker().toString(),n.style({fill:s,opacity:1});var c={t:a.util.round(t[0]),r:a.util.round(t[1])};M&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),h=e.node().getBoundingClientRect(),d=[f.left+f.width/2-H[0]-h.left,f.top+f.height/2-H[1]-h.top];ht.config({color:s}).text(u),ht.move(d)}else o=n.style("stroke"),n.attr({"data-stroke":o}),s=i.hsl(o).darker().toString(),n.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0!=i.event.which?!1:void(i.select(this).attr("data-fill")&&ht.show())}).on("mouseout.tooltip",function(t,e){ht.hide();var r=i.select(this),n=r.attr("data-fill");n?r.style({fill:n,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})}),h}var e,r,n,s,l={data:[],layout:{}},c={},u={},f=i.dispatch("hover"),h={};return h.render=function(e){return t(e),this},h.config=function(t){if(!arguments.length)return l;var e=a.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),o(l.data[e],a.Axis.defaultConfig().data[0]),o(l.data[e],t)}),o(l.layout,a.Axis.defaultConfig().layout),o(l.layout,e.layout),this},h.getLiveConfig=function(){return u},h.getinputConfig=function(){return c},h.radialScale=function(t){return n},h.angularScale=function(t){return s},h.svg=function(){return e},i.rebind(h,f,"on"),h},a.Axis.defaultConfig=function(t,e){var r={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:i.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return r},a.util={},a.DATAEXTENT="dataExtent",a.AREA="AreaChart",a.LINE="LinePlot",a.DOT="DotPlot",a.BAR="BarChart",a.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},a.util._extend=function(t,e){for(var r in t)e[r]=t[r]},a.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},a.util.dataFromEquation2=function(t,e){var r=e||6,n=i.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180,i=t(n);return[e,i]});return n},a.util.dataFromEquation=function(t,e,r){var n=e||6,a=[],o=[];i.range(0,360+n,n).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},a.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return i.range(e).map(function(t,e){return r[e]||r[0]})},a.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=a.util.ensureArray(t[e],r)}),t},a.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},a.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},a.util.sumArrays=function(t,e){return i.zip(t,e).map(function(t,e){return i.sum(t)})},a.util.arrayLast=function(t){return t[t.length-1]},a.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},a.util.flattenArray=function(t){for(var e=[];!a.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},a.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},a.util.convertToCartesian=function(t,e){var r=e*Math.PI/180,n=t*Math.cos(r),i=t*Math.sin(r);return[n,i]},a.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},a.util.getMousePos=function(t){var e=i.mouse(t.node()),r=e[0],n=e[1],a={};return a.x=r,a.y=n,a.pos=e,a.angle=180*(Math.atan2(n,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+n*n),a},a.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;a>i;i++)e=t[i],e in r?(r[e]++,n[e]=r[e]):r[e]=1;return n},a.util.duplicates=function(t){return Object.keys(a.util.duplicatesCount(t))},a.util.translator=function(t,e,r,n){if(n){var i=r.slice();r=e,e=i}var a=e.reduce(function(t,e){return"undefined"!=typeof t?t[e]:void 0},t);"undefined"!=typeof a&&(e.reduce(function(t,r,n){return"undefined"!=typeof t?(n===e.length-1&&delete t[r],t[r]):void 0},t),r.reduce(function(t,e,n){return"undefined"==typeof t[e]&&(t[e]={}),n===r.length-1&&(t[e]=a),t[e]},t))},a.PolyChart=function(){function t(){var t=r[0].geometryConfig,e=t.container;"string"==typeof e&&(e=i.select(e)),e.datum(r).each(function(e,r){function n(e,r){var n=t.radialScale(e[1]),i=(t.angularScale(e[0])+t.orientation)*Math.PI/180;return{r:n,t:i}}function a(t){var e=t.r*Math.cos(t.t),r=t.r*Math.sin(t.t);return{x:e,y:r}}var o=!!e[0].data.yStack,l=e.map(function(t,e){return o?i.zip(t.data.t[0],t.data.r[0],t.data.yStack[0]):i.zip(t.data.t[0],t.data.r[0])}),c=t.angularScale,u=t.radialScale.domain()[0],f={};f.bar=function(r,n,a){var o=e[a].data,s=t.radialScale(r[1])-t.radialScale(0),l=t.radialScale(r[2]||0),u=o.barWidth;i.select(this).attr({"class":"mark bar",d:"M"+[[s+l,-u/2],[s+l,u/2],[l,u/2],[l,-u/2]].join("L")+"Z",transform:function(e,r){return"rotate("+(t.orientation+c(e[0]))+")"}})},f.dot=function(t,r,o){var s=t[2]?[t[0],t[1]+t[2]]:t,l=i.svg.symbol().size(e[o].data.dotSize).type(e[o].data.dotType)(t,r);i.select(this).attr({"class":"mark dot",d:l,transform:function(t,e){var r=a(n(s));return"translate("+[r.x,r.y]+")"}})};var h=i.svg.line.radial().interpolate(e[0].data.lineInterpolation).radius(function(e){return t.radialScale(e[1])}).angle(function(e){return t.angularScale(e[0])*Math.PI/180});f.line=function(r,n,a){var o=r[2]?l[a].map(function(t,e){return[t[0],t[1]+t[2]]}):l[a];if(i.select(this).each(f.dot).style({opacity:function(t,r){return+e[a].data.dotVisible},fill:v.stroke(r,n,a)}).attr({"class":"mark dot"}),!(n>0)){var s=i.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({"class":"line",d:h(o),transform:function(e,r){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(r,n,a)},"fill-opacity":0,stroke:function(t,e){return v.stroke(r,n,a)},"stroke-width":function(t,e){return v["stroke-width"](r,n,a)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](r,n,a)},opacity:function(t,e){return v.opacity(r,n,a)},display:function(t,e){return v.display(r,n,a)}})}};var d=t.angularScale.range(),p=Math.abs(d[1]-d[0])/l[0].length*Math.PI/180,g=i.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,r,n){i.select(this).attr({"class":"mark arc",d:g,transform:function(e,r){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var v={fill:function(t,r,n){return e[n].data.color},stroke:function(t,r,n){return e[n].data.strokeColor},"stroke-width":function(t,r,n){return e[n].data.strokeSize+"px"},"stroke-dasharray":function(t,r,n){return s[e[n].data.strokeDash]},opacity:function(t,r,n){return e[n].data.opacity},display:function(t,r,n){return"undefined"==typeof e[n].data.visible||e[n].data.visible?"block":"none"}},m=i.select(this).selectAll("g.layer").data(l);m.enter().append("g").attr({"class":"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({"class":"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,r=[a.PolyChart.defaultConfig()],n=i.dispatch("hover"),s={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){r[e]||(r[e]={}),o(r[e],a.PolyChart.defaultConfig()),o(r[e],t)}),this):r},t.getColorScale=function(){return e},i.rebind(t,n,"on"),t},a.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:i.scale.category20()}};return t},a.BarChart=function(){return a.PolyChart()},a.BarChart.defaultConfig=function(){var t={ -geometryConfig:{geometryType:"bar"}};return t},a.AreaChart=function(){return a.PolyChart()},a.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},a.DotPlot=function(){return a.PolyChart()},a.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},a.LinePlot=function(){return a.PolyChart()},a.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},a.Legend=function(){function t(){var r=e.legendConfig,n=e.data.map(function(t,e){return[].concat(t).map(function(t,n){var i=o({},r.elements[e]);return i.name=t,i.color=[].concat(r.elements[e].color)[n],i})}),a=i.merge(n);a=a.filter(function(t,e){return r.elements[e]&&(r.elements[e].visibleInLegend||"undefined"==typeof r.elements[e].visibleInLegend)}),r.reverseOrder&&(a=a.reverse());var s=r.container;("string"==typeof s||s.nodeName)&&(s=i.select(s));var l=a.map(function(t,e){return t.color}),c=r.fontSize,u=null==r.isContinuous?"number"==typeof a[0]:r.isContinuous,f=u?r.height:c*a.length,h=s.classed("legend-group",!0),d=h.selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=i.range(a.length),v=i.scale[u?"linear":"ordinal"]().domain(g).range(l),m=i.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var r=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=i.svg.symbolTypes.indexOf(t)?i.svg.symbol().type(t).size(r)():i.svg.symbol().type("square").size(r)()};if(u){var b=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);b.enter().append("stop"),b.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:r.height,width:r.colorBandWidth,fill:"url(#grad1)"})}else{var x=d.select(".legend-marks").selectAll("path.legend-mark").data(a);x.enter().append("path").classed("legend-mark",!0),x.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var r=t.symbol;return y(r,c)},fill:function(t,e){return v(e)}}),x.exit().remove()}var _=i.svg.axis().scale(m).orient("right"),w=d.select("g.legend-axis").attr({transform:"translate("+[u?r.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?r.textColor:"none"}),w.selectAll("text").style({fill:r.textColor,"font-size":r.fontSize}).text(function(t,e){return a[e].name}),t}var e=a.Legend.defaultConfig(),r=i.dispatch("hover");return t.config=function(t){return arguments.length?(o(e,t),this):e},i.rebind(t,r,"on"),t},a.Legend.defaultConfig=function(t,e){var r={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return r},a.tooltipPanel=function(){var t,e,r,n={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+a.tooltipPanel.uid++,l=10,c=function(){t=n.container.selectAll("g."+s).data([0]);var i=t.enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=i.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=i.append("text").attr({dx:n.padding+l,dy:.3*+n.fontSize}),c};return c.text=function(a){var o=i.hsl(n.color).l,s=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":n.fontSize+"px"}).text(f);var h=n.padding,d=e.node().getBBox(),p={fill:n.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[n.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),c},c.move=function(e){return t?(t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c):void 0},c.hide=function(){return t?(t.style({display:"none"}),c):void 0},c.show=function(){return t?(t.style({display:"block"}),c):void 0},c.config=function(t){return o(n,t),c},c},a.tooltipPanel.uid=1,a.adapter={},a.adapter.plotly=function(){var t={};return t.convert=function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=o({},t),i=[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]];return i.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",n.dotVisible===!0?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var n=a.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var i=n.indexOf(t.geometry);-1!=i&&(r.data[e].groupId=i)})}if(t.layout){var s=o({},t.layout),l=[[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]];if(l.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};i.entries(s.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),s.margin=f}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r},t}},{"../../plotly":396,"./micropolar_manager":451,d3:72}],451:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("d3"),a=t("./undo_manager"),o=e.exports={},s=n.Lib.extendDeepAll;o.framework=function(t){function e(e,a){return a&&(f=a),i.select(i.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),r=r?s(r,e):e,c||(c=n.micropolar.Axis()),u=n.micropolar.adapter.plotly().convert(r),c.config(u).render(f),t.data=r.data,t.layout=r.layout,o.fillLayout(t),r}var r,l,c,u,f,h=new a;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return r},e.getLiveConfig=function(){return n.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=n.micropolar.util.cloneJson(r);!function(e,r){h.add({undo:function(){r&&t(r)},redo:function(){t(e)}})}(e,l),l=n.micropolar.util.cloneJson(e)},e.undo=function(){h.undo()},e.redo=function(){h.redo()},e},o.fillLayout=function(t){var e=i.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:n.Color.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../plotly":396,"./undo_manager":452,d3:72}],452:[function(t,e,r){"use strict";e.exports=function(){function t(t,e){return t?(i=!0,t[e](),i=!1,this):this}var e,r=[],n=-1,i=!1;return{add:function(t){return i?this:(r.splice(n+1,r.length-n),r.push(t),n=r.length-1,this)},setCallback:function(t){e=t},undo:function(){var i=r[n];return i?(t(i,"undo"),n-=1,e&&e(i.undo),this):this},redo:function(){var i=r[n+1];return i?(t(i,"redo"),n+=1,e&&e(i.redo),this):this},clear:function(){r=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return ng;g++){var v=d[g];s=t[v]?t[v]:t[v]={},e[v]=l={},o("domain."+h,[g/p,(g+1)/p]),o("domain."+{x:"y",y:"x"}[h]),a.id=v,f(s,l,o,a)}}},{"../lib":378,"./plots":447}],454:[function(t,e,r){"use strict";var n=t("./ternary"),i=t("../../plots/plots");r.name="ternary",r.attr="subplot",r.idRoot="ternary",r.idRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"ternary"),o=0;o=o&&(d.min=0,p.min=0,g.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}var i=t("../../../components/color"),a=t("../../subplot_defaults"),o=t("./layout_attributes"),s=t("./axis_defaults"),l=["aaxis","baxis","caxis"];e.exports=function(t,e,r){e._hasTernary&&a(t,e,r,{type:"ternary",attributes:o,handleDefaults:n,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../../components/color":303,"../../subplot_defaults":453,"./axis_defaults":457,"./layout_attributes":459}],459:[function(t,e,r){"use strict";var n=t("../../../components/color/attributes"),i=t("./axis_attributes");e.exports={domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},bgcolor:{valType:"color",dflt:n.background},sum:{valType:"number",dflt:1,min:0},aaxis:i,baxis:i,caxis:i}},{"../../../components/color/attributes":302,"./axis_attributes":456}],460:[function(t,e,r){"use strict";function n(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework()}function i(t){a.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var a=t("d3"),o=t("tinycolor2"),s=t("../../plotly"),l=t("../../lib"),c=t("../../components/color"),u=t("../../components/drawing"),f=t("../cartesian/set_convert"),h=t("../../lib/extend").extendFlat,d=t("../cartesian/axes"),p=t("../../lib/filter_visible"),g=t("../../components/dragelement"),v=t("../../components/titles"),m=t("../cartesian/select"),y=t("../cartesian/constants"),b=t("../cartesian/graph_interact");e.exports=n;var x=n.prototype;x.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={}},x.plot=function(t,e){var r,n=this,i=e[n.id],a=e._size;l.getPlotDiv(n.plotContainer.node())!==n.graphDiv&&(n.init(n.graphDiv._fullLayout),n.makeFramework()),n.adjustLayout(i,a);var o=n.traceHash,s={};for(r=0;r_*y?(a=y,i=a*_):(i=m,a=i/_),o=g*i/m,s=v*a/y,r=e.l+e.w*d-i/2,n=e.t+e.h*(1-p)-a/2,l.x0=r,l.y0=n,l.w=i,l.h=a,l.sum=b,l.xaxis={type:"linear",range:[x+2*k-b,b-x-2*w],domain:[d-o/2,d+o/2],_id:"x",_gd:l.graphDiv},f(l.xaxis),l.xaxis.setScale(),l.yaxis={type:"linear",range:[x,b-w-k],domain:[p-s/2,p+s/2],_id:"y",_gd:l.graphDiv},f(l.yaxis),l.yaxis.setScale();var A=l.yaxis.domain[0],M=l.aaxis=h({},t.aaxis,{range:[x,b-w-k],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[A,A+s*_],_axislayer:l.layers.aaxis,_gridlayer:l.layers.agrid,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l"+a+",-"+i/2});f(M);var T=l.baxis=h({},t.baxis,{range:[b-x-k,w],side:"bottom",_counterangle:30,domain:l.xaxis.domain,_axislayer:l.layers.baxis,_gridlayer:l.layers.bgrid,_counteraxis:l.aaxis,_pos:0,_gd:l.graphDiv,_id:"x",_length:i,_gridpath:"M0,0l-"+i/2+",-"+a});f(T),M._counteraxis=T;var E=l.caxis=h({},t.caxis,{range:[b-x-w,k],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[A,A+s*_],_axislayer:l.layers.caxis,_gridlayer:l.layers.cgrid,_counteraxis:l.baxis,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l-"+a+","+i/2});f(E);var L="M"+r+","+(n+a)+"h"+i+"l-"+i/2+",-"+a+"Z";l.clipDef.select("path").attr("d",L),l.layers.plotbg.select("path").attr("d",L);var S="translate("+r+","+n+")";l.plotContainer.selectAll(".scatterlayer,.maplayer,.zoom").attr("transform",S);var C="translate("+r+","+(n+a)+")";l.layers.baxis.attr("transform",C),l.layers.bgrid.attr("transform",C);var z="translate("+(r+i/2)+","+n+")rotate(30)";l.layers.aaxis.attr("transform",z),l.layers.agrid.attr("transform",z);var P="translate("+(r+i/2)+","+n+")rotate(-30)";l.layers.caxis.attr("transform",P),l.layers.cgrid.attr("transform",P),l.drawAxes(!0),l.plotContainer.selectAll(".crisp").classed("crisp",!1);var R=l.layers.axlines;R.select(".aline").attr("d",M.showline?"M"+r+","+(n+a)+"l"+i/2+",-"+a:"M0,0").call(c.stroke,M.linecolor||"#000").style("stroke-width",(M.linewidth||0)+"px"),R.select(".bline").attr("d",T.showline?"M"+r+","+(n+a)+"h"+i:"M0,0").call(c.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),R.select(".cline").attr("d",E.showline?"M"+(r+i/2)+","+n+"l"+i/2+","+a:"M0,0").call(c.stroke,E.linecolor||"#000").style("stroke-width",(E.linewidth||0)+"px")},x.drawAxes=function(t){var e=this,r=e.graphDiv,n=e.id.substr(7)+"title",i=e.aaxis,a=e.baxis,o=e.caxis;if(d.doTicks(r,i,!0),d.doTicks(r,a,!0),d.doTicks(r,o,!0),t){var s=Math.max(i.showticklabels?i.tickfont.size/2:0,(o.showticklabels?.75*o.tickfont.size:0)+("outside"===o.ticks?.87*o.ticklen:0));v.draw(r,"a"+n,{propContainer:i,propName:e.id+".aaxis.title",dfltName:"Component A",attributes:{x:e.x0+e.w/2,y:e.y0-i.titlefont.size/3-s,"text-anchor":"middle"}});var l=(a.showticklabels?a.tickfont.size:0)+("outside"===a.ticks?a.ticklen:0)+3;v.draw(r,"b"+n,{propContainer:a,propName:e.id+".baxis.title",dfltName:"Component B",attributes:{x:e.x0-l,y:e.y0+e.h+.83*a.titlefont.size+l,"text-anchor":"middle"}}),v.draw(r,"c"+n,{propContainer:o,propName:e.id+".caxis.title",dfltName:"Component C",attributes:{x:e.x0+e.w+l,y:e.y0+e.h+.83*o.titlefont.size+l,"text-anchor":"middle"}})}};var w=y.MINZOOM/2+.87,k="m-0.87,.5h"+w+"v3h-"+(w+5.2)+"l"+(w/2+2.6)+",-"+(.87*w+4.5)+"l2.6,1.5l-"+w/2+","+.87*w+"Z",A="m0.87,.5h-"+w+"v3h"+(w+5.2)+"l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-2.6,1.5l"+w/2+","+.87*w+"Z",M="m0,1l"+w/2+","+.87*w+"l2.6,-1.5l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-"+(w/2+2.6)+","+(.87*w+4.5)+"l2.6,1.5l"+w/2+",-"+.87*w+"Z",T="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",E=!0;x.initInteractions=function(){function t(t,e,r){var n=j.getBoundingClientRect();x=e-n.left,w=r-n.top,L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L,S=N.aaxis.range[1]-L.a,z=o(N.graphDiv._fullLayout[N.id].bgcolor).getLuminance(),P="M0,"+N.h+"L"+N.w/2+", 0L"+N.w+","+N.h+"Z",R=!1,O=D.append("path").attr("class","zoombox").style({fill:z>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",P),I=D.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),p()}function e(t,e){return 1-e/N.h}function r(t,e){return 1-(t+(N.h-e)/Math.sqrt(3))/N.w}function n(t,e){return(t-(N.h-e)/Math.sqrt(3))/N.w}function a(t,i){var a=x+t,o=w+i,s=Math.max(0,Math.min(1,e(x,w),e(a,o))),l=Math.max(0,Math.min(1,r(x,w),r(a,o))),c=Math.max(0,Math.min(1,n(x,w),n(a,o))),u=(s/2+c)*N.w,f=(1-s/2-l)*N.w,h=(u+f)/2,d=f-u,p=(1-s)*N.h,g=p-d/_;d.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),I.transition().style("opacity",1).duration(200),R=!0)}function u(t,e){if(C===L)return 2===e&&v(),i(F);i(F);var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r),E&&F.data&&F._context.showTips&&(l.notifier("Double-click to
zoom back out","long"),E=!1)}function f(){L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L}function h(t,e){var r=t/N.xaxis._m,n=e/N.yaxis._m;C={a:L.a-n,b:L.b+(r+n)/2,c:L.c-(r-n)/2};var i=[C.a,C.b,C.c].sort(),a={a:i.indexOf(C.a),b:i.indexOf(C.b),c:i.indexOf(C.c)};i[0]<0&&(i[1]+i[0]/2<0?(i[2]+=i[0]+i[1],i[0]=i[1]=0):(i[2]+=i[0]/2,i[1]+=i[0]/2,i[0]=0),C={a:i[a.a],b:i[a.b],c:i[a.c]},e=(L.a-C.a)*N.yaxis._m,t=(L.c-C.c-L.b+C.b)*N.xaxis._m);var o="translate("+(N.x0+t)+","+(N.y0+e)+")";N.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",o),N.aaxis.range=[C.a,N.sum-C.b-C.c],N.baxis.range=[N.sum-C.a-C.c,C.b],N.caxis.range=[N.sum-C.a-C.b,C.c],N.drawAxes(!1),N.plotContainer.selectAll(".crisp").classed("crisp",!1)}function d(t,e){if(t){var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r)}else 2===e&&v()}function p(){N.plotContainer.selectAll(".select-outline").remove()}function v(){var t={};t[N.id+".aaxis.min"]=0,t[N.id+".baxis.min"]=0,t[N.id+".caxis.min"]=0,F.emit("plotly_doubleclick",null),s.relayout(F,t)}var x,w,L,S,C,z,P,R,O,I,N=this,j=N.layers.plotbg.select("path").node(),F=N.graphDiv,D=N.layers.zoom,B={element:j,gd:F,plotinfo:{plot:D},doubleclick:v,subplot:N.id,prepFn:function(e,r,n){B.xaxes=[N.xaxis],B.yaxes=[N.yaxis];var i=F._fullLayout.dragmode;e.shiftKey&&(i="pan"===i?"zoom":"pan"),"lasso"===i?B.minDrag=1:B.minDrag=void 0,"zoom"===i?(B.moveFn=a,B.doneFn=u,t(e,r,n)):"pan"===i?(B.moveFn=h,B.doneFn=d,f(),p()):"select"!==i&&"lasso"!==i||m(e,r,n,B,i)}};g.init(B),j.onmousemove=function(t){b.hover(F,t,N.id),F._fullLayout._lasthover=j,F._fullLayout._hoversubplot=N.id},j.onmouseout=function(t){F._dragging||g.unhover(F,t)},j.onclick=function(t){b.click(F,t)},F._fullLayout._plots||(F._fullLayout._plots={}),F._fullLayout._plots[N.id]={overlays:[],xaxis:N.xaxis,yaxis:N.yaxis,x:function(){return N.xaxis},y:function(){return N.yaxis}}}},{"../../components/color":303,"../../components/dragelement":323,"../../components/drawing":325,"../../components/titles":361,"../../lib":378,"../../lib/extend":373,"../../lib/filter_visible":374,"../../plotly":396,"../cartesian/axes":399,"../cartesian/constants":404,"../cartesian/graph_interact":406,"../cartesian/select":412,"../cartesian/set_convert":413,d3:72,tinycolor2:233}],461:[function(t,e,r){"use strict";function n(t){var e;switch(t){case"themes__thumb":e={autosize:!0,width:150,height:150,title:"",showlegend:!1,margin:{l:5,r:5,t:5,b:5,pad:0},annotations:[]};break;case"thumbnail":e={title:"",hidesources:!0,showlegend:!1,borderwidth:0,bordercolor:"",margin:{l:1,r:1,t:1,b:1,pad:0},annotations:[]};break;default:e={}}return e}function i(t){var e=["xaxis","yaxis","zaxis"];return e.indexOf(t.slice(0,5))>-1}var a=t("../plotly"),o=a.Lib.extendFlat,s=a.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var r,l=t.data,c=t.layout,u=s([],l),f=s({},c,n(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var h=Object.keys(f);for(r=0;rl;l++)n(r[l])&&n(s[l])&&d.push({p:r[l],s:s[l],b:0});return a(e,"marker")&&o(e,e.marker.color,"marker","c"),a(e,"marker.line")&&o(e,e.marker.line.color,"marker.line","c"),d}},{"../../components/colorscale/calc":310,"../../components/colorscale/has_colorscale":315,"../../plots/cartesian/axes":399,"fast-isnumeric":76}],469:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("../scatter/xy_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=a(t,e,u);return f?(u("orientation",e.x&&!e.y?"h":"v"),u("text"),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),void s(t,e,i.defaultLine,{axis:"x",inherit:"y"})):void(e.visible=!1)}},{"../../components/color":303,"../../components/errorbars/defaults":330,"../../lib":378,"../bar/style_defaults":477,"../scatter/xy_defaults":567,"./attributes":467}],470:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../components/errorbars"),a=t("../../components/color");e.exports=function(t,e,r,o){var s,l=t.cd,c=l[0].trace,u=l[0].t,f=t.xa,h=t.ya,d="closest"===o?u.barwidth/2:u.dbar*(1-f._gd._fullLayout.bargap)/2;s="closest"!==o?function(t){return t.p}:"h"===c.orientation?function(t){return t.y}:function(t){return t.x};var p,g;"h"===c.orientation?(p=function(t){return n.inbox(t.b-e,t.x-e)+(t.x-e)/(t.x-t.b)},g=function(t){var e=s(t)-r;return n.inbox(e-d,e+d)}):(g=function(t){return n.inbox(t.b-r,t.y-r)+(t.y-r)/(t.y-t.b)},p=function(t){var r=s(t)-e;return n.inbox(r-d,r+d)});var v=n.getDistanceFunction(o,p,g);if(n.getClosest(l,v,t),t.index!==!1){var m=l[t.index],y=m.mcc||c.marker.color,b=m.mlcc||c.marker.line.color,x=m.mlw||c.marker.line.width;return a.opacity(y)?t.color=y:a.opacity(b)&&x&&(t.color=b),"h"===c.orientation?(t.x0=t.x1=f.c2p(m.x,!0),t.xLabelVal=m.s,t.y0=h.c2p(s(m)-d,!0),t.y1=h.c2p(s(m)+d,!0),t.yLabelVal=m.p):(t.y0=t.y1=h.c2p(m.y,!0),t.yLabelVal=m.s,t.x0=f.c2p(s(m)-d,!0),t.x1=f.c2p(s(m)+d,!0),t.xLabelVal=m.p),m.tx&&(t.text=m.tx),i.hoverInfo(m,c,t),[t]}}},{"../../components/color":303,"../../components/errorbars":331,"../../plots/cartesian/graph_interact":406}],471:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("./layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.calc=t("./calc"),n.setPositions=t("./set_positions"),n.colorbar=t("../scatter/colorbar"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.moduleType="trace",n.name="bar",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","oriented","markerColorscale","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":407,"../scatter/colorbar":549,"./arrays_to_calcdata":466,"./attributes":467,"./calc":468,"./defaults":469,"./hover":470,"./layout_attributes":472,"./layout_defaults":473,"./plot":474,"./set_positions":475,"./style":476}],472:[function(t,e,r){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","group","overlay"],dflt:"group"},barnorm:{valType:"enumerated",values:["","fraction","percent"],dflt:""},bargap:{valType:"number",min:0,max:1},bargroupgap:{valType:"number",min:0,max:1,dflt:0}}},{}],473:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./layout_attributes");e.exports=function(t,e,r){function s(r,n){return a.coerce(t,e,o,r,n)}for(var l=!1,c=!1,u=!1,f={},h=0;h=2?a(t):t>e?Math.ceil(t):Math.floor(t)}var h,d,p,g;if("h"===s.orientation?(p=u.c2p(r.poffset+e.p,!0),g=u.c2p(r.poffset+e.p+r.barwidth,!0),h=c.c2p(e.b,!0),d=c.c2p(e.s+e.b,!0)):(h=c.c2p(r.poffset+e.p,!0),d=c.c2p(r.poffset+e.p+r.barwidth,!0),g=u.c2p(e.s+e.b,!0),p=u.c2p(e.b,!0)),!(i(h)&&i(d)&&i(p)&&i(g)&&h!==d&&p!==g))return void n.select(this).remove();var v=(e.mlw+1||s.marker.line.width+1||(e.trace?e.trace.marker.line.width:0)+1)-1,m=n.round(v/2%1,2);if(!t._context.staticPlot){var y=o.opacity(e.mc||s.marker.color),b=1>y||v>.01?a:l;h=b(h,d),d=b(d,h),p=b(p,g),g=b(g,p)}n.select(this).attr("d","M"+h+","+p+"V"+g+"H"+d+"V"+p+"Z")})}),h.call(s.plot,e)}},{"../../components/color":303,"../../components/errorbars":331,"../../lib":378,"./arrays_to_calcdata":466,d3:72,"fast-isnumeric":76}],475:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axes"),o=t("../../lib");e.exports=function(t,e){var r,s,l=t._fullLayout,c=e.x(),u=e.y();["v","h"].forEach(function(f){function h(e){function r(t){t[p]=t.p+h}var n=[];e.forEach(function(e){t.calcdata[e].forEach(function(t){n.push(t.p)})});var i=o.distinctVals(n),s=i.vals,c=i.minDiff,u=!1,f=[];"group"===l.barmode&&e.forEach(function(e){u||(t.calcdata[e].forEach(function(t){u||f.forEach(function(e){Math.abs(t.p-e)x&&(L=!0,A=x),x>k+z&&(L=!0,k=x))}a.expand(m,[A,k],{tozero:!0,padded:L})}else{var P=function(t){return t[g]=t.s,t.s};for(r=0;r1||0===s.bargap&&0===s.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),e.selectAll("g.points").each(function(t){var e=t[0].trace,r=e.marker,o=r.line,s=(e._input||{}).marker||{},l=a.tryColorscale(r,s,""),c=a.tryColorscale(r,s,"line.");n.select(this).selectAll("path").each(function(t){var e,a,s=(t.mlw+1||o.width+1)-1,u=n.select(this);e="mc"in t?t.mcc=l(t.mc):Array.isArray(r.color)?i.defaultLine:r.color,u.style("stroke-width",s+"px").call(i.fill,e),s&&(a="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(o.color)?i.defaultLine:o.color,u.call(i.stroke,a))})}),e.call(o.style)}},{"../../components/color":303,"../../components/drawing":325,"../../components/errorbars":331,d3:72}],477:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s){r("marker.color",o),i(t,"marker")&&a(t,e,s,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),i(t,"marker.line")&&a(t,e,s,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width")}},{"../../components/color":303,"../../components/colorscale/defaults":312,"../../components/colorscale/has_colorscale":315}],478:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/color/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=o.line;e.exports={y:{valType:"data_array"},x:{valType:"data_array"},x0:{valType:"any"},y0:{valType:"any"},whiskerwidth:{valType:"number",min:0,max:1,dflt:.5},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1},jitter:{valType:"number",min:0,max:1},pointpos:{valType:"number",min:-2,max:2},orientation:{valType:"enumerated",values:["v","h"]},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)"},symbol:a({},o.symbol,{arrayOk:!1}),opacity:a({},o.opacity,{arrayOk:!1,dflt:1}),size:a({},o.size,{arrayOk:!1}),color:a({},o.color,{arrayOk:!1}),line:{color:a({},s.color,{arrayOk:!1,dflt:i.defaultLine}),width:a({},s.width,{arrayOk:!1,dflt:0}),outliercolor:{valType:"color"},outlierwidth:{valType:"number",min:0,dflt:1}}},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2}},fillcolor:n.fillcolor}},{"../../components/color/attributes":302,"../../lib/extend":373,"../scatter/attributes":546}],479:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../../plots/cartesian/axes");e.exports=function(t,e){function r(t,e,r,a,o){var s;return r in e?p=a.makeCalcdata(e,r):(s=r+"0"in e?e[r+"0"]:"name"in e&&("category"===a.type||n(e.name)&&-1!==["linear","log"].indexOf(a.type)||i.isDateTime(e.name)&&"date"===a.type)?e.name:t.numboxes,s=a.d2c(s),p=o.map(function(){return s})),p}function o(t,e,r,a,o){var s,l,c,u,f=a.length,h=e.length,d=[],p=[];for(s=0;f>s;++s)l=a[s],t[s]={pos:l},p[s]=l-o,d[s]=[];for(p.push(a[f-1]+o),s=0;h>s;++s)u=e[s],n(u)&&(c=i.findBin(r[s],p),c>=0&&h>c&&d[c].push(u));return d}function s(t,e){var r,n,a,o;for(o=0;o1,m=r.dPos*(1-h.boxgap)*(1-h.boxgroupgap)/(v?t.numboxes:1),y=v?2*r.dPos*(-.5+(r.boxnum+.5)/t.numboxes)*(1-h.boxgap):0,b=m*g.whiskerwidth;return g.visible!==!0||r.emptybox?void a.select(this).remove():("h"===g.orientation?(l=p,f=d):(l=d,f=p),r.bPos=y,r.bdPos=m,n(),a.select(this).selectAll("path.box").data(o.identity).enter().append("path").attr("class","box").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=l.c2p(t.pos+y-b,!0),s=l.c2p(t.pos+y+b,!0),c=f.c2p(t.q1,!0),u=f.c2p(t.q3,!0),h=o.constrain(f.c2p(t.med,!0),Math.min(c,u)+1,Math.max(c,u)-1),d=f.c2p(g.boxpoints===!1?t.min:t.lf,!0),p=f.c2p(g.boxpoints===!1?t.max:t.uf,!0);"h"===g.orientation?a.select(this).attr("d","M"+h+","+r+"V"+n+"M"+c+","+r+"V"+n+"H"+u+"V"+r+"ZM"+c+","+e+"H"+d+"M"+u+","+e+"H"+p+(0===g.whiskerwidth?"":"M"+d+","+i+"V"+s+"M"+p+","+i+"V"+s)):a.select(this).attr("d","M"+r+","+h+"H"+n+"M"+r+","+c+"H"+n+"V"+u+"H"+r+"ZM"+e+","+c+"V"+d+"M"+e+","+u+"V"+p+(0===g.whiskerwidth?"":"M"+i+","+d+"H"+s+"M"+i+","+p+"H"+s))}),g.boxpoints&&a.select(this).selectAll("g.points").data(function(t){return t.forEach(function(t){t.t=r,t.trace=g}),t}).enter().append("g").attr("class","points").selectAll("path").data(function(t){var e,r,n,a,s,l,f,h="all"===g.boxpoints?t.val:t.val.filter(function(e){return et.uf}),d=(t.q3-t.q1)*u,p=[],v=0;if(g.jitter){for(e=0;et.lo&&(n.so=!0),n})}).enter().append("path").call(s.translatePoints,d,p),void(g.boxmean&&a.select(this).selectAll("path.mean").data(o.identity).enter().append("path").attr("class","mean").style("fill","none").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=f.c2p(t.mean,!0),o=f.c2p(t.mean-t.sd,!0),s=f.c2p(t.mean+t.sd,!0);"h"===g.orientation?a.select(this).attr("d","M"+i+","+r+"V"+n+("sd"!==g.boxmean?"":"m0,0L"+o+","+e+"L"+i+","+r+"L"+s+","+e+"Z")):a.select(this).attr("d","M"+r+","+i+"H"+n+("sd"!==g.boxmean?"":"m0,0L"+e+","+o+"L"+r+","+i+"L"+e+","+s+"Z"))})))})}},{"../../components/drawing":325,"../../lib":378,d3:72}],486:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib");e.exports=function(t,e){var r,o,s,l,c=t._fullLayout,u=e.x(),f=e.y(),h=["v","h"];for(o=0;ol&&(e.z=u.slice(0,l)),s("locationmode"),s("text"),s("marker.line.color"),s("marker.line.width"),i(t,e,o,s,{prefix:"",cLetter:"z"}),void s("hoverinfo",1===o._dataLength?"location+z+text":void 0)):void(e.visible=!1)}},{"../../components/colorscale/defaults":312,"../../lib":378,"./attributes":488}],491:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../heatmap/colorbar"),n.calc=t("./calc"),n.plot=t("./plot").plot,n.moduleType="trace",n.name="choropleth",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","noOpacity"],n.meta={},e.exports=n},{"../../plots/geo":419,"../heatmap/colorbar":505,"./attributes":488,"./calc":489,"./defaults":490,"./plot":492}],492:[function(t,e,r){"use strict";function n(t,e){function r(e){var r=t.mockAxis;return o.tickText(r,r.c2l(e),"hover").text}var n=e.hoverinfo;if("none"===n)return function(t){delete t.nameLabel,delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("name"),s=-1!==i.indexOf("location"),l=-1!==i.indexOf("z"),c=-1!==i.indexOf("text"),u=!a&&s;return function(t){var n=[];u?t.nameLabel=t.id:(a&&(t.nameLabel=e.name),s&&n.push(t.id)),l&&n.push(r(t.z)),c&&n.push(t.tx),t.textLabel=n.join("
")}}function i(t){return function(e,r){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:r,location:e.id,z:e.z}]}}}var a=t("d3"),o=t("../../plots/cartesian/axes"),s=t("../../plots/cartesian/graph_interact"),l=t("../../components/color"),c=t("../../components/drawing"),u=t("../../components/colorscale/get_scale"),f=t("../../components/colorscale/make_scale_function"),h=t("../../lib/topojson_utils").getTopojsonFeatures,d=t("../../lib/geo_location_utils").locationToFeature,p=t("../../lib/array_to_calc_item"),g=t("../../constants/geo_constants"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){for(var r,n=[],i=t.locations,a=i.length,o=h(t,e),s=(t.marker||{}).line||{},l=0;a>l;l++)r=d(t.locationmode,i[l],o),void 0!==r&&(r.z=t.z[l],void 0!==t.text&&(r.tx=t.text[l]),p(s.color,r,"mlc",l),p(s.width,r,"mlw",l),n.push(r));return n.length>0&&(n[0].trace=t),n},m.plot=function(t,e,r){var o,l=t.framework,c=l.select("g.choroplethlayer"),u=l.select("g.baselayer"),f=l.select("g.baselayeroverchoropleth"),h=g.baseLayersOverChoropleth,d=c.selectAll("g.trace.choropleth").data(e,function(t){return t.uid});d.enter().append("g").attr("class","trace choropleth"),d.exit().remove(),d.each(function(e){function r(e,r){if(t.showHover){var n=t.projection(e.properties.ct);c(e),s.loneHover({x:n[0],y:n[1],name:e.nameLabel,text:e.textLabel},{container:t.hoverContainer.node()}),f=u(e,r),t.graphDiv.emit("plotly_hover",f)}}function o(e,r){t.graphDiv.emit("plotly_click",u(e,r))}var l=m.calcGeoJSON(e,t.topojson),c=n(t,e),u=i(e),f=null,h=a.select(this).selectAll("path.choroplethlocation").data(l);h.enter().append("path").classed("choroplethlocation",!0).on("mouseover",r).on("click",o).on("mouseout",function(){s.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",f)}).on("mousedown",function(){s.loneUnhover(t.hoverContainer)}).on("mouseup",r),h.exit().remove()}),f.selectAll("*").remove();for(var p=0;pr;r++)e=f[r],d[r]=e[0]*(t.zmax-t.zmin)+t.zmin,p[r]=e[1];var g=n.extent([t.zmin,t.zmax,a.start,a.start+l*(c-1)]),v=g[t.zminr;r++)e=f[r],d[r]=(e[0]*(c+u-1)-u/2)*l+o,p[r]=e[1];var y=n.scale.linear().interpolate(n.interpolateRgb).domain(d).range(p);return y}},{"../../components/colorscale/get_scale":314,d3:72}],500:[function(t,e,r){"use strict";function n(t,e,r){_.markTime("in Contour.plot");var n=r[0].trace,a=r[0].x,s=r[0].y,c=n.contours,u=n.uid,f=e.x(),h=e.y(),v=t._fullLayout,b="contour"+u,x=i(c,e,r[0]);if(n.visible!==!0)return v._paper.selectAll("."+b+",.hm"+u).remove(),void v._infolayer.selectAll(".cb"+u).remove();"heatmap"===c.coloring?(n.zauto&&n.autocontour===!1&&(n._input.zmin=n.zmin=c.start-c.size/2,n._input.zmax=n.zmax=n.zmin+x.length*c.size),k(t,e,[r])):v._paper.selectAll(".hm"+u).remove(),o(x),l(x);var w=f.c2p(a[0],!0),A=f.c2p(a[a.length-1],!0),M=h.c2p(s[0],!0),T=h.c2p(s[s.length-1],!0),E=[[w,T],[A,T],[A,M],[w,M]],L=d(e,r,b);p(L,E,c),g(L,x,E,c),m(L,x,c),y(L,e,r[0],E),_.markTime("done Contour.plot")}function i(t,e,r){for(var n=t.size||1,i=[],a=t.start;at?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);if(5===r||10===r){var n=(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4;return t>n?5===r?713:1114:5===r?104:208}return 15===r?0:r}function o(t){var e,r,n,i,o,s,l,c,u,f=t[0].z,h=f.length,d=f[0].length,p=2===h||2===d;for(r=0;h-1>r;r++)for(i=[],0===r&&(i=i.concat(A)),r===h-2&&(i=i.concat(M)),e=0;d-1>e;e++)for(n=i.slice(),0===e&&(n=n.concat(T)),e===d-2&&(n=n.concat(E)),o=e+","+r,s=[[f[r][e],f[r][e+1]],[f[r+1][e],f[r+1][e+1]]],u=0;ui;i++){if(s>20?(s=S[s][(l[0]||l[1])<0?0:1],t.crossings[o]=C[s]):delete t.crossings[o],l=L[s],!l){console.log("found bad marching index",s,e,t.level);break}if(d.push(h(t,e,l)),e[0]+=l[0],e[1]+=l[1],u(d[d.length-1],d[d.length-2])&&d.pop(),o=e.join(","),o===a&&l.join(",")===p||r&&(l[0]&&(e[0]<0||e[0]>v-2)||l[1]&&(e[1]<0||e[1]>g-2)))break;s=t.crossings[o]}1e4===i&&console.log("Infinite loop in contour?");var m,y,b,x,_,w,k,A=u(d[0],d[d.length-1]),M=0,T=.2*t.smoothing,E=[],z=0;for(i=1;i=z;i--)if(m=E[i],P>m){for(b=0,y=i-1;y>=z&&m+E[y]b&&m+E[b]e;)e++,r=Object.keys(i.crossings)[0].split(",").map(Number),s(i,r);1e4===e&&console.log("Infinite loop in contour?")}}function c(t,e,r){var n=0,i=0;return t>20&&e?208===t||1114===t?n=0===r[0]?1:-1:i=0===r[1]?1:-1:-1!==A.indexOf(t)?i=1:-1!==T.indexOf(t)?n=1:-1!==M.indexOf(t)?i=-1:n=-1,[n,i]}function u(t,e){return Math.abs(t[0]-e[0])<.01&&Math.abs(t[1]-e[1])<.01}function f(t,e){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function h(t,e,r){var n=e[0]+Math.max(r[0],0),i=e[1]+Math.max(r[1],0),a=t.z[i][n],o=t.xaxis,s=t.yaxis;if(r[1]){var l=(t.level-a)/(t.z[i][n+1]-a);return[o.c2p((1-l)*t.x[n]+l*t.x[n+1],!0),s.c2p(t.y[i],!0)]}var c=(t.level-a)/(t.z[i+1][n]-a);return[o.c2p(t.x[n],!0),s.c2p((1-c)*t.y[i]+c*t.y[i+1],!0)]}function d(t,e,r){var n=t.plot.select(".maplayer").selectAll("g.contour."+r).data(e);return n.enter().append("g").classed("contour",!0).classed(r,!0),n.exit().remove(),n}function p(t,e,r){var n=t.selectAll("g.contourbg").data([0]);n.enter().append("g").classed("contourbg",!0);var i=n.selectAll("path").data("fill"===r.coloring?[0]:[]);i.enter().append("path"),i.exit().remove(),i.attr("d","M"+e.join("L")+"Z").style("stroke","none")}function g(t,e,r,n){var i=t.selectAll("g.contourfill").data([0]);i.enter().append("g").classed("contourfill",!0);var a=i.selectAll("path").data("fill"===n.coloring?e:[]);a.enter().append("path"),a.exit().remove(),a.each(function(t){var e=v(t,r);e?x.select(this).attr("d",e).style("stroke","none"):x.select(this).remove()})}function v(t,e){function r(t){return Math.abs(t[1]-e[0][1])<.01}function n(t){return Math.abs(t[1]-e[2][1])<.01}function i(t){return Math.abs(t[0]-e[0][0])<.01}function a(t){return Math.abs(t[0]-e[2][0])<.01}for(var o,s,l,c,u,f,h=t.edgepaths.length||t.z[0][0]l;l++){if(!o){console.log("missing end?",d,t);break}for(r(o)&&!a(o)?s=e[1]:i(o)?s=e[0]:n(o)?s=e[3]:a(o)&&(s=e[2]),u=0;u=0&&(s=v,c=u):Math.abs(o[1]-s[1])<.01?Math.abs(o[1]-v[1])<.01&&(v[0]-o[0])*(s[0]-v[0])>=0&&(s=v,c=u):console.log("endpt to newendpt is not vert. or horz.",o,s,v)}if(o=s,c>=0)break;h+="L"+s}if(c===t.edgepaths.length){console.log("unclosed perimeter path");break}d=c,g=-1===p.indexOf(d),g&&(d=p[0],h+="Z")}for(d=0;de;e++)s.push(1);for(e=0;a>e;e++)i.push(s.slice());for(e=0;eo;o++)for(n=i(l,o),u[o]=new Array(n),s=0;n>s;s++)u[o][s]=e(a(l,o,s));return u}function i(t,e,r,n,i,a){var o,s,l,c=[],u=h.traceIs(t,"contour"),f=h.traceIs(t,"histogram"),d=h.traceIs(t,"gl2d");if(Array.isArray(e)&&!f&&"category"!==a.type){e=e.map(a.d2c);var p=e.length;if(!(i>=p))return u?e.slice(0,i):e.slice(0,i+1);if(u||d)c=e.slice(0,i);else if(1===i)c=[e[0]-.5,e[0]+.5];else{for(c=[1.5*e[0]-.5*e[1]],l=1;p>l;l++)c.push(.5*(e[l-1]+e[l]));c.push(1.5*e[p-1]-.5*e[p-2])}if(i>p){var g=c[c.length-1],v=g-c[c.length-2];for(l=p;i>l;l++)g+=v,c.push(g)}}else for(s=n||1,o=void 0===r?0:f||"category"===a.type?r:a.d2c(r),l=u||d?0:-.5;i>l;l++)c.push(o+s*l);return c}function a(t){return.5-.25*Math.min(1,.5*t)}function o(t,e,r){var n,i,o=1;if(Array.isArray(r))for(n=0;nn&&o>y;n++)o=l(t,e,a(o));return o>y&&console.log("interp2d didn't converge quickly",o),t}function s(t){var e,r,n,i,a,o,s,l,c=[],u={},f=[],h=t[0],d=[],p=[0,0,0],g=m(t);for(r=0;rn;n++)void 0===d[n]&&(o=(void 0!==d[n-1]?1:0)+(void 0!==d[n+1]?1:0)+(void 0!==e[n]?1:0)+(void 0!==h[n]?1:0),o?(0===r&&o++,0===n&&o++,r===t.length-1&&o++,n===d.length-1&&o++,4>o&&(u[[r,n]]=[r,n,o]),c.push([r,n,o])):f.push([r,n]));for(;f.length;){for(s={},l=!1,a=f.length-1;a>=0;a--)i=f[a],r=i[0],n=i[1],o=((u[[r-1,n]]||p)[2]+(u[[r+1,n]]||p)[2]+(u[[r,n-1]]||p)[2]+(u[[r,n+1]]||p)[2])/20,o&&(s[i]=[r,n,o],f.splice(a,1),l=!0);if(!l)throw"findEmpties iterated with no new neighbors";for(i in s)u[i]=s[i],c.push(s[i])}return c.sort(function(t,e){return e[2]-t[2]})}function l(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g,v=0;for(o=0;os;s++)l=b[s],c=t[i+l[0]],c&&(u=c[a+l[1]],void 0!==u&&(0===h?p=g=u:(p=Math.min(p,u),g=Math.max(g,u)),f++,h+=u));if(0===f)throw"iterateInterp2d order is wrong: no defined neighbors";t[i][a]=h/f,void 0===d?4>f&&(v=1):(t[i][a]=(1+r)*t[i][a]-r*d,g>p&&(v=Math.max(v,Math.abs(t[i][a]-d)/(g-p))))}return v}var c=t("fast-isnumeric"),u=t("../../lib"),f=t("../../plots/cartesian/axes"),h=t("../../plots/plots"),d=t("../histogram2d/calc"),p=t("../../components/colorscale/calc"),g=t("./has_columns"),v=t("./convert_column_xyz"),m=t("./max_row_length");e.exports=function(t,e){function r(t){E=e._input.zsmooth=e.zsmooth=!1,u.notifier("cannot fast-zsmooth: "+t)}u.markTime("start convert x&y");var a,l,c,y,b,x,_,w,k=f.getFromId(t,e.xaxis||"x"),A=f.getFromId(t,e.yaxis||"y"),M=h.traceIs(e,"contour"),T=h.traceIs(e,"histogram"),E=M?"best":e.zsmooth;if(k._minDtick=0,A._minDtick=0,u.markTime("done convert x&y"),T){var L=d(t,e);a=L.x,l=L.x0,c=L.dx,y=L.y,b=L.y0,x=L.dy,_=L.z}else g(e)&&v(e,k,A),a=e.x?k.makeCalcdata(e,"x"):[],y=e.y?A.makeCalcdata(e,"y"):[],l=e.x0||0,c=e.dx||1,b=e.y0||0,x=e.dy||1,_=n(e),(M||e.connectgaps)&&(e._emptypoints=s(_),e._interpz=o(_,e._emptypoints,e._interpz));if("fast"===E)if("log"===k.type||"log"===A.type)r("log axis found");else if(!T){if(a.length){var S=(a[a.length-1]-a[0])/(a.length-1),C=Math.abs(S/100);for(w=0;wC){r("x scale is not linear");break}}if(y.length&&"fast"===E){var z=(y[y.length-1]-y[0])/(y.length-1),P=Math.abs(z/100);for(w=0;wP){r("y scale is not linear");break}}}var R=m(_),O="scaled"===e.xtype?"":e.x,I=i(e,O,l,c,R,k),N="scaled"===e.ytype?"":e.y,j=i(e,N,b,x,_.length,A);f.expand(k,I),f.expand(A,j);var F={x:I,y:j,z:_};if(p(e,_,"","z"),M&&e.contours&&"heatmap"===e.contours.coloring){var D="contour"===e.type?"heatmap":"histogram2d";F.xfill=i(D,O,l,c,R,k),F.yfill=i(D,N,b,x,_.length,A)}return[F]};var y=.01,b=[[-1,0],[1,0],[0,-1],[0,1]]},{"../../components/colorscale/calc":310,"../../lib":378,"../../plots/cartesian/axes":399,"../../plots/plots":447,"../histogram2d/calc":524,"./convert_column_xyz":506,"./has_columns":508,"./max_row_length":511,"fast-isnumeric":76}],505:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c="cb"+r.uid,u=s(r.colorscale),f=r.zmin,h=r.zmax;if(i(f)||(f=a.aggNums(Math.min,null,r.z)),i(h)||(h=a.aggNums(Math.max,null,r.z)),t._fullLayout._infolayer.selectAll("."+c).remove(),!r.showscale)return void o.autoMargin(t,c);var d=e[0].t.cb=l(t,c);d.fillcolor(n.scale.linear().domain(u.map(function(t){return f+t[0]*(h-f)})).range(u.map(function(t){return t[1]}))).filllevels({start:f,end:h,size:(h-f)/254}).options(r.colorbar)(),a.markTime("done colorbar")}},{"../../components/colorbar/draw":306,"../../components/colorscale/get_scale":314,"../../lib":378,"../../plots/plots":447,d3:72,"fast-isnumeric":76}],506:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a=t.x.slice(),o=t.y.slice(),s=t.z,l=t.text,c=Math.min(a.length,o.length,s.length),u=void 0!==l&&!Array.isArray(l[0]);for(ci;i++)a[i]=e.d2c(a[i]),o[i]=r.d2c(o[i]);var f,h,d,p=n.distinctVals(a),g=p.vals,v=n.distinctVals(o),m=v.vals,y=n.init2dArray(m.length,g.length);for(u&&(d=n.init2dArray(m.length,g.length)),i=0;c>i;i++)f=n.findBin(a[i]+p.minDiff/2,g),h=n.findBin(o[i]+v.minDiff/2,m),y[h][f]=s[i],u&&(d[h][f]=l[i]);t.x=g,t.y=m,t.z=y,u&&(t.text=d)}},{"../../lib":378}],507:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./has_columns"),a=t("./xyz_defaults"),o=t("../../components/colorscale/defaults"),s=t("./attributes");e.exports=function(t,e,r,l){function c(r,i){return n.coerce(t,e,s,r,i)}var u=a(t,e,c);return u?(c("text"),c("zsmooth"),c("connectgaps",i(e)&&e.zsmooth!==!1),void o(t,e,l,c,{prefix:"",cLetter:"z"})):void(e.visible=!1)}},{"../../components/colorscale/defaults":312,"../../lib":378,"./attributes":503,"./has_columns":508,"./xyz_defaults":514}],508:[function(t,e,r){"use strict";e.exports=function(t){return!Array.isArray(t.z[0])}},{}],509:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../lib");e.exports=function(t,e,r,a,o){if(!(t.distancec||c>=m[0].length||0>u||u>m.length)return}else{if(n.inbox(e-g[0],e-g[g.length-1])>n.MAXDIST||n.inbox(r-v[0],r-v[v.length-1])>n.MAXDIST)return;if(o){var w;for(b=[2*g[0]-g[1]],w=1;w0;)_=v.c2p(C[M]),M--;for(x>_&&(w=_,_=x,x=w,N=!0),M=0;void 0===k&&M0;)A=m.c2p(z[M]),M--;if(k>A&&(w=k,k=A,A=w,j=!0),P&&(C=r[0].xfill,z=r[0].yfill),"fast"!==R){var F="best"===R?0:.5;x=Math.max(-F*v._length,x),_=Math.min((1+F)*v._length,_),k=Math.max(-F*m._length,k),A=Math.min((1+F)*m._length,A)}var D=Math.round(_-x),B=Math.round(A-k);if(!(0>=D||0>=B)){var U,V;"fast"===R?(U=I,V=O):(U=D,V=B);var q=document.createElement("canvas");q.width=U,q.height=V;var H,G,Y=q.getContext("2d"),X=i.scale.linear().domain(S.map(function(t){return t[0]})).range(S.map(function(t){var e=a(t[1]).toRgb();return[e.r,e.g,e.b,e.a]})).clamp(!0);"fast"===R?(H=N?function(t){return I-1-t}:o.identity,G=j?function(t){return O-1-t}:o.identity):(H=function(t){return o.constrain(Math.round(v.c2p(C[t])-x),0,D)},G=function(t){return o.constrain(Math.round(m.c2p(z[t])-k),0,B)});var W,Z,K,Q,$,J,tt=G(0),et=[tt,tt],rt=N?0:1,nt=j?0:1,it=0,at=0,ot=0,st=0;if(o.markTime("done init png"),R){var lt=0,ct=new Uint8Array(D*B*4);if("best"===R){var ut,ft,ht,dt=new Array(C.length),pt=new Array(z.length),gt=new Array(D);for(M=0;MM;M++)gt[M]=n(M,dt);for(Z=0;B>Z;Z++)for(ut=n(Z,pt),ft=T[ut.bin0],ht=T[ut.bin1],M=0;D>M;M++,lt+=4)J=d(ft,ht,gt[M],ut),h(ct,lt,J)}else for(Z=0;O>Z;Z++)for($=T[Z],et=G(Z),M=0;I>M;M++)J=f($[M],1),lt=4*(et*D+H(M)),h(ct,lt,J);var vt=Y.createImageData(D,B);vt.data.set(ct),Y.putImageData(vt,0,0)}else for(Z=0;O>Z;Z++)if($=T[Z],et.reverse(),et[nt]=G(Z+1),et[0]!==et[1]&&void 0!==et[0]&&void 0!==et[1])for(K=H(0),W=[K,K],M=0;I>M;M++)W.reverse(),W[rt]=H(M+1),W[0]!==W[1]&&void 0!==W[0]&&void 0!==W[1]&&(Q=$[M],J=f(Q,(W[1]-W[0])*(et[1]-et[0])),Y.fillStyle="rgba("+J.join(",")+")",Y.fillRect(W[0],et[0],W[1]-W[0],et[1]-et[0]));o.markTime("done filling png"),at=Math.round(at/it),ot=Math.round(ot/it),st=Math.round(st/it);var mt=a("rgb("+at+","+ot+","+st+")");t._hmpixcount=(t._hmpixcount||0)+it,t._hmlumcount=(t._hmlumcount||0)+it*mt.getLuminance();var yt=e.plot.select(".imagelayer").selectAll("g.hm."+b).data([0]);yt.enter().append("g").classed("hm",!0).classed(b,!0),yt.exit().remove();var bt=yt.selectAll("image").data(r);bt.enter().append("svg:image"),bt.exit().remove(),bt.attr({xmlns:c.svg,"xlink:href":q.toDataURL("image/png"),height:B,width:D,x:x,y:k,preserveAspectRatio:"none"}),o.markTime("done showing png")}}var i=t("d3"),a=t("tinycolor2"),o=t("../../lib"),s=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),c=t("../../constants/xmlns_namespaces"),u=t("./max_row_length");e.exports=function(t,e,r){for(var i=0;i0&&(n=!0);for(var s=0;si;i++)e[i]?(t[i]/=e[i],n+=t[i]):t[i]=null;return n}},{}],517:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){return r("histnorm"),n.forEach(function(t){var e=r(t+"bins.start"),n=r(t+"bins.end"),i=r("autobin"+t,!(e&&n));r(i?"nbins"+t:t+"bins.size")}),e}},{}],518:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports={count:function(t,e,r){return r[t]++,1},sum:function(t,e,r,i){var a=i[e];return n(a)?(a=Number(a),r[t]+=a,a):0},avg:function(t,e,r,i,a){var o=i[e];return n(o)&&(o=Number(o),r[t]+=o,a[t]++),0},min:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]>a)return r[t]=a,a-r[t]}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]r&&c.length<5e3;)g=a.tickIncrement(r,b.size),c.push((r+g)/2),u.push(S),x&&_.push(r),E&&w.push(1/(g-r)),P&&k.push(0),r=g;var R=u.length;for(r=0;r=0&&R>m&&(A+=C(m,r,u,y,k));P&&(A=l(u,k)),z&&z(u,A,w);var O=Math.min(c.length,u.length),I=[],N=0,j=O-1;for(r=0;O>r;r++)if(u[r]){N=r;break}for(r=O-1;r>N;r--)if(u[r]){j=r;break}for(r=N;j>=r;r++)n(c[r])&&n(u[r])&&I.push({p:c[r],s:u[r],b:0});return I}}},{"../../lib":378,"../../plots/cartesian/axes":399,"./average":516,"./bin_functions":518,"./norm_functions":522,"fast-isnumeric":76}],520:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("./bin_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=u("x"),h=u("y");u("text");var d=u("orientation",h&&!f?"h":"v"),p=e["v"===d?"x":"y"];if(!p||!p.length)return void(e.visible=!1);var g=e["h"===d?"x":"y"];g&&u("histfunc");var v="h"===d?["y"]:["x"];a(t,e,u,v),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),s(t,e,i.defaultLine,{axis:"x",inherit:"y"})}},{"../../components/color":303,"../../components/errorbars/defaults":330,"../../lib":378,"../bar/style_defaults":477,"./attributes":515,"./bin_defaults":517}],521:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("../bar/layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("../bar/layout_defaults"),n.calc=t("./calc"),n.setPositions=t("../bar/set_positions"),n.plot=t("../bar/plot"),n.style=t("../bar/style"),n.colorbar=t("../scatter/colorbar"),n.hoverPoints=t("../bar/hover"),n.moduleType="trace",n.name="histogram",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","histogram","oriented","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":407,"../bar/hover":470,"../bar/layout_attributes":472,"../bar/layout_defaults":473,"../bar/plot":474,"../bar/set_positions":475,"../bar/style":476,"../scatter/colorbar":549,"./attributes":515,"./calc":519,"./defaults":520}],522:[function(t,e,r){"use strict";e.exports={percent:function(t,e){for(var r=t.length,n=100/e,i=0;r>i;i++)t[i]*=n},probability:function(t,e){for(var r=t.length,n=0;r>n;n++)t[n]/=e},density:function(t,e,r,n){var i=t.length;n=n||1;for(var a=0;i>a;a++)t[a]*=r[a]*n},"probability density":function(t,e,r,n){var i=t.length;n&&(e/=n);for(var a=0;i>a;a++)t[a]*=r[a]/e}}},{}],523:[function(t,e,r){"use strict";var n=t("../histogram/attributes"),i=t("../heatmap/attributes");e.exports={x:n.x,y:n.y,z:{valType:"data_array"},marker:{color:{valType:"data_array"}},histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zauto:i.zauto,zmin:i.zmin,zmax:i.zmax,colorscale:i.colorscale,autocolorscale:i.autocolorscale,reversescale:i.reversescale,showscale:i.showscale,zsmooth:i.zsmooth,_nestedModules:{colorbar:"Colorbar"}}},{"../heatmap/attributes":503,"../histogram/attributes":515}],524:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("../histogram/bin_functions"),o=t("../histogram/norm_functions"),s=t("../histogram/average");e.exports=function(t,e){var r,l,c,u,f,h,d=i.getFromId(t,e.xaxis||"x"),p=e.x?d.makeCalcdata(e,"x"):[],g=i.getFromId(t,e.yaxis||"y"),v=e.y?g.makeCalcdata(e,"y"):[],m=Math.min(p.length,v.length);p.length>m&&p.splice(m,p.length-m),v.length>m&&v.splice(m,v.length-m),n.markTime("done convert data"),!e.autobinx&&"xbins"in e||(e.xbins=i.autoBin(p,d,e.nbinsx,"2d"),"histogram2dcontour"===e.type&&(e.xbins.start-=e.xbins.size,e.xbins.end+=e.xbins.size),e._input.xbins=e.xbins),!e.autobiny&&"ybins"in e||(e.ybins=i.autoBin(v,g,e.nbinsy,"2d"),"histogram2dcontour"===e.type&&(e.ybins.start-=e.ybins.size,e.ybins.end+=e.ybins.size),e._input.ybins=e.ybins),n.markTime("done autoBin"),f=[];var y,b,x=[],_=[],w="string"==typeof e.xbins.size?[]:e.xbins,k="string"==typeof e.xbins.size?[]:e.ybins,A=0,M=[],T=e.histnorm,E=e.histfunc,L=-1!==T.indexOf("density"),S="max"===E||"min"===E,C=S?null:0,z=a.count,P=o[T],R=!1,O=[],I=[],N="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";N&&"count"!==E&&(R="avg"===E,z=a[E]);var j=e.xbins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6;for(h=j.start;F>h;h=i.tickIncrement(h,j.size))x.push(C),Array.isArray(w)&&w.push(h),R&&_.push(0);Array.isArray(w)&&w.push(h);var D=x.length;for(r=e.xbins.start,l=(h-r)/D,r+=l/2,j=e.ybins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6,h=j.start;F>h;h=i.tickIncrement(h,j.size))f.push(x.concat()),Array.isArray(k)&&k.push(h),R&&M.push(_.concat());Array.isArray(k)&&k.push(h);var B=f.length;for(c=e.ybins.start,u=(h-c)/B,c+=u/2,L&&(O=x.map(function(t,e){return Array.isArray(w)?1/(w[e+1]-w[e]):1/l}),I=f.map(function(t,e){return Array.isArray(k)?1/(k[e+1]-k[e]):1/u})),n.markTime("done making bins"),h=0;m>h;h++)y=n.findBin(p[h],w),b=n.findBin(v[h],k),y>=0&&D>y&&b>=0&&B>b&&(A+=z(y,h,f[b],N,M[b]));if(R)for(b=0;B>b;b++)A+=s(f[b],M[b]);if(P)for(b=0;B>b;b++)P(f[b],A,O,I[b]);return n.markTime("done binning"),{x:p,x0:r,dx:l,y:v,y0:c,dy:u,z:f}}},{"../../lib":378,"../../plots/cartesian/axes":399,"../histogram/average":516,"../histogram/bin_functions":518,"../histogram/norm_functions":522}],525:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./sample_defaults"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r){function s(r,i){return n.coerce(t,e,o,r,i)}i(t,e,s),s("zsmooth"),a(t,e,r,s,{prefix:"",cLetter:"z"})}},{"../../components/colorscale/defaults":312,"../../lib":378,"./attributes":523,"./sample_defaults":527}],526:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../heatmap/calc"),n.plot=t("../heatmap/plot"),n.colorbar=t("../heatmap/colorbar"),n.style=t("../heatmap/style"),n.hoverPoints=t("../heatmap/hover"),n.moduleType="trace",n.name="histogram2d",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":407,"../heatmap/calc":504,"../heatmap/colorbar":505,"../heatmap/hover":509,"../heatmap/plot":512,"../heatmap/style":513,"./attributes":523,"./defaults":525}],527:[function(t,e,r){"use strict";var n=t("../histogram/bin_defaults");e.exports=function(t,e,r){var i=r("x"),a=r("y");if(!(i&&i.length&&a&&a.length))return void(e.visible=!1);var o=r("z")||r("marker.color");o&&r("histfunc");var s=["x","y"];n(t,e,r,s)}},{"../histogram/bin_defaults":517}],528:[function(t,e,r){"use strict";var n=t("../histogram2d/attributes"),i=t("../contour/attributes");e.exports={x:n.x,y:n.y,z:n.z,marker:n.marker,histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zauto:i.zauto,zmin:i.zmin,zmax:i.zmax,colorscale:i.colorscale,autocolorscale:i.autocolorscale,reversescale:i.reversescale,showscale:i.showscale,autocontour:i.autocontour,ncontours:i.ncontours,contours:i.contours,line:i.line,_nestedModules:{colorbar:"Colorbar"}}},{"../contour/attributes":493,"../histogram2d/attributes":523}],529:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../histogram2d/sample_defaults"),a=t("../contour/style_defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,i){return n.coerce(t,e,o,r,i); -}i(t,e,l);var c=n.coerce2(t,e,o,"contours.start"),u=n.coerce2(t,e,o,"contours.end"),f=l("autocontour",!(c&&u));l(f?"ncontours":"contours.size"),a(t,e,l,s)}},{"../../lib":378,"../contour/style_defaults":502,"../histogram2d/sample_defaults":527,"./attributes":528}],530:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../contour/calc"),n.plot=t("../contour/plot"),n.style=t("../contour/style"),n.colorbar=t("../contour/colorbar"),n.hoverPoints=t("../contour/hover"),n.moduleType="trace",n.name="histogram2dcontour",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","contour","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":407,"../contour/calc":494,"../contour/colorbar":495,"../contour/hover":497,"../contour/plot":500,"../contour/style":501,"./attributes":528,"./defaults":529}],531:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../surface/attributes"),a=t("../../lib/extend").extendFlat;e.exports={x:{valType:"data_array"},y:{valType:"data_array"},z:{valType:"data_array"},i:{valType:"data_array"},j:{valType:"data_array"},k:{valType:"data_array"},delaunayaxis:{valType:"enumerated",values:["x","y","z"],dflt:"z"},alphahull:{valType:"number",dflt:-1},intensity:{valType:"data_array"},color:{valType:"color"},vertexcolor:{valType:"data_array"},facecolor:{valType:"data_array"},opacity:a({},i.opacity),flatshading:{valType:"boolean",dflt:!1},contour:{show:a({},i.contours.x.show,{}),color:a({},i.contours.x.color),width:a({},i.contours.x.width)},colorscale:n.colorscale,reversescale:n.reversescale,showscale:n.showscale,lighting:a({},i.lighting),_nestedModules:{colorbar:"Colorbar"}}},{"../../components/colorscale/attributes":309,"../../lib/extend":373,"../surface/attributes":591}],532:[function(t,e,r){"use strict";function n(t,e,r){this.scene=t,this.uid=r,this.mesh=e,this.name="",this.color="#fff",this.data=null,this.showContour=!1}function i(t){return t.map(function(t){var e=t[0],r=c(t[1]),n=r.toRgb();return{index:e,rgb:[n.r,n.g,n.b,1]}})}function a(t){return t.map(d)}function o(t,e,r){for(var n=new Array(t.length),i=0;i0)s=f(t.alphahull,l);else{var c=["x","y","z"].indexOf(t.delaunayaxis);s=u(l.map(function(t){return[t[(c+1)%3],t[(c+2)%3]]}))}var p={positions:l,cells:s,ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,opacity:t.opacity,contourEnable:t.contour.show,contourColor:d(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",p.vertexIntensity=t.intensity,p.colormap=i(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolors[0],p.vertexColors=a(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],p.cellColors=a(t.facecolor)):(this.color=t.color,p.meshColor=d(t.color)),this.mesh.update(p)},p.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=s},{"../../lib/str2rgbarray":389,"alpha-shape":40,"convex-hull":61,"delaunay-triangulate":73,"gl-mesh3d":109,tinycolor2:233}],533:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/colorbar/defaults"),a=t("./attributes");e.exports=function(t,e,r,o){function s(r,i){return n.coerce(t,e,a,r,i)}function l(t){var e=t.map(function(t){var e=s(t);return e&&Array.isArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var c=l(["x","y","z"]),u=l(["i","j","k"]);return c?(u&&u.forEach(function(t){for(var e=0;el||(c=p[r],void 0!==c&&""!==c||(c=r),c=String(c),void 0===y[c]&&(y[c]=!0,u=a(e.marker.colors[r]),u.isValid()?(u=o.addOpacity(u,u.getAlpha()),m[c]||(m[c]=u)):m[c]?u=m[c]:(u=!1,b=!0),f=-1!==_.indexOf(c),f||(x+=l),g.push({v:l,label:c,color:u,i:r,hidden:f}))));if(e.sort&&g.sort(function(t,e){return e.v-t.v}),b)for(r=0;r")}return g};var l},{"../../components/color":303,"./helpers":538,"fast-isnumeric":76,tinycolor2:233}],537:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(r,a){return n.coerce(t,e,i,r,a)}var s=n.coerceFont,l=o("values");if(!Array.isArray(l)||!l.length)return void(e.visible=!1);var c=o("labels");Array.isArray(c)||(o("label0"),o("dlabel"));var u=o("marker.line.width");u&&o("marker.line.color");var f=o("marker.colors");Array.isArray(f)||(e.marker.colors=[]),o("scalegroup");var h=o("text"),d=o("textinfo",Array.isArray(h)?"text+percent":"percent");if(o("hoverinfo",1===a._dataLength?"label+text+value+percent":void 0),d&&"none"!==d){var p=o("textposition"),g=Array.isArray(p)||"auto"===p,v=g||"inside"===p,m=g||"outside"===p;if(v||m){var y=s(o,"textfont",a.font);v&&s(o,"insidetextfont",y),m&&s(o,"outsidetextfont",y)}}o("domain.x"),o("domain.y"),o("hole"),o("sort"),o("direction"),o("rotation"),o("pull")}},{"../../lib":378,"./attributes":535}],538:[function(t,e,r){"use strict";r.formatPiePercent=function(t){var e=(100*t).toPrecision(3);return-1!==e.indexOf(".")?e.replace(/[.]?0+$/,"")+"%":e+"%"},r.formatPieValue=function(t){var e=t.toPrecision(10);return-1!==e.indexOf(".")?e.replace(/[.]?0+$/,""):e}},{}],539:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.layoutAttributes=t("./layout_attributes"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.styleOne=t("./style_one"),n.moduleType="trace",n.name="pie",n.basePlotModule=t("../../plots/cartesian"),n.categories=["pie","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":407,"./attributes":535,"./calc":536,"./defaults":537,"./layout_attributes":540,"./layout_defaults":541,"./plot":542,"./style":543,"./style_one":544}],540:[function(t,e,r){"use strict";e.exports={hiddenlabels:{valType:"data_array"}}},{}],541:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e){function r(r,a){return n.coerce(t,e,i,r,a)}r("hiddenlabels")}},{"../../lib":378,"./layout_attributes":540}],542:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,o=Math.PI*Math.min(e.v/r.vTotal,.5),s=1-r.trace.hole,l=i(e,r),c={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(c.scale>=1)return c;var u=a+1/(2*Math.tan(o)),f=r.r*Math.min(1/(Math.sqrt(u*u+.5)+u),s/(Math.sqrt(a*a+s/2)+a)),h={scale:2*f/t.height,rCenter:Math.cos(f/r.r)-f*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},d=1/a,p=d+1/(2*Math.tan(o)),g=r.r*Math.min(1/(Math.sqrt(p*p+.5)+p),s/(Math.sqrt(d*d+s/2)+d)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},m=v.scale>h.scale?v:h;return c.scale<1&&m.scale>c.scale?m:c}function i(t,e){if(t.v===e.vTotal&&!e.trace.hole)return 1;var r=Math.PI*Math.min(t.v/e.vTotal,.5);return Math.min(1/(1+1/Math.sin(r)),(1-e.trace.hole)/2)}function a(t,e){var r=e.pxmid[0],n=e.pxmid[1],i=t.width/2,a=t.height/2;return 0>r&&(i*=-1),0>n&&(a*=-1),{scale:1,rCenter:1,rotate:0,x:i+Math.abs(a)*(i>0?1:-1)/2,y:a/(1+r*r/(n*n)),outside:!0}}function o(t,e){function r(t,e){return t.pxmid[1]-e.pxmid[1]}function n(t,e){return e.pxmid[1]-t.pxmid[1]}function i(t,r){r||(r={});var n,i,a,s,h,d,g=r.labelExtraY+(o?r.yLabelMax:r.yLabelMin),v=o?t.yLabelMin:t.yLabelMax,m=o?t.yLabelMax:t.yLabelMin,y=t.cyFinal+c(t.px0[1],t.px1[1]),b=g-v;if(b*f>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(i=0;i=e.pull[a.i]||((t.pxmid[1]-a.pxmid[1])*f>0?(s=a.cyFinal+c(a.px0[1],a.px1[1]),b=s-v-t.labelExtraY,b*f>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-y)*f>0&&(n=3*u*Math.abs(i-p.indexOf(t)),h=a.cxFinal+l(a.px0[0],a.px1[0]),d=h+n-(t.cxFinal+t.pxmid[0])-t.labelExtraX,d*u>0&&(t.labelExtraX+=d)))}var a,o,s,l,c,u,f,h,d,p,g,v,m;for(o=0;2>o;o++)for(s=o?r:n,c=o?Math.max:Math.min,f=o?1:-1,a=0;2>a;a++){for(l=a?Math.max:Math.min,u=a?1:-1,h=t[o][a],h.sort(s),d=t[1-o][a],p=d.concat(h),v=[],g=0;gu&&(u=s.pull[a]);o.r=Math.min(r/c(s.tilt,Math.sin(l),s.depth),n/c(s.tilt,Math.cos(l),s.depth))/(2+2*u),o.cx=e.l+e.w*(s.domain.x[1]+s.domain.x[0])/2,o.cy=e.t+e.h*(2-s.domain.y[1]-s.domain.y[0])/2,s.scalegroup&&-1===d.indexOf(s.scalegroup)&&d.push(s.scalegroup)}for(a=0;af.vTotal/2?1:0)}function c(t,e,r){if(!t)return 1;var n=Math.sin(t*Math.PI/180);return Math.max(.01,r*n*Math.abs(e)+2*Math.sqrt(1-n*n*e*e))}var u=t("d3"),f=t("../../plots/cartesian/graph_interact"),h=t("../../components/color"),d=t("../../components/drawing"),p=t("../../lib/svg_text_utils"),g=t("./helpers");e.exports=function(t,e){var r=t._fullLayout;s(e,r._size);var c=r._pielayer.selectAll("g.trace").data(e);c.enter().append("g").attr({"stroke-linejoin":"round","class":"trace"}),c.exit().remove(),c.order(),c.each(function(e){var s=u.select(this),c=e[0],v=c.trace,m=0,y=(v.depth||0)*c.r*Math.sin(m)/2,b=v.tiltaxis||0,x=b*Math.PI/180,_=[y*Math.sin(x),y*Math.cos(x)],w=c.r*Math.cos(m),k=s.selectAll("g.part").data(v.tilt?["top","sides"]:["top"]);k.enter().append("g").attr("class",function(t){return t+" part"}),k.exit().remove(),k.order(),l(e),s.selectAll(".top").each(function(){var s=u.select(this).selectAll("g.slice").data(e);s.enter().append("g").classed("slice",!0),s.exit().remove();var l=[[[],[]],[[],[]]],m=!1;s.each(function(o){function s(e){var r=t._fullLayout,n=t._fullData[v.index],a=n.hoverinfo;if("all"===a&&(a="label+text+value+percent+name"),!t._dragging&&r.hovermode!==!1&&"none"!==a&&a){var s=i(o,c),l=k+o.pxmid[0]*(1-s),u=A+o.pxmid[1]*(1-s),h=[];-1!==a.indexOf("label")&&h.push(o.label),n.text&&n.text[o.i]&&-1!==a.indexOf("text")&&h.push(n.text[o.i]),-1!==a.indexOf("value")&&h.push(g.formatPieValue(o.v)),-1!==a.indexOf("percent")&&h.push(g.formatPiePercent(o.v/c.vTotal)),f.loneHover({x0:l-s*c.r,x1:l+s*c.r,y:u,text:h.join("
"),name:-1!==a.indexOf("name")?n.name:void 0,color:o.color,idealAlign:o.pxmid[0]<0?"left":"right"},{container:r._hoverlayer.node(),outerContainer:r._paper.node()}),f.hover(t,e,"pie"),E=!0}}function h(e){t.emit("plotly_unhover",{points:[e]}),E&&(f.loneUnhover(r._hoverlayer.node()),E=!1)}function y(){t._hoverdata=[o],t._hoverdata.trace=e.trace,f.click(t,{target:!0})}function x(t,e,r,n){return"a"+n*c.r+","+n*w+" "+b+" "+o.largeArc+(r?" 1 ":" 0 ")+n*(e[0]-t[0])+","+n*(e[1]-t[1])}if(o.hidden)return void u.select(this).selectAll("path,g").remove();l[o.pxmid[1]<0?0:1][o.pxmid[0]<0?0:1].push(o);var k=c.cx+_[0],A=c.cy+_[1],M=u.select(this),T=M.selectAll("path.surface").data([o]),E=!1;if(T.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),M.select("path.textline").remove(),M.on("mouseover",s).on("mouseout",h).on("click",y),v.pull){var L=+(Array.isArray(v.pull)?v.pull[o.i]:v.pull)||0;L>0&&(k+=L*o.pxmid[0],A+=L*o.pxmid[1])}o.cxFinal=k,o.cyFinal=A;var S=v.hole;if(o.v===c.vTotal){var C="M"+(k+o.px0[0])+","+(A+o.px0[1])+x(o.px0,o.pxmid,!0,1)+x(o.pxmid,o.px0,!0,1)+"Z";S?T.attr("d","M"+(k+S*o.px0[0])+","+(A+S*o.px0[1])+x(o.px0,o.pxmid,!1,S)+x(o.pxmid,o.px0,!1,S)+"Z"+C):T.attr("d",C)}else{var z=x(o.px0,o.px1,!0,1);if(S){var P=1-S;T.attr("d","M"+(k+S*o.px1[0])+","+(A+S*o.px1[1])+x(o.px1,o.px0,!1,S)+"l"+P*o.px0[0]+","+P*o.px0[1]+z+"Z")}else T.attr("d","M"+k+","+A+"l"+o.px0[0]+","+o.px0[1]+z+"Z")}var R=Array.isArray(v.textposition)?v.textposition[o.i]:v.textposition,O=M.selectAll("g.slicetext").data(o.text&&"none"!==R?[0]:[]);O.enter().append("g").classed("slicetext",!0),O.exit().remove(),O.each(function(){var t=u.select(this).selectAll("text").data([0]);t.enter().append("text").attr("data-notex",1),t.exit().remove(),t.text(o.text).attr({"class":"slicetext",transform:"","data-bb":"","text-anchor":"middle",x:0,y:0}).call(d.font,"outside"===R?v.outsidetextfont:v.insidetextfont).call(p.convertToTspans),t.selectAll("tspan.line").attr({x:0,y:0});var e,r=d.bBox(t.node());"outside"===R?e=a(r,o):(e=n(r,o,c),"auto"===R&&e.scale<1&&(t.call(d.font,v.outsidetextfont),v.outsidetextfont.family===v.insidetextfont.family&&v.outsidetextfont.size===v.insidetextfont.size||(t.attr({"data-bb":""}),r=d.bBox(t.node())),e=a(r,o)));var i=k+o.pxmid[0]*e.rCenter+(e.x||0),s=A+o.pxmid[1]*e.rCenter+(e.y||0);e.outside&&(o.yLabelMin=s-r.height/2,o.yLabelMid=s,o.yLabelMax=s+r.height/2,o.labelExtraX=0,o.labelExtraY=0,m=!0),t.attr("transform","translate("+i+","+s+")"+(e.scale<1?"scale("+e.scale+")":"")+(e.rotate?"rotate("+e.rotate+")":"")+"translate("+-(r.left+r.right)/2+","+-(r.top+r.bottom)/2+")")})}),m&&o(l,v),s.each(function(t){if(t.labelExtraX||t.labelExtraY){var e=u.select(this),r=e.select("g.slicetext text");r.attr("transform","translate("+t.labelExtraX+","+t.labelExtraY+")"+r.attr("transform"));var n=t.cxFinal+t.pxmid[0],i=t.cyFinal+t.pxmid[1],a="M"+n+","+i,o=(t.yLabelMax-t.yLabelMin)*(t.pxmid[0]<0?-1:1)/4;if(t.labelExtraX){var s=t.labelExtraX*t.pxmid[1]/t.pxmid[0],l=t.yLabelMid+t.labelExtraY-(t.cyFinal+t.pxmid[1]);a+=Math.abs(s)>Math.abs(l)?"l"+l*t.pxmid[0]/t.pxmid[1]+","+l+"H"+(n+t.labelExtraX+o):"l"+t.labelExtraX+","+s+"v"+(l-s)+"h"+o}else a+="V"+(t.yLabelMid+t.labelExtraY)+"h"+o;e.append("path").classed("textline",!0).call(h.stroke,v.outsidetextfont.color).attr({"stroke-width":Math.min(2,v.outsidetextfont.size/8),d:a,fill:"none"})}})})}),setTimeout(function(){c.selectAll("tspan").each(function(){var t=u.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":303,"../../components/drawing":325,"../../lib/svg_text_utils":390,"../../plots/cartesian/graph_interact":406,"./helpers":538,d3:72}],543:[function(t,e,r){"use strict";var n=t("d3"),i=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0],r=e.trace,a=n.select(this);a.style({opacity:r.opacity}),a.selectAll(".top path.surface").each(function(t){n.select(this).call(i,t,r)})})}},{"./style_one":544,d3:72}],544:[function(t,e,r){"use strict";var n=t("../../components/color");e.exports=function(t,e,r){var i=r.marker.line.color;Array.isArray(i)&&(i=i[e.i]||n.defaultLine);var a=r.marker.line.width||0;Array.isArray(a)&&(a=a[e.i]||0),t.style({"stroke-width":a,fill:e.color}).call(n.stroke,i)}},{"../../components/color":303}],545:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t){var e=t[0].trace,r=e.marker;if(n.mergeArray(e.text,t,"tx"),n.mergeArray(e.textposition,t,"tp"),e.textfont&&(n.mergeArray(e.textfont.size,t,"ts"),n.mergeArray(e.textfont.color,t,"tc"),n.mergeArray(e.textfont.family,t,"tf")),r&&r.line){var i=r.line;n.mergeArray(r.opacity,t,"mo"),n.mergeArray(r.symbol,t,"mx"),n.mergeArray(r.color,t,"mc"),n.mergeArray(i.color,t,"mlc"),n.mergeArray(i.width,t,"mlw")}}},{"../../lib":378}],546:[function(t,e,r){"use strict";var n=t("../../components/drawing");t("./constants");e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number",min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:{symbol:{valType:"enumerated",values:n.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},color:{valType:"color",arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number",dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},colorscale:{valType:"colorscale"},cauto:{valType:"boolean",dflt:!0},cmax:{valType:"number",dflt:null},cmin:{valType:"number",dflt:null},autocolorscale:{valType:"boolean",dflt:!0},reversescale:{valType:"boolean",dflt:!1},showscale:{valType:"boolean",dflt:!1},line:{color:{valType:"color",arrayOk:!0},width:{valType:"number",min:0,arrayOk:!0},colorscale:{valType:"colorscale"},cauto:{valType:"boolean",dflt:!0},cmax:{valType:"number",dflt:null},cmin:{valType:"number",dflt:null},autocolorscale:{valType:"boolean",dflt:!0},reversescale:{valType:"boolean",dflt:!1}}},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:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/drawing":325,"./constants":550}],547:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./subtypes"),s=t("./marker_colorscale_calc");e.exports=function(t,e){var r=i.getFromId(t,e.xaxis||"x"),l=i.getFromId(t,e.yaxis||"y");a.markTime("in Scatter.calc");var c=r.makeCalcdata(e,"x");a.markTime("finished convert x");var u=l.makeCalcdata(e,"y");a.markTime("finished convert y");var f,h,d,p=Math.min(c.length,u.length);r._minDtick=0,l._minDtick=0,c.length>p&&c.splice(p,c.length-p),u.length>p&&u.splice(p,u.length-p);var g={padded:!0},v={padded:!0};if(o.hasMarkers(e)){if(f=e.marker,h=f.size,Array.isArray(h)){var m={type:"linear"};i.setConvert(m),h=m.makeCalcdata(e.marker,"size"),h.length>p&&h.splice(p,h.length-p)}var y,b=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/b),3)}:function(t){return Math.max((t||0)/b,3)},g.ppad=v.ppad=Array.isArray(h)?h.map(y):y(h)}s(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||c[0]===c[p-1]&&u[0]===u[p-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(o.hasMarkers(e)||o.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||c[0]===c[p-1]&&u[0]===u[p-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(v.padded=!1):v.tozero=!0,a.markTime("ready for Axes.expand"),i.expand(r,c,g),a.markTime("done expand x"),i.expand(l,u,v),a.markTime("done expand y");var x=new Array(p);for(d=0;p>d;d++)x[d]=n(c[d])&&n(u[d])?{x:c[d],y:u[d]}:{x:!1,y:!1};return void 0!==typeof h&&a.mergeArray(h,x,"ms"),t.firstscatter=!1,x}},{"../../lib":378,"../../plots/cartesian/axes":399,"./marker_colorscale_calc":560,"./subtypes":565,"fast-isnumeric":76}],548:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i,a;for(e=0;e=0;i--)if(a=t[i],"scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}},{}],549:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c=r.marker,u="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void o.autoMargin(t,u);var f=s(c.colorscale),h=c.color,d=c.cmin,p=c.cmax;i(d)||(d=a.aggNums(Math.min,null,h)),i(p)||(p=a.aggNums(Math.max,null,h));var g=e[0].t.cb=l(t,u);g.fillcolor(n.scale.linear().domain(f.map(function(t){return d+t[0]*(p-d)})).range(f.map(function(t){return t[1]}))).filllevels({start:d,end:p,size:(p-d)/254}).options(c.colorbar)(),a.markTime("done colorbar")}},{"../../components/colorbar/draw":306,"../../components/colorscale/get_scale":314,"../../lib":378,"../../plots/plots":447,d3:72,"fast-isnumeric":76}],550:[function(t,e,r){"use strict";e.exports={PTS_LINESONLY:20}},{}],551:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("./constants"),o=t("./subtypes"),s=t("./xy_defaults"),l=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),h=t("./fillcolor_defaults"),d=t("../../components/errorbars/defaults");e.exports=function(t,e,r,p){function g(r,a){return n.coerce(t,e,i,r,a)}var v=s(t,e,g),m=vi(f))break;l=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,c=f,d=!1):m>y&&(m=y,u=f,d=!0)}if(d?(C[z++]=c,l!==u&&(C[z++]=u)):(u!==s&&(C[z++]=u),l!==c&&(C[z++]=c)),C[z++]=l,o>=t.length||!f)break;C[z++]=f,s=f}}else C[z++]=c}E.push(C.slice(0,z))}return E}},{"../../plots/cartesian/axes":399}],558:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=r("line.shape");"spline"===n&&r("line.smoothing")}},{}],559:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t){var e=t.marker,r=e.sizeref||1,i=e.sizemin||0,a="area"===e.sizemode?function(t){return Math.sqrt(t/r)}:function(t){return t/r};return function(t){var e=a(t/2);return n(e)&&e>0?Math.max(e,i):0}}},{"fast-isnumeric":76}],560:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("./subtypes");e.exports=function(t){if(a.hasMarkers(t)){var e=t.marker;n(t,"marker")&&i(t,e.color,"marker","c"),n(t,"marker.line")&&i(t,e.line.color,"marker.line","c")}}},{"../../components/colorscale/calc":310,"../../components/colorscale/has_colorscale":315,"./subtypes":565}],561:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l){var c,u=o.isBubble(t),f=(t.line||{}).color;f&&(r=f),l("marker.symbol"),l("marker.opacity",u?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),c=f&&e.marker.color!==f?f:u?n.background:n.defaultLine,l("marker.line.color",c),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",u?1:0),u&&(l("marker.sizeref"), -l("marker.sizemin"),l("marker.sizemode"))}},{"../../components/color":303,"../../components/colorscale/defaults":312,"../../components/colorscale/has_colorscale":315,"./subtypes":565}],562:[function(t,e,r){"use strict";function n(t,e,r){var n=e.x(),a=e.y(),o=i.extent(n.range.map(n.l2c)),s=i.extent(a.range.map(a.l2c));r.forEach(function(t,e){var n=t[0].trace;if(l.hasMarkers(n)){var i=n.marker.maxdisplayed;if(0!==i){var a=t.filter(function(t){return t.x>=o[0]&&t.x<=o[1]&&t.y>=s[0]&&t.y<=s[1]}),c=Math.ceil(a.length/i),u=0;r.forEach(function(t,r){var n=t[0].trace;l.hasMarkers(n)&&n.marker.maxdisplayed>0&&e>r&&u++});var f=Math.round(u*c/3+Math.floor(u/3)*c/7.1);t.forEach(function(t){delete t.vis}),a.forEach(function(t,e){0===Math.round((e+f)%c)&&(t.vis=!0)})}}})}var i=t("d3"),a=t("../../lib"),o=t("../../components/drawing"),s=t("../../components/errorbars"),l=t("./subtypes"),c=t("./arrays_to_calcdata"),u=t("./line_points");e.exports=function(t,e,r){function f(t){return t.filter(function(t){return t.vis})}n(t,e,r);var h=e.x(),d=e.y(),p=e.plot.select(".scatterlayer").selectAll("g.trace.scatter").data(r);p.enter().append("g").attr("class","trace scatter").style("stroke-miterlimit",2),p.call(s.plot,e);var g,v,m,y,b="";p.each(function(t){var e=t[0].trace,r=e.line,n=i.select(this);if(e.visible===!0&&(v=e.fill.charAt(e.fill.length-1),"x"!==v&&"y"!==v&&(v=""),t[0].node3=n,c(t),l.hasLines(e)||"none"!==e.fill)){var a,s,f,p,x,_="",w="";g="tozero"===e.fill.substr(0,6)||"toself"===e.fill||"to"===e.fill.substr(0,2)&&!b?n.append("path").classed("js-fill",!0):null,y&&(m=y.datum(t)),y=n.append("path").classed("js-fill",!0),-1!==["hv","vh","hvh","vhv"].indexOf(r.shape)?(f=o.steps(r.shape),p=o.steps(r.shape.split("").reverse().join(""))):f=p="spline"===r.shape?function(t){var e=t[t.length-1];return t[0][0]===e[0]&&t[0][1]===e[1]?o.smoothclosed(t.slice(1),r.smoothing):o.smoothopen(t,r.smoothing)}:function(t){return"M"+t.join("L")},x=function(t){return p(t.reverse())};var k=u(t,{xaxis:h,yaxis:d,connectGaps:e.connectgaps,baseTolerance:Math.max(r.width||1,3)/4,linear:"linear"===r.shape});if(k.length){for(var A=k[0][0],M=k[k.length-1],T=M[M.length-1],E=0;E1&&n.append("path").classed("js-line",!0).attr("d",a)}g?A&&T&&(v?("y"===v?A[1]=T[1]=d.c2p(0,!0):"x"===v&&(A[0]=T[0]=h.c2p(0,!0)),g.attr("d",_+"L"+T+"L"+A+"Z")):g.attr("d",_+"Z")):"tonext"===e.fill.substr(0,6)&&_&&b&&("tonext"===e.fill?m.attr("d",_+"Z"+b+"Z"):m.attr("d",_+"L"+b.substr(1)+"Z")),b=w}}}),p.selectAll("path:not([d])").remove(),p.append("g").attr("class","points").each(function(t){var e=t[0].trace,r=i.select(this),n=l.hasMarkers(e),s=l.hasText(e);!n&&!s||e.visible!==!0?r.remove():(n&&r.selectAll("path.point").data(e.marker.maxdisplayed?f:a.identity).enter().append("path").classed("point",!0).call(o.translatePoints,h,d),s&&r.selectAll("g").data(e.marker.maxdisplayed?f:a.identity).enter().append("g").append("text").call(o.translatePoints,h,d))})}},{"../../components/drawing":325,"../../components/errorbars":331,"../../lib":378,"./arrays_to_calcdata":545,"./line_points":557,"./subtypes":565,d3:72}],563:[function(t,e,r){"use strict";var n=t("./subtypes"),i=.2;e.exports=function(t,e){var r,a,o,s,l=t.cd,c=t.xaxis,u=t.yaxis,f=[],h=l[0].trace,d=h.index,p=h.marker;if(n.hasMarkers(h)||n.hasText(h)){var g=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(r=0;rs;s++){for(var l=[[0,0,0],[0,0,0]],c=0;3>c;c++)if(r[c])for(var u=0;2>u;u++)l[u][c]=r[c][s][u];o[s]=l}return o}var o=t("../../components/errorbars/compute_error");e.exports=a},{"../../components/errorbars/compute_error":329}],571:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.linePlot=null,this.scatterPlot=null,this.errorBars=null,this.textMarkers=null,this.delaunayMesh=null,this.color=null,this.mode="",this.dataPoints=[],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.textLabels=null,this.data=null}function i(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],s=[];for(n=0;ni;i++){var a=t[i];a&&a.copy_zstyle!==!1&&(a=t[2]),a&&(e[i]=a.width/2,r[i]=b(a.color),n=a.thickness)}return{capSize:e,color:r,lineWidth:n}}function o(t){var e=[0,0];return Array.isArray(t)?[0,-1]:(t.indexOf("bottom")>=0&&(e[1]+=1),t.indexOf("top")>=0&&(e[1]-=1),t.indexOf("left")>=0&&(e[0]-=1),t.indexOf("right")>=0&&(e[0]+=1),e)}function s(t,e){return e(4*t)}function l(t){return k[t]}function c(t,e,r,n,i){var a=null;if(Array.isArray(t)){a=[];for(var o=0;e>o;o++)void 0===t[o]?a[o]=n:a[o]=r(t[o],i)}else a=r(t,y.identity);return a}function u(t,e){var r,n,i,u,f,h,d=[],p=t.fullSceneLayout,g=t.dataScale,v=p.xaxis,m=p.yaxis,w=p.zaxis,k=e.marker,M=e.line,T=e.x||[],E=e.y||[],L=e.z||[],S=T.length;for(n=0;S>n;n++)i=v.d2l(T[n])*g[0],u=m.d2l(E[n])*g[1],f=w.d2l(L[n])*g[2],d[n]=[i,u,f];if(Array.isArray(e.text))h=e.text;else if(void 0!==e.text)for(h=new Array(S),n=0;S>n;n++)h[n]=e.text;if(r={position:d,mode:e.mode,text:h},"line"in e&&(r.lineColor=b(M.color),r.lineWidth=M.width,r.lineDashes=M.dash),"marker"in e){var C=_(e);r.scatterColor=x(k,1,S),r.scatterSize=c(k.size,S,s,20,C),r.scatterMarker=c(k.symbol,S,l,"\u25cf"),r.scatterLineWidth=k.line.width,r.scatterLineColor=x(k.line,1,S),r.scatterAngle=0}"textposition"in e&&(r.textOffset=o(e.textposition),r.textColor=x(e.textfont,1,S),r.textSize=c(e.textfont.size,S,y.identity,12),r.textFont=e.textfont.family,r.textAngle=0);var z=["x","y","z"];for(r.project=[!1,!1,!1],r.projectScale=[1,1,1],r.projectOpacity=[1,1,1],n=0;3>n;++n){var P=e.projection[z[n]];(r.project[n]=P.show)&&(r.projectOpacity[n]=P.opacity,r.projectScale[n]=P.scale)}r.errorBounds=A(e,g);var R=a([e.error_x,e.error_y,e.error_z]);return r.errorColor=R.color,r.errorLineWidth=R.lineWidth,r.errorCapSize=R.capSize,r.delaunayAxis=e.surfaceaxis,r.delaunayColor=b(e.surfacecolor),r}function f(t){if(Array.isArray(t)){var e=t[0];return Array.isArray(e)&&(t=e),"rgb("+t.slice(0,3).map(function(t){return Math.round(255*t)})+")"}return null}function h(t,e){var r=new n(t,e.uid);return r.update(e),r}var d=t("gl-line3d"),p=t("gl-scatter3d"),g=t("gl-error3d"),v=t("gl-mesh3d"),m=t("delaunay-triangulate"),y=t("../../lib"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/make_bubble_size_func"),w=t("../../constants/gl3d_dashes"),k=t("../../constants/gl_markers"),A=t("./calc_errors"),M=n.prototype;M.handlePick=function(t){if(t.object&&(t.object===this.linePlot||t.object===this.delaunayMesh||t.object===this.textMarkers||t.object===this.scatterPlot)){t.object.highlight&&t.object.highlight(null),this.scatterPlot&&(t.object=this.scatterPlot,this.scatterPlot.highlight(t.data)),this.textLabels&&void 0!==this.textLabels[t.data.index]?t.textLabel=this.textLabels[t.data.index]:t.textLabel="";var e=t.data.index;return t.traceCoordinate=[this.data.x[e],this.data.y[e],this.data.z[e]],!0}},M.update=function(t){var e,r,n,a,o=this.scene.glplot.gl,s=w.solid;this.data=t;var l=u(this.scene,t);"mode"in l&&(this.mode=l.mode),"lineDashes"in l&&l.lineDashes in w&&(s=w[l.lineDashes]),this.color=f(l.scatterColor)||f(l.lineColor),this.dataPoints=l.position,e={gl:o,position:l.position,color:l.lineColor,lineWidth:l.lineWidth||1,dashes:s[0],dashScale:s[1],opacity:t.opacity,connectGaps:t.connectgaps},-1!==this.mode.indexOf("lines")?this.linePlot?this.linePlot.update(e):(this.linePlot=d(e),this.scene.glplot.add(this.linePlot)):this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose(),this.linePlot=null);var c=t.opacity;if(t.marker&&t.marker.opacity&&(c*=t.marker.opacity),r={gl:o,position:l.position,color:l.scatterColor,size:l.scatterSize,glyph:l.scatterMarker,opacity:c,orthographic:!0,lineWidth:l.scatterLineWidth,lineColor:l.scatterLineColor,project:l.project,projectScale:l.projectScale,projectOpacity:l.projectOpacity},-1!==this.mode.indexOf("markers")?this.scatterPlot?this.scatterPlot.update(r):(this.scatterPlot=p(r),this.scatterPlot.highlightScale=1,this.scene.glplot.add(this.scatterPlot)):this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose(),this.scatterPlot=null),a={gl:o,position:l.position,glyph:l.text,color:l.textColor,size:l.textSize,angle:l.textAngle,alignment:l.textOffset,font:l.textFont,orthographic:!0,lineWidth:0,project:!1,opacity:t.opacity},this.textLabels=l.text,-1!==this.mode.indexOf("text")?this.textMarkers?this.textMarkers.update(a):(this.textMarkers=p(a),this.textMarkers.highlightScale=1,this.scene.glplot.add(this.textMarkers)):this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose(),this.textMarkers=null),n={gl:o,position:l.position,color:l.errorColor,error:l.errorBounds,lineWidth:l.errorLineWidth,capSize:l.errorCapSize,opacity:t.opacity},this.errorBars?l.errorBounds?this.errorBars.update(n):(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose(),this.errorBars=null):l.errorBounds&&(this.errorBars=g(n),this.scene.glplot.add(this.errorBars)),l.delaunayAxis>=0){var h=i(l.position,l.delaunayColor,l.delaunayAxis);h.opacity=t.opacity,this.delaunayMesh?this.delaunayMesh.update(h):(h.gl=o,this.delaunayMesh=v(h),this.scene.glplot.add(this.delaunayMesh))}else this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose(),this.delaunayMesh=null)},M.dispose=function(){this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose()),this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose()),this.errorBars&&(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose()),this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose()),this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose())},e.exports=h},{"../../constants/gl3d_dashes":364,"../../constants/gl_markers":365,"../../lib":378,"../../lib/gl_format_color":376,"../../lib/str2rgbarray":389,"../scatter/make_bubble_size_func":559,"./calc_errors":570,"delaunay-triangulate":73,"gl-error3d":80,"gl-line3d":86,"gl-mesh3d":109,"gl-scatter3d":152}],572:[function(t,e,r){"use strict";function n(t,e,r){var n=0,i=r("x"),a=r("y"),o=r("z");return i&&a&&o&&(n=Math.min(i.length,a.length,o.length),n=0&&h("surfacecolor",p||g);for(var v=["x","y","z"],m=0;3>m;++m){var y="projection."+v[m];h(y+".show")&&(h(y+".opacity"),h(y+".scale"))}c(t,e,r,{axis:"z"}),c(t,e,r,{axis:"y",inherit:"z"}),c(t,e,r,{axis:"x",inherit:"z"})}},{"../../components/errorbars/defaults":330,"../../lib":378,"../scatter/line_defaults":556,"../scatter/marker_defaults":561,"../scatter/subtypes":565,"../scatter/text_defaults":566,"./attributes":568}],573:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../constants/gl_markers":365,"../../plots/gl3d":434,"../scatter/colorbar":549,"./attributes":568,"./calc":569,"./convert":571,"./defaults":572}],574:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=n.line,l=o.line;e.exports={lon:{valType:"data_array"},lat:{valType:"data_array"},locations:{valType:"data_array"},locationmode:{valType:"enumerated",values:["ISO-3","USA-states","country names"],dflt:"ISO-3"},mode:a({},n.mode,{dflt:"markers"}),text:a({},n.text,{}),line:{color:s.color,width:s.width,dash:s.dash},marker:{symbol:o.symbol,opacity:o.opacity,size:o.size,sizeref:o.sizeref,sizemin:o.sizemin,sizemode:o.sizemode,color:o.color,colorscale:o.colorscale,cauto:o.cauto,cmax:o.cmax,cmin:o.cmin,autocolorscale:o.autocolorscale,reversescale:o.reversescale,showscale:o.showscale,line:{color:l.color,width:l.width,colorscale:l.colorscale,cauto:l.cauto,cmax:l.cmax,cmin:l.cmin,autocolorscale:l.autocolorscale,reversescale:l.reversescale}},textfont:n.textfont,textposition:n.textposition,hoverinfo:a({},i.hoverinfo,{flags:["lon","lat","location","text","name"]}),_nestedModules:{"marker.colorbar":"Colorbar"}}},{"../../lib/extend":373,"../../plots/attributes":397,"../scatter/attributes":546}],575:[function(t,e,r){"use strict";var n=t("../scatter/marker_colorscale_calc");e.exports=function(t,e){var r=[{x:!1,y:!1,trace:e,t:{}}];return n(e),r}},{"../scatter/marker_colorscale_calc":560}],576:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=0,o=r("locations");return o?(r("locationmode"),a=o.length):(n=r("lon")||[],i=r("lat")||[],a=Math.min(n.length,i.length),an;n++)r[n]=[t.lon[n],t.lat[n]];return{type:"LineString",coordinates:r,trace:t}}function a(t,e){function r(e){var r=t.mockAxis;return c.tickText(r,r.c2l(e),"hover").text+"\xb0"}var n=e.hoverinfo;if("none"===n)return function(t){delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("location")&&Array.isArray(e.locations),o=-1!==i.indexOf("lon"),s=-1!==i.indexOf("lat"),l=-1!==i.indexOf("text");return function(t){var n=[];a?n.push(t.location):o&&s?n.push("("+r(t.lon)+", "+r(t.lat)+")"):o?n.push("lon: "+r(t.lon)):s&&n.push("lat: "+r(t.lat)),l&&n.push(t.tx||e.text),t.textLabel=n.join("
")}}function o(t){var e=Array.isArray(t.locations);return function(r,n){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:n,lon:r.lon,lat:r.lat,location:e?r.location:null}]}}}var s=t("d3"),l=t("../../plots/cartesian/graph_interact"),c=t("../../plots/cartesian/axes"),u=t("../../lib/topojson_utils").getTopojsonFeatures,f=t("../../lib/geo_location_utils").locationToFeature,h=t("../../lib/array_to_calc_item"),d=t("../../components/color"),p=t("../../components/drawing"),g=t("../scatter/subtypes"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){var r,i,a,o,s=[],l=Array.isArray(t.locations);l?(o=t.locations,r=o.length,i=u(t,e),a=function(t,e){var r=f(t.locationmode,o[e],i);return void 0!==r?r.properties.ct:void 0}):(r=t.lon.length,a=function(t,e){return[t.lon[e],t.lat[e]]});for(var c=0;r>c;c++){var h=a(t,c);if(h){var d={lon:h[0],lat:h[1],location:l?t.locations[c]:null};n(t,d,c),s.push(d)}}return s.length>0&&(s[0].trace=t),s},m.plot=function(t,e){var r=t.framework.select(".scattergeolayer").selectAll("g.trace.scattergeo").data(e,function(t){return t.uid});r.enter().append("g").attr("class","trace scattergeo"),r.exit().remove(),r.selectAll("*").remove(),r.each(function(t){var e=s.select(this);g.hasLines(t)&&e.selectAll("path.js-line").data([i(t)]).enter().append("path").classed("js-line",!0)}),r.each(function(e){function r(r,n){if(t.showHover){var i=t.projection([r.lon,r.lat]);h(r),l.loneHover({x:i[0],y:i[1],name:v?e.name:void 0,text:r.textLabel,color:r.mc||(e.marker||{}).color},{container:t.hoverContainer.node()}),y=d(r,n),t.graphDiv.emit("plotly_hover",y)}}function n(e,r){t.graphDiv.emit("plotly_click",d(e,r))}var i=s.select(this),c=g.hasMarkers(e),u=g.hasText(e);if(c||u){var f=m.calcGeoJSON(e,t.topojson),h=a(t,e),d=o(e),p=e.hoverinfo,v="all"===p||-1!==p.indexOf("name"),y=null;c&&i.selectAll("path.point").data(f).enter().append("path").classed("point",!0).on("mouseover",r).on("click",n).on("mouseout",function(){l.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",y)}).on("mousedown",function(){l.loneUnhover(t.hoverContainer)}).on("mouseup",r),u&&i.selectAll("g").data(f).enter().append("g").append("text")}}),m.style(t)},m.style=function(t){var e=t.framework.selectAll("g.trace.scattergeo");e.style("opacity",function(t){return t.opacity}),e.each(function(t){s.select(this).selectAll("path.point").call(p.pointStyle,t),s.select(this).selectAll("text").call(p.textPointStyle,t)}),e.selectAll("path.js-line").style("fill","none").each(function(t){var e=t.trace,r=e.line||{};s.select(this).call(d.stroke,r.color).call(p.dashLine,r.dash||"",r.width||0)})}},{"../../components/color":303,"../../components/drawing":325,"../../lib/array_to_calc_item":369,"../../lib/geo_location_utils":375,"../../lib/topojson_utils":391,"../../plots/cartesian/axes":399,"../../plots/cartesian/graph_interact":406,"../scatter/subtypes":565,"./attributes":574,d3:72}],579:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../constants/gl2d_dashes"),a=t("../../constants/gl_markers"),o=t("../../lib/extend").extendFlat,s=n.line,l=n.marker,c=l.line;e.exports={x:n.x,x0:n.x0,dx:n.dx,y:n.y,y0:n.y0,dy:n.dy,text:o({},n.text,{}),mode:{valType:"flaglist",flags:["lines","markers"],extras:["none"]},line:{color:s.color,width:s.width,dash:{valType:"enumerated",values:Object.keys(i),dflt:"solid"}},marker:{color:l.color,symbol:{valType:"enumerated",values:Object.keys(a),dflt:"circle",arrayOk:!0},size:l.size,sizeref:l.sizeref,sizemin:l.sizemin,sizemode:l.sizemode,opacity:l.opacity,colorscale:l.colorscale,cauto:l.cauto,cmax:l.cmax,cmin:l.cmin,autocolorscale:l.autocolorscale,reversescale:l.reversescale,showscale:l.showscale,line:{color:c.color,width:c.width,colorscale:c.colorscale,cauto:c.cauto,cmax:c.cmax,cmin:c.cmin,autocolorscale:c.autocolorscale,reversescale:c.reversescale}},fill:o({},n.fill,{values:["none","tozeroy","tozerox"]}),fillcolor:n.fillcolor,_nestedModules:{error_x:"ErrorBars",error_y:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../constants/gl2d_dashes":363,"../../constants/gl_markers":365,"../../lib/extend":373,"../scatter/attributes":546}],580:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.xData=[],this.yData=[],this.textLabels=[],this.color="rgb(0, 0, 0)",this.name="",this.hoverinfo="all",this.idToIndex=[],this.bounds=[0,0,0,0],this.hasLines=!1,this.lineOptions={positions:new Float32Array,color:[0,0,0,1],width:1,fill:[!1,!1,!1,!1],fillColor:[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],dashes:[1]},this.line=d(t.glplot,this.lineOptions),this.line._trace=this,this.hasErrorX=!1,this.errorXOptions={positions:new Float32Array,errors:new Float32Array,lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorX=p(t.glplot,this.errorXOptions),this.errorX._trace=this,this.hasErrorY=!1,this.errorYOptions={positions:new Float32Array,errors:new Float32Array,lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorY=p(t.glplot,this.errorYOptions),this.errorY._trace=this,this.hasMarkers=!1,this.scatterOptions={positions:new Float32Array,sizes:[],colors:[],glyphs:[],borderWidths:[],borderColors:[],size:12,color:[0,0,0,1],borderSize:1,borderColor:[0,0,0,1]},this.scatter=f(t.glplot,this.scatterOptions),this.scatter._trace=this,this.fancyScatter=h(t.glplot,this.scatterOptions),this.fancyScatter._trace=this}function i(t,e,r){return Array.isArray(e)||(e=[e]),a(t,e,r)}function a(t,e,r){for(var n=new Array(r),i=e[0],a=0;r>a;++a)n[a]=t(a>=e.length?i:e[a]);return n}function o(t,e,r){return l(S(t,r),L(e,r),r)}function s(t,e,r,n){var i=x(t,e,n);return i=Array.isArray(i[0])?i:a(v.identity,[i],n),l(i,L(r,n),n)}function l(t,e,r){for(var n=new Array(4*r),i=0;r>i;++i){for(var a=0;3>a;++a)n[4*i+a]=t[i][a];n[4*i+3]=t[i][3]*e[i]}return n}function c(t,e){if(void 0===Float32Array.slice){for(var r=new Float32Array(e),n=0;e>n;n++)r[n]=t[n];return r}return t.slice(0,e)}function u(t,e){var r=new n(t,e.uid);return r.update(e),r}var f=t("gl-scatter2d"),h=t("gl-scatter2d-fancy"),d=t("gl-line2d"),p=t("gl-error2d"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../plots/cartesian/axes"),y=t("../../components/errorbars"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/subtypes"),w=t("../scatter/make_bubble_size_func"),k=t("../scatter/get_trace_color"),A=t("../../constants/gl_markers"),M=t("../../constants/gl2d_dashes"),T=["xaxis","yaxis"],E=n.prototype;E.handlePick=function(t){var e=this.idToIndex[t.pointId];return{trace:this,dataCoord:t.dataCoord,traceCoord:[this.xData[e],this.yData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:Array.isArray(this.color)?this.color[e]:this.color,name:this.name,hoverinfo:this.hoverinfo}},E.isFancy=function(t){if("linear"!==this.scene.xaxis.type)return!0;if("linear"!==this.scene.yaxis.type)return!0;if(!t.x||!t.y)return!0;var e=t.marker||{};if(Array.isArray(e.symbol)||"circle"!==e.symbol||Array.isArray(e.size)||Array.isArray(e.line.width)||Array.isArray(e.opacity))return!0;var r=e.color;if(Array.isArray(r))return!0;var n=Array.isArray(e.line.color);return Array.isArray(n)?!0:this.hasErrorX?!0:!!this.hasErrorY};var L=i.bind(null,function(t){return+t}),S=i.bind(null,b),C=i.bind(null,function(t){return A[t]||"\u25cf"});E.update=function(t){t.visible!==!0?(this.hasLines=!1,this.hasErrorX=!1,this.hasErrorY=!1,this.hasMarkers=!1):(this.hasLines=_.hasLines(t),this.hasErrorX=t.error_x.visible===!0,this.hasErrorY=t.error_y.visible===!0,this.hasMarkers=_.hasMarkers(t)),this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.isFancy(t)?this.updateFancy(t):this.updateFast(t),this.color=k(t,{})},E.updateFast=function(t){for(var e,r,n=this.xData=t.x,i=this.yData=t.y,a=n.length,o=new Array(a),s=new Float32Array(2*a),l=this.bounds,u=0,f=0,h=0;a>h;++h)e=n[h],r=i[h],g(e)&&g(r)&&(o[u++]=h,s[f++]=e,s[f++]=r,l[0]=Math.min(l[0],e),l[1]=Math.min(l[1],r),l[2]=Math.max(l[2],e),l[3]=Math.max(l[3],r));s=c(s,f),this.idToIndex=o,this.updateLines(t,s),this.updateError("X",t),this.updateError("Y",t);var d;if(this.hasMarkers){this.scatterOptions.positions=s;var p=b(t.marker.color),v=b(t.marker.line.color),m=t.opacity*t.marker.opacity;p[3]*=m,this.scatterOptions.color=p,v[3]*=m,this.scatterOptions.borderColor=v,d=t.marker.size,this.scatterOptions.size=d,this.scatterOptions.borderSize=t.marker.line.width,this.scatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions),this.expandAxesFast(l,d)},E.updateFancy=function(t){var e,r,n,a,o,l,u,f,h=this.scene,d=h.xaxis,p=h.yaxis,g=this.bounds,v=this.xData=d.makeCalcdata(t,"x"),m=this.yData=p.makeCalcdata(t,"y"),b=y.calcFromTrace(t,h.fullLayout),x=v.length,_=new Array(x),k=new Float32Array(2*x),A=new Float32Array(4*x),M=new Float32Array(4*x),T=0,E=0,S=0,z=0,P="log"===d.type?function(t){return d.d2l(t)}:function(t){return t},R="log"===p.type?function(t){return p.d2l(t)}:function(t){return t};for(e=0;x>e;++e)n=P(v[e]),a=R(m[e]),isNaN(n)||isNaN(a)||(_[T++]=e,k[E++]=n,k[E++]=a,o=A[S++]=n-b[e].xs||0,l=A[S++]=b[e].xh-n||0,A[S++]=0,A[S++]=0,M[z++]=0,M[z++]=0,u=M[z++]=a-b[e].ys||0,f=M[z++]=b[e].yh-a||0,g[0]=Math.min(g[0],n-o),g[1]=Math.min(g[1],a-u),g[2]=Math.max(g[2],n+l),g[3]=Math.max(g[3],a+f));k=c(k,E),this.idToIndex=_,this.updateLines(t,k),this.updateError("X",t,k,A),this.updateError("Y",t,k,M);var O;if(this.hasMarkers){this.scatterOptions.positions=k,this.scatterOptions.sizes=new Array(T),this.scatterOptions.glyphs=new Array(T),this.scatterOptions.borderWidths=new Array(T),this.scatterOptions.colors=new Array(4*T),this.scatterOptions.borderColors=new Array(4*T);var I,N=w(t),j=t.marker,F=j.opacity,D=t.opacity,B=s(j,F,D,x),U=C(j.symbol,x),V=L(j.line.width,x),q=s(j.line,F,D,x);for(O=i(N,j.size,x),e=0;T>e;++e)for(I=_[e],this.scatterOptions.sizes[e]=4*O[I],this.scatterOptions.glyphs[e]=U[I],this.scatterOptions.borderWidths[e]=.5*V[I],r=0;4>r;++r)this.scatterOptions.colors[4*e+r]=B[4*I+r],this.scatterOptions.borderColors[4*e+r]=q[4*I+r];this.fancyScatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions),this.expandAxesFancy(v,m,O)},E.updateLines=function(t,e){if(this.hasLines){this.lineOptions.positions=e;var r=b(t.line.color);this.hasMarkers&&(r[3]*=t.marker.opacity);for(var n=Math.round(.5*this.lineOptions.width),i=(M[t.line.dash]||[1]).slice(),a=0;ao;o++)r=this.scene[T[o]],n=r._min,n||(n=[]),n.push({val:t[o],pad:a}),i=r._max,i||(i=[]),i.push({val:t[o+2],pad:a})},E.expandAxesFancy=function(t,e,r){var n=this.scene,i={padded:!0,ppad:r};m.expand(n.xaxis,t,i),m.expand(n.yaxis,e,i)},E.dispose=function(){this.line.dispose(),this.errorX.dispose(),this.errorY.dispose(),this.scatter.dispose(),this.fancyScatter.dispose()},e.exports=u},{"../../components/errorbars":331,"../../constants/gl2d_dashes":363,"../../constants/gl_markers":365,"../../lib":378,"../../lib/gl_format_color":376,"../../lib/str2rgbarray":389,"../../plots/cartesian/axes":399,"../scatter/get_trace_color":553,"../scatter/make_bubble_size_func":559, -"../scatter/subtypes":565,"fast-isnumeric":76,"gl-error2d":78,"gl-line2d":84,"gl-scatter2d":149,"gl-scatter2d-fancy":144}],581:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/xy_defaults"),s=t("../scatter/marker_defaults"),l=t("../scatter/line_defaults"),c=t("../scatter/fillcolor_defaults"),u=t("../../components/errorbars/defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p=o(t,e,d);return p?(d("text"),d("mode",pr;r++)y=e.a[r],b=e.b[r],x=e.c[r],n(y)&&n(b)&&n(x)?(y=+y,b=+b,x=+x,_=v/(y+b+x),1!==_&&(y*=_,b*=_,x*=_),k=y,w=x-b,M[r]={x:w,y:k,a:y,b:b,c:x}):M[r]={x:!1,y:!1};var T,E;if(o.hasMarkers(e)&&(T=e.marker,E=T.size,Array.isArray(E))){var L={type:"linear"};i.setConvert(L),E=L.makeCalcdata(e.marker,"size"),E.length>A&&E.splice(A,E.length-A)}return s(e),void 0!==typeof E&&a.mergeArray(E,M,"ms"),M}},{"../../lib":378,"../../plots/cartesian/axes":399,"../scatter/marker_colorscale_calc":560,"../scatter/subtypes":565,"fast-isnumeric":76}],585:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/marker_defaults"),s=t("../scatter/line_defaults"),l=t("../scatter/line_shape_defaults"),c=t("../scatter/text_defaults"),u=t("../scatter/fillcolor_defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p,g=d("a"),v=d("b"),m=d("c");if(g?(p=g.length,v?(p=Math.min(p,v.length),m&&(p=Math.min(p,m.length))):p=m?Math.min(p,m.length):0):v&&m&&(p=Math.min(v.length,m.length)),!p)return void(e.visible=!1);g&&p"),s}}},{"../../plots/cartesian/axes":399,"../scatter/hover":554}],587:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../plots/ternary":454,"../scatter/colorbar":549,"./attributes":583,"./calc":584,"./defaults":585,"./hover":586,"./plot":588,"./select":589,"./style":590}],588:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e){for(var r={x:function(){return t.xaxis},y:function(){return t.yaxis},plot:t.plotContainer},i=new Array(e.length),a=t.graphDiv.calcdata,o=0;oe){for(var r=g/e,n=[0|Math.floor(t[0].shape[0]*r+1),0|Math.floor(t[0].shape[1]*r+1)],i=n[0]*n[1],o=0;or;++r)this.showContour[r]&&(e=!0,t[r]=this.scene.contourLevels[r]);e&&this.surface.update({levels:t})},v.update=function(t){var e,r=this.scene,n=r.fullSceneLayout,a=this.surface,s=t.opacity,l=i(t.colorscale,s),u=t.z,h=t.x,d=t.y,g=n.xaxis,v=n.yaxis,m=n.zaxis,y=r.dataScale,b=u[0].length,x=u.length,_=[c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x])],w=_[0],k=_[1],A=r.contourLevels;this.data=t,f(_[2],function(t,e){return m.d2l(u[e][t])*y[2]}),Array.isArray(h[0])?f(w,function(t,e){return g.d2l(h[e][t])*y[0]}):f(w,function(t){return g.d2l(h[t])*y[0]}),Array.isArray(d[0])?f(k,function(t,e){return v.d2l(d[e][t])*y[1]}):f(k,function(t,e){return v.d2l(d[e])*y[1]});var M={colormap:l,levels:[[],[],[]],showContour:[!0,!0,!0],showSurface:!t.hidesurface,contourProject:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],contourWidth:[1,1,1],contourColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],contourTint:[1,1,1],dynamicColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],dynamicWidth:[1,1,1],dynamicTint:[1,1,1],opacity:1};if(M.intensityBounds=[t.cmin,t.cmax],t.surfacecolor){var T=c(new Float32Array(b*x),[b,x]);f(T,function(e,r){return t.surfacecolor[r][e]}),_.push(T)}else M.intensityBounds[0]*=y[2],M.intensityBounds[1]*=y[2];this.dataScale=o(_),t.surfacecolor&&(M.intensity=_.pop()),"opacity"in t&&t.opacity<1&&(M.opacity=.25*t.opacity);var E=[!0,!0,!0],L=["x","y","z"];for(e=0;3>e;++e){var S=t.contours[L[e]];E[e]=S.highlight,M.showContour[e]=S.show||S.highlight,M.showContour[e]&&(M.contourProject[e]=[S.project.x,S.project.y,S.project.z],S.show?(this.showContour[e]=!0,M.levels[e]=A[e],a.highlightColor[e]=M.contourColor[e]=p(S.color),S.usecolormap?a.highlightTint[e]=M.contourTint[e]=0:a.highlightTint[e]=M.contourTint[e]=1,M.contourWidth[e]=S.width):this.showContour[e]=!1,S.highlight&&(M.dynamicColor[e]=p(S.highlightcolor),M.dynamicWidth[e]=S.highlightwidth))}M.coords=_,a.update(M),a.visible=t.visible,a.enableDynamic=E,a.snapToData=!0,"lighting"in t&&(a.ambientLight=t.lighting.ambient,a.diffuseLight=t.lighting.diffuse,a.specularLight=t.lighting.specular,a.roughness=t.lighting.roughness,a.fresnel=t.lighting.fresnel),s&&1>s&&(a.supportsTransparency=!0)},v.dispose=function(){this.scene.glplot.remove(this.surface),this.surface.dispose()},e.exports=s},{"../../lib/str2rgbarray":389,"gl-surface3d":180,ndarray:212,"ndarray-fill":205,"ndarray-homography":210,"ndarray-ops":211,tinycolor2:233}],595:[function(t,e,r){"use strict";function n(t,e,r){e in t&&!(r in t)&&(t[r]=t[e])}var i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}var c,u,f=l("z");if(!f)return void(e.visible=!1);var h=f[0].length,d=f.length;if(l("x"),l("y"),!Array.isArray(e.x))for(e.x=[],c=0;h>c;++c)e.x[c]=c;if(l("text"),!Array.isArray(e.y))for(e.y=[],c=0;d>c;++c)e.y[c]=c;l("lighting.ambient"),l("lighting.diffuse"),l("lighting.specular"),l("lighting.roughness"),l("lighting.fresnel"),l("hidesurface"),l("opacity");var p=l("surfacecolor");l("colorscale");var g=["x","y","z"];for(c=0;3>c;++c){var v="contours."+g[c],m=l(v+".show"),y=l(v+".highlight");if(m||y)for(u=0;3>u;++u)l(v+".project."+g[u]);m&&(l(v+".color"),l(v+".width"),l(v+".usecolormap")),y&&(l(v+".highlightcolor"),l(v+".highlightwidth"))}p||(n(t,"zmin","cmin"),n(t,"zmax","cmax"),n(t,"zauto","cauto")),a(t,e,s,l,{prefix:"",cLetter:"c"})}},{"../../components/colorscale/defaults":312,"../../lib":378,"./attributes":591}],596:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("./colorbar"),n.calc=t("./calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="surface",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","noOpacity"],n.meta={},e.exports=n},{"../../plots/gl3d":434,"./attributes":591,"./calc":592,"./colorbar":593,"./convert":594,"./defaults":595}]},{},[12])(12)}); \ No newline at end of file +path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],300:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:o({},i,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":376,"../../plots/cartesian/constants":408,"../../plots/font_attributes":421,"./arrow_paths":299}],301:[function(t,e,r){"use strict";function n(t,e){function r(e,r){return c.coerce(t,n,v.layoutAttributes,e,r)}var n={};r("opacity"),r("align"),r("bgcolor");var i=r("bordercolor"),a=f.opacity(i);r("borderpad");var o=r("borderwidth"),s=r("showarrow");s&&(r("arrowcolor",a?n.bordercolor:f.defaultLine),r("arrowhead"),r("arrowsize"),r("arrowwidth",2*(a&&o||1)),r("ax"),r("ay"),c.noneOrAll(t,n,["ax","ay"])),r("text",s?" ":"new text"),r("textangle"),c.coerceFont(r,"font",e.font);for(var l=["x","y"],h=0;2>h;h++){var d=l[h],p={_fullLayout:e},g=u.coerceRef(t,n,p,d),m=.5;if("paper"!==g){var y=u.getFromId(p,g);if(m=y.range[0]+m*(y.range[1]-y.range[0]),-1!==["date","category"].indexOf(y.type)&&"string"==typeof t[d]){var b;"date"===y.type?(b=c.dateTime2ms(t[d]),b!==!1&&(t[d]=b)):(y._categories||[]).length&&(b=y._categories.indexOf(t[d]),-1!==b&&(t[d]=b))}}r(d,m),s||r(d+"anchor")}return c.noneOrAll(t,n,["x","y"]),n}function i(t){var e=t._fullLayout;e.annotations.forEach(function(e){var r=u.getFromId(t,e.xref),n=u.getFromId(t,e.yref);if(r||n){var i=(e._xsize||0)/2,a=e._xshift||0,o=(e._ysize||0)/2,s=e._yshift||0,l=i-a,c=i+a,f=o-s,h=o+s;if(e.showarrow){var d=3*e.arrowsize*e.arrowwidth;l=Math.max(l,d),c=Math.max(c,d),f=Math.max(f,d),h=Math.max(h,d)}r&&r.autorange&&u.expand(r,[r.l2c(e.x)],{ppadplus:c,ppadminus:l}),n&&n.autorange&&u.expand(n,[n.l2c(e.y)],{ppadplus:h,ppadminus:f})}})}function a(t,e,r,n,i,a,o,s){var l=r-t,c=i-t,u=o-i,f=n-e,h=a-e,d=s-a,p=l*d-u*f;if(0===p)return null;var g=(c*d-u*h)/p,v=(c*f-l*h)/p;return 0>v||v>1||0>g||g>1?null:{x:t+l*g,y:e+f*g}}var o=t("d3"),s=t("fast-isnumeric"),l=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),h=t("../drawing"),d=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var r=t.annotations||[],i=e.annotations=[],a=0;at?"left":t>2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var n=W.select(".annotation-math-group"),i=!n.empty(),s=h.bBox((i?n:tt).node()),d=s.width,m=s.height,y=Math.round(d+2*$),b=Math.round(m+2*$);U._w=d,U._h=m;var x=!1;if(["x","y"].forEach(function(e){var n,i=u.getFromId(t,U[e+"ref"]||e),a=(G+("x"===e?0:90))*Math.PI/180,o=y*Math.abs(Math.cos(a))+b*Math.abs(Math.sin(a)),s=U[e+"anchor"];if(i){if(!i.autorange&&(U[e]-i.range[0])*(U[e]-i.range[1])>0)return void(x=!0);H[e]=i._offset+i.l2p(U[e]),n=.5}else n=U[e],"y"===e&&(n=1-n),H[e]="x"===e?S.l+S.w*n:S.t+S.h*n;var l=0;l=U.showarrow?U["a"+e]:o*r(n,s),H[e]+=l,U["_"+e+"type"]=i&&i.type,U["_"+e+"size"]=o,U["_"+e+"shift"]=l}),x)return void W.remove();var w,k;U.showarrow&&(w=c.constrain(H.x-U.ax,1,_.width-1),k=c.constrain(H.y-U.ay,1,_.height-1)),H.x=c.constrain(H.x,1,_.width-1),H.y=c.constrain(H.y,1,_.height-1);var A=$-s.top,M=$-s.left;i?n.select("svg").attr({x:$-1,y:$}):(tt.attr({x:M,y:A}),tt.selectAll("tspan.line").attr({y:A,x:M})),Q.call(h.setRect,Z/2,Z/2,y-Z,b-Z);var T=Math.round(H.x-y/2),E=Math.round(H.y-b/2);W.call(c.setTranslate,T,E);var L="annotations["+e+"]",C=function(r,n){o.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var i=H.x+r,s=H.y+n,u=c.rotationXYMatrix(G,i,s),h=c.apply2DTransform(u),d=c.apply2DTransform2(u),p=Q.attr("width")/2,m=Q.attr("height")/2,y=[[i-p,s-m,i-p,s+m],[i-p,s+m,i+p,s+m],[i+p,s+m,i+p,s-m],[i+p,s-m,i-p,s-m]].map(d);if(!y.reduce(function(t,e){return t^!!a(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=a(i,s,w,k,t[0],t[1],t[2],t[3]);e&&(i=e.x,s=e.y)});var b=U.arrowwidth,x=U.arrowcolor,_=Y.append("g").style({opacity:f.opacity(x)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),A=_.append("path").attr("d","M"+i+","+s+"L"+w+","+k).style("stroke-width",b+"px").call(f.stroke,f.rgb(x));v.arrowhead(A,U.arrowhead,"end",U.arrowsize);var M=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(i-w)+","+(s-k),transform:"translate("+w+","+k+")"}).style("stroke-width",b+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var T,E,C;g.init({element:M.node(),prepFn:function(){var t=c.getTranslate(W);E=t.x,C=t.y,T={},V&&V.autorange&&(T[V._name+".autorange"]=!0),q&&q.autorange&&(T[q._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var r=h(E,C),n=r[0]+t,i=r[1]+e;W.call(c.setTranslate,n,i),T[L+".x"]=V?U.x+t/V._m:(w+t-S.l)/S.w,T[L+".y"]=q?U.y+e/q._m:1-(k+e-S.t)/S.h,X.attr({transform:"rotate("+G+","+n+","+i+")"})},doneFn:function(e){if(e){l.relayout(t,T);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}};U.showarrow&&C(0,0);var z=c.rotationXYMatrix(G,H.x,H.y),P=c.apply2DTransform(z);if(t._context.editable){var R,O,I;g.init({element:W.node(),prepFn:function(){var t=c.getTranslate(W);R=t.x,O=t.y,I={}},moveFn:function(t,e){W.call(c.setTranslate,R+t,O+e);var r="pointer";if(U.showarrow)I[L+".ax"]=U.ax+t,I[L+".ay"]=U.ay+e,C(t,e);else{if(V)I[L+".x"]=U.x+t/V._m;else{var n=U._xsize/S.w,i=U.x+U._xshift/S.w-n/2;I[L+".x"]=g.align(i+t/S.w,n,0,1,U.xanchor)}if(q)I[L+".y"]=U.y+e/q._m;else{var a=U._ysize/S.h,o=U.y-U._yshift/S.h-a/2;I[L+".y"]=g.align(o-e/S.h,a,0,1,U.yanchor)}V&&q||(r=g.getCursor(V?.5:I[L+".x"],q?.5:I[L+".y"],U.xanchor,U.yanchor))}var s=P(R,O),l=s[0]+t,u=s[1]+e;W.call(c.setTranslate,R+t,O+e),X.attr({transform:"rotate("+G+","+l+","+u+")"}),p(W,r)},doneFn:function(e){if(p(W),e){l.relayout(t,I);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}var b,x=t.layout,_=t._fullLayout;if(!s(e)||-1===e){if(!e&&Array.isArray(i))return x.annotations=i,v.supplyLayoutDefaults(x,_),void v.drawAll(t);if("remove"===i)return delete x.annotations,_.annotations=[],void v.drawAll(t);if(r&&"add"!==i){for(b=0;b<_.annotations.length;b++)v.draw(t,b,r,i);return}e=_.annotations.length,_.annotations.push({})}if(!r&&i){if("remove"===i){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),x.annotations.splice(e,1),b=e;b<_.annotations.length;b++)_._infolayer.selectAll('.annotation[data-index="'+(b+1)+'"]').attr("data-index",String(b)),v.draw(t,b);return}if("add"===i||c.isPlainObject(i)){_.annotations.splice(e,0,{});var w=c.isPlainObject(i)?c.extendFlat({},i):{text:"New text"};for(x.annotations?x.annotations.splice(e,0,w):x.annotations=[w],b=_.annotations.length-1;b>e;b--)_._infolayer.selectAll('.annotation[data-index="'+(b-1)+'"]').attr("data-index",String(b)),v.draw(t,b)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=x.annotations[e],A=_.annotations[e];if(k){var M={xref:k.xref,yref:k.yref},T={};"string"==typeof r&&r?T[r]=i:c.isPlainObject(r)&&(T=r);var E=Object.keys(T);for(b=0;bb;b++){var z=C[b];if(void 0===T[z]&&void 0!==k[z]){var P=u.getFromId(t,u.coerceRef(M,{},t,z)),R=u.getFromId(t,u.coerceRef(k,{},t,z)),O=k[z],I=A["_"+z+"type"];if(void 0!==T[z+"ref"]){var N="auto"===k[z+"anchor"],j="x"===z?S.w:S.h,F=(A["_"+z+"size"]||0)/(2*j);if(P&&R)O=(O-P.range[0])/(P.range[1]-P.range[0]),O=R.range[0]+O*(R.range[1]-R.range[0]);else if(P){if(O=(O-P.range[0])/(P.range[1]-P.range[0]),O=P.domain[0]+O*(P.domain[1]-P.domain[0]),N){var D=O+F,B=O-F;2/3>O+B?O=B:O+D>4/3&&(O=D)}}else R&&(N&&(1/3>O?O+=F:O>2/3&&(O-=F)),O=(O-R.domain[0])/(R.domain[1]-R.domain[0]),O=R.range[0]+O*(R.range[1]-R.range[0]))}R&&R===P&&I&&("log"===I&&"log"!==R.type?O=Math.pow(10,O):"log"!==I&&"log"===R.type&&(O=O>0?Math.log(O)/Math.LN10:void 0)),k[z]=O}}var U=n(k,_);_.annotations[e]=U;var V=u.getFromId(t,U.xref),q=u.getFromId(t,U.yref),H={x:0,y:0},G=+U.textangle||0,Y=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",U.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:U})}),X=Y.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),W=X.append("g"),Z=U.borderwidth,K=U.borderpad,$=Z+K,Q=W.append("rect").attr("class","bg").style("stroke-width",Z+"px").call(f.stroke,U.bordercolor).call(f.fill,U.bgcolor),J=U.font,tt=W.append("text").classed("annotation",!0).attr("data-unformatted",U.text).text(U.text);t._context.editable?tt.call(d.makeEditable,W).call(m).on("edit",function(r){U.text=r,this.attr({"data-unformatted":U.text}),this.call(m);var n={};n["annotations["+e+"].text"]=U.text,V&&V.autorange&&(n[V._name+".autorange"]=!0),q&&q.autorange&&(n[q._name+".autorange"]=!0),l.relayout(t,n)}):tt.call(m),X.attr({transform:"rotate("+G+","+H.x+","+H.y+")"}).call(h.setPosition,H.x,H.y)}},v.arrowhead=function(t,e,r,n){s(n)||(n=1);var i=t.node(),a=v.ARROWPATHS[e||0];if(a){"string"==typeof r&&r||(r="end");var l,c,u,d,p=(h.getPx(t,"stroke-width")||1)*n,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=r.indexOf("start")>=0,b=r.indexOf("end")>=0,x=a.backoff*p;if("line"===i.nodeName){if(l={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(l.y-c.y,l.x-c.x),d=u+Math.PI,x){var _=x*Math.cos(u),w=x*Math.sin(u);y&&(l.x-=_,l.y-=w,t.attr({x1:l.x,y1:l.y})),b&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===i.nodeName){var k=i.getTotalLength(),A="";if(y){var M=i.getPointAtLength(0),T=i.getPointAtLength(.1);u=Math.atan2(M.y-T.y,M.x-T.x),l=i.getPointAtLength(Math.min(x,k)),x&&(A="0px,"+x+"px,")}if(b){var E=i.getPointAtLength(k),L=i.getPointAtLength(k-.1);if(d=Math.atan2(E.y-L.y,E.x-L.x),c=i.getPointAtLength(Math.max(0,k-x)),x){var S=A?2*x:x;A+=k-S+"px,"+k+"px"}}else A&&(A+=k+"px");A&&t.style("stroke-dasharray",A)}var C=function(r,n){e>5&&(n=0),o.select(i.parentElement).append("path").attr({"class":t.attr("class"),d:a.path,transform:"translate("+r.x+","+r.y+")rotate("+180*n/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(l,u),b&&C(c,d)}},v.calcAutorange=function(t){var e=t._fullLayout,r=e.annotations;if(r.length&&t._fullData.length){var n={};r.forEach(function(t){n[t.xref]=!0,n[t.yref]=!0});var a=u.list(t).filter(function(t){return t.autorange&&n[t._id]});if(a.length)return c.syncOrAsync([v.drawAll,i],t)}}},{"../../lib":381,"../../lib/setcursor":389,"../../lib/svg_text_utils":393,"../../plotly":400,"../../plots/cartesian/axes":403,"../color":303,"../dragelement":323,"../drawing":325,"./arrow_paths":299,"./attributes":300,d3:72,"fast-isnumeric":76}],302:[function(t,e,r){"use strict";r.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],r.defaultLine="#444",r.lightLine="#eee",r.background="#fff",r.lightFraction=1e3/11},{}],303:[function(t,e,r){"use strict";function n(t){if(a(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var r=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!r)return t;var n=r[1].trim().split(/\s*[\s,]\s*/),i="a"===e.charAt(3)&&4===n.length;if(!i&&3!==n.length)return t;for(var o=0;o=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}var i=t("tinycolor2"),a=t("fast-isnumeric"),o=e.exports={},s=t("./attributes");o.defaults=s.defaults,o.defaultLine=s.defaultLine,o.lightLine=s.lightLine,o.background=s.background,o.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},o.rgb=function(t){return o.tinyRGB(i(t))},o.opacity=function(t){return t?i(t).getAlpha():0},o.addOpacity=function(t,e){var r=i(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},o.combine=function(t,e){var r=i(t).toRgb();if(1===r.a)return i(t).toRgbString();var n=i(e||o.background).toRgb(),a=1===n.a?n:{r:255*(1-n.a)+n.r*n.a,g:255*(1-n.a)+n.g*n.a,b:255*(1-n.a)+n.b*n.a},s={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return i(s).toRgbString()},o.stroke=function(t,e){var r=i(e);t.style({stroke:o.tinyRGB(r),"stroke-opacity":r.getAlpha()})},o.fill=function(t,e){var r=i(e);t.style({fill:o.tinyRGB(r),"fill-opacity":r.getAlpha()})},o.clean=function(t){if(t&&"object"==typeof t){var e,r,i,a,s=Object.keys(t);for(e=0;el&&(a[1]-=(ot-l)/2)):r.node()&&!r.classed("js-placeholder")&&(ot=h.bBox(e.node()).height),ot){if(ot+=5,"top"===x.titleside)Q.domain[1]-=ot/M.h,a[1]*=-1;else{Q.domain[0]+=ot/M.h;var u=Math.max(1,r.selectAll("tspan.line").size());a[1]+=(1-u)*l}e.attr("transform","translate("+a+")"),Q.setScale()}}it.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(M.h*(1-Q.domain[1]))+")");var f=it.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var r=[0===e?E[0]:(S[e]+S[e-1])/2,e===S.length-1?E[1]:(S[e]+S[e+1])/2].map(Q.c2p).map(Math.round);e!==S.length-1&&(r[1]+=r[1]>r[0]?1:-1);var a=z(t).replace("e-",""),o=i(a).toHexString();n.select(this).attr({x:Y,width:Math.max(D,2),y:n.min(r),height:Math.max(n.max(r)-n.min(r),2),fill:o})});var d=it.select(".cblines").selectAll("path.cbline").data(x.line.color&&x.line.width?L:[]);return d.enter().append("path").classed("cbline",!0),d.exit().remove(),d.each(function(t){n.select(this).attr("d","M"+Y+","+(Math.round(Q.c2p(t))+x.line.width/2%1)+"h"+D).call(h.lineGroupStyle,x.line.width,C(t),x.line.dash)}),Q._axislayer.selectAll("g."+Q._id+"tick,path").remove(),Q._pos=Y+D+(x.outlinewidth||0)/2-("outside"===x.ticks?1:0),Q.side="right",c.syncOrAsync([function(){return s.doTicks(t,Q,!0)},function(){if(-1===["top","bottom"].indexOf(x.titleside)){var e=Q.titlefont.size,r=Q._offset+Q._length/2,i=M.l+(Q.position||0)*M.w+("right"===Q.side?10+e*(Q.showticklabels?1:.5):-10-e*(Q.showticklabels?.5:0));w("h"+Q._id+"title",{avoid:{selection:n.select(t).selectAll("g."+Q._id+"tick"),side:x.titleside,offsetLeft:M.l,offsetTop:M.t,maxShift:A.width},attributes:{x:i,y:r,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,r){var n,i=b();n=o.traceIs(i,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var a={propContainer:Q,propName:n,traceIndex:i.index,dfltName:"colorscale",containerGroup:it.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;it.selectAll("."+s+",."+s+"-math-group").remove(),p.draw(t,e,u(a,r||{}))}function k(){var r=D+x.outlinewidth/2+h.bBox(Q._axislayer.node()).width;if(N=at.select("text"),N.node()&&!N.classed("js-placeholder")){var n,i=at.select(".h"+Q._id+"title-math-group").node();n=i&&-1!==["top","bottom"].indexOf(x.titleside)?h.bBox(i).width:h.bBox(at.node()).right-Y-M.l,r=Math.max(r,n)}var a=2*x.xpad+r+x.borderwidth+x.outlinewidth/2,s=Z-K;it.select(".cbbg").attr({x:Y-x.xpad-(x.borderwidth+x.outlinewidth)/2,y:K-H,width:Math.max(a,2),height:Math.max(s+2*H,2)}).call(d.fill,x.bgcolor).call(d.stroke,x.bordercolor).style({"stroke-width":x.borderwidth}),it.selectAll(".cboutline").attr({x:Y,y:K+x.ypad+("top"===x.titleside?ot:0),width:Math.max(D,2),height:Math.max(s-2*x.ypad-ot,2)}).call(d.stroke,x.outlinecolor).style({fill:"None","stroke-width":x.outlinewidth});var l=({center:.5,right:1}[x.xanchor]||0)*a;it.attr("transform","translate("+(M.l-l)+","+M.t+")"),o.autoMargin(t,e,{x:x.x,y:x.y,l:a*({right:1,center:.5}[x.xanchor]||0),r:a*({left:1,center:.5}[x.xanchor]||0),t:s*({bottom:1,middle:.5}[x.yanchor]||0),b:s*({top:1,middle:.5}[x.yanchor]||0)})}var A=t._fullLayout,M=A._size;if("function"!=typeof x.fillcolor&&"function"!=typeof x.line.color)return void A._infolayer.selectAll("g."+e).remove();var T,E=n.extent(("function"==typeof x.fillcolor?x.fillcolor:x.line.color).domain()),L=[],S=[],C="function"==typeof x.line.color?x.line.color:function(){return x.line.color},z="function"==typeof x.fillcolor?x.fillcolor:function(){return x.fillcolor},P=x.levels.end+x.levels.size/100,R=x.levels.size,O=1.001*E[0]-.001*E[1],I=1.001*E[1]-.001*E[0];for(T=x.levels.start;0>(T-P)*R;T+=R)T>O&&I>T&&L.push(T);if("function"==typeof x.fillcolor)if(x.filllevels)for(P=x.filllevels.end+x.filllevels.size/100,R=x.filllevels.size,T=x.filllevels.start;0>(T-P)*R;T+=R)T>E[0]&&T1){var nt=Math.pow(10,Math.floor(Math.log(rt)/Math.LN10));tt*=nt*c.roundUp(rt/nt,[2,5,10]),(Math.abs(x.levels.start)/x.levels.size+1e-6)%1<2e-6&&(Q.tick0=0)}Q.dtick=tt}Q.domain=[W+G,W+V-G],Q.setScale();var it=A._infolayer.selectAll("g."+e).data([0]);it.enter().append("g").classed(e,!0).each(function(){var t=n.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),it.attr("transform","translate("+Math.round(M.l)+","+Math.round(M.t)+")");var at=it.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(M.l)+",-"+Math.round(M.t)+")");Q._axislayer=it.select(".cbaxis");var ot=0;if(-1!==["top","bottom"].indexOf(x.titleside)){var st,lt=M.l+(x.x+q)*M.w,ct=Q.titlefont.size;st="top"===x.titleside?(1-(W+V-G))*M.h+M.t+3+.75*ct:(1-(W+G))*M.h+M.t-3-.25*ct,w(Q._id+"title",{attributes:{x:lt,y:st,"text-anchor":"start"}})}var ut=c.syncOrAsync([o.previousPromises,_,o.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,ht,dt;l.init({element:it.node(),prepFn:function(){ft=it.attr("transform"),f(it)},moveFn:function(t,e){it.attr("transform",ft+" translate("+t+","+e+")"),ht=l.align(X+t/M.w,B,0,1,x.xanchor),dt=l.align(W-e/M.h,V,0,1,x.yanchor);var r=l.getCursor(ht,dt,x.xanchor,x.yanchor);f(it,r)},doneFn:function(e){f(it),e&&void 0!==ht&&void 0!==dt&&a.restyle(t,{"colorbar.x":ht,"colorbar.y":dt},b().index)}})}return ut}function b(){var r,n,i=e.substr(2);for(r=0;ru*f?i.RdBu:u>=0?i.Reds:i.Blues,l.colorscale=h,s.reversescale&&(h=a(h)),s.colorscale=h)}},{"../../lib":381,"./flip_scale":313,"./scales":320}],311:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":320}],312:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,c,u){var f=u.prefix,h=u.cLetter,d=f.slice(0,f.length-1),p=f?i.nestedProperty(t,d).get()||{}:t,g=f?i.nestedProperty(e,d).get()||{}:e,v=p[h+"min"],m=p[h+"max"],y=p.colorscale,b=n(v)&&n(m)&&m>v;c(f+h+"auto",!b),c(f+h+"min"),c(f+h+"max");var x;void 0!==y&&(x=!s(y)),c(f+"autocolorscale",x);var _=c(f+"colorscale"),w=c(f+"reversescale");if(w&&(g.colorscale=l(_)),"marker.line."!==f){var k;f&&(k=a(p));var A=c(f+"showscale",k);A&&o(p,g,r)}}},{"../../lib":381,"../colorbar/defaults":305,"../colorbar/has_colorbar":307,"./flip_scale":313,"./is_valid_scale":317,"fast-isnumeric":76}],313:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=t.length,n=new Array(r),i=r-1,a=0;i>=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],314:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return e||(e=i),t?("string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e):e}},{"./default_scale":311,"./is_valid_scale_array":318,"./scales":320}],315:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(Array.isArray(o))for(var l=0;lh;h++)l=t[h],u[h]=e+l[0]*(r-e),f[h]=i(l[1]).toRgb();var d=n.scale.linear().domain(u).interpolate(n.interpolateObject).range(f);return function(t){if(a(t)){var n=o.constrain(t,e,r),l=d(n);return i(l).toRgbString()}return i(t).isValid()?t:s.defaultLine}}},{"../../lib":381,"../color":303,d3:72,"fast-isnumeric":76,tinycolor2:233}],320:[function(t,e,r){"use strict";e.exports={Greys:[[0,"rgb(0,0,0)"],[1,"rgb(255,255,255)"]],YlGnBu:[[0,"rgb(8,29,88)"],[.125,"rgb(37,52,148)"],[.25,"rgb(34,94,168)"],[.375,"rgb(29,145,192)"],[.5,"rgb(65,182,196)"],[.625,"rgb(127,205,187)"],[.75,"rgb(199,233,180)"],[.875,"rgb(237,248,217)"],[1,"rgb(255,255,217)"]],Greens:[[0,"rgb(0,68,27)"],[.125,"rgb(0,109,44)"],[.25,"rgb(35,139,69)"],[.375,"rgb(65,171,93)"],[.5,"rgb(116,196,118)"],[.625,"rgb(161,217,155)"],[.75,"rgb(199,233,192)"],[.875,"rgb(229,245,224)"],[1,"rgb(247,252,245)"]],YlOrRd:[[0,"rgb(128,0,38)"],[.125,"rgb(189,0,38)"],[.25,"rgb(227,26,28)"],[.375,"rgb(252,78,42)"],[.5,"rgb(253,141,60)"],[.625,"rgb(254,178,76)"],[.75,"rgb(254,217,118)"],[.875,"rgb(255,237,160)"],[1,"rgb(255,255,204)"]], +Bluered:[[0,"rgb(0,0,255)"],[1,"rgb(255,0,0)"]],RdBu:[[0,"rgb(5,10,172)"],[.35,"rgb(106,137,247)"],[.5,"rgb(190,190,190)"],[.6,"rgb(220,170,132)"],[.7,"rgb(230,145,90)"],[1,"rgb(178,10,28)"]],Reds:[[0,"rgb(220,220,220)"],[.2,"rgb(245,195,157)"],[.4,"rgb(245,160,105)"],[1,"rgb(178,10,28)"]],Blues:[[0,"rgb(5,10,172)"],[.35,"rgb(40,60,190)"],[.5,"rgb(70,100,245)"],[.6,"rgb(90,120,245)"],[.7,"rgb(106,137,247)"],[1,"rgb(220,220,220)"]],Picnic:[[0,"rgb(0,0,255)"],[.1,"rgb(51,153,255)"],[.2,"rgb(102,204,255)"],[.3,"rgb(153,204,255)"],[.4,"rgb(204,204,255)"],[.5,"rgb(255,255,255)"],[.6,"rgb(255,204,255)"],[.7,"rgb(255,153,255)"],[.8,"rgb(255,102,204)"],[.9,"rgb(255,102,102)"],[1,"rgb(255,0,0)"]],Rainbow:[[0,"rgb(150,0,90)"],[.125,"rgb(0,0,200)"],[.25,"rgb(0,25,255)"],[.375,"rgb(0,152,255)"],[.5,"rgb(44,255,150)"],[.625,"rgb(151,255,0)"],[.75,"rgb(255,234,0)"],[.875,"rgb(255,111,0)"],[1,"rgb(255,0,0)"]],Portland:[[0,"rgb(12,51,131)"],[.25,"rgb(10,136,186)"],[.5,"rgb(242,211,56)"],[.75,"rgb(242,143,56)"],[1,"rgb(217,30,30)"]],Jet:[[0,"rgb(0,0,131)"],[.125,"rgb(0,60,170)"],[.375,"rgb(5,255,255)"],[.625,"rgb(255,255,0)"],[.875,"rgb(250,0,0)"],[1,"rgb(128,0,0)"]],Hot:[[0,"rgb(0,0,0)"],[.3,"rgb(230,0,0)"],[.6,"rgb(255,210,0)"],[1,"rgb(255,255,255)"]],Blackbody:[[0,"rgb(0,0,0)"],[.2,"rgb(230,0,0)"],[.4,"rgb(230,210,0)"],[.7,"rgb(255,255,255)"],[1,"rgb(160,200,255)"]],Earth:[[0,"rgb(0,0,130)"],[.1,"rgb(0,180,180)"],[.2,"rgb(40,210,40)"],[.4,"rgb(230,230,50)"],[.6,"rgb(120,70,20)"],[1,"rgb(255,255,255)"]],Electric:[[0,"rgb(0,0,0)"],[.15,"rgb(30,0,100)"],[.4,"rgb(120,0,100)"],[.6,"rgb(160,90,0)"],[.8,"rgb(230,200,0)"],[1,"rgb(255,250,220)"]],Viridis:[[0,"#440154"],[.06274509803921569,"#48186a"],[.12549019607843137,"#472d7b"],[.18823529411764706,"#424086"],[.25098039215686274,"#3b528b"],[.3137254901960784,"#33638d"],[.3764705882352941,"#2c728e"],[.4392156862745098,"#26828e"],[.5019607843137255,"#21918c"],[.5647058823529412,"#1fa088"],[.6274509803921569,"#28ae80"],[.6901960784313725,"#3fbc73"],[.7529411764705882,"#5ec962"],[.8156862745098039,"#84d44b"],[.8784313725490196,"#addc30"],[.9411764705882353,"#d8e219"],[1,"#fde725"]]}},{}],321:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i){var a=(t-r)/(n-r),o=a+e/(n-r),s=(a+o)/2;return"left"===i||"bottom"===i?a:"center"===i||"middle"===i?s:"right"===i||"top"===i?o:2/3-s>a?a:o>4/3-s?o:s}},{}],322:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":381}],323:[function(t,e,r){"use strict";function n(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function i(t){t._dragging=!1,t._replotPending&&a.plot(t)}var a=t("../../plotly"),o=t("../../lib"),s=t("../../plots/cartesian/constants"),l=e.exports={};l.align=t("./align"),l.getCursor=t("./cursor");var c=t("./unhover");l.unhover=c.wrapped,l.unhoverRaw=c.raw,l.init=function(t){function e(e){return p._dragged=!1,p._dragging=!0,c=e.clientX,u=e.clientY,d=e.target,f=(new Date).getTime(),f-p._mouseDownTimev&&(g=Math.max(g-1,1)),t.doneFn&&t.doneFn(p._dragged,g),!p._dragged){var r=document.createEvent("MouseEvents");r.initEvent("click",!0,!0),d.dispatchEvent(r)}return i(p),p._dragged=!1,o.pauseEvent(e)}var c,u,f,h,d,p=o.getPlotDiv(t.element)||{},g=1,v=s.DBLCLICKDELAY;p._mouseDownTime||(p._mouseDownTime=0),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":381,"../../plotly":400,"../../plots/cartesian/constants":408,"./align":321,"./cursor":322,"./unhover":324}],324:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=e.exports={};i.wrapped=function(t,e,r){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),i.raw(t,e,r)},i.raw=function(t,e){var r=t._fullLayout;e||(e={}),e.target&&n.triggerHandler(t,"plotly_beforehover",e)===!1||(r._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":375}],325:[function(t,e,r){"use strict";function n(t,e,r,n){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],c=Math.pow(a*a+o*o,x/2),u=Math.pow(s*s+l*l,x/2),f=(u*u*a-c*c*s)*n,h=(u*u*o-c*c*l)*n,d=3*u*(c+u),p=3*c*(c+u);return[[i.round(e[0]+(d&&f/d),2),i.round(e[1]+(d&&h/d),2)],[i.round(e[0]-(p&&f/p),2),i.round(e[1]-(p&&h/p),2)]]}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../plots/plots"),s=t("../color"),l=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../traces/scatter/subtypes"),d=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,r,n){e&&e.family&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},p.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},p.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},p.setRect=function(t,e,r,n,i){t.call(p.setPosition,e,r).call(p.setSize,n,i)},p.translatePoints=function(t,e,r){t.each(function(t){var n=t.xp||e.c2p(t.x),o=t.yp||r.c2p(t.y),s=i.select(this);a(n)&&a(o)?"text"===this.nodeName?s.attr("x",n).attr("y",o):s.attr("transform","translate("+n+","+o+")"):s.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:1>e?1:Math.round(e):r||0},p.lineGroupStyle=function(t,e,r,n){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=n||a.dash||"";i.select(this).call(s.stroke,r||a.color).call(p.dashLine,l,o)})},p.dashLine=function(t,e,r){var n=Math.max(r,3);"solid"===e?e="":"dot"===e?e=n+"px,"+n+"px":"dash"===e?e=3*n+"px,"+3*n+"px":"longdash"===e?e=5*n+"px,"+5*n+"px":"dashdot"===e?e=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===e&&(e=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var r=i.select(this);try{r.call(s.fill,e[0].trace.fillcolor)}catch(n){console.log(n,t),r.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var r=e.marker,n=r.line;if(o.traceIs(e,"symbols")){var a=d(e);t.attr("d",function(t){var n;n="various"===t.ms||"various"===r.size?3:h.isBubble(e)?a(t.ms):(r.size||6)/2,t.mrc=n;var i=p.symbolNumber(t.mx||r.symbol)||0,o=i%100;return t.om=i%200>=100,p.symbolFuncs[o](n)+(i>=200?m:"")}).style("opacity",function(t){return(t.mo+1||r.opacity+1)-1})}var l=(e._input||{}).marker||{},c=p.tryColorscale(r,l,""),u=p.tryColorscale(r,l,"line.");t.each(function(t){var e,a,o;t.so?(o=n.outlierwidth,a=n.outliercolor,e=r.outliercolor):(o=(t.mlw+1||n.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,a="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(n.color)?s.defaultLine:n.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(r.color)?s.defaultLine:r.color||"rgba(0,0,0,0)");var l=i.select(this);t.om?l.call(s.stroke,e).style({"stroke-width":(o||1)+"px",fill:"none"}):(l.style("stroke-width",o+"px").call(s.fill,e),o&&l.call(s.stroke,a))})}},p.tryColorscale=function(t,e,r){var n=c.nestedProperty(t,r+"color").get(),i=c.nestedProperty(t,r+"colorscale").get(),o=c.nestedProperty(t,r+"cauto").get(),s=c.nestedProperty(t,r+"cmin"),u=c.nestedProperty(t,r+"cmax"),f=s.get(),h=u.get();return i&&Array.isArray(n)?(!o&&a(f)&&a(h)||(f=1/0,h=-(1/0),n.forEach(function(t){a(t)&&(f>t&&(f=+t),t>h&&(h=+t))}),f>h&&(f=0,h=1),s.set(f),u.set(h),c.nestedProperty(e,r+"cmin").set(f),c.nestedProperty(e,r+"cmax").set(h)),l.makeScaleFunction(i,f,h)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},b=1.3;p.textPointStyle=function(t,e){t.each(function(t){var r=i.select(this),n=t.tx||e.text;if(!n||Array.isArray(n))return void r.remove();var o=t.tp||e.textposition,s=-1!==o.indexOf("top")?"top":-1!==o.indexOf("bottom")?"bottom":"middle",l=-1!==o.indexOf("left")?"end":-1!==o.indexOf("right")?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=a(c)&&c>0?c:0,r.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",l).text(n).call(u.convertToTspans);var h=i.select(this.parentNode),d=r.selectAll("tspan.line"),g=((d[0].length||1)-1)*b+1,v=y[l]*f,m=.75*c+y[s]*f+(y[s]-1)*g*c/2;h.attr("transform","translate("+v+","+m+")"),g>1&&d.attr({x:r.attr("x"),y:r.attr("y")})})};var x=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,i="M"+t[0],a=[];for(r=1;rr;r++)o.push(n(t[r-1],t[r],t[r+1],e));for(o.push(n(t[a-1],t[a],t[0],e)),r=1;a>=r;r++)i+="C"+o[r-1][1]+" "+o[r][0]+" "+t[r];return i+="C"+o[a][1]+" "+o[0][0]+" "+t[0]+"Z"};var _={hv:function(t,e){return"H"+i.round(e[0],2)+"V"+i.round(e[1],2)},vh:function(t,e){return"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},hvh:function(t,e){return"H"+i.round((t[0]+e[0])/2,2)+"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},vhv:function(t,e){return"V"+i.round((t[1]+e[1])/2,2)+"H"+i.round(e[0],2)+"V"+i.round(e[1],2)}},w=function(t,e){return"L"+i.round(e[0],2)+","+i.round(e[1],2)};p.steps=function(t){var e=_[t]||w;return function(t){for(var r="M"+i.round(t[0][0],2)+","+i.round(t[0][1],2),n=1;n=A&&(i.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(l),c.extendFlat({},l)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var r="#"+e,n=i.select("base");n.size()&&n.attr("href")&&(r=window.location.href+r),t.attr("clip-path","url("+r+")")}},{"../../constants/xmlns_namespaces":369,"../../lib":381,"../../lib/svg_text_utils":393,"../../plots/plots":452,"../../traces/scatter/make_bubble_size_func":567,"../../traces/scatter/subtypes":573,"../color":303,"../colorscale":316,"./symbol_defs":326,d3:72,"fast-isnumeric":76}],326:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+","+r+"H"+e+"L0,-"+i+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+",-"+r+"H"+e+"L0,"+i+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M"+r+",-"+e+"V"+e+"L-"+i+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+r+",-"+e+"V"+e+"L"+i+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(t*-.309,2),o=n.round(.809*t,2);return"M"+e+","+a+"L"+r+","+o+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(e*-.309,2),c=n.round(.118*e,2),u=n.round(.809*e,2),f=n.round(.382*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+c+"L"+o+","+u+"L0,"+f+"L-"+o+","+u+"L-"+a+","+c+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:72}],327:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],328:[function(t,e,r){"use strict";function n(t,e,r,n){var a=e["error_"+n]||{},l=a.visible&&-1!==["linear","log"].indexOf(r.type),c=[];if(l){for(var u=s(a),f=0;fs;s++)o[s]={x:r[s],y:i[s]};return o[0].trace=t,n.calc({calcdata:[o],_fullLayout:e}),o},n.plot=t("./plot"),n.style=t("./style"),n.hoverInfo=function(t,e,r){(e.error_y||{}).visible&&(r.yerr=t.yh-t.y,e.error_y.symmetric||(r.yerrneg=t.y-t.ys)),(e.error_x||{}).visible&&(r.xerr=t.xh-t.x,e.error_x.symmetric||(r.xerrneg=t.x-t.xs))}},{"./attributes":327,"./calc":328,"./defaults":330,"./plot":332,"./style":333}],332:[function(t,e,r){"use strict";function n(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};return void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0))),void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0))),n}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),s=t("../../traces/scatter/subtypes");e.exports=function(t,e){var r=e.x(),l=e.y();t.each(function(t){var e=t[0].trace,c=e.error_x||{},u=e.error_y||{},f=s.hasMarkers(e)&&e.marker.maxdisplayed>0;if(u.visible||c.visible){var h=i.select(this).selectAll("g.errorbar").data(o.identity);h.enter().append("g").classed("errorbar",!0),h.each(function(t){var e=i.select(this),o=n(t,r,l);if(!f||t.vis){var s;if(u.visible&&a(o.x)&&a(o.yh)&&a(o.ys)){var h=u.width;s="M"+(o.x-h)+","+o.yh+"h"+2*h+"m-"+h+",0V"+o.ys,o.noYS||(s+="m-"+h+",0h"+2*h),e.append("path").classed("yerror",!0).attr("d",s)}if(c.visible&&a(o.y)&&a(o.xh)&&a(o.xs)){var d=(c.copy_ystyle?u:c).width;s="M"+o.xh+","+(o.y-d)+"v"+2*d+"m0,-"+d+"H"+o.xs,o.noXS||(s+="m0,-"+d+"v"+2*d),e.append("path").classed("xerror",!0).attr("d",s)}}})}})}},{"../../lib":381,"../../traces/scatter/subtypes":573,d3:72,"fast-isnumeric":76}],333:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":303,d3:72}],334:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",n.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",n.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":408}],335:[function(t,e,r){"use strict";function n(t,e,r){function n(r,n){return a.coerce(t,e,o,r,n)}e=e||{},n("source"),n("layer"),n("x"),n("y"),n("xanchor"),n("yanchor"),n("sizex"),n("sizey"),n("sizing"),n("opacity");for(var s=0;2>s;s++){var l={_fullLayout:r},c=["x","y"][s];i.coerceRef(t,e,l,c,"paper")}return e}var i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var r=t.images,i=e.images=[],a=0;a=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],339:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:a({},n,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":376,"../../plots/font_attributes":421,"../color/attributes":302}],340:[function(t,e,r){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],341:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/plots"),a=t("./attributes"),o=t("./helpers");e.exports=function(t,e,r){function s(t,e){return n.coerce(h,d,a,t,e)}for(var l,c,u,f,h=t.legend||{},d=e.legend={},p=0,g="normal",v=0;v1);if(y!==!1){if(s("bgcolor",e.paper_bgcolor),s("bordercolor"),s("borderwidth"),n.coerceFont(s,"font",e.font),s("orientation"),"h"===d.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(l=0,u="left",c=1.1,f="bottom"):(l=0,u="left",c=-.1,f="top")}s("traceorder",g),o.isGrouped(e.legend)&&s("tracegroupgap"),s("x",l),s("xanchor",u),s("y",c),s("yanchor",f),n.noneOrAll(h,d,["x","y"])}}},{"../../lib":381,"../../plots/plots":452,"./attributes":339,"./helpers":344}],342:[function(t,e,r){"use strict";function n(t,e){function r(r){u.util.convertToTspans(r,function(){r.selectAll("tspan.line").attr({x:r.attr("x")}),t.call(a,e)})}var n=t.data()[0][0],i=e._fullLayout,o=n.trace,s=h.traceIs(o,"pie"),l=o.index,c=s?n.label:o.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":c}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,i.legend.font).text(c),e._context.editable&&!s?f.call(u.util.makeEditable).call(r).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(r),this.text()||(t=" "),u.restyle(e,"name",t,l)}):f.call(r)}function i(t,e){var r=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],n=t.selectAll("rect").data([0]);n.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"),n.on("click",function(){if(!e._dragged){var n,i,a=t.data()[0][0],o=e._fullData,s=a.trace,l=s.legendgroup,c=[];if(h.traceIs(s,"pie")){var f=a.label,d=r.indexOf(f);-1===d?r.push(f):r.splice(d,1),u.relayout(e,"hiddenlabels",r)}else{if(""===l)c=[s.index];else for(var p=0;ptspan"),d=h[0].length||1;r=l*d,n=u.node()&&p.bBox(u.node()).width;var g=l*(.3+(1-d)/2);u.attr("y",g),h.attr("y",g)}r=Math.max(r,16)+3,a.attr({x:0,y:-r/2,height:r}),i.height=r,i.width=n}function o(t,e,r){var n=t._fullLayout,i=n.legend,a=i.borderwidth,o=b.isGrouped(i);if(b.isVertical(i))o&&e.each(function(t,e){f.setTranslate(this,0,e*i.tracegroupgap)}),i.width=0,i.height=0,r.each(function(t){var e=t[0],r=e.height,n=e.width;f.setTranslate(this,a,5+a+i.height+r/2),i.height+=r,i.width=Math.max(i.width,n)}),i.width+=45+2*a,i.height+=10+2*a,o&&(i.height+=(i._lgroupsLength-1)*i.tracegroupgap),r.selectAll(".legendtoggle").attr("width",(t._context.editable?0:i.width)+40),i.width=Math.ceil(i.width),i.height=Math.ceil(i.height);else if(o){i.width=0,i.height=0;for(var s=[i.width],l=e.data(),u=0,h=l.length;h>u;u++){var d=l[u].map(function(t){return t[0].width}),p=40+Math.max.apply(null,d);i.width+=i.tracegroupgap+p,s.push(i.width)}e.each(function(t,e){f.setTranslate(this,s[e],0)}),e.each(function(){var t=c.select(this),e=t.selectAll("g.traces"),r=0;e.each(function(t){var e=t[0],n=e.height;f.setTranslate(this,0,5+a+r+n/2),r+=n}),i.height=Math.max(i.height,r)}),i.height+=10+2*a,i.width+=2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}else i.width=0,i.height=0,r.each(function(t){var e=t[0],r=40+e.width,n=i.tracegroupgap||5;f.setTranslate(this,a+i.width,5+a+e.height/2),i.width+=n+r,i.height=Math.max(i.height,e.height)}),i.width+=2*a,i.height+=10+2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}function s(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center");var i="top";x.isBottomAnchor(r)?i="bottom":x.isMiddleAnchor(r)&&(i="middle"),h.autoMargin(t,"legend",{x:r.x,y:r.y,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:r.height*({top:1,middle:.5}[i]||0),t:r.height*({bottom:1,middle:.5}[i]||0)})}function l(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center"),h.autoMargin(t,"legend",{x:r.x,y:.5,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:0,t:0})}var c=t("d3"),u=t("../../plotly"),f=t("../../lib"),h=t("../../plots/plots"),d=t("../dragelement"),p=t("../drawing"),g=t("../color"),v=t("./constants"),m=t("./get_legend_data"),y=t("./style"),b=t("./helpers"),x=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e).call(f.setTranslate,0,e),E.call(p.setRect,j,t,v.scrollBarWidth,v.scrollBarHeight),A.select("rect").attr({y:b.borderwidth-e})}var r=t._fullLayout,a="legend"+r._uid;if(r._infolayer&&t.calcdata){var b=r.legend,_=r.showlegend&&m(t.calcdata,b),w=r.hiddenlabels||[];if(!r.showlegend||!_.length)return r._infolayer.selectAll(".legend").remove(),r._topdefs.select("#"+a).remove(),void h.autoMargin(t,"legend");"undefined"==typeof t.firstRender?t.firstRender=!0:t.firstRender&&(t.firstRender=!1);var k=r._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({"class":"legend","pointer-events":"all"});var A=r._topdefs.selectAll("#"+a).data([0]);A.enter().append("clipPath").attr("id",a).append("rect");var M=k.selectAll("rect.bg").data([0]);M.enter().append("rect").attr({"class":"bg","shape-rendering":"crispEdges"}).call(g.stroke,b.bordercolor).call(g.fill,b.bgcolor).style("stroke-width",b.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var E=k.selectAll("rect.scrollbar").data([0]);E.enter().append("rect").attr({"class":"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var L=T.selectAll("g.groups").data(_);L.enter().append("g").attr("class","groups"),L.exit().remove();var S=L.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return h.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(){c.select(this).call(n,t).call(i,t)}),t.firstRender&&(o(t,L,S),s(t));var C=0,z=r.width,P=0,R=r.height;o(t,L,S),b.height>R?l(t):s(t);var O=r._size,I=O.l+O.w*b.x,N=O.t+O.h*(1-b.y);x.isRightAnchor(b)?I-=b.width:x.isCenterAnchor(b)&&(I-=b.width/2),x.isBottomAnchor(b)?N-=b.height:x.isMiddleAnchor(b)&&(N-=b.height/2);var j=b.width,F=O.w;j>F?(I=O.l,j=F):(I+j>z&&(I=z-j),C>I&&(I=C),j=Math.min(z-I,b.width));var D=b.height,B=O.h;D>B?(N=O.t,D=B):(N+D>R&&(N=R-D),P>N&&(N=P),D=Math.min(R-N,b.height)),f.setTranslate(k,I,N),M.attr({width:j-b.borderwidth,height:D-b.borderwidth,x:b.borderwidth/2,y:b.borderwidth/2});var U=T.attr("data-scroll")||0;if(f.setTranslate(T,0,U),A.select("rect").attr({width:j-2*b.borderwidth,height:D-2*b.borderwidth,x:b.borderwidth-U,y:b.borderwidth}),T.call(p.setClipUrl,a),b.height-D>0&&!t._context.staticPlot){M.attr({width:j-2*b.borderwidth+v.scrollBarWidth+v.scrollBarMargin}),A.select("rect").attr({width:j-2*b.borderwidth+v.scrollBarWidth+v.scrollBarMargin}),t.firstRender&&e(v.scrollBarMargin,0);var V=D-v.scrollBarHeight-2*v.scrollBarMargin,q=b.height-D,H=v.scrollBarMargin,G=0;e(H,G),k.on("wheel",null),k.on("wheel",function(){G=f.constrain(T.attr("data-scroll")-c.event.deltaY/V*q,-q,0),H=v.scrollBarMargin-G/q*V,e(H,G),c.event.preventDefault()}),E.on(".drag",null),T.on(".drag",null);var Y=c.behavior.drag().on("drag",function(){H=f.constrain(c.event.y-v.scrollBarHeight/2,v.scrollBarMargin,v.scrollBarMargin+V),G=-(H-v.scrollBarMargin)/V*q,e(H,G)});E.call(Y),T.call(Y)}if(t._context.editable){var X,W,Z,K;k.classed("cursor-move",!0),d.init({element:k.node(),prepFn:function(){var t=f.getTranslate(k);Z=t.x,K=t.y},moveFn:function(t,e){var r=Z+t,n=K+e;f.setTranslate(k,r,n),X=d.align(r,0,O.l,O.l+O.w,b.xanchor),W=d.align(n,0,O.t+O.h,O.t,b.yanchor)},doneFn:function(e){e&&void 0!==X&&void 0!==W&&u.relayout(t,{"legend.x":X,"legend.y":W})}})}}}},{"../../lib":381,"../../plotly":400,"../../plots/plots":452,"../color":303,"../dragelement":323,"../drawing":325,"./anchor_utils":338,"./constants":340,"./get_legend_data":343,"./helpers":344,"./style":346,d3:72}],343:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("./helpers");e.exports=function(t,e){function r(t,r){if(""!==t&&i.isGrouped(e))-1===l.indexOf(t)?(l.push(t),c=!0,s[t]=[[r]]):s[t].push([r]);else{var n="~~i"+f;l.push(n),s[n]=[[r]],f++}}var a,o,s={},l=[],c=!1,u={},f=0;for(a=0;aa;a++)m=s[l[a]],y[a]=i.isReversed(e)?m.reverse():m;else{for(y=[new Array(b)],a=0;b>a;a++)m=s[l[a]][0],y[0][i.isReversed(e)?b-a-1:a]=m;b=1}return e._lgroupsLength=b,y}},{"../../plots/plots":452,"./helpers":344}],344:[function(t,e,r){"use strict";var n=t("../../plots/plots");r.legendGetsTrace=function(t){return t.visible&&n.traceIs(t,"showLegend")},r.isGrouped=function(t){return-1!==(t.traceorder||"").indexOf("grouped")},r.isVertical=function(t){return"h"!==t.orientation},r.isReversed=function(t){return-1!==(t.traceorder||"").indexOf("reversed")}},{"../../plots/plots":452}],345:[function(t,e,r){"use strict";var n=e.exports={};n.layoutAttributes=t("./attributes"),n.supplyLayoutDefaults=t("./defaults"),n.draw=t("./draw"),n.style=t("./style")},{"./attributes":339,"./defaults":341,"./draw":342,"./style":346}],346:[function(t,e,r){"use strict";function n(t){var e=t[0].trace,r=e.visible&&e.fill&&"none"!==e.fill,n=d.hasLines(e),i=l.select(this).select(".legendfill").selectAll("path").data(r?[t]:[]);i.enter().append("path").classed("js-fill",!0),i.exit().remove(),i.attr("d","M5,0h30v6h-30z").call(f.fillGroupStyle);var a=l.select(this).select(".legendlines").selectAll("path").data(n?[t]:[]);a.enter().append("path").classed("js-line",!0).attr("d","M5,0h30"),a.exit().remove(),a.call(f.lineGroupStyle)}function i(t){function e(t,e,r){var n=c.nestedProperty(o,t).get(),i=Array.isArray(n)&&e?e(n):n;if(r){if(ir[1])return r[1]}return i}function r(t){return t[0]}var n,i,a=t[0],o=a.trace,s=d.hasMarkers(o),u=d.hasText(o),h=d.hasLines(o);if(s||u||h){var p={},g={};s&&(p.mc=e("marker.color",r),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",r),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),h&&(g.line={width:e("line.width",r,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",r),p.ts=10,p.tc=e("textfont.color",r),p.tf=e("textfont.family",r)),n=[c.minExtend(a,p)],i=c.minExtend(o,g)}var v=l.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(s?n:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,i),s&&(n[0].mrc=3);var y=v.selectAll("g.pointtext").data(u?n:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,i)}function a(t){var e=t[0].trace,r=e.marker||{},n=r.line||{},i=l.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);i.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),i.exit().remove(),i.each(function(t){var e=(t.mlw+1||n.width+1)-1,i=l.select(this);i.style("stroke-width",e+"px").call(h.fill,t.mc||r.color),e&&i.call(h.stroke,t.mlc||n.color)})}function o(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);r.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.each(function(t){var r=(t.lw+1||e.line.width+1)-1,n=l.select(this);n.style("stroke-width",r+"px").call(h.fill,t.fc||e.fillcolor),r&&n.call(h.stroke,t.lc||e.line.color)})}function s(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);r.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.size()&&r.call(p,t[0],e)}var l=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),h=t("../color"),d=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=l.select(this),r=e.selectAll("g.legendfill").data([t]);r.enter().append("g").classed("legendfill",!0);var n=e.selectAll("g.legendlines").data([t]);n.enter().append("g").classed("legendlines",!0);var i=e.selectAll("g.legendsymbols").data([t]);i.enter().append("g").classed("legendsymbols",!0),i.style("opacity",t[0].trace.opacity),i.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(a).each(o).each(s).each(n).each(i)}},{"../../lib":381,"../../plots/plots":452,"../../traces/pie/style_one":552,"../../traces/scatter/subtypes":573,"../color":303,"../drawing":325,d3:72}],347:[function(t,e,r){"use strict";function n(t,e){var r=e.currentTarget,n=r.getAttribute("data-attr"),i=r.getAttribute("data-val")||!0,a=t._fullLayout,o={};if("zoom"===n){for(var s,l,u="in"===i?.5:2,h=(1+u)/2,d=(1-u)/2,p=c.Axes.list(t,null,!0),v=0;vy;y++){var b=s[y];h=m[b]={};for(var x=0;x1)return n(["resetViews","toggleHover"]),o(v,r);u&&(n(["zoom3d","pan3d","orbitRotation","tableRotation"]),n(["resetCameraDefault3d","resetCameraLastSave3d"]),n(["hoverClosest3d"])),h&&(n(["zoomInGeo","zoomOutGeo","resetGeo"]),n(["hoverClosestGeo"]));var m=i(s),y=[];return((c||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(c||g)&&a(l)&&(y.push("select2d"),y.push("lasso2d")),y.length&&n(y),!c&&!p||m||g||n(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&d?n(["toggleHover"]):p?n(["hoverClosestGl2d"]):c?n(["hoverClosestCartesian","hoverCompareCartesian"]):d&&n(["hoverClosestPie"]),o(v,r)}function i(t){for(var e=l.Axes.list({_fullLayout:t},null,!0),r=!0,n=0;n0);if(h){var d=i(e,r,s);l("x",d[0]),l("y",d[1]),a.noneOrAll(t,e,["x","y"]),l("xanchor"),l("yanchor"),a.coerceFont(l,"font",r.font),l("bgcolor"),l("bordercolor"),l("borderwidth")}}},{"../../lib":381,"./attributes":350,"./button_attributes":351,"./constants":352}],354:[function(t,e,r){"use strict";function n(t){for(var e=m.list(t,"x",!0),r=[],n=0;nr){var i=r;r=e,e=i}s.setAttributes(x,{"data-min":e,"data-max":r}),s.setAttributes(z,{x:e,width:r-e}),s.setAttributes(k,{width:e}),s.setAttributes(A,{x:r,width:h-r}),s.setAttributes(M,{transform:"translate("+(e-p-1)+")"}),s.setAttributes(L,{transform:"translate("+r+")"});var o=f.range[0],l=f.range[1],c=l-o,u=e/h*c+o,d=r/h*c+o;window.requestAnimationFrame?window.requestAnimationFrame(function(){n.relayout(t,"xaxis.range",[u,d])}):setTimeout(function(){n.relayout(t,"xaxis.range",[u,d])},16)}var c=t._fullLayout,u=c._infolayer.selectAll("g.range-slider"),f=c.xaxis.rangeslider,h=c._size.w,d=(c.height-c.margin.b-c.margin.t)*f.thickness,p=2,g=Math.floor(f.borderwidth/2),v=c.margin.l,m=c.height-d-c.margin.b,y=0,b=h,x=document.createElementNS(o,"g");s.setAttributes(x,{"class":"range-slider","data-min":y,"data-max":b,"pointer-events":"all",transform:"translate("+v+","+m+")" +});var _=document.createElementNS(o,"rect"),w=f.borderwidth%2===0?f.borderwidth:f.borderwidth-1;s.setAttributes(_,{fill:f.bgcolor,stroke:f.bordercolor,"stroke-width":f.borderwidth,height:d+w,width:h+w,transform:"translate(-"+g+", -"+g+")","shape-rendering":"crispEdges"});var k=document.createElementNS(o,"rect");s.setAttributes(k,{x:0,width:y,height:d,fill:"rgba(0,0,0,0.4)"});var A=document.createElementNS(o,"rect");s.setAttributes(A,{x:b,width:h-b,height:d,fill:"rgba(0,0,0,0.4)"});var M=document.createElementNS(o,"g"),T=document.createElementNS(o,"rect"),E=document.createElementNS(o,"rect");s.setAttributes(M,{transform:"translate("+(y-p-1)+")"}),s.setAttributes(T,{width:10,height:d,x:-6,fill:"transparent",cursor:"col-resize"}),s.setAttributes(E,{width:p,height:d/2,y:d/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(M,[E,T]);var L=document.createElementNS(o,"g"),S=document.createElementNS(o,"rect"),C=document.createElementNS(o,"rect");s.setAttributes(L,{transform:"translate("+b+")"}),s.setAttributes(S,{width:10,height:d,x:-2,fill:"transparent",cursor:"col-resize"}),s.setAttributes(C,{width:p,height:d/2,y:d/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(L,[C,S]);var z=document.createElementNS(o,"rect");s.setAttributes(z,{x:y,width:b-y,height:d,cursor:"ew-resize",fill:"transparent"}),x.addEventListener("mousedown",function(t){function e(t){var e=+t.clientX-a;switch(i){case z:x.style.cursor="ew-resize",r(+l+e,+s+e);break;case T:x.style.cursor="col-resize",r(+s+e,+l);break;case S:x.style.cursor="col-resize",r(+s,+l+e);break;default:x.style.cursor="ew-resize",r(o,o+e)}}function n(){window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",n),x.style.cursor="auto"}var i=t.target,a=t.clientX,o=a-x.getBoundingClientRect().left,s=x.getAttribute("data-min"),l=x.getAttribute("data-max");window.addEventListener("mousemove",e),window.addEventListener("mouseup",n)}),f.range||(f.range=i.getAutoRange(c.xaxis));var P=l(t,h,d);s.appendChildren(x,[_,P,k,A,z,M,L]),e(c.xaxis.range[0],c.xaxis.range[1]),u.data([0]).enter().append(function(){return f.setRange=e,x})}},{"../../constants/xmlns_namespaces":369,"../../lib":381,"../../plotly":400,"../../plots/cartesian/axes":403,"./helpers":360,"./range_plot":362}],359:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(t,e){return n.coerce(s,l,i,t,e)}if(t[r].rangeslider){var s="object"==typeof t[r].rangeslider?t[r].rangeslider:{},l=e[r].rangeslider={};if(o("bgcolor"),o("bordercolor"),o("borderwidth"),o("thickness"),o("visible"),o("range"),l.range&&!e[r].autorange){var c=l.range,u=e[r].range;c[0]=Math.min(c[0],u[0]),c[1]=Math.max(c[1],u[1])}else e[r]._needsExpand=!0;l.visible&&a.forEach(function(t){var r=e[t]||{};r.fixedrange=!0,e[t]=r})}}},{"../../lib":381,"./attributes":357}],360:[function(t,e,r){"use strict";r.setAttributes=function(t,e){for(var r in e)t.setAttribute(r,e[r])},r.appendChildren=function(t,e){for(var r=0;rl;l++){var c=s[l],u={_fullLayout:e},f=x.coerceRef(t,n,u,c);if("path"!==o){var h=.25,d=.75;if("paper"!==f){var p=x.getFromId(u,f),g=a(p);h=g(p.range[0]+h*(p.range[1]-p.range[0])),d=g(p.range[0]+d*(p.range[1]-p.range[0]))}r(c+"0",h),r(c+"1",d)}}return"path"===o?r("path"):b.noneOrAll(t,n,["x0","x1","y0","y1"]),n}function i(t){return"category"===t.type?t.c2l:t.d2l}function a(t){return"category"===t.type?t.l2c:t.l2d}function o(t,e){t.layout.shapes=e,k.supplyLayoutDefaults(t.layout,t._fullLayout),k.drawAll(t)}function s(t){delete t.layout.shapes,t._fullLayout.shapes=[],k.drawAll(t)}function l(t,e,r){for(var n=0;ne;i--)h(t,i).selectAll('[data-index="'+(i-1)+'"]').attr("data-index",i),k.draw(t,i)}function f(t,e,r,o){function s(e){var r=e.append("path").attr(z).style("opacity",S.opacity).call(_.stroke,P).call(_.fill,S.fillcolor).call(w.dashLine,S.line.dash,S.line.width);C&&r.call(w.setClipUrl,"clip"+t._fullLayout._uid+C)}var l,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},p={};"string"==typeof r&&r?p[r]=o:b.isPlainObject(r)&&(p=r);var v=Object.keys(p);for(l=0;ll;l++){var k=y[l];if(void 0===p[k]&&void 0!==u[k]){var A,M=k.charAt(0),T=x.getFromId(t,x.coerceRef(f,{},t,M)),E=x.getFromId(t,x.coerceRef(u,{},t,M)),L=u[k];void 0!==p[M+"ref"]&&(T?(A=i(T)(L),L=(A-T.range[0])/(T.range[1]-T.range[0])):L=(L-E.domain[0])/(E.domain[1]-E.domain[0]),E?(A=E.range[0]+L*(E.range[1]-E.range[0]),L=a(E)(A)):L=T.domain[0]+L*(T.domain[1]-T.domain[0])),u[k]=L}}var S=n(u,t._fullLayout);t._fullLayout.shapes[e]=S;var C,z={"data-index":e,"fill-rule":"evenodd",d:g(t,S)},P=S.line.width?S.line.color:"rgba(0,0,0,0)";if("below"!==S.layer)C=(S.xref+S.yref).replace(/paper/g,""),s(t._fullLayout._shapeUpperLayer);else if("paper"===S.xref&&"paper"===S.yref)C="",s(t._fullLayout._shapeLowerLayer);else{var R,O=t._fullLayout._plots||{},I=Object.keys(O);for(l=0,c=I.length;c>l;l++)R=O[I[l]],C=I[l],d(t,S,R.id)&&s(R.shapelayer)}}}function h(t,e){var r=t._fullLayout.shapes[e],n=t._fullLayout._shapeUpperLayer;return r?"below"===r.layer&&(n="paper"===r.xref&&"paper"===r.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):console.log("getShapeLayer: undefined shape: index",e),n}function d(t,e,r){var n=y.Axes.getFromId(t,r,"x")._id,i=y.Axes.getFromId(t,r,"y")._id;return"below"===e.layer&&(n===e.xref||i===e.yref)}function p(t){return function(e){return t(e.replace("_"," "))}}function g(t,e){var r,n,a,o,s=e.type,l=x.getFromId(t,e.xref),c=x.getFromId(t,e.yref),u=t._fullLayout._size;if(l?(r=i(l),n=function(t){return l._offset+l.l2p(r(t,!0))}):n=function(t){return u.l+u.w*t},c?(a=i(c),o=function(t){return c._offset+c.l2p(a(t,!0))}):o=function(t){return u.t+u.h*(1-t)},"path"===s)return l&&"date"===l.type&&(n=p(n)),c&&"date"===c.type&&(o=p(o)),k.convertPath(e.path,n,o);var f=n(e.x0),h=n(e.x1),d=o(e.y0),g=o(e.y1);if("line"===s)return"M"+f+","+d+"L"+h+","+g;if("rect"===s)return"M"+f+","+d+"H"+h+"V"+g+"H"+f+"Z";var v=(f+h)/2,m=(d+g)/2,y=Math.abs(v-f),b=Math.abs(m-d),_="A"+y+","+b,w=v+y+","+m,A=v+","+(m-b);return"M"+w+_+" 0 1,1 "+A+_+" 0 0,1 "+w+"Z"}function v(t,e,r,n,i){var a="category"===t.type?Number:t.d2c;if(void 0!==e)return[a(e),a(r)];if(n){var o,s,l,c,u,f=1/0,h=-(1/0),d=n.match(A);for("date"===t.type&&(a=p(a)),o=0;ou&&(f=u),u>h&&(h=u)));return h>=f?[f,h]:void 0}}var m=t("fast-isnumeric"),y=t("../../plotly"),b=t("../../lib"),x=t("../../plots/cartesian/axes"),_=t("../color"),w=t("../drawing"),k=e.exports={};k.layoutAttributes=t("./attributes"),k.supplyLayoutDefaults=function(t,e){for(var r=t.shapes||[],i=e.shapes=[],a=0;as&&(t="X"),t});return n>s&&(l=l.replace(/[\s,]*X.*/,""),console.log("ignoring extra params in segment "+t)),i+l})},k.calcAutorange=function(t){var e,r,n,i,a,o=t._fullLayout,s=o.shapes;if(s.length&&t._fullData.length)for(e=0;eh?r=h:(u.left-=b.offsetLeft,u.right-=b.offsetLeft,u.top-=b.offsetTop,u.bottom-=b.offsetTop,b.selection.each(function(){var t=l.bBox(this);s.bBoxIntersect(u,t,c)&&(r=Math.max(r,o*(t[b.side]-u[a])+c))}),r=Math.min(h,r)),r>0||0>h){var d={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[b.side];e.attr("transform","translate("+d+")")}}}function p(){E=0,L=!0,S=z,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)})}var g=r.propContainer,v=r.propName,m=r.traceIndex,y=r.dfltName,b=r.avoid||{},x=r.attributes,_=r.transform,w=r.containerGroup,k=t._fullLayout,A=g.titlefont.family,M=g.titlefont.size,T=g.titlefont.color,E=1,L=!1,S=g.title.trim();""===S&&(E=0),S.match(/Click to enter .+ title/)&&(E=.2,L=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var z="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==m?a.restyle(t,v,e,m):a.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(x).selectAll("tspan.line").attr(x)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",L)}},{"../../lib":381,"../../lib/svg_text_utils":393,"../../plotly":400,"../../plots/plots":452,"../color":303,"../drawing":325,d3:72,"fast-isnumeric":76}],366:[function(t,e,r){"use strict";e.exports={solid:[1],dot:[1,1],dash:[4,1],longdash:[8,1],dashdot:[4,1,1,1],longdashdot:[8,1,1,1]}},{}],367:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],368:[function(t,e,r){"use strict";e.exports={circle:"\u25cf","circle-open":"\u25cb",square:"\u25a0","square-open":"\u25a1",diamond:"\u25c6","diamond-open":"\u25c7",cross:"+",x:"\u274c"}},{}],369:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],370:[function(t,e,r){"use strict";var n=t("./plotly");r.version="1.11.0",r.plot=n.plot,r.newPlot=n.newPlot,r.restyle=n.restyle,r.relayout=n.relayout,r.redraw=n.redraw,r.extendTraces=n.extendTraces,r.prependTraces=n.prependTraces,r.addTraces=n.addTraces,r.deleteTraces=n.deleteTraces,r.moveTraces=n.moveTraces,r.purge=n.purge,r.setPlotConfig=t("./plot_api/set_plot_config"),r.register=n.register,r.toImage=t("./plot_api/to_image"),r.downloadImage=t("./snapshot/download"),r.Icons=t("../build/ploticon"),r.Plots=n.Plots,r.Fx=n.Fx,r.Snapshot=n.Snapshot,r.PlotSchema=n.PlotSchema,r.Queue=n.Queue,r.d3=t("d3")},{"../build/ploticon":2,"./plot_api/set_plot_config":398,"./plot_api/to_image":399,"./plotly":400,"./snapshot/download":467,d3:72}],371:[function(t,e,r){"use strict";"undefined"!=typeof MathJax?(r.MathJax=!0,MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:!0,displayAlign:"left",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]}}),MathJax.Hub.Configured()):r.MathJax=!1},{}],372:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){Array.isArray(t)&&(e[r]=t[n])}},{}],373:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("./nested_property"),o=t("../components/colorscale/get_scale"),s=(Object.keys(t("../components/colorscale/scales")),/^([2-9]|[1-9][0-9]+)$/);r.valObjects={data_array:{coerceFunction:function(t,e,r){Array.isArray(t)?e.set(t):void 0!==r&&e.set(r)}},enumerated:{coerceFunction:function(t,e,r,n){n.coerceNumber&&(t=+t),-1===n.values.indexOf(t)?e.set(r):e.set(t)}},"boolean":{coerceFunction:function(t,e,r){t===!0||t===!1?e.set(t):e.set(r)}},number:{coerceFunction:function(t,e,r,i){!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if(n.strict===!0&&"string"!=typeof t)return void e.set(r);var i=String(t);void 0===t||n.noBlank===!0&&!i?e.set(r):e.set(i)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r){var n=r.length;return"string"==typeof t&&t.substr(0,n)===r&&s.test(t.substr(n))?void e.set(t):void e.set(r)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"!=typeof t)return void e.set(r);if(-1!==n.extras.indexOf(t))return void e.set(t);for(var i=t.split("+"),a=0;a2)return!1;var l=o[0].split("-");if(l.length>3||3!==l.length&&o[1])return!1;if(4===l[0].length)r=Number(l[0]);else{if(2!==l[0].length)return!1;var c=(new Date).getFullYear();r=((Number(l[0])-c+70)%100+200)%100+c-70}return s(r)?1===l.length?new Date(r,0,1).getTime():(n=Number(l[1])-1,l[1].length>2||!(n>=0&&11>=n)?!1:2===l.length?new Date(r,n,1).getTime():(i=Number(l[2]),l[2].length>2||!(i>=1&&31>=i)?!1:(i=new Date(r,n,i).getTime(),o[1]?(l=o[1].split(":"),l.length>3?!1:(a=Number(l[0]),l[0].length>2||!(a>=0&&23>=a)?!1:(i+=36e5*a,1===l.length?i:(n=Number(l[1]),l[1].length>2||!(n>=0&&59>=n)?!1:(i+=6e4*n,2===l.length?i:(t=Number(l[2]),t>=0&&60>t?i+1e3*t:!1)))))):i))):!1},r.isDateTime=function(t){return r.dateTime2ms(t)!==!1},r.ms2DateTime=function(t,e){if("undefined"==typeof o)return void console.log("d3 is not defined");e||(e=0);var r=new Date(t),i=o.time.format("%Y-%m-%d")(r);return 7776e6>e?(i+=" "+n(r.getHours(),2),432e6>e&&(i+=":"+n(r.getMinutes(),2),108e5>e&&(i+=":"+n(r.getSeconds(),2),3e5>e&&(i+="."+n(r.getMilliseconds(),3)))),i.replace(/([:\s]00)*\.?[0]*$/,"")):i};var l={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},c={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},u=o.time.format.utc,f={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(u),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(u)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(u)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){c[t].forEach(function(e){f[t].D.push(u(e)),["H","I","D"].forEach(function(r){l[r].forEach(function(n){var i=f[t][r];i.push(u(e+"~"+n)),i.push(u(n+"~"+e))})})})});var h=/[a-z]*/g,d=function(t){return t.substr(0,3)},p=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,g=/[\s,\/\-\.\(\)]+/g,v=/~?([ap])~?m(~|$)/,m=function(t,e){return e+"m "},y=/\d\d\d\d/,b=/(^|~)[a-z]{3}/,x=/[ap]m/,_=/:/,w=/q([1-4])/,k=["31~mar","30~jun","30~sep","31~dec"],A=function(t,e){return k[e-1]},M=/ ?([+\-]\d\d:?\d\d|Z)$/;r.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(h,d).replace(p,"").replace(g,"~").replace(v,m).replace(w,A).trim().replace(M,"");var e,r,n=null,o=i(t),s=a(t);e=f[o][s],r=e.length;for(var l=0;r>l&&!(n=e[l].parse(t));l++);if(!(n instanceof Date))return!1;var c=n.getTimezoneOffset();return n.setTime(n.getTime()+60*c*1e3),n}},{d3:72,"fast-isnumeric":76}],375:[function(t,e,r){"use strict";var n=t("events").EventEmitter,i={init:function(t){if(t._ev instanceof n)return t;var e=new n;return t._ev=e,t.on=e.on.bind(e),t.once=e.once.bind(e),t.removeListener=e.removeListener.bind(e),t.removeAllListeners=e.removeAllListeners.bind(e),t.emit=function(r,n){"undefined"!=typeof jQuery&&jQuery(t).trigger(r,n),e.emit(r,n)},t},triggerHandler:function(t,e,r){var n,i;"undefined"!=typeof jQuery&&(n=jQuery(t).triggerHandler(e,r));var a=t._ev;if(!a)return n;var o=a._events[e];if(!o)return n;"function"==typeof o&&(o=[o]);for(var s=o.pop(),l=0;lp;p++){o=t[p];for(s in o)l=h[s],c=o[s],e&&c&&(i(c)||(u=a(c)))?(u?(u=!1,f=l&&a(l)?l:[]):f=l&&i(l)?l:{},h[s]=n([f,c],e,r)):("undefined"!=typeof c||r)&&(h[s]=c)}return h}var i=t("./is_plain_object.js"),a=Array.isArray;r.extendFlat=function(){return n(arguments,!1,!1)},r.extendDeep=function(){return n(arguments,!0,!1)},r.extendDeepAll=function(){return n(arguments,!0,!0)}},{"./is_plain_object.js":382}],377:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=0;ry;y++)f=s(p,y),d=l(e,y),m[y]=n(f,d);else m=n(p,e);return m}var s=t("tinycolor2"),l=t("fast-isnumeric"),c=t("../components/colorscale/make_scale_function"),u=t("../components/color/attributes").defaultLine,f=t("./str2rgbarray"),h=1;e.exports=o},{"../components/color/attributes":302,"../components/colorscale/make_scale_function":319,"./str2rgbarray":392,"fast-isnumeric":76,tinycolor2:233}],380:[function(t,e,r){"use strict";function n(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(e>r)break;t=t.slice(0,e)+l(t.slice(e+5,r))+t.slice(r+6)}return t}function i(t){return t.replace(/\/g,"\n")}function a(t){return t.replace(/\<.*\>/g,"")}function o(t){for(var e=0;(e=t.indexOf("&",e))>=0;){var r=t.indexOf(";",e);if(e>r)e+=1;else{var n=c[t.slice(e+1,r)];t=n?t.slice(0,e)+n+t.slice(r+1):t.slice(0,e)+t.slice(r+1)}}return t}function s(t){return""+o(a(n(i(t))))}var l=t("superscript-text"),c={mu:"\u03bc",amp:"&",lt:"<",gt:">"};e.exports=s},{"superscript-text":222}],381:[function(t,e,r){"use strict";var n=t("d3"),i=e.exports={};i.nestedProperty=t("./nested_property"),i.isPlainObject=t("./is_plain_object");var a=t("./coerce");i.valObjects=a.valObjects,i.coerce=a.coerce,i.coerce2=a.coerce2,i.coerceFont=a.coerceFont;var o=t("./dates");i.dateTime2ms=o.dateTime2ms,i.isDateTime=o.isDateTime,i.ms2DateTime=o.ms2DateTime,i.parseDate=o.parseDate;var s=t("./search");i.findBin=s.findBin,i.sorterAsc=s.sorterAsc,i.sorterDes=s.sorterDes,i.distinctVals=s.distinctVals,i.roundUp=s.roundUp;var l=t("./stats");i.aggNums=l.aggNums,i.len=l.len,i.mean=l.mean,i.variance=l.variance,i.stdev=l.stdev,i.interp=l.interp;var c=t("./matrix");i.init2dArray=c.init2dArray,i.transposeRagged=c.transposeRagged,i.dot=c.dot,i.translationMatrix=c.translationMatrix,i.rotationMatrix=c.rotationMatrix,i.rotationXYMatrix=c.rotationXYMatrix,i.apply2DTransform=c.apply2DTransform,i.apply2DTransform2=c.apply2DTransform2;var u=t("./extend");i.extendFlat=u.extendFlat,i.extendDeep=u.extendDeep,i.extendDeepAll=u.extendDeepAll,i.notifier=t("./notifier"),i.swapAttrs=function(t,e,r,n){r||(r="x"),n||(n="y");for(var a=0;ar?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},i.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},i.identity=function(t){return t},i.randstr=function f(t,e,r){if(r||(r=16),void 0===e&&(e=24),0>=e)return"0";var n,i,a,o=Math.log(Math.pow(2,e))/Math.log(r),s="";for(n=2;o===1/0;n*=2)o=Math.log(Math.pow(2,e/n))/Math.log(r)*n;var l=o-Math.floor(o);for(n=0;n-1||c!==1/0&&c>=Math.pow(2,e)?f(t,e,r):s},i.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={};return r.optionList=[],r._newoption=function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)},r["_"+e]=t,r},i.smooth=function(t,e){if(e=Math.round(e)||0,2>e)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,c=new Array(l),u=new Array(o);for(r=0;l>r;r++)c[r]=(1-Math.cos(Math.PI*(r+1)/e))/(2*e);for(r=0;o>r;r++){for(a=0,n=0;l>n;n++)i=r+n+1-e,-o>i?i-=s*Math.round(i/s):i>=s&&(i-=s*Math.floor(i/s)),0>i?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*c[n];u[r]=a}return u},i.promiseError=function(t){console.log(t,t.stack)},i.syncOrAsync=function(t,e,r){function n(){return i.markTime("async done "+o.name),i.syncOrAsync(t,e,r)}for(var a,o;t.length;){if(o=t.splice(0,1)[0],a=o(e),a&&a.then)return a.then(n).then(void 0,i.promiseError);i.markTime("sync done "+o.name)}return r&&r(e)},i.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},i.noneOrAll=function(t,e,r){if(t){var n,i,a=!1,o=!0;for(n=0;ni;i++)e[i][r]=t[i]},i.minExtend=function(t,e){var r={};"object"!=typeof e&&(e={});var n,a,o,s=3,l=Object.keys(t);for(n=0;nn;n++)r[n]=new Array(e);return r},r.transposeRagged=function(t){var e,r,n=0,i=t.length;for(e=0;i>e;e++)n=Math.max(n,t[e].length);var a=new Array(n);for(e=0;n>e;e++)for(a[e]=new Array(i),r=0;i>r;r++)a[e][r]=t[r][e];return a},r.dot=function(t,e){if(!t.length||!e.length||t.length!==e.length)return null;var n,i,a=t.length;if(t[0].length)for(n=new Array(a),i=0;a>i;i++)n[i]=r.dot(t[i],e);else if(e[0].length){var o=r.transposeRagged(e);for(n=new Array(o.length),i=0;ii;i++)n+=t[i]*e[i];return n},r.translationMatrix=function(t,e){return[[1,0,t],[0,1,e],[0,0,1]]},r.rotationMatrix=function(t){var e=t*Math.PI/180;return[[Math.cos(e),-Math.sin(e),0],[Math.sin(e),Math.cos(e),0],[0,0,1]]},r.rotationXYMatrix=function(t,e,n){return r.dot(r.dot(r.translationMatrix(e,n),r.rotationMatrix(t)),r.translationMatrix(-e,-n))},r.apply2DTransform=function(t){return function(){var e=arguments;3===e.length&&(e=e[0]);var n=1===arguments.length?e[0]:[e[0],e[1]];return r.dot(t,[n[0],n[1],1]).slice(0,2)}},r.apply2DTransform2=function(t){var e=r.apply2DTransform(t);return function(t){return e(t.slice(0,2)).concat(e(t.slice(2,4)))}}},{}],384:[function(t,e,r){"use strict";function n(t,e){return function(){var r,i,a,o,s,l=t;for(o=0;o=0;e--){if(n=t[e],o=!1,Array.isArray(n))for(r=n.length-1;r>=0;r--)c(n[r])?o?n[r]=void 0:n.pop():o=!0;else if("object"==typeof n&&null!==n)for(a=Object.keys(n),o=!1,r=a.length-1;r>=0;r--)c(n[a[r]])&&!i(n[a[r]],a[r])?delete n[a[r]]:o=!0;if(o)return}}function c(t){return void 0===t||null===t?!0:"object"!=typeof t?!1:Array.isArray(t)?!t.length:!Object.keys(t).length}function u(t,e,r){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:r,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,l=e.split(".");sr||r>a||o>n||n>s?!1:!e||!c(t)}function r(t,e){var r=t[0],l=t[1];if(i>r||r>a||o>l||l>s)return!1;var c,u,f,h,d,p=n.length,g=n[0][0],v=n[0][1],m=0;for(c=1;p>c;c++)if(u=g,f=v,g=n[c][0],v=n[c][1],h=Math.min(u,g),!(h>r||r>Math.max(u,g)||l>Math.max(f,v)))if(l=l&&r!==h&&m++}return m%2===1}var n=t.slice(),i=n[0][0],a=i,o=n[0][1],s=o;n.push(n[0]);for(var l=1;la;a++)if(o=[t[a][0]-l[0],t[a][1]-l[1]],s=n(o,c),0>s||s>u||Math.abs(n(o,h))>i)return!0;return!1};i.filter=function(t,e){function r(r){t.push(r);var s=n.length,l=i;n.splice(o+1);for(var c=l+1;c1){var s=t.pop();r(s)}return{addPt:r,raw:t,filtered:n}}},{"./matrix":383}],387:[function(t,e,r){"use strict";function n(t,e){for(var r,n=[],a=0;a=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;rt}function i(t,e){return e>=t}function a(t,e){return t>e}function o(t,e){return t>=e}var s=t("fast-isnumeric");r.findBin=function(t,e,r){if(s(e.start))return r?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var l,c,u=0,f=e.length,h=0;for(c=e[e.length-1]>=e[0]?r?n:i:r?o:a;f>u&&h++<100;)l=Math.floor((u+f)/2),c(e[l],t)?u=l+1:f=l;return h>90&&console.log("Long binary search..."),u-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;n>s;s++)e[s+1]>e[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,c=r?Math.ceil:Math.floor;a>i&&o++<100;)n=c((i+a)/2),e[n]<=t?i=n+s:a=n-l;return e[i]}},{"fast-isnumeric":76}],389:[function(t,e,r){"use strict";e.exports=function(t,e){(t.attr("class")||"").split(" ").forEach(function(e){0===e.indexOf("cursor-")&&t.classed(e,!1)}),e&&t.classed("cursor-"+e,!0)}},{}],390:[function(t,e,r){"use strict";var n=t("../components/color"),i=function(){};e.exports=function(t){for(var e in t)"function"==typeof t[e]&&(t[e]=i);t.destroy=function(){t.container.parentNode.removeChild(t.container)};var r=document.createElement("div");return r.textContent="Webgl is not supported by your browser - visit http://get.webgl.org for more info",r.style.cursor="pointer",r.style.fontSize="24px",r.style.color=n.defaults[0],t.container.appendChild(r),t.container.style.background="#FFFFFF",t.container.onclick=function(){window.open("http://get.webgl.org")},!1}},{"../components/color":303}],391:[function(t,e,r){"use strict";var n=t("fast-isnumeric");r.aggNums=function(t,e,i,a){var o,s;if(a||(a=i.length),n(e)||(e=!1),Array.isArray(i[0])){for(s=new Array(a),o=0;a>o;o++)s[o]=r.aggNums(t,e,i[o]);i=s}for(o=0;a>o;o++)n(e)?n(i[o])&&(e=t(+e,+i[o])):e=i[o];return e},r.len=function(t){return r.aggNums(function(t){return t+1},0,t)},r.mean=function(t,e){return e||(e=r.len(t)),r.aggNums(function(t,e){return t+e},0,t)/e},r.variance=function(t,e,i){return e||(e=r.len(t)),n(i)||(i=r.mean(t,e)),r.aggNums(function(t,e){return t+Math.pow(e-i,2)},0,t)/e},r.stdev=function(t,e,n){return Math.sqrt(r.variance(t,e,n))},r.interp=function(t,e){if(!n(e))throw"n should be a finite number";if(e=e*t.length-.5,0>e)return t[0];if(e>t.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"fast-isnumeric":76}],392:[function(t,e,r){"use strict";function n(t){return t=i(t),a.str2RgbaArray(t.toRgbString())}var i=t("tinycolor2"),a=t("arraytools");e.exports=n},{arraytools:49,tinycolor2:233}],393:[function(t,e,r){"use strict";function n(t,e){return t.node().getBoundingClientRect()[e]}function i(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function a(t,e,r){var n="math-output-"+l.Lib.randstr([],64),a=c.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(i(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,a.node()],function(){var e=c.select("body").select("#MathJax_SVG_glyphs");if(a.select(".MathJax_SVG").empty()||!a.select("svg").node())console.log("There was an error in the tex syntax.",t),r();else{var n=a.select("svg").node().getBoundingClientRect();r(a.select(".MathJax_SVG"),e,n)}a.remove()})}function o(t){for(var e=l.util.html_entity_decode(t),r=e.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),r=e&&e[2].toLowerCase(),n=h[r];if(void 0!==n){var i=e[1],a=e[3],o=a.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===r){if(i)return"
";if("href"!==a.substr(0,4).toLowerCase())return"";var s=document.createElement("a");return s.href=a.substr(4).replace(/["'=]/g,""),-1===d.indexOf(s.protocol)?"":'"}if("br"===r)return"
";if(i)return"sup"===r?'':"sub"===r?'':"";var c=""}return l.util.xml_entity_encode(t).replace(/");i>0;i=r.indexOf("
",i+1))n.push(i);var a=0;n.forEach(function(t){for(var e=t+a,n=r.slice(0,e),i="",o=n.length-1;o>=0;o--){var s=n[o].match(/<(\/?).*>/i);if(s&&"
"!==n[o]){s[1]||(i=n[o]);break}}i&&(r.splice(e+1,0,i),r.splice(e,0,""),a+=2)});var o=r.join(""),s=o.split(/
/gi);return s.length>1&&(r=s.map(function(t,e){return''+t+""})),r.join("")}function s(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-c.top+"px",left:a()-c.left+"px","z-index":1e3}),this}}var l=t("../plotly"),c=t("d3"),u=t("../constants/xmlns_namespaces"),f=e.exports={};c.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),r=(new DOMParser).parseFromString(e,"application/xml"),n=r.documentElement.firstChild;n;)this.node().appendChild(this.node().ownerDocument.importNode(n,!0)),n=n.nextSibling;return r.querySelector("parsererror")?(console.log(r.querySelector("parsererror div").textContent),null):c.select(this.node().lastChild)},f.html_entity_decode=function(t){var e=c.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),r},f.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},f.convertToTspans=function(t,e){function r(){d.empty()||(p=u.attr("class")+"-math",d.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),h=t.appendSVG(s),h||t.text(i),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(u)}var i=t.text(),s=o(i),u=t,f=!u.attr("data-notex")&&s.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),h=i,d=c.select(u.node().parentNode);if(!d.empty()){var p=u.attr("class")?u.attr("class").split(" ")[0]:"text";p+="-math",d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=l.Lib.getPlotDiv(u.node());(v&&v._promises||[]).push(new Promise(function(t){u.style({visibility:"hidden"});var i={fontSize:parseInt(u.style("font-size"),10)};a(f[2],i,function(i,a,o){d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove();var s=i&&i.select("svg");if(!s||!s.node())return r(),void t();var l=d.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});l.node().appendChild(s.node()),a&&a.node()&&s.node().insertBefore(a.node().cloneNode(!0),s.node().firstChild),s.attr({"class":p,height:o.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=u.style("fill")||"black";s.select("g").attr({fill:c,stroke:c});var f=n(s,"width"),h=n(s,"height"),g=+u.attr("x")-f*{start:0,middle:.5,end:1}[u.attr("text-anchor")||"start"],v=parseInt(u.style("font-size"),10)||n(u,"height"),m=-v/4;"y"===p[0]?(l.attr({transform:"rotate("+[-90,+u.attr("x"),+u.attr("y")]+") translate("+[-f/2,m-h/2]+")"}),s.attr({x:+u.attr("x"),y:+u.attr("y")})):"l"===p[0]?s.attr({x:u.attr("x"),y:m-h/2}):"a"===p[0]?s.attr({x:0,y:m}):s.attr({x:g,y:+u.attr("y")+m-h/2}),e&&e.call(u,l),t(l)})}))}else r();return t}};var h={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},d=["http:","https:","mailto:"],p=new RegExp("]*)?/?>","g");f.plainText=function(t){return(t||"").replace(p," ")},f.makeEditable=function(t,e,r){function n(){a(),o.style({opacity:0});var t,e=h.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0})}function i(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}function a(){var t=c.select(l.Lib.getPlotDiv(o.node())),e=t.select(".svg-container"),n=e.append("div");n.classed("plugin-editable editable",!0).style({position:"absolute","font-family":o.style("font-family")||"Arial","font-size":o.style("font-size")||12,color:r.fill||o.style("fill")||"black",opacity:1,"background-color":r.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(o.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(r.text||o.attr("data-unformatted")).call(s(o,e,r)).on("blur",function(){o.text(this.textContent).style({opacity:1});var t,e=c.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0});var r=this.textContent;c.select(this).transition().duration(0).remove(),c.select(document).on("mouseup",null),u.edit.call(o,r)}).on("focus",function(){var t=this;c.select(document).on("mouseup",function(){return c.event.target===t?!1:void(document.activeElement===n.node()&&n.node().blur())})}).on("keyup",function(){27===c.event.which?(o.style({opacity:1}),c.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),u.cancel.call(o,this.textContent)):(u.input.call(o,this.textContent),c.select(this).call(s(o,e,r)))}).on("keydown",function(){13===c.event.which&&this.blur()}).call(i)}r||(r={});var o=this,u=c.dispatch("edit","input","cancel"),f=c.select(this.node()).style({"pointer-events":"all"}),h=e||f;return e&&f.style({"pointer-events":"none"}),r.immediate?n():h.on("click",n),c.rebind(this,u,"on")}},{"../constants/xmlns_namespaces":369,"../plotly":400,d3:72}],394:[function(t,e,r){"use strict";var n=e.exports={},i=t("../plots/geo/constants").locationmodeToLayer,a=t("topojson").feature;n.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},n.getTopojsonPath=function(t,e){return t+e+".json"},n.getTopojsonFeatures=function(t,e){var r=i[t.locationmode],n=e.objects[r];return a(e,n).features}},{"../plots/geo/constants":422,topojson:234}],395:[function(t,e,r){"use strict";function n(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function i(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function a(t,e){t._context||(t._context=R.extendFlat({},P.defaultConfig));var r=t._context;e&&(Object.keys(e).forEach(function(t){t in r&&("setBackground"===t&&"opaque"===e[t]?r[t]=i:r[t]=e[t])}),e.plot3dPixelRatio&&!r.plotGlPixelRatio&&(r.plotGlPixelRatio=r.plot3dPixelRatio)),r.staticPlot&&(r.editable=!1,r.autosizable=!1,r.scrollZoom=!1,r.doubleClick=!1,r.showTips=!1,r.showLink=!1,r.displayModeBar=!1)}function o(t,e,r){var n=S.select(t).selectAll(".plot-container").data([0]);n.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=n.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e),r&&(t.layout=r),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(w(t,{}),t._fullLayout.autosize=r.autosize=!0),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var a=t.framework.svg(),o=1,s=t._fullLayout.title;""!==s&&s||(o=0);var l="Click to enter title",c=function(){this.call(P.util.convertToTspans)},u=a.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":s}),s&&s!==l||(o=.2,u.attr({"data-unformatted":l}).text(l).style({opacity:o}).on("mouseover.opacity",function(){S.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){S.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),N.addLinks(t),Promise.resolve()}function s(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var n=P.Axes.list({_fullLayout:t});for(e=0;ee;e++){var o=t.annotations[e];o.ref&&("paper"===o.ref?(o.xref="paper",o.yref="paper"):"data"===o.ref&&(o.xref="x",o.yref="y"),delete o.ref),l(o,"xref"),l(o,"yref")}void 0===t.shapes||Array.isArray(t.shapes)||(console.log("shapes must be an array"),delete t.shapes);var s=(t.shapes||[]).length;for(e=0;s>e;e++){var c=t.shapes[e];l(c,"xref"),l(c,"yref")}var u=t.legend;u&&(u.x>3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var h=N.getSubplotIds(t,"gl3d");for(e=0;er;++r)b[r]=v[e]+m*y[2+4*r];d.camera={eye:{x:b[0],y:b[1],z:b[2]},center:{x:v[0],y:v[1],z:v[2]},up:{x:y[1],y:y[5],z:y[9]}},delete d.cameraposition}}return R.markTime("finished rest of cleanLayout, starting color"),F.clean(t),R.markTime("finished cleanLayout color.clean"),t}function l(t,e){var r=t[e],n=e.charAt(0);r&&"paper"!==r&&(t[e]=P.Axes.cleanId(r,n))}function c(t,e){for(var r=[],n=(t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid})),i=0;ia&&(s=R.randstr(n),-1!==r.indexOf(s));a++);o.uid=R.randstr(n),n.push(o.uid)}if(r.push(o.uid),"histogramy"===o.type&&"xbins"in o&&!("ybins"in o)&&(o.ybins=o.xbins,delete o.xbins),o.error_y&&"opacity"in o.error_y){var l=F.defaults,c=o.error_y.color||(N.traceIs(o,"bar")?F.defaultLine:l[i%l.length]);o.error_y.color=F.addOpacity(F.rgb(c),F.opacity(c)*o.error_y.opacity),delete o.error_y.opacity}if("bardir"in o&&("h"!==o.bardir||!N.traceIs(o,"bar")&&"histogram"!==o.type.substr(0,9)||(o.orientation="h",x(o)),delete o.bardir),"histogramy"===o.type&&x(o),"histogramx"!==o.type&&"histogramy"!==o.type||(o.type="histogram"),"scl"in o&&(o.colorscale=o.scl,delete o.scl),"reversescl"in o&&(o.reversescale=o.reversescl,delete o.reversescl),o.xaxis&&(o.xaxis=P.Axes.cleanId(o.xaxis,"x")),o.yaxis&&(o.yaxis=P.Axes.cleanId(o.yaxis,"y")),N.traceIs(o,"gl3d")&&o.scene&&(o.scene=N.subplotsRegistry.gl3d.cleanId(o.scene)),N.traceIs(o,"pie")||(Array.isArray(o.textposition)?o.textposition=o.textposition.map(u):o.textposition&&(o.textposition=u(o.textposition))),N.traceIs(o,"2dMap")&&("YIGnBu"===o.colorscale&&(o.colorscale="YlGnBu"),"YIOrRd"===o.colorscale&&(o.colorscale="YlOrRd")),N.traceIs(o,"markerColorscale")&&o.marker){var h=o.marker;"YIGnBu"===h.colorscale&&(h.colorscale="YlGnBu"),"YIOrRd"===h.colorscale&&(h.colorscale="YlOrRd")}if("surface"===o.type&&R.isPlainObject(o.contours)){var d=["x","y","z"];for(a=0;an?a.push(i+n):a.push(n);return a}function p(t,e,r){var n,i;for(n=0;n=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||0>i&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function g(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),p(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&p(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function v(t,e,r){var n,i;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),n=0;n=0&&l0){var s=_(t._boundingBoxMargins),l=s.left+s.right,c=s.bottom+s.top,u=a._container.node().getBoundingClientRect(),f=1-2*o.frameMargins;i=Math.round(f*(u.width-l)),n=Math.round(f*(u.height-c))}else r=window.getComputedStyle(t),n=parseFloat(r.height)||a.height,i=parseFloat(r.width)||a.width;return Math.abs(a.width-i)>1||Math.abs(a.height-n)>1?(a.height=t.layout.height=n,a.width=t.layout.width=i):"initial"!==a.autosize&&(delete e.autosize,a.autosize=t.layout.autosize=!0),N.sanitizeMargins(a),e}function k(t){var e=S.select(t),r=t._fullLayout;if(r._container=e.selectAll(".plot-container").data([0]),r._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),r._paperdiv=r._container.selectAll(".svg-container").data([0]),r._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===r.autosize&&(w(t,{}),r.autosize=!0,t.layout.autosize=!0),r._glcontainer=r._paperdiv.selectAll(".gl-container").data([0]),r._glcontainer.enter().append("div").classed("gl-container",!0),r._geocontainer=r._paperdiv.selectAll(".geo-container").data([0]),r._geocontainer.enter().append("div").classed("geo-container",!0),r._paperdiv.selectAll(".main-svg").remove(),r._paper=r._paperdiv.insert("svg",":first-child").classed("main-svg",!0),r._toppaper=r._paperdiv.append("svg").classed("main-svg",!0),!r._uid){var n=[];S.selectAll("defs").each(function(){this.id&&n.push(this.id.split("-")[1])}),r._uid=R.randstr(n)}r._paperdiv.selectAll(".main-svg").attr(W.svgAttrs),r._defs=r._paper.append("defs").attr("id","defs-"+r._uid),r._topdefs=r._toppaper.append("defs").attr("id","topdefs-"+r._uid),r._draggers=r._paper.append("g").classed("draglayer",!0);var i=r._paper.append("g").classed("layer-below",!0);r._imageLowerLayer=i.append("g").classed("imagelayer",!0),r._shapeLowerLayer=i.append("g").classed("shapelayer",!0);var a=P.Axes.getSubplots(t); +a.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,a),r._has("cartesian")&&M(t,a),r._ternarylayer=r._paper.append("g").classed("ternarylayer",!0);var o=r._paper.selectAll(".layer-subplot");r._imageSubplotLayer=o.selectAll(".imagelayer"),r._shapeSubplotLayer=o.selectAll(".shapelayer");var s=r._paper.append("g").classed("layer-above",!0);r._imageUpperLayer=s.append("g").classed("imagelayer",!0),r._shapeUpperLayer=s.append("g").classed("shapelayer",!0),r._pielayer=r._paper.append("g").classed("pielayer",!0),r._glimages=r._paper.append("g").classed("glimages",!0),r._geoimages=r._paper.append("g").classed("geoimages",!0),r._infolayer=r._toppaper.append("g").classed("infolayer",!0),r._zoomlayer=r._toppaper.append("g").classed("zoomlayer",!0),r._hoverlayer=r._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var l=R.syncOrAsync([T,function(){return P.Axes.doTicks(t,"redraw")},j.init],t);return l&&l.then&&t._promises.push(l),l}function A(t,e){function r(e,r){return function(){return P.Axes.getFromId(t,e,r)}}for(var n,i,a=t._fullLayout._plots={},o=0;o0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),A=w===_;x?t.framework===k&&!b&&A||(t.framework=k,k(t)):A?b&&k(t):(t.framework=k,k(t)),b&&P.Axes.saveRangeInitial(t);var M=t._fullLayout,E=!t.calcdata||t.calcdata.length!==(t.data||[]).length;E&&h(t);for(var L=0;LY.range[0]?[1,2]:[2,1]);else{var W=Y.range[0],Z=Y.range[1];"log"===O?(0>=W&&0>=Z&&i(q+".autorange",!0),0>=W?W=Z/1e6:0>=Z&&(Z=W/1e6),i(q+".range[0]",Math.log(W)/Math.LN10),i(q+".range[1]",Math.log(Z)/Math.LN10)):(i(q+".range[0]",Math.pow(10,W)),i(q+".range[1]",Math.pow(10,Z)))}else i(q+".autorange",!0)}if("reverse"===D)H.range?H.range.reverse():(i(q+".autorange",!0),H.range=[1,0]),G.autorange?_=!0:x=!0;else if("annotations"===z.parts[0]||"shapes"===z.parts[0]){var K=z.parts[1],$=z.parts[0],Q=p[$]||[],J=P[R.titleCase($)],tt=Q[K]||{};2===z.parts.length&&("add"===v[C]||R.isPlainObject(v[C])?E[C]="remove":"remove"===v[C]?-1===K?(E[$]=Q,delete E[C]):E[C]=tt:console.log("???",v)),!a(tt,"x")&&!a(tt,"y")||R.containsAny(C,["color","opacity","align","dash"])||(_=!0),J.draw(t,K,z.parts.slice(2).join("."),v[C]),delete v[C]}else if("images"===z.parts[0]){var rt=R.objectFromPath(e,O);R.extendDeepAll(t.layout,rt),U.supplyLayoutDefaults(t.layout,t._fullLayout),U.draw(t)}else 0===z.parts[0].indexOf("scene")?x=!0:0===z.parts[0].indexOf("geo")?x=!0:0===z.parts[0].indexOf("ternary")?x=!0:!g._has("gl2d")||-1===C.indexOf("axis")&&"plot_bgcolor"!==z.parts[0]?"hiddenlabels"===C?_=!0:-1!==z.parts[0].indexOf("legend")?m=!0:-1!==C.indexOf("title")?y=!0:-1!==z.parts[0].indexOf("bgcolor")?b=!0:z.parts.length>1&&R.containsAny(z.parts[1],["tick","exponent","grid","zeroline"])?y=!0:-1!==C.indexOf(".linewidth")&&-1!==C.indexOf("axis")?y=b=!0:z.parts.length>1&&-1!==z.parts[1].indexOf("line")?b=!0:z.parts.length>1&&"mirror"===z.parts[1]?y=b=!0:"margin.pad"===C?y=b=!0:"margin"===z.parts[0]||"autorange"===z.parts[1]||"rangemode"===z.parts[1]||"type"===z.parts[1]||"domain"===z.parts[1]||C.match(/^(bar|box|font)/)?_=!0:-1!==["hovermode","dragmode"].indexOf(C)?k=!0:-1===["hovermode","dragmode","height","width","autosize"].indexOf(C)&&(x=!0):x=!0,z.set(O)}I&&I.add(t,et,[t,E],et,[t,M]),v.autosize&&(v=w(t,v)),(v.height||v.width||v.autosize)&&(_=!0);var nt=Object.keys(v),it=[N.previousPromises];if(x||_)it.push(function(){return t.layout=void 0,_&&(t.calcdata=void 0),P.plot(t,"",p)});else if(nt.length&&(N.supplyDefaults(t),g=t._fullLayout,m&&it.push(function(){return V.draw(t),N.previousPromises(t)}),b&&it.push(T),y&&it.push(function(){return P.Axes.doTicks(t,"redraw"),L(t),N.previousPromises(t)}),k)){var at;for(X(t),at=N.getSubplotIds(g,"gl3d"),d=0;d1)};l(r.width)&&l(r.height)||o(new Error("Height and width should be pixel values."));var c=n.clone(e,{format:"png",height:r.height,width:r.width}),u=c.td;u.style.position="absolute",u.style.left="-5000px",document.body.appendChild(u);var f=n.getRedrawFunc(u);i.plot(u,c.data,c.layout,c.config).then(f).then(s).then(function(e){t(e)}).catch(function(t){o(t)})});return o}var i=t("../plotly"),a=t("fast-isnumeric");e.exports=n},{"../plotly":400,"../snapshot":469,"fast-isnumeric":76}],400:[function(t,e,r){"use strict";t("es6-promise").polyfill(),r.Lib=t("./lib"),r.util=t("./lib/svg_text_utils"),r.Queue=t("./lib/queue"),t("../build/plotcss"),r.MathJaxConfig=t("./fonts/mathjax_config"),r.defaultConfig=t("./plot_api/plot_config");var n=r.Plots=t("./plots/plots");r.Axes=t("./plots/cartesian/axes"),r.Fx=t("./plots/cartesian/graph_interact"),r.micropolar=t("./plots/polar/micropolar"),r.Color=t("./components/color"),r.Drawing=t("./components/drawing"),r.Colorscale=t("./components/colorscale"),r.Colorbar=t("./components/colorbar"),r.ErrorBars=t("./components/errorbars"),r.Annotations=t("./components/annotations"),r.Shapes=t("./components/shapes"),r.Legend=t("./components/legend"),r.Images=t("./components/images"),r.ModeBar=t("./components/modebar"),r.register=function(t){if(!t)throw new Error("No argument passed to Plotly.register.");t&&!Array.isArray(t)&&(t=[t]);for(var e=0;ec&&u>e&&(void 0===i[r]?a[f]=E.tickText(t,e):a[f]=s(t,e,String(i[r])),f++);return f=864e5?t._tickround="d":r>=36e5?t._tickround="H":r>=6e4?t._tickround="M":r>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(r/2)/Math.LN10);else{x(r)||(r=Number(r.substr(1))),t._tickround=2-Math.floor(Math.log(r)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var n=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(n)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((n-1)/3):t._tickexponent=n)}else"M"===r.charAt(0)?t._tickround=2===r.length?"m":"y":t._tickround=null}function o(t,e){var r=t.match(V),n=new Date(e);if(r){var i=Math.min(+r[1]||6,6),a=String(e/1e3%1+2.0000005).substr(2,i).replace(/0+$/,"")||"0";return b.time.format(t.replace(V,a))(n)}return b.time.format(t)(n)}function s(t,e,r){var n=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}function l(t,e,r,n){var i,a=e.x,s=t._tickround,l=new Date(a),c="";r&&t.hoverformat?i=o(t.hoverformat,a):t.tickformat?i=o(t.tickformat,a):(n&&(x(s)?s+=2:s={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[s]),"y"===s?i=N(l):"m"===s?i=j(l):(a!==t._tmin||r||(c="
"+N(l)),"d"===s?i=F(l):"H"===s?i=D(l):(a!==t._tmin||r||(c="
"+F(l)+", "+N(l)),i=B(l),"M"!==s&&(i+=U(l),"S"!==s&&(i+=h(y(a/1e3,1),t,"none",r).substr(1)))))),e.text=i+c}function c(t,e,r,n,i){var a=t.dtick,o=e.x;if(!n||"string"==typeof a&&"L"===a.charAt(0)||(a="L3"),t.tickformat||"string"==typeof a&&"L"===a.charAt(0))e.text=h(Math.pow(10,o),t,i,n);else if(x(a)||"D"===a.charAt(0)&&y(o+.01,1)<.1)if(-1!==["e","E","power"].indexOf(t.exponentformat)){var s=Math.round(o);0===s?e.text=1:1===s?e.text="10":s>1?e.text="10"+s+"":e.text="10\u2212"+-s+"",e.fontSize*=1.25}else e.text=h(Math.pow(10,o),t,"","fakehover"),"D1"===a&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==a.charAt(0))throw"unrecognized dtick "+String(a);e.text=String(Math.round(Math.pow(10,y(o,1)))),e.fontSize*=.75}if("D1"===t.dtick){var l=String(e.text).charAt(0);"0"!==l&&"1"!==l||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(0>o?.5:.25)))}}function u(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r=""),e.text=String(r)}function f(t,e,r,n,i){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide"),e.text=h(e.x,t,i,n)}function h(t,e,r,n){var i=0>t,o=e._tickround,s=r||e.exponentformat||"B",l=e._tickexponent,c=e.tickformat;if(n){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:x(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};a(u),o=(Number(u._tickround)||0)+4,l=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return b.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-o)/2;if("none"===s&&(l=0),t=Math.abs(t),f>t)t="0",i=!1;else{if(t+=f,l&&(t*=Math.pow(10,-l),o+=l),0===o)t=String(Math.floor(t));else if(0>o){t=String(Math.round(t)),t=t.substr(0,t.length+o);for(var h=o;0>h;h++)t+="0"}else{t=String(t);var p=t.indexOf(".")+1;p&&(t=t.substr(0,p+o).replace(/\.?0+$/,""))}t=d(t,e._gd._fullLayout.separators)}if(l&&"hide"!==s){var g;g=0>l?"\u2212"+-l:"power"!==s?"+"+l:String(l),"e"===s||("SI"===s||"B"===s)&&(l>12||-15>l)?t+="e"+g:"E"===s?t+="E"+g:"power"===s?t+="×10"+g+"":"B"===s&&9===l?t+="B":"SI"!==s&&"B"!==s||(t+=q[l/3+5])}return i?"\u2212"+t:t}function d(t,e){var r=e.charAt(0),n=e.charAt(1),i=t.split("."),a=i[0],o=i.length>1?r+i[1]:"";if(n&&(i.length>1||a.length>4))for(;H.test(a);)a=a.replace(H,"$1"+n+"$2");return a+o}function p(t,e){var r,n,i=[];for(r=0;r1)for(n=1;n2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},E.getAutoRange=function(t){var e,r=[],n=t._min[0].val,i=t._max[0].val;for(e=1;e0&&u>0&&f/u>h&&(l=o,c=s,h=f/u);return n===i?r=d?[n+1,"normal"!==t.rangemode?0:n-1]:["normal"!==t.rangemode?0:n-1,n+1]:h&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode&&l.val>=0?l={val:0,pad:0}:"nonnegative"===t.rangemode&&(l.val-h*l.pad<0&&(l={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),h=(c.val-l.val)/(t._length-l.pad-c.pad)),r=[l.val-h*l.pad,c.val+h*c.pad],r[0]===r[1]&&(r=[r[0]-1,r[0]+1]),d&&r.reverse()),r},E.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=E.getAutoRange(t);var r=t._gd.layout[t._name];r||(t._gd.layout[t._name]=r={}),r!==t&&(r.range=t.range.slice(),r.autorange=t.autorange)}},E.saveRangeInitial=function(t,e){for(var r=E.list(t,"",!0),n=!1,i=0;ip&&(p=g/10),c=t.c2l(p),u=t.c2l(g),y&&(c=Math.min(0,c),u=Math.max(0,u)),n(c)){for(d=!0,o=0;o=h?d=!1:s.val>=c&&s.pad<=h&&(t._min.splice(o,1),o--);d&&t._min.push({val:c,pad:y&&0===c?0:h})}if(n(u)){for(d=!0,o=0;o=u&&s.pad>=f?d=!1:s.val<=u&&s.pad<=f&&(t._max.splice(o,1),o--);d&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),r||(r={}),t._m||t.setScale();var a,o,s,l,c,u,f,h,d,p,g,v=e.length,m=r.padded?.05*t._length:0,y=r.tozero&&("linear"===t.type||"-"===t.type),b=n((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),_=n((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),w=n(r.vpadplus||r.vpad),k=n(r.vpadminus||r.vpad);for(a=0;6>a;a++)i(a);for(a=v-1;a>5;a--)i(a)}},E.autoBin=function(t,e,r,n){function i(t){return(1+100*(t-d)/f.dtick)%100<2}var a=w.aggNums(Math.min,null,t),o=w.aggNums(Math.max,null,t);if("category"===e.type)return{start:a-.5,end:o+.5,size:1};var s;if(r)s=(o-a)/r;else{var l=w.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(l.minDiff)/Math.LN10)),u=c*w.roundUp(l.minDiff/c,[.9,1.9,4.9,9.9],!0);s=Math.max(u,2*w.stdev(t)/Math.pow(t.length,n?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[a,o]};E.autoTicks(f,s);var h,d=E.tickIncrement(E.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;yg&&(p>.3*b||i(a)||i(o))){var _=f.dtick/2;d+=a>d+_?_:-_}var k=1+Math.floor((o-d)/f.dtick);h=d+k*f.dtick}else for(h=d;o>=h;)h=E.tickIncrement(h,f.dtick);return{start:d,end:h,size:f.dtick}},E.calcTicks=function(t){if("array"===t.tickmode)return n(t);if("auto"===t.tickmode||!t.dtick){var e,r=t.nticks;r||("category"===t.type?(e=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/e):(e="y"===t._id.charAt(0)?40:80,r=w.constrain(t._length/e,4,9)+1)),E.autoTicks(t,Math.abs(t.range[1]-t.range[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),a(t),t._tmin=E.tickFirst(t);var i=t.range[1]=s:s>=l)&&(o.push(l),!(o.length>1e3));l=E.tickIncrement(l,t.dtick,i));t._tmax=o[o.length-1];for(var c=new Array(o.length),u=0;u157788e5?(e/=315576e5,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*i(e,r,C)):e>12096e5?(e/=26298e5,t.dtick="M"+i(e,1,z)):e>432e5?(t.dtick=i(e,864e5,R),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=i(e,36e5,z):e>3e4?t.dtick=i(e,6e4,P):e>500?t.dtick=i(e,1e3,P):(r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,C));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var n=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/n,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+i(e,r,C)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,C));if(0===t.dtick&&(t.dtick=1),!x(t.dtick)&&"string"!=typeof t.dtick){var a=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(a)}},E.tickIncrement=function(t,e,r){var n=r?-1:1;if(x(e))return t+n*e;var i=e.charAt(0),a=n*Number(e.substr(1));if("M"===i){var o=new Date(t);return o.setMonth(o.getMonth()+a)}if("L"===i)return Math.log(Math.pow(10,t)+a)/Math.LN10;if("D"===i){var s="D2"===e?I:O,l=t+.01*n,c=w.roundUp(y(l,1),s,r);return Math.floor(l)+Math.log(b.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},E.tickFirst=function(t){var e=t.range[1]n:n>c;)c=E.tickIncrement(c,i,e);return c}if("L"===u)return Math.log(r((Math.pow(10,n)-a)/f)*f+a)/Math.LN10;if("D"===u){var h="D2"===i?I:O,d=w.roundUp(y(n,1),h,e);return Math.floor(n)+Math.log(b.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(i)};var N=b.time.format("%Y"),j=b.time.format("%b %Y"),F=b.time.format("%b %-d"),D=b.time.format("%b %-d %Hh"),B=b.time.format("%H:%M"),U=b.time.format(":%S"),V=/%(\d?)f/g;E.tickText=function(t,e,r){function n(n){var i;return void 0===n?!0:r?"none"===n:(i={first:t._tmin,last:t._tmax}[n],"all"!==n&&e!==i)}var i,a,o=s(t,e),h="array"===t.tickmode,d=r||h;if(h&&Array.isArray(t.ticktext)){var p=Math.abs(t.range[1]-t.range[0])/1e4;for(a=0;a1&&er&&(M=90),i(u,M)}c._lastangle=M}return o(e),e+" done"}function l(){c._boundingBox=r.node().getBoundingClientRect()}var u=r.selectAll("g."+C).data(y,S);if(!c.showticklabels||!x(n))return u.remove(),void o(e);var f,h,p,m,_;"x"===v?(_="bottom"===B?1:-1,f=function(t){return t.dx+I*_},m=n+(O+R)*_,h=function(t){return t.dy+m+t.fontSize*("bottom"===B?1:-.5)},p=function(t){return x(t)&&0!==t&&180!==t?0>t*_?"end":"start":"middle"}):(_="right"===B?1:-1,h=function(t){return t.dy+t.fontSize/2-I*_},f=function(t){return t.dx+n+(O+R+(90===Math.abs(c.tickangle)?t.fontSize/2:0))*_},p=function(t){return x(t)&&90===Math.abs(t)?"middle":"right"===B?"start":"end"});var A=0,M=0,E=[];u.enter().append("g").classed(C,1).append("text").attr("text-anchor","middle").each(function(e){var r=b.select(this),n=t._promises.length;r.call(T.setPosition,f(e),h(e)).call(T.font,e.font,e.fontSize,e.fontColor).text(e.text).call(k.convertToTspans),n=t._promises[n],n?E.push(t._promises.pop().then(function(){i(r,c.tickangle)})):i(r,c.tickangle)}),u.exit().remove(),u.each(function(t){A=Math.max(A,t.fontSize)}),i(u,c._lastangle||c.tickangle);var L=w.syncOrAsync([a,s,l]);return L&&L.then&&t._promises.push(L),L}function o(e){if(!r){var n,i,a,o,s=L.getFromId(t,e),l=b.select(t).selectAll("g."+e+"tick"),c={selection:l,side:s.side},f=e.charAt(0),h=t._fullLayout._size,d=1.5,p=s.titlefont.size;if(l.size()){var g=b.select(l.node().parentNode).attr("transform").match(/translate\(([-\.\d]+),([-\.\d]+)\)/);g&&(c.offsetLeft=+g[1],c.offsetTop=+g[2])}"x"===f?(i="free"===s.anchor?{_offset:h.t+(1-(s.position||0))*h.h,_length:0}:L.getFromId(t,s.anchor),a=s._offset+s._length/2,o=i._offset+("top"===s.side?-10-p*(d+(s.showticklabels?1:0)):i._length+10+p*(d+(s.showticklabels?1.5:.5))),s.rangeslider&&s.rangeslider.visible&&s._boundingBox&&(o+=(u.height-u.margin.b-u.margin.t)*s.rangeslider.thickness+s._boundingBox.height),c.side||(c.side="bottom")):(i="free"===s.anchor?{_offset:h.l+(s.position||0)*h.w,_length:0}:L.getFromId(t,s.anchor),o=s._offset+s._length/2,a=i._offset+("right"===s.side?i._length+10+p*(d+(s.showticklabels?1:.5)):-10-p*(d+(s.showticklabels?.5:0))),n={rotate:"-90",offset:0},c.side||(c.side="left")),A.draw(t,e+"title",{propContainer:s,propName:s._name+".title",dfltName:f.toUpperCase()+" axis",avoid:c,transform:n,attributes:{x:a,y:o,"text-anchor":"middle"}})}}function s(t,e){return t.visible!==!0||t.xaxis+t.yaxis!==e?!1:_.Plots.traceIs(t,"bar")&&t.orientation==={x:"h",y:"v"}[v]?!0:t.fill&&t.fill.charAt(t.fill.length-1)===v}function l(e,r,i){var a=e.gridlayer,o=e.zerolinelayer,l=e["hidegrid"+v]?[]:V,u=c._gridpath||"M0,0"+("x"===v?"v":"h")+r._length,f=a.selectAll("path."+z).data(c.showgrid===!1?[]:l,S);if(f.enter().append("path").classed(z,1).classed("crisp",1).attr("d",u).each(function(t){c.zeroline&&("linear"===c.type||"-"===c.type)&&Math.abs(t.x)g;g++){var y=c.mirrors[o._id+h[g]];"ticks"!==y&&"labels"!==y||(f[g]=!0)}return void 0!==n[2]&&(f[2]=!0),f.forEach(function(t,e){var r=n[e],i=U[e];t&&x(r)&&(d+=p(r+R*i,i*c.ticklen))}),i(r,d),l(e,o,t),a(r,n[3])}}).filter(function(t){return t&&t.then});return H.length?Promise.all(H):0},E.swap=function(t,e){for(var r=p(t,e),n=0;n2*n}function u(t){for(var e,r=Math.max(1,(t.length-1)/1e3),n=0,i=0,a=0;a2*n}var f=t("fast-isnumeric"),h=t("tinycolor2").mix,d=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),b=t("./tick_label_defaults"),x=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),A=t("./axis_ids");e.exports=function(t,e,r,i){function a(r,n){return d.coerce2(t,e,v,r,n)}var o=i.letter,s=i.font||{},l="Click to enter "+(i.title||o.toUpperCase()+" axis")+" title";i.name&&(e._name=i.name,e._id=A.name2id(i.name));var c=r("type");"-"===c&&(n(e,i.data),"-"===e.type?e.type="linear":c=t.type=e.type),_(e);var u=r("color"),p=u===t.color?u:s.color;r("title",l),d.coerceFont(r,"titlefont",{family:s.family,size:Math.round(1.2*s.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),M=r("autorange",!k);M&&r("rangemode");var T=r("range",[-1,"x"===o?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),d.noneOrAll(t.range,e.range,[0,1]),r("fixedrange"),m(t,e,r,c),b(t,e,r,c,i),y(t,e,r,i),x(t,e,r);var E=a("linecolor",u),L=a("linewidth"),S=r("showline",!!E||!!L);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&r("mirror");var C=a("gridcolor",h(u,i.bgColor,g).toRgbString()),z=a("gridwidth"),P=r("showgrid",i.showGrid||!!C||!!z);P||(delete e.gridcolor,delete e.gridwidth);var R=a("zerolinecolor",u),O=a("zerolinewidth"),I=r("zeroline",i.showGrid||!!R||!!O);return I||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===c?w(o,e.categoryorder,e.categoryarray,i.data):[],e}},{"../../components/color/attributes":302,"../../lib":381,"../plots":452,"./axis_ids":405,"./category_order_defaults":406,"./clean_datum":407,"./layout_attributes":412,"./ordered_categories":414,"./set_convert":417,"./tick_label_defaults":418,"./tick_mark_defaults":419,"./tick_value_defaults":420,"fast-isnumeric":76,tinycolor2:233}],405:[function(t,e,r){"use strict";function n(t,e,r){function n(t,r){for(var n=Object.keys(t),i=/^[xyz]axis[0-9]*/,a=[],o=0;o0;a&&(n="array");var o=r("categoryorder",n);"array"===o&&r("categoryarray"),a||"array"!==o||(e.categoryorder="trace")}}},{}],407:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return i.ms2DateTime(t);if("string"!=typeof t&&!n(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){console.log(e,t)}return t}},{"../../lib":381,"fast-isnumeric":76}],408:[function(t,e,r){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5}},{}],409:[function(t,e,r){"use strict";function n(t,e){var r,n=t.range[e],i=Math.abs(n-t.range[1-e]);return"date"===t.type?c.ms2DateTime(n,i):"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,o.format("."+r+"g")(Math.pow(10,n))):(r=Math.floor(Math.log(Math.abs(n))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,o.format("."+String(r)+"g")(n))}function i(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function a(t){o.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var o=t("d3"),s=t("tinycolor2"),l=t("../../plotly"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../components/color"),h=t("../../components/drawing"),d=t("../../lib/setcursor"),p=t("../../components/dragelement"),g=t("./axes"),v=t("./select"),m=t("./constants"),y=!0;e.exports=function(t,e,r,o,b,x,_,w){function k(t,e){for(var r=0;r.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+ht+", "+dt+")").attr("d",ot+"Z"),ut=ft.append("path").attr("class","zoombox-corners").style({fill:f.background,stroke:f.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+ht+", "+dt+")").attr("d","M0,0Z"),T();for(var a=0;ai?(lt="",it.r=it.l,it.t=it.b,ut.attr("d","M0,0Z")):(it.t=0,it.b=V,lt="x",ut.attr("d","M"+(it.l-.5)+","+(nt-H-.5)+"h-3v"+(2*H+1)+"h3ZM"+(it.r+.5)+","+(nt-H-.5)+"h3v"+(2*H+1)+"h-3Z")):!Z||i.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),ut.transition().style("opacity",1).duration(200),st=!0)}function L(t,e,r){var n,i,a;for(n=0;nzoom back out","long"),y=!1)))}function C(e,r){var i=1===(_+w).length;if(e)I();else if(2!==r||i){if(1===r&&i){var a=_?B[0]:D[0],o="s"===_||"w"===w?0:1,s=a._name+".range["+o+"]",c=n(a,o),f="left",h="middle";if(a.fixedrange)return;_?(h="n"===_?"top":"bottom","right"===a.side&&(f="right")):"e"===w&&(f="right"),J.call(u.makeEditable,null,{immediate:!0,background:j.paper_bgcolor,text:String(c),fill:a.tickfont?a.tickfont.color:"#444",horizontalAlign:f,verticalAlign:h}).on("edit",function(e){var r="category"===a.type?a.c2l(e):a.d2l(e);void 0!==r&&l.relayout(t,s,r)})}}else O()}function z(e){function r(t,e,r){if(!t.fixedrange){A(t.range);var n=t.range,i=n[0]+(n[1]-n[0])*e;t.range=[i+(n[0]-i)*r,i+(n[1]-i)*r]}}if(t._context.scrollZoom||j._enablescrollzoom){var n=t.querySelector(".plotly");if(!(n.scrollHeight-n.clientHeight>10||n.scrollWidth-n.clientWidth>10)){clearTimeout(gt);var i=-e.deltaY;if(isFinite(i)||(i=e.wheelDelta/10),!isFinite(i))return void console.log("did not find wheel motion attributes",e);var a,o=Math.exp(-Math.min(Math.max(i,-20),20)/100),s=mt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-s.left)/s.width,u=pt[0]+pt[2]*l,f=(s.bottom-e.clientY)/s.height,h=pt[1]+pt[3]*(1-f);if(w){for(a=0;a=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function i(t,e,r){for(var i=1-e,a=0,o=0;o0;n--)r.push(e);return r}function i(t,e){for(var r=[],n=0;nj||j>D.width||0>F||F>D.height)return _.unhoverRaw(t,e)}else j="xpx"in e?e.xpx:p[0]._length/2,F="ypx"in e?e.ypx:v[0]._length/2;if(x="xval"in e?n(d,e.xval):i(p,j),A="yval"in e?n(d,e.yval):i(v,F),!g(x[0])||!g(A[0]))return console.log("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var B=1/0;for(T=0;T1||-1!==L.hoverinfo.indexOf("name")?L.name:void 0,index:!1,distance:Math.min(B,k.MAXDIST),color:b.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},O=I.length,"array"===C){var U=e[T];"pointNumber"in U?(R.index=U.pointNumber,C="closest"):(C="","xval"in U&&(z=U.xval,C="x"),"yval"in U&&(P=U.yval,C=C?"closest":"y"))}else z=x[S],P=A[S];if(L._module&&L._module.hoverPoints){var V=L._module.hoverPoints(R,z,P,C);if(V)for(var q,H=0;HO&&(I.splice(0,O),B=I[0].distance)}if(0===I.length)return _.unhoverRaw(t,e);var G="y"===y&&N.length>1;I.sort(function(t,e){return t.distance-e.distance});var Y=b.combine(a.plot_bgcolor||b.background,a.paper_bgcolor),X={hovermode:y,rotateLabels:G,bgColor:Y,container:a._hoverlayer,outerContainer:a._paperdiv},W=c(I,X);u(I,G?"xa":"ya"),f(W,G);var Z=t._hoverdata,K=[];for(M=0;M128?"#000":b.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,r=u.textContent||"",r.length>15&&(r=r.substr(0,12)+"...")}void 0!==t.extraText&&(n+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(n+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(n+="y: "+t.yLabel+"
"),n+=(n?"z: ":"")+t.zLabel):M&&t[i+"Label"]===g?n=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(n=t.yLabel):n=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(n+=(n?"
":"")+t.text),""===n&&(""===r&&e.remove(),n=r);var f=e.select("text.nums").style("fill",c).call(x.setPosition,0,0).text(n).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(x.setPosition,0,0);var h=e.select("text.name"),v=0;r&&r!==n?(h.style("fill",l).text(r).call(x.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),h.selectAll("tspan.line").call(x.setPosition,0,0),v=h.node().getBoundingClientRect().width+2*P):(h.remove(),e.select("rect").remove()),e.select("path").style({fill:l,stroke:c});var m,k,E=f.node().getBoundingClientRect(),L=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),R=Math.abs(t.y1-t.y0),O=E.width+z+P+v;t.ty0=_-E.top,t.bx=E.width+2*P,t.by=E.height+2*P,t.anchor="start",t.txwidth=E.width,t.tx2width=v,t.offset=0,a?(t.pos=L,m=A>=S+R/2+O,k=S-R/2-O>=0,"top"!==t.idealAlign&&m||!k?m?(S+=R/2,t.anchor="start"):t.anchor="middle":(S-=R/2,t.anchor="end")):(t.pos=S,m=w>=L+C/2+O,k=L-C/2-O>=0,"left"!==t.idealAlign&&m||!k?m?(L+=C/2,t.anchor="start"):t.anchor="middle":(L-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&h.attr("text-anchor",t.anchor),e.attr("transform","translate("+L+","+S+")"+(a?"rotate("+T+")":""))}),S}function u(t,e){function r(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(.01>a)){if(-.01>i){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos>e.pmax-1&&(l.del=!0,c--);for(o=0;o=c);o++)if(l=t[o],l.pos=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos+l.dp+l.size>e.pmax&&(l.del=!0,c--)}}}for(var n,i,a,o,s,l,c,u=0,f=t.map(function(t,r){var n=t[e];return[{i:r,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===n._id.charAt(0)?L:1)/2,pmin:n._offset,pmax:n._offset+n._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(s=d.length-1;s>=0;s--)d[s].dp+=i;for(h.push.apply(h,d),f.splice(o+1,1),c=0,s=h.length-1;s>=0;s--)c+=h[s].dp;for(a=c/h.length,s=h.length-1;s>=0;s--)h[s].dp-=a;n=!1}else o++}f.forEach(r)}for(o=f.length-1;o>=0;o--){var v=f[o];for(s=v.length-1;s>=0;s--){var m=v[s],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var r=d.select(this);if(t.del)return void r.remove();var n="end"===t.anchor?-1:1,i=r.select("text.nums"),a={start:1,end:-1,middle:0}[t.anchor],o=a*(z+P),s=o+a*(t.txwidth+P),l=0,c=t.offset;"middle"===t.anchor&&(o-=t.tx2width/2,s-=t.tx2width/2),e&&(c*=-C,l=t.offset*S),r.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(n*z+l)+","+(z+c)+"v"+(t.by/2-z)+"h"+n*t.bx+"v-"+t.by+"H"+(n*z+l)+"V"+(c-z)+"Z"),i.call(x.setPosition,o+l,c+t.ty0-t.by/2+P).selectAll("tspan.line").attr({x:i.attr("x"),y:i.attr("y")}),t.tx2width&&(r.select("text.name, text.name tspan.line").call(x.setPosition,s+a*P+l,c+t.ty0-t.by/2+P),r.select("rect").call(x.setRect,s+(a-1)*t.tx2width/2+l,c-t.by/2-1,t.tx2width,t.by+2))})}function h(t,e,r){if(!e.target)return!1;if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}var d=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),b=t("../../components/color"),x=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),A=t("./dragbox"),M=e.exports={};M.unhover=_.unhover,M.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},M.supplyLayoutDefaults=function(t,e,r){function n(r,n){return v.coerce(t,e,M.layoutAttributes,r,n)}n("dragmode");var i;if(e._has("cartesian")){var a=e._isHoriz=M.isHoriz(r);i=a?"y":"x"}else i="closest";n("hovermode",i)},M.isHoriz=function(t){for(var e=!0,r=0;rt._lastHoverTime+k.HOVERMINTIME?(o(t,e,r),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){o(t,e,r),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},M.getDistanceFunction=function(t,e,r,n){return"closest"===t?n||a(e,r):"x"===t?e:r},M.getClosest=function(t,e,r){if(r.index!==!1)r.index>=0&&r.indext*e||0===t?k.MAXDIST*(.6-.3/Math.max(3,Math.abs(t-e))):1/0}},{"../../components/color":303,"../../components/dragelement":323,"../../components/drawing":325,"../../lib":381,"../../lib/events":375,"../../lib/svg_text_utils":393,"./axes":403,"./constants":408,"./dragbox":409,d3:72,"fast-isnumeric":76,tinycolor2:233}],411:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../plots"),a=t("./constants");r.name="cartesian",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex=a.idRegex,r.attrRegex=a.attrRegex,r.attributes=t("./attributes"),r.plot=function(t){function e(t,e){for(var r=[],n=0;nf[1]-.01&&(e.domain=[0,1]),i.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":381,"fast-isnumeric":76}],416:[function(t,e,r){"use strict";function n(t){return t._id}var i=t("../../lib/polygon"),a=t("../../components/color"),o=t("./axes"),s=t("./constants"),l=i.filter,c=i.tester,u=s.MINSELECT;e.exports=function(t,e,r,i,f){function h(t){var e="y"===t._id.charAt(0)?1:0;return function(r){return t.p2d(r[e])}}function d(t,e){return t-e}var p,g=i.gd._fullLayout._zoomlayer,v=i.element.getBoundingClientRect(),m=i.plotinfo.x()._offset,y=i.plotinfo.y()._offset,b=e-v.left,x=r-v.top,_=b,w=x,k="M"+b+","+x,A=i.xaxes[0]._length,M=i.yaxes[0]._length,T=i.xaxes.map(n),E=i.yaxes.map(n),L=i.xaxes.concat(i.yaxes);"lasso"===f&&(p=l([[b,x]],s.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",k+"Z");var C,z,P,R,O,I=g.append("path").attr("class","zoombox-corners").style({fill:a.background,stroke:a.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),N=[],j=i.gd,F=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(0>=e&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-3*u*Math.abs(n-i))}return o.BADNUM}function r(t){return Math.pow(10,t); +}function c(t){return i(t)?Number(t):o.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?r:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,r=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var n=l.getFromId(t._gd,t.overlaying);t.domain=n.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;2>e;e++)i(t.range[e])||(t.range[e]=i(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=r.t+(1-t.domain[1])*r.h,t._length=r.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=r.l+t.domain[0]*r.w,t._length=r.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw a.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return i(e)?n.round(t._b+t._m*e,2):o.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,r){return t.l2p(t.c2l(e,r))},t.p2c=function(e){return t.l2c(t.p2l(e))},-1!==["linear","log","-"].indexOf(t.type))t.c2d=c,t.d2c=function(t){return t=s(t),i(t)?Number(t):o.BADNUM},t.d2l=function(e,r){return"log"===t.type?t.c2l(t.d2c(e),r):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return i(t)?a.ms2DateTime(t):o.BADNUM},t.d2c=function(t){return i(t)?Number(t):a.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(a.dateTime2ms);!i(t.range[0])&&i(f[0])&&(t.range[0]=f[0]),!i(t.range[1])&&i(f[1])&&(t.range[1]=f[1])}catch(h){console.log(h,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&-1===t._categories.indexOf(e)&&t._categories.push(e);var r=t._categories.indexOf(e);return-1===r?o.BADNUM:r},t.d2l=t.d2c);t.makeCalcdata=function(e,r){var n,i,a;if(r in e)for(n=e[r],i=new Array(n.length),a=0;an?"0":"1.0"}var r=this.framework,n=r.select("g.choroplethlayer"),i=r.select("g.scattergeolayer"),a=this.projection,o=this.path,s=this.clipAngle;r.selectAll("path.basepath").attr("d",o),r.selectAll("path.graticulepath").attr("d",o),n.selectAll("path.choroplethlocation").attr("d",o),n.selectAll("path.basepath").attr("d",o),i.selectAll("path.js-line").attr("d",o),null!==s?(i.selectAll("path.point").style("opacity",e).attr("transform",t),i.selectAll("text").style("opacity",e).attr("transform",t)):(i.selectAll("path.point").attr("transform",t),i.selectAll("text").attr("transform",t))}},{"../../components/color":303,"../../components/drawing":325,"../../constants/xmlns_namespaces":369,"../../lib/filter_visible":377,"../../lib/topojson_utils":394,"../../plots/cartesian/axes":403,"./constants":422,"./projections":430,"./set_scale":431,"./zoom":432,"./zoom_reset":433,d3:72,topojson:234}],424:[function(t,e,r){"use strict";var n=t("./geo"),i=t("../../plots/plots");r.name="geo",r.attr="geo",r.idRoot="geo",r.idRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"geo");void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var o=0;o=n}function a(t,e){for(var r=e[0],n=e[1],i=!1,a=0,o=t.length,s=o-1;o>a;s=a++){var l=t[a],c=l[0],u=l[1],f=t[s],h=f[0],d=f[1];u>n^d>n&&(h-c)*(n-u)/(d-u)+c>r&&(i=!i)}return i}function o(t){return t?t/Math.sin(t):1}function s(t){return t>1?P:-1>t?-P:Math.asin(t)}function l(t){return t>1?0:-1>t?z:Math.acos(t)}function c(t,e){var r=(2+P)*Math.sin(e);e/=2;for(var n=0,i=1/0;10>n&&Math.abs(i)>S;n++){var a=Math.cos(e);e-=i=(e+Math.sin(e)*(a+2)-r)/(2*a*(1+a))}return[2/Math.sqrt(z*(4+z))*t*(1+Math.cos(e)),2*Math.sqrt(z/(4+z))*Math.sin(e)]}function u(t,e){function r(r,n){var i=j(r/e,n);return i[0]*=t,i}return arguments.length<2&&(e=t),1===e?j:e===1/0?h:(r.invert=function(r,n){var i=j.invert(r/t,n);return i[0]*=e,i},r)}function f(){var t=2,e=N(u),r=e(t);return r.coefficient=function(r){return arguments.length?e(t=+r):t},r}function h(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function d(t,e){return[3*t/(2*z)*Math.sqrt(z*z/3-e*e),e]}function p(t,e){return[t,1.25*Math.log(Math.tan(z/4+.4*e))]}function g(t){return function(e){var r,n=t*Math.sin(e),i=30;do e-=r=(e+Math.sin(e)-n)/(1+Math.cos(e));while(Math.abs(r)>S&&--i>0);return e/2}}function v(t,e,r){function n(r,n){return[t*r*Math.cos(n=i(n)),e*Math.sin(n)]}var i=g(r);return n.invert=function(n,i){var a=s(i/e);return[n/(t*Math.cos(a)),s((2*a+Math.sin(2*a))/r)]},n}function m(t,e){var r=e*e,n=r*r;return[t*(.8707-.131979*r+n*(-.013791+n*(.003971*r-.001529*n))),e*(1.007226+r*(.015085+n*(-.044475+.028874*r-.005916*n)))]}function y(t,e){var r,n=Math.min(18,36*Math.abs(e)/z),i=Math.floor(n),a=n-i,o=(r=D[i])[0],s=r[1],l=(r=D[++i])[0],c=r[1],u=(r=D[Math.min(19,++i)])[0],f=r[1];return[t*(l+a*(u-o)/2+a*a*(u-2*l+o)/2),(e>0?P:-P)*(c+a*(f-s)/2+a*a*(f-2*c+s)/2)]}function b(t,e){return[t*Math.cos(e),e]}function x(t,e){var r=Math.cos(e),n=o(l(r*Math.cos(t/=2)));return[2*r*Math.sin(t)*n,Math.sin(e)*n]}function _(t,e){var r=x(t,e);return[(r[0]+t/P)/2,(r[1]+e)/2]}t.geo.project=function(t,e){var n=e.stream;if(!n)throw new Error("not yet supported");return(t&&w.hasOwnProperty(t.type)?w[t.type]:r)(t,n)};var w={Feature:e,FeatureCollection:function(t,r){return{type:"FeatureCollection",features:t.features.map(function(t){return e(t,r)})}}},k=[],A=[],M={point:function(t,e){k.push([t,e])},result:function(){var t=k.length?k.length<2?{type:"Point",coordinates:k[0]}:{type:"MultiPoint",coordinates:k}:null;return k=[],t}},T={lineStart:n,point:function(t,e){k.push([t,e])},lineEnd:function(){k.length&&(A.push(k),k=[])},result:function(){var t=A.length?A.length<2?{type:"LineString",coordinates:A[0]}:{type:"MultiLineString",coordinates:A}:null;return A=[],t}},E={polygonStart:n,lineStart:n,point:function(t,e){k.push([t,e])},lineEnd:function(){var t=k.length;if(t){do k.push(k[0].slice());while(++t<4);A.push(k),k=[]}},polygonEnd:n,result:function(){if(!A.length)return null;var t=[],e=[];return A.forEach(function(r){i(r)?t.push([r]):e.push(r)}),e.forEach(function(e){var r=e[0];t.some(function(t){return a(t[0],r)?(t.push(e),!0):void 0})||t.push([e])}),A=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},L={Point:M,MultiPoint:M,LineString:T,MultiLineString:T,Polygon:E,MultiPolygon:E,Sphere:E},S=1e-6,C=S*S,z=Math.PI,P=z/2,R=(Math.sqrt(z),z/180),O=180/z,I=t.geo.projection,N=t.geo.projectionMutator;t.geo.interrupt=function(e){function r(t,r){for(var n=0>r?-1:1,i=l[+(0>r)],a=0,o=i.length-1;o>a&&t>i[a][2][0];++a);var s=e(t-i[a][1][0],r);return s[0]+=e(i[a][1][0],n*r>n*i[a][0][1]?i[a][0][1]:r)[0],s}function n(){s=l.map(function(t){return t.map(function(t){var r,n=e(t[0][0],t[0][1])[0],i=e(t[2][0],t[2][1])[0],a=e(t[1][0],t[0][1])[1],o=e(t[1][0],t[1][1])[1];return a>o&&(r=a,a=o,o=r),[[n,a],[i,o]]})})}function i(){for(var e=1e-6,r=[],n=0,i=l[0].length;i>n;++n){var o=l[0][n],s=180*o[0][0]/z,c=180*o[0][1]/z,u=180*o[1][1]/z,f=180*o[2][0]/z,h=180*o[2][1]/z;r.push(a([[s+e,c+e],[s+e,u-e],[f-e,u-e],[f-e,h+e]],30))}for(var n=l[1].length-1;n>=0;--n){var o=l[1][n],s=180*o[0][0]/z,c=180*o[0][1]/z,u=180*o[1][1]/z,f=180*o[2][0]/z,h=180*o[2][1]/z;r.push(a([[f-e,h-e],[f-e,u+e],[s+e,u+e],[s+e,c-e]],30))}return{type:"Polygon",coordinates:[t.merge(r)]}}function a(t,e){for(var r,n,i,a=-1,o=t.length,s=t[0],l=[];++ac;++c)l.push([s[0]+c*n,s[1]+c*i]);s=r}return l.push(r),l}function o(t,e){return Math.abs(t[0]-e[0])n)],a=l[+(0>n)],c=0,u=i.length;u>c;++c){var f=i[c];if(f[0][0]<=t&&tS&&--i>0);return[t/(.8707+(a=n*n)*(-.131979+a*(-.013791+a*a*a*(.003971-.001529*a)))),n]},(t.geo.naturalEarth=function(){return I(m)}).raw=m;var D=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];D.forEach(function(t){t[1]*=1.0144}),y.invert=function(t,e){var r=e/P,n=90*r,i=Math.min(18,Math.abs(n/5)),a=Math.max(0,Math.floor(i));do{var o=D[a][1],s=D[a+1][1],l=D[Math.min(19,a+2)][1],c=l-o,u=l-2*s+o,f=2*(Math.abs(r)-s)/c,h=u/c,d=f*(1-h*f*(1-2*h*f));if(d>=0||1===a){n=(e>=0?5:-5)*(d+i);var p,g=50;do i=Math.min(18,Math.abs(n)/5),a=Math.floor(i),d=i-a,o=D[a][1],s=D[a+1][1],l=D[Math.min(19,a+2)][1],n-=(p=(e>=0?P:-P)*(s+d*(l-o)/2+d*d*(l-2*s+o)/2)-e)*O;while(Math.abs(p)>C&&--g>0);break}}while(--a>=0);var v=D[a][0],m=D[a+1][0],y=D[Math.min(19,a+2)][0];return[t/(m+d*(y-v)/2+d*d*(y-2*m+v)/2),n*R]},(t.geo.robinson=function(){return I(y)}).raw=y,b.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return I(b)}).raw=b,x.invert=function(t,e){if(!(t*t+4*e*e>z*z+S)){var r=t,n=e,i=25;do{var a,o=Math.sin(r),s=Math.sin(r/2),c=Math.cos(r/2),u=Math.sin(n),f=Math.cos(n),h=Math.sin(2*n),d=u*u,p=f*f,g=s*s,v=1-p*c*c,m=v?l(f*c)*Math.sqrt(a=1/v):a=0,y=2*m*f*s-t,b=m*u-e,x=a*(p*g+m*f*c*d),_=a*(.5*o*h-2*m*u*s),w=.25*a*(h*s-m*u*p*o),k=a*(d*c+m*g*f),A=_*w-k*x;if(!A)break;var M=(b*_-y*k)/A,T=(y*w-b*x)/A;r-=M,n-=T}while((Math.abs(M)>S||Math.abs(T)>S)&&--i>0);return[r,n]}},(t.geo.aitoff=function(){return I(x)}).raw=x,_.invert=function(t,e){var r=t,n=e,i=25;do{var a,o=Math.cos(n),s=Math.sin(n),c=Math.sin(2*n),u=s*s,f=o*o,h=Math.sin(r),d=Math.cos(r/2),p=Math.sin(r/2),g=p*p,v=1-f*d*d,m=v?l(o*d)*Math.sqrt(a=1/v):a=0,y=.5*(2*m*o*p+r/P)-t,b=.5*(m*s+n)-e,x=.5*a*(f*g+m*o*d*u)+.5/P,_=a*(h*c/4-m*s*p),w=.125*a*(c*p-m*s*f*h),k=.5*a*(u*d+m*g*o)+.5,A=_*w-k*x,M=(b*_-y*k)/A,T=(y*w-b*x)/A;r-=M,n-=T}while((Math.abs(M)>S||Math.abs(T)>S)&&--i>0);return[r,n]},(t.geo.winkel3=function(){return I(_)}).raw=_}e.exports=n},{}],431:[function(t,e,r){"use strict";function n(t,e){var r=t.projection,n=t.lonaxis,o=t.lataxis,l=t.domain,c=t.framewidth||0,u=e.w*(l.x[1]-l.x[0]),f=e.h*(l.y[1]-l.y[0]),h=n.range[0]+s,d=n.range[1]-s,p=o.range[0]+s,g=o.range[1]-s,v=n._fullRange[0]+s,m=n._fullRange[1]-s,y=o._fullRange[0]+s,b=o._fullRange[1]-s;r._translate0=[e.l+u/2,e.t+f/2];var x=d-h,_=g-p,w=[h+x/2,p+_/2],k=r._rotate;r._center=[w[0]+k[0],w[1]+k[1]];var A=function(e){function n(t){return Math.min(_*u/(t[1][0]-t[0][0]),_*f/(t[1][1]-t[0][1]))}var o,s,l,x,_=e.scale(),w=r._translate0,k=i(h,p,d,g),A=i(v,y,m,b);l=a(e,k),o=n(l),x=a(e,A),r._fullScale=n(x),e.scale(o),l=a(e,k),s=[w[0]-l[0][0]+c,w[1]-l[0][1]+c],r._translate=s,e.translate(s),l=a(e,k),t._isAlbersUsa||e.clipExtent(l),o=r.scale*o,r._scale=o,t._width=Math.round(l[1][0])+c,t._height=Math.round(l[1][1])+c,t._marginX=(u-Math.round(l[1][0]))/2,t._marginY=(f-Math.round(l[1][1]))/2};return A}function i(t,e,r,n){var i=(r-t)/4;return{type:"Polygon",coordinates:[[[t,e],[t,n],[t+i,n],[t+2*i,n],[t+3*i,n],[r,n],[r,e],[r-i,e],[r-2*i,e],[r-3*i,e],[t,e]]]}}function a(t,e){return o.geo.path().projection(t).bounds(e)}var o=t("d3"),s=t("./constants/").clipPad;e.exports=n},{"./constants/":422,d3:72}],432:[function(t,e,r){"use strict";function n(t,e){var r;return(r=e._isScoped?a:e._clipAngle?s:o)(t,e.projection)}function i(t,e){var r=e._fullScale;return _.behavior.zoom().translate(t.translate()).scale(t.scale()).scaleExtent([.5*r,100*r])}function a(t,e){function r(){_.select(this).style(A)}function n(){o.scale(_.event.scale).translate(_.event.translate),t.render()}function a(){_.select(this).style(M)}var o=t.projection,s=i(o,e);return s.on("zoomstart",r).on("zoom",n).on("zoomend",a),s}function o(t,e){function r(t){return v.invert(t)}function n(t){var e=v(r(t));return Math.abs(e[0]-t[0])>y||Math.abs(e[1]-t[1])>y}function a(){_.select(this).style(A),l=_.mouse(this),c=v.rotate(),u=v.translate(),f=c,h=r(l)}function o(){return d=_.mouse(this),n(l)?(m.scale(v.scale()),void m.translate(v.translate())):(v.scale(_.event.scale),v.translate([u[0],_.event.translate[1]]),h?r(d)&&(g=r(d),p=[f[0]+(g[0]-h[0]),c[1],c[2]],v.rotate(p),f=p):(l=d,h=r(l)),void t.render())}function s(){_.select(this).style(M)}var l,c,u,f,h,d,p,g,v=t.projection,m=i(v,e),y=2;return m.on("zoomstart",a).on("zoom",o).on("zoomend",s),m}function s(t,e){function r(t){m++||t({type:"zoomstart"})}function n(t){t({type:"zoom"})}function a(t){--m||t({type:"zoomend"})}var o,s=t.projection,d={r:s.rotate(),k:s.scale()},p=i(s,e),g=x(p,"zoomstart","zoom","zoomend"),m=0,y=p.on;return p.on("zoomstart",function(){_.select(this).style(A);var t=_.mouse(this),e=s.rotate(),i=e,a=s.translate(),m=c(e);o=l(s,t),y.call(p,"zoom",function(){var r=_.mouse(this);if(s.scale(d.k=_.event.scale),o){if(l(s,r)){s.rotate(e).translate(a);var c=l(s,r),p=f(o,c),y=v(u(m,p)),b=d.r=h(y,o,i);isFinite(b[0])&&isFinite(b[1])&&isFinite(b[2])||(b=i),s.rotate(b),i=b}}else t=r,o=l(s,t);n(g.of(this,arguments))}),r(g.of(this,arguments))}).on("zoomend",function(){_.select(this).style(M),y.call(p,"zoom",null),a(g.of(this,arguments))}).on("zoom.redraw",function(){t.render()}),_.rebind(p,g,"on")}function l(t,e){var r=t.invert(e);return r&&isFinite(r[0])&&isFinite(r[1])&&m(r)}function c(t){var e=.5*t[0]*w,r=.5*t[1]*w,n=.5*t[2]*w,i=Math.sin(e),a=Math.cos(e),o=Math.sin(r),s=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return[a*s*c+i*o*l,i*s*c-a*o*l,a*o*c+i*s*l,a*s*l-i*o*c]}function u(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=e[0],s=e[1],l=e[2],c=e[3];return[r*o-n*s-i*l-a*c,r*s+n*o+i*c-a*l,r*l-n*c+i*o+a*s,r*c+n*l-i*s+a*o]}function f(t,e){if(t&&e){var r=b(t,e),n=Math.sqrt(y(r,r)),i=.5*Math.acos(Math.max(-1,Math.min(1,y(t,e)))),a=Math.sin(i)/n;return n&&[Math.cos(i),r[2]*a,-r[1]*a,r[0]*a]}}function h(t,e,r){var n=g(e,2,t[0]);n=g(n,1,t[1]),n=g(n,0,t[2]-r[2]);var i,a,o=e[0],s=e[1],l=e[2],c=n[0],u=n[1],f=n[2],h=Math.atan2(s,o)*k,p=Math.sqrt(o*o+s*s);Math.abs(u)>p?(a=(u>0?90:-90)-h,i=0):(a=Math.asin(u/p)*k-h,i=Math.sqrt(p*p-u*u));var v=180-a-2*h,m=(Math.atan2(f,c)-Math.atan2(l,i))*k,y=(Math.atan2(f,c)-Math.atan2(l,-i))*k,b=d(r[0],r[1],a,m),x=d(r[0],r[1],v,y);return x>=b?[a,m,r[2]]:[v,y,r[2]]}function d(t,e,r,n){var i=p(r-t),a=p(n-e);return Math.sqrt(i*i+a*a)}function p(t){return(t%360+540)%360-180}function g(t,e,r){var n=r*w,i=t.slice(),a=0===e?1:0,o=2===e?1:2,s=Math.cos(n),l=Math.sin(n);return i[a]=t[a]*s-t[o]*l,i[o]=t[o]*s+t[a]*l,i}function v(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*k,Math.asin(Math.max(-1,Math.min(1,2*(t[0]*t[2]-t[3]*t[1]))))*k,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*k]}function m(t){var e=t[0]*w,r=t[1]*w,n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function y(t,e){for(var r=0,n=0,i=t.length;i>n;++n)r+=t[n]*e[n];return r}function b(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]; +}function x(t){for(var e=0,r=arguments.length,n=[];++ed;++d){for(e=c[d],r=t[this.scene[e]._name],n=/Click to enter .+ title/.test(r.title)?"":r.title,p=0;2>=p;p+=2)this.labelEnable[d+p]=!1,this.labels[d+p]=o(n),this.labelColor[d+p]=s(r.titlefont.color),this.labelFont[d+p]=r.titlefont.family,this.labelSize[d+p]=r.titlefont.size,this.labelPad[d+p]=this.getLabelPad(e,r),this.tickEnable[d+p]=!1,this.tickColor[d+p]=s((r.tickfont||{}).color),this.tickAngle[d+p]="auto"===r.tickangle?0:Math.PI*-r.tickangle/180,this.tickPad[d+p]=this.getTickPad(r),this.tickMarkLength[d+p]=0,this.tickMarkWidth[d+p]=r.tickwidth||0,this.tickMarkColor[d+p]=s(r.tickcolor),this.borderLineEnable[d+p]=!1,this.borderLineColor[d+p]=s(r.linecolor),this.borderLineWidth[d+p]=r.linewidth||0;u=this.hasSharedAxis(r),a=this.hasAxisInDfltPos(e,r)&&!u,l=this.hasAxisInAltrPos(e,r)&&!u,i=r.mirror||!1,f=u?-1!==String(i).indexOf("all"):!!i,h=u?"allticks"===i:-1!==String(i).indexOf("ticks"),a?this.labelEnable[d]=!0:l&&(this.labelEnable[d+2]=!0),a?this.tickEnable[d]=r.showticklabels:l&&(this.tickEnable[d+2]=r.showticklabels),(a||f)&&(this.borderLineEnable[d]=r.showline),(l||f)&&(this.borderLineEnable[d+2]=r.showline),(a||h)&&(this.tickMarkLength[d]=this.getTickMarkLength(r)),(l||h)&&(this.tickMarkLength[d+2]=this.getTickMarkLength(r)),this.gridLineEnable[d]=r.showgrid,this.gridLineColor[d]=s(r.gridcolor),this.gridLineWidth[d]=r.gridwidth,this.zeroLineEnable[d]=r.zeroline,this.zeroLineColor[d]=s(r.zerolinecolor),this.zeroLineWidth[d]=r.zerolinewidth}},l.hasSharedAxis=function(t){var e=this.scene,r=a.Plots.getSubplotIds(e.fullLayout,"gl2d"),n=a.Axes.findSubplotsWithAxis(r,t);return 0!==n.indexOf(e.id)},l.hasAxisInDfltPos=function(t,e){var r=e.side;return"xaxis"===t?"bottom"===r:"yaxis"===t?"left"===r:void 0},l.hasAxisInAltrPos=function(t,e){var r=e.side;return"xaxis"===t?"top"===r:"yaxis"===t?"right"===r:void 0},l.getLabelPad=function(t,e){var r=1.5,n=e.titlefont.size,i=e.showticklabels;return"xaxis"===t?"top"===e.side?-10+n*(r+(i?1:0)):-10+n*(r+(i?.5:0)):"yaxis"===t?"right"===e.side?10+n*(r+(i?1:.5)):10+n*(r+(i?.5:0)):void 0},l.getTickPad=function(t){return"outside"===t.ticks?10+t.ticklen:15},l.getTickMarkLength=function(t){if(!t.ticks)return 0;var e=t.ticklen;return"inside"===t.ticks?-e:e},e.exports=i},{"../../lib/html2unicode":380,"../../lib/str2rgbarray":392,"../../plotly":400}],436:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("./scene2d"),a=n.Plots;r.name="gl2d",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex={x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},r.attrRegex={x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},r.attributes=t("../cartesian/attributes"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,n=a.getSubplotIds(e,"gl2d"),o=0;or;++r){var n=t[r],i=e[r];if(n.length!==i.length)return!0;for(var a=0;ao;++o,--s)for(var l=0;r>l;++l)for(var c=0;4>c;++c){var u=i[4*(r*o+l)+c];i[4*(r*o+l)+c]=i[4*(r*s+l)+c],i[4*(r*s+l)+c]=u}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticPlot&&this.container.removeChild(a),p},m.computeTickMarks=function(){this.xaxis._length=this.glplot.viewBox[2]-this.glplot.viewBox[0],this.yaxis._length=this.glplot.viewBox[3]-this.glplot.viewBox[1];for(var t=[s.calcTicks(this.xaxis),s.calcTicks(this.yaxis)],e=0;2>e;++e)for(var r=0;rk;++k)w[k]=Math.min(w[k],a.bounds[k]),w[k+2]=Math.max(w[k+2],a.bounds[k+2])}var A;for(n=0;2>n;++n)w[n]>w[n+2]&&(w[n]=-1,w[n+2]=1),A=this[v[n]],A._length=y.viewBox[n+2]-y.viewBox[n],s.doAutoRange(A);y.ticks=this.computeTickMarks();var M=this.xaxis.range,T=this.yaxis.range;y.dataBox=[M[0],T[0],M[1],T[1]],y.merge(r),o.update(y),this.glplot.draw()},m.draw=function(){if(!this.stopped){requestAnimationFrame(this.redraw);var t=this.glplot,e=this.camera,r=e.mouseListener,n=this.fullLayout;this.cameraChanged();var i=r.x*t.pixelRatio,a=this.canvas.height-t.pixelRatio*r.y;if(e.boxEnabled&&"zoom"===n.dragmode)this.selectBox.enabled=!0,this.selectBox.selectBox=[Math.min(e.boxStart[0],e.boxEnd[0]),Math.min(e.boxStart[1],e.boxEnd[1]),Math.max(e.boxStart[0],e.boxEnd[0]),Math.max(e.boxStart[1],e.boxEnd[1])],t.setDirty();else{this.selectBox.enabled=!1;var o=n._size,s=this.xaxis.domain,c=this.yaxis.domain,u=t.pick(i/t.pixelRatio+o.l+s[0]*o.w,a/t.pixelRatio-(o.t+(1-c[1])*o.h));if(u&&n.hovermode){var f=u.object._trace.handlePick(u);if(f&&(!this.lastPickResult||this.lastPickResult.trace!==f.trace||this.lastPickResult.dataCoord[0]!==f.dataCoord[0]||this.lastPickResult.dataCoord[1]!==f.dataCoord[1])){var h=this.lastPickResult=f;this.spikes.update({center:u.dataCoord}),h.screenCoord=[((t.viewBox[2]-t.viewBox[0])*(u.dataCoord[0]-t.dataBox[0])/(t.dataBox[2]-t.dataBox[0])+t.viewBox[0])/t.pixelRatio,(this.canvas.height-(t.viewBox[3]-t.viewBox[1])*(u.dataCoord[1]-t.dataBox[1])/(t.dataBox[3]-t.dataBox[1])-t.viewBox[1])/t.pixelRatio];var d=h.hoverinfo;if("all"!==d){var p=d.split("+");-1===p.indexOf("x")&&(h.traceCoord[0]=void 0),-1===p.indexOf("y")&&(h.traceCoord[1]=void 0),-1===p.indexOf("z")&&(h.traceCoord[2]=void 0),-1===p.indexOf("text")&&(h.textLabel=void 0),-1===p.indexOf("name")&&(h.name=void 0)}l.loneHover({x:h.screenCoord[0],y:h.screenCoord[1],xLabel:this.hoverFormatter("xaxis",h.traceCoord[0]),yLabel:this.hoverFormatter("yaxis",h.traceCoord[1]),zLabel:h.traceCoord[2],text:h.textLabel,name:h.name,color:h.color},{container:this.svgContainer}),this.lastPickResult={dataCoord:u.dataCoord}}}else!u&&this.lastPickResult&&(this.spikes.update({}),this.lastPickResult=null,l.loneUnhover(this.svgContainer))}t.draw()}},m.hoverFormatter=function(t,e){if(void 0!==e){var r=this[t];return s.tickText(r,r.c2l(e),"hover").text}}},{"../../lib/html2unicode":380,"../../lib/show_no_webgl_msg":390,"../../plots/cartesian/axes":403,"../../plots/cartesian/graph_interact":410,"./camera":434,"./convert":435,"gl-plot2d":124,"gl-select-box":154,"gl-spikes2d":174}],438:[function(t,e,r){"use strict";function n(t,e){t=t||document.body,e=e||{};var r=[.01,1/0];"distanceLimits"in e&&(r[0]=e.distanceLimits[0],r[1]=e.distanceLimits[1]),"zoomMin"in e&&(r[0]=e.zoomMin),"zoomMax"in e&&(r[1]=e.zoomMax);var n=a({center:e.center||[0,0,0],up:e.up||[0,1,0],eye:e.eye||[0,0,10],mode:e.mode||"orbit",distanceLimits:r}),l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0,u=t.clientWidth,f=t.clientHeight,h={keyBindingMode:"rotate",view:n,element:t,delay:e.delay||16,rotateSpeed:e.rotateSpeed||1,zoomSpeed:e.zoomSpeed||1,translateSpeed:e.translateSpeed||1,flipX:!!e.flipX,flipY:!!e.flipY,modes:n.modes,tick:function(){var e=i(),r=this.delay,a=e-2*r;n.idle(e-r),n.recalcMatrix(a),n.flush(e-(100+2*r));for(var o=!0,s=n.computedMatrix,h=0;16>h;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){var e=n.computedUp.slice(),r=n.computedEye.slice(),a=n.computedCenter.slice();if(n.setMode(t),"turntable"===t){var o=i();n._active.lookAt(o,r,a,e),n._active.lookAt(o+500,r,a,[0,0,1]),n._active.flush(o)}return n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s="rotate"===h.keyBindingMode,l="pan"===h.keyBindingMode,u="zoom"===h.keyBindingMode,f=!!o.control,g=!!o.alt,v=!!o.shift,m=!!(1&e),y=!!(2&e),b=!!(4&e),x=1/t.clientHeight,_=x*(r-d),w=x*(a-p),k=h.flipX?1:-1,A=h.flipY?1:-1,M=i(),T=Math.PI*h.rotateSpeed;if((s&&m&&!f&&!g&&!v||m&&!f&&!g&&v)&&n.rotate(M,k*T*_,-A*T*w,0),(l&&m&&!f&&!g&&!v||y||m&&f&&!g&&!v)&&n.pan(M,-h.translateSpeed*_*c,h.translateSpeed*w*c,0),u&&m&&!f&&!g&&!v||b||m&&!f&&g&&!v){var E=-h.zoomSpeed*w/window.innerHeight*(M-n.lastT())*100;n.pan(M,0,0,c*(Math.exp(E)-1))}return d=r,p=a,!0}),s(t,function(t,e){var r=h.flipX?1:-1,a=h.flipY?1:-1,o=i();if(Math.abs(t)>Math.abs(e))n.rotate(o,0,0,-t*r*Math.PI*h.rotateSpeed/window.innerWidth);else{var s=-h.zoomSpeed*a*e/window.innerHeight*(o-n.lastT())/100;n.pan(o,0,0,c*(Math.exp(s)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":39,"mouse-change":200,"mouse-wheel":204,"right-now":214}],439:[function(t,e,r){"use strict";function n(t,e){for(var r=0;3>r;++r){var n=o[r];e[n]._gd=t}}var i=t("./scene"),a=t("../plots"),o=["xaxis","yaxis","zaxis"];r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,o=a.getSubplotIds(e,"gl3d");e._paperdiv.style({width:e.width+"px",height:e.height+"px"}),t._context.setBackground(t,e.paper_bgcolor);for(var s=0;sr;++r){var n=t[c[r]];e.labels[r]=o(n.title),"titlefont"in n&&(n.titlefont.color&&(e.labelColor[r]=s(n.titlefont.color)),n.titlefont.family&&(e.labelFont[r]=n.titlefont.family),n.titlefont.size&&(e.labelSize[r]=n.titlefont.size)),"showline"in n&&(e.lineEnable[r]=n.showline),"linecolor"in n&&(e.lineColor[r]=s(n.linecolor)),"linewidth"in n&&(e.lineWidth[r]=n.linewidth),"showgrid"in n&&(e.gridEnable[r]=n.showgrid),"gridcolor"in n&&(e.gridColor[r]=s(n.gridcolor)),"gridwidth"in n&&(e.gridWidth[r]=n.gridwidth),"log"===n.type?e.zeroEnable[r]=!1:"zeroline"in n&&(e.zeroEnable[r]=n.zeroline),"zerolinecolor"in n&&(e.zeroLineColor[r]=s(n.zerolinecolor)),"zerolinewidth"in n&&(e.zeroLineWidth[r]=n.zerolinewidth),"ticks"in n&&n.ticks?e.lineTickEnable[r]=!0:e.lineTickEnable[r]=!1,"ticklen"in n&&(e.lineTickLength[r]=e._defaultLineTickLength[r]=n.ticklen),"tickcolor"in n&&(e.lineTickColor[r]=s(n.tickcolor)),"tickwidth"in n&&(e.lineTickWidth[r]=n.tickwidth),"tickangle"in n&&(e.tickAngle[r]="auto"===n.tickangle?0:Math.PI*-n.tickangle/180),"showticklabels"in n&&(e.tickEnable[r]=n.showticklabels),"tickfont"in n&&(n.tickfont.color&&(e.tickColor[r]=s(n.tickfont.color)),n.tickfont.family&&(e.tickFont[r]=n.tickfont.family),n.tickfont.size&&(e.tickSize[r]=n.tickfont.size)),"mirror"in n?-1!==["ticks","all","allticks"].indexOf(n.mirror)?(e.lineTickMirror[r]=!0,e.lineMirror[r]=!0):n.mirror===!0?(e.lineTickMirror[r]=!1,e.lineMirror[r]=!0):(e.lineTickMirror[r]=!1,e.lineMirror[r]=!1):e.lineMirror[r]=!1,"showbackground"in n&&n.showbackground!==!1?(e.backgroundEnable[r]=!0,e.backgroundColor[r]=s(n.backgroundcolor)):e.backgroundEnable[r]=!1}},e.exports=i},{"../../../lib/html2unicode":380,"../../../lib/str2rgbarray":392,arraytools:49}],444:[function(t,e,r){"use strict";function n(t,e,r,n){for(var a=r("bgcolor"),l=i.combine(a,n.paper_bgcolor),c=Object.keys(o.camera),u=0;ue;++e){var r=t[o[e]];this.enabled[e]=r.showspikes,this.colors[e]=a(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness}},e.exports=i},{"../../../lib/str2rgbarray":392}],447:[function(t,e,r){"use strict";function n(t){for(var e=new Array(3),r=0;3>r;++r){for(var n=t[r],i=new Array(n.length),a=0;au;++u){var f=i[s[u]];if(f._length=(r[u].hi-r[u].lo)*r[u].pixelsPerDataUnit/t.dataScale[u],Math.abs(f._length)===1/0)c[u]=[];else{f.range[0]=r[u].lo/t.dataScale[u],f.range[1]=r[u].hi/t.dataScale[u],f._m=1/(t.dataScale[u]*r[u].pixelsPerDataUnit),f.range[0]===f.range[1]&&(f.range[0]-=1,f.range[1]+=1);var h=f.tickmode;if("auto"===f.tickmode){f.tickmode="linear";var d=f.nticks||a.Lib.constrain(f._length/40,4,9);a.Axes.autoTicks(f,Math.abs(f.range[1]-f.range[0])/d)}for(var p=a.Axes.calcTicks(f),g=0;gu;++u){l[u]=.5*(t.glplot.bounds[0][u]+t.glplot.bounds[1][u]);for(var g=0;2>g;++g)e.bounds[g][u]=t.glplot.bounds[g][u]}t.contourLevels=n(c)}e.exports=i;var a=t("../../../plotly"),o=t("../../../lib/html2unicode"),s=["xaxis","yaxis","zaxis"],l=[0,0,0]},{"../../../lib/html2unicode":380,"../../../plotly":400}],448:[function(t,e,r){"use strict";function n(t,e){var r,n,i=[0,0,0,0];for(r=0;4>r;++r)for(n=0;4>n;++n)i[n]+=t[4*r+n]*e[r];return i}function i(t,e){var r=n(t.projection,n(t.view,n(t.model,[e[0],e[1],e[2],1])));return r}e.exports=i},{}],449:[function(t,e,r){"use strict";function n(t){function e(e,r){if("string"==typeof r)return r;var n=t.fullSceneLayout[e];return g.tickText(n,n.c2l(r),"hover").text}var r,n=t.svgContainer,i=t.container.getBoundingClientRect(),a=i.width,o=i.height;n.setAttributeNS(null,"viewBox","0 0 "+a+" "+o),n.setAttributeNS(null,"width",a),n.setAttributeNS(null,"height",o),A(t),t.glplot.axes.update(t.axesOptions);for(var s=Object.keys(t.traces),l=null,c=t.glplot.selection,u=0;ua;++a)l=u[T[a]],_(l);t?Array.isArray(t)||(t=[t]):t=[];var h=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]];for(a=0;ao;++o)h[0][o]>h[1][o]?d[o]=1:h[1][o]===h[0][o]?d[o]=1:d[o]=1/(h[1][o]-h[0][o]);for(this.dataScale=d,a=0;aa;++a){if(l=u[T[a]],c=l.type,c in x?(x[c].acc*=d[a],x[c].count+=1):x[c]={acc:d[a],count:1},l.autorange){for(y[0][a]=1/0,y[1][a]=-(1/0),o=0;oy[1][a])y[0][a]=-1,y[1][a]=1;else{var k=y[1][a]-y[0][a];y[0][a]-=k/32,y[1][a]+=k/32}}else{var A=u[T[a]].range;y[0][a]=A[0],y[1][a]=A[1]}y[0][a]===y[1][a]&&(y[0][a]-=1,y[1][a]+=1),b[a]=y[1][a]-y[0][a],this.glplot.bounds[0][a]=y[0][a]*d[a],this.glplot.bounds[1][a]=y[1][a]*d[a]}var M=[1,1,1];for(a=0;3>a;++a){l=u[T[a]],c=l.type;var E=x[c];M[a]=Math.pow(E.acc,1/E.count)/d[a]}var L,S=4;if("auto"===u.aspectmode)L=Math.max.apply(null,M)/Math.min.apply(null,M)<=S?M:[1,1,1];else if("cube"===u.aspectmode)L=[1,1,1];else if("data"===u.aspectmode)L=M;else{if("manual"!==u.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var C=u.aspectratio;L=[C.x,C.y,C.z]}u.aspectratio.x=f.aspectratio.x=L[0],u.aspectratio.y=f.aspectratio.y=L[1],u.aspectratio.z=f.aspectratio.z=L[2],this.glplot.aspect=L;var z=u.domain||null,P=e._size||null;if(z&&P){var R=this.container.style;R.position="absolute",R.left=P.l+z.x[0]*P.w+"px",R.top=P.t+(1-z.y[1])*P.h+"px",R.width=P.w*(z.x[1]-z.x[0])+"px",R.height=P.h*(z.y[1]-z.y[0])+"px"}this.glplot.redraw()}},M.destroy=function(){this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null},M.setCameraToDefault=function(){this.setCamera({eye:{x:1.25,y:1.25,z:1.25},center:{x:0,y:0,z:0},up:{x:0,y:0,z:1}})},M.getCamera=function(){return this.glplot.camera.view.recalcMatrix(this.camera.view.lastT()),c(this.glplot.camera)},M.setCamera=function(t){var e={};e[this.id]=t,this.glplot.camera.lookAt.apply(this,l(t)),this.graphDiv.emit("plotly_relayout",e)},M.saveCamera=function(t){function e(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return e[i[r]]&&t[i[r]][a[n]]===e[i[r]][a[n]]}var r=this.getCamera(),n=d.nestedProperty(t,this.id+".camera"),i=n.get(),a=!1;if(void 0===i)a=!0;else for(var o=0;3>o;o++)for(var s=0;3>s;s++)if(!e(r,i,o,s)){a=!0;break}return a&&n.set(r),a},M.updateFx=function(t,e){var r=this.camera;r&&("orbit"===t?(r.mode="orbit",r.keyBindingMode="rotate"):"turntable"===t?(r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate"):r.keyBindingMode=t),this.fullSceneLayout.hovermode=e},M.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(u),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,n=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var i=new Uint8Array(r*n*4);e.readPixels(0,0,r,n,e.RGBA,e.UNSIGNED_BYTE,i);for(var a=0,o=n-1;o>a;++a,--o)for(var s=0;r>s;++s)for(var l=0;4>l;++l){var c=i[4*(r*a+s)+l];i[4*(r*a+s)+l]=i[4*(r*o+s)+l],i[4*(r*o+s)+l]=c}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticMode&&this.container.removeChild(u),p},e.exports=a},{"../../lib":381,"../../lib/show_no_webgl_msg":390,"../../lib/str2rgbarray":392,"../../plots/cartesian/axes":403,"../../plots/cartesian/graph_interact":410,"../../plots/plots":452,"./camera":438,"./layout/convert":443,"./layout/spikes":446,"./layout/tick_marks":447,"./project":448,"./set_convert":450,"gl-plot3d":142}],450:[function(t,e,r){"use strict";var n=t("../cartesian/axes"),i=function(){};e.exports=function(t){n.setConvert(t),t.setScale=i}},{"../cartesian/axes":403}],451:[function(t,e,r){"use strict";var n=t("../plotly"),i=t("./font_attributes"),a=t("../components/color/attributes"),o=n.Lib.extendFlat;e.exports={font:{family:o({},i.family,{dflt:'"Open Sans", verdana, arial, sans-serif'}),size:o({},i.size,{dflt:12}),color:o({},i.color,{dflt:a.defaultLine})},title:{valType:"string",dflt:"Click to enter Plot title"},titlefont:o({},i,{}),autosize:{valType:"enumerated",values:[!0,!1,"initial"]},width:{valType:"number",min:10,dflt:700},height:{valType:"number",min:10,dflt:450},margin:{l:{valType:"number",min:0,dflt:80},r:{valType:"number",min:0,dflt:80},t:{valType:"number",min:0,dflt:100},b:{valType:"number",min:0,dflt:80},pad:{valType:"number",min:0,dflt:0},autoexpand:{valType:"boolean",dflt:!0}},paper_bgcolor:{valType:"color",dflt:a.background},plot_bgcolor:{valType:"color",dflt:a.background},separators:{valType:"string",dflt:".,"},hidesources:{valType:"boolean",dflt:!1},smith:{valType:"enumerated",values:[!1],dflt:!1},showlegend:{valType:"boolean"},_composedModules:{"*":"Fx"},_nestedModules:{xaxis:"Axes",yaxis:"Axes",scene:"gl3d",geo:"geo",legend:"Legend",annotations:"Annotations",shapes:"Shapes",images:"Images",ternary:"ternary"}}},{"../components/color/attributes":302,"../plotly":400,"./font_attributes":421}],452:[function(t,e,r){"use strict";function n(t){return"object"==typeof t&&(t=t.type),t}function i(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#","class":"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){f.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}function a(t,e){for(var r,n=Object.keys(e),i=0;i=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var s=r.select(".js-link-to-tool"),l=r.select(".js-link-spacer"),c=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&i(t,s),l.text(s.text()&&c.text()?" - ":"")},f.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",r=o.select(t).append("div").attr("id","hiddenform").style("display","none"),n=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),i=n.append("input").attr({type:"text",name:"data"});return i.node().value=f.graphJson(t,!1,"keepdata"),n.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1},f.supplyDefaults=function(t){var e,r,n=t._fullLayout||{},i=t._fullLayout={},o=t.layout||{},s=t._fullData||[],u=t._fullData=[],h=t.data||[],d=i._modules=[],p=i._basePlotModules=[];for(f.supplyLayoutGlobalDefaults(o,i),i._dataLength=h.length,e=0;ea&&(e=(r-1)/(i.l+i.r),i.l=Math.floor(e*i.l),i.r=Math.floor(e*i.r)),0>o&&(e=(n-1)/(i.t+i.b),i.t=Math.floor(e*i.t),i.b=Math.floor(e*i.b))}},f.autoMargin=function(t,e,r){var n=t._fullLayout;if(n._pushmargin||(n._pushmargin={}),n.margin.autoexpand!==!1){if(r){var i=void 0===r.pad?12:r.pad;r.l+r.r>.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0),n._pushmargin[e]={l:{val:r.x,size:r.l+i},r:{val:r.x,size:r.r+i},b:{val:r.y,size:r.b+i},t:{val:r.y,size:r.t+i}}}else delete n._pushmargin[e];t._replotting||f.doAutoMargin(t)}},f.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var r=e._size,n=JSON.stringify(r),i=Math.max(e.margin.l||0,0),a=Math.max(e.margin.r||0,0),o=Math.max(e.margin.t||0,0),c=Math.max(e.margin.b||0,0),u=e._pushmargin;return e.margin.autoexpand!==!1&&(u.base={l:{val:0,size:i},r:{val:1,size:a},t:{val:1,size:o},b:{val:0,size:c}},Object.keys(u).forEach(function(t){var r=u[t].l||{},n=u[t].b||{},l=r.val,f=r.size,h=n.val,d=n.size;Object.keys(u).forEach(function(t){if(s(f)&&u[t].r){var r=u[t].r.val,n=u[t].r.size;if(r>l){var p=(f*r+(n-e.width)*l)/(r-l),g=(n*(1-l)+(f-e.width)*(1-r))/(r-l);p>=0&&g>=0&&p+g>i+a&&(i=p,a=g)}}if(s(d)&&u[t].t){var v=u[t].t.val,m=u[t].t.size;if(v>h){var y=(d*v+(m-e.height)*h)/(v-h),b=(m*(1-h)+(d-e.height)*(1-v))/(v-h);y>=0&&b>=0&&y+b>c+o&&(c=y,o=b)}}})})),r.l=Math.round(i),r.r=Math.round(a),r.t=Math.round(o),r.b=Math.round(c),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,t._replotting||"{}"===n||n===JSON.stringify(e._size)?void 0:l.plot(t)},f.graphJson=function(t,e,r,n,i){function a(t){if("function"==typeof t)return null;if(c.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0&&!c.isPlainObject(t.stream))continue}else if("keepall"!==r&&(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0))continue;i[e]=a(t[e])}return i}return Array.isArray(t)?t.map(a):t&&t.getTime?c.ms2DateTime(t):t}(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&f.supplyDefaults(t);var o=i?t._fullData:t.data,s=i?t._fullLayout:t.layout,l={data:(o||[]).map(function(t){var r=a(t);return e&&delete r.fit,r})};return e||(l.layout=a(s)),t.framework&&t.framework.isPolar&&(l=t.framework.getConfig()),"object"===n?l:JSON.stringify(l)}},{"../components/color":303,"../lib":381,"../plotly":400,"./attributes":401,"./font_attributes":421,"./layout_attributes":451,d3:72,"fast-isnumeric":76}],453:[function(t,e,r){"use strict";var n=t("../../traces/scatter/attributes"),i=n.marker;e.exports={r:n.r,t:n.t,marker:{color:i.color,size:i.size,symbol:i.symbol,opacity:i.opacity}}},{"../../traces/scatter/attributes":554}],454:[function(t,e,r){"use strict";function n(t,e){var r={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return a({},e,r)}var i=t("../cartesian/layout_attributes"),a=t("../../lib/extend").extendFlat,o=a({},i.domain,{});e.exports={radialaxis:n("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:o,orientation:{valType:"number"}}),angularaxis:n("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:o}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":376,"../cartesian/layout_attributes":412}],455:[function(t,e,r){var n=t("../../plotly"),i=t("d3"),a=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},o=n.Lib.extendDeepAll;a.Axis=function(){function t(t){r=t||r;var c=l.data,f=l.layout;return("string"==typeof r||r.nodeName)&&(r=i.select(r)),r.datum(c).each(function(t,r){function l(t,e){return s(t)%360+f.orientation}var c=t.slice();u={data:a.util.cloneJson(c),layout:a.util.cloneJson(f)};var h=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[h],h=(h+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:i.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var d=c.filter(function(t,e){var r=t.visible;return"undefined"==typeof r||r===!0}),p=!1,g=d.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=i.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var r=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,n){t.yStack=[r],m.push(r),r=a.util.sumArrays(t.r,r)}),t.values});d=i.merge(y)}d.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var b=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;b=Math.max(10,b);var x,_=[f.margin.left+b,f.margin.top+b];if(p){var w=i.max(a.util.sumArrays(a.util.arrayLast(d).r[0],a.util.arrayLast(m)));x=[0,w]}else x=i.extent(a.util.flattenArray(d.map(function(t,e){return t.r})));f.radialAxis.domain!=a.DATAEXTENT&&(x[0]=0),n=i.scale.linear().domain(f.radialAxis.domain!=a.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:x).range([0,b]),u.layout.radialAxis.domain=n.domain();var k,A=a.util.flattenArray(d.map(function(t,e){return t.t})),M="string"==typeof A[0];M&&(A=a.util.deduplicate(A),k=A.slice(),A=i.range(A.length),d=d.map(function(t,e){var r=t;return t.t=[A],p&&(r.yStack=t.yStack),r}));var T=d.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===d.length,E=null===f.needsEndSpacing?M||!T:f.needsEndSpacing,L=f.angularAxis.domain&&f.angularAxis.domain!=a.DATAEXTENT&&!M&&f.angularAxis.domain[0]>=0,S=L?f.angularAxis.domain:i.extent(A),C=Math.abs(A[1]-A[0]);T&&!M&&(C=0);var z=S.slice();E&&M&&(z[1]+=C);var P=f.angularAxis.ticksCount||4;P>8&&(P=P/(P/8)+P%8),f.angularAxis.ticksStep&&(P=(z[1]-z[0])/P);var R=f.angularAxis.ticksStep||(z[1]-z[0])/(P*(f.minorTicks+1));k&&(R=Math.max(Math.round(R),1)),z[2]||(z[2]=R);var O=i.range.apply(this,z);if(O=O.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=i.scale.linear().domain(z.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=s.domain(),u.layout.angularAxis.endPadding=E?C:0,e=i.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var I="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",N=(new DOMParser).parseFromString(I,"application/xml"),j=this.appendChild(this.ownerDocument.importNode(N.documentElement,!0));e=i.select(j)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var F,D=e.select(".chart-group"),B={fill:"none",stroke:f.tickColor},U={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){F=e.select(".legend-group").attr({transform:"translate("+[b,f.margin.top]+")"}).style({display:"block"});var V=d.map(function(t,e){var r=a.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});a.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:o({},a.Legend.defaultConfig().legendConfig,{container:F,elements:V,reverseOrder:f.legend.reverseOrder})})();var q=F.node().getBBox();b=Math.min(f.width-q.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,b=Math.max(10,b),_=[f.margin.left+b,f.margin.top+b],n.range([0,b]),u.layout.radialAxis.domain=n.domain(),F.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else F=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),D.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(f.width-(f.margin.left+f.margin.right+2*b+(q?q.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*b))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),e.select(".outer-group").attr("transform","translate("+H+")"),f.title){var G=e.select("g.title-group text").style(U).text(f.title),Y=G.node().getBBox();G.attr({x:_[0]-Y.width/2,y:_[1]-b-20})}var X=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var W=X.selectAll("circle.grid-circle").data(n.ticks(5));W.enter().append("circle").attr({"class":"grid-circle"}).style(B),W.attr("r",n),W.exit().remove()}X.select("circle.outside-circle").attr({r:b}).style(B);var Z=e.select("circle.background-circle").attr({r:b}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var K=i.svg.axis().scale(n).ticks(5).tickSize(5);X.call(K).attr({transform:"rotate("+f.radialAxis.orientation+")"}),X.selectAll(".domain").style(B),X.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(U).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,U["font-size"]]+")":"translate("+[0,U["font-size"]]+")"}}),X.selectAll("g>line").style({stroke:"black"})}var $=e.select(".angular.axis-group").selectAll("g.angular-tick").data(O),Q=$.enter().append("g").classed("angular-tick",!0);$.attr({transform:function(t,e){return"rotate("+l(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),$.exit().remove(),Q.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(B),Q.selectAll(".minor").style({stroke:f.minorTickColor}),$.select("line.grid-line").attr({x1:f.tickLength?b-f.tickLength:0,x2:b}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),Q.append("text").classed("axis-text",!0).style(U);var J=$.select("text.axis-text").attr({x:b+f.labelOffset,dy:".35em",transform:function(t,e){var r=l(t,e),n=b+f.labelOffset,i=f.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?270>r&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(180>=r&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(U);f.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=i.max(D.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));F.attr({transform:"translate("+[b+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,rt=e.select("g.geometry-group").selectAll("g.geometry").data(d);if(rt.enter().append("g").attr({"class":function(t,e){return"geometry geometry"+e}}),rt.exit().remove(),d[0]||et){var nt=[];d.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=s,r.container=rt.filter(function(t,r){return r==e}),r.geometry=t.geometry,r.orientation=f.orientation,r.direction=f.direction,r.index=e,nt.push({data:t,geometryConfig:r})});var it=i.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(nt),at=[];it.forEach(function(t,e){"unstacked"===t.key?at=at.concat(t.values.map(function(t,e){return[t]})):at.push(t.values)}),at.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return o(a[r].defaultConfig(),t)});a[r]().config(n)()})}var ot,st,lt=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=a.tooltipPanel().config({container:ct,fontSize:8})(),ft=a.tooltipPanel().config({container:ct,fontSize:8})(),ht=a.tooltipPanel().config({container:ct,hasTick:!0})();if(!M){var dt=lt.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});D.on("mousemove.angular-guide",function(t,e){var r=a.util.getMousePos(Z).angle;dt.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-f.orientation)%360;ot=s.invert(n);var i=a.util.convertToCartesian(b+12,r+180);ut.text(a.util.round(ot)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){lt.select("line").style({opacity:0})})}var pt=lt.select("circle").style({stroke:"grey",fill:"none"});D.on("mousemove.radial-guide",function(t,e){var r=a.util.getMousePos(Z).radius;pt.attr({r:r}).style({opacity:.5}),st=n.invert(a.util.getMousePos(Z).radius);var i=a.util.convertToCartesian(r,f.radialAxis.orientation);ft.text(a.util.round(st)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),ht.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,r){var n=i.select(this),o=n.style("fill"),s="black",l=n.style("opacity")||1;if(n.attr({"data-opacity":l}),"none"!=o){n.attr({"data-fill":o}),s=i.hsl(o).darker().toString(),n.style({fill:s,opacity:1});var c={t:a.util.round(t[0]),r:a.util.round(t[1])};M&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),h=e.node().getBoundingClientRect(),d=[f.left+f.width/2-H[0]-h.left,f.top+f.height/2-H[1]-h.top];ht.config({color:s}).text(u),ht.move(d)}else o=n.style("stroke"),n.attr({"data-stroke":o}),s=i.hsl(o).darker().toString(),n.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0!=i.event.which?!1:void(i.select(this).attr("data-fill")&&ht.show())}).on("mouseout.tooltip",function(t,e){ht.hide();var r=i.select(this),n=r.attr("data-fill");n?r.style({fill:n,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})}),h}var e,r,n,s,l={ +data:[],layout:{}},c={},u={},f=i.dispatch("hover"),h={};return h.render=function(e){return t(e),this},h.config=function(t){if(!arguments.length)return l;var e=a.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),o(l.data[e],a.Axis.defaultConfig().data[0]),o(l.data[e],t)}),o(l.layout,a.Axis.defaultConfig().layout),o(l.layout,e.layout),this},h.getLiveConfig=function(){return u},h.getinputConfig=function(){return c},h.radialScale=function(t){return n},h.angularScale=function(t){return s},h.svg=function(){return e},i.rebind(h,f,"on"),h},a.Axis.defaultConfig=function(t,e){var r={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:i.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return r},a.util={},a.DATAEXTENT="dataExtent",a.AREA="AreaChart",a.LINE="LinePlot",a.DOT="DotPlot",a.BAR="BarChart",a.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},a.util._extend=function(t,e){for(var r in t)e[r]=t[r]},a.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},a.util.dataFromEquation2=function(t,e){var r=e||6,n=i.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180,i=t(n);return[e,i]});return n},a.util.dataFromEquation=function(t,e,r){var n=e||6,a=[],o=[];i.range(0,360+n,n).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},a.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return i.range(e).map(function(t,e){return r[e]||r[0]})},a.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=a.util.ensureArray(t[e],r)}),t},a.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},a.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},a.util.sumArrays=function(t,e){return i.zip(t,e).map(function(t,e){return i.sum(t)})},a.util.arrayLast=function(t){return t[t.length-1]},a.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},a.util.flattenArray=function(t){for(var e=[];!a.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},a.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},a.util.convertToCartesian=function(t,e){var r=e*Math.PI/180,n=t*Math.cos(r),i=t*Math.sin(r);return[n,i]},a.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},a.util.getMousePos=function(t){var e=i.mouse(t.node()),r=e[0],n=e[1],a={};return a.x=r,a.y=n,a.pos=e,a.angle=180*(Math.atan2(n,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+n*n),a},a.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;a>i;i++)e=t[i],e in r?(r[e]++,n[e]=r[e]):r[e]=1;return n},a.util.duplicates=function(t){return Object.keys(a.util.duplicatesCount(t))},a.util.translator=function(t,e,r,n){if(n){var i=r.slice();r=e,e=i}var a=e.reduce(function(t,e){return"undefined"!=typeof t?t[e]:void 0},t);"undefined"!=typeof a&&(e.reduce(function(t,r,n){return"undefined"!=typeof t?(n===e.length-1&&delete t[r],t[r]):void 0},t),r.reduce(function(t,e,n){return"undefined"==typeof t[e]&&(t[e]={}),n===r.length-1&&(t[e]=a),t[e]},t))},a.PolyChart=function(){function t(){var t=r[0].geometryConfig,e=t.container;"string"==typeof e&&(e=i.select(e)),e.datum(r).each(function(e,r){function n(e,r){var n=t.radialScale(e[1]),i=(t.angularScale(e[0])+t.orientation)*Math.PI/180;return{r:n,t:i}}function a(t){var e=t.r*Math.cos(t.t),r=t.r*Math.sin(t.t);return{x:e,y:r}}var o=!!e[0].data.yStack,l=e.map(function(t,e){return o?i.zip(t.data.t[0],t.data.r[0],t.data.yStack[0]):i.zip(t.data.t[0],t.data.r[0])}),c=t.angularScale,u=t.radialScale.domain()[0],f={};f.bar=function(r,n,a){var o=e[a].data,s=t.radialScale(r[1])-t.radialScale(0),l=t.radialScale(r[2]||0),u=o.barWidth;i.select(this).attr({"class":"mark bar",d:"M"+[[s+l,-u/2],[s+l,u/2],[l,u/2],[l,-u/2]].join("L")+"Z",transform:function(e,r){return"rotate("+(t.orientation+c(e[0]))+")"}})},f.dot=function(t,r,o){var s=t[2]?[t[0],t[1]+t[2]]:t,l=i.svg.symbol().size(e[o].data.dotSize).type(e[o].data.dotType)(t,r);i.select(this).attr({"class":"mark dot",d:l,transform:function(t,e){var r=a(n(s));return"translate("+[r.x,r.y]+")"}})};var h=i.svg.line.radial().interpolate(e[0].data.lineInterpolation).radius(function(e){return t.radialScale(e[1])}).angle(function(e){return t.angularScale(e[0])*Math.PI/180});f.line=function(r,n,a){var o=r[2]?l[a].map(function(t,e){return[t[0],t[1]+t[2]]}):l[a];if(i.select(this).each(f.dot).style({opacity:function(t,r){return+e[a].data.dotVisible},fill:v.stroke(r,n,a)}).attr({"class":"mark dot"}),!(n>0)){var s=i.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({"class":"line",d:h(o),transform:function(e,r){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(r,n,a)},"fill-opacity":0,stroke:function(t,e){return v.stroke(r,n,a)},"stroke-width":function(t,e){return v["stroke-width"](r,n,a)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](r,n,a)},opacity:function(t,e){return v.opacity(r,n,a)},display:function(t,e){return v.display(r,n,a)}})}};var d=t.angularScale.range(),p=Math.abs(d[1]-d[0])/l[0].length*Math.PI/180,g=i.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,r,n){i.select(this).attr({"class":"mark arc",d:g,transform:function(e,r){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var v={fill:function(t,r,n){return e[n].data.color},stroke:function(t,r,n){return e[n].data.strokeColor},"stroke-width":function(t,r,n){return e[n].data.strokeSize+"px"},"stroke-dasharray":function(t,r,n){return s[e[n].data.strokeDash]},opacity:function(t,r,n){return e[n].data.opacity},display:function(t,r,n){return"undefined"==typeof e[n].data.visible||e[n].data.visible?"block":"none"}},m=i.select(this).selectAll("g.layer").data(l);m.enter().append("g").attr({"class":"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({"class":"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,r=[a.PolyChart.defaultConfig()],n=i.dispatch("hover"),s={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){r[e]||(r[e]={}),o(r[e],a.PolyChart.defaultConfig()),o(r[e],t)}),this):r},t.getColorScale=function(){return e},i.rebind(t,n,"on"),t},a.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:i.scale.category20()}};return t},a.BarChart=function(){return a.PolyChart()},a.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},a.AreaChart=function(){return a.PolyChart()},a.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},a.DotPlot=function(){return a.PolyChart()},a.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},a.LinePlot=function(){return a.PolyChart()},a.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},a.Legend=function(){function t(){var r=e.legendConfig,n=e.data.map(function(t,e){return[].concat(t).map(function(t,n){var i=o({},r.elements[e]);return i.name=t,i.color=[].concat(r.elements[e].color)[n],i})}),a=i.merge(n);a=a.filter(function(t,e){return r.elements[e]&&(r.elements[e].visibleInLegend||"undefined"==typeof r.elements[e].visibleInLegend)}),r.reverseOrder&&(a=a.reverse());var s=r.container;("string"==typeof s||s.nodeName)&&(s=i.select(s));var l=a.map(function(t,e){return t.color}),c=r.fontSize,u=null==r.isContinuous?"number"==typeof a[0]:r.isContinuous,f=u?r.height:c*a.length,h=s.classed("legend-group",!0),d=h.selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=i.range(a.length),v=i.scale[u?"linear":"ordinal"]().domain(g).range(l),m=i.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var r=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=i.svg.symbolTypes.indexOf(t)?i.svg.symbol().type(t).size(r)():i.svg.symbol().type("square").size(r)()};if(u){var b=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);b.enter().append("stop"),b.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:r.height,width:r.colorBandWidth,fill:"url(#grad1)"})}else{var x=d.select(".legend-marks").selectAll("path.legend-mark").data(a);x.enter().append("path").classed("legend-mark",!0),x.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var r=t.symbol;return y(r,c)},fill:function(t,e){return v(e)}}),x.exit().remove()}var _=i.svg.axis().scale(m).orient("right"),w=d.select("g.legend-axis").attr({transform:"translate("+[u?r.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?r.textColor:"none"}),w.selectAll("text").style({fill:r.textColor,"font-size":r.fontSize}).text(function(t,e){return a[e].name}),t}var e=a.Legend.defaultConfig(),r=i.dispatch("hover");return t.config=function(t){return arguments.length?(o(e,t),this):e},i.rebind(t,r,"on"),t},a.Legend.defaultConfig=function(t,e){var r={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return r},a.tooltipPanel=function(){var t,e,r,n={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+a.tooltipPanel.uid++,l=10,c=function(){t=n.container.selectAll("g."+s).data([0]);var i=t.enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=i.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=i.append("text").attr({dx:n.padding+l,dy:.3*+n.fontSize}),c};return c.text=function(a){var o=i.hsl(n.color).l,s=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":n.fontSize+"px"}).text(f);var h=n.padding,d=e.node().getBBox(),p={fill:n.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[n.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),c},c.move=function(e){return t?(t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c):void 0},c.hide=function(){return t?(t.style({display:"none"}),c):void 0},c.show=function(){return t?(t.style({display:"block"}),c):void 0},c.config=function(t){return o(n,t),c},c},a.tooltipPanel.uid=1,a.adapter={},a.adapter.plotly=function(){var t={};return t.convert=function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=o({},t),i=[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]];return i.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",n.dotVisible===!0?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var n=a.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var i=n.indexOf(t.geometry);-1!=i&&(r.data[e].groupId=i)})}if(t.layout){var s=o({},t.layout),l=[[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]];if(l.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};i.entries(s.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),s.margin=f}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r},t}},{"../../plotly":400,"./micropolar_manager":456,d3:72}],456:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("d3"),a=t("./undo_manager"),o=e.exports={},s=n.Lib.extendDeepAll;o.framework=function(t){function e(e,a){return a&&(f=a),i.select(i.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),r=r?s(r,e):e,c||(c=n.micropolar.Axis()),u=n.micropolar.adapter.plotly().convert(r),c.config(u).render(f),t.data=r.data,t.layout=r.layout,o.fillLayout(t),r}var r,l,c,u,f,h=new a;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return r},e.getLiveConfig=function(){return n.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=n.micropolar.util.cloneJson(r);!function(e,r){h.add({undo:function(){r&&t(r)},redo:function(){t(e)}})}(e,l),l=n.micropolar.util.cloneJson(e)},e.undo=function(){h.undo()},e.redo=function(){h.redo()},e},o.fillLayout=function(t){var e=i.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:n.Color.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../plotly":400,"./undo_manager":457,d3:72}],457:[function(t,e,r){"use strict";e.exports=function(){function t(t,e){return t?(i=!0,t[e](),i=!1,this):this}var e,r=[],n=-1,i=!1;return{add:function(t){return i?this:(r.splice(n+1,r.length-n),r.push(t),n=r.length-1,this)},setCallback:function(t){e=t},undo:function(){var i=r[n];return i?(t(i,"undo"),n-=1,e&&e(i.undo),this):this},redo:function(){var i=r[n+1];return i?(t(i,"redo"),n+=1,e&&e(i.redo),this):this},clear:function(){r=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return ng;g++){var v=d[g];s=t[v]?t[v]:t[v]={},e[v]=l={},o("domain."+h,[g/p,(g+1)/p]),o("domain."+{x:"y",y:"x"}[h]),a.id=v,f(s,l,o,a)}}},{"../lib":381,"./plots":452}],459:[function(t,e,r){"use strict";var n=t("./ternary"),i=t("../../plots/plots");r.name="ternary",r.attr="subplot",r.idRoot="ternary",r.idRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"ternary"),o=0;o=o&&(d.min=0,p.min=0,g.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}var i=t("../../../components/color"),a=t("../../subplot_defaults"),o=t("./layout_attributes"),s=t("./axis_defaults"),l=["aaxis","baxis","caxis"];e.exports=function(t,e,r){a(t,e,r,{type:"ternary",attributes:o,handleDefaults:n,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../../components/color":303,"../../subplot_defaults":458,"./axis_defaults":462,"./layout_attributes":464}],464:[function(t,e,r){"use strict";var n=t("../../../components/color/attributes"),i=t("./axis_attributes");e.exports={domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},bgcolor:{valType:"color",dflt:n.background},sum:{valType:"number",dflt:1,min:0},aaxis:i,baxis:i,caxis:i}},{"../../../components/color/attributes":302,"./axis_attributes":461}],465:[function(t,e,r){"use strict";function n(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework()}function i(t){a.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var a=t("d3"),o=t("tinycolor2"),s=t("../../plotly"),l=t("../../lib"),c=t("../../components/color"),u=t("../../components/drawing"),f=t("../cartesian/set_convert"),h=t("../../lib/extend").extendFlat,d=t("../cartesian/axes"),p=t("../../lib/filter_visible"),g=t("../../components/dragelement"),v=t("../../components/titles"),m=t("../cartesian/select"),y=t("../cartesian/constants"),b=t("../cartesian/graph_interact");e.exports=n;var x=n.prototype;x.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={}},x.plot=function(t,e){var r,n=this,i=e[n.id],a=e._size;l.getPlotDiv(n.plotContainer.node())!==n.graphDiv&&(n.init(n.graphDiv._fullLayout),n.makeFramework()),n.adjustLayout(i,a);var o=n.traceHash,s={};for(r=0;r_*y?(a=y,i=a*_):(i=m,a=i/_),o=g*i/m,s=v*a/y,r=e.l+e.w*d-i/2,n=e.t+e.h*(1-p)-a/2,l.x0=r,l.y0=n,l.w=i,l.h=a,l.sum=b,l.xaxis={type:"linear",range:[x+2*k-b,b-x-2*w],domain:[d-o/2,d+o/2],_id:"x",_gd:l.graphDiv},f(l.xaxis),l.xaxis.setScale(),l.yaxis={type:"linear",range:[x,b-w-k],domain:[p-s/2,p+s/2],_id:"y",_gd:l.graphDiv},f(l.yaxis),l.yaxis.setScale();var A=l.yaxis.domain[0],M=l.aaxis=h({},t.aaxis,{range:[x,b-w-k],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[A,A+s*_],_axislayer:l.layers.aaxis,_gridlayer:l.layers.agrid,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l"+a+",-"+i/2});f(M);var T=l.baxis=h({},t.baxis,{range:[b-x-k,w],side:"bottom",_counterangle:30,domain:l.xaxis.domain,_axislayer:l.layers.baxis,_gridlayer:l.layers.bgrid,_counteraxis:l.aaxis,_pos:0,_gd:l.graphDiv,_id:"x",_length:i,_gridpath:"M0,0l-"+i/2+",-"+a});f(T),M._counteraxis=T;var E=l.caxis=h({},t.caxis,{range:[b-x-w,k],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[A,A+s*_],_axislayer:l.layers.caxis,_gridlayer:l.layers.cgrid,_counteraxis:l.baxis,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l-"+a+","+i/2});f(E);var L="M"+r+","+(n+a)+"h"+i+"l-"+i/2+",-"+a+"Z";l.clipDef.select("path").attr("d",L),l.layers.plotbg.select("path").attr("d",L);var S="translate("+r+","+n+")";l.plotContainer.selectAll(".scatterlayer,.maplayer,.zoom").attr("transform",S);var C="translate("+r+","+(n+a)+")";l.layers.baxis.attr("transform",C),l.layers.bgrid.attr("transform",C);var z="translate("+(r+i/2)+","+n+")rotate(30)";l.layers.aaxis.attr("transform",z),l.layers.agrid.attr("transform",z);var P="translate("+(r+i/2)+","+n+")rotate(-30)";l.layers.caxis.attr("transform",P),l.layers.cgrid.attr("transform",P),l.drawAxes(!0),l.plotContainer.selectAll(".crisp").classed("crisp",!1);var R=l.layers.axlines;R.select(".aline").attr("d",M.showline?"M"+r+","+(n+a)+"l"+i/2+",-"+a:"M0,0").call(c.stroke,M.linecolor||"#000").style("stroke-width",(M.linewidth||0)+"px"),R.select(".bline").attr("d",T.showline?"M"+r+","+(n+a)+"h"+i:"M0,0").call(c.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),R.select(".cline").attr("d",E.showline?"M"+(r+i/2)+","+n+"l"+i/2+","+a:"M0,0").call(c.stroke,E.linecolor||"#000").style("stroke-width",(E.linewidth||0)+"px")},x.drawAxes=function(t){var e=this,r=e.graphDiv,n=e.id.substr(7)+"title",i=e.aaxis,a=e.baxis,o=e.caxis;if(d.doTicks(r,i,!0),d.doTicks(r,a,!0),d.doTicks(r,o,!0),t){var s=Math.max(i.showticklabels?i.tickfont.size/2:0,(o.showticklabels?.75*o.tickfont.size:0)+("outside"===o.ticks?.87*o.ticklen:0));v.draw(r,"a"+n,{propContainer:i,propName:e.id+".aaxis.title",dfltName:"Component A",attributes:{x:e.x0+e.w/2,y:e.y0-i.titlefont.size/3-s,"text-anchor":"middle"}});var l=(a.showticklabels?a.tickfont.size:0)+("outside"===a.ticks?a.ticklen:0)+3;v.draw(r,"b"+n,{propContainer:a,propName:e.id+".baxis.title",dfltName:"Component B",attributes:{x:e.x0-l,y:e.y0+e.h+.83*a.titlefont.size+l,"text-anchor":"middle"}}),v.draw(r,"c"+n,{propContainer:o,propName:e.id+".caxis.title",dfltName:"Component C",attributes:{x:e.x0+e.w+l,y:e.y0+e.h+.83*o.titlefont.size+l,"text-anchor":"middle"}})}};var w=y.MINZOOM/2+.87,k="m-0.87,.5h"+w+"v3h-"+(w+5.2)+"l"+(w/2+2.6)+",-"+(.87*w+4.5)+"l2.6,1.5l-"+w/2+","+.87*w+"Z",A="m0.87,.5h-"+w+"v3h"+(w+5.2)+"l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-2.6,1.5l"+w/2+","+.87*w+"Z",M="m0,1l"+w/2+","+.87*w+"l2.6,-1.5l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-"+(w/2+2.6)+","+(.87*w+4.5)+"l2.6,1.5l"+w/2+",-"+.87*w+"Z",T="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",E=!0;x.initInteractions=function(){function t(t,e,r){var n=j.getBoundingClientRect();x=e-n.left,w=r-n.top,L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L,S=N.aaxis.range[1]-L.a,z=o(N.graphDiv._fullLayout[N.id].bgcolor).getLuminance(),P="M0,"+N.h+"L"+N.w/2+", 0L"+N.w+","+N.h+"Z",R=!1,O=D.append("path").attr("class","zoombox").style({fill:z>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",P),I=D.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),p()}function e(t,e){return 1-e/N.h}function r(t,e){return 1-(t+(N.h-e)/Math.sqrt(3))/N.w}function n(t,e){return(t-(N.h-e)/Math.sqrt(3))/N.w}function a(t,i){var a=x+t,o=w+i,s=Math.max(0,Math.min(1,e(x,w),e(a,o))),l=Math.max(0,Math.min(1,r(x,w),r(a,o))),c=Math.max(0,Math.min(1,n(x,w),n(a,o))),u=(s/2+c)*N.w,f=(1-s/2-l)*N.w,h=(u+f)/2,d=f-u,p=(1-s)*N.h,g=p-d/_;d.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),I.transition().style("opacity",1).duration(200),R=!0)}function u(t,e){if(C===L)return 2===e&&v(),i(F);i(F);var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r),E&&F.data&&F._context.showTips&&(l.notifier("Double-click to
zoom back out","long"),E=!1)}function f(){L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L}function h(t,e){var r=t/N.xaxis._m,n=e/N.yaxis._m;C={a:L.a-n,b:L.b+(r+n)/2,c:L.c-(r-n)/2};var i=[C.a,C.b,C.c].sort(),a={a:i.indexOf(C.a),b:i.indexOf(C.b),c:i.indexOf(C.c)};i[0]<0&&(i[1]+i[0]/2<0?(i[2]+=i[0]+i[1],i[0]=i[1]=0):(i[2]+=i[0]/2,i[1]+=i[0]/2,i[0]=0),C={a:i[a.a],b:i[a.b],c:i[a.c]},e=(L.a-C.a)*N.yaxis._m,t=(L.c-C.c-L.b+C.b)*N.xaxis._m);var o="translate("+(N.x0+t)+","+(N.y0+e)+")";N.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",o),N.aaxis.range=[C.a,N.sum-C.b-C.c],N.baxis.range=[N.sum-C.a-C.c,C.b],N.caxis.range=[N.sum-C.a-C.b,C.c],N.drawAxes(!1),N.plotContainer.selectAll(".crisp").classed("crisp",!1)}function d(t,e){if(t){var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r)}else 2===e&&v(); +}function p(){N.plotContainer.selectAll(".select-outline").remove()}function v(){var t={};t[N.id+".aaxis.min"]=0,t[N.id+".baxis.min"]=0,t[N.id+".caxis.min"]=0,F.emit("plotly_doubleclick",null),s.relayout(F,t)}var x,w,L,S,C,z,P,R,O,I,N=this,j=N.layers.plotbg.select("path").node(),F=N.graphDiv,D=N.layers.zoom,B={element:j,gd:F,plotinfo:{plot:D},doubleclick:v,subplot:N.id,prepFn:function(e,r,n){B.xaxes=[N.xaxis],B.yaxes=[N.yaxis];var i=F._fullLayout.dragmode;e.shiftKey&&(i="pan"===i?"zoom":"pan"),"lasso"===i?B.minDrag=1:B.minDrag=void 0,"zoom"===i?(B.moveFn=a,B.doneFn=u,t(e,r,n)):"pan"===i?(B.moveFn=h,B.doneFn=d,f(),p()):"select"!==i&&"lasso"!==i||m(e,r,n,B,i)}};g.init(B),j.onmousemove=function(t){b.hover(F,t,N.id),F._fullLayout._lasthover=j,F._fullLayout._hoversubplot=N.id},j.onmouseout=function(t){F._dragging||g.unhover(F,t)},j.onclick=function(t){b.click(F,t)},F._fullLayout._plots||(F._fullLayout._plots={}),F._fullLayout._plots[N.id]={overlays:[],xaxis:N.xaxis,yaxis:N.yaxis,x:function(){return N.xaxis},y:function(){return N.yaxis}}}},{"../../components/color":303,"../../components/dragelement":323,"../../components/drawing":325,"../../components/titles":365,"../../lib":381,"../../lib/extend":376,"../../lib/filter_visible":377,"../../plotly":400,"../cartesian/axes":403,"../cartesian/constants":408,"../cartesian/graph_interact":410,"../cartesian/select":416,"../cartesian/set_convert":417,d3:72,tinycolor2:233}],466:[function(t,e,r){"use strict";function n(t){var e;switch(t){case"themes__thumb":e={autosize:!0,width:150,height:150,title:"",showlegend:!1,margin:{l:5,r:5,t:5,b:5,pad:0},annotations:[]};break;case"thumbnail":e={title:"",hidesources:!0,showlegend:!1,borderwidth:0,bordercolor:"",margin:{l:1,r:1,t:1,b:1,pad:0},annotations:[]};break;default:e={}}return e}function i(t){var e=["xaxis","yaxis","zaxis"];return e.indexOf(t.slice(0,5))>-1}var a=t("../plotly"),o=a.Lib.extendFlat,s=a.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var r,l=t.data,c=t.layout,u=s([],l),f=s({},c,n(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var h=Object.keys(f);for(r=0;rl;l++)n(r[l])&&d.push({p:r[l],s:s[l],b:0});return a(e,"marker")&&o(e,e.marker.color,"marker","c"),a(e,"marker.line")&&o(e,e.marker.line.color,"marker.line","c"),d}},{"../../components/colorscale/calc":310,"../../components/colorscale/has_colorscale":315,"../../plots/cartesian/axes":403,"fast-isnumeric":76}],476:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("../scatter/xy_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=a(t,e,u);return f?(u("orientation",e.x&&!e.y?"h":"v"),u("text"),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),void s(t,e,i.defaultLine,{axis:"x",inherit:"y"})):void(e.visible=!1)}},{"../../components/color":303,"../../components/errorbars/defaults":330,"../../lib":381,"../bar/style_defaults":484,"../scatter/xy_defaults":575,"./attributes":474}],477:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../components/errorbars"),a=t("../../components/color");e.exports=function(t,e,r,o){var s,l=t.cd,c=l[0].trace,u=l[0].t,f=t.xa,h=t.ya,d="closest"===o?u.barwidth/2:u.dbar*(1-f._gd._fullLayout.bargap)/2;s="closest"!==o?function(t){return t.p}:"h"===c.orientation?function(t){return t.y}:function(t){return t.x};var p,g;"h"===c.orientation?(p=function(t){return n.inbox(t.b-e,t.x-e)+(t.x-e)/(t.x-t.b)},g=function(t){var e=s(t)-r;return n.inbox(e-d,e+d)}):(g=function(t){return n.inbox(t.b-r,t.y-r)+(t.y-r)/(t.y-t.b)},p=function(t){var r=s(t)-e;return n.inbox(r-d,r+d)});var v=n.getDistanceFunction(o,p,g);if(n.getClosest(l,v,t),t.index!==!1){var m=l[t.index],y=m.mcc||c.marker.color,b=m.mlcc||c.marker.line.color,x=m.mlw||c.marker.line.width;return a.opacity(y)?t.color=y:a.opacity(b)&&x&&(t.color=b),"h"===c.orientation?(t.x0=t.x1=f.c2p(m.x,!0),t.xLabelVal=m.s,t.y0=h.c2p(s(m)-d,!0),t.y1=h.c2p(s(m)+d,!0),t.yLabelVal=m.p):(t.y0=t.y1=h.c2p(m.y,!0),t.yLabelVal=m.s,t.x0=f.c2p(s(m)-d,!0),t.x1=f.c2p(s(m)+d,!0),t.xLabelVal=m.p),m.tx&&(t.text=m.tx),i.hoverInfo(m,c,t),[t]}}},{"../../components/color":303,"../../components/errorbars":331,"../../plots/cartesian/graph_interact":410}],478:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("./layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.calc=t("./calc"),n.setPositions=t("./set_positions"),n.colorbar=t("../scatter/colorbar"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.moduleType="trace",n.name="bar",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","oriented","markerColorscale","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":411,"../scatter/colorbar":557,"./arrays_to_calcdata":473,"./attributes":474,"./calc":475,"./defaults":476,"./hover":477,"./layout_attributes":479,"./layout_defaults":480,"./plot":481,"./set_positions":482,"./style":483}],479:[function(t,e,r){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","group","overlay","relative"],dflt:"group"},barnorm:{valType:"enumerated",values:["","fraction","percent"],dflt:""},bargap:{valType:"number",min:0,max:1},bargroupgap:{valType:"number",min:0,max:1,dflt:0}}},{}],480:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./layout_attributes");e.exports=function(t,e,r){function s(r,n){return a.coerce(t,e,o,r,n)}for(var l=!1,c=!1,u=!1,f={},h=0;h=2?a(t):t>e?Math.ceil(t):Math.floor(t)}var h,d,p,g;if("h"===s.orientation?(p=u.c2p(r.poffset+e.p,!0),g=u.c2p(r.poffset+e.p+r.barwidth,!0),h=c.c2p(e.b,!0),d=c.c2p(e.s+e.b,!0)):(h=c.c2p(r.poffset+e.p,!0),d=c.c2p(r.poffset+e.p+r.barwidth,!0),g=u.c2p(e.s+e.b,!0),p=u.c2p(e.b,!0)),!(i(h)&&i(d)&&i(p)&&i(g)&&h!==d&&p!==g))return void n.select(this).remove();var v=(e.mlw+1||s.marker.line.width+1||(e.trace?e.trace.marker.line.width:0)+1)-1,m=n.round(v/2%1,2);if(!t._context.staticPlot){var y=o.opacity(e.mc||s.marker.color),b=1>y||v>.01?a:l;h=b(h,d),d=b(d,h),p=b(p,g),g=b(g,p)}n.select(this).attr("d","M"+h+","+p+"V"+g+"H"+d+"V"+p+"Z")})}),h.call(s.plot,e)}},{"../../components/color":303,"../../components/errorbars":331,"../../lib":381,"./arrays_to_calcdata":473,d3:72,"fast-isnumeric":76}],482:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axes"),o=t("../../lib");e.exports=function(t,e){var r,s,l=t._fullLayout,c=e.x(),u=e.y();["v","h"].forEach(function(f){function h(e){function r(t){t[p]=t.p+h}var n=[];e.forEach(function(e){t.calcdata[e].forEach(function(t){n.push(t.p)})});var i=o.distinctVals(n),s=i.vals,c=i.minDiff,u=!1,f=[];"group"===l.barmode&&e.forEach(function(e){u||(t.calcdata[e].forEach(function(t){u||f.forEach(function(e){Math.abs(t.p-e)_&&(S=!0,M=_),_>A+R&&(S=!0,A=_))}a.expand(m,[M,A],{tozero:!0,padded:S})}else{var O=function(t){return t[g]=t.s,t.s};for(r=0;r1||0===s.bargap&&0===s.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),e.selectAll("g.points").each(function(t){var e=t[0].trace,r=e.marker,o=r.line,s=(e._input||{}).marker||{},l=a.tryColorscale(r,s,""),c=a.tryColorscale(r,s,"line.");n.select(this).selectAll("path").each(function(t){var e,a,s=(t.mlw+1||o.width+1)-1,u=n.select(this);e="mc"in t?t.mcc=l(t.mc):Array.isArray(r.color)?i.defaultLine:r.color,u.style("stroke-width",s+"px").call(i.fill,e),s&&(a="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(o.color)?i.defaultLine:o.color,u.call(i.stroke,a))})}),e.call(o.style)}},{"../../components/color":303,"../../components/drawing":325,"../../components/errorbars":331,d3:72}],484:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s){r("marker.color",o),i(t,"marker")&&a(t,e,s,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),i(t,"marker.line")&&a(t,e,s,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width")}},{"../../components/color":303,"../../components/colorscale/defaults":312,"../../components/colorscale/has_colorscale":315}],485:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/color/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=o.line;e.exports={y:{valType:"data_array"},x:{valType:"data_array"},x0:{valType:"any"},y0:{valType:"any"},whiskerwidth:{valType:"number",min:0,max:1,dflt:.5},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1},jitter:{valType:"number",min:0,max:1},pointpos:{valType:"number",min:-2,max:2},orientation:{valType:"enumerated",values:["v","h"]},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)"},symbol:a({},o.symbol,{arrayOk:!1}),opacity:a({},o.opacity,{arrayOk:!1,dflt:1}),size:a({},o.size,{arrayOk:!1}),color:a({},o.color,{arrayOk:!1}),line:{color:a({},s.color,{arrayOk:!1,dflt:i.defaultLine}),width:a({},s.width,{arrayOk:!1,dflt:0}),outliercolor:{valType:"color"},outlierwidth:{valType:"number",min:0,dflt:1}}},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2}},fillcolor:n.fillcolor}},{"../../components/color/attributes":302,"../../lib/extend":376,"../scatter/attributes":554}],486:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../../plots/cartesian/axes");e.exports=function(t,e){function r(t,e,r,a,o){var s;return r in e?p=a.makeCalcdata(e,r):(s=r+"0"in e?e[r+"0"]:"name"in e&&("category"===a.type||n(e.name)&&-1!==["linear","log"].indexOf(a.type)||i.isDateTime(e.name)&&"date"===a.type)?e.name:t.numboxes,s=a.d2c(s),p=o.map(function(){return s})),p}function o(t,e,r,a,o){var s,l,c,u,f=a.length,h=e.length,d=[],p=[];for(s=0;f>s;++s)l=a[s],t[s]={pos:l},p[s]=l-o,d[s]=[];for(p.push(a[f-1]+o),s=0;h>s;++s)u=e[s],n(u)&&(c=i.findBin(r[s],p),c>=0&&h>c&&d[c].push(u));return d}function s(t,e){var r,n,a,o;for(o=0;o1,m=r.dPos*(1-h.boxgap)*(1-h.boxgroupgap)/(v?t.numboxes:1),y=v?2*r.dPos*(-.5+(r.boxnum+.5)/t.numboxes)*(1-h.boxgap):0,b=m*g.whiskerwidth;return g.visible!==!0||r.emptybox?void a.select(this).remove():("h"===g.orientation?(l=p,f=d):(l=d,f=p),r.bPos=y,r.bdPos=m,n(),a.select(this).selectAll("path.box").data(o.identity).enter().append("path").attr("class","box").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=l.c2p(t.pos+y-b,!0),s=l.c2p(t.pos+y+b,!0),c=f.c2p(t.q1,!0),u=f.c2p(t.q3,!0),h=o.constrain(f.c2p(t.med,!0),Math.min(c,u)+1,Math.max(c,u)-1),d=f.c2p(g.boxpoints===!1?t.min:t.lf,!0),p=f.c2p(g.boxpoints===!1?t.max:t.uf,!0);"h"===g.orientation?a.select(this).attr("d","M"+h+","+r+"V"+n+"M"+c+","+r+"V"+n+"H"+u+"V"+r+"ZM"+c+","+e+"H"+d+"M"+u+","+e+"H"+p+(0===g.whiskerwidth?"":"M"+d+","+i+"V"+s+"M"+p+","+i+"V"+s)):a.select(this).attr("d","M"+r+","+h+"H"+n+"M"+r+","+c+"H"+n+"V"+u+"H"+r+"ZM"+e+","+c+"V"+d+"M"+e+","+u+"V"+p+(0===g.whiskerwidth?"":"M"+i+","+d+"H"+s+"M"+i+","+p+"H"+s))}),g.boxpoints&&a.select(this).selectAll("g.points").data(function(t){return t.forEach(function(t){t.t=r,t.trace=g}),t}).enter().append("g").attr("class","points").selectAll("path").data(function(t){var e,r,n,a,s,l,f,h="all"===g.boxpoints?t.val:t.val.filter(function(e){return et.uf}),d=(t.q3-t.q1)*u,p=[],v=0;if(g.jitter){for(e=0;et.lo&&(n.so=!0),n})}).enter().append("path").call(s.translatePoints,d,p),void(g.boxmean&&a.select(this).selectAll("path.mean").data(o.identity).enter().append("path").attr("class","mean").style("fill","none").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=f.c2p(t.mean,!0),o=f.c2p(t.mean-t.sd,!0),s=f.c2p(t.mean+t.sd,!0);"h"===g.orientation?a.select(this).attr("d","M"+i+","+r+"V"+n+("sd"!==g.boxmean?"":"m0,0L"+o+","+e+"L"+i+","+r+"L"+s+","+e+"Z")):a.select(this).attr("d","M"+r+","+i+"H"+n+("sd"!==g.boxmean?"":"m0,0L"+e+","+o+"L"+r+","+i+"L"+e+","+s+"Z"))})))})}},{"../../components/drawing":325,"../../lib":381,d3:72}],493:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib");e.exports=function(t,e){var r,o,s,l,c=t._fullLayout,u=e.x(),f=e.y(),h=["v","h"];for(o=0;ol&&(e.z=u.slice(0,l)),s("locationmode"),s("text"),s("marker.line.color"),s("marker.line.width"),i(t,e,o,s,{prefix:"",cLetter:"z"}),void s("hoverinfo",1===o._dataLength?"location+z+text":void 0)):void(e.visible=!1); +}},{"../../components/colorscale/defaults":312,"../../lib":381,"./attributes":495}],498:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../heatmap/colorbar"),n.calc=t("./calc"),n.plot=t("./plot").plot,n.moduleType="trace",n.name="choropleth",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","noOpacity"],n.meta={},e.exports=n},{"../../plots/geo":424,"../heatmap/colorbar":512,"./attributes":495,"./calc":496,"./defaults":497,"./plot":499}],499:[function(t,e,r){"use strict";function n(t,e){function r(e){var r=t.mockAxis;return o.tickText(r,r.c2l(e),"hover").text}var n=e.hoverinfo;if("none"===n)return function(t){delete t.nameLabel,delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("name"),s=-1!==i.indexOf("location"),l=-1!==i.indexOf("z"),c=-1!==i.indexOf("text"),u=!a&&s;return function(t){var n=[];u?t.nameLabel=t.id:(a&&(t.nameLabel=e.name),s&&n.push(t.id)),l&&n.push(r(t.z)),c&&n.push(t.tx),t.textLabel=n.join("
")}}function i(t){return function(e,r){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:r,location:e.id,z:e.z}]}}}var a=t("d3"),o=t("../../plots/cartesian/axes"),s=t("../../plots/cartesian/graph_interact"),l=t("../../components/color"),c=t("../../components/drawing"),u=t("../../components/colorscale/get_scale"),f=t("../../components/colorscale/make_scale_function"),h=t("../../lib/topojson_utils").getTopojsonFeatures,d=t("../../lib/geo_location_utils").locationToFeature,p=t("../../lib/array_to_calc_item"),g=t("../../plots/geo/constants"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){for(var r,n=[],i=t.locations,a=i.length,o=h(t,e),s=(t.marker||{}).line||{},l=0;a>l;l++)r=d(t.locationmode,i[l],o),void 0!==r&&(r.z=t.z[l],void 0!==t.text&&(r.tx=t.text[l]),p(s.color,r,"mlc",l),p(s.width,r,"mlw",l),n.push(r));return n.length>0&&(n[0].trace=t),n},m.plot=function(t,e,r){var o,l=t.framework,c=l.select("g.choroplethlayer"),u=l.select("g.baselayer"),f=l.select("g.baselayeroverchoropleth"),h=g.baseLayersOverChoropleth,d=c.selectAll("g.trace.choropleth").data(e,function(t){return t.uid});d.enter().append("g").attr("class","trace choropleth"),d.exit().remove(),d.each(function(e){function r(e,r){if(t.showHover){var n=t.projection(e.properties.ct);c(e),s.loneHover({x:n[0],y:n[1],name:e.nameLabel,text:e.textLabel},{container:t.hoverContainer.node()}),f=u(e,r),t.graphDiv.emit("plotly_hover",f)}}function o(e,r){t.graphDiv.emit("plotly_click",u(e,r))}var l=m.calcGeoJSON(e,t.topojson),c=n(t,e),u=i(e),f=null,h=a.select(this).selectAll("path.choroplethlocation").data(l);h.enter().append("path").classed("choroplethlocation",!0).on("mouseover",r).on("click",o).on("mouseout",function(){s.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",f)}).on("mousedown",function(){s.loneUnhover(t.hoverContainer)}).on("mouseup",r),h.exit().remove()}),f.selectAll("*").remove();for(var p=0;pr;r++)e=f[r],d[r]=e[0]*(t.zmax-t.zmin)+t.zmin,p[r]=e[1];var g=n.extent([t.zmin,t.zmax,a.start,a.start+l*(c-1)]),v=g[t.zminr;r++)e=f[r],d[r]=(e[0]*(c+u-1)-u/2)*l+o,p[r]=e[1];var y=n.scale.linear().interpolate(n.interpolateRgb).domain(d).range(p);return y}},{"../../components/colorscale/get_scale":314,d3:72}],507:[function(t,e,r){"use strict";function n(t,e,r){_.markTime("in Contour.plot");var n=r[0].trace,a=r[0].x,s=r[0].y,c=n.contours,u=n.uid,f=e.x(),h=e.y(),v=t._fullLayout,b="contour"+u,x=i(c,e,r[0]);if(n.visible!==!0)return v._paper.selectAll("."+b+",.hm"+u).remove(),void v._infolayer.selectAll(".cb"+u).remove();"heatmap"===c.coloring?(n.zauto&&n.autocontour===!1&&(n._input.zmin=n.zmin=c.start-c.size/2,n._input.zmax=n.zmax=n.zmin+x.length*c.size),k(t,e,[r])):v._paper.selectAll(".hm"+u).remove(),o(x),l(x);var w=f.c2p(a[0],!0),A=f.c2p(a[a.length-1],!0),M=h.c2p(s[0],!0),T=h.c2p(s[s.length-1],!0),E=[[w,T],[A,T],[A,M],[w,M]],L=d(e,r,b);p(L,E,c),g(L,x,E,c),m(L,x,c),y(L,e,r[0],E),_.markTime("done Contour.plot")}function i(t,e,r){for(var n=t.size||1,i=[],a=t.start;at?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);if(5===r||10===r){var n=(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4;return t>n?5===r?713:1114:5===r?104:208}return 15===r?0:r}function o(t){var e,r,n,i,o,s,l,c,u,f=t[0].z,h=f.length,d=f[0].length,p=2===h||2===d;for(r=0;h-1>r;r++)for(i=[],0===r&&(i=i.concat(A)),r===h-2&&(i=i.concat(M)),e=0;d-1>e;e++)for(n=i.slice(),0===e&&(n=n.concat(T)),e===d-2&&(n=n.concat(E)),o=e+","+r,s=[[f[r][e],f[r][e+1]],[f[r+1][e],f[r+1][e+1]]],u=0;ui;i++){if(s>20?(s=S[s][(l[0]||l[1])<0?0:1],t.crossings[o]=C[s]):delete t.crossings[o],l=L[s],!l){console.log("found bad marching index",s,e,t.level);break}if(d.push(h(t,e,l)),e[0]+=l[0],e[1]+=l[1],u(d[d.length-1],d[d.length-2])&&d.pop(),o=e.join(","),o===a&&l.join(",")===p||r&&(l[0]&&(e[0]<0||e[0]>v-2)||l[1]&&(e[1]<0||e[1]>g-2)))break;s=t.crossings[o]}1e4===i&&console.log("Infinite loop in contour?");var m,y,b,x,_,w,k,A=u(d[0],d[d.length-1]),M=0,T=.2*t.smoothing,E=[],z=0;for(i=1;i=z;i--)if(m=E[i],P>m){for(b=0,y=i-1;y>=z&&m+E[y]b&&m+E[b]e;)e++,r=Object.keys(i.crossings)[0].split(",").map(Number),s(i,r);1e4===e&&console.log("Infinite loop in contour?")}}function c(t,e,r){var n=0,i=0;return t>20&&e?208===t||1114===t?n=0===r[0]?1:-1:i=0===r[1]?1:-1:-1!==A.indexOf(t)?i=1:-1!==T.indexOf(t)?n=1:-1!==M.indexOf(t)?i=-1:n=-1,[n,i]}function u(t,e){return Math.abs(t[0]-e[0])<.01&&Math.abs(t[1]-e[1])<.01}function f(t,e){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function h(t,e,r){var n=e[0]+Math.max(r[0],0),i=e[1]+Math.max(r[1],0),a=t.z[i][n],o=t.xaxis,s=t.yaxis;if(r[1]){var l=(t.level-a)/(t.z[i][n+1]-a);return[o.c2p((1-l)*t.x[n]+l*t.x[n+1],!0),s.c2p(t.y[i],!0)]}var c=(t.level-a)/(t.z[i+1][n]-a);return[o.c2p(t.x[n],!0),s.c2p((1-c)*t.y[i]+c*t.y[i+1],!0)]}function d(t,e,r){var n=t.plot.select(".maplayer").selectAll("g.contour."+r).data(e);return n.enter().append("g").classed("contour",!0).classed(r,!0),n.exit().remove(),n}function p(t,e,r){var n=t.selectAll("g.contourbg").data([0]);n.enter().append("g").classed("contourbg",!0);var i=n.selectAll("path").data("fill"===r.coloring?[0]:[]);i.enter().append("path"),i.exit().remove(),i.attr("d","M"+e.join("L")+"Z").style("stroke","none")}function g(t,e,r,n){var i=t.selectAll("g.contourfill").data([0]);i.enter().append("g").classed("contourfill",!0);var a=i.selectAll("path").data("fill"===n.coloring?e:[]);a.enter().append("path"),a.exit().remove(),a.each(function(t){var e=v(t,r);e?x.select(this).attr("d",e).style("stroke","none"):x.select(this).remove()})}function v(t,e){function r(t){return Math.abs(t[1]-e[0][1])<.01}function n(t){return Math.abs(t[1]-e[2][1])<.01}function i(t){return Math.abs(t[0]-e[0][0])<.01}function a(t){return Math.abs(t[0]-e[2][0])<.01}for(var o,s,l,c,u,f,h=t.edgepaths.length||t.z[0][0]l;l++){if(!o){console.log("missing end?",d,t);break}for(r(o)&&!a(o)?s=e[1]:i(o)?s=e[0]:n(o)?s=e[3]:a(o)&&(s=e[2]),u=0;u=0&&(s=v,c=u):Math.abs(o[1]-s[1])<.01?Math.abs(o[1]-v[1])<.01&&(v[0]-o[0])*(s[0]-v[0])>=0&&(s=v,c=u):console.log("endpt to newendpt is not vert. or horz.",o,s,v)}if(o=s,c>=0)break;h+="L"+s}if(c===t.edgepaths.length){console.log("unclosed perimeter path");break}d=c,g=-1===p.indexOf(d),g&&(d=p[0],h+="Z")}for(d=0;de;e++)s.push(1);for(e=0;a>e;e++)i.push(s.slice());for(e=0;eo;o++)for(n=i(l,o),u[o]=new Array(n),s=0;n>s;s++)u[o][s]=e(a(l,o,s));return u}function i(t,e,r,n,i,a){var o,s,l,c=[],u=h.traceIs(t,"contour"),f=h.traceIs(t,"histogram"),d=h.traceIs(t,"gl2d");if(Array.isArray(e)&&!f&&"category"!==a.type){e=e.map(a.d2c);var p=e.length;if(!(i>=p))return u?e.slice(0,i):e.slice(0,i+1);if(u||d)c=e.slice(0,i);else if(1===i)c=[e[0]-.5,e[0]+.5];else{for(c=[1.5*e[0]-.5*e[1]],l=1;p>l;l++)c.push(.5*(e[l-1]+e[l]));c.push(1.5*e[p-1]-.5*e[p-2])}if(i>p){var g=c[c.length-1],v=g-c[c.length-2];for(l=p;i>l;l++)g+=v,c.push(g)}}else for(s=n||1,o=void 0===r?0:f||"category"===a.type?r:a.d2c(r),l=u||d?0:-.5;i>l;l++)c.push(o+s*l);return c}function a(t){return.5-.25*Math.min(1,.5*t)}function o(t,e,r){var n,i,o=1;if(Array.isArray(r))for(n=0;nn&&o>y;n++)o=l(t,e,a(o));return o>y&&console.log("interp2d didn't converge quickly",o),t}function s(t){var e,r,n,i,a,o,s,l,c=[],u={},f=[],h=t[0],d=[],p=[0,0,0],g=m(t);for(r=0;rn;n++)void 0===d[n]&&(o=(void 0!==d[n-1]?1:0)+(void 0!==d[n+1]?1:0)+(void 0!==e[n]?1:0)+(void 0!==h[n]?1:0),o?(0===r&&o++,0===n&&o++,r===t.length-1&&o++,n===d.length-1&&o++,4>o&&(u[[r,n]]=[r,n,o]),c.push([r,n,o])):f.push([r,n]));for(;f.length;){for(s={},l=!1,a=f.length-1;a>=0;a--)i=f[a],r=i[0],n=i[1],o=((u[[r-1,n]]||p)[2]+(u[[r+1,n]]||p)[2]+(u[[r,n-1]]||p)[2]+(u[[r,n+1]]||p)[2])/20,o&&(s[i]=[r,n,o],f.splice(a,1),l=!0);if(!l)throw"findEmpties iterated with no new neighbors";for(i in s)u[i]=s[i],c.push(s[i])}return c.sort(function(t,e){return e[2]-t[2]})}function l(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g,v=0;for(o=0;os;s++)l=b[s],c=t[i+l[0]],c&&(u=c[a+l[1]],void 0!==u&&(0===h?p=g=u:(p=Math.min(p,u),g=Math.max(g,u)),f++,h+=u));if(0===f)throw"iterateInterp2d order is wrong: no defined neighbors";t[i][a]=h/f,void 0===d?4>f&&(v=1):(t[i][a]=(1+r)*t[i][a]-r*d,g>p&&(v=Math.max(v,Math.abs(t[i][a]-d)/(g-p))))}return v}var c=t("fast-isnumeric"),u=t("../../lib"),f=t("../../plots/cartesian/axes"),h=t("../../plots/plots"),d=t("../histogram2d/calc"),p=t("../../components/colorscale/calc"),g=t("./has_columns"),v=t("./convert_column_xyz"),m=t("./max_row_length");e.exports=function(t,e){function r(t){E=e._input.zsmooth=e.zsmooth=!1,u.notifier("cannot fast-zsmooth: "+t)}u.markTime("start convert x&y");var a,l,c,y,b,x,_,w,k=f.getFromId(t,e.xaxis||"x"),A=f.getFromId(t,e.yaxis||"y"),M=h.traceIs(e,"contour"),T=h.traceIs(e,"histogram"),E=M?"best":e.zsmooth;if(k._minDtick=0,A._minDtick=0,u.markTime("done convert x&y"),T){var L=d(t,e);a=L.x,l=L.x0,c=L.dx,y=L.y,b=L.y0,x=L.dy,_=L.z}else g(e)&&v(e,k,A),a=e.x?k.makeCalcdata(e,"x"):[],y=e.y?A.makeCalcdata(e,"y"):[],l=e.x0||0,c=e.dx||1,b=e.y0||0,x=e.dy||1,_=n(e),(M||e.connectgaps)&&(e._emptypoints=s(_),e._interpz=o(_,e._emptypoints,e._interpz));if("fast"===E)if("log"===k.type||"log"===A.type)r("log axis found");else if(!T){if(a.length){var S=(a[a.length-1]-a[0])/(a.length-1),C=Math.abs(S/100);for(w=0;wC){r("x scale is not linear");break}}if(y.length&&"fast"===E){var z=(y[y.length-1]-y[0])/(y.length-1),P=Math.abs(z/100);for(w=0;wP){r("y scale is not linear");break}}}var R=m(_),O="scaled"===e.xtype?"":e.x,I=i(e,O,l,c,R,k),N="scaled"===e.ytype?"":e.y,j=i(e,N,b,x,_.length,A);f.expand(k,I),f.expand(A,j);var F={x:I,y:j,z:_};if(p(e,_,"","z"),M&&e.contours&&"heatmap"===e.contours.coloring){var D="contour"===e.type?"heatmap":"histogram2d";F.xfill=i(D,O,l,c,R,k),F.yfill=i(D,N,b,x,_.length,A)}return[F]};var y=.01,b=[[-1,0],[1,0],[0,-1],[0,1]]},{"../../components/colorscale/calc":310,"../../lib":381,"../../plots/cartesian/axes":403,"../../plots/plots":452,"../histogram2d/calc":531,"./convert_column_xyz":513,"./has_columns":515,"./max_row_length":518,"fast-isnumeric":76}],512:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c="cb"+r.uid,u=s(r.colorscale),f=r.zmin,h=r.zmax;if(i(f)||(f=a.aggNums(Math.min,null,r.z)),i(h)||(h=a.aggNums(Math.max,null,r.z)),t._fullLayout._infolayer.selectAll("."+c).remove(),!r.showscale)return void o.autoMargin(t,c);var d=e[0].t.cb=l(t,c);d.fillcolor(n.scale.linear().domain(u.map(function(t){return f+t[0]*(h-f)})).range(u.map(function(t){return t[1]}))).filllevels({start:f,end:h,size:(h-f)/254}).options(r.colorbar)(),a.markTime("done colorbar")}},{"../../components/colorbar/draw":306,"../../components/colorscale/get_scale":314,"../../lib":381,"../../plots/plots":452,d3:72,"fast-isnumeric":76}],513:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a=t.x.slice(),o=t.y.slice(),s=t.z,l=t.text,c=Math.min(a.length,o.length,s.length),u=void 0!==l&&!Array.isArray(l[0]);for(ci;i++)a[i]=e.d2c(a[i]),o[i]=r.d2c(o[i]);var f,h,d,p=n.distinctVals(a),g=p.vals,v=n.distinctVals(o),m=v.vals,y=n.init2dArray(m.length,g.length);for(u&&(d=n.init2dArray(m.length,g.length)),i=0;c>i;i++)f=n.findBin(a[i]+p.minDiff/2,g),h=n.findBin(o[i]+v.minDiff/2,m),y[h][f]=s[i],u&&(d[h][f]=l[i]);t.x=g,t.y=m,t.z=y,u&&(t.text=d)}},{"../../lib":381}],514:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./has_columns"),a=t("./xyz_defaults"),o=t("../../components/colorscale/defaults"),s=t("./attributes");e.exports=function(t,e,r,l){function c(r,i){return n.coerce(t,e,s,r,i)}var u=a(t,e,c);return u?(c("text"),c("zsmooth"),c("connectgaps",i(e)&&e.zsmooth!==!1),void o(t,e,l,c,{prefix:"",cLetter:"z"})):void(e.visible=!1)}},{"../../components/colorscale/defaults":312,"../../lib":381,"./attributes":510,"./has_columns":515,"./xyz_defaults":521}],515:[function(t,e,r){"use strict";e.exports=function(t){return!Array.isArray(t.z[0])}},{}],516:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../lib");e.exports=function(t,e,r,a,o){if(!(t.distancec||c>=m[0].length||0>u||u>m.length)return}else{if(n.inbox(e-g[0],e-g[g.length-1])>n.MAXDIST||n.inbox(r-v[0],r-v[v.length-1])>n.MAXDIST)return;if(o){var w;for(b=[2*g[0]-g[1]],w=1;w0;)_=v.c2p(C[M]),M--;for(x>_&&(w=_,_=x,x=w,N=!0),M=0;void 0===k&&M0;)A=m.c2p(z[M]),M--;if(k>A&&(w=k,k=A,A=w,j=!0),P&&(C=r[0].xfill,z=r[0].yfill),"fast"!==R){var F="best"===R?0:.5;x=Math.max(-F*v._length,x),_=Math.min((1+F)*v._length,_),k=Math.max(-F*m._length,k),A=Math.min((1+F)*m._length,A)}var D=Math.round(_-x),B=Math.round(A-k);if(!(0>=D||0>=B)){var U,V;"fast"===R?(U=I,V=O):(U=D,V=B);var q=document.createElement("canvas");q.width=U,q.height=V;var H,G,Y=q.getContext("2d"),X=i.scale.linear().domain(S.map(function(t){return t[0]})).range(S.map(function(t){var e=a(t[1]).toRgb();return[e.r,e.g,e.b,e.a]})).clamp(!0);"fast"===R?(H=N?function(t){return I-1-t}:o.identity,G=j?function(t){return O-1-t}:o.identity):(H=function(t){return o.constrain(Math.round(v.c2p(C[t])-x),0,D)},G=function(t){return o.constrain(Math.round(m.c2p(z[t])-k),0,B)});var W,Z,K,$,Q,J,tt=G(0),et=[tt,tt],rt=N?0:1,nt=j?0:1,it=0,at=0,ot=0,st=0;if(o.markTime("done init png"),R){var lt=0,ct=new Uint8Array(D*B*4);if("best"===R){var ut,ft,ht,dt=new Array(C.length),pt=new Array(z.length),gt=new Array(D);for(M=0;MM;M++)gt[M]=n(M,dt);for(Z=0;B>Z;Z++)for(ut=n(Z,pt),ft=T[ut.bin0],ht=T[ut.bin1],M=0;D>M;M++,lt+=4)J=d(ft,ht,gt[M],ut),h(ct,lt,J)}else for(Z=0;O>Z;Z++)for(Q=T[Z],et=G(Z),M=0;I>M;M++)J=f(Q[M],1),lt=4*(et*D+H(M)),h(ct,lt,J);var vt=Y.createImageData(D,B);vt.data.set(ct),Y.putImageData(vt,0,0)}else for(Z=0;O>Z;Z++)if(Q=T[Z],et.reverse(),et[nt]=G(Z+1),et[0]!==et[1]&&void 0!==et[0]&&void 0!==et[1])for(K=H(0),W=[K,K],M=0;I>M;M++)W.reverse(),W[rt]=H(M+1),W[0]!==W[1]&&void 0!==W[0]&&void 0!==W[1]&&($=Q[M],J=f($,(W[1]-W[0])*(et[1]-et[0])),Y.fillStyle="rgba("+J.join(",")+")",Y.fillRect(W[0],et[0],W[1]-W[0],et[1]-et[0]));o.markTime("done filling png"),at=Math.round(at/it),ot=Math.round(ot/it),st=Math.round(st/it);var mt=a("rgb("+at+","+ot+","+st+")");t._hmpixcount=(t._hmpixcount||0)+it,t._hmlumcount=(t._hmlumcount||0)+it*mt.getLuminance();var yt=e.plot.select(".imagelayer").selectAll("g.hm."+b).data([0]);yt.enter().append("g").classed("hm",!0).classed(b,!0),yt.exit().remove();var bt=yt.selectAll("image").data(r);bt.enter().append("svg:image"),bt.exit().remove(),bt.attr({xmlns:c.svg,"xlink:href":q.toDataURL("image/png"),height:B,width:D,x:x,y:k,preserveAspectRatio:"none"}),o.markTime("done showing png")}}var i=t("d3"),a=t("tinycolor2"),o=t("../../lib"),s=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),c=t("../../constants/xmlns_namespaces"),u=t("./max_row_length");e.exports=function(t,e,r){for(var i=0;i0&&(n=!0);for(var s=0;si;i++)e[i]?(t[i]/=e[i],n+=t[i]):t[i]=null;return n}},{}],524:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){return r("histnorm"),n.forEach(function(t){var e=r(t+"bins.start"),n=r(t+"bins.end"),i=r("autobin"+t,!(e&&n));r(i?"nbins"+t:t+"bins.size")}),e}},{}],525:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports={count:function(t,e,r){return r[t]++,1},sum:function(t,e,r,i){var a=i[e];return n(a)?(a=Number(a),r[t]+=a,a):0},avg:function(t,e,r,i,a){var o=i[e];return n(o)&&(o=Number(o),r[t]+=o,a[t]++),0},min:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]>a)return r[t]=a,a-r[t]}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]r&&c.length<5e3;)g=a.tickIncrement(r,b.size),c.push((r+g)/2),u.push(S),x&&_.push(r),E&&w.push(1/(g-r)),P&&k.push(0),r=g;var R=u.length;for(r=0;r=0&&R>m&&(A+=C(m,r,u,y,k));P&&(A=l(u,k)),z&&z(u,A,w);var O=Math.min(c.length,u.length),I=[],N=0,j=O-1;for(r=0;O>r;r++)if(u[r]){N=r;break}for(r=O-1;r>N;r--)if(u[r]){j=r;break}for(r=N;j>=r;r++)n(c[r])&&n(u[r])&&I.push({p:c[r],s:u[r],b:0});return I}}},{"../../lib":381,"../../plots/cartesian/axes":403,"./average":523,"./bin_functions":525,"./norm_functions":529,"fast-isnumeric":76}],527:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("./bin_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=u("x"),h=u("y");u("text");var d=u("orientation",h&&!f?"h":"v"),p=e["v"===d?"x":"y"];if(!p||!p.length)return void(e.visible=!1);var g=e["h"===d?"x":"y"];g&&u("histfunc");var v="h"===d?["y"]:["x"];a(t,e,u,v),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),s(t,e,i.defaultLine,{axis:"x",inherit:"y"})}},{"../../components/color":303,"../../components/errorbars/defaults":330,"../../lib":381,"../bar/style_defaults":484,"./attributes":522,"./bin_defaults":524}],528:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("../bar/layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("../bar/layout_defaults"),n.calc=t("./calc"),n.setPositions=t("../bar/set_positions"),n.plot=t("../bar/plot"),n.style=t("../bar/style"),n.colorbar=t("../scatter/colorbar"),n.hoverPoints=t("../bar/hover"),n.moduleType="trace",n.name="histogram",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","histogram","oriented","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":411,"../bar/hover":477,"../bar/layout_attributes":479,"../bar/layout_defaults":480,"../bar/plot":481,"../bar/set_positions":482,"../bar/style":483,"../scatter/colorbar":557,"./attributes":522,"./calc":526,"./defaults":527}],529:[function(t,e,r){"use strict";e.exports={percent:function(t,e){for(var r=t.length,n=100/e,i=0;r>i;i++)t[i]*=n},probability:function(t,e){for(var r=t.length,n=0;r>n;n++)t[n]/=e},density:function(t,e,r,n){var i=t.length;n=n||1;for(var a=0;i>a;a++)t[a]*=r[a]*n},"probability density":function(t,e,r,n){var i=t.length;n&&(e/=n);for(var a=0;i>a;a++)t[a]*=r[a]/e}}},{}],530:[function(t,e,r){"use strict";var n=t("../histogram/attributes"),i=t("../heatmap/attributes");e.exports={x:n.x,y:n.y,z:{valType:"data_array"},marker:{color:{valType:"data_array"}},histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zauto:i.zauto,zmin:i.zmin,zmax:i.zmax,colorscale:i.colorscale,autocolorscale:i.autocolorscale,reversescale:i.reversescale,showscale:i.showscale,zsmooth:i.zsmooth,_nestedModules:{colorbar:"Colorbar"}}},{"../heatmap/attributes":510,"../histogram/attributes":522}],531:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("../histogram/bin_functions"),o=t("../histogram/norm_functions"),s=t("../histogram/average");e.exports=function(t,e){var r,l,c,u,f,h,d=i.getFromId(t,e.xaxis||"x"),p=e.x?d.makeCalcdata(e,"x"):[],g=i.getFromId(t,e.yaxis||"y"),v=e.y?g.makeCalcdata(e,"y"):[],m=Math.min(p.length,v.length);p.length>m&&p.splice(m,p.length-m),v.length>m&&v.splice(m,v.length-m),n.markTime("done convert data"),!e.autobinx&&"xbins"in e||(e.xbins=i.autoBin(p,d,e.nbinsx,"2d"),"histogram2dcontour"===e.type&&(e.xbins.start-=e.xbins.size,e.xbins.end+=e.xbins.size),e._input.xbins=e.xbins),!e.autobiny&&"ybins"in e||(e.ybins=i.autoBin(v,g,e.nbinsy,"2d"),"histogram2dcontour"===e.type&&(e.ybins.start-=e.ybins.size,e.ybins.end+=e.ybins.size),e._input.ybins=e.ybins),n.markTime("done autoBin"),f=[];var y,b,x=[],_=[],w="string"==typeof e.xbins.size?[]:e.xbins,k="string"==typeof e.xbins.size?[]:e.ybins,A=0,M=[],T=e.histnorm,E=e.histfunc,L=-1!==T.indexOf("density"),S="max"===E||"min"===E,C=S?null:0,z=a.count,P=o[T],R=!1,O=[],I=[],N="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";N&&"count"!==E&&(R="avg"===E,z=a[E]);var j=e.xbins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6;for(h=j.start;F>h;h=i.tickIncrement(h,j.size))x.push(C),Array.isArray(w)&&w.push(h),R&&_.push(0);Array.isArray(w)&&w.push(h);var D=x.length;for(r=e.xbins.start,l=(h-r)/D,r+=l/2,j=e.ybins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6,h=j.start;F>h;h=i.tickIncrement(h,j.size))f.push(x.concat()),Array.isArray(k)&&k.push(h),R&&M.push(_.concat());Array.isArray(k)&&k.push(h);var B=f.length;for(c=e.ybins.start,u=(h-c)/B,c+=u/2,L&&(O=x.map(function(t,e){return Array.isArray(w)?1/(w[e+1]-w[e]):1/l}),I=f.map(function(t,e){return Array.isArray(k)?1/(k[e+1]-k[e]):1/u})),n.markTime("done making bins"),h=0;m>h;h++)y=n.findBin(p[h],w),b=n.findBin(v[h],k),y>=0&&D>y&&b>=0&&B>b&&(A+=z(y,h,f[b],N,M[b]));if(R)for(b=0;B>b;b++)A+=s(f[b],M[b]);if(P)for(b=0;B>b;b++)P(f[b],A,O,I[b]);return n.markTime("done binning"),{x:p,x0:r,dx:l,y:v,y0:c,dy:u,z:f}}},{"../../lib":381,"../../plots/cartesian/axes":403,"../histogram/average":523,"../histogram/bin_functions":525,"../histogram/norm_functions":529}],532:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./sample_defaults"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r){function s(r,i){return n.coerce(t,e,o,r,i)}i(t,e,s),s("zsmooth"),a(t,e,r,s,{prefix:"",cLetter:"z"})}},{"../../components/colorscale/defaults":312,"../../lib":381,"./attributes":530,"./sample_defaults":534}],533:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../heatmap/calc"),n.plot=t("../heatmap/plot"),n.colorbar=t("../heatmap/colorbar"),n.style=t("../heatmap/style"),n.hoverPoints=t("../heatmap/hover"),n.moduleType="trace",n.name="histogram2d",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":411,"../heatmap/calc":511,"../heatmap/colorbar":512,"../heatmap/hover":516,"../heatmap/plot":519,"../heatmap/style":520,"./attributes":530,"./defaults":532}],534:[function(t,e,r){"use strict";var n=t("../histogram/bin_defaults");e.exports=function(t,e,r){var i=r("x"),a=r("y");if(!(i&&i.length&&a&&a.length))return void(e.visible=!1);var o=r("z")||r("marker.color");o&&r("histfunc");var s=["x","y"];n(t,e,r,s)}},{"../histogram/bin_defaults":524}],535:[function(t,e,r){"use strict";var n=t("../histogram2d/attributes"),i=t("../contour/attributes");e.exports={x:n.x,y:n.y,z:n.z,marker:n.marker,histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zauto:i.zauto,zmin:i.zmin,zmax:i.zmax,colorscale:i.colorscale,autocolorscale:i.autocolorscale,reversescale:i.reversescale,showscale:i.showscale,autocontour:i.autocontour,ncontours:i.ncontours,contours:i.contours,line:i.line,_nestedModules:{colorbar:"Colorbar"}}},{"../contour/attributes":500,"../histogram2d/attributes":530}],536:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../histogram2d/sample_defaults"),a=t("../contour/style_defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,i){return n.coerce(t,e,o,r,i)}i(t,e,l);var c=n.coerce2(t,e,o,"contours.start"),u=n.coerce2(t,e,o,"contours.end"),f=l("autocontour",!(c&&u));l(f?"ncontours":"contours.size"),a(t,e,l,s)}},{"../../lib":381,"../contour/style_defaults":509,"../histogram2d/sample_defaults":534,"./attributes":535}],537:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../contour/calc"),n.plot=t("../contour/plot"),n.style=t("../contour/style"),n.colorbar=t("../contour/colorbar"),n.hoverPoints=t("../contour/hover"),n.moduleType="trace",n.name="histogram2dcontour",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","contour","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":411,"../contour/calc":501,"../contour/colorbar":502,"../contour/hover":504,"../contour/plot":507,"../contour/style":508,"./attributes":535,"./defaults":536}],538:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../surface/attributes"),a=t("../../lib/extend").extendFlat;e.exports={x:{valType:"data_array"},y:{valType:"data_array"},z:{valType:"data_array"},i:{valType:"data_array"},j:{valType:"data_array"},k:{valType:"data_array"},delaunayaxis:{valType:"enumerated",values:["x","y","z"],dflt:"z"},alphahull:{valType:"number",dflt:-1},intensity:{valType:"data_array"},color:{valType:"color"},vertexcolor:{valType:"data_array"},facecolor:{valType:"data_array"},opacity:a({},i.opacity),flatshading:{valType:"boolean",dflt:!1},contour:{show:a({},i.contours.x.show,{}),color:a({},i.contours.x.color),width:a({},i.contours.x.width)},colorscale:n.colorscale,reversescale:n.reversescale,showscale:n.showscale,lighting:a({},i.lighting),_nestedModules:{colorbar:"Colorbar"}}},{"../../components/colorscale/attributes":309,"../../lib/extend":376,"../surface/attributes":599}],539:[function(t,e,r){"use strict";function n(t,e,r){this.scene=t,this.uid=r,this.mesh=e,this.name="",this.color="#fff",this.data=null,this.showContour=!1}function i(t){return t.map(function(t){var e=t[0],r=c(t[1]),n=r.toRgb();return{index:e,rgb:[n.r,n.g,n.b,1]}})}function a(t){return t.map(d)}function o(t,e,r){for(var n=new Array(t.length),i=0;i0)s=f(t.alphahull,l);else{var c=["x","y","z"].indexOf(t.delaunayaxis);s=u(l.map(function(t){return[t[(c+1)%3],t[(c+2)%3]]}))}var p={positions:l,cells:s,ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,opacity:t.opacity,contourEnable:t.contour.show,contourColor:d(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",p.vertexIntensity=t.intensity,p.colormap=i(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolors[0],p.vertexColors=a(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],p.cellColors=a(t.facecolor)):(this.color=t.color,p.meshColor=d(t.color)),this.mesh.update(p)},p.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=s},{"../../lib/str2rgbarray":392,"alpha-shape":40,"convex-hull":61,"delaunay-triangulate":73,"gl-mesh3d":109,tinycolor2:233}],540:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/colorbar/defaults"),a=t("./attributes");e.exports=function(t,e,r,o){function s(r,i){return n.coerce(t,e,a,r,i)}function l(t){var e=t.map(function(t){var e=s(t);return e&&Array.isArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var c=l(["x","y","z"]),u=l(["i","j","k"]);return c?(u&&u.forEach(function(t){for(var e=0;el||(c=p[r],void 0!==c&&""!==c||(c=r),c=String(c),void 0===y[c]&&(y[c]=!0,u=a(e.marker.colors[r]),u.isValid()?(u=o.addOpacity(u,u.getAlpha()),m[c]||(m[c]=u)):m[c]?u=m[c]:(u=!1,b=!0),f=-1!==_.indexOf(c),f||(x+=l),g.push({v:l,label:c,color:u,i:r,hidden:f}))));if(e.sort&&g.sort(function(t,e){return e.v-t.v}),b)for(r=0;r")}return g};var l},{"../../components/color":303,"./helpers":546,"fast-isnumeric":76,tinycolor2:233}],545:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(r,a){return n.coerce(t,e,i,r,a)}var s=n.coerceFont,l=o("values");if(!Array.isArray(l)||!l.length)return void(e.visible=!1);var c=o("labels");Array.isArray(c)||(o("label0"),o("dlabel"));var u=o("marker.line.width");u&&o("marker.line.color");var f=o("marker.colors");Array.isArray(f)||(e.marker.colors=[]),o("scalegroup");var h=o("text"),d=o("textinfo",Array.isArray(h)?"text+percent":"percent");if(o("hoverinfo",1===a._dataLength?"label+text+value+percent":void 0),d&&"none"!==d){var p=o("textposition"),g=Array.isArray(p)||"auto"===p,v=g||"inside"===p,m=g||"outside"===p;if(v||m){var y=s(o,"textfont",a.font);v&&s(o,"insidetextfont",y),m&&s(o,"outsidetextfont",y)}}o("domain.x"),o("domain.y"),o("hole"),o("sort"),o("direction"),o("rotation"),o("pull")}},{"../../lib":381,"./attributes":542}],546:[function(t,e,r){"use strict";r.formatPiePercent=function(t){var e=(100*t).toPrecision(3);return-1!==e.indexOf(".")?e.replace(/[.]?0+$/,"")+"%":e+"%"},r.formatPieValue=function(t){var e=t.toPrecision(10);return-1!==e.indexOf(".")?e.replace(/[.]?0+$/,""):e}},{}],547:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.layoutAttributes=t("./layout_attributes"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.styleOne=t("./style_one"),n.moduleType="trace",n.name="pie",n.basePlotModule=t("./base_plot"),n.categories=["pie","showLegend"],n.meta={},e.exports=n},{"./attributes":542,"./base_plot":543,"./calc":544,"./defaults":545,"./layout_attributes":548,"./layout_defaults":549,"./plot":550,"./style":551,"./style_one":552}],548:[function(t,e,r){"use strict";e.exports={hiddenlabels:{valType:"data_array"}}},{}],549:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e){function r(r,a){return n.coerce(t,e,i,r,a)}r("hiddenlabels")}},{"../../lib":381,"./layout_attributes":548}],550:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,o=Math.PI*Math.min(e.v/r.vTotal,.5),s=1-r.trace.hole,l=i(e,r),c={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(c.scale>=1)return c;var u=a+1/(2*Math.tan(o)),f=r.r*Math.min(1/(Math.sqrt(u*u+.5)+u),s/(Math.sqrt(a*a+s/2)+a)),h={scale:2*f/t.height,rCenter:Math.cos(f/r.r)-f*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},d=1/a,p=d+1/(2*Math.tan(o)),g=r.r*Math.min(1/(Math.sqrt(p*p+.5)+p),s/(Math.sqrt(d*d+s/2)+d)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},m=v.scale>h.scale?v:h;return c.scale<1&&m.scale>c.scale?m:c}function i(t,e){if(t.v===e.vTotal&&!e.trace.hole)return 1;var r=Math.PI*Math.min(t.v/e.vTotal,.5);return Math.min(1/(1+1/Math.sin(r)),(1-e.trace.hole)/2)}function a(t,e){var r=e.pxmid[0],n=e.pxmid[1],i=t.width/2,a=t.height/2;return 0>r&&(i*=-1),0>n&&(a*=-1),{scale:1,rCenter:1,rotate:0,x:i+Math.abs(a)*(i>0?1:-1)/2,y:a/(1+r*r/(n*n)),outside:!0}}function o(t,e){function r(t,e){return t.pxmid[1]-e.pxmid[1]}function n(t,e){return e.pxmid[1]-t.pxmid[1]}function i(t,r){r||(r={});var n,i,a,s,h,d,g=r.labelExtraY+(o?r.yLabelMax:r.yLabelMin),v=o?t.yLabelMin:t.yLabelMax,m=o?t.yLabelMax:t.yLabelMin,y=t.cyFinal+c(t.px0[1],t.px1[1]),b=g-v;if(b*f>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(i=0;i=e.pull[a.i]||((t.pxmid[1]-a.pxmid[1])*f>0?(s=a.cyFinal+c(a.px0[1],a.px1[1]),b=s-v-t.labelExtraY,b*f>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-y)*f>0&&(n=3*u*Math.abs(i-p.indexOf(t)),h=a.cxFinal+l(a.px0[0],a.px1[0]),d=h+n-(t.cxFinal+t.pxmid[0])-t.labelExtraX,d*u>0&&(t.labelExtraX+=d)))}var a,o,s,l,c,u,f,h,d,p,g,v,m;for(o=0;2>o;o++)for(s=o?r:n,c=o?Math.max:Math.min,f=o?1:-1,a=0;2>a;a++){for(l=a?Math.max:Math.min,u=a?1:-1,h=t[o][a],h.sort(s),d=t[1-o][a],p=d.concat(h),v=[],g=0;gu&&(u=s.pull[a]);o.r=Math.min(r/c(s.tilt,Math.sin(l),s.depth),n/c(s.tilt,Math.cos(l),s.depth))/(2+2*u),o.cx=e.l+e.w*(s.domain.x[1]+s.domain.x[0])/2,o.cy=e.t+e.h*(2-s.domain.y[1]-s.domain.y[0])/2,s.scalegroup&&-1===d.indexOf(s.scalegroup)&&d.push(s.scalegroup)}for(a=0;af.vTotal/2?1:0)}function c(t,e,r){if(!t)return 1;var n=Math.sin(t*Math.PI/180);return Math.max(.01,r*n*Math.abs(e)+2*Math.sqrt(1-n*n*e*e))}var u=t("d3"),f=t("../../plots/cartesian/graph_interact"),h=t("../../components/color"),d=t("../../components/drawing"),p=t("../../lib/svg_text_utils"),g=t("./helpers");e.exports=function(t,e){var r=t._fullLayout;s(e,r._size);var c=r._pielayer.selectAll("g.trace").data(e);c.enter().append("g").attr({"stroke-linejoin":"round","class":"trace"}),c.exit().remove(),c.order(),c.each(function(e){var s=u.select(this),c=e[0],v=c.trace,m=0,y=(v.depth||0)*c.r*Math.sin(m)/2,b=v.tiltaxis||0,x=b*Math.PI/180,_=[y*Math.sin(x),y*Math.cos(x)],w=c.r*Math.cos(m),k=s.selectAll("g.part").data(v.tilt?["top","sides"]:["top"]);k.enter().append("g").attr("class",function(t){return t+" part"}),k.exit().remove(),k.order(),l(e),s.selectAll(".top").each(function(){var s=u.select(this).selectAll("g.slice").data(e);s.enter().append("g").classed("slice",!0),s.exit().remove();var l=[[[],[]],[[],[]]],m=!1;s.each(function(o){function s(e){var r=t._fullLayout,n=t._fullData[v.index],a=n.hoverinfo;if("all"===a&&(a="label+text+value+percent+name"),!t._dragging&&r.hovermode!==!1&&"none"!==a&&a){var s=i(o,c),l=k+o.pxmid[0]*(1-s),u=A+o.pxmid[1]*(1-s),h=[];-1!==a.indexOf("label")&&h.push(o.label),n.text&&n.text[o.i]&&-1!==a.indexOf("text")&&h.push(n.text[o.i]),-1!==a.indexOf("value")&&h.push(g.formatPieValue(o.v)),-1!==a.indexOf("percent")&&h.push(g.formatPiePercent(o.v/c.vTotal)),f.loneHover({x0:l-s*c.r,x1:l+s*c.r,y:u,text:h.join("
"),name:-1!==a.indexOf("name")?n.name:void 0,color:o.color,idealAlign:o.pxmid[0]<0?"left":"right"},{container:r._hoverlayer.node(),outerContainer:r._paper.node()}),f.hover(t,e,"pie"),E=!0}}function h(e){t.emit("plotly_unhover",{points:[e]}),E&&(f.loneUnhover(r._hoverlayer.node()),E=!1)}function y(){t._hoverdata=[o],t._hoverdata.trace=e.trace,f.click(t,{target:!0})}function x(t,e,r,n){return"a"+n*c.r+","+n*w+" "+b+" "+o.largeArc+(r?" 1 ":" 0 ")+n*(e[0]-t[0])+","+n*(e[1]-t[1])}if(o.hidden)return void u.select(this).selectAll("path,g").remove();l[o.pxmid[1]<0?0:1][o.pxmid[0]<0?0:1].push(o);var k=c.cx+_[0],A=c.cy+_[1],M=u.select(this),T=M.selectAll("path.surface").data([o]),E=!1;if(T.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),M.select("path.textline").remove(),M.on("mouseover",s).on("mouseout",h).on("click",y),v.pull){var L=+(Array.isArray(v.pull)?v.pull[o.i]:v.pull)||0;L>0&&(k+=L*o.pxmid[0],A+=L*o.pxmid[1])}o.cxFinal=k,o.cyFinal=A;var S=v.hole;if(o.v===c.vTotal){var C="M"+(k+o.px0[0])+","+(A+o.px0[1])+x(o.px0,o.pxmid,!0,1)+x(o.pxmid,o.px0,!0,1)+"Z";S?T.attr("d","M"+(k+S*o.px0[0])+","+(A+S*o.px0[1])+x(o.px0,o.pxmid,!1,S)+x(o.pxmid,o.px0,!1,S)+"Z"+C):T.attr("d",C)}else{var z=x(o.px0,o.px1,!0,1);if(S){var P=1-S;T.attr("d","M"+(k+S*o.px1[0])+","+(A+S*o.px1[1])+x(o.px1,o.px0,!1,S)+"l"+P*o.px0[0]+","+P*o.px0[1]+z+"Z")}else T.attr("d","M"+k+","+A+"l"+o.px0[0]+","+o.px0[1]+z+"Z")}var R=Array.isArray(v.textposition)?v.textposition[o.i]:v.textposition,O=M.selectAll("g.slicetext").data(o.text&&"none"!==R?[0]:[]);O.enter().append("g").classed("slicetext",!0),O.exit().remove(),O.each(function(){var t=u.select(this).selectAll("text").data([0]);t.enter().append("text").attr("data-notex",1),t.exit().remove(),t.text(o.text).attr({"class":"slicetext",transform:"","data-bb":"","text-anchor":"middle",x:0,y:0}).call(d.font,"outside"===R?v.outsidetextfont:v.insidetextfont).call(p.convertToTspans),t.selectAll("tspan.line").attr({x:0,y:0});var e,r=d.bBox(t.node());"outside"===R?e=a(r,o):(e=n(r,o,c),"auto"===R&&e.scale<1&&(t.call(d.font,v.outsidetextfont),v.outsidetextfont.family===v.insidetextfont.family&&v.outsidetextfont.size===v.insidetextfont.size||(t.attr({"data-bb":""}),r=d.bBox(t.node())),e=a(r,o)));var i=k+o.pxmid[0]*e.rCenter+(e.x||0),s=A+o.pxmid[1]*e.rCenter+(e.y||0);e.outside&&(o.yLabelMin=s-r.height/2,o.yLabelMid=s,o.yLabelMax=s+r.height/2,o.labelExtraX=0,o.labelExtraY=0,m=!0),t.attr("transform","translate("+i+","+s+")"+(e.scale<1?"scale("+e.scale+")":"")+(e.rotate?"rotate("+e.rotate+")":"")+"translate("+-(r.left+r.right)/2+","+-(r.top+r.bottom)/2+")")})}),m&&o(l,v),s.each(function(t){if(t.labelExtraX||t.labelExtraY){var e=u.select(this),r=e.select("g.slicetext text");r.attr("transform","translate("+t.labelExtraX+","+t.labelExtraY+")"+r.attr("transform"));var n=t.cxFinal+t.pxmid[0],i=t.cyFinal+t.pxmid[1],a="M"+n+","+i,o=(t.yLabelMax-t.yLabelMin)*(t.pxmid[0]<0?-1:1)/4;if(t.labelExtraX){var s=t.labelExtraX*t.pxmid[1]/t.pxmid[0],l=t.yLabelMid+t.labelExtraY-(t.cyFinal+t.pxmid[1]);a+=Math.abs(s)>Math.abs(l)?"l"+l*t.pxmid[0]/t.pxmid[1]+","+l+"H"+(n+t.labelExtraX+o):"l"+t.labelExtraX+","+s+"v"+(l-s)+"h"+o}else a+="V"+(t.yLabelMid+t.labelExtraY)+"h"+o;e.append("path").classed("textline",!0).call(h.stroke,v.outsidetextfont.color).attr({"stroke-width":Math.min(2,v.outsidetextfont.size/8),d:a,fill:"none"})}})})}),setTimeout(function(){c.selectAll("tspan").each(function(){var t=u.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":303,"../../components/drawing":325,"../../lib/svg_text_utils":393,"../../plots/cartesian/graph_interact":410,"./helpers":546,d3:72}],551:[function(t,e,r){"use strict";var n=t("d3"),i=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0],r=e.trace,a=n.select(this);a.style({opacity:r.opacity}),a.selectAll(".top path.surface").each(function(t){n.select(this).call(i,t,r)})})}},{"./style_one":552,d3:72}],552:[function(t,e,r){"use strict";var n=t("../../components/color");e.exports=function(t,e,r){var i=r.marker.line.color;Array.isArray(i)&&(i=i[e.i]||n.defaultLine);var a=r.marker.line.width||0;Array.isArray(a)&&(a=a[e.i]||0),t.style({"stroke-width":a,fill:e.color}).call(n.stroke,i)}},{"../../components/color":303}],553:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t){var e=t[0].trace,r=e.marker;if(n.mergeArray(e.text,t,"tx"),n.mergeArray(e.textposition,t,"tp"),e.textfont&&(n.mergeArray(e.textfont.size,t,"ts"),n.mergeArray(e.textfont.color,t,"tc"),n.mergeArray(e.textfont.family,t,"tf")),r&&r.line){var i=r.line;n.mergeArray(r.opacity,t,"mo"),n.mergeArray(r.symbol,t,"mx"),n.mergeArray(r.color,t,"mc"),n.mergeArray(i.color,t,"mlc"),n.mergeArray(i.width,t,"mlw")}}},{"../../lib":381}],554:[function(t,e,r){"use strict";var n=t("../../components/drawing");t("./constants");e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number",min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:{symbol:{valType:"enumerated",values:n.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},color:{valType:"color",arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number",dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},colorscale:{valType:"colorscale"},cauto:{valType:"boolean",dflt:!0},cmax:{valType:"number",dflt:null},cmin:{valType:"number",dflt:null},autocolorscale:{valType:"boolean",dflt:!0},reversescale:{valType:"boolean",dflt:!1},showscale:{valType:"boolean",dflt:!1},line:{color:{valType:"color",arrayOk:!0},width:{valType:"number",min:0,arrayOk:!0},colorscale:{ +valType:"colorscale"},cauto:{valType:"boolean",dflt:!0},cmax:{valType:"number",dflt:null},cmin:{valType:"number",dflt:null},autocolorscale:{valType:"boolean",dflt:!0},reversescale:{valType:"boolean",dflt:!1}}},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:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/drawing":325,"./constants":558}],555:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./subtypes"),s=t("./marker_colorscale_calc");e.exports=function(t,e){var r=i.getFromId(t,e.xaxis||"x"),l=i.getFromId(t,e.yaxis||"y");a.markTime("in Scatter.calc");var c=r.makeCalcdata(e,"x");a.markTime("finished convert x");var u=l.makeCalcdata(e,"y");a.markTime("finished convert y");var f,h,d,p=Math.min(c.length,u.length);r._minDtick=0,l._minDtick=0,c.length>p&&c.splice(p,c.length-p),u.length>p&&u.splice(p,u.length-p);var g={padded:!0},v={padded:!0};if(o.hasMarkers(e)){if(f=e.marker,h=f.size,Array.isArray(h)){var m={type:"linear"};i.setConvert(m),h=m.makeCalcdata(e.marker,"size"),h.length>p&&h.splice(p,h.length-p)}var y,b=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/b),3)}:function(t){return Math.max((t||0)/b,3)},g.ppad=v.ppad=Array.isArray(h)?h.map(y):y(h)}s(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||c[0]===c[p-1]&&u[0]===u[p-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(o.hasMarkers(e)||o.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||c[0]===c[p-1]&&u[0]===u[p-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(v.padded=!1):v.tozero=!0,a.markTime("ready for Axes.expand"),i.expand(r,c,g),a.markTime("done expand x"),i.expand(l,u,v),a.markTime("done expand y");var x=new Array(p);for(d=0;p>d;d++)x[d]=n(c[d])&&n(u[d])?{x:c[d],y:u[d]}:{x:!1,y:!1};return void 0!==typeof h&&a.mergeArray(h,x,"ms"),t.firstscatter=!1,x}},{"../../lib":381,"../../plots/cartesian/axes":403,"./marker_colorscale_calc":568,"./subtypes":573,"fast-isnumeric":76}],556:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i,a;for(e=0;e=0;i--)if(a=t[i],"scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}},{}],557:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c=r.marker,u="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void o.autoMargin(t,u);var f=s(c.colorscale),h=c.color,d=c.cmin,p=c.cmax;i(d)||(d=a.aggNums(Math.min,null,h)),i(p)||(p=a.aggNums(Math.max,null,h));var g=e[0].t.cb=l(t,u);g.fillcolor(n.scale.linear().domain(f.map(function(t){return d+t[0]*(p-d)})).range(f.map(function(t){return t[1]}))).filllevels({start:d,end:p,size:(p-d)/254}).options(c.colorbar)(),a.markTime("done colorbar")}},{"../../components/colorbar/draw":306,"../../components/colorscale/get_scale":314,"../../lib":381,"../../plots/plots":452,d3:72,"fast-isnumeric":76}],558:[function(t,e,r){"use strict";e.exports={PTS_LINESONLY:20}},{}],559:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("./constants"),o=t("./subtypes"),s=t("./xy_defaults"),l=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),h=t("./fillcolor_defaults"),d=t("../../components/errorbars/defaults");e.exports=function(t,e,r,p){function g(r,a){return n.coerce(t,e,i,r,a)}var v=s(t,e,g),m=vi(f))break;l=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,c=f,d=!1):m>y&&(m=y,u=f,d=!0)}if(d?(C[z++]=c,l!==u&&(C[z++]=u)):(u!==s&&(C[z++]=u),l!==c&&(C[z++]=c)),C[z++]=l,o>=t.length||!f)break;C[z++]=f,s=f}}else C[z++]=c}E.push(C.slice(0,z))}return E}},{"../../plots/cartesian/axes":403}],566:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=r("line.shape");"spline"===n&&r("line.smoothing")}},{}],567:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t){var e=t.marker,r=e.sizeref||1,i=e.sizemin||0,a="area"===e.sizemode?function(t){return Math.sqrt(t/r)}:function(t){return t/r};return function(t){var e=a(t/2);return n(e)&&e>0?Math.max(e,i):0}}},{"fast-isnumeric":76}],568:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("./subtypes");e.exports=function(t){if(a.hasMarkers(t)){var e=t.marker;n(t,"marker")&&i(t,e.color,"marker","c"),n(t,"marker.line")&&i(t,e.line.color,"marker.line","c")}}},{"../../components/colorscale/calc":310,"../../components/colorscale/has_colorscale":315,"./subtypes":573}],569:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l){var c,u=o.isBubble(t),f=(t.line||{}).color;f&&(r=f),l("marker.symbol"),l("marker.opacity",u?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),c=f&&e.marker.color!==f?f:u?n.background:n.defaultLine,l("marker.line.color",c),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",u?1:0),u&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode"))}},{"../../components/color":303,"../../components/colorscale/defaults":312,"../../components/colorscale/has_colorscale":315,"./subtypes":573}],570:[function(t,e,r){"use strict";function n(t,e,r){var n=e.x(),a=e.y(),o=i.extent(n.range.map(n.l2c)),s=i.extent(a.range.map(a.l2c));r.forEach(function(t,e){var n=t[0].trace;if(l.hasMarkers(n)){var i=n.marker.maxdisplayed;if(0!==i){var a=t.filter(function(t){return t.x>=o[0]&&t.x<=o[1]&&t.y>=s[0]&&t.y<=s[1]}),c=Math.ceil(a.length/i),u=0;r.forEach(function(t,r){var n=t[0].trace;l.hasMarkers(n)&&n.marker.maxdisplayed>0&&e>r&&u++});var f=Math.round(u*c/3+Math.floor(u/3)*c/7.1);t.forEach(function(t){delete t.vis}),a.forEach(function(t,e){0===Math.round((e+f)%c)&&(t.vis=!0)})}}})}var i=t("d3"),a=t("../../lib"),o=t("../../components/drawing"),s=t("../../components/errorbars"),l=t("./subtypes"),c=t("./arrays_to_calcdata"),u=t("./line_points");e.exports=function(t,e,r){function f(t){return t.filter(function(t){return t.vis})}n(t,e,r);var h=e.x(),d=e.y(),p=e.plot.select(".scatterlayer").selectAll("g.trace.scatter").data(r);p.enter().append("g").attr("class","trace scatter").style("stroke-miterlimit",2),p.call(s.plot,e);var g,v,m,y,b="";p.each(function(t){var e=t[0].trace,r=e.line,n=i.select(this);if(e.visible===!0&&(v=e.fill.charAt(e.fill.length-1),"x"!==v&&"y"!==v&&(v=""),t[0].node3=n,c(t),l.hasLines(e)||"none"!==e.fill)){var a,s,f,p,x,_="",w="";g="tozero"===e.fill.substr(0,6)||"toself"===e.fill||"to"===e.fill.substr(0,2)&&!b?n.append("path").classed("js-fill",!0):null,y&&(m=y.datum(t)),y=n.append("path").classed("js-fill",!0),-1!==["hv","vh","hvh","vhv"].indexOf(r.shape)?(f=o.steps(r.shape),p=o.steps(r.shape.split("").reverse().join(""))):f=p="spline"===r.shape?function(t){var e=t[t.length-1];return t[0][0]===e[0]&&t[0][1]===e[1]?o.smoothclosed(t.slice(1),r.smoothing):o.smoothopen(t,r.smoothing)}:function(t){return"M"+t.join("L")},x=function(t){return p(t.reverse())};var k=u(t,{xaxis:h,yaxis:d,connectGaps:e.connectgaps,baseTolerance:Math.max(r.width||1,3)/4,linear:"linear"===r.shape});if(k.length){for(var A=k[0][0],M=k[k.length-1],T=M[M.length-1],E=0;E1&&n.append("path").classed("js-line",!0).attr("d",a)}g?A&&T&&(v?("y"===v?A[1]=T[1]=d.c2p(0,!0):"x"===v&&(A[0]=T[0]=h.c2p(0,!0)),g.attr("d",_+"L"+T+"L"+A+"Z")):g.attr("d",_+"Z")):"tonext"===e.fill.substr(0,6)&&_&&b&&("tonext"===e.fill?m.attr("d",_+"Z"+b+"Z"):m.attr("d",_+"L"+b.substr(1)+"Z")),b=w}}}),p.selectAll("path:not([d])").remove(),p.append("g").attr("class","points").each(function(t){var e=t[0].trace,r=i.select(this),n=l.hasMarkers(e),s=l.hasText(e);!n&&!s||e.visible!==!0?r.remove():(n&&r.selectAll("path.point").data(e.marker.maxdisplayed?f:a.identity).enter().append("path").classed("point",!0).call(o.translatePoints,h,d),s&&r.selectAll("g").data(e.marker.maxdisplayed?f:a.identity).enter().append("g").append("text").call(o.translatePoints,h,d))})}},{"../../components/drawing":325,"../../components/errorbars":331,"../../lib":381,"./arrays_to_calcdata":553,"./line_points":565,"./subtypes":573,d3:72}],571:[function(t,e,r){"use strict";var n=t("./subtypes"),i=.2;e.exports=function(t,e){var r,a,o,s,l=t.cd,c=t.xaxis,u=t.yaxis,f=[],h=l[0].trace,d=h.index,p=h.marker;if(n.hasMarkers(h)||n.hasText(h)){var g=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(r=0;rs;s++){for(var l=[[0,0,0],[0,0,0]],c=0;3>c;c++)if(r[c])for(var u=0;2>u;u++)l[u][c]=r[c][s][u];o[s]=l}return o}var o=t("../../components/errorbars/compute_error");e.exports=a},{"../../components/errorbars/compute_error":329}],579:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.linePlot=null,this.scatterPlot=null,this.errorBars=null,this.textMarkers=null,this.delaunayMesh=null,this.color=null,this.mode="",this.dataPoints=[],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.textLabels=null,this.data=null}function i(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],s=[];for(n=0;ni;i++){var a=t[i];a&&a.copy_zstyle!==!1&&(a=t[2]),a&&(e[i]=a.width/2,r[i]=b(a.color),n=a.thickness)}return{capSize:e,color:r,lineWidth:n}}function o(t){var e=[0,0];return Array.isArray(t)?[0,-1]:(t.indexOf("bottom")>=0&&(e[1]+=1),t.indexOf("top")>=0&&(e[1]-=1),t.indexOf("left")>=0&&(e[0]-=1),t.indexOf("right")>=0&&(e[0]+=1),e)}function s(t,e){return e(4*t)}function l(t){return k[t]}function c(t,e,r,n,i){var a=null;if(Array.isArray(t)){a=[];for(var o=0;e>o;o++)void 0===t[o]?a[o]=n:a[o]=r(t[o],i)}else a=r(t,y.identity);return a}function u(t,e){var r,n,i,u,f,h,d=[],p=t.fullSceneLayout,g=t.dataScale,v=p.xaxis,m=p.yaxis,w=p.zaxis,k=e.marker,M=e.line,T=e.x||[],E=e.y||[],L=e.z||[],S=T.length;for(n=0;S>n;n++)i=v.d2l(T[n])*g[0],u=m.d2l(E[n])*g[1],f=w.d2l(L[n])*g[2],d[n]=[i,u,f];if(Array.isArray(e.text))h=e.text;else if(void 0!==e.text)for(h=new Array(S),n=0;S>n;n++)h[n]=e.text;if(r={position:d,mode:e.mode,text:h},"line"in e&&(r.lineColor=b(M.color),r.lineWidth=M.width,r.lineDashes=M.dash),"marker"in e){var C=_(e);r.scatterColor=x(k,1,S),r.scatterSize=c(k.size,S,s,20,C),r.scatterMarker=c(k.symbol,S,l,"\u25cf"),r.scatterLineWidth=k.line.width,r.scatterLineColor=x(k.line,1,S),r.scatterAngle=0}"textposition"in e&&(r.textOffset=o(e.textposition),r.textColor=x(e.textfont,1,S),r.textSize=c(e.textfont.size,S,y.identity,12),r.textFont=e.textfont.family,r.textAngle=0);var z=["x","y","z"];for(r.project=[!1,!1,!1],r.projectScale=[1,1,1],r.projectOpacity=[1,1,1],n=0;3>n;++n){var P=e.projection[z[n]];(r.project[n]=P.show)&&(r.projectOpacity[n]=P.opacity,r.projectScale[n]=P.scale)}r.errorBounds=A(e,g);var R=a([e.error_x,e.error_y,e.error_z]);return r.errorColor=R.color,r.errorLineWidth=R.lineWidth,r.errorCapSize=R.capSize,r.delaunayAxis=e.surfaceaxis,r.delaunayColor=b(e.surfacecolor),r}function f(t){if(Array.isArray(t)){var e=t[0];return Array.isArray(e)&&(t=e),"rgb("+t.slice(0,3).map(function(t){return Math.round(255*t)})+")"}return null}function h(t,e){var r=new n(t,e.uid);return r.update(e),r}var d=t("gl-line3d"),p=t("gl-scatter3d"),g=t("gl-error3d"),v=t("gl-mesh3d"),m=t("delaunay-triangulate"),y=t("../../lib"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/make_bubble_size_func"),w=t("../../constants/gl3d_dashes"),k=t("../../constants/gl_markers"),A=t("./calc_errors"),M=n.prototype;M.handlePick=function(t){if(t.object&&(t.object===this.linePlot||t.object===this.delaunayMesh||t.object===this.textMarkers||t.object===this.scatterPlot)){t.object.highlight&&t.object.highlight(null),this.scatterPlot&&(t.object=this.scatterPlot,this.scatterPlot.highlight(t.data)),this.textLabels&&void 0!==this.textLabels[t.data.index]?t.textLabel=this.textLabels[t.data.index]:t.textLabel="";var e=t.data.index;return t.traceCoordinate=[this.data.x[e],this.data.y[e],this.data.z[e]],!0}},M.update=function(t){var e,r,n,a,o=this.scene.glplot.gl,s=w.solid;this.data=t;var l=u(this.scene,t);"mode"in l&&(this.mode=l.mode),"lineDashes"in l&&l.lineDashes in w&&(s=w[l.lineDashes]),this.color=f(l.scatterColor)||f(l.lineColor),this.dataPoints=l.position,e={gl:o,position:l.position,color:l.lineColor,lineWidth:l.lineWidth||1,dashes:s[0],dashScale:s[1],opacity:t.opacity,connectGaps:t.connectgaps},-1!==this.mode.indexOf("lines")?this.linePlot?this.linePlot.update(e):(this.linePlot=d(e),this.scene.glplot.add(this.linePlot)):this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose(),this.linePlot=null);var c=t.opacity;if(t.marker&&t.marker.opacity&&(c*=t.marker.opacity),r={gl:o,position:l.position,color:l.scatterColor,size:l.scatterSize,glyph:l.scatterMarker,opacity:c,orthographic:!0,lineWidth:l.scatterLineWidth,lineColor:l.scatterLineColor,project:l.project,projectScale:l.projectScale,projectOpacity:l.projectOpacity},-1!==this.mode.indexOf("markers")?this.scatterPlot?this.scatterPlot.update(r):(this.scatterPlot=p(r),this.scatterPlot.highlightScale=1,this.scene.glplot.add(this.scatterPlot)):this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose(),this.scatterPlot=null),a={gl:o,position:l.position,glyph:l.text,color:l.textColor,size:l.textSize,angle:l.textAngle,alignment:l.textOffset,font:l.textFont,orthographic:!0,lineWidth:0,project:!1,opacity:t.opacity},this.textLabels=l.text,-1!==this.mode.indexOf("text")?this.textMarkers?this.textMarkers.update(a):(this.textMarkers=p(a),this.textMarkers.highlightScale=1,this.scene.glplot.add(this.textMarkers)):this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose(),this.textMarkers=null),n={gl:o,position:l.position,color:l.errorColor,error:l.errorBounds,lineWidth:l.errorLineWidth,capSize:l.errorCapSize,opacity:t.opacity},this.errorBars?l.errorBounds?this.errorBars.update(n):(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose(),this.errorBars=null):l.errorBounds&&(this.errorBars=g(n),this.scene.glplot.add(this.errorBars)),l.delaunayAxis>=0){var h=i(l.position,l.delaunayColor,l.delaunayAxis);h.opacity=t.opacity,this.delaunayMesh?this.delaunayMesh.update(h):(h.gl=o,this.delaunayMesh=v(h),this.scene.glplot.add(this.delaunayMesh))}else this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose(),this.delaunayMesh=null)},M.dispose=function(){this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose()),this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose()),this.errorBars&&(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose()),this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose()),this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose())},e.exports=h},{"../../constants/gl3d_dashes":367,"../../constants/gl_markers":368,"../../lib":381,"../../lib/gl_format_color":379,"../../lib/str2rgbarray":392,"../scatter/make_bubble_size_func":567,"./calc_errors":578,"delaunay-triangulate":73,"gl-error3d":80,"gl-line3d":86,"gl-mesh3d":109,"gl-scatter3d":152}],580:[function(t,e,r){"use strict";function n(t,e,r){var n=0,i=r("x"),a=r("y"),o=r("z");return i&&a&&o&&(n=Math.min(i.length,a.length,o.length),n=0&&h("surfacecolor",p||g);for(var v=["x","y","z"],m=0;3>m;++m){var y="projection."+v[m];h(y+".show")&&(h(y+".opacity"),h(y+".scale"))}c(t,e,r,{axis:"z"}),c(t,e,r,{axis:"y",inherit:"z"}),c(t,e,r,{axis:"x",inherit:"z"})}},{"../../components/errorbars/defaults":330,"../../lib":381,"../scatter/line_defaults":564,"../scatter/marker_defaults":569,"../scatter/subtypes":573,"../scatter/text_defaults":574,"./attributes":576}],581:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../constants/gl_markers":368,"../../plots/gl3d":439,"../scatter/colorbar":557,"./attributes":576,"./calc":577,"./convert":579,"./defaults":580}],582:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=n.line,l=o.line;e.exports={lon:{valType:"data_array"},lat:{valType:"data_array"},locations:{valType:"data_array"},locationmode:{valType:"enumerated",values:["ISO-3","USA-states","country names"],dflt:"ISO-3"},mode:a({},n.mode,{dflt:"markers"}),text:a({},n.text,{}),line:{color:s.color,width:s.width,dash:s.dash},marker:{symbol:o.symbol,opacity:o.opacity,size:o.size,sizeref:o.sizeref,sizemin:o.sizemin,sizemode:o.sizemode,color:o.color,colorscale:o.colorscale,cauto:o.cauto,cmax:o.cmax,cmin:o.cmin,autocolorscale:o.autocolorscale,reversescale:o.reversescale,showscale:o.showscale,line:{color:l.color,width:l.width,colorscale:l.colorscale,cauto:l.cauto,cmax:l.cmax,cmin:l.cmin,autocolorscale:l.autocolorscale,reversescale:l.reversescale}},textfont:n.textfont,textposition:n.textposition,hoverinfo:a({},i.hoverinfo,{flags:["lon","lat","location","text","name"]}),_nestedModules:{"marker.colorbar":"Colorbar"}}},{"../../lib/extend":376,"../../plots/attributes":401,"../scatter/attributes":554}],583:[function(t,e,r){"use strict";var n=t("../scatter/marker_colorscale_calc");e.exports=function(t,e){var r=[{x:!1,y:!1,trace:e,t:{}}];return n(e),r}},{"../scatter/marker_colorscale_calc":568}],584:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=0,o=r("locations");return o?(r("locationmode"),a=o.length):(n=r("lon")||[],i=r("lat")||[],a=Math.min(n.length,i.length),an;n++)r[n]=[t.lon[n],t.lat[n]];return{type:"LineString",coordinates:r,trace:t}}function a(t,e){function r(e){var r=t.mockAxis;return c.tickText(r,r.c2l(e),"hover").text+"\xb0"}var n=e.hoverinfo;if("none"===n)return function(t){delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("location")&&Array.isArray(e.locations),o=-1!==i.indexOf("lon"),s=-1!==i.indexOf("lat"),l=-1!==i.indexOf("text");return function(t){var n=[];a?n.push(t.location):o&&s?n.push("("+r(t.lon)+", "+r(t.lat)+")"):o?n.push("lon: "+r(t.lon)):s&&n.push("lat: "+r(t.lat)),l&&n.push(t.tx||e.text),t.textLabel=n.join("
")}}function o(t){var e=Array.isArray(t.locations);return function(r,n){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:n,lon:r.lon,lat:r.lat,location:e?r.location:null}]}}}var s=t("d3"),l=t("../../plots/cartesian/graph_interact"),c=t("../../plots/cartesian/axes"),u=t("../../lib/topojson_utils").getTopojsonFeatures,f=t("../../lib/geo_location_utils").locationToFeature,h=t("../../lib/array_to_calc_item"),d=t("../../components/color"),p=t("../../components/drawing"),g=t("../scatter/subtypes"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){var r,i,a,o,s=[],l=Array.isArray(t.locations);l?(o=t.locations,r=o.length,i=u(t,e),a=function(t,e){var r=f(t.locationmode,o[e],i);return void 0!==r?r.properties.ct:void 0}):(r=t.lon.length,a=function(t,e){return[t.lon[e],t.lat[e]]});for(var c=0;r>c;c++){var h=a(t,c);if(h){var d={lon:h[0],lat:h[1],location:l?t.locations[c]:null};n(t,d,c),s.push(d)}}return s.length>0&&(s[0].trace=t),s},m.plot=function(t,e){var r=t.framework.select(".scattergeolayer").selectAll("g.trace.scattergeo").data(e,function(t){return t.uid});r.enter().append("g").attr("class","trace scattergeo"),r.exit().remove(),r.selectAll("*").remove(),r.each(function(t){var e=s.select(this);g.hasLines(t)&&e.selectAll("path.js-line").data([i(t)]).enter().append("path").classed("js-line",!0)}),r.each(function(e){function r(r,n){if(t.showHover){var i=t.projection([r.lon,r.lat]);h(r),l.loneHover({x:i[0],y:i[1],name:v?e.name:void 0,text:r.textLabel,color:r.mc||(e.marker||{}).color},{container:t.hoverContainer.node()}),y=d(r,n),t.graphDiv.emit("plotly_hover",y)}}function n(e,r){t.graphDiv.emit("plotly_click",d(e,r))}var i=s.select(this),c=g.hasMarkers(e),u=g.hasText(e);if(c||u){var f=m.calcGeoJSON(e,t.topojson),h=a(t,e),d=o(e),p=e.hoverinfo,v="all"===p||-1!==p.indexOf("name"),y=null;c&&i.selectAll("path.point").data(f).enter().append("path").classed("point",!0).on("mouseover",r).on("click",n).on("mouseout",function(){l.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",y)}).on("mousedown",function(){ +l.loneUnhover(t.hoverContainer)}).on("mouseup",r),u&&i.selectAll("g").data(f).enter().append("g").append("text")}}),m.style(t)},m.style=function(t){var e=t.framework.selectAll("g.trace.scattergeo");e.style("opacity",function(t){return t.opacity}),e.each(function(t){s.select(this).selectAll("path.point").call(p.pointStyle,t),s.select(this).selectAll("text").call(p.textPointStyle,t)}),e.selectAll("path.js-line").style("fill","none").each(function(t){var e=t.trace,r=e.line||{};s.select(this).call(d.stroke,r.color).call(p.dashLine,r.dash||"",r.width||0)})}},{"../../components/color":303,"../../components/drawing":325,"../../lib/array_to_calc_item":372,"../../lib/geo_location_utils":378,"../../lib/topojson_utils":394,"../../plots/cartesian/axes":403,"../../plots/cartesian/graph_interact":410,"../scatter/subtypes":573,"./attributes":582,d3:72}],587:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../constants/gl2d_dashes"),a=t("../../constants/gl_markers"),o=t("../../lib/extend").extendFlat,s=n.line,l=n.marker,c=l.line;e.exports={x:n.x,x0:n.x0,dx:n.dx,y:n.y,y0:n.y0,dy:n.dy,text:o({},n.text,{}),mode:{valType:"flaglist",flags:["lines","markers"],extras:["none"]},line:{color:s.color,width:s.width,dash:{valType:"enumerated",values:Object.keys(i),dflt:"solid"}},marker:{color:l.color,symbol:{valType:"enumerated",values:Object.keys(a),dflt:"circle",arrayOk:!0},size:l.size,sizeref:l.sizeref,sizemin:l.sizemin,sizemode:l.sizemode,opacity:l.opacity,colorscale:l.colorscale,cauto:l.cauto,cmax:l.cmax,cmin:l.cmin,autocolorscale:l.autocolorscale,reversescale:l.reversescale,showscale:l.showscale,line:{color:c.color,width:c.width,colorscale:c.colorscale,cauto:c.cauto,cmax:c.cmax,cmin:c.cmin,autocolorscale:c.autocolorscale,reversescale:c.reversescale}},connectgaps:n.connectgaps,fill:o({},n.fill,{values:["none","tozeroy","tozerox"]}),fillcolor:n.fillcolor,_nestedModules:{error_x:"ErrorBars",error_y:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../constants/gl2d_dashes":366,"../../constants/gl_markers":368,"../../lib/extend":376,"../scatter/attributes":554}],588:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.pickXData=[],this.pickYData=[],this.xData=[],this.yData=[],this.textLabels=[],this.color="rgb(0, 0, 0)",this.name="",this.hoverinfo="all",this.connectgaps=!0,this.idToIndex=[],this.bounds=[0,0,0,0],this.hasLines=!1,this.lineOptions={positions:new Float32Array,color:[0,0,0,1],width:1,fill:[!1,!1,!1,!1],fillColor:[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],dashes:[1]},this.line=d(t.glplot,this.lineOptions),this.line._trace=this,this.hasErrorX=!1,this.errorXOptions={positions:new Float32Array,errors:new Float32Array,lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorX=p(t.glplot,this.errorXOptions),this.errorX._trace=this,this.hasErrorY=!1,this.errorYOptions={positions:new Float32Array,errors:new Float32Array,lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorY=p(t.glplot,this.errorYOptions),this.errorY._trace=this,this.hasMarkers=!1,this.scatterOptions={positions:new Float32Array,sizes:[],colors:[],glyphs:[],borderWidths:[],borderColors:[],size:12,color:[0,0,0,1],borderSize:1,borderColor:[0,0,0,1]},this.scatter=f(t.glplot,this.scatterOptions),this.scatter._trace=this,this.fancyScatter=h(t.glplot,this.scatterOptions),this.fancyScatter._trace=this}function i(t,e,r){return Array.isArray(e)||(e=[e]),a(t,e,r)}function a(t,e,r){for(var n=new Array(r),i=e[0],a=0;r>a;++a)n[a]=t(a>=e.length?i:e[a]);return n}function o(t,e,r){return l(S(t,r),L(e,r),r)}function s(t,e,r,n){var i=x(t,e,n);return i=Array.isArray(i[0])?i:a(v.identity,[i],n),l(i,L(r,n),n)}function l(t,e,r){for(var n=new Array(4*r),i=0;r>i;++i){for(var a=0;3>a;++a)n[4*i+a]=t[i][a];n[4*i+3]=t[i][3]*e[i]}return n}function c(t,e){if(void 0===Float32Array.slice){for(var r=new Float32Array(e),n=0;e>n;n++)r[n]=t[n];return r}return t.slice(0,e)}function u(t,e){var r=new n(t,e.uid);return r.update(e),r}var f=t("gl-scatter2d"),h=t("gl-scatter2d-fancy"),d=t("gl-line2d"),p=t("gl-error2d"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../plots/cartesian/axes"),y=t("../../components/errorbars"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/subtypes"),w=t("../scatter/make_bubble_size_func"),k=t("../scatter/get_trace_color"),A=t("../../constants/gl_markers"),M=t("../../constants/gl2d_dashes"),T=["xaxis","yaxis"],E=n.prototype;E.handlePick=function(t){var e=t.pointId;return(t.object!==this.line||this.connectgaps)&&(e=this.idToIndex[t.pointId]),{trace:this,dataCoord:t.dataCoord,traceCoord:[this.pickXData[e],this.pickYData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:Array.isArray(this.color)?this.color[e]:this.color,name:this.name,hoverinfo:this.hoverinfo}},E.isFancy=function(t){if("linear"!==this.scene.xaxis.type)return!0;if("linear"!==this.scene.yaxis.type)return!0;if(!t.x||!t.y)return!0;var e=t.marker||{};if(Array.isArray(e.symbol)||"circle"!==e.symbol||Array.isArray(e.size)||Array.isArray(e.line.width)||Array.isArray(e.opacity))return!0;var r=e.color;if(Array.isArray(r))return!0;var n=Array.isArray(e.line.color);return Array.isArray(n)?!0:this.hasErrorX?!0:!!this.hasErrorY};var L=i.bind(null,function(t){return+t}),S=i.bind(null,b),C=i.bind(null,function(t){return A[t]||"\u25cf"});E.update=function(t){t.visible!==!0?(this.hasLines=!1,this.hasErrorX=!1,this.hasErrorY=!1,this.hasMarkers=!1):(this.hasLines=_.hasLines(t),this.hasErrorX=t.error_x.visible===!0,this.hasErrorY=t.error_y.visible===!0,this.hasMarkers=_.hasMarkers(t)),this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.connectgaps=!!t.connectgaps,this.isFancy(t)?this.updateFancy(t):this.updateFast(t),this.color=k(t,{})},E.updateFast=function(t){for(var e,r,n=this.xData=this.pickXData=t.x,i=this.yData=this.pickYData=t.y,a=n.length,o=new Array(a),s=new Float32Array(2*a),l=this.bounds,u=0,f=0,h=0;a>h;++h)e=n[h],r=i[h],g(e)&&g(r)&&(o[u++]=h,s[f++]=e,s[f++]=r,l[0]=Math.min(l[0],e),l[1]=Math.min(l[1],r),l[2]=Math.max(l[2],e),l[3]=Math.max(l[3],r));s=c(s,f),this.idToIndex=o,this.updateLines(t,s),this.updateError("X",t),this.updateError("Y",t);var d;if(this.hasMarkers){this.scatterOptions.positions=s;var p=b(t.marker.color),v=b(t.marker.line.color),m=t.opacity*t.marker.opacity;p[3]*=m,this.scatterOptions.color=p,v[3]*=m,this.scatterOptions.borderColor=v,d=t.marker.size,this.scatterOptions.size=d,this.scatterOptions.borderSize=t.marker.line.width,this.scatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions),this.expandAxesFast(l,d)},E.updateFancy=function(t){var e=this.scene,r=e.xaxis,n=e.yaxis,a=this.bounds,o=this.pickXData=r.makeCalcdata(t,"x").slice(),l=this.pickYData=n.makeCalcdata(t,"y").slice();this.xData=o.slice(),this.yData=l.slice();var u,f,h,d,p,g,v,m,b=y.calcFromTrace(t,e.fullLayout),x=o.length,_=new Array(x),k=new Float32Array(2*x),A=new Float32Array(4*x),M=new Float32Array(4*x),T=0,E=0,S=0,z=0,P="log"===r.type?function(t){return r.d2l(t)}:function(t){return t},R="log"===n.type?function(t){return n.d2l(t)}:function(t){return t};for(u=0;x>u;++u)this.xData[u]=h=P(o[u]),this.yData[u]=d=R(l[u]),isNaN(h)||isNaN(d)||(_[T++]=u,k[E++]=h,k[E++]=d,p=A[S++]=h-b[u].xs||0,g=A[S++]=b[u].xh-h||0,A[S++]=0,A[S++]=0,M[z++]=0,M[z++]=0,v=M[z++]=d-b[u].ys||0,m=M[z++]=b[u].yh-d||0,a[0]=Math.min(a[0],h-p),a[1]=Math.min(a[1],d-v),a[2]=Math.max(a[2],h+g),a[3]=Math.max(a[3],d+m));k=c(k,E),this.idToIndex=_,this.updateLines(t,k),this.updateError("X",t,k,A),this.updateError("Y",t,k,M);var O;if(this.hasMarkers){this.scatterOptions.positions=k,this.scatterOptions.sizes=new Array(T),this.scatterOptions.glyphs=new Array(T),this.scatterOptions.borderWidths=new Array(T),this.scatterOptions.colors=new Array(4*T),this.scatterOptions.borderColors=new Array(4*T);var I,N=w(t),j=t.marker,F=j.opacity,D=t.opacity,B=s(j,F,D,x),U=C(j.symbol,x),V=L(j.line.width,x),q=s(j.line,F,D,x);for(O=i(N,j.size,x),u=0;T>u;++u)for(I=_[u],this.scatterOptions.sizes[u]=4*O[I],this.scatterOptions.glyphs[u]=U[I],this.scatterOptions.borderWidths[u]=.5*V[I],f=0;4>f;++f)this.scatterOptions.colors[4*u+f]=B[4*I+f],this.scatterOptions.borderColors[4*u+f]=q[4*I+f];this.fancyScatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions),this.expandAxesFancy(o,l,O)},E.updateLines=function(t,e){var r;if(this.hasLines){var n=e;if(!t.connectgaps){var i=0,a=this.xData,o=this.yData;for(n=new Float32Array(2*a.length),r=0;ro;o++)r=this.scene[T[o]],n=r._min,n||(n=[]),n.push({val:t[o],pad:a}),i=r._max,i||(i=[]),i.push({val:t[o+2],pad:a})},E.expandAxesFancy=function(t,e,r){var n=this.scene,i={padded:!0,ppad:r};m.expand(n.xaxis,t,i),m.expand(n.yaxis,e,i)},E.dispose=function(){this.line.dispose(),this.errorX.dispose(),this.errorY.dispose(),this.scatter.dispose(),this.fancyScatter.dispose()},e.exports=u},{"../../components/errorbars":331,"../../constants/gl2d_dashes":366,"../../constants/gl_markers":368,"../../lib":381,"../../lib/gl_format_color":379,"../../lib/str2rgbarray":392,"../../plots/cartesian/axes":403,"../scatter/get_trace_color":561,"../scatter/make_bubble_size_func":567,"../scatter/subtypes":573,"fast-isnumeric":76,"gl-error2d":78,"gl-line2d":84,"gl-scatter2d":149,"gl-scatter2d-fancy":144}],589:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/xy_defaults"),s=t("../scatter/marker_defaults"),l=t("../scatter/line_defaults"),c=t("../scatter/fillcolor_defaults"),u=t("../../components/errorbars/defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p=o(t,e,d);return p?(d("text"),d("mode",pr;r++)y=e.a[r],b=e.b[r],x=e.c[r],n(y)&&n(b)&&n(x)?(y=+y,b=+b,x=+x,_=v/(y+b+x),1!==_&&(y*=_,b*=_,x*=_),k=y,w=x-b,M[r]={x:w,y:k,a:y,b:b,c:x}):M[r]={x:!1,y:!1};var T,E;if(o.hasMarkers(e)&&(T=e.marker,E=T.size,Array.isArray(E))){var L={type:"linear"};i.setConvert(L),E=L.makeCalcdata(e.marker,"size"),E.length>A&&E.splice(A,E.length-A)}return s(e),void 0!==typeof E&&a.mergeArray(E,M,"ms"),M}},{"../../lib":381,"../../plots/cartesian/axes":403,"../scatter/marker_colorscale_calc":568,"../scatter/subtypes":573,"fast-isnumeric":76}],593:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/marker_defaults"),s=t("../scatter/line_defaults"),l=t("../scatter/line_shape_defaults"),c=t("../scatter/text_defaults"),u=t("../scatter/fillcolor_defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p,g=d("a"),v=d("b"),m=d("c");if(g?(p=g.length,v?(p=Math.min(p,v.length),m&&(p=Math.min(p,m.length))):p=m?Math.min(p,m.length):0):v&&m&&(p=Math.min(v.length,m.length)),!p)return void(e.visible=!1);g&&p"),s}}},{"../../plots/cartesian/axes":403,"../scatter/hover":562}],595:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../plots/ternary":459,"../scatter/colorbar":557,"./attributes":591,"./calc":592,"./defaults":593,"./hover":594,"./plot":596,"./select":597,"./style":598}],596:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e){for(var r={x:function(){return t.xaxis},y:function(){return t.yaxis},plot:t.plotContainer},i=new Array(e.length),a=t.graphDiv.calcdata,o=0;oe){for(var r=g/e,n=[0|Math.floor(t[0].shape[0]*r+1),0|Math.floor(t[0].shape[1]*r+1)],i=n[0]*n[1],o=0;or;++r)this.showContour[r]&&(e=!0,t[r]=this.scene.contourLevels[r]);e&&this.surface.update({levels:t})},v.update=function(t){var e,r=this.scene,n=r.fullSceneLayout,a=this.surface,s=t.opacity,l=i(t.colorscale,s),u=t.z,h=t.x,d=t.y,g=n.xaxis,v=n.yaxis,m=n.zaxis,y=r.dataScale,b=u[0].length,x=u.length,_=[c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x])],w=_[0],k=_[1],A=r.contourLevels;this.data=t,f(_[2],function(t,e){return m.d2l(u[e][t])*y[2]}),Array.isArray(h[0])?f(w,function(t,e){return g.d2l(h[e][t])*y[0]}):f(w,function(t){return g.d2l(h[t])*y[0]}),Array.isArray(d[0])?f(k,function(t,e){return v.d2l(d[e][t])*y[1]}):f(k,function(t,e){return v.d2l(d[e])*y[1]});var M={colormap:l,levels:[[],[],[]],showContour:[!0,!0,!0],showSurface:!t.hidesurface,contourProject:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],contourWidth:[1,1,1],contourColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],contourTint:[1,1,1],dynamicColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],dynamicWidth:[1,1,1],dynamicTint:[1,1,1],opacity:1};if(M.intensityBounds=[t.cmin,t.cmax],t.surfacecolor){var T=c(new Float32Array(b*x),[b,x]);f(T,function(e,r){return t.surfacecolor[r][e]}),_.push(T)}else M.intensityBounds[0]*=y[2],M.intensityBounds[1]*=y[2];this.dataScale=o(_),t.surfacecolor&&(M.intensity=_.pop()),"opacity"in t&&t.opacity<1&&(M.opacity=.25*t.opacity);var E=[!0,!0,!0],L=["x","y","z"];for(e=0;3>e;++e){var S=t.contours[L[e]];E[e]=S.highlight,M.showContour[e]=S.show||S.highlight,M.showContour[e]&&(M.contourProject[e]=[S.project.x,S.project.y,S.project.z],S.show?(this.showContour[e]=!0,M.levels[e]=A[e],a.highlightColor[e]=M.contourColor[e]=p(S.color),S.usecolormap?a.highlightTint[e]=M.contourTint[e]=0:a.highlightTint[e]=M.contourTint[e]=1,M.contourWidth[e]=S.width):this.showContour[e]=!1,S.highlight&&(M.dynamicColor[e]=p(S.highlightcolor),M.dynamicWidth[e]=S.highlightwidth))}M.coords=_,a.update(M),a.visible=t.visible,a.enableDynamic=E,a.snapToData=!0,"lighting"in t&&(a.ambientLight=t.lighting.ambient,a.diffuseLight=t.lighting.diffuse,a.specularLight=t.lighting.specular,a.roughness=t.lighting.roughness,a.fresnel=t.lighting.fresnel),s&&1>s&&(a.supportsTransparency=!0)},v.dispose=function(){this.scene.glplot.remove(this.surface),this.surface.dispose()},e.exports=s},{"../../lib/str2rgbarray":392,"gl-surface3d":180,ndarray:212,"ndarray-fill":205,"ndarray-homography":210,"ndarray-ops":211,tinycolor2:233}],603:[function(t,e,r){"use strict";function n(t,e,r){e in t&&!(r in t)&&(t[r]=t[e])}var i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}var c,u,f=l("z");if(!f)return void(e.visible=!1);var h=f[0].length,d=f.length;if(l("x"),l("y"),!Array.isArray(e.x))for(e.x=[],c=0;h>c;++c)e.x[c]=c;if(l("text"),!Array.isArray(e.y))for(e.y=[],c=0;d>c;++c)e.y[c]=c;l("lighting.ambient"),l("lighting.diffuse"),l("lighting.specular"),l("lighting.roughness"),l("lighting.fresnel"),l("hidesurface"),l("opacity");var p=l("surfacecolor");l("colorscale");var g=["x","y","z"];for(c=0;3>c;++c){var v="contours."+g[c],m=l(v+".show"),y=l(v+".highlight");if(m||y)for(u=0;3>u;++u)l(v+".project."+g[u]);m&&(l(v+".color"),l(v+".width"),l(v+".usecolormap")),y&&(l(v+".highlightcolor"),l(v+".highlightwidth"))}p||(n(t,"zmin","cmin"),n(t,"zmax","cmax"),n(t,"zauto","cauto")),a(t,e,s,l,{prefix:"",cLetter:"c"})}},{"../../components/colorscale/defaults":312,"../../lib":381,"./attributes":599}],604:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("./colorbar"),n.calc=t("./calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="surface",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","noOpacity"],n.meta={},e.exports=n},{"../../plots/gl3d":439,"./attributes":599,"./calc":600,"./colorbar":601,"./convert":602,"./defaults":603}]},{},[12])(12)}); \ No newline at end of file diff --git a/inst/htmlwidgets/plotly.js b/inst/htmlwidgets/plotly.js index e9a3f90eda..3df60ef50d 100644 --- a/inst/htmlwidgets/plotly.js +++ b/inst/htmlwidgets/plotly.js @@ -27,11 +27,11 @@ HTMLWidgets.widget({ // if no plot exists yet, create one with a particular configuration if (!instance.plotly) { - Plotly.plot(graphDiv, x.data, x.layout, x.config); + var plot = Plotly.plot(graphDiv, x.data, x.layout, x.config); instance.plotly = true; instance.autosize = x.layout.autosize; } else { - Plotly.newPlot(graphDiv, x.data, x.layout); + var plot = Plotly.newPlot(graphDiv, x.data, x.layout); } sendEventData = function(eventType) { diff --git a/inst/htmlwidgets/plotly.yaml b/inst/htmlwidgets/plotly.yaml index a0fc88e332..b8704579d1 100644 --- a/inst/htmlwidgets/plotly.yaml +++ b/inst/htmlwidgets/plotly.yaml @@ -1,6 +1,6 @@ dependencies: - name: plotlyjs - version: 1.10.1 + version: 1.11.0 src: "htmlwidgets/lib/plotlyjs" script: plotly-latest.min.js stylesheet: plotly-htmlwidgets.css diff --git a/inst/plotlyjs.R b/inst/plotlyjs.R index c784098879..7837c8aafa 100644 --- a/inst/plotlyjs.R +++ b/inst/plotlyjs.R @@ -4,10 +4,17 @@ zip <- content(x)$zipball_url tmp <- tempfile(fileext = ".zip") download.file(zip, tmp) unzip(tmp) +# save trace types (mostly for error checking on the R side) +traces <- basename(Sys.glob("plotly-plotly.js*/src/traces/*")) +devtools::use_data(traces, overwrite = TRUE, internal = TRUE) +# TODO: figure out the _required_ properties of each trace type, store them +# as internal R data, and use them to provide error checking + +# update the plotly.js bundle p <- Sys.glob("plotly-plotly.js*/dist/plotly.min.js") file.copy(p, "inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js", overwrite = T) l <- Sys.glob("plotly-plotly.js*/LICENSE") file.copy(l, "inst/htmlwidgets/lib/plotlyjs/LICENSE", overwrite = T) unlink("plotly-plotly.js*", recursive = T) -# update plotly.yml with version +message("Manually update plotly.yaml with this version") basename(zip) diff --git a/man/add_trace.Rd b/man/add_trace.Rd index 756480adec..08d97d8f08 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -1,14 +1,13 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotly.R +% Please edit documentation in R/add.R \name{add_trace} \alias{add_trace} \title{Add a trace to a plotly visualization} \usage{ -add_trace(p = last_plot(), ..., group, color, colors, symbol, symbols, size, - data = NULL, evaluate = FALSE) +add_trace(p, ..., group, color, colors, symbol, symbols, size, data = NULL) } \arguments{ -\item{p}{A plotly object.} +\item{p}{a plotly or ggplot object.} \item{...}{These arguments are documented in the references section below. Note that acceptable arguments depend on the trace type.} @@ -31,8 +30,6 @@ or a color interpolation function like \code{colorRamp}.} \item{data}{A data frame to associate with this trace (optional). If not provided, arguments are evaluated using the data frame in \code{\link{plot_ly}()}.} - -\item{evaluate}{logical. Evaluate arguments when this function is called?} } \description{ Add a trace to a plotly visualization diff --git a/man/as.widget.Rd b/man/as.widget.Rd index 9f86bf8bfa..9a570a27fe 100644 --- a/man/as.widget.Rd +++ b/man/as.widget.Rd @@ -12,13 +12,7 @@ as.widget(x, ...) \item{...}{other options passed onto \code{htmlwidgets::createWidget}} } \description{ -Convert a plotly object to an htmlwidget object -} -\examples{ -\dontrun{ -p <- plot_ly(mtcars, x = mpg, y = disp, mode = "markers") -htmlwidgets::saveWidget(as.widget(p), "index.html") -} - +As of version 4.0.0, plotly objects are now htmlwidget objects, +so users shouldn't have to use this function directly. } diff --git a/man/config.Rd b/man/config.Rd index 93a44ac336..b345426433 100644 --- a/man/config.Rd +++ b/man/config.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotly.R +% Please edit documentation in R/layout.R \name{config} \alias{config} \title{Set the default configuration for plotly} \usage{ -config(p = last_plot(), ...) +config(p, ...) } \arguments{ \item{p}{a plotly object} diff --git a/man/export.Rd b/man/export.Rd new file mode 100644 index 0000000000..ca41ecb612 --- /dev/null +++ b/man/export.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/export.R +\name{export} +\alias{export} +\title{Export a plotly graph to a static file} +\usage{ +export(p, file = "plotly.png", ...) +} +\arguments{ +\item{p}{a plotly or ggplot object.} + +\item{file}{a filename. See the file argument of \code{webshot::webshot} +for valid extensions.} + +\item{...}{arguments passed onto \code{webshot::webshot}} +} +\description{ +Export a plotly graph to a static file +} +\examples{ +\dontrun{ +export(plot_ly(economics, x = ~date, y = ~pce)) +} +} + diff --git a/man/get_plot.Rd b/man/get_plot.Rd deleted file mode 100644 index 5fee59d6a4..0000000000 --- a/man/get_plot.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{get_plot} -\alias{get_plot} -\title{Obtain underlying data of plotly object} -\usage{ -get_plot(data = NULL, last = FALSE) -} -\arguments{ -\item{data}{a data frame with a class of plotly (and a plotly_hash attribute).} - -\item{last}{if no plotly attribute is found, return the last plot or NULL?} -} -\description{ -Given a data frame with a class of plotly, this function returns the arguments -and/or data used to create the plotly. If no data frame is provided, -the last plotly object created in this R session is returned (if it exists). -} - diff --git a/man/knit_print.plotly_built.Rd b/man/knit_print.plotly_built.Rd deleted file mode 100644 index 67cb3f08cc..0000000000 --- a/man/knit_print.plotly_built.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/print.R -\name{knit_print.plotly_built} -\alias{knit_print.plotly_built} -\title{Print a 'built' plotly object in a knitr doc} -\usage{ -knit_print.plotly_built(x, options, ...) -} -\arguments{ -\item{x}{a plotly object} - -\item{options}{knitr options.} - -\item{...}{additional arguments} -} -\description{ -Print a 'built' plotly object in a knitr doc -} - diff --git a/man/knit_print.figure.Rd b/man/knit_print.plotly_figure.Rd similarity index 79% rename from man/knit_print.figure.Rd rename to man/knit_print.plotly_figure.Rd index 25080ca060..d0a878a6af 100644 --- a/man/knit_print.figure.Rd +++ b/man/knit_print.plotly_figure.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/print.R -\name{knit_print.figure} -\alias{knit_print.figure} +\name{knit_print.plotly_figure} +\alias{knit_print.plotly_figure} \title{Embed a plotly figure as an iframe in a knitr doc} \usage{ -knit_print.figure(x, options, ...) +knit_print.plotly_figure(x, options, ...) } \arguments{ \item{x}{a plotly figure object} diff --git a/man/knit_print.plotly_hash.Rd b/man/knit_print.plotly_hash.Rd deleted file mode 100644 index 733c731c20..0000000000 --- a/man/knit_print.plotly_hash.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/print.R -\name{knit_print.plotly_hash} -\alias{knit_print.plotly_hash} -\title{Print a plotly object in a knitr doc} -\usage{ -knit_print.plotly_hash(x, options, ...) -} -\arguments{ -\item{x}{a plotly object} - -\item{options}{knitr options.} - -\item{...}{additional arguments} -} -\description{ -Print a plotly object in a knitr doc -} - diff --git a/man/last_plot.Rd b/man/last_plot.Rd deleted file mode 100644 index f6e02286a1..0000000000 --- a/man/last_plot.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{last_plot} -\alias{last_plot} -\title{Retrive and create the last plotly (or ggplot).} -\usage{ -last_plot(data = NULL) -} -\arguments{ -\item{data}{(optional) a data frame with a class of plotly (and a plotly_hash attribute).} -} -\description{ -Retrive and create the last plotly (or ggplot). -} -\seealso{ -\link{plotly_build} -} - diff --git a/man/layout.Rd b/man/layout.Rd index a774d16019..5983273923 100644 --- a/man/layout.Rd +++ b/man/layout.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotly.R +% Please edit documentation in R/layout.R \name{layout} \alias{layout} -\title{Add and/or modify layout of a plotly} +\title{Modify the layout of a plotly visualization} \usage{ -layout(p = last_plot(), ..., data = NULL, evaluate = FALSE) +layout(p, ..., data = NULL) } \arguments{ \item{p}{A plotly object.} @@ -14,11 +14,9 @@ see \url{https://plot.ly/r/reference/#Layout_and_layout_style_objects}} \item{data}{A data frame to associate with this layout (optional). If not provided, arguments are evaluated using the data frame in \code{\link{plot_ly}()}.} - -\item{evaluate}{logical. Evaluate arguments when this function is called?} } \description{ -Add and/or modify layout of a plotly +Modify the layout of a plotly visualization } \author{ Carson Sievert diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index 974c248fcd..7cb84ca96b 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -4,9 +4,9 @@ \alias{plot_ly} \title{Initiate a plotly visualization} \usage{ -plot_ly(data = data.frame(), ..., type = "scatter", group, color, colors, - symbol, symbols, size, width = NULL, height = NULL, inherit = FALSE, - evaluate = FALSE, source = "A") +plot_ly(data = data.frame(), ..., type = NULL, group, color, colors, symbol, + symbols, size, width = NULL, height = NULL, inherit = FALSE, + source = "A") } \arguments{ \item{data}{A data frame (optional).} @@ -38,8 +38,6 @@ or a color interpolation function like \code{colorRamp()}.} \item{inherit}{logical. Should future traces inherit properties from this initial trace?} -\item{evaluate}{logical. Evaluate arguments when this function is called?} - \item{source}{Only relevant for \link{event_data}.} } \description{ @@ -53,10 +51,9 @@ Reference section (see below). \dontrun{ data(economics, package = "ggplot2") # basic time-series plot -p <- plot_ly(economics, x = date, y = uempmed, type = "scatter", - showlegend = FALSE) +p <- plot_ly(economics, x = ~date, y = ~uempmed, inherit = TRUE) # add a loess smoother -p2 <- add_trace(p, y = fitted(loess(uempmed ~ as.numeric(date)))) +p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) # add a title p3 <- layout(p2, title = "Median duration of unemployment (in weeks)") # change the font @@ -73,17 +70,24 @@ decade <- function(x) { } plot_ly(economics, x = unemploy / pop, color = decade(date), type = "box") -# plotly loves pipelines -economics \%>\% - transform(rate = unemploy / pop) \%>\% - plot_ly(x = date, y = rate) \%>\% - loess(rate ~ as.numeric(date), data = .) \%>\% - broom::augment() \%>\% +# monads::`\%>>\%` enables data-plot-pipelines + +plot_ly(mtcars, x = ~wt, y = ~mpg) + + +economics \%>>\% + transform(rate = unemploy / pop) \%>>\% + + \%>\% + \%>>\% + loess(rate ~ as.numeric(date), data = .) \%>>\% + broom::augment() \%>>\% add_trace(y = .fitted) # sometimes, a data frame isn't fit for the use case... # for 3D surface plots, a numeric matrix is more natural plot_ly(z = volcano, type = "surface") + } } diff --git a/man/plotly_build.Rd b/man/plotly_build.Rd index b074b94518..2e7bbe6bf7 100644 --- a/man/plotly_build.Rd +++ b/man/plotly_build.Rd @@ -1,13 +1,13 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotly.R +% Please edit documentation in R/plotly_build.R \name{plotly_build} \alias{plotly_build} -\title{Create a 'plotly_built' object} +\title{'Build' (i.e., evaluate) a plotly object} \usage{ -plotly_build(l = last_plot()) +plotly_build(p) } \arguments{ -\item{l}{a ggplot object, or a plotly_hash object, or a list.} +\item{p}{a ggplot object, or a plotly object, or a list.} } \description{ This generic function creates the list object sent to plotly.js @@ -17,17 +17,17 @@ errors. } \examples{ -p <- plot_ly() -# data frame -str(p) +p <- plot_ly(economics, x = ~date, y = ~pce) +# a plotly visualization object +str(p$x$data) # the actual list of options sent to plotly.js str(plotly_build(p)) p <- qplot(data = mtcars, wt, mpg, geom = c("point", "smooth")) l <- plotly_build(p) # turn off hoverinfo for the smooth (but keep it for the points) -l$data[[2]]$hoverinfo <- "none" -l$data[[3]]$hoverinfo <- "none" +l$x$data[[2]]$hoverinfo <- "none" +l$x$data[[3]]$hoverinfo <- "none" l } diff --git a/man/plotly_empty.Rd b/man/plotly_empty.Rd index 285d721321..0177e2994f 100644 --- a/man/plotly_empty.Rd +++ b/man/plotly_empty.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotly.R +% Please edit documentation in R/helpers.R \name{plotly_empty} \alias{plotly_empty} \title{Create a complete empty plotly graph.} diff --git a/man/plotly_spec.Rd b/man/plotly_spec.Rd new file mode 100644 index 0000000000..45172be8ab --- /dev/null +++ b/man/plotly_spec.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helpers.R +\name{plotly_spec} +\alias{plotly_spec} +\title{Obtain JSON sent to plotly.js} +\usage{ +plotly_spec(p = plot_ly(), as = c("plain", "json"), ...) +} +\arguments{ +\item{p}{a plotly or ggplot object.} + +\item{as}{in what format should the spec be printed?} + +\item{...}{arguments passed onto \code{jsonlite::toJSON}} +} +\description{ +This function returns the JSON sent to plotly.js which can be useful for +debugging. +} +\examples{ + +plotly_spec(plot_ly(), as = "json", pretty = TRUE) +} + diff --git a/man/print.plotly_built.Rd b/man/print.plotly_built.Rd deleted file mode 100644 index 664df2cf35..0000000000 --- a/man/print.plotly_built.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/print.R -\name{print.plotly_built} -\alias{print.plotly_built} -\title{Print a 'built' plotly object} -\usage{ -\method{print}{plotly_built}(x, ...) -} -\arguments{ -\item{x}{a plotly object} - -\item{...}{additional arguments} -} -\description{ -Print a 'built' plotly object -} - diff --git a/man/print.figure.Rd b/man/print.plotly_figure.Rd similarity index 75% rename from man/print.figure.Rd rename to man/print.plotly_figure.Rd index 44754f456d..2ea4bc7b86 100644 --- a/man/print.figure.Rd +++ b/man/print.plotly_figure.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/print.R -\name{print.figure} -\alias{print.figure} +\name{print.plotly_figure} +\alias{print.plotly_figure} \title{Print a plotly figure object} \usage{ -\method{print}{figure}(x, ...) +\method{print}{plotly_figure}(x, ...) } \arguments{ \item{x}{a plotly figure object} diff --git a/man/print.plotly_hash.Rd b/man/print.plotly_hash.Rd deleted file mode 100644 index b595b37c34..0000000000 --- a/man/print.plotly_hash.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/print.R -\name{print.plotly_hash} -\alias{print.plotly_hash} -\title{Print a plotly object} -\usage{ -\method{print}{plotly_hash}(x, ...) -} -\arguments{ -\item{x}{a plotly object} - -\item{...}{additional arguments} -} -\description{ -Print a plotly object -} - diff --git a/man/style.Rd b/man/style.Rd index ad01f1ec6f..bbf21d7963 100644 --- a/man/style.Rd +++ b/man/style.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotly.R +% Please edit documentation in R/layout.R \name{style} \alias{style} \title{Modify trace(s)} \usage{ -style(p = last_plot(), ..., traces = 1, evaluate = FALSE) +style(p, ..., traces = 1) } \arguments{ \item{p}{A plotly visualization.} @@ -12,8 +12,6 @@ style(p = last_plot(), ..., traces = 1, evaluate = FALSE) \item{...}{Visual properties.} \item{traces}{numeric vector. Which traces should be modified?} - -\item{evaluate}{logical. Evaluate arguments when this function is called?} } \description{ Modify trace(s) of an existing plotly visualization. Useful when used in diff --git a/man/toWebGL.Rd b/man/toWebGL.Rd new file mode 100644 index 0000000000..082fb79e09 --- /dev/null +++ b/man/toWebGL.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helpers.R +\name{toWebGL} +\alias{toWebGL} +\title{Convert trace types to WebGL} +\usage{ +toWebGL(p, warn = TRUE) +} +\arguments{ +\item{p}{a plotly or ggplot object.} + +\item{warn}{should a warning be produced if the trace type doesn't have +a WebGL equivalent?} +} +\description{ +This function will also build +} +\examples{ + +# currently no bargl trace type +toWebGL(qplot(1:10)) +toWebGL(qplot(1:10, 1:10)) + +} + From c1c0ec9be9a97796d56facde166674d2f3d8a3cb Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 26 May 2016 19:11:23 +1000 Subject: [PATCH 02/73] make group2NA simpler and reusable --- R/dplyr.R | 31 +++++++++++++++++++++++++++++++ R/layers2traces.R | 43 ------------------------------------------- 2 files changed, 31 insertions(+), 43 deletions(-) create mode 100644 R/dplyr.R diff --git a/R/dplyr.R b/R/dplyr.R new file mode 100644 index 0000000000..a6dd25ad05 --- /dev/null +++ b/R/dplyr.R @@ -0,0 +1,31 @@ +#' Insert missing values to create trace groupings +#' +#' If a group of traces share the same non-positional characteristics (i.e., +#' color, fill, etc), it is more efficient to draw them as a single trace +#' with missing values that separate the groups (instead of multiple traces). +#' This is a helper function for inserting missing values into a data set +#' +#' @param data a data frame. +#' @param groupName the name of the grouping variable as a character string +#' @param nested other variables that group should be nested +#' (i.e., ordered) within. +#' @param retrace.first should the first row of each group be appended to the +#' last row? This is useful for enclosing polygons with lines. +#' @examples +#' elong <- tidyr::gather(economics, variable, value, -date) +#' plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) +#' + +group2NA <- function(data, groupName = "group", nested = NULL, + retrace.first = inherits(data, "GeomPolygon")) { + if (nrow(data) == 0 || any(!groupName %in% names(data))) return(data) + nested <- nested[nested %in% names(data)] + data <- data[do.call(order, data[c(nested, groupName)]), , drop = FALSE] + s <- split(data, data[[groupName]], drop = TRUE) + f <- if (retrace.first) { + function(x) rbind(x, x[1, , drop = FALSE], NA) + } else { + function(x) rbind(x, NA) + } + dplyr::bind_rows(lapply(s, f)) +} diff --git a/R/layers2traces.R b/R/layers2traces.R index ff7890c0b2..13042c09b6 100644 --- a/R/layers2traces.R +++ b/R/layers2traces.R @@ -585,49 +585,6 @@ geom2trace.default <- function(data, params, p) { # Utility functions # -------------------------------------------------------------------------- -# Drawing ggplot2 geoms with a group aesthetic is most efficient in -# plotly when we convert groups of things that look the same to -# vectors with NA. -group2NA <- function(data) { - if (!"group" %in% names(data)) return(data) - poly.list <- split(data, data$group, drop = TRUE) - is.group <- names(data) == "group" - poly.na.list <- list() - forward.i <- seq_along(poly.list) - ## When group2NA is called on geom_polygon (or geom_rect, which is - ## treated as a basic polygon), we need to retrace the first points - ## of each group, see https://github.com/ropensci/plotly/pull/178 - retrace.first.points <- inherits(data, "GeomPolygon") - for (i in forward.i) { - no.group <- poly.list[[i]][, !is.group, drop = FALSE] - na.row <- no.group[1, ] - na.row[, c("x", "y")] <- NA - retrace.first <- if (retrace.first.points) { - no.group[1,] - } - poly.na.list[[paste(i, "forward")]] <- - rbind(no.group, retrace.first, na.row) - } - if (retrace.first.points) { - backward.i <- rev(forward.i[-1])[-1] - for (i in backward.i) { - no.group <- poly.list[[i]][1, !is.group, drop = FALSE] - na.row <- no.group[1, ] - na.row[, c("x", "y")] <- NA - poly.na.list[[paste(i, "backward")]] <- rbind(no.group, na.row) - } - if (length(poly.list) > 1) { - first.group <- poly.list[[1]][1, !is.group, drop = FALSE] - poly.na.list[["last"]] <- rbind(first.group, first.group) - } - } - data <- do.call(rbind, poly.na.list) - if (is.na(data$x[nrow(data)])) { - data <- data[-nrow(data), ] - } - data -} - # given a geom, should we split on any continuous variables? # this is necessary for some geoms, for example, polygons # since plotly.js can't draw two polygons with different fill in a single trace From d9c479d45d2d5f7480b4839854fea0ebc4a04995 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 27 May 2016 11:13:27 +1000 Subject: [PATCH 03/73] fixes for style(), group2NA(), import dplyr --- DESCRIPTION | 4 ++-- NAMESPACE | 1 + R/add.R | 6 ++++++ R/dplyr.R | 22 ++++++++++++++++------ R/ggplotly.R | 3 ++- R/layout.R | 19 ------------------- R/plotly.R | 1 - R/plotly_build.R | 14 +++----------- R/style.R | 32 ++++++++++++++++++++++++++++++++ man/group2NA.Rd | 32 ++++++++++++++++++++++++++++++++ man/plot_ly.Rd | 1 - man/plotly_build.Rd | 13 +++---------- man/style.Rd | 6 ++++++ 13 files changed, 103 insertions(+), 51 deletions(-) create mode 100644 R/style.R create mode 100644 man/group2NA.Rd diff --git a/DESCRIPTION b/DESCRIPTION index c328c1bd7c..11a7f8987b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,9 +31,9 @@ Imports: base64enc, htmlwidgets, tidyr, - hexbin, -Suggests: dplyr, + hexbin +Suggests: maps, ggthemes, GGally, diff --git a/NAMESPACE b/NAMESPACE index 1322fb13ae..1ebbc564a7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -46,6 +46,7 @@ S3method(to_basic,default) export("%>%") export(add_lines) export(add_points) +export(add_polygons) export(add_text) export(add_trace) export(as.widget) diff --git a/R/add.R b/R/add.R index 550aecd893..859946b865 100644 --- a/R/add.R +++ b/R/add.R @@ -59,3 +59,9 @@ add_text <- function(p, ...) { add_trace(p, type = "scatter", mode = "text", ...) } +#' @export +add_polygons <- function(p, ...) { + # TODO: Should mode='markers+lines'? If so, retrace first points? + add_trace(p, type = "scatter", mode = "none", fill = "toself", ...) +} + diff --git a/R/dplyr.R b/R/dplyr.R index a6dd25ad05..55d75874e5 100644 --- a/R/dplyr.R +++ b/R/dplyr.R @@ -6,7 +6,7 @@ #' This is a helper function for inserting missing values into a data set #' #' @param data a data frame. -#' @param groupName the name of the grouping variable as a character string +#' @param groupNames name(s) of the grouping variable(s) as a character vector #' @param nested other variables that group should be nested #' (i.e., ordered) within. #' @param retrace.first should the first row of each group be appended to the @@ -16,16 +16,26 @@ #' plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) #' -group2NA <- function(data, groupName = "group", nested = NULL, +group2NA <- function(data, groupNames = "group", nested = NULL, retrace.first = inherits(data, "GeomPolygon")) { - if (nrow(data) == 0 || any(!groupName %in% names(data))) return(data) + if (nrow(data) == 0) return(data) + idx <- groupNames %in% names(data) + if (any(!idx)) { + message( + "Couldn't group by the following columns:", + paste(groupNames[!idx], collapse = ", ") + ) + groupNames <- groupNames[idx] + } nested <- nested[nested %in% names(data)] - data <- data[do.call(order, data[c(nested, groupName)]), , drop = FALSE] - s <- split(data, data[[groupName]], drop = TRUE) + data <- data[do.call(order, data[c(nested, groupNames)]), , drop = FALSE] + + s <- split(data, data[groupNames], drop = TRUE) f <- if (retrace.first) { function(x) rbind(x, x[1, , drop = FALSE], NA) } else { function(x) rbind(x, NA) } - dplyr::bind_rows(lapply(s, f)) + d <- dplyr::bind_rows(lapply(s, f)) + structure(d, class = unique(class(data), class(d))) } diff --git a/R/ggplotly.R b/R/ggplotly.R index 8fab417eb4..cde683a17a 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -840,7 +840,8 @@ bold <- function(x) paste("", x, "") italic <- function(x) paste("", x, "") # if a vector has one unique value, return that value -uniq <- function(x) { +uniq <- function(x, na.rm = TRUE) { + if (na.rm) x <- x[!is.na(x)] u <- unique(x) if (length(u) == 1) u else x } diff --git a/R/layout.R b/R/layout.R index 9b0fd254f5..d0fe9c445e 100644 --- a/R/layout.R +++ b/R/layout.R @@ -45,22 +45,3 @@ config <- function(p, ...) { p$x$config[[nConfig + 1]] <- list(...) p } - -#' Modify trace(s) -#' -#' Modify trace(s) of an existing plotly visualization. Useful when used in -#' conjunction with \code{\link{get_figure}()}. -#' -#' @param p A plotly visualization. -#' @param ... Visual properties. -#' @param traces numeric vector. Which traces should be modified? -#' @seealso \code{\link{get_figure}()} -#' @author Carson Sievert -#' @export -style <- function(p, ..., traces = 1) { - p <- plotly_build(p) - idx <- traces >= length(p$x$data) - if (any(idx)) warning("You've referenced non-existent traces", call. = FALSE) - p$x$style <- c(p$x$style, list(...)) - p -} diff --git a/R/plotly.R b/R/plotly.R index 4392013e0e..f31fcd88db 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -49,7 +49,6 @@ #' } #' plot_ly(economics, x = unemploy / pop, color = decade(date), type = "box") #' -#' # monads::`%>>%` enables data-plot-pipelines #' #' plot_ly(mtcars, x = ~wt, y = ~mpg) #' diff --git a/R/plotly_build.R b/R/plotly_build.R index 73c0532a8c..7af9dcd25d 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -1,6 +1,5 @@ #' 'Build' (i.e., evaluate) a plotly object #' -#' #' This generic function creates the list object sent to plotly.js #' for rendering. Using this function can be useful for overriding defaults #' provided by \code{ggplotly}/\code{plot_ly} or for debugging rendering @@ -11,17 +10,10 @@ #' @examples #' #' p <- plot_ly(economics, x = ~date, y = ~pce) -#' # a plotly visualization object +#' # the unevaluated data #' str(p$x$data) -#' # the actual list of options sent to plotly.js -#' str(plotly_build(p)) -#' -#' p <- qplot(data = mtcars, wt, mpg, geom = c("point", "smooth")) -#' l <- plotly_build(p) -#' # turn off hoverinfo for the smooth (but keep it for the points) -#' l$x$data[[2]]$hoverinfo <- "none" -#' l$x$data[[3]]$hoverinfo <- "none" -#' l +#' # the evaluated data +#' str(plotly_build(p)$x$data) #' plotly_build <- function(p) { UseMethod("plotly_build") diff --git a/R/style.R b/R/style.R new file mode 100644 index 0000000000..88524e3d27 --- /dev/null +++ b/R/style.R @@ -0,0 +1,32 @@ + +#' Modify trace(s) +#' +#' Modify trace(s) of an existing plotly visualization. Useful when used in +#' conjunction with \code{\link{get_figure}()}. +#' +#' @param p A plotly visualization. +#' @param ... Visual properties. +#' @param traces numeric vector. Which traces should be modified? +#' @seealso \code{\link{get_figure}()} +#' @author Carson Sievert +#' @export +#' @examples +#' +#' p <- qplot(data = mtcars, wt, mpg, geom = c("point", "smooth")) +#' # keep the hover info for points, but remove it for the line/ribbon +#' style(p, hoverinfo = "none", traces = c(2, 3)) +#' +style <- function(p, ..., traces = 1) { + p <- plotly_build(p) + nTraces <- length(p$x$data) + idx <- traces > nTraces + traces <- traces[!idx] + if (any(idx)) warning("You've referenced non-existent traces", call. = FALSE) + argz <- list(...) + for (i in traces) { + for (j in names(argz)) { + p$x$data[[i]][[j]] <- argz[[j]] + } + } + p +} diff --git a/man/group2NA.Rd b/man/group2NA.Rd new file mode 100644 index 0000000000..fda6a88d45 --- /dev/null +++ b/man/group2NA.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dplyr.R +\name{group2NA} +\alias{group2NA} +\title{Insert missing values to create trace groupings} +\usage{ +group2NA(data, groupName = "group", nested = NULL, + retrace.first = inherits(data, "GeomPolygon")) +} +\arguments{ +\item{data}{a data frame.} + +\item{groupName}{the name of the grouping variable as a character string} + +\item{nested}{other variables that group should be nested +(i.e., ordered) within.} + +\item{retrace.first}{should the first row of each group be appended to the +last row? This is useful for enclosing polygons with lines.} +} +\description{ +If a group of traces share the same non-positional characteristics (i.e., +color, fill, etc), it is more efficient to draw them as a single trace +with missing values that separate the groups (instead of multiple traces). +This is a helper function for inserting missing values into a data set +} +\examples{ +elong <- tidyr::gather(economics, variable, value, -date) +plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) + +} + diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index 7cb84ca96b..c63257ce6a 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -70,7 +70,6 @@ decade <- function(x) { } plot_ly(economics, x = unemploy / pop, color = decade(date), type = "box") -# monads::`\%>>\%` enables data-plot-pipelines plot_ly(mtcars, x = ~wt, y = ~mpg) diff --git a/man/plotly_build.Rd b/man/plotly_build.Rd index 2e7bbe6bf7..7808dd6db1 100644 --- a/man/plotly_build.Rd +++ b/man/plotly_build.Rd @@ -18,17 +18,10 @@ errors. \examples{ p <- plot_ly(economics, x = ~date, y = ~pce) -# a plotly visualization object +# the unevaluated data str(p$x$data) -# the actual list of options sent to plotly.js -str(plotly_build(p)) - -p <- qplot(data = mtcars, wt, mpg, geom = c("point", "smooth")) -l <- plotly_build(p) -# turn off hoverinfo for the smooth (but keep it for the points) -l$x$data[[2]]$hoverinfo <- "none" -l$x$data[[3]]$hoverinfo <- "none" -l +# the evaluated data +str(plotly_build(p)$x$data) } diff --git a/man/style.Rd b/man/style.Rd index bbf21d7963..67f1cdafab 100644 --- a/man/style.Rd +++ b/man/style.Rd @@ -16,6 +16,12 @@ style(p, ..., traces = 1) \description{ Modify trace(s) of an existing plotly visualization. Useful when used in conjunction with \code{\link{get_figure}()}. +} +\examples{ + +p <- qplot(data = mtcars, wt, mpg, geom = c("point", "smooth")) +style(p, hoverinfo = "none", traces = c(2, 3)) + } \author{ Carson Sievert From ba0aa50d9641cbc9f6d3e4545376086e13ebfe0e Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 27 May 2016 11:36:14 +1000 Subject: [PATCH 04/73] dplyrify group2NA (now much, much faster) --- NAMESPACE | 4 ++++ R/dplyr.R | 24 ++++++++---------------- R/imports.R | 3 ++- man/group2NA.Rd | 4 ++-- man/style.Rd | 3 ++- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 1ebbc564a7..dbeab0ecb4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -78,6 +78,9 @@ export(toWebGL) export(to_basic) import(ggplot2) importFrom(base64enc,base64encode) +importFrom(dplyr,arrange_) +importFrom(dplyr,do) +importFrom(dplyr,group_by_) importFrom(grDevices,col2rgb) importFrom(graphics,layout) importFrom(htmlwidgets,createWidget) @@ -101,6 +104,7 @@ importFrom(magrittr,"%>%") importFrom(stats,complete.cases) importFrom(stats,setNames) importFrom(tidyr,gather) +importFrom(tidyr,unnest) importFrom(utils,browseURL) importFrom(utils,data) importFrom(utils,getFromNamespace) diff --git a/R/dplyr.R b/R/dplyr.R index 55d75874e5..5c34d034e0 100644 --- a/R/dplyr.R +++ b/R/dplyr.R @@ -19,23 +19,15 @@ group2NA <- function(data, groupNames = "group", nested = NULL, retrace.first = inherits(data, "GeomPolygon")) { if (nrow(data) == 0) return(data) - idx <- groupNames %in% names(data) - if (any(!idx)) { - message( - "Couldn't group by the following columns:", - paste(groupNames[!idx], collapse = ", ") - ) - groupNames <- groupNames[idx] - } nested <- nested[nested %in% names(data)] - data <- data[do.call(order, data[c(nested, groupNames)]), , drop = FALSE] - - s <- split(data, data[groupNames], drop = TRUE) - f <- if (retrace.first) { - function(x) rbind(x, x[1, , drop = FALSE], NA) + if (length(nested)) { + data <- dplyr::arrange_(data, nested) + } + d <- dplyr::group_by_(data, groupNames) + d <- if (retrace.first) { + dplyr::do(d, rbind(., .[1,], NA)) } else { - function(x) rbind(x, NA) + dplyr::do(d, rbind(., NA)) } - d <- dplyr::bind_rows(lapply(s, f)) - structure(d, class = unique(class(data), class(d))) + structure(tidyr::unnest(d), class = unique(class(data), class(d))) } diff --git a/R/imports.R b/R/imports.R index 3f1295e74c..9ea0951f41 100644 --- a/R/imports.R +++ b/R/imports.R @@ -3,7 +3,8 @@ #' @importFrom graphics layout #' @importFrom utils getFromNamespace modifyList data packageVersion browseURL #' @importFrom stats setNames complete.cases -#' @importFrom tidyr gather +#' @importFrom tidyr gather unnest +#' @importFrom dplyr arrange_ group_by_ do #' @importFrom viridis viridis #' @importFrom jsonlite toJSON fromJSON #' @importFrom httr GET POST PATCH content config add_headers stop_for_status diff --git a/man/group2NA.Rd b/man/group2NA.Rd index fda6a88d45..19e37adbb4 100644 --- a/man/group2NA.Rd +++ b/man/group2NA.Rd @@ -4,13 +4,13 @@ \alias{group2NA} \title{Insert missing values to create trace groupings} \usage{ -group2NA(data, groupName = "group", nested = NULL, +group2NA(data, groupNames = "group", nested = NULL, retrace.first = inherits(data, "GeomPolygon")) } \arguments{ \item{data}{a data frame.} -\item{groupName}{the name of the grouping variable as a character string} +\item{groupNames}{name(s) of the grouping variable(s) as a character vector} \item{nested}{other variables that group should be nested (i.e., ordered) within.} diff --git a/man/style.Rd b/man/style.Rd index 67f1cdafab..f3998f7d45 100644 --- a/man/style.Rd +++ b/man/style.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/layout.R +% Please edit documentation in R/style.R \name{style} \alias{style} \title{Modify trace(s)} @@ -20,6 +20,7 @@ conjunction with \code{\link{get_figure}()}. \examples{ p <- qplot(data = mtcars, wt, mpg, geom = c("point", "smooth")) +# keep the hover info for points, but remove it for the line/ribbon style(p, hoverinfo = "none", traces = c(2, 3)) } From 6bce1b8993b57c5ba6feb684ac6215589bcffb80 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 27 May 2016 16:54:19 +1000 Subject: [PATCH 05/73] first implementation of dplyr methods (thanks ggvis) --- NAMESPACE | 16 ++++ NEWS | 10 +-- R/add.R | 29 ++++-- R/dplyr.R | 125 +++++++++++++++++++++++++- R/ggplotly.R | 2 +- R/layers2traces.R | 2 +- R/layout.R | 8 +- R/plotly.R | 38 +++----- R/plotly_build.R | 67 +++++++------- R/subplots.R | 4 +- R/utils.R | 13 ++- inst/htmlwidgets/plotly.js | 1 + man/add_data.Rd | 21 +++++ man/dplyr-plotly.Rd | 41 +++++++++ man/group_by.Rd | 18 ++++ man/plot_ly.Rd | 19 +--- man/plotly-ggvis.Rd | 18 ++++ man/plotly_build.Rd | 4 +- tests/testthat.R | 2 +- tests/testthat/test-ggplot-polygons.R | 28 +++--- tests/testthat/test-ggplot-rect.R | 84 +++++++---------- tests/testthat/test-ggplot-tooltip.R | 4 +- tests/testthat/test-ggplot-violin.R | 2 +- tests/testthat/test-plotly-subplot.R | 2 +- 24 files changed, 384 insertions(+), 174 deletions(-) create mode 100644 man/add_data.Rd create mode 100644 man/dplyr-plotly.Rd create mode 100644 man/group_by.Rd create mode 100644 man/plotly-ggvis.Rd diff --git a/NAMESPACE b/NAMESPACE index dbeab0ecb4..65b3806439 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,8 @@ # Generated by roxygen2: do not edit by hand +S3method(arrange_,plotly) +S3method(distinct_,plotly) +S3method(filter_,plotly) S3method(geom2trace,GeomBar) S3method(geom2trace,GeomBlank) S3method(geom2trace,GeomBoxplot) @@ -13,11 +16,19 @@ S3method(geom2trace,GeomTile) S3method(geom2trace,default) S3method(ggplotly,ggmatrix) S3method(ggplotly,ggplot) +S3method(group_by_,plotly) +S3method(groups,plotly) S3method(layout,matrix) S3method(layout,plotly) +S3method(mutate_,plotly) +S3method(plotly_build,default) S3method(plotly_build,gg) S3method(plotly_build,plotly) S3method(print,plotly_figure) +S3method(rename_,plotly) +S3method(select_,plotly) +S3method(slice_,plotly) +S3method(summarise_,plotly) S3method(to_basic,GeomAbline) S3method(to_basic,GeomArea) S3method(to_basic,GeomBoxplot) @@ -43,7 +54,10 @@ S3method(to_basic,GeomTile) S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) S3method(to_basic,default) +S3method(transmute_,plotly) +S3method(ungroup,plotly) export("%>%") +export(add_data) export(add_lines) export(add_points) export(add_polygons) @@ -58,6 +72,7 @@ export(geom2trace) export(get_figure) export(gg2list) export(ggplotly) +export(group_by) export(knit_print.plotly_figure) export(layout) export(offline) @@ -80,6 +95,7 @@ import(ggplot2) importFrom(base64enc,base64encode) importFrom(dplyr,arrange_) importFrom(dplyr,do) +importFrom(dplyr,group_by) importFrom(dplyr,group_by_) importFrom(grDevices,col2rgb) importFrom(graphics,layout) diff --git a/NEWS b/NEWS index 20b583569c..51fe6cc1d3 100644 --- a/NEWS +++ b/NEWS @@ -3,7 +3,8 @@ MAJOR CHANGES & IMPROVEMENTS: * Formulas (instead of plain expressions) are now required when referring to variable names. For example, `plot_ly(mtcars, x = wt, y = mpg, color = vs)` should now be `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~vs)`. This is a major breaking change, but it is necessary to ensure that evaluation is correct in all contexts (as a result, `evaluate` argument is now deprecated). It also has the benefit of being easier to program with (i.e., writing your own custom functions that wrap `plot_ly()`). For more details, see the [lazyeval vignette](https://github.com/hadley/lazyeval/blob/master/vignettes/lazyeval.Rmd) -* The central object (i.e., the return value and first argument to functions) is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, plotly objects can now be serialized across R sessions and avoid [memory leak issues](https://github.com/rstudio/shiny/issues/1151). This also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided. +* The central object (i.e., the return value and first argument to functions) is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, plotly objects can now be serialized across R sessions and avoid [memory leak issues](https://github.com/rstudio/shiny/issues/1151). This also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `help("dplyr-plotly")` for more details). +* Using the `group` argument (or now, equivalently, the `group_by()` method) will no longer create multiple traces, but instead inserts "gaps" into a given trace via missing values (fixes #418, #381, #577). NEW FEATURES & IMPROVEMENTS: @@ -11,10 +12,9 @@ NEW FEATURES & IMPROVEMENTS: * Error checking for trace types. * New `add_points()`/`add_lines()`/`add_text()` functions provide a shorthand for common plots. * New `toWebGL()` function for easy conversion from SVG to WebGL. -* New `export()` function makes it easy to save plots as png/jpeg/pdf. -* `layout()` is now a generic function and uses method dispatch to avoid conflicts with graphics:layout(). -* Added a `plotly_json()` function to help - +* New `export()` function makes it easy to save plots as png/jpeg/pdf (fixes #311). +* `layout()` is now a generic function and uses method dispatch to avoid conflicts with `graphics:layout()` (fixes #464). +* Added a `plotly_spec()` function for inspecting the data sent to plotly.js (as an R list or JSON). diff --git a/R/add.R b/R/add.R index 859946b865..ed958103c1 100644 --- a/R/add.R +++ b/R/add.R @@ -1,3 +1,21 @@ +#' Add data to a plotly visualization +#' +#' @param p a plotly visualization +#' @param data a data frame. +#' @export +#' @examples +#' +#' NULL %>% plot_ly() %>% add_data(economics) %>% add_trace(x = ~date, y = ~pce) +add_data <- function(p, data = NULL) { + if (is.null(data)) return(p) + p <- verify_plot(p) + id <- new_id() + p$x$visdat[[id]] <- function() data + p$x$cur_data <- id + # TODO: should this also override the data used for the most recent trace? + p +} + #' Add a trace to a plotly visualization #' #' @param p a plotly or ggplot object. @@ -21,7 +39,6 @@ #' @export add_trace <- function(p, ..., group, color, colors, symbol, symbols, size, data = NULL) { - p <- verify_plot(p) # "native" plotly arguments argz <- list(...) # tack on "special" arguments @@ -31,16 +48,10 @@ add_trace <- function(p, ..., if (!missing(symbol)) argz$symbol <- substitute(symbol) if (!missing(symbols)) argz$symbols <- substitute(symbols) if (!missing(size)) argz$size <- substitute(size) - argz$type <- verify_type(argz$type) - nTraces <- length(p$x$data) - - p$x$data[[nTraces + 1]] <- list( - attrs = argz, - rdata = data %||% p$x$data[[1]]$rdata - ) - + p <- add_data(p, data) + p$x$attrs[[p$x$cur_data]] <- argz p } diff --git a/R/dplyr.R b/R/dplyr.R index 5c34d034e0..f0b9f3ccd3 100644 --- a/R/dplyr.R +++ b/R/dplyr.R @@ -1,3 +1,123 @@ +#' Dplyr verbs for plotly. +#' +#' @name plotly-ggvis +#' @keywords internal +#' @examples +#' +#' library(dplyr) +#' plot_ly(mtcars, x = ~wt, y = ~mpg) %>% +#' filter(cyl == 4) %>% +#' add_points() +#' +NULL + +#' Divide data into groups. +#' +#' @param p a plotly visualization. +#' @param ... variables to group by. +#' @param add By default, when \code{add = FALSE}, \code{group_by} will +#' override existing groups. To instead add to the existing groups, +#' use \code{add = TRUE} +#' @importFrom dplyr group_by +#' @name group_by +#' @export +NULL + +#' @export +#' @rdname dplyr-plotly +groups.plotly <- function(x) { + dplyr::groups(plotly_data(x)) +} + +#' @export +#' @rdname dplyr-plotly +group_by_.plotly <- function(.data, ..., .dots, add = FALSE) { + d <- plotly_data(.data) + d <- dplyr::group_by_(d, .dots = lazyeval::all_dots(.dots, ...), add = add) + # TODO: where to use group2NA? In plotly_build() + add_data(.data, d) +} + +#' @export +#' @rdname dplyr-plotly +ungroup.plotly <- function(x) { + dplyr::ungroup(plotly_data(x)) +} + + +#' @rdname dplyr-plotly +#' @export +summarise_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::summarise_(d, .dots = lazyeval::all_dots(.dots, ...)) + add_data(.data, d) +} + +#' @rdname dplyr-plotly +#' @export +mutate_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::mutate_(d, .dots = lazyeval::all_dots(.dots, ...)) + add_data(.data, d) +} + +#' @rdname dplyr-plotly +#' @export +arrange_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::arrange_(d, .dots = lazyeval::all_dots(.dots, ...)) + add_data(.data, d) +} + +#' @rdname dplyr-plotly +#' @export +select_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::select_(d, .dots = lazyeval::all_dots(.dots, ...)) + add_data(.data, d) +} + +#' @rdname dplyr-plotly +#' @export +filter_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::filter_(d, .dots = lazyeval::all_dots(.dots, ...)) + add_data(.data, d) +} + +#' @rdname dplyr-plotly +#' @export +distinct_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::distinct_(d, ..., .dots, add = add) + add_data(.data, d) +} + +#' @rdname dplyr-plotly +#' @export +slice_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::slice_(d, ..., .dots, add = add) + add_data(.data, d) +} + +#' @rdname dplyr-plotly +#' @export +rename_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::rename_(d, ..., .dots, add = add) + add_data(.data, d) +} + +#' @rdname dplyr-plotly +#' @export +transmute_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::transmute_(d, ..., .dots, add = add) + add_data(.data, d) +} + + #' Insert missing values to create trace groupings #' #' If a group of traces share the same non-positional characteristics (i.e., @@ -29,5 +149,8 @@ group2NA <- function(data, groupNames = "group", nested = NULL, } else { dplyr::do(d, rbind(., NA)) } - structure(tidyr::unnest(d), class = unique(class(data), class(d))) + d <- tidyr::unnest(d) + n <- nrow(d) + if (all(is.na(d[n, ]))) d <- d[-n, ] + structure(d, class = unique(class(data), class(d))) } diff --git a/R/ggplotly.R b/R/ggplotly.R index cde683a17a..af622228c9 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -687,7 +687,7 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A # If a trace isn't named, it shouldn't have additional hoverinfo traces <- lapply(compact(traces), function(x) { x$name <- x$name %||% ""; x }) - l <- list(data = setNames(traces, NULL), layout = list(compact(gglayout))) + l <- list(data = setNames(traces, NULL), layout = compact(gglayout)) # ensure properties are boxed correctly l <- add_boxed(rm_asis(l)) l$layout$width <- width diff --git a/R/layers2traces.R b/R/layers2traces.R index 13042c09b6..7a48d70b74 100644 --- a/R/layers2traces.R +++ b/R/layers2traces.R @@ -469,7 +469,7 @@ geom2trace.GeomPolygon <- function(data, params, p) { ), dash = aes2plotly(data, params, "linetype") ), - fill = "tozerox", + fill = "toself", fillcolor = toRGB( aes2plotly(data, params, "fill"), aes2plotly(data, params, "alpha") diff --git a/R/layout.R b/R/layout.R index d0fe9c445e..f1b3ef6417 100644 --- a/R/layout.R +++ b/R/layout.R @@ -20,12 +20,8 @@ layout.matrix <- function(p, ..., data = NULL) { #' @export layout.plotly <- function(p, ..., data = NULL) { - argz <- list(...) - nLayouts <- length(p$x$layout) - p$x$layout[[nLayouts + 1]] <- list( - attrs = argz, - rdata = data %||% p$x$data[[1]]$rdata - ) + p <- add_data(p, data) + p$x$layoutAttrs[[p$x$cur_data]] <- list(...) p } diff --git a/R/plotly.R b/R/plotly.R index f31fcd88db..b260219ec4 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -39,28 +39,15 @@ #' layout(p3, font = list(family = "Courier New, monospace")) #' #' # using the color argument -#' plot_ly(economics, x = date, y = unemploy / pop, color = pop, mode = "markers") -#' plot_ly(economics, x = date, y = unemploy / pop, color = pop, +#' plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, mode = "markers") +#' plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, #' colors = terrain.colors(5), mode = "markers") #' #' # function to extract the decade of a given date #' decade <- function(x) { #' factor(floor(as.numeric(format(x, "%Y")) / 10) * 10) #' } -#' plot_ly(economics, x = unemploy / pop, color = decade(date), type = "box") -#' -#' -#' plot_ly(mtcars, x = ~wt, y = ~mpg) -#' -#' -#' economics %>>% -#' transform(rate = unemploy / pop) %>>% -#' -#' %>% -#' %>>% -#' loess(rate ~ as.numeric(date), data = .) %>>% -#' broom::augment() %>>% -#' add_trace(y = .fitted) +#' plot_ly(economics, x = ~unemploy / pop, color = ~decade(date), type = "box") #' #' # sometimes, a data frame isn't fit for the use case... #' # for 3D surface plots, a numeric matrix is more natural @@ -89,24 +76,21 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, # TODO: do we really need to verify these? argz$colors <- verify_arg(colors) argz$symbols <- verify_arg(symbols) + argz$type <- verify_type(type) - # we always deal with a _list_ of traces and _list_ of layouts - # since they can each have different data + # id for tracking attribute mappings and finding the most current data + id <- new_id() p <- list( - data = list( - list( - type = verify_type(type), - attrs = argz, - rdata = data - ) - ), + visdat = setNames(list(function() data), id), + cur_data = id, + attrs = setNames(list(argz), id), + # we always deal with a _list_ of traces and _list_ of layouts + # since they can each have different data layout = list( - list( width = width, height = height, # sane margin defaults (mainly for RStudio) margin = list(b = 40, l = 60, t = 25, r = 10) - ) ), config = list(modeBarButtonsToRemove = I("sendDataToCloud")), inherit = inherit, diff --git a/R/plotly_build.R b/R/plotly_build.R index 7af9dcd25d..47998e2dfa 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -10,8 +10,8 @@ #' @examples #' #' p <- plot_ly(economics, x = ~date, y = ~pce) -#' # the unevaluated data -#' str(p$x$data) +#' # the unevaluated plotly object +#' str(p) #' # the evaluated data #' str(plotly_build(p)$x$data) #' @@ -19,52 +19,59 @@ plotly_build <- function(p) { UseMethod("plotly_build") } +#' @export +plotly_build.default <- identity + #' @export plotly_build.gg <- function(p) { - ggplotly(p) + l <- ggplotly(p) + browser() } #' @export plotly_build.plotly <- function(p) { - # Initiating a plot with plot_ly() should have a _list_ of layouts - if (is.list(p$x$layout) && is.null(names(p$x$layout))) { - p$x$layout <- lapply(p$x$layout, function(lay) { - is_formula <- vapply(lay$attrs, is.formula, logical(1)) - fl <- lazyeval::as_f_list(lay$attrs[is_formula] %||% list()) - for (var in names(fl)) { - lay[[var]] <- lazyeval::f_eval(fl[[var]], lay$rdata) - } - # tack on attributes, that aren't formulas, without evaluating them - lay <- c(lay, lay$attrs[!is_formula]) - lay[c("attrs", "rdata")] <- NULL - lay[lengths(lay) > 0] - }) - # combine all the layouts into one layout - # (with later layout() calls overriding previous ones) - p$x$layout <- Reduce(modifyList, p$x$layout) - } + layouts <- Map(function(x, y) { + + is_formula <- vapply(x, is.formula, logical(1)) + fl <- lazyeval::as_f_list(x[is_formula] %||% list()) + for (var in names(fl)) { + x[[var]] <- lazyeval::f_eval(fl[[var]], plotly_data(p, y)) + } + x[lengths(x) > 0] + + }, p$x$layoutAttrs, names(p$x$layoutAttrs)) + + # get rid of the data -> layout mapping and merge all the layouts + # into a single layout (more recent layouts will override older ones) + p$x$layoutAttrs <- NULL + p$x$layout <- modifyList(p$x$layout %||% list(), layouts) - p$x$data <- lapply(p$x$data, function(tr) { - is_formula <- vapply(tr$attrs, is.formula, logical(1)) - fl <- lazyeval::as_f_list(tr$attrs[is_formula] %||% list()) + p$x$data <- Map(function(x, y) { + + is_formula <- vapply(x, is.formula, logical(1)) + fl <- lazyeval::as_f_list(x[is_formula] %||% list()) for (var in names(fl)) { - tr[[var]] <- lazyeval::f_eval(fl[[var]], tr$rdata) + x[[var]] <- lazyeval::f_eval(fl[[var]], plotly_data(p, y)) varname <- sub("^~", "", deparse2(fl[[var]])) # deparse axis names and add to layout if (any(c("x", "y", "z") %in% var)) { - if (is3d(tr$type)) { + if (is3d(x$type)) { p$x$layout$scene[[paste0(var, "axis")]]$title <<- varname } else { p$x$layout[[paste0(var, "axis")]]$title <<- varname } } } - # tack on attributes, that aren't formulas, without evaluating them - tr <- c(tr, tr$attrs[!is_formula]) - tr[c("attrs", "rdata")] <- NULL - tr[lengths(tr) > 0] - }) + x[lengths(x) > 0] + + }, p$x$attrs, names(p$x$attrs)) + + # get rid of data -> vis mapping stuff + p$x[c("visdat", "cur_data", "attrs")] <- NULL + + # traces can't have names + p$x$data <- setNames(p$x$data, NULL) p } diff --git a/R/subplots.R b/R/subplots.R index d5fd017e24..2dd988b941 100644 --- a/R/subplots.R +++ b/R/subplots.R @@ -38,7 +38,7 @@ subplot <- function(..., nrows = 1, widths = NULL, heights = NULL, margin = 0.02 dotz <- dotz[[1]] } # build each plot - plotz <- lapply(dotz, plotly_build) + plotz <- lapply(dotz, function(d) plotly_build(d)$x) # ensure "axis-reference" trace attributes are properly formatted # TODO: should this go inside plotly_build()? plotz <- lapply(plotz, function(p) { @@ -236,7 +236,7 @@ subplot <- function(..., nrows = 1, widths = NULL, heights = NULL, margin = 0.02 layouts <- layouts[which_layout] } p$layout <- c(p$layout, Reduce(modifyList, layouts)) - p + as.widget(p) } diff --git a/R/utils.R b/R/utils.R index 8a93b04f37..bd2ad9488c 100644 --- a/R/utils.R +++ b/R/utils.R @@ -18,7 +18,18 @@ is.discrete <- function(x) { is.factor(x) || is.character(x) || is.logical(x) } -deparse2 <- function(x) paste(deparse(x, 500L), collapse = "") +deparse2 <- function(x) { + paste(deparse(x, 500L), collapse = "") +} + +new_id <- function() { + basename(tempfile("")) +} + +# obtain the current data from a plotly vis +plotly_data <- function(p, id = p$x$cur_data) { + p$x$visdat[[id]]() +} verify_arg <- function(arg) { if (missing(arg)) return(NULL) diff --git a/inst/htmlwidgets/plotly.js b/inst/htmlwidgets/plotly.js index 3df60ef50d..2ded06eea1 100644 --- a/inst/htmlwidgets/plotly.js +++ b/inst/htmlwidgets/plotly.js @@ -27,6 +27,7 @@ HTMLWidgets.widget({ // if no plot exists yet, create one with a particular configuration if (!instance.plotly) { + console.log(x.data); var plot = Plotly.plot(graphDiv, x.data, x.layout, x.config); instance.plotly = true; instance.autosize = x.layout.autosize; diff --git a/man/add_data.Rd b/man/add_data.Rd new file mode 100644 index 0000000000..0dbceb40e9 --- /dev/null +++ b/man/add_data.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add.R +\name{add_data} +\alias{add_data} +\title{Add data to a plotly visualization} +\usage{ +add_data(p, data = NULL) +} +\arguments{ +\item{p}{a plotly visualization} + +\item{data}{a data frame.} +} +\description{ +Add data to a plotly visualization +} +\examples{ + +NULL \%>\% plot_ly() \%>\% add_data(economics) \%>\% add_trace(x = ~date, y = ~pce) +} + diff --git a/man/dplyr-plotly.Rd b/man/dplyr-plotly.Rd new file mode 100644 index 0000000000..7bf060e0fb --- /dev/null +++ b/man/dplyr-plotly.Rd @@ -0,0 +1,41 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dplyr.R +\name{groups.plotly} +\alias{arrange_.plotly} +\alias{distinct_.plotly} +\alias{filter_.plotly} +\alias{group_by_.plotly} +\alias{groups.plotly} +\alias{mutate_.plotly} +\alias{rename_.plotly} +\alias{select_.plotly} +\alias{slice_.plotly} +\alias{summarise_.plotly} +\alias{transmute_.plotly} +\alias{ungroup.plotly} +\usage{ +\method{groups}{plotly}(x) + +\method{group_by_}{plotly}(.data, ..., .dots, add = FALSE) + +\method{ungroup}{plotly}(x) + +\method{summarise_}{plotly}(.data, ..., .dots) + +\method{mutate_}{plotly}(.data, ..., .dots) + +\method{arrange_}{plotly}(.data, ..., .dots) + +\method{select_}{plotly}(.data, ..., .dots) + +\method{filter_}{plotly}(.data, ..., .dots) + +\method{distinct_}{plotly}(.data, ..., .dots) + +\method{slice_}{plotly}(.data, ..., .dots) + +\method{rename_}{plotly}(.data, ..., .dots) + +\method{transmute_}{plotly}(.data, ..., .dots) +} + diff --git a/man/group_by.Rd b/man/group_by.Rd new file mode 100644 index 0000000000..29302f0fdc --- /dev/null +++ b/man/group_by.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dplyr.R +\name{group_by} +\alias{group_by} +\title{Divide data into groups.} +\arguments{ +\item{p}{a plotly visualization.} + +\item{...}{variables to group by.} + +\item{add}{By default, when \code{add = FALSE}, \code{group_by} will +override existing groups. To instead add to the existing groups, +use \code{add = TRUE}} +} +\description{ +Divide data into groups. +} + diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index c63257ce6a..ab138656da 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -60,28 +60,15 @@ p3 <- layout(p2, title = "Median duration of unemployment (in weeks)") layout(p3, font = list(family = "Courier New, monospace")) # using the color argument -plot_ly(economics, x = date, y = unemploy / pop, color = pop, mode = "markers") -plot_ly(economics, x = date, y = unemploy / pop, color = pop, +plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, mode = "markers") +plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, colors = terrain.colors(5), mode = "markers") # function to extract the decade of a given date decade <- function(x) { factor(floor(as.numeric(format(x, "\%Y")) / 10) * 10) } -plot_ly(economics, x = unemploy / pop, color = decade(date), type = "box") - - -plot_ly(mtcars, x = ~wt, y = ~mpg) - - -economics \%>>\% - transform(rate = unemploy / pop) \%>>\% - - \%>\% - \%>>\% - loess(rate ~ as.numeric(date), data = .) \%>>\% - broom::augment() \%>>\% - add_trace(y = .fitted) +plot_ly(economics, x = ~unemploy / pop, color = ~decade(date), type = "box") # sometimes, a data frame isn't fit for the use case... # for 3D surface plots, a numeric matrix is more natural diff --git a/man/plotly-ggvis.Rd b/man/plotly-ggvis.Rd new file mode 100644 index 0000000000..68297abf99 --- /dev/null +++ b/man/plotly-ggvis.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dplyr.R +\name{plotly-ggvis} +\alias{plotly-ggvis} +\title{Dplyr verbs for plotly.} +\description{ +Dplyr verbs for plotly. +} +\examples{ + +library(dplyr) +plot_ly(mtcars, x = ~wt, y = ~mpg) \%>\% + filter(cyl == 4) \%>\% + add_points() + +} +\keyword{internal} + diff --git a/man/plotly_build.Rd b/man/plotly_build.Rd index 7808dd6db1..697fd11e86 100644 --- a/man/plotly_build.Rd +++ b/man/plotly_build.Rd @@ -18,8 +18,8 @@ errors. \examples{ p <- plot_ly(economics, x = ~date, y = ~pce) -# the unevaluated data -str(p$x$data) +# the unevaluated plotly object +str(p) # the evaluated data str(plotly_build(p)$x$data) diff --git a/tests/testthat.R b/tests/testthat.R index 2260d9352f..9c020f86a1 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -62,7 +62,7 @@ if (report_diffs || build_table) { # object (aka the data behind the plot). save_outputs <- function(gg, name) { print(paste("Running test:", name)) - p <- plotly_build(gg) + p <- plotly_build(gg)$x has_diff <- if (report_diffs) { # save a hash of the R object plot_hash <- digest::digest(p) diff --git a/tests/testthat/test-ggplot-polygons.R b/tests/testthat/test-ggplot-polygons.R index 77f95cfdf7..a4247427a2 100644 --- a/tests/testthat/test-ggplot-polygons.R +++ b/tests/testthat/test-ggplot-polygons.R @@ -24,16 +24,10 @@ test_that("polygons filled with the same color become one trace", { gg <- ggplot(poly.df) + geom_polygon(aes(x, y, group = g)) info <- expect_traces(gg, 1, "black") tr <- info$data[[1]] - expected.x <- - c(10, 11, 11, 10, 10, NA, - 12, 13, 13, 12, 12, NA, - 10, 10) + expected.x <- c(10, 11, 11, 10, 10, NA, 12, 13, 13, 12, 12) expect_equal(tr$x, expected.x) expect_equal(tr$fill, "tozerox") - expected.y <- - c(0, 0, 1, 1, 0, NA, - 0, 0, 1, 1, 0, NA, - 0, 0) + expected.y <- c(0, 0, 1, 1, 0, NA, 0, 0, 1, 1, 0) expect_equal(tr$y, expected.y) }) @@ -156,14 +150,12 @@ test_that("geom_polygon(aes(group)) -> 1 trace", { info <- expect_traces(star.group, 1, "star-group") tr <- info$data[[1]] expect_equal(tr$fill, "tozerox") - expect_equal(tr$x, - c(0, -1, 2, -2, 1, 0, NA, - 10, 9, 12, 8, 11, 10, NA, - 0, 0)) - expect_equal(tr$y, - c(2, 0, 1, 1, 0, 2, NA, - 2, 0, 1, 1, 0, 2, NA, - 2, 2)) + expect_equal( + tr$x, c(0, -1, 2, -2, 1, 0, NA, 10, 9, 12, 8, 11, 10) + ) + expect_equal( + tr$y, c(2, 0, 1, 1, 0, 2, NA, 2, 0, 1, 1, 0, 2) + ) }) star.group.color <- ggplot(stars) + @@ -175,10 +167,10 @@ test_that("geom_polygon(aes(group), color) -> 1 trace", { expect_true(tr$fill == "tozerox") expect_true(tr$line$color == toRGB("red")) expect_equal( - tr$x, c(0, -1, 2, -2, 1, 0, NA, 10, 9, 12, 8, 11, 10, NA, 0, 0) + tr$x, c(0, -1, 2, -2, 1, 0, NA, 10, 9, 12, 8, 11, 10) ) expect_equal( - tr$y, c(2, 0, 1, 1, 0, 2, NA, 2, 0, 1, 1, 0, 2, NA, 2, 2) + tr$y, c(2, 0, 1, 1, 0, 2, NA, 2, 0, 1, 1, 0, 2) ) }) diff --git a/tests/testthat/test-ggplot-rect.R b/tests/testthat/test-ggplot-rect.R index c42ad992c6..e663e67bc9 100644 --- a/tests/testthat/test-ggplot-rect.R +++ b/tests/testthat/test-ggplot-rect.R @@ -49,18 +49,12 @@ test_that('trace contains NA back to 1st rect', { expected.x <- c(1, 1, 1.5, 1.5, 1, NA, 2, 2, 2.5, 2.5, 2, NA, 3, 3, 3.5, 3.5, 3, NA, - 4, 4, 4.5, 4.5, 4, NA, - 3, NA, - 2, NA, - 1, 1) + 4, 4, 4.5, 4.5, 4) expect_equal(tr$x, expected.x) expected.y <- c(0, 1, 1, 0, 0, NA, 0, 1, 1, 0, 0, NA, 0, 1, 1, 0, 0, NA, - 0, 1, 1, 0, 0, NA, - 0, NA, - 0, NA, - 0, 0) + 0, 1, 1, 0, 0) expect_equal(tr$y, expected.y) }) @@ -73,22 +67,18 @@ test_that('rect color', { for(tr in info$data){ expect_true(tr$fillcolor == toRGB("grey")) expect_true(tr$fill == "tozerox") - expect_equal(tr$y, - c(0, 1, 1, 0, 0, NA, - 0, 1, 1, 0, 0, NA, - 0, 0)) + expect_equal(tr$y, c(0, 1, 1, 0, 0, NA, 0, 1, 1, 0, 0)) traces.by.name[[tr$name]] <- tr } - expect_equal(traces.by.name[[1]]$x, - c(1, 1, 1.5, 1.5, 1, NA, - 4, 4, 4.5, 4.5, 4, NA, - 1, 1)) - expect_equal(traces.by.name[[2]]$x, - c(2, 2, 2.5, 2.5, 2, NA, - 3, 3, 3.5, 3.5, 3, NA, - 2, 2)) - expect_false(traces.by.name[[1]]$line$color == - traces.by.name[[2]]$line$color) + expect_equal( + traces.by.name[[1]]$x, c(1, 1, 1.5, 1.5, 1, NA, 4, 4, 4.5, 4.5, 4) + ) + expect_equal( + traces.by.name[[2]]$x,c(2, 2, 2.5, 2.5, 2, NA, 3, 3, 3.5, 3.5, 3) + ) + expect_false( + traces.by.name[[1]]$line$color == traces.by.name[[2]]$line$color + ) }) rect.fill <- ggplot(df4, aes(xmin = x, xmax = x + 0.5, ymin = 0, ymax = 1)) + @@ -100,22 +90,18 @@ test_that('rect color', { for(tr in info$data){ expect_true(tr$line$color == "transparent") expect_true(tr$fill == "tozerox") - expect_equal(tr$y, - c(0, 1, 1, 0, 0, NA, - 0, 1, 1, 0, 0, NA, - 0, 0)) + expect_equal(tr$y, c(0, 1, 1, 0, 0, NA, 0, 1, 1, 0, 0)) traces.by.name[[tr$name]] <- tr } - expect_equal(traces.by.name[[1]]$x, - c(1, 1, 1.5, 1.5, 1, NA, - 4, 4, 4.5, 4.5, 4, NA, - 1, 1)) - expect_equal(traces.by.name[[2]]$x, - c(2, 2, 2.5, 2.5, 2, NA, - 3, 3, 3.5, 3.5, 3, NA, - 2, 2)) - expect_false(traces.by.name[[1]]$fillcolor == - traces.by.name[[2]]$fillcolor) + expect_equal( + traces.by.name[[1]]$x, c(1, 1, 1.5, 1.5, 1, NA, 4, 4, 4.5, 4.5, 4) + ) + expect_equal( + traces.by.name[[2]]$x, c(2, 2, 2.5, 2.5, 2, NA, 3, 3, 3.5, 3.5, 3) + ) + expect_false( + traces.by.name[[1]]$fillcolor == traces.by.name[[2]]$fillcolor + ) }) rect.fill.color <- @@ -128,22 +114,20 @@ test_that('rect aes(fill) with constant color', { for(tr in info$data){ expect_true(tr$line$color == toRGB("black")) expect_true(tr$fill == "tozerox") - expect_equal(tr$y, - c(0, 1, 1, 0, 0, NA, - 0, 1, 1, 0, 0, NA, - 0, 0)) + expect_equal( + tr$y, c(0, 1, 1, 0, 0, NA, 0, 1, 1, 0, 0) + ) traces.by.name[[tr$name]] <- tr } - expect_equal(traces.by.name[[1]]$x, - c(1, 1, 1.5, 1.5, 1, NA, - 4, 4, 4.5, 4.5, 4, NA, - 1, 1)) - expect_equal(traces.by.name[[2]]$x, - c(2, 2, 2.5, 2.5, 2, NA, - 3, 3, 3.5, 3.5, 3, NA, - 2, 2)) - expect_false(traces.by.name[[1]]$fillcolor == - traces.by.name[[2]]$fillcolor) + expect_equal( + traces.by.name[[1]]$x, c(1, 1, 1.5, 1.5, 1, NA, 4, 4, 4.5, 4.5, 4) + ) + expect_equal( + traces.by.name[[2]]$x, c(2, 2, 2.5, 2.5, 2, NA, 3, 3, 3.5, 3.5, 3) + ) + expect_false( + traces.by.name[[1]]$fillcolor == traces.by.name[[2]]$fillcolor + ) }) diff --git a/tests/testthat/test-ggplot-tooltip.R b/tests/testthat/test-ggplot-tooltip.R index 13ef4ddbd2..b8480a3463 100644 --- a/tests/testthat/test-ggplot-tooltip.R +++ b/tests/testthat/test-ggplot-tooltip.R @@ -31,7 +31,7 @@ test_that("dates are displayed in tooltip properly", { test_that("tooltip argument respects ordering", { p <- qplot(mpg, fill = factor(cyl), data = mtcars, geom = "density") p <- ggplotly(p, tooltip = c("density", "x")) - info <- plotly_build(p) + info <- plotly_build(p)$x txt <- strsplit(info$data[[1]]$text, "
") expect_true(all(grepl("^density", sapply(txt, "[[", 1)))) expect_true(all(grepl("^mpg", sapply(txt, "[[", 2)))) @@ -40,7 +40,7 @@ test_that("tooltip argument respects ordering", { test_that("can hide x values in tooltip", { gg2 <- ggplot(mtcars, aes(factor(cyl), mpg, fill = factor(cyl))) + geom_violin() p <- ggplotly(gg2, tooltip = "y") - l <- plotly_build(p) + l <- plotly_build(p)$x expect_equal(sum(grepl("cyl", l$data[[1]]$text)), 0) }) diff --git a/tests/testthat/test-ggplot-violin.R b/tests/testthat/test-ggplot-violin.R index 8d56627484..7b6dc38105 100644 --- a/tests/testthat/test-ggplot-violin.R +++ b/tests/testthat/test-ggplot-violin.R @@ -9,7 +9,7 @@ test_that("basic geom_violin works", { expect_identical(tr$type, "scatter") expect_true(tr$fill == "tozerox") expect_false(tr$showlegend) - expect_true(all(grepl("density", tr$text))) + expect_true(all(grepl("density", tr$text[!is.na(tr$text)]))) expect_true(tr$hoverinfo == "text") }) diff --git a/tests/testthat/test-plotly-subplot.R b/tests/testthat/test-plotly-subplot.R index c1a8ac13b2..3306022dd6 100644 --- a/tests/testthat/test-plotly-subplot.R +++ b/tests/testthat/test-plotly-subplot.R @@ -31,7 +31,7 @@ test_that("nrows argument works", { test_that("group + [x/y]axis works", { iris$id <- as.integer(iris$Species) - p <- plot_ly(iris, x = Petal.Length, y = Petal.Width, group = Species, + p <- plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width, color = ~Species, xaxis = paste0("x", id), mode = "markers") s <- expect_traces(subplot(p, margin = 0.05), 3, "group") ax <- s$layout[grepl("^[x-y]axis", names(s$layout))] From 9409c14daa11072a5e48dac862cd466115b940e5 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 27 May 2016 17:17:57 +1000 Subject: [PATCH 06/73] ggplotly should return information about the data so it works with downstream plotly stuff --- NAMESPACE | 25 +++++++++++++------------ R/ggplotly.R | 21 ++++++++++++++------- R/imports.R | 2 +- R/plotly_build.R | 11 +++++++---- inst/htmlwidgets/plotly.js | 2 +- man/dplyr-plotly.Rd | 24 ++++++++++++------------ 6 files changed, 48 insertions(+), 37 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 65b3806439..6de522b199 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,8 +1,5 @@ # Generated by roxygen2: do not edit by hand -S3method(arrange_,plotly) -S3method(distinct_,plotly) -S3method(filter_,plotly) S3method(geom2trace,GeomBar) S3method(geom2trace,GeomBlank) S3method(geom2trace,GeomBoxplot) @@ -16,19 +13,12 @@ S3method(geom2trace,GeomTile) S3method(geom2trace,default) S3method(ggplotly,ggmatrix) S3method(ggplotly,ggplot) -S3method(group_by_,plotly) -S3method(groups,plotly) S3method(layout,matrix) S3method(layout,plotly) -S3method(mutate_,plotly) S3method(plotly_build,default) S3method(plotly_build,gg) S3method(plotly_build,plotly) S3method(print,plotly_figure) -S3method(rename_,plotly) -S3method(select_,plotly) -S3method(slice_,plotly) -S3method(summarise_,plotly) S3method(to_basic,GeomAbline) S3method(to_basic,GeomArea) S3method(to_basic,GeomBoxplot) @@ -54,8 +44,6 @@ S3method(to_basic,GeomTile) S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) S3method(to_basic,default) -S3method(transmute_,plotly) -S3method(ungroup,plotly) export("%>%") export(add_data) export(add_lines) @@ -63,18 +51,24 @@ export(add_points) export(add_polygons) export(add_text) export(add_trace) +export(arrange_.plotly) export(as.widget) export(config) +export(distinct_.plotly) export(embed_notebook) export(event_data) export(export) +export(filter_.plotly) export(geom2trace) export(get_figure) export(gg2list) export(ggplotly) export(group_by) +export(group_by_.plotly) +export(groups.plotly) export(knit_print.plotly_figure) export(layout) +export(mutate_.plotly) export(offline) export(plot_ly) export(plotly) @@ -84,16 +78,23 @@ export(plotly_POST) export(plotly_build) export(plotly_empty) export(plotly_spec) +export(rename_.plotly) export(renderPlotly) +export(select_.plotly) export(signup) +export(slice_.plotly) export(style) export(subplot) +export(summarise_.plotly) export(toRGB) export(toWebGL) export(to_basic) +export(transmute_.plotly) +export(ungroup.plotly) import(ggplot2) importFrom(base64enc,base64encode) importFrom(dplyr,arrange_) +importFrom(dplyr,distinct_) importFrom(dplyr,do) importFrom(dplyr,group_by) importFrom(dplyr,group_by_) diff --git a/R/ggplotly.R b/R/ggplotly.R index af622228c9..5aee097e4c 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -686,14 +686,21 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A } # If a trace isn't named, it shouldn't have additional hoverinfo traces <- lapply(compact(traces), function(x) { x$name <- x$name %||% ""; x }) - - l <- list(data = setNames(traces, NULL), layout = compact(gglayout)) + + gglayout$width <- width + gglayout$height <- height + + id <- new_id() + l <- list( + visdat = setNames(list(function() data[[length(data)]]), id), + attrs = list(), + cur_data = id, + data = setNames(traces, NULL), + layout = compact(gglayout), + source = source + ) # ensure properties are boxed correctly - l <- add_boxed(rm_asis(l)) - l$layout$width <- width - l$layout$height <- height - l$source <- source - l + add_boxed(rm_asis(l)) } diff --git a/R/imports.R b/R/imports.R index 9ea0951f41..3fa6eeb216 100644 --- a/R/imports.R +++ b/R/imports.R @@ -4,7 +4,7 @@ #' @importFrom utils getFromNamespace modifyList data packageVersion browseURL #' @importFrom stats setNames complete.cases #' @importFrom tidyr gather unnest -#' @importFrom dplyr arrange_ group_by_ do +#' @importFrom dplyr distinct_ arrange_ group_by_ do #' @importFrom viridis viridis #' @importFrom jsonlite toJSON fromJSON #' @importFrom httr GET POST PATCH content config add_headers stop_for_status diff --git a/R/plotly_build.R b/R/plotly_build.R index 47998e2dfa..00c4dd7437 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -20,12 +20,13 @@ plotly_build <- function(p) { } #' @export -plotly_build.default <- identity +plotly_build.default <- function(p) { + p +} #' @export plotly_build.gg <- function(p) { - l <- ggplotly(p) - browser() + ggplotly(p) } #' @export @@ -47,7 +48,7 @@ plotly_build.plotly <- function(p) { p$x$layoutAttrs <- NULL p$x$layout <- modifyList(p$x$layout %||% list(), layouts) - p$x$data <- Map(function(x, y) { + dats <- Map(function(x, y) { is_formula <- vapply(x, is.formula, logical(1)) fl <- lazyeval::as_f_list(x[is_formula] %||% list()) @@ -67,6 +68,8 @@ plotly_build.plotly <- function(p) { }, p$x$attrs, names(p$x$attrs)) + p$x$data <- c(p$x$data, dats) + # get rid of data -> vis mapping stuff p$x[c("visdat", "cur_data", "attrs")] <- NULL diff --git a/inst/htmlwidgets/plotly.js b/inst/htmlwidgets/plotly.js index 2ded06eea1..b406d6759f 100644 --- a/inst/htmlwidgets/plotly.js +++ b/inst/htmlwidgets/plotly.js @@ -27,7 +27,7 @@ HTMLWidgets.widget({ // if no plot exists yet, create one with a particular configuration if (!instance.plotly) { - console.log(x.data); + console.log(x); var plot = Plotly.plot(graphDiv, x.data, x.layout, x.config); instance.plotly = true; instance.autosize = x.layout.autosize; diff --git a/man/dplyr-plotly.Rd b/man/dplyr-plotly.Rd index 7bf060e0fb..f880882b71 100644 --- a/man/dplyr-plotly.Rd +++ b/man/dplyr-plotly.Rd @@ -14,28 +14,28 @@ \alias{transmute_.plotly} \alias{ungroup.plotly} \usage{ -\method{groups}{plotly}(x) +groups.plotly(x) -\method{group_by_}{plotly}(.data, ..., .dots, add = FALSE) +group_by_.plotly(.data, ..., .dots, add = FALSE) -\method{ungroup}{plotly}(x) +ungroup.plotly(x) -\method{summarise_}{plotly}(.data, ..., .dots) +summarise_.plotly(.data, ..., .dots) -\method{mutate_}{plotly}(.data, ..., .dots) +mutate_.plotly(.data, ..., .dots) -\method{arrange_}{plotly}(.data, ..., .dots) +arrange_.plotly(.data, ..., .dots) -\method{select_}{plotly}(.data, ..., .dots) +select_.plotly(.data, ..., .dots) -\method{filter_}{plotly}(.data, ..., .dots) +filter_.plotly(.data, ..., .dots) -\method{distinct_}{plotly}(.data, ..., .dots) +distinct_.plotly(.data, ..., .dots) -\method{slice_}{plotly}(.data, ..., .dots) +slice_.plotly(.data, ..., .dots) -\method{rename_}{plotly}(.data, ..., .dots) +rename_.plotly(.data, ..., .dots) -\method{transmute_}{plotly}(.data, ..., .dots) +transmute_.plotly(.data, ..., .dots) } From 3d10149ce1d5d1f63386035bdebf8124deb4c67e Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 31 May 2016 14:27:58 +1000 Subject: [PATCH 07/73] deprecate group argument in favor of group_by() --- NAMESPACE | 2 - NEWS | 4 +- R/add.R | 23 +++++----- R/dplyr.R | 59 ++++++++++++------------- R/plotly.R | 28 +++++++----- R/plotly_build.R | 8 +++- man/add_trace.Rd | 5 +-- man/group_by.Rd | 18 -------- man/plot_ly.Rd | 6 +-- man/{dplyr-plotly.Rd => plotly-data.Rd} | 29 +++++++++++- man/plotly-ggvis.Rd | 18 -------- 11 files changed, 98 insertions(+), 102 deletions(-) delete mode 100644 man/group_by.Rd rename man/{dplyr-plotly.Rd => plotly-data.Rd} (58%) delete mode 100644 man/plotly-ggvis.Rd diff --git a/NAMESPACE b/NAMESPACE index 6de522b199..c919d9dd3c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -63,7 +63,6 @@ export(geom2trace) export(get_figure) export(gg2list) export(ggplotly) -export(group_by) export(group_by_.plotly) export(groups.plotly) export(knit_print.plotly_figure) @@ -96,7 +95,6 @@ importFrom(base64enc,base64encode) importFrom(dplyr,arrange_) importFrom(dplyr,distinct_) importFrom(dplyr,do) -importFrom(dplyr,group_by) importFrom(dplyr,group_by_) importFrom(grDevices,col2rgb) importFrom(graphics,layout) diff --git a/NEWS b/NEWS index 51fe6cc1d3..478e7ffd9f 100644 --- a/NEWS +++ b/NEWS @@ -3,8 +3,8 @@ MAJOR CHANGES & IMPROVEMENTS: * Formulas (instead of plain expressions) are now required when referring to variable names. For example, `plot_ly(mtcars, x = wt, y = mpg, color = vs)` should now be `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~vs)`. This is a major breaking change, but it is necessary to ensure that evaluation is correct in all contexts (as a result, `evaluate` argument is now deprecated). It also has the benefit of being easier to program with (i.e., writing your own custom functions that wrap `plot_ly()`). For more details, see the [lazyeval vignette](https://github.com/hadley/lazyeval/blob/master/vignettes/lazyeval.Rmd) -* The central object (i.e., the return value and first argument to functions) is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, plotly objects can now be serialized across R sessions and avoid [memory leak issues](https://github.com/rstudio/shiny/issues/1151). This also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `help("dplyr-plotly")` for more details). -* Using the `group` argument (or now, equivalently, the `group_by()` method) will no longer create multiple traces, but instead inserts "gaps" into a given trace via missing values (fixes #418, #381, #577). +* The central object (i.e., the return value and first argument to functions) is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, plotly objects can now be serialized across R sessions and avoid [memory leak issues](https://github.com/rstudio/shiny/issues/1151). This also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `help("plotly-data")` for more details). +* The `group` argument has been deprecated in favor of `group_by()`. Also, groupings will no longer create multiple traces (fixes #418, #381, #577). NEW FEATURES & IMPROVEMENTS: diff --git a/R/add.R b/R/add.R index ed958103c1..d755124909 100644 --- a/R/add.R +++ b/R/add.R @@ -21,8 +21,6 @@ add_data <- function(p, data = NULL) { #' @param p a plotly or ggplot object. #' @param ... These arguments are documented in the references section below. #' Note that acceptable arguments depend on the trace type. -#' @param group Either a variable name or a vector to use for grouping. If used, -#' a different trace will be created for each unique value. #' @param color Either a variable name or a vector to use for color mapping. #' @param colors Either a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"), #' or a vector of colors to interpolate in hexadecimal "#RRGGBB" format, @@ -38,18 +36,23 @@ add_data <- function(p, data = NULL) { #' @author Carson Sievert #' @export add_trace <- function(p, ..., - group, color, colors, symbol, symbols, size, data = NULL) { + color, colors, symbol, symbols, size, data = NULL) { # "native" plotly arguments argz <- list(...) - # tack on "special" arguments - if (!missing(group)) argz$group <- substitute(group) - if (!missing(color)) argz$color <- substitute(color) - if (!missing(colors)) argz$colors <- substitute(colors) - if (!missing(symbol)) argz$symbol <- substitute(symbol) - if (!missing(symbols)) argz$symbols <- substitute(symbols) - if (!missing(size)) argz$size <- substitute(size) + argz$type <- verify_type(argz$type) + if (!is.null(argz[["group"]])) { + warning("The group argument has been deprecated. Use group_by() instead.") + } + + # tack on "special" arguments + argz$color <- verify_arg(color) + argz$colors <- verify_arg(colors) + argz$symbol <- verify_arg(symbol) + argz$symbols <- verify_arg(symbols) + argz$size <- verify_arg(size) + p <- add_data(p, data) p$x$attrs[[p$x$cur_data]] <- argz p diff --git a/R/dplyr.R b/R/dplyr.R index f0b9f3ccd3..0bc3c7af97 100644 --- a/R/dplyr.R +++ b/R/dplyr.R @@ -1,36 +1,37 @@ -#' Dplyr verbs for plotly. +#' Data manipulation verbs for plotly. #' -#' @name plotly-ggvis +#' @name plotly-data #' @keywords internal #' @examples #' +#' # loading dplyr is super important! #' library(dplyr) -#' plot_ly(mtcars, x = ~wt, y = ~mpg) %>% -#' filter(cyl == 4) %>% -#' add_points() #' -NULL - -#' Divide data into groups. +#' mtcars %>% +#' plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") %>% +#' filter(cyl == 4) %>% +#' add_points(x = ~wt, y = ~mpg, name = "filtered points", +#' marker = list(color = "red")) +#' +#' library(tidyr) +#' economics %>% +#' gather(variable, value, -date) %>% +#' group_by(variable) %>% +#' plot_ly(x = ~date, y = ~value) +#' +#' #' -#' @param p a plotly visualization. -#' @param ... variables to group by. -#' @param add By default, when \code{add = FALSE}, \code{group_by} will -#' override existing groups. To instead add to the existing groups, -#' use \code{add = TRUE} -#' @importFrom dplyr group_by -#' @name group_by -#' @export +#' NULL #' @export -#' @rdname dplyr-plotly +#' @rdname plotly-data groups.plotly <- function(x) { dplyr::groups(plotly_data(x)) } #' @export -#' @rdname dplyr-plotly +#' @rdname plotly-data group_by_.plotly <- function(.data, ..., .dots, add = FALSE) { d <- plotly_data(.data) d <- dplyr::group_by_(d, .dots = lazyeval::all_dots(.dots, ...), add = add) @@ -39,13 +40,12 @@ group_by_.plotly <- function(.data, ..., .dots, add = FALSE) { } #' @export -#' @rdname dplyr-plotly +#' @rdname plotly-data ungroup.plotly <- function(x) { dplyr::ungroup(plotly_data(x)) } - -#' @rdname dplyr-plotly +#' @rdname plotly-data #' @export summarise_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) @@ -53,7 +53,7 @@ summarise_.plotly <- function(.data, ..., .dots) { add_data(.data, d) } -#' @rdname dplyr-plotly +#' @rdname plotly-data #' @export mutate_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) @@ -61,7 +61,7 @@ mutate_.plotly <- function(.data, ..., .dots) { add_data(.data, d) } -#' @rdname dplyr-plotly +#' @rdname plotly-data #' @export arrange_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) @@ -69,7 +69,7 @@ arrange_.plotly <- function(.data, ..., .dots) { add_data(.data, d) } -#' @rdname dplyr-plotly +#' @rdname plotly-data #' @export select_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) @@ -77,7 +77,7 @@ select_.plotly <- function(.data, ..., .dots) { add_data(.data, d) } -#' @rdname dplyr-plotly +#' @rdname plotly-data #' @export filter_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) @@ -85,7 +85,7 @@ filter_.plotly <- function(.data, ..., .dots) { add_data(.data, d) } -#' @rdname dplyr-plotly +#' @rdname plotly-data #' @export distinct_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) @@ -93,7 +93,7 @@ distinct_.plotly <- function(.data, ..., .dots) { add_data(.data, d) } -#' @rdname dplyr-plotly +#' @rdname plotly-data #' @export slice_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) @@ -101,7 +101,7 @@ slice_.plotly <- function(.data, ..., .dots) { add_data(.data, d) } -#' @rdname dplyr-plotly +#' @rdname plotly-data #' @export rename_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) @@ -109,7 +109,7 @@ rename_.plotly <- function(.data, ..., .dots) { add_data(.data, d) } -#' @rdname dplyr-plotly +#' @rdname plotly-data #' @export transmute_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) @@ -117,7 +117,6 @@ transmute_.plotly <- function(.data, ..., .dots) { add_data(.data, d) } - #' Insert missing values to create trace groupings #' #' If a group of traces share the same non-positional characteristics (i.e., diff --git a/R/plotly.R b/R/plotly.R index b260219ec4..f60ab67eba 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -9,8 +9,6 @@ #' @param ... These arguments are documented at \url{https://plot.ly/r/reference/} #' Note that acceptable arguments depend on the value of \code{type}. #' @param type A character string describing the type of trace. -#' @param group Either a variable name or a vector to use for grouping. If used, -#' a different trace will be created for each unique value. #' @param color Either a variable name or a vector to use for color mapping. #' @param colors Either a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"), #' or a vector of colors to interpolate in hexadecimal "#RRGGBB" format, @@ -38,6 +36,7 @@ #' # change the font #' layout(p3, font = list(family = "Courier New, monospace")) #' +#' #' # using the color argument #' plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, mode = "markers") #' plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, @@ -56,32 +55,37 @@ #' } #' plot_ly <- function(data = data.frame(), ..., type = NULL, - group, color, colors, symbol, symbols, size, + color, colors, symbol, symbols, size, width = NULL, height = NULL, inherit = FALSE, source = "A") { # "native" plotly arguments argz <- list(...) # old arguments to this function that are no longer supported - if (!is.null(argz$filename)) - warning("Ignoring filename. Use plotly_POST() if you want to post figures to plotly.") - if (!is.null(argz$fileopt)) - warning("Ignoring fileopt. Use plotly_POST() if you want to post figures to plotly.") - if (!is.null(argz$world_readable)) - warning("Ignoring world_readable. Use plotly_POST() if you want to post figures to plotly.") + for (i in c("filename", "fileopt", "world_readable")) { + if (is.null(argz[[i]])) next + warning("Ignoring ", i, ". Use plotly_POST() if you want to post figures to plotly.") + } + if (!is.null(argz[["group"]])) { + warning("The group argument has been deprecated. Use group_by() instead.") + } + + # if type is NULL, return the default trace type with a message + # if type is invalid, throw an error + argz$type <- verify_type(type) # tack on "special" arguments - argz$group <- verify_arg(group) argz$color <- verify_arg(color) argz$symbol <- verify_arg(symbol) argz$size <- verify_arg(size) # TODO: do we really need to verify these? argz$colors <- verify_arg(colors) argz$symbols <- verify_arg(symbols) - argz$type <- verify_type(type) # id for tracking attribute mappings and finding the most current data id <- new_id() + # avoid weird naming clashes + plotlyVisDat <- data p <- list( - visdat = setNames(list(function() data), id), + visdat = setNames(list(function() plotlyVisDat), id), cur_data = id, attrs = setNames(list(argz), id), # we always deal with a _list_ of traces and _list_ of layouts diff --git a/R/plotly_build.R b/R/plotly_build.R index 00c4dd7437..9d74e85b2e 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -52,8 +52,14 @@ plotly_build.plotly <- function(p) { is_formula <- vapply(x, is.formula, logical(1)) fl <- lazyeval::as_f_list(x[is_formula] %||% list()) + d <- plotly_data(p, y) + grps <- dplyr::groups(d) + # insert missing values to differentiate groups + if (length(grps) > 0) { + d <- group2NA(d, as.character(grps)) + } for (var in names(fl)) { - x[[var]] <- lazyeval::f_eval(fl[[var]], plotly_data(p, y)) + x[[var]] <- lazyeval::f_eval(fl[[var]], d) varname <- sub("^~", "", deparse2(fl[[var]])) # deparse axis names and add to layout if (any(c("x", "y", "z") %in% var)) { diff --git a/man/add_trace.Rd b/man/add_trace.Rd index 08d97d8f08..65a3f9d234 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -4,7 +4,7 @@ \alias{add_trace} \title{Add a trace to a plotly visualization} \usage{ -add_trace(p, ..., group, color, colors, symbol, symbols, size, data = NULL) +add_trace(p, ..., color, colors, symbol, symbols, size, data = NULL) } \arguments{ \item{p}{a plotly or ggplot object.} @@ -12,9 +12,6 @@ add_trace(p, ..., group, color, colors, symbol, symbols, size, data = NULL) \item{...}{These arguments are documented in the references section below. Note that acceptable arguments depend on the trace type.} -\item{group}{Either a variable name or a vector to use for grouping. If used, -a different trace will be created for each unique value.} - \item{color}{Either a variable name or a vector to use for color mapping.} \item{colors}{Either a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"), diff --git a/man/group_by.Rd b/man/group_by.Rd deleted file mode 100644 index 29302f0fdc..0000000000 --- a/man/group_by.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/dplyr.R -\name{group_by} -\alias{group_by} -\title{Divide data into groups.} -\arguments{ -\item{p}{a plotly visualization.} - -\item{...}{variables to group by.} - -\item{add}{By default, when \code{add = FALSE}, \code{group_by} will -override existing groups. To instead add to the existing groups, -use \code{add = TRUE}} -} -\description{ -Divide data into groups. -} - diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index ab138656da..da2c63ffea 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -4,7 +4,7 @@ \alias{plot_ly} \title{Initiate a plotly visualization} \usage{ -plot_ly(data = data.frame(), ..., type = NULL, group, color, colors, symbol, +plot_ly(data = data.frame(), ..., type = NULL, color, colors, symbol, symbols, size, width = NULL, height = NULL, inherit = FALSE, source = "A") } @@ -16,9 +16,6 @@ Note that acceptable arguments depend on the value of \code{type}.} \item{type}{A character string describing the type of trace.} -\item{group}{Either a variable name or a vector to use for grouping. If used, -a different trace will be created for each unique value.} - \item{color}{Either a variable name or a vector to use for color mapping.} \item{colors}{Either a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"), @@ -59,6 +56,7 @@ p3 <- layout(p2, title = "Median duration of unemployment (in weeks)") # change the font layout(p3, font = list(family = "Courier New, monospace")) + # using the color argument plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, mode = "markers") plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, diff --git a/man/dplyr-plotly.Rd b/man/plotly-data.Rd similarity index 58% rename from man/dplyr-plotly.Rd rename to man/plotly-data.Rd index f880882b71..a55ae3a7a0 100644 --- a/man/dplyr-plotly.Rd +++ b/man/plotly-data.Rd @@ -1,18 +1,20 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/dplyr.R -\name{groups.plotly} +\name{plotly-data} \alias{arrange_.plotly} \alias{distinct_.plotly} \alias{filter_.plotly} \alias{group_by_.plotly} \alias{groups.plotly} \alias{mutate_.plotly} +\alias{plotly-data} \alias{rename_.plotly} \alias{select_.plotly} \alias{slice_.plotly} \alias{summarise_.plotly} \alias{transmute_.plotly} \alias{ungroup.plotly} +\title{Data manipulation verbs for plotly.} \usage{ groups.plotly(x) @@ -38,4 +40,29 @@ rename_.plotly(.data, ..., .dots) transmute_.plotly(.data, ..., .dots) } +\description{ +Data manipulation verbs for plotly. +} +\examples{ + +# loading dplyr is super important! +library(dplyr) + +mtcars \%>\% + plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") \%>\% + filter(cyl == 4) \%>\% + add_points(x = ~wt, y = ~mpg, name = "filtered points", + marker = list(color = "red")) + +library(tidyr) +economics \%>\% + gather(variable, value, -date) \%>\% + group_by(variable) \%>\% + plot_ly(x = ~date, y = ~value) + + + + +} +\keyword{internal} diff --git a/man/plotly-ggvis.Rd b/man/plotly-ggvis.Rd deleted file mode 100644 index 68297abf99..0000000000 --- a/man/plotly-ggvis.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/dplyr.R -\name{plotly-ggvis} -\alias{plotly-ggvis} -\title{Dplyr verbs for plotly.} -\description{ -Dplyr verbs for plotly. -} -\examples{ - -library(dplyr) -plot_ly(mtcars, x = ~wt, y = ~mpg) \%>\% - filter(cyl == 4) \%>\% - add_points() - -} -\keyword{internal} - From becb1226bec97915ab8f398324938b14f35c972f Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 1 Jun 2016 11:24:37 +1000 Subject: [PATCH 08/73] always inherit arguments from plot_ly() --- NAMESPACE | 12 +- NEWS | 8 +- R/add.R | 70 +++++++- R/helpers.R | 16 +- R/plotly.R | 10 +- R/plotly_build.R | 4 +- R/plotly_data.R | 163 ++++++++++++++++++ R/utils.R | 5 - inst/docs.R | 5 +- .../lib/plotlyjs/plotly-latest.min.js | 78 ++++----- man/add_chull.Rd | 14 ++ man/add_polygons.Rd | 17 ++ man/group2NA.Rd | 23 ++- man/plot_ly.Rd | 5 +- man/plotly-data.Rd | 6 +- man/plotly_data.Rd | 69 ++++++++ man/plotly_spec.Rd | 4 +- 17 files changed, 431 insertions(+), 78 deletions(-) create mode 100644 R/plotly_data.R create mode 100644 man/add_chull.Rd create mode 100644 man/add_polygons.Rd create mode 100644 man/plotly_data.Rd diff --git a/NAMESPACE b/NAMESPACE index c919d9dd3c..c0001103cf 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,7 @@ # Generated by roxygen2: do not edit by hand +S3method(arrange_,plotly) +S3method(distinct_,plotly) S3method(geom2trace,GeomBar) S3method(geom2trace,GeomBlank) S3method(geom2trace,GeomBoxplot) @@ -13,6 +15,7 @@ S3method(geom2trace,GeomTile) S3method(geom2trace,default) S3method(ggplotly,ggmatrix) S3method(ggplotly,ggplot) +S3method(group_by_,plotly) S3method(layout,matrix) S3method(layout,plotly) S3method(plotly_build,default) @@ -45,16 +48,19 @@ S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) S3method(to_basic,default) export("%>%") +export(add_annotation) +export(add_chull) export(add_data) export(add_lines) export(add_points) export(add_polygons) +export(add_ribbons) +export(add_shape) export(add_text) export(add_trace) -export(arrange_.plotly) +export(add_transform) export(as.widget) export(config) -export(distinct_.plotly) export(embed_notebook) export(event_data) export(export) @@ -63,7 +69,6 @@ export(geom2trace) export(get_figure) export(gg2list) export(ggplotly) -export(group_by_.plotly) export(groups.plotly) export(knit_print.plotly_figure) export(layout) @@ -75,6 +80,7 @@ export(plotlyOutput) export(plotly_IMAGE) export(plotly_POST) export(plotly_build) +export(plotly_data) export(plotly_empty) export(plotly_spec) export(rename_.plotly) diff --git a/NEWS b/NEWS index 478e7ffd9f..7a04124a35 100644 --- a/NEWS +++ b/NEWS @@ -4,12 +4,15 @@ MAJOR CHANGES & IMPROVEMENTS: * Formulas (instead of plain expressions) are now required when referring to variable names. For example, `plot_ly(mtcars, x = wt, y = mpg, color = vs)` should now be `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~vs)`. This is a major breaking change, but it is necessary to ensure that evaluation is correct in all contexts (as a result, `evaluate` argument is now deprecated). It also has the benefit of being easier to program with (i.e., writing your own custom functions that wrap `plot_ly()`). For more details, see the [lazyeval vignette](https://github.com/hadley/lazyeval/blob/master/vignettes/lazyeval.Rmd) * The central object (i.e., the return value and first argument to functions) is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, plotly objects can now be serialized across R sessions and avoid [memory leak issues](https://github.com/rstudio/shiny/issues/1151). This also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `help("plotly-data")` for more details). -* The `group` argument has been deprecated in favor of `group_by()`. Also, groupings will no longer create multiple traces (fixes #418, #381, #577). +* The `group` argument is deprecated. Groups should be added to the data via `dplyr::group_by()`. Also, groupings will no longer create multiple traces (fixes #418, #381, #577). +* The `inherit` argument is deprecated. Any arguments/attributes specified in `plot_ly()` will automatically be passed along to additional traces added via `add_trace()` (or any of it's `add_*()` siblings). + +Traces created via `add_trace()` (or, more generally, by any `add_*()` function), will inherit _required_ attributes from parent traces. NEW FEATURES & IMPROVEMENTS: -* Error checking for trace types. +* Error checking for trace types and their attributes. * New `add_points()`/`add_lines()`/`add_text()` functions provide a shorthand for common plots. * New `toWebGL()` function for easy conversion from SVG to WebGL. * New `export()` function makes it easy to save plots as png/jpeg/pdf (fixes #311). @@ -17,7 +20,6 @@ NEW FEATURES & IMPROVEMENTS: * Added a `plotly_spec()` function for inspecting the data sent to plotly.js (as an R list or JSON). - 3.6.2 -- 24 May 2016 CHANGES: diff --git a/R/add.R b/R/add.R index d755124909..18924ab073 100644 --- a/R/add.R +++ b/R/add.R @@ -35,6 +35,12 @@ add_data <- function(p, data = NULL) { #' @references \url{https://plot.ly/r/reference/} #' @author Carson Sievert #' @export +#' @examples +#' +#' p <- plot_ly(economics, x = ~date, y = ~uempmed) +#' # add a loess smoother +#' p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) +#' add_trace <- function(p, ..., color, colors, symbol, symbols, size, data = NULL) { # "native" plotly arguments @@ -54,7 +60,14 @@ add_trace <- function(p, ..., argz$size <- verify_arg(size) p <- add_data(p, data) - p$x$attrs[[p$x$cur_data]] <- argz + + # inherit arguments from the "first layer" + new_attrs <- modifyList(p$x$attrs[[1]] %||% list(), argz) + p$x$attrs <- c( + p$x$attrs %||% list(), + setNames(list(new_attrs), p$x$cur_data) + ) + p } @@ -74,8 +87,61 @@ add_text <- function(p, ...) { } #' @export +#' @examples +#' +#' library(dplyr) +#' data(canada.cities, package = "maps") +#' +#' ggplot2::map_data("world", "canada") %>% +#' group_by(group) %>% +#' plot_ly(x = ~long, y = ~lat, hoverinfo = "none") %>% +#' add_points(text = ~paste(name, "
", pop), hoverinfo = "text", +#' data = canada.cities) %>% +#' layout(showlegend = FALSE) add_polygons <- function(p, ...) { # TODO: Should mode='markers+lines'? If so, retrace first points? - add_trace(p, type = "scatter", mode = "none", fill = "toself", ...) + add_trace(p, type = "scatter", mode = "lines", fill = "toself", ...) } +#' @export +add_ribbons <- function(p, ...) { + # TODO: Should mode='markers+lines'? If so, retrace first points? + add_polygons(...) +} + + +#' @export +#' @examples +#' +#' x <- rnorm(10) +#' plot_ly(x = ~x) %>% +#' add_chull() +add_chull <- function(p, ...) { + stop("not yet implemented") + ch <- chull(x, y = NULL) + # TODO: Should mode='markers+lines'? If so, retrace first points? + add_polygons(...) +} + + +# ------------------------------------------------------------------------ +# Non-trace addition +# ------------------------------------------------------------------------ + +#' @export +add_transform <- function(p, ...) { + stop("not yet implemented") +} + + +#' @export +add_shape <- function(p, ...) { + stop("not yet implemented") +} + +#' @export +add_annotation <- function(p, ...) { + stop("not yet implemented") +} + + diff --git a/R/helpers.R b/R/helpers.R index 609e97fb10..4cdb343b94 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -4,17 +4,21 @@ #' debugging. #' #' @param p a plotly or ggplot object. +#' @param attr focus on a particular attribute in the spec. #' @param as in what format should the spec be printed? -#' @param ... arguments passed onto \code{jsonlite::toJSON} +#' @param pretty adds indentation whitespace to JSON output. #' @export #' @examples #' -#' plotly_spec(plot_ly(), as = "json", pretty = TRUE) +#' plotly_spec(plot_ly(), "data") -plotly_spec <- function(p = plot_ly(), as = c("plain", "json"), ...) { +plotly_spec <- function(p = plot_ly(), attr = NULL, as = c("json", "plain"), pretty = TRUE) { spec <- plotly_build(p)$x + if (!is.null(attr)) { + spec <- spec[[attr]] + } if (identical("json", match.arg(as))) { - return(to_JSON(spec, ...)) + return(to_JSON(spec, pretty = pretty)) } spec } @@ -56,11 +60,11 @@ toWebGL <- function(p, warn = TRUE) { #' Useful when used with \link{subplot} #' #' @export -plotly_empty <- function() { +plotly_empty <- function(...) { eaxis <- list( showticklabels = FALSE, showgrid = FALSE, zeroline = FALSE ) - layout(plot_ly(), xaxis = eaxis, yaxis = eaxis) + layout(plot_ly(...), xaxis = eaxis, yaxis = eaxis) } diff --git a/R/plotly.R b/R/plotly.R index f60ab67eba..164e3a1c34 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -19,7 +19,6 @@ #' @param size A variable name or numeric vector to encode the size of markers. #' @param width Width in pixels (optional, defaults to automatic sizing). #' @param height Height in pixels (optional, defaults to automatic sizing). -#' @param inherit logical. Should future traces inherit properties from this initial trace? #' @param source Only relevant for \link{event_data}. #' @seealso \code{\link{layout}()}, \code{\link{add_trace}()}, \code{\link{style}()} #' @author Carson Sievert @@ -28,7 +27,7 @@ #' \dontrun{ #' data(economics, package = "ggplot2") #' # basic time-series plot -#' p <- plot_ly(economics, x = ~date, y = ~uempmed, inherit = TRUE) +#' p <- plot_ly(economics, x = ~date, y = ~uempmed) #' # add a loess smoother #' p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) #' # add a title @@ -56,8 +55,7 @@ #' plot_ly <- function(data = data.frame(), ..., type = NULL, color, colors, symbol, symbols, size, - width = NULL, height = NULL, inherit = FALSE, - source = "A") { + width = NULL, height = NULL, source = "A") { # "native" plotly arguments argz <- list(...) # old arguments to this function that are no longer supported @@ -68,6 +66,9 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, if (!is.null(argz[["group"]])) { warning("The group argument has been deprecated. Use group_by() instead.") } + if (!is.null(argz[["inherit"]])) { + warning("The inherit argument has been deprecated.") + } # if type is NULL, return the default trace type with a message # if type is invalid, throw an error @@ -97,7 +98,6 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, margin = list(b = 40, l = 60, t = 25, r = 10) ), config = list(modeBarButtonsToRemove = I("sendDataToCloud")), - inherit = inherit, base_url = get_domain() ) diff --git a/R/plotly_build.R b/R/plotly_build.R index 9d74e85b2e..a31adeabc6 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -42,11 +42,11 @@ plotly_build.plotly <- function(p) { x[lengths(x) > 0] }, p$x$layoutAttrs, names(p$x$layoutAttrs)) - + # get rid of the data -> layout mapping and merge all the layouts # into a single layout (more recent layouts will override older ones) p$x$layoutAttrs <- NULL - p$x$layout <- modifyList(p$x$layout %||% list(), layouts) + p$x$layout <- modifyList(p$x$layout %||% list(), Reduce(modifyList, layouts)) dats <- Map(function(x, y) { diff --git a/R/plotly_data.R b/R/plotly_data.R new file mode 100644 index 0000000000..3333369e82 --- /dev/null +++ b/R/plotly_data.R @@ -0,0 +1,163 @@ +#' View and manipulate data associated with a plotly graph +#' +#' \code{plotly_data()} returns the data associated with +#' a plotly visualization. This data can be manipulated via +#' the dplyr and tidyr verbs listed below: +#' +#' +#' @name plotly_data +#' @keywords internal +#' @examples +#' +#' # loading dplyr is super important! +#' library(dplyr) +#' +#' mtcars %>% +#' plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") %>% +#' filter(cyl == 4) %>% +#' add_points(x = ~wt, y = ~mpg, name = "filtered points", +#' marker = list(color = "red")) +#' +#' library(tidyr) +#' economics %>% +#' gather(variable, value, -date) %>% +#' group_by(variable) %>% +#' plot_ly(x = ~date, y = ~value) +#' +NULL + +#' @export +#' @rdname plotly_data +plotly_data <- function(p, id = p$x$cur_data) { + p$x$visdat[[id]]() %||% data.frame() +} + +#' @export +#' @rdname plotly_data +groups.plotly <- function(x) { + dplyr::groups(plotly_data(x)) +} + +#' @export +#' @rdname plotly_data +group_by_.plotly <- function(.data, ..., .dots, add = FALSE) { + d <- plotly_data(.data) + d <- dplyr::group_by_(d, .dots = lazyeval::all_dots(.dots, ...), add = add) + # TODO: where to use group2NA? In plotly_build() + add_data(.data, d) +} + +#' @export +#' @rdname plotly_data +ungroup.plotly <- function(x) { + dplyr::ungroup(plotly_data(x)) +} + +#' @rdname plotly_data +#' @export +summarise_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::summarise_(d, .dots = lazyeval::all_dots(.dots, ...)) + add_data(.data, d) +} + +#' @rdname plotly_data +#' @export +mutate_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::mutate_(d, .dots = lazyeval::all_dots(.dots, ...)) + add_data(.data, d) +} + +#' @rdname plotly_data +#' @export +arrange_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::arrange_(d, .dots = lazyeval::all_dots(.dots, ...)) + add_data(.data, d) +} + +#' @rdname plotly_data +#' @export +select_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::select_(d, .dots = lazyeval::all_dots(.dots, ...)) + add_data(.data, d) +} + +#' @rdname plotly_data +#' @export +filter_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::filter_(d, .dots = lazyeval::all_dots(.dots, ...)) + add_data(.data, d) +} + +#' @rdname plotly_data +#' @export +distinct_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::distinct_(d, ..., .dots, add = add) + add_data(.data, d) +} + +#' @rdname plotly_data +#' @export +slice_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::slice_(d, ..., .dots, add = add) + add_data(.data, d) +} + +#' @rdname plotly_data +#' @export +rename_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::rename_(d, ..., .dots, add = add) + add_data(.data, d) +} + +#' @rdname plotly_data +#' @export +transmute_.plotly <- function(.data, ..., .dots) { + d <- plotly_data(.data) + d <- dplyr::transmute_(d, ..., .dots, add = add) + add_data(.data, d) +} + +#' Insert missing values to create trace groupings +#' +#' If a group of traces share the same non-positional characteristics (i.e., +#' color, fill, etc), it is more efficient to draw them as a single trace +#' with missing values that separate the groups (instead of multiple traces). +#' This is a helper function for inserting missing values into a data set +#' +#' @param data a data frame. +#' @param groupNames name(s) of the grouping variable(s) as a character vector +#' @param nested other variables that group should be nested +#' (i.e., ordered) within. +#' @param retrace.first should the first row of each group be appended to the +#' last row? This is useful for enclosing polygons with lines. +#' @examples +#' elong <- tidyr::gather(economics, variable, value, -date) +#' plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) +#' + +group2NA <- function(data, groupNames = "group", nested = NULL, + retrace.first = inherits(data, "GeomPolygon")) { + if (nrow(data) == 0) return(data) + nested <- nested[nested %in% names(data)] + if (length(nested)) { + data <- dplyr::arrange_(data, nested) + } + d <- dplyr::group_by_(data, groupNames) + d <- if (retrace.first) { + dplyr::do(d, rbind(., .[1,], NA)) + } else { + dplyr::do(d, rbind(., NA)) + } + d <- tidyr::unnest(d) + n <- nrow(d) + if (all(is.na(d[n, ]))) d <- d[-n, ] + structure(d, class = unique(class(data), class(d))) +} diff --git a/R/utils.R b/R/utils.R index bd2ad9488c..deac0953fe 100644 --- a/R/utils.R +++ b/R/utils.R @@ -26,11 +26,6 @@ new_id <- function() { basename(tempfile("")) } -# obtain the current data from a plotly vis -plotly_data <- function(p, id = p$x$cur_data) { - p$x$visdat[[id]]() -} - verify_arg <- function(arg) { if (missing(arg)) return(NULL) if (!is.formula(arg)) { diff --git a/inst/docs.R b/inst/docs.R index 1dc2137e5c..413a810494 100644 --- a/inst/docs.R +++ b/inst/docs.R @@ -440,7 +440,7 @@ g2 <- c( plot_ly(df, type = 'scattergeo', mode = 'markers', locations = Country, locationmode = 'country names', text = paste(Value, "cases"), - color = as.ordered(abbrev), marker = list(size = Value/50), inherit = F) %>% + color = as.ordered(abbrev), marker = list(size = Value/50)) %>% add_trace(type = 'scattergeo', mode = 'text', geo = 'geo2', showlegend = F, lon = 21.0936, lat = 7.1881, text = 'Africa') %>% add_trace(type = 'choropleth', locations = Country, locationmode = 'country names', @@ -470,8 +470,7 @@ geo <- list( ) plot_ly(air, lon = long, lat = lat, text = airport, type = 'scattergeo', - locationmode = 'USA-states', marker = list(size = 2, color = 'red'), - inherit = FALSE) %>% + locationmode = 'USA-states', marker = list(size = 2, color = 'red')) %>% add_trace(lon = list(start_lon, end_lon), lat = list(start_lat, end_lat), group = id, opacity = cnt/max(cnt), data = flights, mode = 'lines', line = list(width = 1, color = 'red'), diff --git a/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js b/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js index 08e5b506a7..1f35fd075f 100644 --- a/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js +++ b/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js @@ -1,44 +1,44 @@ /** -* plotly.js v1.11.0 +* plotly.js v1.10.1 * Copyright 2012-2016, Plotly, Inc. * All rights reserved. * Licensed under the MIT license */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Plotly=t()}}(function(){var t;return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,function(e){var r=t[o][1][e];return i(r?r:e)},u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;or;++r)e[r]=0;return e}function o(t,e,r){switch(arguments.length){case 0:return new i([0],[0],0);case 1:if("number"==typeof t){var n=a(t);return new i(n,n,0)}return new i(t,a(t.length),0);case 2:if("number"==typeof e){var n=a(t.length);return new i(t,n,+e)}r=0;case 3:if(t.length!==e.length)throw new Error("state and velocity lengths must match");return new i(t,e,r)}}e.exports=o;var s=t("cubic-hermite"),l=t("binary-search-bounds"),c=i.prototype;c.flush=function(t){var e=l.gt(this._time,t)-1;0>=e||(this._time.splice(0,e),this._state.splice(0,e*this.dimension),this._velocity.splice(0,e*this.dimension))},c.curve=function(t){var e=this._time,r=e.length,i=l.le(e,t),a=this._scratch[0],o=this._state,c=this._velocity,u=this.dimension,f=this.bounds;if(0>i)for(var h=u-1,d=0;u>d;++d,--h)a[d]=o[h];else if(i>=r-1)for(var h=o.length-1,p=t-e[r-1],d=0;u>d;++d,--h)a[d]=o[h]+p*c[h];else{for(var h=u*(i+1)-1,g=e[i],v=e[i+1],m=v-g||1,y=this._scratch[1],b=this._scratch[2],x=this._scratch[3],_=this._scratch[4],w=!0,d=0;u>d;++d,--h)y[d]=o[h],x[d]=c[h]*m,b[d]=o[h+u],_[d]=c[h+u]*m,w=w&&y[d]===b[d]&&x[d]===_[d]&&0===x[d];if(w)for(var d=0;u>d;++d)a[d]=y[d];else s(y,x,b,_,(t-g)/m,a)}for(var k=f[0],A=f[1],d=0;u>d;++d)a[d]=n(k[d],A[d],a[d]);return a},c.dcurve=function(t){var e=this._time,r=e.length,n=l.le(e,t),i=this._scratch[0],a=this._state,o=this._velocity,c=this.dimension;if(n>=r-1)for(var u=a.length-1,f=(t-e[r-1],0);c>f;++f,--u)i[f]=o[u];else{for(var u=c*(n+1)-1,h=e[n],d=e[n+1],p=d-h||1,g=this._scratch[1],v=this._scratch[2],m=this._scratch[3],y=this._scratch[4],b=!0,f=0;c>f;++f,--u)g[f]=a[u],m[f]=o[u]*p,v[f]=a[u+c],y[f]=o[u+c]*p,b=b&&g[f]===v[f]&&m[f]===y[f]&&0===m[f];if(b)for(var f=0;c>f;++f)i[f]=0;else{s.derivative(g,m,v,y,(t-h)/p,i);for(var f=0;c>f;++f)i[f]/=p}}return i},c.lastT=function(){var t=this._time;return t[t.length-1]},c.stable=function(){for(var t=this._velocity,e=t.length,r=this.dimension-1;r>=0;--r)if(t[--e])return!1;return!0},c.jump=function(t){var e=this.lastT(),r=this.dimension;if(!(e>t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1];this._time.push(e,t);for(var u=0;2>u;++u)for(var f=0;r>f;++f)i.push(i[o++]),a.push(0);this._time.push(t);for(var f=r;f>0;--f)i.push(n(l[f-1],c[f-1],arguments[f])),a.push(0)}},c.push=function(t){var e=this.lastT(),r=this.dimension;if(!(e>t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=t-e,l=this.bounds,c=l[0],u=l[1],f=s>1e-6?1/s:0;this._time.push(t);for(var h=r;h>0;--h){var d=n(c[h-1],u[h-1],arguments[h]);i.push(d),a.push((d-i[o++])*f)}}},c.set=function(t){var e=this.dimension;if(!(t0;--l)r.push(n(o[l-1],s[l-1],arguments[l])),i.push(0)}},c.move=function(t){var e=this.lastT(),r=this.dimension;if(!(e>=t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1],u=t-e,f=u>1e-6?1/u:0;this._time.push(t);for(var h=r;h>0;--h){var d=arguments[h];i.push(n(l[h-1],c[h-1],i[o++]+d)),a.push(d*f)}}},c.idle=function(t){var e=this.lastT();if(!(e>t)){var r=this.dimension,i=this._state,a=this._velocity,o=i.length-r,s=this.bounds,l=s[0],c=s[1],u=t-e;this._time.push(t);for(var f=r-1;f>=0;--f)i.push(n(l[f],c[f],i[o]+u*a[o])),a.push(0),o+=1}}},{"binary-search-bounds":21,"cubic-hermite":22}],21:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],22:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=6*i*i-6*i,s=3*i*i-4*i+1,l=-6*i*i+6*i,c=3*i*i-2*i;if(t.length){a||(a=new Array(t.length));for(var u=t.length-1;u>=0;--u)a[u]=o*t[u]+s*e[u]+l*r[u]+c*n[u];return a}return o*t+s*e+l*r[u]+c*n}function i(t,e,r,n,i,a){var o=i-1,s=i*i,l=o*o,c=(1+2*i)*l,u=i*l,f=s*(3-2*i),h=s*o;if(t.length){a||(a=new Array(t.length));for(var d=t.length-1;d>=0;--d)a[d]=c*t[d]+u*e[d]+f*r[d]+h*n[d];return a}return c*t+u*e+f*r+h*n}e.exports=i,e.exports.derivative=n},{}],23:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=i*l-a*s,t[1]=a*o-n*l,t[2]=n*s-i*o,t}e.exports=n},{}],24:[function(t,e,r){function n(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}e.exports=n},{}],25:[function(t,e,r){function n(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}e.exports=n},{}],26:[function(t,e,r){function n(t,e,r,n){var i=e[0],a=e[1],o=e[2];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t}e.exports=n},{}],27:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t}e.exports=n},{}],28:[function(t,e,r){"use strict";function n(t){this._components=t.slice(),this._time=[0],this.prevMatrix=t.slice(),this.nextMatrix=t.slice(),this.computedMatrix=t.slice(),this.computedInverse=t.slice(),this.computedEye=[0,0,0],this.computedUp=[0,0,0],this.computedCenter=[0,0,0],this.computedRadius=[0],this._limits=[-(1/0),1/0]}function i(t){t=t||{};var e=t.matrix||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return new n(e)}var a=t("binary-search-bounds"),o=t("mat4-interpolate"),s=t("gl-mat4/invert"),l=t("gl-mat4/rotateX"),c=t("gl-mat4/rotateY"),u=t("gl-mat4/rotateZ"),f=t("gl-mat4/lookAt"),h=t("gl-mat4/translate"),d=(t("gl-mat4/scale"),t("gl-vec3/normalize")),p=[0,0,0];e.exports=i;var g=n.prototype;g.recalcMatrix=function(t){var e=this._time,r=a.le(e,t),n=this.computedMatrix;if(!(0>r)){var i=this._components;if(r===e.length-1)for(var l=16*r,c=0;16>c;++c)n[c]=i[l++];else{for(var u=e[r+1]-e[r],l=16*r,f=this.prevMatrix,h=!0,c=0;16>c;++c)f[c]=i[l++];for(var p=this.nextMatrix,c=0;16>c;++c)p[c]=i[l++],h=h&&f[c]===p[c];if(1e-6>u||h)for(var c=0;16>c;++c)n[c]=f[c];else o(n,f,p,(t-e[r])/u)}var g=this.computedUp;g[0]=n[1],g[1]=n[5],g[2]=n[6],d(g,g);var v=this.computedInverse;s(v,n);var m=this.computedEye,y=v[15];m[0]=v[12]/y,m[1]=v[13]/y,m[2]=v[14]/y;for(var b=this.computedCenter,x=Math.exp(this.computedRadius[0]),c=0;3>c;++c)b[c]=m[c]-n[2+4*c]*x}},g.idle=function(t){if(!(tn;++n)e.push(e[r++]);this._time.push(t)}},g.flush=function(t){var e=a.gt(this._time,t)-2;0>e||(this._time.slice(0,e),this._components.slice(0,16*e))},g.lastT=function(){return this._time[this._time.length-1]},g.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||p,n=n||this.computedUp,this.setMatrix(t,f(this.computedMatrix,e,r,n));for(var i=0,a=0;3>a;++a)i+=Math.pow(r[a]-e[a],2);i=Math.log(Math.sqrt(i)),this.computedRadius[0]=i},g.rotate=function(t,e,r,n){this.recalcMatrix(t);var i=this.computedInverse;e&&c(i,i,e),r&&l(i,i,r),n&&u(i,i,n),this.setMatrix(t,s(this.computedMatrix,i))};var v=[0,0,0];g.pan=function(t,e,r,n){v[0]=-(e||0),v[1]=-(r||0),v[2]=-(n||0),this.recalcMatrix(t);var i=this.computedInverse;h(i,i,v),this.setMatrix(t,s(i,i))},g.translate=function(t,e,r,n){v[0]=e||0,v[1]=r||0,v[2]=n||0,this.recalcMatrix(t);var i=this.computedMatrix;h(i,i,v),this.setMatrix(t,i)},g.setMatrix=function(t,e){if(!(tr;++r)this._components.push(e[r])}},g.setDistance=function(t,e){this.computedRadius[0]=e},g.setDistanceLimits=function(t,e){var r=this._limits;r[0]=t,r[1]=e},g.getDistanceLimits=function(t){var e=this._limits;return t?(t[0]=e[0],t[1]=e[1],t):e}},{"binary-search-bounds":29,"gl-mat4/invert":96,"gl-mat4/lookAt":97,"gl-mat4/rotateX":101,"gl-mat4/rotateY":102,"gl-mat4/rotateZ":103,"gl-mat4/scale":104,"gl-mat4/translate":105,"gl-vec3/normalize":27,"mat4-interpolate":30}],29:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],30:[function(t,e,r){function n(t,e,r,n){if(0===u(e)||0===u(r))return!1;var i=c(e,h.translate,h.scale,h.skew,h.perspective,h.quaternion),a=c(r,d.translate,d.scale,d.skew,d.perspective,d.quaternion);return i&&a?(s(p.translate,h.translate,d.translate,n),s(p.skew,h.skew,d.skew,n),s(p.scale,h.scale,d.scale,n),s(p.perspective,h.perspective,d.perspective,n),f(p.quaternion,h.quaternion,d.quaternion,n),l(t,p.translate,p.scale,p.skew,p.perspective,p.quaternion),!0):!1}function i(){return{translate:a(),scale:a(1),skew:a(),perspective:o(),quaternion:o()}}function a(t){return[t||0,t||0,t||0]}function o(){return[0,0,0,1]}var s=t("gl-vec3/lerp"),l=t("mat4-recompose"),c=t("mat4-decompose"),u=t("gl-mat4/determinant"),f=t("quat-slerp"),h=i(),d=i(),p=i();e.exports=n},{"gl-mat4/determinant":92,"gl-vec3/lerp":26,"mat4-decompose":31,"mat4-recompose":33,"quat-slerp":34}],31:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}function i(t,e){t[0][0]=e[0],t[0][1]=e[1],t[0][2]=e[2],t[1][0]=e[4],t[1][1]=e[5],t[1][2]=e[6],t[2][0]=e[8],t[2][1]=e[9],t[2][2]=e[10]}function a(t,e,r,n,i){t[0]=e[0]*n+r[0]*i,t[1]=e[1]*n+r[1]*i,t[2]=e[2]*n+r[2]*i}var o=t("./normalize"),s=t("gl-mat4/create"),l=t("gl-mat4/clone"),c=t("gl-mat4/determinant"),u=t("gl-mat4/invert"),f=t("gl-mat4/transpose"),h={length:t("gl-vec3/length"),normalize:t("gl-vec3/normalize"),dot:t("gl-vec3/dot"),cross:t("gl-vec3/cross")},d=s(),p=s(),g=[0,0,0,0],v=[[0,0,0],[0,0,0],[0,0,0]],m=[0,0,0];e.exports=function(t,e,r,s,y,b){if(e||(e=[0,0,0]),r||(r=[0,0,0]),s||(s=[0,0,0]),y||(y=[0,0,0,1]),b||(b=[0,0,0,1]),!o(d,t))return!1;if(l(p,d),p[3]=0,p[7]=0,p[11]=0,p[15]=1,Math.abs(c(p)<1e-8))return!1;var x=d[3],_=d[7],w=d[11],k=d[12],A=d[13],M=d[14],T=d[15];if(0!==x||0!==_||0!==w){g[0]=x,g[1]=_,g[2]=w,g[3]=T;var E=u(p,p);if(!E)return!1;f(p,p),n(y,g,p)}else y[0]=y[1]=y[2]=0,y[3]=1;if(e[0]=k,e[1]=A,e[2]=M,i(v,d),r[0]=h.length(v[0]),h.normalize(v[0],v[0]),s[0]=h.dot(v[0],v[1]),a(v[1],v[1],v[0],1,-s[0]),r[1]=h.length(v[1]),h.normalize(v[1],v[1]),s[0]/=r[1],s[1]=h.dot(v[0],v[2]),a(v[2],v[2],v[0],1,-s[1]),s[2]=h.dot(v[1],v[2]),a(v[2],v[2],v[1],1,-s[2]),r[2]=h.length(v[2]),h.normalize(v[2],v[2]),s[1]/=r[2],s[2]/=r[2],h.cross(m,v[1],v[2]),h.dot(v[0],m)<0)for(var L=0;3>L;L++)r[L]*=-1,v[L][0]*=-1,v[L][1]*=-1,v[L][2]*=-1;return b[0]=.5*Math.sqrt(Math.max(1+v[0][0]-v[1][1]-v[2][2],0)),b[1]=.5*Math.sqrt(Math.max(1-v[0][0]+v[1][1]-v[2][2],0)),b[2]=.5*Math.sqrt(Math.max(1-v[0][0]-v[1][1]+v[2][2],0)),b[3]=.5*Math.sqrt(Math.max(1+v[0][0]+v[1][1]+v[2][2],0)),v[2][1]>v[1][2]&&(b[0]=-b[0]),v[0][2]>v[2][0]&&(b[1]=-b[1]),v[1][0]>v[0][1]&&(b[2]=-b[2]),!0}},{"./normalize":32,"gl-mat4/clone":90,"gl-mat4/create":91,"gl-mat4/determinant":92,"gl-mat4/invert":96,"gl-mat4/transpose":106,"gl-vec3/cross":23,"gl-vec3/dot":24,"gl-vec3/length":25,"gl-vec3/normalize":27}],32:[function(t,e,r){e.exports=function(t,e){var r=e[15];if(0===r)return!1;for(var n=1/r,i=0;16>i;i++)t[i]=e[i]*n;return!0}},{}],33:[function(t,e,r){var n={identity:t("gl-mat4/identity"),translate:t("gl-mat4/translate"),multiply:t("gl-mat4/multiply"),create:t("gl-mat4/create"),scale:t("gl-mat4/scale"),fromRotationTranslation:t("gl-mat4/fromRotationTranslation")},i=(n.create(),n.create());e.exports=function(t,e,r,a,o,s){return n.identity(t),n.fromRotationTranslation(t,s,e),t[3]=o[0],t[7]=o[1],t[11]=o[2],t[15]=o[3],n.identity(i),0!==a[2]&&(i[9]=a[2],n.multiply(t,t,i)),0!==a[1]&&(i[9]=0,i[8]=a[1],n.multiply(t,t,i)),0!==a[0]&&(i[8]=0,i[4]=a[0],n.multiply(t,t,i)),n.scale(t,t,r),t}},{"gl-mat4/create":91,"gl-mat4/fromRotationTranslation":94,"gl-mat4/identity":95,"gl-mat4/multiply":98,"gl-mat4/scale":104,"gl-mat4/translate":105}],34:[function(t,e,r){e.exports=t("gl-quat/slerp")},{"gl-quat/slerp":35}],35:[function(t,e,r){function n(t,e,r,n){var i,a,o,s,l,c=e[0],u=e[1],f=e[2],h=e[3],d=r[0],p=r[1],g=r[2],v=r[3];return a=c*d+u*p+f*g+h*v,0>a&&(a=-a,d=-d,p=-p,g=-g,v=-v),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n),t[0]=s*c+l*d,t[1]=s*u+l*p,t[2]=s*f+l*g,t[3]=s*h+l*v,t}e.exports=n},{}],36:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c){var u=e+a+c;if(f>0){var f=Math.sqrt(u+1);t[0]=.5*(o-l)/f,t[1]=.5*(s-n)/f,t[2]=.5*(r-a)/f,t[3]=.5*f}else{var h=Math.max(e,a,c),f=Math.sqrt(2*h-u+1);e>=h?(t[0]=.5*f,t[1]=.5*(i+r)/f,t[2]=.5*(s+n)/f,t[3]=.5*(o-l)/f):a>=h?(t[0]=.5*(r+i)/f,t[1]=.5*f,t[2]=.5*(l+o)/f,t[3]=.5*(s-n)/f):(t[0]=.5*(n+s)/f,t[1]=.5*(o+l)/f,t[2]=.5*f,t[3]=.5*(r-i)/f)}return t}e.exports=n},{}],37:[function(t,e,r){"use strict";function n(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function i(t,e,r,n){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2)+Math.pow(n,2))}function a(t,e){var r=e[0],n=e[1],a=e[2],o=e[3],s=i(r,n,a,o);s>1e-6?(t[0]=r/s,t[1]=n/s,t[2]=a/s,t[3]=o/s):(t[0]=t[1]=t[2]=0,t[3]=1)}function o(t,e,r){this.radius=l([r]),this.center=l(e),this.rotation=l(t),this.computedRadius=this.radius.curve(0),this.computedCenter=this.center.curve(0),this.computedRotation=this.rotation.curve(0),this.computedUp=[.1,0,0],this.computedEye=[.1,0,0],this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.recalcMatrix(0)}function s(t){t=t||{};var e=t.center||[0,0,0],r=t.rotation||[0,0,0,1],n=t.radius||1;e=[].slice.call(e,0,3),r=[].slice.call(r,0,4),a(r,r);var i=new o(r,e,Math.log(n));return i.setDistanceLimits(t.zoomMin,t.zoomMax),("eye"in t||"up"in t)&&i.lookAt(0,t.eye,t.center,t.up),i}e.exports=s;var l=t("filtered-vector"),c=t("gl-mat4/lookAt"),u=t("gl-mat4/fromQuat"),f=t("gl-mat4/invert"),h=t("./lib/quatFromFrame"),d=o.prototype;d.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())},d.recalcMatrix=function(t){this.radius.curve(t),this.center.curve(t),this.rotation.curve(t);var e=this.computedRotation;a(e,e);var r=this.computedMatrix;u(r,e);var n=this.computedCenter,i=this.computedEye,o=this.computedUp,s=Math.exp(this.computedRadius[0]);i[0]=n[0]+s*r[2],i[1]=n[1]+s*r[6],i[2]=n[2]+s*r[10],o[0]=r[1],o[1]=r[5],o[2]=r[9];for(var l=0;3>l;++l){for(var c=0,f=0;3>f;++f)c+=r[l+4*f]*i[f];r[12+l]=-c}},d.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;16>n;++n)e[n]=r[n];return e}return r},d.idle=function(t){this.center.idle(t),this.radius.idle(t),this.rotation.idle(t)},d.flush=function(t){this.center.flush(t),this.radius.flush(t),this.rotation.flush(t)},d.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=a[1],s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],f=a[4],h=a[8],d=u*o+f*s+h*l;u-=o*d,f-=s*d,h-=l*d;var p=n(u,f,h);u/=p,f/=p,h/=p;var g=a[2],v=a[6],m=a[10],y=g*o+v*s+m*l,b=g*u+v*f+m*h;g-=y*o+b*u,v-=y*s+b*f,m-=y*l+b*h;var x=n(g,v,m);g/=x,v/=x,m/=x;var _=u*e+o*r,w=f*e+s*r,k=h*e+l*r;this.center.move(t,_,w,k);var A=Math.exp(this.computedRadius[0]);A=Math.max(1e-4,A+i),this.radius.set(t,Math.log(A))},d.rotate=function(t,e,r,a){this.recalcMatrix(t),e=e||0,r=r||0;var o=this.computedMatrix,s=o[0],l=o[4],c=o[8],u=o[1],f=o[5],h=o[9],d=o[2],p=o[6],g=o[10],v=e*s+r*u,m=e*l+r*f,y=e*c+r*h,b=-(p*y-g*m),x=-(g*v-d*y),_=-(d*m-p*v),w=Math.sqrt(Math.max(0,1-Math.pow(b,2)-Math.pow(x,2)-Math.pow(_,2))),k=i(b,x,_,w);k>1e-6?(b/=k,x/=k,_/=k,w/=k):(b=x=_=0,w=1);var A=this.computedRotation,M=A[0],T=A[1],E=A[2],L=A[3],S=M*w+L*b+T*_-E*x,C=T*w+L*x+E*b-M*_,z=E*w+L*_+M*x-T*b,P=L*w-M*b-T*x-E*_;if(a){b=d,x=p,_=g;var R=Math.sin(a)/n(b,x,_);b*=R,x*=R,_*=R,w=Math.cos(e),S=S*w+P*b+C*_-z*x,C=C*w+P*x+z*b-S*_,z=z*w+P*_+S*x-C*b,P=P*w-S*b-C*x-z*_}var O=i(S,C,z,P);O>1e-6?(S/=O,C/=O,z/=O,P/=O):(S=C=z=0,P=1),this.rotation.set(t,S,C,z,P)},d.lookAt=function(t,e,r,n){this.recalcMatrix(t),r=r||this.computedCenter,e=e||this.computedEye,n=n||this.computedUp;var i=this.computedMatrix;c(i,e,r,n);var o=this.computedRotation;h(o,i[0],i[1],i[2],i[4],i[5],i[6],i[8],i[9],i[10]),a(o,o),this.rotation.set(t,o[0],o[1],o[2],o[3]);for(var s=0,l=0;3>l;++l)s+=Math.pow(r[l]-e[l],2);this.radius.set(t,.5*Math.log(Math.max(s,1e-6))),this.center.set(t,r[0],r[1],r[2])},d.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},d.setMatrix=function(t,e){var r=this.computedRotation;h(r,e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]),a(r,r),this.rotation.set(t,r[0],r[1],r[2],r[3]);var n=this.computedMatrix;f(n,e);var i=n[15];if(Math.abs(i)>1e-6){var o=n[12]/i,s=n[13]/i,l=n[14]/i;this.recalcMatrix(t);var c=Math.exp(this.computedRadius[0]);this.center.set(t,o-n[2]*c,s-n[6]*c,l-n[10]*c),this.radius.idle(t)}else this.center.idle(t),this.radius.idle(t)},d.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},d.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-(1/0),e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},d.getDistanceLimits=function(t){var e=this.radius.bounds; -return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},d.toJSON=function(){return this.recalcMatrix(this.lastT()),{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}},d.fromJSON=function(t){var e=this.lastT(),r=t.center;r&&this.center.set(e,r[0],r[1],r[2]);var n=t.rotation;n&&this.rotation.set(e,n[0],n[1],n[2],n[3]);var i=t.distance;i&&i>0&&this.radius.set(e,Math.log(i)),this.setDistanceLimits(t.zoomMin,t.zoomMax)}},{"./lib/quatFromFrame":36,"filtered-vector":20,"gl-mat4/fromQuat":93,"gl-mat4/invert":96,"gl-mat4/lookAt":97}],38:[function(t,e,r){"use strict";function n(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function i(t){return Math.min(1,Math.max(-1,t))}function a(t){var e=Math.abs(t[0]),r=Math.abs(t[1]),n=Math.abs(t[2]),i=[0,0,0];e>Math.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,s=0;3>s;++s)a+=t[s]*t[s],o+=i[s]*t[s];for(var s=0;3>s;++s)i[s]-=o/a*t[s];return h(i,i),i}function o(t,e,r,n,i,a,o,s){this.center=l(r),this.up=l(n),this.right=l(i),this.radius=l([a]),this.angle=l([o,s]),this.angle.bounds=[[-(1/0),-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var c=0;16>c;++c)this.computedMatrix[c]=.5;this.recalcMatrix(0)}function s(t){t=t||{};var e=t.center||[0,0,0],r=t.up||[0,1,0],i=t.right||a(r),s=t.radius||1,l=t.theta||0,c=t.phi||0;if(e=[].slice.call(e,0,3),r=[].slice.call(r,0,3),h(r,r),i=[].slice.call(i,0,3),h(i,i),"eye"in t){var u=t.eye,p=[u[0]-e[0],u[1]-e[1],u[2]-e[2]];f(i,p,r),n(i[0],i[1],i[2])<1e-6?i=a(r):h(i,i),s=n(p[0],p[1],p[2]);var g=d(r,p)/s,v=d(i,p)/s;c=Math.acos(g),l=Math.acos(v)}return s=Math.log(s),new o(t.zoomMin,t.zoomMax,e,r,i,s,l,c)}e.exports=s;var l=t("filtered-vector"),c=t("gl-mat4/invert"),u=t("gl-mat4/rotate"),f=t("gl-vec3/cross"),h=t("gl-vec3/normalize"),d=t("gl-vec3/dot"),p=o.prototype;p.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-(1/0),e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},p.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},p.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,i=0,a=0,o=0;3>o;++o)a+=e[o]*r[o],i+=e[o]*e[o];for(var s=Math.sqrt(i),l=0,o=0;3>o;++o)r[o]-=e[o]*a/i,l+=r[o]*r[o],e[o]/=s;for(var c=Math.sqrt(l),o=0;3>o;++o)r[o]/=c;var u=this.computedToward;f(u,e,r),h(u,u);for(var d=Math.exp(this.computedRadius[0]),p=this.computedAngle[0],g=this.computedAngle[1],v=Math.cos(p),m=Math.sin(p),y=Math.cos(g),b=Math.sin(g),x=this.computedCenter,_=v*y,w=m*y,k=b,A=-v*b,M=-m*b,T=y,E=this.computedEye,L=this.computedMatrix,o=0;3>o;++o){var S=_*r[o]+w*u[o]+k*e[o];L[4*o+1]=A*r[o]+M*u[o]+T*e[o],L[4*o+2]=S,L[4*o+3]=0}var C=L[1],z=L[5],P=L[9],R=L[2],O=L[6],I=L[10],N=z*I-P*O,j=P*R-C*I,F=C*O-z*R,D=n(N,j,F);N/=D,j/=D,F/=D,L[0]=N,L[4]=j,L[8]=F;for(var o=0;3>o;++o)E[o]=x[o]+L[2+4*o]*d;for(var o=0;3>o;++o){for(var l=0,B=0;3>B;++B)l+=L[o+4*B]*E[B];L[12+o]=-l}L[15]=1},p.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;16>n;++n)e[n]=r[n];return e}return r};var g=[0,0,0];p.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;g[0]=i[2],g[1]=i[6],g[2]=i[10];for(var a=this.computedUp,o=this.computedRight,s=this.computedToward,l=0;3>l;++l)i[4*l]=a[l],i[4*l+1]=o[l],i[4*l+2]=s[l];u(i,i,n,g);for(var l=0;3>l;++l)a[l]=i[4*l],o[l]=i[4*l+1];this.up.set(t,a[0],a[1],a[2]),this.right.set(t,o[0],o[1],o[2])}},p.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=(Math.exp(this.computedRadius[0]),a[1]),s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],f=a[4],h=a[8],d=u*o+f*s+h*l;u-=o*d,f-=s*d,h-=l*d;var p=n(u,f,h);u/=p,f/=p,h/=p;var g=u*e+o*r,v=f*e+s*r,m=h*e+l*r;this.center.move(t,g,v,m);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+i),this.radius.set(t,Math.log(y))},p.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},p.setMatrix=function(t,e,r,a){var o=1;"number"==typeof r&&(o=0|r),(0>o||o>3)&&(o=1);var s=(o+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var l=e[o],u=e[o+4],f=e[o+8];if(a){var h=Math.abs(l),d=Math.abs(u),p=Math.abs(f),g=Math.max(h,d,p);h===g?(l=0>l?-1:1,u=f=0):p===g?(f=0>f?-1:1,l=u=0):(u=0>u?-1:1,l=f=0)}else{var v=n(l,u,f);l/=v,u/=v,f/=v}var m=e[s],y=e[s+4],b=e[s+8],x=m*l+y*u+b*f;m-=l*x,y-=u*x,b-=f*x;var _=n(m,y,b);m/=_,y/=_,b/=_;var w=u*b-f*y,k=f*m-l*b,A=l*y-u*m,M=n(w,k,A);w/=M,k/=M,A/=M,this.center.jump(t,H,G,Y),this.radius.idle(t),this.up.jump(t,l,u,f),this.right.jump(t,m,y,b);var T,E;if(2===o){var L=e[1],S=e[5],C=e[9],z=L*m+S*y+C*b,P=L*w+S*k+C*A;T=0>N?-Math.PI/2:Math.PI/2,E=Math.atan2(P,z)}else{var R=e[2],O=e[6],I=e[10],N=R*l+O*u+I*f,j=R*m+O*y+I*b,F=R*w+O*k+I*A;T=Math.asin(i(N)),E=Math.atan2(F,j)}this.angle.jump(t,E,T),this.recalcMatrix(t);var D=e[2],B=e[6],U=e[10],V=this.computedMatrix;c(V,e);var q=V[15],H=V[12]/q,G=V[13]/q,Y=V[14]/q,X=Math.exp(this.computedRadius[0]);this.center.jump(t,H-D*X,G-B*X,Y-U*X)},p.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},p.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},p.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},p.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},p.lookAt=function(t,e,r,a){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter,a=a||this.computedUp;var o=a[0],s=a[1],l=a[2],c=n(o,s,l);if(!(1e-6>c)){o/=c,s/=c,l/=c;var u=e[0]-r[0],f=e[1]-r[1],h=e[2]-r[2],d=n(u,f,h);if(!(1e-6>d)){u/=d,f/=d,h/=d;var p=this.computedRight,g=p[0],v=p[1],m=p[2],y=o*g+s*v+l*m;g-=y*o,v-=y*s,m-=y*l;var b=n(g,v,m);if(!(.01>b&&(g=s*h-l*f,v=l*u-o*h,m=o*f-s*u,b=n(g,v,m),1e-6>b))){g/=b,v/=b,m/=b,this.up.set(t,o,s,l),this.right.set(t,g,v,m),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(d));var x=s*m-l*v,_=l*g-o*m,w=o*v-s*g,k=n(x,_,w);x/=k,_/=k,w/=k;var A=o*u+s*f+l*h,M=g*u+v*f+m*h,T=x*u+_*f+w*h,E=Math.asin(i(A)),L=Math.atan2(T,M),S=this.angle._state,C=S[S.length-1],z=S[S.length-2];C%=2*Math.PI;var P=Math.abs(C+2*Math.PI-L),R=Math.abs(C-L),O=Math.abs(C-2*Math.PI-L);R>P&&(C+=2*Math.PI),R>O&&(C-=2*Math.PI),this.angle.jump(this.angle.lastT(),C,z),this.angle.set(t,L,E)}}}}},{"filtered-vector":20,"gl-mat4/invert":96,"gl-mat4/rotate":100,"gl-vec3/cross":23,"gl-vec3/dot":24,"gl-vec3/normalize":27}],39:[function(t,e,r){"use strict";function n(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map(function(e){return t[e]}),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.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}function i(t){t=t||{};var e=t.eye||[0,0,1],r=t.center||[0,0,0],i=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],c=t.mode||"turntable",u=a(),f=o(),h=s();return u.setDistanceLimits(l[0],l[1]),u.lookAt(0,e,r,i),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,i),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,i),new n({turntable:u,orbit:f,matrix:h},c)}e.exports=i;var a=t("turntable-camera-controller"),o=t("orbit-camera-controller"),s=t("matrix-camera-controller"),l=n.prototype,c=[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]];c.forEach(function(t){for(var e=t[0],r=[],n=0;ne)){var r=this._active,n=this._controllerList[e],i=Math.max(r.lastT(),n.lastT());r.recalcMatrix(i),n.setMatrix(i,r.computedMatrix),this._active=n,this._mode=t,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}}},l.getMode=function(){return this._mode}},{"matrix-camera-controller":28,"orbit-camera-controller":37,"turntable-camera-controller":38}],40:[function(t,e,r){function n(t,e){return a(i(t,e))}e.exports=n;var i=t("alpha-complex"),a=t("simplicial-complex-boundary")},{"alpha-complex":41,"simplicial-complex-boundary":44}],41:[function(t,e,r){"use strict";function n(t,e){return i(e).filter(function(r){for(var n=new Array(r.length),i=0;ii;++i)r+=t[i]*e[i];return r}function i(t){var e=t.length;if(0===e)return[];var r=(t[0].length,o([t.length+1,t.length+1],1)),i=o([t.length+1],1);r[e][e]=0;for(var a=0;e>a;++a){for(var l=0;a>=l;++l)r[l][a]=r[a][l]=2*n(t[a],t[l]);i[a]=n(t[a],t[a])}for(var c=s(r,i),u=0,f=c[e+1],a=0;aa;++a){for(var f=c[a],d=0,l=0;ls;++s)r[s]+=t[a][s]*n[a];return r}var o=t("dup"),s=t("robust-linear-solve");a.barycenetric=i,e.exports=a},{dup:74,"robust-linear-solve":215}],44:[function(t,e,r){"use strict";function n(t){return a(i(t))}e.exports=n;var i=t("boundary-cells"),a=t("reduce-simplicial-complex")},{"boundary-cells":45,"reduce-simplicial-complex":48}],45:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=0,n=0;e>n;++n)r+=t[n].length;for(var i=new Array(r),a=0,n=0;e>n;++n)for(var o=t[n],s=o.length,l=0;s>l;++l)for(var c=i[a++]=new Array(s-1),u=1;s>u;++u)c[u-1]=o[(l+u)%s];return i}e.exports=n},{}],46:[function(t,e,r){"use strict";function n(t){for(var e=1,r=1;rn;++n)if(t[r]n;++n){var s=t[n],l=o(s);if(0!==l){if(r>0){var c=t[r-1];if(0===i(s,c)&&o(c)!==l){r-=1;continue}}t[r++]=s}}return t.length=r,t}var i=t("compare-cell"),a=t("compare-oriented-cell"),o=t("cell-orientation");e.exports=n},{"cell-orientation":46,"compare-cell":60,"compare-oriented-cell":47}],49:[function(t,e,r){"use strict";var n=function(){function t(t){return!Array.isArray(t)&&null!==t&&"object"==typeof t}function e(t,e,r){for(var n=(e-t)/Math.max(r-1,1),i=[],a=0;r>a;a++)i.push(t+a*n);return i}function r(){for(var t=[].slice.call(arguments),e=t.map(function(t){return t.length}),r=Math.min.apply(null,e),n=[],i=0;r>i;i++){n[i]=[];for(var a=0;aa;a++)i.push([t[a],e[a],r[a]]);return i}function i(t){function e(t){for(var n=0;n>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3])),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}function c(t,e){var r,n;if("string"!=typeof t)return t;if(r=[],"#"===t[0]?(t=t.substr(1),3===t.length&&(t+=t),n=parseInt(t,16),r[0]=n>>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3]),n[4]?r[3]=parseFloat(n[4]):r[3]=1),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}var u={},f=/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,.*)?\)$/,h=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,?\s*(.*)?\)$/;return u.isPlainObject=t,u.linspace=e,u.zip3=n,u.sum=i,u.zip=r,u.isEqual=s,u.copy2D=a,u.copy1D=o,u.str2RgbArray=l,u.str2RgbaArray=c,u};e.exports=n()},{}],50:[function(t,e,r){"use strict";"use restrict";function n(t){var e=32;return t&=-t,t&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}var i=32;r.INT_BITS=i,r.INT_MAX=2147483647,r.INT_MIN=-1<0)-(0>t)},r.abs=function(t){var e=t>>i-1;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(e>t)},r.max=function(t,e){return t^(t^e)&-(e>t)},r.isPow2=function(t){return!(t&t-1||!t)},r.log2=function(t){var e,r;return e=(t>65535)<<4,t>>>=e,r=(t>255)<<3,t>>>=r,e|=r,r=(t>15)<<2,t>>>=r,e|=r,r=(t>3)<<1,t>>>=r,e|=r,e|t>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return t-=t>>>1&1431655765,t=(858993459&t)+(t>>>2&858993459),16843009*(t+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,t&=15,27030>>>t&1};var a=new Array(256);!function(t){for(var e=0;256>e;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|a[t>>>16&255]<<8|a[t>>>24&255]},r.interleave2=function(t,e){return t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},r.deinterleave2=function(t,e){return t=t>>>e&1431655765,t=858993459&(t|t>>>1),t=252645135&(t|t>>>2),t=16711935&(t|t>>>4),t=65535&(t|t>>>16),t<<16>>16},r.interleave3=function(t,e,r){return t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t|=e<<1,r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),t|r<<2},r.deinterleave3=function(t,e){return t=t>>>e&1227133513,t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),t=1023&(t|t>>>16),t<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],51:[function(t,e,r){(function(e){"use strict";function n(){try{var t=new Uint8Array(1);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function i(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t){return this instanceof a?(a.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?o(this,t):"string"==typeof t?s(this,t,arguments.length>1?arguments[1]:"utf8"):l(this,t)):arguments.length>1?new a(t,arguments[1]):new a(t)}function o(t,e){if(t=g(t,0>e?0:0|v(e)),!a.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;r++)t[r]=0;return t}function s(t,e,r){"string"==typeof r&&""!==r||(r="utf8");var n=0|y(e,r);return t=g(t,n),t.write(e,r),t}function l(t,e){if(a.isBuffer(e))return c(t,e);if(K(e))return u(t,e);if(null==e)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(e.buffer instanceof ArrayBuffer)return f(t,e);if(e instanceof ArrayBuffer)return h(t,e)}return e.length?d(t,e):p(t,e)}function c(t,e){var r=0|v(e.length);return t=g(t,r),e.copy(t,0,0,r),t}function u(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function f(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function h(t,e){return e.byteLength,a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=a.prototype):t=f(t,new Uint8Array(e)),t}function d(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function p(t,e){var r,n=0;"Buffer"===e.type&&K(e.data)&&(r=e.data,n=0|v(r.length)),t=g(t,n);for(var i=0;n>i;i+=1)t[i]=255&r[i];return t}function g(t,e){a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=a.prototype):t.length=e;var r=0!==e&&e<=a.poolSize>>>1;return r&&(t.parent=$),t}function v(t){if(t>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function m(t,e){if(!(this instanceof m))return new m(t,e);var r=new a(t,e);return delete r.parent,r}function y(t,e){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(t).length;default:if(n)return q(t).length;e=(""+e).toLowerCase(),n=!0}}function b(t,e,r){var n=!1;if(e=0|e,r=void 0===r||r===1/0?this.length:0|r,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return z(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return S(this,e,r);case"binary":return C(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function x(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=e.length;if(a%2!==0)throw new Error("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;n>o;o++){var s=parseInt(e.substr(2*o,2),16);if(isNaN(s))throw new Error("Invalid hex string");t[r+o]=s}return o}function _(t,e,r,n){return X(q(e,t.length-r),t,r,n)}function w(t,e,r,n){return X(H(e),t,r,n)}function k(t,e,r,n){return w(t,e,r,n)}function A(t,e,r,n){return X(Y(e),t,r,n)}function M(t,e,r,n){return X(G(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;r>i;){var a=t[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(r>=i+s){var l,c,u,f;switch(s){case 1:128>a&&(o=a);break;case 2:l=t[i+1],128===(192&l)&&(f=(31&a)<<6|63&l,f>127&&(o=f));break;case 3:l=t[i+1],c=t[i+2],128===(192&l)&&128===(192&c)&&(f=(15&a)<<12|(63&l)<<6|63&c,f>2047&&(55296>f||f>57343)&&(o=f));break;case 4:l=t[i+1],c=t[i+2],u=t[i+3],128===(192&l)&&128===(192&c)&&128===(192&u)&&(f=(15&a)<<18|(63&l)<<12|(63&c)<<6|63&u,f>65535&&1114112>f&&(o=f))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return L(n)}function L(t){var e=t.length;if(Q>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Q));return r}function S(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function C(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function z(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",a=e;r>a;a++)i+=V(t[a]);return i}function P(t,e,r){for(var n=t.slice(e,r),i="",a=0;at)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!a.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>i||o>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range")}function I(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,a=Math.min(t.length-r,2);a>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function N(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,a=Math.min(t.length-r,4);a>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function j(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function F(t,e,r,n,i){return i||j(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,i){return i||j(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(t,e,r,n,52,8),r+8}function B(t){if(t=U(t).replace(J,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function U(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function V(t){return 16>t?"0"+t.toString(16):t.toString(16)}function q(t,e){e=e||1/0;for(var r,n=t.length,i=null,a=[],o=0;n>o;o++){if(r=t.charCodeAt(o),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,128>r){if((e-=1)<0)break;a.push(r)}else if(2048>r){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function H(t){for(var e=[],r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function Y(t){return W.toByteArray(B(t))}function X(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}var W=t("base64-js"),Z=t("ieee754"),K=t("isarray");r.Buffer=a,r.SlowBuffer=m,r.INSPECT_MAX_BYTES=50,a.poolSize=8192;var $={};a.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),a._augment=function(t){return t.__proto__=a.prototype,t},a.TYPED_ARRAY_SUPPORT?(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})):(a.prototype.length=void 0,a.prototype.parent=void 0),a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,e){if(!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);o>i&&t[i]===e[i];)++i;return i!==o&&(r=t[i],n=e[i]),n>r?-1:r>n?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!K(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new a(0);var r;if(void 0===e)for(e=0,r=0;r0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},a.prototype.compare=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:a.compare(this,t)},a.prototype.indexOf=function(t,e){function r(t,e,r){for(var n=-1,i=0;r+i2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,e);if(a.isBuffer(t))return r(this,t,e);if("number"==typeof t)return a.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):r(this,[t],e);throw new TypeError("val must be string, number or Buffer")},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite(e))e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var i=n;n=e,e=0|r,r=i}var a=this.length-e;if((void 0===r||r>a)&&(r=a),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return x(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":return w(this,t,e,r);case"binary":return k(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var n;if(a.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=a.prototype;else{var i=e-t;n=new a(i,void 0);for(var o=0;i>o;o++)n[o]=this[o+t]}return n.length&&(n.parent=this.parent||this),n},a.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||R(t,e,this.length);for(var n=this[t],i=1,a=0;++a0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||R(t,e,this.length);for(var n=this[t],i=1,a=0;++a=i&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||R(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a},a.prototype.readInt8=function(t,e){return e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),Z.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),Z.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),Z.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),Z.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,r,n){t=+t,e=0|e,r=0|r,n||O(this,t,e,r,Math.pow(2,8*r),0);var i=1,a=0;for(this[e]=255&t;++a=0&&(a*=256);)this[e+i]=t/a&255;return e+r},a.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):N(this,t,e,!0),e+4},a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=0,o=1,s=0>t?1:0;for(this[e]=255&t;++a>0)-s&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0>t?1:0;for(this[e+a]=255&t;--a>=0&&(o*=256);)this[e+a]=(t/o>>0)-s&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):N(this,t,e,!0),e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},a.prototype.writeFloatLE=function(t,e,r){return F(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return F(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length), -t.length-er&&n>e)for(i=o-1;i>=0;i--)t[i+e]=this[i+r];else if(1e3>o||!a.TYPED_ARRAY_SUPPORT)for(i=0;o>i;i++)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},a.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new RangeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=q(t.toString()),a=i.length;for(n=e;r>n;n++)this[n]=i[n%a]}return this}};var J=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":52,ieee754:53,isarray:54}],52:[function(t,e,r){"use strict";function n(){var t,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=e.length;for(t=0;r>t;t++)l[t]=e[t];for(t=0;r>t;++t)c[e.charCodeAt(t)]=t;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63}function i(t){var e,r,n,i,a,o,s=t.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===t[s-2]?2:"="===t[s-1]?1:0,o=new u(3*s/4-a),n=a>0?s-4:s;var l=0;for(e=0,r=0;n>e;e+=4,r+=3)i=c[t.charCodeAt(e)]<<18|c[t.charCodeAt(e+1)]<<12|c[t.charCodeAt(e+2)]<<6|c[t.charCodeAt(e+3)],o[l++]=(16711680&i)>>16,o[l++]=(65280&i)>>8,o[l++]=255&i;return 2===a?(i=c[t.charCodeAt(e)]<<2|c[t.charCodeAt(e+1)]>>4,o[l++]=255&i):1===a&&(i=c[t.charCodeAt(e)]<<10|c[t.charCodeAt(e+1)]<<4|c[t.charCodeAt(e+2)]>>2,o[l++]=i>>8&255,o[l++]=255&i),o}function a(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function o(t,e,r){for(var n,i=[],o=e;r>o;o+=3)n=(t[o]<<16)+(t[o+1]<<8)+t[o+2],i.push(a(n));return i.join("")}function s(t){for(var e,r=t.length,n=r%3,i="",a=[],s=16383,c=0,u=r-n;u>c;c+=s)a.push(o(t,c,c+s>u?u:c+s));return 1===n?(e=t[r-1],i+=l[e>>2],i+=l[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=l[e>>10],i+=l[e>>4&63],i+=l[e<<2&63],i+="="),a.push(i),a.join("")}r.toByteArray=i,r.fromByteArray=s;var l=[],c=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],53:[function(t,e,r){r.read=function(t,e,r,n,i){var a,o,s=8*i-n-1,l=(1<>1,u=-7,f=r?i-1:0,h=r?-1:1,d=t[e+f];for(f+=h,a=d&(1<<-u)-1,d>>=-u,u+=s;u>0;a=256*a+t[e+f],f+=h,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+f],f+=h,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:(d?-1:1)*(1/0);o+=Math.pow(2,n),a-=c}return(d?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:a-1,p=n?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),e+=o+f>=1?h/l:h*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=u?(s=0,o=u):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,c-=8);t[r+d-p]|=128*g}},{}],54:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],55:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function a(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!a(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,l,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,l=0;n>l;l++)c[l].apply(this,a);return!0},n.prototype.addListener=function(t,e){var r;if(!i(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(r=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,a,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],a=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(s=a;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],56:[function(t,e,r){function n(){u=!1,s.length?c=s.concat(c):f=-1,c.length&&i()}function i(){if(!u){var t=setTimeout(n);u=!0;for(var e=c.length;e;){for(s=c,c=[];++f1)for(var r=1;rn;++n)e=t[n],e=e.toString(16),r+=("00"+e).substr(e.length);return r}function i(t){return"rgba("+t.join(",")+")"}var a=t("arraytools"),o=t("clone"),s=t("./colorScales");e.exports=function(t){var e,r,l,c,u,f,h,d,p,g,v,m,y,b=[],x=[],_=[],w=[];if(a.isPlainObject(t)||(t={}),p=t.nshades||72,d=t.format||"hex",h=t.colormap,h||(h="jet"),"string"==typeof h){if(h=h.toLowerCase(),!s[h])throw Error(h+" not a supported colorscale");f=o(s[h])}else{if(!Array.isArray(h))throw Error("unsupported colormap option",h);f=o(h)}if(f.length>p)throw new Error(h+" map requires nshades to be at least size "+f.length);for(v=Array.isArray(t.alpha)?2!==t.alpha.length?[1,1]:o(t.alpha):"number"==typeof t.alpha?[t.alpha,t.alpha]:[1,1],e=f.map(function(t){return Math.round(t.index*p)}),v[0]<0&&(v[0]=0),v[1]<0&&(v[0]=0),v[0]>1&&(v[0]=1),v[1]>1&&(v[0]=1),y=0;y=0&&r[3]<=1||(r[3]=v[0]+(v[1]-v[0])*m);for(y=0;yx;++x)if(i=y[x]-b[x])return i;return 0}}e.exports=i;var a=Math.min},{}],61:[function(t,e,r){"use strict";function n(t){var e=t.length;if(0===e)return[];if(1===e)return[[0]];var r=t[0].length;return 0===r?[]:1===r?i(t):2===r?a(t):o(t,r)}var i=t("./lib/ch1d"),a=t("./lib/ch2d"),o=t("./lib/chnd");e.exports=n},{"./lib/ch1d":62,"./lib/ch2d":63,"./lib/chnd":64}],62:[function(t,e,r){"use strict";function n(t){for(var e=0,r=0,n=1;nt[r][0]&&(r=n);return r>e?[[e],[r]]:e>r?[[r],[e]]:[[e]]}e.exports=n},{}],63:[function(t,e,r){"use strict";function n(t){var e=i(t),r=e.length;if(2>=r)return[];for(var n=new Array(r),a=e[r-1],o=0;r>o;++o){var s=e[o];n[o]=[a,s],a=s}return n}e.exports=n;var i=t("monotone-convex-hull-2d")},{"monotone-convex-hull-2d":66}],64:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),i=0;ii;++i)e.indexOf(i)<0&&(n[a++]=t[i]);return n}function i(t,e){for(var r=t.length,n=e.length,i=0;r>i;++i)for(var a=t[i],o=0;os)a[o]=e[s];else{s-=n;for(var l=0;n>l;++l)s>=e[l]&&(s+=1);a[o]=s}}return t}function a(t,e){try{return o(t,!0)}catch(r){var a=s(t);if(a.length<=e)return[];var l=n(t,a),c=o(l,!0);return i(c,a)}}e.exports=a;var o=t("incremental-convex-hull"),s=t("affine-hull")},{"affine-hull":65,"incremental-convex-hull":194}],65:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(e+1),n=0;n=i;++i){for(var o=new Array(e),s=0;e>s;++s)o[s]=Math.pow(i+1-n,s);r[i]=o}var l=a.apply(void 0,r);if(l)return!0}return!1}function i(t){var e=t.length;if(0===e)return[];if(1===e)return[0];for(var r=t[0].length,i=[t[0]],a=[0],o=1;e>o;++o)if(i.push(t[o]),n(i,r)){if(a.push(o),a.length===r+1)return a}else i.pop();return a}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":218}],66:[function(t,e,r){"use strict";function n(t){var e=t.length;if(3>e){for(var r=new Array(e),n=0;e>n;++n)r[n]=n;return 2===e&&t[0][0]===t[1][0]&&t[0][1]===t[1][1]?[0]:r}for(var a=new Array(e),n=0;e>n;++n)a[n]=n;a.sort(function(e,r){var n=t[e][0]-t[r][0];return n?n:t[e][1]-t[r][1]});for(var o=[a[0],a[1]],s=[a[0],a[1]],n=2;e>n;++n){for(var l=a[n],c=t[l],u=o.length;u>1&&i(t[o[u-2]],t[o[u-1]],c)<=0;)u-=1,o.pop();for(o.push(l),u=s.length;u>1&&i(t[s[u-2]],t[s[u-1]],c)>=0;)u-=1,s.pop();s.push(l)}for(var r=new Array(s.length+o.length-2),f=0,n=0,h=o.length;h>n;++n)r[f++]=o[n];for(var d=s.length-2;d>0;--d)r[f++]=s[d];return r}e.exports=n;var i=t("robust-orientation")[3]},{"robust-orientation":218}],67:[function(t,e,r){e.exports={AFG:"afghan",ALA:"\\b\\wland",ALB:"albania",DZA:"algeria",ASM:"^(?=.*americ).*samoa",AND:"andorra",AGO:"angola",AIA:"anguill?a",ATA:"antarctica",ATG:"antigua",ARG:"argentin",ARM:"armenia",ABW:"^(?!.*bonaire).*\\baruba",AUS:"australia",AUT:"^(?!.*hungary).*austria|\\baustri.*\\bemp",AZE:"azerbaijan",BHS:"bahamas",BHR:"bahrain",BGD:"bangladesh|^(?=.*east).*paki?stan",BRB:"barbados",BLR:"belarus|byelo",BEL:"^(?!.*luxem).*belgium",BLZ:"belize|^(?=.*british).*honduras",BEN:"benin|dahome",BMU:"bermuda",BTN:"bhutan",BOL:"bolivia",BES:"^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands",BIH:"herzegovina|bosnia",BWA:"botswana|bechuana",BVT:"bouvet",BRA:"brazil",IOT:"british.?indian.?ocean",BRN:"brunei",BGR:"bulgaria",BFA:"burkina|\\bfaso|upper.?volta",BDI:"burundi",KHM:"cambodia|kampuchea|khmer",CMR:"cameroon",CAN:"canada",CPV:"verde",CYM:"cayman",CAF:"\\bcentral.african.republic",TCD:"\\bchad",CHL:"\\bchile",CHN:"^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai).*china",CXR:"christmas",CCK:"\\bcocos|keeling",COL:"colombia",COM:"comoro",COD:"\\bdem.*congo|congo.*\\bdem|congo.*\\bdr|\\bdr.*congo|belgian.?congo|congo.?free.?state|kinshasa|zaire|l.opoldville|drc|droc|rdc",COG:"^(?!.*\\bdem)(?!.*\\bdr)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l.opoldville)(?!.*free).*\\bcongo",COK:"\\bcook",CRI:"costa.?rica",CIV:"ivoire|ivory",HRV:"croatia",CUB:"\\bcuba",CUW:"^(?!.*bonaire).*\\bcura(c|\xe7)ao",CYP:"cyprus",CZE:"^(?=.*rep).*czech|czechia|bohemia",CSK:"czechoslovakia",DNK:"denmark",DJI:"djibouti",DMA:"dominica(?!n)",DOM:"dominican.rep",ECU:"ecuador",EGY:"egypt",SLV:"el.?salvador",GNQ:"guine.*eq|eq.*guine|^(?=.*span).*guinea",ERI:"eritrea",EST:"estonia",ETH:"ethiopia|abyssinia",FLK:"falkland|malvinas",FRO:"faroe|faeroe",FJI:"fiji",FIN:"finland",FRA:"^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul",GUF:"^(?=.*french).*guiana",PYF:"french.?polynesia|tahiti",ATF:"french.?southern",GAB:"gabon",GMB:"gambia",GEO:"^(?!.*south).*georgia",DDR:"german.?democratic.?republic|democratic.?republic.*germany|east.germany",DEU:"^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german",GHA:"ghana|gold.?coast",GIB:"gibraltar",GRC:"greece|hellenic|hellas",GRL:"greenland",GRD:"grenada",GLP:"guadeloupe",GUM:"\\bguam",GTM:"guatemala",GGY:"guernsey",GIN:"^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea",GNB:"bissau|^(?=.*portu).*guinea",GUY:"guyana|british.?guiana",HTI:"haiti",HMD:"heard.*mcdonald",VAT:"holy.?see|vatican|papal.?st",HND:"^(?!.*brit).*honduras",HKG:"hong.?kong",HUN:"^(?!.*austr).*hungary",ISL:"iceland",IND:"india(?!.*ocea)",IDN:"indonesia",IRN:"\\biran|persia",IRQ:"\\biraq|mesopotamia",IRL:"ireland",IMN:"^(?=.*isle).*\\bman",ISR:"israel",ITA:"italy",JAM:"jamaica",JPN:"japan",JEY:"jersey",JOR:"jordan",KAZ:"kazak",KEN:"kenya|british.?east.?africa|east.?africa.?prot",KIR:"kiribati",PRK:"^(?=.*democrat).*\\bkorea|^(?=.*people).*\\bkorea|^(?=.*north).*\\bkorea|dprk",KOR:"^(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea",KWT:"kuwait",KGZ:"kyrgyz|kirghiz",LAO:"\\blaos?\\b",LVA:"latvia",LBN:"lebanon",LSO:"lesotho|basuto",LBR:"liberia",LBY:"libya",LIE:"liechtenstein",LTU:"lithuania",LUX:"^(?!.*belg).*luxem",MAC:"maca(o|u)",MKD:"macedonia|fyrom",MDG:"madagascar|malagasy",MWI:"malawi|nyasa",MYS:"malaysia",MDV:"maldive",MLI:"\\bmali\\b",MLT:"\\bmalta",MHL:"marshall",MTQ:"martinique",MRT:"mauritania",MUS:"mauritius",MYT:"\\bmayotte",MEX:"\\bmexic",FSM:"micronesia",MDA:"moldov|b(a|e)ssarabia",MCO:"monaco",MNG:"mongolia",MNE:"^(?!.*serbia).*montenegro",MSR:"montserrat",MAR:"morocco|\\bmaroc",MOZ:"mozambique",MMR:"myanmar|burma",NAM:"namibia",NRU:"nauru",NPL:"nepal",NLD:"^(?!.*\\bant)(?!.*\\bcarib).*netherlands",ANT:"^(?=.*\\bant).*(nether|dutch)",NCL:"new.?caledonia",NZL:"new.?zealand",NIC:"nicaragua",NER:"\\bniger(?!ia)",NGA:"nigeria",NIU:"niue",NFK:"norfolk",MNP:"mariana",NOR:"norway",OMN:"\\boman|trucial",PAK:"^(?!.*east).*paki?stan",PLW:"palau",PSE:"palestin|\\bgaza|west.?bank",PAN:"panama",PNG:"papua|new.?guinea",PRY:"paraguay",PER:"peru",PHL:"philippines",PCN:"pitcairn",POL:"poland",PRT:"portugal",PRI:"puerto.?rico",QAT:"qatar",REU:"r(e|\xe9)union",ROU:"r(o|u|ou)mania",RUS:"\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics",RWA:"rwanda",BLM:"barth(e|\xe9)lemy",SHN:"helena",KNA:"kitts|\\bnevis",LCA:"\\blucia",MAF:"^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)",SPM:"miquelon",VCT:"vincent",WSM:"^(?!.*amer).*samoa",SMR:"san.?marino",STP:"\\bs(a|\xe3)o.?tom(e|\xe9)",SAU:"\\bsa\\w*.?arabia",SEN:"senegal",SRB:"^(?!.*monte).*serbia",SYC:"seychell",SLE:"sierra",SGP:"singapore",SXM:"^(?!.*martin)(?!.*saba).*maarten",SVK:"^(?!.*cze).*slovak",SVN:"slovenia",SLB:"solomon",SOM:"somali",ZAF:"\\bs\\w*.?africa",SGS:"south.?georgia|sandwich",SSD:"\\bs\\w*.?sudan",ESP:"spain",LKA:"sri.?lanka|ceylon",SDN:"^(?!.*\\bs(?!u)).*sudan",SUR:"surinam|dutch.?guiana",SJM:"svalbard",SWZ:"swaziland",SWE:"sweden",CHE:"switz|swiss",SYR:"syria",TWN:"taiwan|taipei|formosa",TJK:"tajik",TZA:"tanzania",THA:"thailand|\\bsiam",TLS:"^(?=.*leste).*timor|^(?=.*east).*timor",TGO:"togo",TKL:"tokelau",TON:"tonga",TTO:"trinidad|tobago",TUN:"tunisia",TUR:"turkey",TKM:"turkmen",TCA:"turks",TUV:"tuvalu",UGA:"uganda",UKR:"ukrain",ARE:"emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em",GBR:"united.?kingdom|britain|^u\\.?k\\.?$",USA:"united.?states|\\bu\\.?s\\.?a\\.?\\b|\\bu\\.?s\\.?\\b(?!.*islands)",UMI:"minor.?outlying.?is",URY:"uruguay",UZB:"uzbek",VUT:"vanuatu|new.?hebrides",VEN:"venezuela",VNM:"^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam",VGB:"^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin",VIR:"^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin",WLF:"futuna|wallis",ESH:"western.sahara",YEM:"^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen",YMD:"^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen",YUG:"yugoslavia",ZMB:"zambia|northern.?rhodesia",EAZ:"zanzibar",ZWE:"zimbabwe|^(?!.*northern).*rhodesia"}},{}],68:[function(t,e,r){"use strict";function n(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function i(t){var e=new n;e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===o){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(i),ir.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,a(e)}var a=t("./lib/thunk.js");e.exports=i},{"./lib/thunk.js":70}],69:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],c=[],u=0,f=0;for(n=0;a>n;++n)c.push(["i",n,"=0"].join(""));for(i=0;o>i;++i)for(n=0;a>n;++n)f=u,u=t[n],0===n?c.push(["d",i,"s",n,"=t",i,"p",u].join("")):c.push(["d",i,"s",n,"=(t",i,"p",u,"-s",f,"*t",i,"p",f,")"].join(""));for(l.push("var "+c.join(",")),n=a-1;n>=0;--n)u=t[n],l.push(["for(i",n,"=0;i",n,"n;++n){for(f=u,u=t[n],i=0;o>i;++i)l.push(["p",i,"+=d",i,"s",n].join(""));s&&(n>0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",u,"]"].join(""))),l.push("}")}return l.join("\n")}function i(t,e,r,i){for(var a=e.length,o=r.arrayArgs.length,s=r.blockSize,l=r.indexArgs.length>0,c=[],u=0;o>u;++u)c.push(["var offset",u,"=p",u].join(""));for(var u=t;a>u;++u)c.push(["for(var j"+u+"=SS[",e[u],"]|0;j",u,">0;){"].join("")),c.push(["if(j",u,"<",s,"){"].join("")),c.push(["s",e[u],"=j",u].join("")),c.push(["j",u,"=0"].join("")),c.push(["}else{s",e[u],"=",s].join("")),c.push(["j",u,"-=",s,"}"].join("")),l&&c.push(["index[",e[u],"]=j",u].join(""));for(var u=0;o>u;++u){for(var f=["offset"+u],h=t;a>h;++h)f.push(["j",h,"*t",u,"p",e[h]].join(""));c.push(["p",u,"=(",f.join("+"),")"].join(""))}c.push(n(e,r,i));for(var u=t;a>u;++u)c.push("}");return c.join("\n")}function a(t){for(var e=0,r=t[0].length;r>e;){for(var n=1;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}function l(t,e){for(var r=e[1].length-Math.abs(t.arrayBlockIndices[0])|0,l=new Array(t.arrayArgs.length),u=new Array(t.arrayArgs.length),f=0;fy;++y)_.push(["s",y,"=SS[",y,"]"].join(""));for(var f=0;fy;++y)_.push(["t",f,"p",y,"=t",f,"[",p[f]+y,"]"].join(""));for(var y=0;y0&&_.push("shape=SS.slice(0)"),t.indexArgs.length>0){for(var w=new Array(r),f=0;r>f;++f)w[f]="0";_.push(["index=[",w.join(","),"]"].join(""))}for(var f=0;f3&&x.push(o(t.pre,t,u));var T=o(t.body,t,u),E=a(v);r>E?x.push(i(E,v[0],t,T)):x.push(n(v[0],t,T)),t.post.body.length>3&&x.push(o(t.post,t,u)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+x.join("\n")+"\n----------");var L=[t.funcName||"unnamed","_cwise_loop_",l[0].join("s"),"m",E,s(u)].join(""),S=new Function(["function ",L,"(",b.join(","),"){",x.join("\n"),"} return ",L].join(""));return S()}var c=t("uniq");e.exports=l},{uniq:238}],70:[function(t,e,r){"use strict";function n(t){var e=["'use strict'","var CACHED={}"],r=[],n=t.funcName+"_cwise_thunk";e.push(["return function ",n,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],c=[],u=0;u0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[u]))),c.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[u])+"]"))}t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex-->0;) {"), -e.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}"));for(var u=0;ut?-1:t>e?1:t>=e?0:NaN}function a(t){return null===t?NaN:+t}function o(t){return!isNaN(t)}function s(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}function l(t){return t.length}function c(t){for(var e=1;t*e%1;)e*=10;return e}function u(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function f(){this._=Object.create(null)}function h(t){return(t+="")===ko||t[0]===Ao?Ao+t:t}function d(t){return(t+="")[0]===Ao?t.slice(1):t}function p(t){return h(t)in this._}function g(t){return(t=h(t))in this._&&delete this._[t]}function v(){var t=[];for(var e in this._)t.push(d(e));return t}function m(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function b(){this._=Object.create(null)}function x(t){return t}function _(t,e,r){return function(){var n=r.apply(e,arguments);return n===e?t:n}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var r=0,n=Mo.length;n>r;++r){var i=Mo[r]+e;if(i in t)return i}}function k(){}function A(){}function M(t){function e(){for(var e,n=r,i=-1,a=n.length;++ir;r++)for(var i,a=t[r],o=0,s=a.length;s>o;o++)(i=a[o])&&e(i,o,r);return t}function Y(t){return Eo(t,Oo),t}function X(t){var e,r;return function(n,i,a){var o,s=t[a].update,l=s.length;for(a!=r&&(r=a,e=0),i>=e&&(e=i+1);!(o=s[e])&&++e0&&(t=t.slice(0,s));var c=Io.get(t);return c&&(t=c,l=K),s?e?i:n:e?k:a}function Z(t,e){return function(r){var n=co.event;co.event=r,e[0]=this.__data__;try{t.apply(this,e)}finally{co.event=n}}}function K(t,e){var r=Z(t,e);return function(t){var e=this,n=t.relatedTarget;n&&(n===e||8&n.compareDocumentPosition(e))||r.call(e,t)}}function $(t){var r=".dragsuppress-"+ ++jo,i="click"+r,a=co.select(n(t)).on("touchmove"+r,T).on("dragstart"+r,T).on("selectstart"+r,T);if(null==No&&(No="onselectstart"in t?!1:w(t.style,"userSelect")),No){var o=e(t).style,s=o[No];o[No]="none"}return function(t){if(a.on(r,null),No&&(o[No]=s),t){var e=function(){a.on(i,null)};a.on(i,function(){T(),e()},!0),setTimeout(e,0)}}}function Q(t,e){e.changedTouches&&(e=e.changedTouches[0]);var r=t.ownerSVGElement||t;if(r.createSVGPoint){var i=r.createSVGPoint();if(0>Fo){var a=n(t);if(a.scrollX||a.scrollY){r=co.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();Fo=!(o.f||o.e),r.remove()}}return Fo?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}function J(){return co.event.changedTouches[0].identifier}function tt(t){return t>0?1:0>t?-1:0}function et(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function rt(t){return t>1?0:-1>t?Uo:Math.acos(t)}function nt(t){return t>1?Ho:-1>t?-Ho:Math.asin(t)}function it(t){return((t=Math.exp(t))-1/t)/2}function at(t){return((t=Math.exp(t))+1/t)/2}function ot(t){return((t=Math.exp(2*t))-1)/(t+1)}function st(t){return(t=Math.sin(t/2))*t}function lt(){}function ct(t,e,r){return this instanceof ct?(this.h=+t,this.s=+e,void(this.l=+r)):arguments.length<2?t instanceof ct?new ct(t.h,t.s,t.l):kt(""+t,At,ct):new ct(t,e,r)}function ut(t,e,r){function n(t){return t>360?t-=360:0>t&&(t+=360),60>t?a+(o-a)*t/60:180>t?o:240>t?a+(o-a)*(240-t)/60:a}function i(t){return Math.round(255*n(t))}var a,o;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:0>e?0:e>1?1:e,r=0>r?0:r>1?1:r,o=.5>=r?r*(1+e):r+e-r*e,a=2*r-o,new bt(i(t+120),i(t),i(t-120))}function ft(t,e,r){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+r)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof dt?gt(t.l,t.a,t.b):gt((t=Mt((t=co.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,r)}function ht(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new dt(r,Math.cos(t*=Go)*e,Math.sin(t)*e)}function dt(t,e,r){return this instanceof dt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof dt?new dt(t.l,t.a,t.b):t instanceof ft?ht(t.h,t.c,t.l):Mt((t=bt(t)).r,t.g,t.b):new dt(t,e,r)}function pt(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return i=vt(i)*rs,n=vt(n)*ns,a=vt(a)*is,new bt(yt(3.2404542*i-1.5371385*n-.4985314*a),yt(-.969266*i+1.8760108*n+.041556*a),yt(.0556434*i-.2040259*n+1.0572252*a))}function gt(t,e,r){return t>0?new ft(Math.atan2(r,e)*Yo,Math.sqrt(e*e+r*r),t):new ft(NaN,NaN,t)}function vt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function mt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function bt(t,e,r){return this instanceof bt?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof bt?new bt(t.r,t.g,t.b):kt(""+t,bt,ut):new bt(t,e,r)}function xt(t){return new bt(t>>16,t>>8&255,255&t)}function _t(t){return xt(t)+""}function wt(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function kt(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(Et(i[0]),Et(i[1]),Et(i[2]))}return(a=ss.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o=o>>4|o,s=240&a,s=s>>4|s,l=15&a,l=l<<4|l):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function At(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=.5>l?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(r>e?6:0):e==o?(r-t)/s+2:(t-e)/s+4,n*=60):(n=NaN,i=l>0&&1>l?0:n),new ct(n,i,l)}function Mt(t,e,r){t=Tt(t),e=Tt(e),r=Tt(r);var n=mt((.4124564*t+.3575761*e+.1804375*r)/rs),i=mt((.2126729*t+.7151522*e+.072175*r)/ns),a=mt((.0193339*t+.119192*e+.9503041*r)/is);return dt(116*i-16,500*(n-i),200*(i-a))}function Tt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Et(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function Lt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,r,n){return 2===arguments.length&&"function"==typeof r&&(n=r,r=null),Ct(e,r,t,n)}}function Ct(t,e,r,n){function i(){var t,e=l.status;if(!e&&Pt(l)||e>=200&&300>e||304===e){try{t=r.call(a,l)}catch(n){return void o.error.call(a,n)}o.load.call(a,t)}else o.error.call(a,l)}var a={},o=co.dispatch("beforesend","progress","load","error"),s={},l=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(t)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(t){var e=co.event;co.event=t;try{o.progress.call(a,l)}finally{co.event=e}},a.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",a)},a.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",a):e},a.responseType=function(t){return arguments.length?(c=t,a):c},a.response=function(t){return r=t,a},["get","post"].forEach(function(t){a[t]=function(){return a.send.apply(a,[t].concat(fo(arguments)))}}),a.send=function(r,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),l.open(r,t,!0),null==e||"accept"in s||(s.accept=e+",*/*"),l.setRequestHeader)for(var u in s)l.setRequestHeader(u,s[u]);return null!=e&&l.overrideMimeType&&l.overrideMimeType(e),null!=c&&(l.responseType=c),null!=i&&a.on("error",i).on("load",function(t){i(null,t)}),o.beforesend.call(a,l),l.send(null==n?null:n),a},a.abort=function(){return l.abort(),a},co.rebind(a,o,"on"),null==n?a:a.get(zt(n))}function zt(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}function Pt(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Rt(t,e,r){var n=arguments.length;2>n&&(e=0),3>n&&(r=Date.now());var i=r+e,a={c:t,t:i,n:null};return cs?cs.n=a:ls=a,cs=a,us||(fs=clearTimeout(fs),us=1,hs(Ot)),a}function Ot(){var t=It(),e=Nt()-t;e>24?(isFinite(e)&&(clearTimeout(fs),fs=setTimeout(Ot,e)),us=0):(us=1,hs(Ot))}function It(){for(var t=Date.now(),e=ls;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Nt(){for(var t,e=ls,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}}function Dt(t){var e=t.decimal,r=t.thousands,n=t.grouping,i=t.currency,a=n&&r?function(t,e){for(var i=t.length,a=[],o=0,s=n[0],l=0;i>0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>e));)s=n[o=(o+1)%n.length];return a.reverse().join(r)}:x;return function(t){var r=ps.exec(t),n=r[1]||" ",o=r[2]||">",s=r[3]||"-",l=r[4]||"",c=r[5],u=+r[6],f=r[7],h=r[8],d=r[9],p=1,g="",v="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(c||"0"===n&&"="===o)&&(c=n="0",o="="),d){case"n":f=!0,d="g";break;case"%":p=100,v="%",d="f";break;case"p":p=100,v="%",d="r";break;case"b":case"o":case"x":case"X":"#"===l&&(g="0"+d.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,d="r"}"$"===l&&(g=i[0],v=i[1]),"r"!=d||h||(d="g"),null!=h&&("g"==d?h=Math.max(1,Math.min(21,h)):"e"!=d&&"f"!=d||(h=Math.max(0,Math.min(20,h)))),d=gs.get(d)||Bt;var b=c&&f;return function(t){var r=v;if(m&&t%1)return"";var i=0>t||0===t&&0>1/t?(t=-t,"-"):"-"===s?"":s;if(0>p){var l=co.formatPrefix(t,h);t=l.scale(t),r=l.symbol+v}else t*=p;t=d(t,h);var x,_,w=t.lastIndexOf(".");if(0>w){var k=y?t.lastIndexOf("e"):-1;0>k?(x=t,_=""):(x=t.substring(0,k),_=t.substring(k))}else x=t.substring(0,w),_=e+t.substring(w+1);!c&&f&&(x=a(x,1/0));var A=g.length+x.length+_.length+(b?0:i.length),M=u>A?new Array(A=u-A+1).join(n):"";return b&&(x=a(M+x,M.length?u-_.length:1/0)),i+=g,t=x+_,("<"===o?i+t+M:">"===o?M+i+t:"^"===o?M.substring(0,A>>=1)+i+t+M.substring(A):i+(b?t:M+t))+r}}}function Bt(t){return t+""}function Ut(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Vt(t,e,r){function n(e){var r=t(e),n=a(r,1);return n-e>e-r?r:n}function i(r){return e(r=t(new ms(r-1)),1),r}function a(t,r){return e(t=new ms(+t),r),t}function o(t,n,a){var o=i(t),s=[];if(a>1)for(;n>o;)r(o)%a||s.push(new Date(+o)),e(o,1);else for(;n>o;)s.push(new Date(+o)),e(o,1);return s}function s(t,e,r){try{ms=Ut;var n=new Ut;return n._=t,o(n,e,r)}finally{ms=Date}}t.floor=t,t.round=n,t.ceil=i,t.offset=a,t.range=o;var l=t.utc=qt(t);return l.floor=l,l.round=qt(n),l.ceil=qt(i),l.offset=qt(a),l.range=s,t}function qt(t){return function(e,r){try{ms=Ut;var n=new Ut;return n._=e,t(n,r)._}finally{ms=Date}}}function Ht(t){function e(t){function e(e){for(var r,i,a,o=[],s=-1,l=0;++ss;){if(n>=c)return-1;if(i=e.charCodeAt(s++),37===i){if(o=e.charAt(s++),a=S[o in bs?e.charAt(s++):o],!a||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}function n(t,e,r){w.lastIndex=0;var n=w.exec(e.slice(r));return n?(t.w=k.get(n[0].toLowerCase()),r+n[0].length):-1}function i(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.w=_.get(n[0].toLowerCase()),r+n[0].length):-1}function a(t,e,r){T.lastIndex=0;var n=T.exec(e.slice(r));return n?(t.m=E.get(n[0].toLowerCase()),r+n[0].length):-1}function o(t,e,r){A.lastIndex=0;var n=A.exec(e.slice(r));return n?(t.m=M.get(n[0].toLowerCase()),r+n[0].length):-1}function s(t,e,n){return r(t,L.c.toString(),e,n)}function l(t,e,n){return r(t,L.x.toString(),e,n)}function c(t,e,n){return r(t,L.X.toString(),e,n)}function u(t,e,r){var n=b.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)}var f=t.dateTime,h=t.date,d=t.time,p=t.periods,g=t.days,v=t.shortDays,m=t.months,y=t.shortMonths;e.utc=function(t){function r(t){try{ms=Ut;var e=new ms;return e._=t,n(e)}finally{ms=Date}}var n=e(t);return r.parse=function(t){try{ms=Ut;var e=n.parse(t);return e&&e._}finally{ms=Date}},r.toString=n.toString,r},e.multi=e.utc.multi=ue;var b=co.map(),x=Yt(g),_=Xt(g),w=Yt(v),k=Xt(v),A=Yt(m),M=Xt(m),T=Yt(y),E=Xt(y);p.forEach(function(t,e){b.set(t.toLowerCase(),e)});var L={a:function(t){return v[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return m[t.getMonth()]},c:e(f),d:function(t,e){return Gt(t.getDate(),e,2)},e:function(t,e){return Gt(t.getDate(),e,2)},H:function(t,e){return Gt(t.getHours(),e,2)},I:function(t,e){return Gt(t.getHours()%12||12,e,2)},j:function(t,e){return Gt(1+vs.dayOfYear(t),e,3)},L:function(t,e){return Gt(t.getMilliseconds(),e,3)},m:function(t,e){return Gt(t.getMonth()+1,e,2)},M:function(t,e){return Gt(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Gt(t.getSeconds(),e,2)},U:function(t,e){return Gt(vs.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Gt(vs.mondayOfYear(t),e,2)},x:e(h),X:e(d),y:function(t,e){return Gt(t.getFullYear()%100,e,2)},Y:function(t,e){return Gt(t.getFullYear()%1e4,e,4)},Z:le,"%":function(){return"%"}},S={a:n,A:i,b:a,B:o,c:s,d:re,e:re,H:ie,I:ie,j:ne,L:se,m:ee,M:ae,p:u,S:oe,U:Zt,w:Wt,W:Kt,x:l,X:c,y:Qt,Y:$t,Z:Jt,"%":ce};return e}function Gt(t,e,r){var n=0>t?"-":"",i=(n?-t:t)+"",a=i.length;return n+(r>a?new Array(r-a+1).join(e)+i:i)}function Yt(t){return new RegExp("^(?:"+t.map(co.requote).join("|")+")","i")}function Xt(t){for(var e=new f,r=-1,n=t.length;++r68?1900:2e3)}function ee(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function re(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function ne(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function ie(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function ae(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function oe(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function se(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function le(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=wo(e)/60|0,i=wo(e)%60;return r+Gt(n,"0",2)+Gt(i,"0",2)}function ce(t,e,r){_s.lastIndex=0;var n=_s.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function ue(t){for(var e=t.length,r=-1;++r=0?1:-1,s=o*r,l=Math.cos(e),c=Math.sin(e),u=a*c,f=i*l+u*Math.cos(s),h=u*o*Math.sin(s);Es.add(Math.atan2(h,f)),n=t,i=l,a=c}var e,r,n,i,a;Ls.point=function(o,s){Ls.point=t,n=(e=o)*Go,i=Math.cos(s=(r=s)*Go/2+Uo/4),a=Math.sin(s)},Ls.lineEnd=function(){t(e,r)}}function me(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function be(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function xe(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ke(t){return[Math.atan2(t[1],t[0]),nt(t[2])]}function Ae(t,e){return wo(t[0]-e[0])s;++s)i.point((r=t[s])[0],r[1]);return void i.lineEnd()}var l=new Oe(r,t,null,!0),c=new Oe(r,null,l,!1);l.o=c,a.push(l),o.push(c),l=new Oe(n,t,null,!1),c=new Oe(n,null,l,!0),l.o=c,a.push(l),o.push(c)}}),o.sort(e),Re(a),Re(o),a.length){for(var s=0,l=r,c=o.length;c>s;++s)o[s].e=l=!l;for(var u,f,h=a[0];;){for(var d=h,p=!0;d.v;)if((d=d.n)===h)return;u=d.z,i.lineStart();do{if(d.v=d.o.v=!0,d.e){if(p)for(var s=0,c=u.length;c>s;++s)i.point((f=u[s])[0],f[1]);else n(d.x,d.n.x,1,i);d=d.n}else{if(p){u=d.p.z;for(var s=u.length-1;s>=0;--s)i.point((f=u[s])[0],f[1])}else n(d.x,d.p.x,-1,i);d=d.p}d=d.o,u=d.z,p=!p}while(!d.v);i.lineEnd()}}}function Re(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n0){for(_||(a.polygonStart(),_=!0),a.lineStart();++o1&&2&e&&r.push(r.pop().concat(r.shift())),d.push(r.filter(Ne))}var d,p,g,v=e(a),m=i.invert(n[0],n[1]),y={point:o,lineStart:l,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=f,y.lineEnd=h,d=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=l,y.lineEnd=c,d=co.merge(d);var t=Ve(m,p);d.length?(_||(a.polygonStart(),_=!0),Pe(d,Fe,t,r,a)):t&&(_||(a.polygonStart(),_=!0),a.lineStart(),r(null,null,1,a),a.lineEnd()),_&&(a.polygonEnd(),_=!1),d=p=null},sphere:function(){a.polygonStart(),a.lineStart(),r(null,null,1,a),a.lineEnd(),a.polygonEnd()}},b=je(),x=e(b),_=!1;return y}}function Ne(t){return t.length>1}function je(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:k,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Fe(t,e){return((t=t.x)[0]<0?t[1]-Ho-Do:Ho-t[1])-((e=e.x)[0]<0?e[1]-Ho-Do:Ho-e[1])}function De(t){var e,r=NaN,n=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?Uo:-Uo,l=wo(a-r);wo(l-Uo)0?Ho:-Ho),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=Uo&&(wo(r-i)Do?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}function Ue(t,e,r,n){var i;if(null==t)i=r*Ho,n.point(-Uo,i),n.point(0,i),n.point(Uo,i),n.point(Uo,0),n.point(Uo,-i),n.point(0,-i),n.point(-Uo,-i),n.point(-Uo,0),n.point(-Uo,i);else if(wo(t[0]-e[0])>Do){var a=t[0]s;++s){var c=e[s],u=c.length;if(u)for(var f=c[0],h=f[0],d=f[1]/2+Uo/4,p=Math.sin(d),g=Math.cos(d),v=1;;){v===u&&(v=0),t=c[v];var m=t[0],y=t[1]/2+Uo/4,b=Math.sin(y),x=Math.cos(y),_=m-h,w=_>=0?1:-1,k=w*_,A=k>Uo,M=p*b;if(Es.add(Math.atan2(M*w*Math.sin(k),g*x+M*Math.cos(k))),a+=A?_+w*Vo:_,A^h>=r^m>=r){var T=be(me(f),me(t));we(T);var E=be(i,T);we(E);var L=(A^_>=0?-1:1)*nt(E[2]);(n>L||n===L&&(T[0]||T[1]))&&(o+=A^_>=0?1:-1)}if(!v++)break;h=m,p=b,g=x,f=t}}return(-Do>a||Do>a&&0>Es)^1&o}function qe(t){function e(t,e){return Math.cos(t)*Math.cos(e)>a}function r(t){var r,a,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(f,h){var d,p=[f,h],g=e(f,h),v=o?g?0:i(f,h):g?i(f+(0>f?Uo:-Uo),h):0;if(!r&&(c=l=g)&&t.lineStart(),g!==l&&(d=n(r,p),(Ae(r,d)||Ae(p,d))&&(p[0]+=Do,p[1]+=Do,g=e(p[0],p[1]))),g!==l)u=0,g?(t.lineStart(),d=n(p,r),t.point(d[0],d[1])):(d=n(r,p),t.point(d[0],d[1]),t.lineEnd()),r=d;else if(s&&r&&o^g){var m;v&a||!(m=n(p,r,!0))||(u=0,o?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||r&&Ae(r,p)||t.point(p[0],p[1]),r=p,l=g,a=v},lineEnd:function(){l&&t.lineEnd(),r=null},clean:function(){return u|(c&&l)<<1}}}function n(t,e,r){var n=me(t),i=me(e),o=[1,0,0],s=be(n,i),l=ye(s,s),c=s[0],u=l-c*c;if(!u)return!r&&t;var f=a*l/u,h=-a*c/u,d=be(o,s),p=_e(o,f),g=_e(s,h);xe(p,g);var v=d,m=ye(p,v),y=ye(v,v),b=m*m-y*(ye(p,p)-1);if(!(0>b)){var x=Math.sqrt(b),_=_e(v,(-m-x)/y);if(xe(_,p),_=ke(_),!r)return _;var w,k=t[0],A=e[0],M=t[1],T=e[1];k>A&&(w=k,k=A,A=w);var E=A-k,L=wo(E-Uo)E;if(!L&&M>T&&(w=M,M=T,T=w),S?L?M+T>0^_[1]<(wo(_[0]-k)Uo^(k<=_[0]&&_[0]<=A)){var C=_e(v,(-m+x)/y);return xe(C,p),[_,ke(C)]}}}function i(e,r){var n=o?t:Uo-t,i=0;return-n>e?i|=1:e>n&&(i|=2),-n>r?i|=4:r>n&&(i|=8),i}var a=Math.cos(t),o=a>0,s=wo(a)>Do,l=vr(t,6*Go);return Ie(e,r,l,o?[0,-t]:[-Uo,t-Uo])}function He(t,e,r,n){return function(i){var a,o=i.a,s=i.b,l=o.x,c=o.y,u=s.x,f=s.y,h=0,d=1,p=u-l,g=f-c;if(a=t-l,p||!(a>0)){if(a/=p,0>p){if(h>a)return;d>a&&(d=a)}else if(p>0){if(a>d)return;a>h&&(h=a)}if(a=r-l,p||!(0>a)){if(a/=p,0>p){if(a>d)return;a>h&&(h=a)}else if(p>0){if(h>a)return;d>a&&(d=a)}if(a=e-c,g||!(a>0)){if(a/=g,0>g){if(h>a)return;d>a&&(d=a)}else if(g>0){if(a>d)return;a>h&&(h=a)}if(a=n-c,g||!(0>a)){if(a/=g,0>g){if(a>d)return;a>h&&(h=a)}else if(g>0){if(h>a)return;d>a&&(d=a)}return h>0&&(i.a={x:l+h*p,y:c+h*g}),1>d&&(i.b={x:l+d*p,y:c+d*g}),i}}}}}}function Ge(t,e,r,n){function i(n,i){return wo(n[0]-t)0?0:3:wo(n[0]-r)0?2:1:wo(n[1]-e)0?1:0:i>0?3:2}function a(t,e){return o(t.x,e.x)}function o(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}return function(s){function l(t){for(var e=0,r=v.length,n=t[1],i=0;r>i;++i)for(var a,o=1,s=v[i],l=s.length,c=s[0];l>o;++o)a=s[o],c[1]<=n?a[1]>n&&et(c,a,t)>0&&++e:a[1]<=n&&et(c,a,t)<0&&--e,c=a;return 0!==e}function c(a,s,l,c){var u=0,f=0;if(null==a||(u=i(a,l))!==(f=i(s,l))||o(a,s)<0^l>0){do c.point(0===u||3===u?t:r,u>1?n:e);while((u=(u+l+4)%4)!==f)}else c.point(s[0],s[1])}function u(i,a){return i>=t&&r>=i&&a>=e&&n>=a}function f(t,e){u(t,e)&&s.point(t,e)}function h(){S.point=p,v&&v.push(m=[]),A=!0,k=!1,_=w=NaN}function d(){g&&(p(y,b),x&&k&&E.rejoin(),g.push(E.buffer())),S.point=f,k&&s.lineEnd()}function p(t,e){t=Math.max(-Vs,Math.min(Vs,t)),e=Math.max(-Vs,Math.min(Vs,e));var r=u(t,e);if(v&&m.push([t,e]),A)y=t,b=e,x=r,A=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&k)s.point(t,e);else{var n={a:{x:_,y:w},b:{x:t,y:e}};L(n)?(k||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),M=!1):r&&(s.lineStart(),s.point(t,e),M=!1)}_=t,w=e,k=r}var g,v,m,y,b,x,_,w,k,A,M,T=s,E=je(),L=He(t,e,r,n),S={point:f,lineStart:h,lineEnd:d,polygonStart:function(){s=E,g=[],v=[],M=!0},polygonEnd:function(){s=T,g=co.merge(g);var e=l([t,n]),r=M&&e,i=g.length;(r||i)&&(s.polygonStart(),r&&(s.lineStart(),c(null,null,1,s),s.lineEnd()),i&&Pe(g,a,e,c,s),s.polygonEnd()),g=v=m=null}};return S}}function Ye(t){var e=0,r=Uo/3,n=lr(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*Uo/180,r=t[1]*Uo/180):[e/Uo*180,r/Uo*180]},i}function Xe(t,e){function r(t,e){var r=Math.sqrt(a-2*i*Math.sin(e))/i;return[r*Math.sin(t*=i),o-r*Math.cos(t)]}var n=Math.sin(t),i=(n+Math.sin(e))/2,a=1+n*(2*i-n),o=Math.sqrt(a)/i;return r.invert=function(t,e){var r=o-e;return[Math.atan2(t,r)/i,nt((a-(t*t+r*r)*i*i)/(2*i))]},r}function We(){function t(t,e){Hs+=i*t-n*e,n=t,i=e}var e,r,n,i;Zs.point=function(a,o){Zs.point=t,e=n=a,r=i=o},Zs.lineEnd=function(){t(e,r)}}function Ze(t,e){Gs>t&&(Gs=t),t>Xs&&(Xs=t),Ys>e&&(Ys=e),e>Ws&&(Ws=e)}function Ke(){function t(t,e){o.push("M",t,",",e,a)}function e(t,e){o.push("M",t,",",e),s.point=r}function r(t,e){o.push("L",t,",",e)}function n(){s.point=t}function i(){o.push("Z")}var a=$e(4.5),o=[],s={point:t,lineStart:function(){s.point=e},lineEnd:n,polygonStart:function(){s.lineEnd=i},polygonEnd:function(){s.lineEnd=n,s.point=t},pointRadius:function(t){return a=$e(t),s},result:function(){if(o.length){var t=o.join("");return o=[],t}}};return s}function $e(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Qe(t,e){zs+=t,Ps+=e,++Rs}function Je(){function t(t,n){var i=t-e,a=n-r,o=Math.sqrt(i*i+a*a);Os+=o*(e+t)/2,Is+=o*(r+n)/2,Ns+=o,Qe(e=t,r=n)}var e,r;$s.point=function(n,i){$s.point=t,Qe(e=n,r=i)}}function tr(){$s.point=Qe}function er(){function t(t,e){var r=t-n,a=e-i,o=Math.sqrt(r*r+a*a);Os+=o*(n+t)/2,Is+=o*(i+e)/2,Ns+=o,o=i*t-n*e,js+=o*(n+t),Fs+=o*(i+e),Ds+=3*o,Qe(n=t,i=e)}var e,r,n,i;$s.point=function(a,o){$s.point=t,Qe(e=n=a,r=i=o)},$s.lineEnd=function(){t(e,r)}}function rr(t){function e(e,r){t.moveTo(e+o,r),t.arc(e,r,o,0,Vo); -}function r(e,r){t.moveTo(e,r),s.point=n}function n(e,r){t.lineTo(e,r)}function i(){s.point=e}function a(){t.closePath()}var o=4.5,s={point:e,lineStart:function(){s.point=r},lineEnd:i,polygonStart:function(){s.lineEnd=a},polygonEnd:function(){s.lineEnd=i,s.point=e},pointRadius:function(t){return o=t,s},result:k};return s}function nr(t){function e(t){return(s?n:r)(t)}function r(e){return or(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})}function n(e){function r(r,n){r=t(r,n),e.point(r[0],r[1])}function n(){b=NaN,A.point=a,e.lineStart()}function a(r,n){var a=me([r,n]),o=t(r,n);i(b,x,y,_,w,k,b=o[0],x=o[1],y=r,_=a[0],w=a[1],k=a[2],s,e),e.point(b,x)}function o(){A.point=r,e.lineEnd()}function l(){n(),A.point=c,A.lineEnd=u}function c(t,e){a(f=t,h=e),d=b,p=x,g=_,v=w,m=k,A.point=a}function u(){i(b,x,y,_,w,k,d,p,f,g,v,m,s,e),A.lineEnd=o,o()}var f,h,d,p,g,v,m,y,b,x,_,w,k,A={point:r,lineStart:n,lineEnd:o,polygonStart:function(){e.polygonStart(),A.lineStart=l},polygonEnd:function(){e.polygonEnd(),A.lineStart=n}};return A}function i(e,r,n,s,l,c,u,f,h,d,p,g,v,m){var y=u-e,b=f-r,x=y*y+b*b;if(x>4*a&&v--){var _=s+d,w=l+p,k=c+g,A=Math.sqrt(_*_+w*w+k*k),M=Math.asin(k/=A),T=wo(wo(k)-1)a||wo((y*C+b*z)/x-.5)>.3||o>s*d+l*p+c*g)&&(i(e,r,n,s,l,c,L,S,T,_/=A,w/=A,k,v,m),m.point(L,S),i(L,S,T,_,w,k,u,f,h,d,p,g,v,m))}}var a=.5,o=Math.cos(30*Go),s=16;return e.precision=function(t){return arguments.length?(s=(a=t*t)>0&&16,e):Math.sqrt(a)},e}function ir(t){var e=nr(function(e,r){return t([e*Yo,r*Yo])});return function(t){return cr(e(t))}}function ar(t){this.stream=t}function or(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sr(t){return lr(function(){return t})()}function lr(t){function e(t){return t=s(t[0]*Go,t[1]*Go),[t[0]*h+l,c-t[1]*h]}function r(t){return t=s.invert((t[0]-l)/h,(c-t[1])/h),t&&[t[0]*Yo,t[1]*Yo]}function n(){s=Ce(o=hr(m,y,b),a);var t=a(g,v);return l=d-t[0]*h,c=p+t[1]*h,i()}function i(){return u&&(u.valid=!1,u=null),e}var a,o,s,l,c,u,f=nr(function(t,e){return t=a(t,e),[t[0]*h+l,c-t[1]*h]}),h=150,d=480,p=250,g=0,v=0,m=0,y=0,b=0,_=Us,w=x,k=null,A=null;return e.stream=function(t){return u&&(u.valid=!1),u=cr(_(o,f(w(t)))),u.valid=!0,u},e.clipAngle=function(t){return arguments.length?(_=null==t?(k=t,Us):qe((k=+t)*Go),i()):k},e.clipExtent=function(t){return arguments.length?(A=t,w=t?Ge(t[0][0],t[0][1],t[1][0],t[1][1]):x,i()):A},e.scale=function(t){return arguments.length?(h=+t,n()):h},e.translate=function(t){return arguments.length?(d=+t[0],p=+t[1],n()):[d,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Go,v=t[1]%360*Go,n()):[g*Yo,v*Yo]},e.rotate=function(t){return arguments.length?(m=t[0]%360*Go,y=t[1]%360*Go,b=t.length>2?t[2]%360*Go:0,n()):[m*Yo,y*Yo,b*Yo]},co.rebind(e,f,"precision"),function(){return a=t.apply(this,arguments),e.invert=a.invert&&r,n()}}function cr(t){return or(t,function(e,r){t.point(e*Go,r*Go)})}function ur(t,e){return[t,e]}function fr(t,e){return[t>Uo?t-Vo:-Uo>t?t+Vo:t,e]}function hr(t,e,r){return t?e||r?Ce(pr(t),gr(e,r)):pr(t):e||r?gr(e,r):fr}function dr(t){return function(e,r){return e+=t,[e>Uo?e-Vo:-Uo>e?e+Vo:e,r]}}function pr(t){var e=dr(t);return e.invert=dr(-t),e}function gr(t,e){function r(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*n+s*i;return[Math.atan2(l*a-u*o,s*n-c*i),nt(u*a+l*o)]}var n=Math.cos(t),i=Math.sin(t),a=Math.cos(e),o=Math.sin(e);return r.invert=function(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*a-l*o;return[Math.atan2(l*a+c*o,s*n+u*i),nt(u*n-s*i)]},r}function vr(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=mr(r,i),a=mr(r,a),(o>0?a>i:i>a)&&(i+=o*Vo)):(i=t+o*Vo,a=t-.5*l);for(var c,u=i;o>0?u>a:a>u;u-=l)s.point((c=ke([r,-n*Math.cos(u),-n*Math.sin(u)]))[0],c[1])}}function mr(t,e){var r=me(e);r[0]-=t,we(r);var n=rt(-r[1]);return((-r[2]<0?-n:n)+2*Math.PI-Do)%(2*Math.PI)}function yr(t,e,r){var n=co.range(t,e-Do,r).concat(e);return function(t){return n.map(function(e){return[t,e]})}}function br(t,e,r){var n=co.range(t,e-Do,r).concat(e);return function(t){return n.map(function(e){return[e,t]})}}function xr(t){return t.source}function _r(t){return t.target}function wr(t,e,r,n){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(n),s=Math.sin(n),l=i*Math.cos(t),c=i*Math.sin(t),u=o*Math.cos(r),f=o*Math.sin(r),h=2*Math.asin(Math.sqrt(st(n-e)+i*o*st(r-t))),d=1/Math.sin(h),p=h?function(t){var e=Math.sin(t*=h)*d,r=Math.sin(h-t)*d,n=r*l+e*u,i=r*c+e*f,o=r*a+e*s;return[Math.atan2(i,n)*Yo,Math.atan2(o,Math.sqrt(n*n+i*i))*Yo]}:function(){return[t*Yo,e*Yo]};return p.distance=h,p}function kr(){function t(t,i){var a=Math.sin(i*=Go),o=Math.cos(i),s=wo((t*=Go)-e),l=Math.cos(s);Qs+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=n*a-r*o*l)*s),r*a+n*o*l),e=t,r=a,n=o}var e,r,n;Js.point=function(i,a){e=i*Go,r=Math.sin(a*=Go),n=Math.cos(a),Js.point=t},Js.lineEnd=function(){Js.point=Js.lineEnd=k}}function Ar(t,e){function r(e,r){var n=Math.cos(e),i=Math.cos(r),a=t(n*i);return[a*i*Math.sin(e),a*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),i=e(n),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,n*o),Math.asin(n&&r*a/n)]},r}function Mr(t,e){function r(t,e){o>0?-Ho+Do>e&&(e=-Ho+Do):e>Ho-Do&&(e=Ho-Do);var r=o/Math.pow(i(e),a);return[r*Math.sin(a*t),o-r*Math.cos(a*t)]}var n=Math.cos(t),i=function(t){return Math.tan(Uo/4+t/2)},a=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(i(e)/i(t)),o=n*Math.pow(i(t),a)/a;return a?(r.invert=function(t,e){var r=o-e,n=tt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(o/n,1/a))-Ho]},r):Er}function Tr(t,e){function r(t,e){var r=a-e;return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}var n=Math.cos(t),i=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),a=n/i+t;return wo(i)i;i++){for(;n>1&&et(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function Rr(t,e){return t[0]-e[0]||t[1]-e[1]}function Or(t,e,r){return(r[0]-e[0])*(t[1]-e[1])<(r[1]-e[1])*(t[0]-e[0])}function Ir(t,e,r,n){var i=t[0],a=r[0],o=e[0]-i,s=n[0]-a,l=t[1],c=r[1],u=e[1]-l,f=n[1]-c,h=(s*(l-c)-f*(i-a))/(f*o-s*u);return[i+h*o,l+h*u]}function Nr(t){var e=t[0],r=t[t.length-1];return!(e[0]-r[0]||e[1]-r[1])}function jr(){an(this),this.edge=this.site=this.circle=null}function Fr(t){var e=fl.pop()||new jr;return e.site=t,e}function Dr(t){Zr(t),ll.remove(t),fl.push(t),an(t)}function Br(t){var e=t.circle,r=e.x,n=e.cy,i={x:r,y:n},a=t.P,o=t.N,s=[t];Dr(t);for(var l=a;l.circle&&wo(r-l.circle.x)u;++u)c=s[u],l=s[u-1],en(c.edge,l.site,c.site,i);l=s[0],c=s[f-1],c.edge=Jr(l.site,c.site,null,i),Wr(l),Wr(c)}function Ur(t){for(var e,r,n,i,a=t.x,o=t.y,s=ll._;s;)if(n=Vr(s,o)-a,n>Do)s=s.L;else{if(i=a-qr(s,o),!(i>Do)){n>-Do?(e=s.P,r=s):i>-Do?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=Fr(t);if(ll.insert(e,l),e||r){if(e===r)return Zr(e),r=Fr(e.site),ll.insert(l,r),l.edge=r.edge=Jr(e.site,l.site),Wr(e),void Wr(r);if(!r)return void(l.edge=Jr(e.site,l.site));Zr(e),Zr(r);var c=e.site,u=c.x,f=c.y,h=t.x-u,d=t.y-f,p=r.site,g=p.x-u,v=p.y-f,m=2*(h*v-d*g),y=h*h+d*d,b=g*g+v*v,x={x:(v*y-d*b)/m+u,y:(h*b-g*y)/m+f};en(r.edge,c,p,x),l.edge=Jr(c,t,null,x),r.edge=Jr(t,p,null,x),Wr(e),Wr(r)}}function Vr(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-(1/0);r=o.site;var s=r.x,l=r.y,c=l-e;if(!c)return s;var u=s-n,f=1/a-1/c,h=u/c;return f?(-h+Math.sqrt(h*h-2*f*(u*u/(-2*c)-l+c/2+i-a/2)))/f+n:(n+s)/2}function qr(t,e){var r=t.N;if(r)return Vr(r,e);var n=t.site;return n.y===e?n.x:1/0}function Hr(t){this.site=t,this.edges=[]}function Gr(t){for(var e,r,n,i,a,o,s,l,c,u,f=t[0][0],h=t[1][0],d=t[0][1],p=t[1][1],g=sl,v=g.length;v--;)if(a=g[v],a&&a.prepare())for(s=a.edges,l=s.length,o=0;l>o;)u=s[o].end(),n=u.x,i=u.y,c=s[++o%l].start(),e=c.x,r=c.y,(wo(n-e)>Do||wo(i-r)>Do)&&(s.splice(o,0,new rn(tn(a.site,u,wo(n-f)Do?{x:f,y:wo(e-f)Do?{x:wo(r-p)Do?{x:h,y:wo(e-h)Do?{x:wo(r-d)=-Bo)){var d=l*l+c*c,p=u*u+f*f,g=(f*d-c*p)/h,v=(l*p-u*d)/h,f=v+s,m=hl.pop()||new Xr;m.arc=t,m.site=i,m.x=g+o,m.y=f+Math.sqrt(g*g+v*v),m.cy=f,t.circle=m;for(var y=null,b=ul._;b;)if(m.yv||v>=s)return;if(h>p){if(a){if(a.y>=c)return}else a={x:v,y:l};r={x:v,y:c}}else{if(a){if(a.yn||n>1)if(h>p){if(a){if(a.y>=c)return}else a={x:(l-i)/n,y:l};r={x:(c-i)/n,y:c}}else{if(a){if(a.yd){if(a){if(a.x>=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xa||f>o||n>h||i>d)){if(p=t.point){var p,g=e-t.x,v=r-t.y,m=g*g+v*v;if(l>m){var y=Math.sqrt(l=m);n=e-y,i=r-y,a=e+y,o=r+y,s=p}}for(var b=t.nodes,x=.5*(u+h),_=.5*(f+d),w=e>=x,k=r>=_,A=k<<1|w,M=A+4;M>A;++A)if(t=b[3&A])switch(3&A){case 0:c(t,u,f,x,_);break;case 1:c(t,x,f,h,_);break;case 2:c(t,u,_,x,d);break;case 3:c(t,x,_,h,d)}}}(t,n,i,a,o),s}function mn(t,e){t=co.rgb(t),e=co.rgb(e);var r=t.r,n=t.g,i=t.b,a=e.r-r,o=e.g-n,s=e.b-i;return function(t){return"#"+wt(Math.round(r+a*t))+wt(Math.round(n+o*t))+wt(Math.round(i+s*t))}}function yn(t,e){var r,n={},i={};for(r in t)r in e?n[r]=_n(t[r],e[r]):i[r]=t[r];for(r in e)r in t||(i[r]=e[r]);return function(t){for(r in n)i[r]=n[r](t);return i}}function bn(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function xn(t,e){var r,n,i,a=pl.lastIndex=gl.lastIndex=0,o=-1,s=[],l=[];for(t+="",e+="";(r=pl.exec(t))&&(n=gl.exec(e));)(i=n.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:bn(r,n)})),a=gl.lastIndex;return an;++n)s[(r=l[n]).i]=r.x(t);return s.join("")})}function _n(t,e){for(var r,n=co.interpolators.length;--n>=0&&!(r=co.interpolators[n](t,e)););return r}function wn(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;s>r;++r)n.push(_n(t[r],e[r]));for(;a>r;++r)i[r]=t[r];for(;o>r;++r)i[r]=e[r];return function(t){for(r=0;s>r;++r)i[r]=n[r](t);return i}}function kn(t){return function(e){return 0>=e?0:e>=1?1:t(e)}}function An(t){return function(e){return 1-t(1-e)}}function Mn(t){return function(e){return.5*(.5>e?t(2*e):2-t(2-2*e))}}function Tn(t){return t*t}function En(t){return t*t*t}function Ln(t){if(0>=t)return 0;if(t>=1)return 1;var e=t*t,r=e*t;return 4*(.5>t?r:3*(t-e)+r-.75)}function Sn(t){return function(e){return Math.pow(e,t)}}function Cn(t){return 1-Math.cos(t*Ho)}function zn(t){return Math.pow(2,10*(t-1))}function Pn(t){return 1-Math.sqrt(1-t*t)}function Rn(t,e){var r;return arguments.length<2&&(e=.45),arguments.length?r=e/Vo*Math.asin(1/t):(t=1,r=e/4),function(n){return 1+t*Math.pow(2,-10*n)*Math.sin((n-r)*Vo/e)}}function On(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function In(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Nn(t,e){t=co.hcl(t),e=co.hcl(e);var r=t.h,n=t.c,i=t.l,a=e.h-r,o=e.c-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.c:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ht(r+a*t,n+o*t,i+s*t)+""}}function jn(t,e){t=co.hsl(t),e=co.hsl(e);var r=t.h,n=t.s,i=t.l,a=e.h-r,o=e.s-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.s:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ut(r+a*t,n+o*t,i+s*t)+""}}function Fn(t,e){t=co.lab(t),e=co.lab(e);var r=t.l,n=t.a,i=t.b,a=e.l-r,o=e.a-n,s=e.b-i;return function(t){return pt(r+a*t,n+o*t,i+s*t)+""}}function Dn(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function Bn(t){var e=[t.a,t.b],r=[t.c,t.d],n=Vn(e),i=Un(e,r),a=Vn(qn(r,e,-i))||0;e[0]*r[1]180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(Hn(r)+"rotate(",null,")")-2,x:bn(t,e)})):e&&r.push(Hn(r)+"rotate("+e+")")}function Xn(t,e,r,n){t!==e?n.push({i:r.push(Hn(r)+"skewX(",null,")")-2,x:bn(t,e)}):e&&r.push(Hn(r)+"skewX("+e+")")}function Wn(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(Hn(r)+"scale(",null,",",null,")");n.push({i:i-4,x:bn(t[0],e[0])},{i:i-2,x:bn(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(Hn(r)+"scale("+e+")")}function Zn(t,e){var r=[],n=[];return t=co.transform(t),e=co.transform(e),Gn(t.translate,e.translate,r,n),Yn(t.rotate,e.rotate,r,n),Xn(t.skew,e.skew,r,n),Wn(t.scale,e.scale,r,n),t=e=null,function(t){for(var e,i=-1,a=n.length;++i=0;)r.push(i[n])}function li(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++or;++r)(e=t[r][1])>i&&(n=r,i=e);return n}function bi(t){return t.reduce(xi,0)}function xi(t,e){return t+e[1]}function _i(t,e){return wi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wi(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function ki(t){return[co.min(t),co.max(t)]}function Ai(t,e){return t.value-e.value}function Mi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ti(t,e){t._pack_next=e,e._pack_prev=t}function Ei(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function Li(t){function e(t){u=Math.min(t.x-t.r,u),f=Math.max(t.x+t.r,f),h=Math.min(t.y-t.r,h),d=Math.max(t.y+t.r,d)}if((r=t.children)&&(c=r.length)){var r,n,i,a,o,s,l,c,u=1/0,f=-(1/0),h=1/0,d=-(1/0);if(r.forEach(Si),n=r[0],n.x=-n.r,n.y=0,e(n),c>1&&(i=r[1],i.x=i.r,i.y=0,e(i),c>2))for(a=r[2],Pi(n,i,a),e(a),Mi(n,a),n._pack_prev=a,Mi(a,i),i=n._pack_next,o=3;c>o;o++){Pi(n,i,a=r[o]);var p=0,g=1,v=1;for(s=i._pack_next;s!==i;s=s._pack_next,g++)if(Ei(s,a)){p=1;break}if(1==p)for(l=n._pack_prev;l!==s._pack_prev&&!Ei(l,a);l=l._pack_prev,v++);p?(v>g||g==v&&i.ro;o++)a=r[o],a.x-=m,a.y-=y,b=Math.max(b,a.r+Math.sqrt(a.x*a.x+a.y*a.y));t.r=b,r.forEach(Ci)}}function Si(t){t._pack_next=t._pack_prev=t}function Ci(t){delete t._pack_next,delete t._pack_prev}function zi(t,e,r,n){var i=t.children;if(t.x=e+=n*t.x,t.y=r+=n*t.y,t.r*=n,i)for(var a=-1,o=i.length;++a=0;)e=i[a],e.z+=r,e.m+=r,r+=e.s+(n+=e.c)}function Fi(t,e,r){return t.a.parent===e.parent?t.a:r}function Di(t){return 1+co.max(t,function(t){return t.y})}function Bi(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ui(t){var e=t.children;return e&&e.length?Ui(e[0]):t}function Vi(t){var e,r=t.children;return r&&(e=r.length)?Vi(r[e-1]):t}function qi(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Hi(t,e){var r=t.x+e[3],n=t.y+e[0],i=t.dx-e[1]-e[3],a=t.dy-e[0]-e[2];return 0>i&&(r+=i/2,i=0),0>a&&(n+=a/2,a=0),{x:r,y:n,dx:i,dy:a}}function Gi(t){var e=t[0],r=t[t.length-1];return r>e?[e,r]:[r,e]}function Yi(t){return t.rangeExtent?t.rangeExtent():Gi(t.range())}function Xi(t,e,r,n){var i=r(t[0],t[1]),a=n(e[0],e[1]);return function(t){return a(i(t))}}function Wi(t,e){var r,n=0,i=t.length-1,a=t[n],o=t[i];return a>o&&(r=n,n=i,i=r,r=a,a=o,o=r),t[n]=e.floor(a),t[i]=e.ceil(o),t}function Zi(t){return t?{floor:function(e){return Math.floor(e/t)*t},ceil:function(e){return Math.ceil(e/t)*t}}:Tl}function Ki(t,e,r,n){var i=[],a=[],o=0,s=Math.min(t.length,e.length)-1;for(t[s]2?Ki:Xi,l=n?$n:Kn;return o=i(t,e,l,r),s=i(e,t,l,_n),a}function a(t){return o(t)}var o,s;return a.invert=function(t){return s(t)},a.domain=function(e){return arguments.length?(t=e.map(Number),i()):t},a.range=function(t){return arguments.length?(e=t,i()):e},a.rangeRound=function(t){return a.range(t).interpolate(Dn)},a.clamp=function(t){return arguments.length?(n=t,i()):n},a.interpolate=function(t){return arguments.length?(r=t,i()):r},a.ticks=function(e){return ea(t,e)},a.tickFormat=function(e,r){return ra(t,e,r)},a.nice=function(e){return Ji(t,e),i()},a.copy=function(){return $i(t,e,r,n)},i()}function Qi(t,e){return co.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ji(t,e){return Wi(t,Zi(ta(t,e)[2])),Wi(t,Zi(ta(t,e)[2])),t}function ta(t,e){null==e&&(e=10);var r=Gi(t),n=r[1]-r[0],i=Math.pow(10,Math.floor(Math.log(n/e)/Math.LN10)),a=e/n*i;return.15>=a?i*=10:.35>=a?i*=5:.75>=a&&(i*=2),r[0]=Math.ceil(r[0]/i)*i,r[1]=Math.floor(r[1]/i)*i+.5*i,r[2]=i,r}function ea(t,e){return co.range.apply(co,ta(t,e))}function ra(t,e,r){var n=ta(t,e);if(r){var i=ps.exec(r);if(i.shift(),"s"===i[8]){var a=co.formatPrefix(Math.max(wo(n[0]),wo(n[1])));return i[7]||(i[7]="."+na(a.scale(n[2]))),i[8]="f",r=co.format(i.join("")),function(t){return r(a.scale(t))+a.symbol}}i[7]||(i[7]="."+ia(i[8],n)),r=i.join("")}else r=",."+na(n[2])+"f";return co.format(r)}function na(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ia(t,e){var r=na(e[2]);return t in El?Math.abs(r-na(Math.max(wo(e[0]),wo(e[1]))))+ +("e"!==t):r-2*("%"===t)}function aa(t,e,r,n){function i(t){return(r?Math.log(0>t?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function a(t){return r?Math.pow(e,t):-Math.pow(e,-t)}function o(e){return t(i(e))}return o.invert=function(e){return a(t.invert(e))},o.domain=function(e){return arguments.length?(r=e[0]>=0,t.domain((n=e.map(Number)).map(i)),o):n},o.base=function(r){return arguments.length?(e=+r,t.domain(n.map(i)),o):e},o.nice=function(){var e=Wi(n.map(i),r?Math:Sl);return t.domain(e),n=e.map(a),o},o.ticks=function(){var t=Gi(n),o=[],s=t[0],l=t[1],c=Math.floor(i(s)),u=Math.ceil(i(l)),f=e%1?2:e;if(isFinite(u-c)){if(r){for(;u>c;c++)for(var h=1;f>h;h++)o.push(a(c)*h);o.push(a(c))}else for(o.push(a(c));c++0;h--)o.push(a(c)*h);for(c=0;o[c]l;u--);o=o.slice(c,u)}return o},o.tickFormat=function(t,r){if(!arguments.length)return Ll;arguments.length<2?r=Ll:"function"!=typeof r&&(r=co.format(r));var n=Math.max(1,e*t/o.ticks().length);return function(t){var o=t/a(Math.round(i(t)));return e-.5>o*e&&(o*=e),n>=o?r(t):""}},o.copy=function(){return aa(t.copy(),e,r,n)},Qi(o,t)}function oa(t,e,r){function n(e){return t(i(e))}var i=sa(e),a=sa(1/e);return n.invert=function(e){return a(t.invert(e))},n.domain=function(e){return arguments.length?(t.domain((r=e.map(Number)).map(i)),n):r},n.ticks=function(t){return ea(r,t)},n.tickFormat=function(t,e){return ra(r,t,e)},n.nice=function(t){return n.domain(Ji(r,t))},n.exponent=function(o){return arguments.length?(i=sa(e=o),a=sa(1/e),t.domain(r.map(i)),n):e},n.copy=function(){return oa(t.copy(),e,r)},Qi(n,t)}function sa(t){return function(e){return 0>e?-Math.pow(-e,t):Math.pow(e,t)}}function la(t,e){function r(r){return a[((i.get(r)||("range"===e.t?i.set(r,t.push(r)):NaN))-1)%a.length]}function n(e,r){return co.range(t.length).map(function(t){return e+r*t})}var i,a,o;return r.domain=function(n){if(!arguments.length)return t;t=[],i=new f;for(var a,o=-1,s=n.length;++or?[NaN,NaN]:[r>0?s[r-1]:t[0],re?NaN:e/a+t,[e,e+1/a]},n.copy=function(){return ua(t,e,r)},i()}function fa(t,e){function r(r){return r>=r?e[co.bisect(t,r)]:void 0}return r.domain=function(e){return arguments.length?(t=e,r):t},r.range=function(t){return arguments.length?(e=t,r):e},r.invertExtent=function(r){return r=e.indexOf(r),[t[r-1],t[r]]},r.copy=function(){return fa(t,e)},r}function ha(t){function e(t){return+t}return e.invert=e,e.domain=e.range=function(r){return arguments.length?(t=r.map(e),e):t},e.ticks=function(e){return ea(t,e)},e.tickFormat=function(e,r){return ra(t,e,r)},e.copy=function(){return ha(t)},e}function da(){return 0}function pa(t){return t.innerRadius}function ga(t){return t.outerRadius}function va(t){return t.startAngle}function ma(t){return t.endAngle}function ya(t){return t&&t.padAngle}function ba(t,e,r,n){return(t-r)*e-(e-n)*t>0?0:1}function xa(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,c=-s*a,u=t[0]+l,f=t[1]+c,h=e[0]+l,d=e[1]+c,p=(u+h)/2,g=(f+d)/2,v=h-u,m=d-f,y=v*v+m*m,b=r-n,x=u*d-h*f,_=(0>m?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*m-v*_)/y,k=(-x*v-m*_)/y,A=(x*m+v*_)/y,M=(-x*v+m*_)/y,T=w-p,E=k-g,L=A-p,S=M-g;return T*T+E*E>L*L+S*S&&(w=A,k=M),[[w-l,k-c],[w*r/b,k*r/b]]}function _a(t){function e(e){function o(){c.push("M",a(t(u),s))}for(var l,c=[],u=[],f=-1,h=e.length,d=Lt(r),p=Lt(n);++f1?t.join("L"):t+"Z"}function ka(t){return t.join("L")+"Z"}function Aa(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1&&i.push("H",n[0]),i.join("")}function Ma(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var c=2;c9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));for(s=-1;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}function Ua(t){return t.length<3?wa(t):t[0]+Ca(t,Ba(t))}function Va(t){for(var e,r,n,i=-1,a=t.length;++i=e?o(t-e):void(c.c=o)}function o(r){var i=p.active,a=p[i];a&&(a.timer.c=null,a.timer.t=NaN,--p.count,delete p[i],a.event&&a.event.interrupt.call(t,t.__data__,a.index));for(var o in p)if(n>+o){var f=p[o];f.timer.c=null,f.timer.t=NaN,--p.count,delete p[o]}c.c=s,Rt(function(){return c.c&&s(r||1)&&(c.c=null,c.t=NaN),1},0,l),p.active=n,g.event&&g.event.start.call(t,t.__data__,e),d=[],g.tween.forEach(function(r,n){(n=n.call(t,t.__data__,e))&&d.push(n)}),h=g.ease,u=g.duration}function s(i){for(var a=i/u,o=h(a),s=d.length;s>0;)d[--s].call(t,o);return a>=1?(g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[n]:delete t[r],1):void 0}var l,c,u,h,d,p=t[r]||(t[r]={active:0,count:0}),g=p[n];g||(l=i.time,c=Rt(a,0,l),g=p[n]={tween:new f,time:l,timer:c,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++p.count)}function ro(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate("+(isFinite(n)?n:r(t))+",0)"})}function no(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate(0,"+(isFinite(n)?n:r(t))+")"})}function io(t){return t.toISOString()}function ao(t,e,r){function n(e){return t(e)}function i(t,r){var n=t[1]-t[0],i=n/r,a=co.bisect(tc,i);return a==tc.length?[e.year,ta(t.map(function(t){return t/31536e6}),r)[2]]:a?e[i/tc[a-1]1?{floor:function(e){for(;r(e=t.floor(e));)e=oo(e-1);return e},ceil:function(e){for(;r(e=t.ceil(e));)e=oo(+e+1);return e}}:t))},n.ticks=function(t,e){var r=Gi(n.domain()),a=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return a&&(t=a[0],e=a[1]),t.range(r[0],oo(+r[1]+1),1>e?1:e)},n.tickFormat=function(){return r},n.copy=function(){return ao(t.copy(),e,r)},Qi(n,t)}function oo(t){return new Date(t)}function so(t){return JSON.parse(t.responseText)}function lo(t){var e=ho.createRange();return e.selectNode(ho.body),e.createContextualFragment(t.responseText)}var co={version:"3.5.16"},uo=[].slice,fo=function(t){return uo.call(t)},ho=this.document;if(ho)try{fo(ho.documentElement.childNodes)[0].nodeType}catch(po){fo=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),ho)try{ho.createElement("DIV").style.setProperty("opacity",0,"")}catch(go){var vo=this.Element.prototype,mo=vo.setAttribute,yo=vo.setAttributeNS,bo=this.CSSStyleDeclaration.prototype,xo=bo.setProperty;vo.setAttribute=function(t,e){mo.call(this,t,e+"")},vo.setAttributeNS=function(t,e,r){yo.call(this,t,e,r+"")},bo.setProperty=function(t,e,r){xo.call(this,t,e+"",r)}}co.ascending=i,co.descending=function(t,e){return t>e?-1:e>t?1:e>=t?0:NaN},co.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},co.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},co.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}else{for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}return[r,i]},co.sum=function(t,e){var r,n=0,i=t.length,a=-1;if(1===arguments.length)for(;++a1?l/(u-1):void 0},co.deviation=function(){var t=co.variance.apply(this,arguments);return t?Math.sqrt(t):t};var _o=s(i);co.bisectLeft=_o.left,co.bisect=co.bisectRight=_o.right,co.bisector=function(t){return s(1===t.length?function(e,r){return i(t(e),r)}:t)},co.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,2>a&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},co.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},co.pairs=function(t){for(var e,r=0,n=t.length-1,i=t[0],a=new Array(0>n?0:n);n>r;)a[r]=[e=i,i=t[++r]];return a},co.transpose=function(t){if(!(i=t.length))return[];for(var e=-1,r=co.min(t,l),n=new Array(r);++e=0;)for(n=t[i],e=n.length;--e>=0;)r[--o]=n[e];return r};var wo=Math.abs;co.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r===1/0)throw new Error("infinite range");var n,i=[],a=c(wo(r)),o=-1;if(t*=a,e*=a,r*=a,0>r)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=a.length)return n?n.call(i,o):r?o.sort(r):o;for(var l,c,u,h,d=-1,p=o.length,g=a[s++],v=new f;++d=a.length)return t;var n=[],i=o[r++];return t.forEach(function(t,i){n.push({key:t,values:e(i,r)})}),i?n.sort(function(t,e){return i(t.key,e.key)}):n}var r,n,i={},a=[],o=[];return i.map=function(e,r){return t(r,e,0)},i.entries=function(r){return e(t(co.map,r,0),0)},i.key=function(t){return a.push(t),i},i.sortKeys=function(t){return o[a.length-1]=t,i},i.sortValues=function(t){return r=t,i},i.rollup=function(t){return n=t,i},i},co.set=function(t){var e=new b;if(t)for(var r=0,n=t.length;n>r;++r)e.add(t[r]);return e},u(b,{has:p,add:function(t){return this._[h(t+="")]=!0,t},remove:g,values:v,size:m,empty:y,forEach:function(t){for(var e in this._)t.call(this,d(e))}}),co.behavior={},co.rebind=function(t,e){for(var r,n=1,i=arguments.length;++n=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},co.event=null,co.requote=function(t){return t.replace(To,"\\$&")};var To=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Eo={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]},Lo=function(t,e){return e.querySelector(t)},So=function(t,e){return e.querySelectorAll(t)},Co=function(t,e){var r=t.matches||t[w(t,"matchesSelector")];return(Co=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(Lo=function(t,e){return Sizzle(t,e)[0]||null},So=Sizzle,Co=Sizzle.matchesSelector),co.selection=function(){return co.select(ho.documentElement)};var zo=co.selection.prototype=[];zo.select=function(t){var e,r,n,i,a=[];t=C(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Ro.hasOwnProperty(r)?{space:Ro[r],local:t}:t}},zo.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node();return t=co.ns.qualify(t),t.local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}for(e in t)this.each(P(e,t[e]));return this}return this.each(P(t,e))},zo.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=I(t)).length,i=-1;if(e=r.classList){for(;++ii){if("string"!=typeof t){2>i&&(e="");for(r in t)this.each(F(r,t[r],e));return this}if(2>i){var a=this.node();return n(a).getComputedStyle(a,null).getPropertyValue(t)}r=""}return this.each(F(t,e,r))},zo.property=function(t,e){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(e in t)this.each(D(e,t[e]));return this}return this.each(D(t,e))},zo.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},zo.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},zo.append=function(t){return t=B(t),this.select(function(){return this.appendChild(t.apply(this,arguments))})},zo.insert=function(t,e){return t=B(t),e=C(e),this.select(function(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)})},zo.remove=function(){return this.each(U)},zo.data=function(t,e){function r(t,r){var n,i,a,o=t.length,u=r.length,h=Math.min(o,u),d=new Array(u),p=new Array(u),g=new Array(o);if(e){var v,m=new f,y=new Array(o);for(n=-1;++nn;++n)p[n]=V(r[n]);for(;o>n;++n)g[n]=t[n]}p.update=d,p.parentNode=d.parentNode=g.parentNode=t.parentNode,s.push(p),l.push(d),c.push(g)}var n,i,a=-1,o=this.length;if(!arguments.length){for(t=new Array(o=(n=this[0]).length);++aa;a++){i.push(e=[]),e.parentNode=(r=this[a]).parentNode;for(var s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return S(i)},zo.order=function(){for(var t=-1,e=this.length;++t=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},zo.sort=function(t){t=H.apply(this,arguments);for(var e=-1,r=this.length;++et;t++)for(var r=this[t],n=0,i=r.length;i>n;n++){var a=r[n];if(a)return a}return null},zo.size=function(){var t=0;return G(this,function(){++t}),t};var Oo=[];co.selection.enter=Y,co.selection.enter.prototype=Oo,Oo.append=zo.append,Oo.empty=zo.empty,Oo.node=zo.node,Oo.call=zo.call,Oo.size=zo.size,Oo.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++sn){if("string"!=typeof t){2>n&&(e=!1);for(r in t)this.each(W(r,t[r],e));return this}if(2>n)return(n=this.node()["__on"+t])&&n._;r=!1}return this.each(W(t,e,r))};var Io=co.map({mouseenter:"mouseover",mouseleave:"mouseout"});ho&&Io.forEach(function(t){"on"+t in ho&&Io.remove(t)});var No,jo=0;co.mouse=function(t){return Q(t,E())};var Fo=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;co.touch=function(t,e,r){if(arguments.length<3&&(r=e,e=E().changedTouches),e)for(var n,i=0,a=e.length;a>i;++i)if((n=e[i]).identifier===r)return Q(t,n)},co.behavior.drag=function(){function t(){this.on("mousedown.drag",a).on("touchstart.drag",o)}function e(t,e,n,a,o){return function(){function s(){var t,r,n=e(h,g);n&&(t=n[0]-b[0],r=n[1]-b[1],p|=t|r,b=n,d({type:"drag",x:n[0]+c[0],y:n[1]+c[1],dx:t,dy:r}))}function l(){e(h,g)&&(m.on(a+v,null).on(o+v,null),y(p),d({type:"dragend"}))}var c,u=this,f=co.event.target.correspondingElement||co.event.target,h=u.parentNode,d=r.of(u,arguments),p=0,g=t(),v=".drag"+(null==g?"":"-"+g),m=co.select(n(f)).on(a+v,s).on(o+v,l),y=$(f),b=e(h,g);i?(c=i.apply(u,arguments),c=[c.x-b[0],c.y-b[1]]):c=[0,0],d({type:"dragstart"})}}var r=L(t,"drag","dragstart","dragend"),i=null,a=e(k,co.mouse,n,"mousemove","mouseup"),o=e(J,co.touch,x,"touchmove","touchend");return t.origin=function(e){return arguments.length?(i=e,t):i},co.rebind(t,r,"on")},co.touches=function(t,e){return arguments.length<2&&(e=E().touches),e?fo(e).map(function(e){var r=Q(t,e);return r.identifier=e.identifier,r}):[]};var Do=1e-6,Bo=Do*Do,Uo=Math.PI,Vo=2*Uo,qo=Vo-Do,Ho=Uo/2,Go=Uo/180,Yo=180/Uo,Xo=Math.SQRT2,Wo=2,Zo=4;co.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],c=e[2],u=s-i,f=l-a,h=u*u+f*f;if(Bo>h)n=Math.log(c/o)/Xo,r=function(t){return[i+t*u,a+t*f,o*Math.exp(Xo*t*n)]};else{var d=Math.sqrt(h),p=(c*c-o*o+Zo*h)/(2*o*Wo*d),g=(c*c-o*o-Zo*h)/(2*c*Wo*d),v=Math.log(Math.sqrt(p*p+1)-p),m=Math.log(Math.sqrt(g*g+1)-g);n=(m-v)/Xo,r=function(t){var e=t*n,r=at(v),s=o/(Wo*d)*(r*ot(Xo*e+v)-it(v));return[i+s*u,a+s*f,o*r/at(Xo*e+v)]}}return r.duration=1e3*n,r},co.behavior.zoom=function(){function t(t){t.on(z,f).on($o+".zoom",d).on("dblclick.zoom",p).on(O,h)}function e(t){return[(t[0]-A.x)/A.k,(t[1]-A.y)/A.k]}function r(t){return[t[0]*A.k+A.x,t[1]*A.k+A.y]}function i(t){A.k=Math.max(E[0],Math.min(E[1],t))}function a(t,e){e=r(e),A.x+=t[0]-e[0],A.y+=t[1]-e[1]}function o(e,r,n,o){e.__chart__={x:A.x,y:A.y,k:A.k},i(Math.pow(2,o)),a(v=r,n),e=co.select(e),S>0&&(e=e.transition().duration(S)),e.call(t.event)}function s(){_&&_.domain(x.range().map(function(t){return(t-A.x)/A.k}).map(x.invert)),k&&k.domain(w.range().map(function(t){return(t-A.y)/A.k}).map(w.invert))}function l(t){C++||t({type:"zoomstart"})}function c(t){s(),t({type:"zoom",scale:A.k,translate:[A.x,A.y]})}function u(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){s=1,a(co.mouse(i),h),c(o)}function r(){f.on(P,null).on(R,null),d(s),u(o)}var i=this,o=I.of(i,arguments),s=0,f=co.select(n(i)).on(P,t).on(R,r),h=e(co.mouse(i)),d=$(i);Hl.call(i),l(o)}function h(){function t(){var t=co.touches(p);return d=A.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function r(){var e=co.event.target;co.select(e).on(x,n).on(_,s),w.push(e);for(var r=co.event.changedTouches,i=0,a=r.length;a>i;++i)v[r[i].identifier]=null;var l=t(),c=Date.now();if(1===l.length){if(500>c-b){var u=l[0];o(p,u,v[u.identifier],Math.floor(Math.log(A.k)/Math.LN2)+1),T()}b=c}else if(l.length>1){var u=l[0],f=l[1],h=u[0]-f[0],d=u[1]-f[1];m=h*h+d*d}}function n(){var t,e,r,n,o=co.touches(p);Hl.call(p);for(var s=0,l=o.length;l>s;++s,n=null)if(r=o[s],n=v[r.identifier]){if(e)break;t=r,e=n}if(n){var u=(u=r[0]-t[0])*u+(u=r[1]-t[1])*u,f=m&&Math.sqrt(u/m);t=[(t[0]+r[0])/2,(t[1]+r[1])/2],e=[(e[0]+n[0])/2,(e[1]+n[1])/2],i(f*d)}b=null,a(t,e),c(g)}function s(){if(co.event.touches.length){for(var e=co.event.changedTouches,r=0,n=e.length;n>r;++r)delete v[e[r].identifier];for(var i in v)return void t()}co.selectAll(w).on(y,null),k.on(z,f).on(O,h),M(),u(g)}var d,p=this,g=I.of(p,arguments),v={},m=0,y=".zoom-"+co.event.changedTouches[0].identifier,x="touchmove"+y,_="touchend"+y,w=[],k=co.select(p),M=$(p);r(),l(g),k.on(z,null).on(O,r)}function d(){var t=I.of(this,arguments);y?clearTimeout(y):(Hl.call(this),g=e(v=m||co.mouse(this)),l(t)),y=setTimeout(function(){y=null,u(t)},50),T(),i(Math.pow(2,.002*Ko())*A.k),a(v,g),c(t)}function p(){var t=co.mouse(this),r=Math.log(A.k)/Math.LN2;o(this,t,e(t),co.event.shiftKey?Math.ceil(r)-1:Math.floor(r)+1)}var g,v,m,y,b,x,_,w,k,A={x:0,y:0,k:1},M=[960,500],E=Qo,S=250,C=0,z="mousedown.zoom",P="mousemove.zoom",R="mouseup.zoom",O="touchstart.zoom",I=L(t,"zoomstart","zoom","zoomend");return $o||($o="onwheel"in ho?(Ko=function(){return-co.event.deltaY*(co.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ho?(Ko=function(){return co.event.wheelDelta},"mousewheel"):(Ko=function(){return-co.event.detail},"MozMousePixelScroll")),t.event=function(t){t.each(function(){var t=I.of(this,arguments),e=A;Vl?co.select(this).transition().each("start.zoom",function(){A=this.__chart__||{x:0,y:0,k:1},l(t)}).tween("zoom:zoom",function(){var r=M[0],n=M[1],i=v?v[0]:r/2,a=v?v[1]:n/2,o=co.interpolateZoom([(i-A.x)/A.k,(a-A.y)/A.k,r/A.k],[(i-e.x)/e.k,(a-e.y)/e.k,r/e.k]);return function(e){var n=o(e),s=r/n[2];this.__chart__=A={x:i-n[0]*s,y:a-n[1]*s,k:s},c(t)}}).each("interrupt.zoom",function(){u(t)}).each("end.zoom",function(){u(t)}):(this.__chart__=A,l(t),c(t),u(t))})},t.translate=function(e){return arguments.length?(A={x:+e[0],y:+e[1],k:A.k},s(),t):[A.x,A.y]},t.scale=function(e){return arguments.length?(A={x:A.x,y:A.y,k:null},i(+e),s(),t):A.k},t.scaleExtent=function(e){return arguments.length?(E=null==e?Qo:[+e[0],+e[1]],t):E},t.center=function(e){return arguments.length?(m=e&&[+e[0],+e[1]],t):m},t.size=function(e){return arguments.length?(M=e&&[+e[0],+e[1]],t):M},t.duration=function(e){return arguments.length?(S=+e,t):S},t.x=function(e){return arguments.length?(_=e,x=e.copy(),A={x:0,y:0,k:1},t):_},t.y=function(e){return arguments.length?(k=e,w=e.copy(),A={x:0,y:0,k:1},t):k},co.rebind(t,I,"on")};var Ko,$o,Qo=[0,1/0];co.color=lt,lt.prototype.toString=function(){return this.rgb()+""},co.hsl=ct;var Jo=ct.prototype=new lt;Jo.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,this.l/t)},Jo.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,t*this.l)},Jo.rgb=function(){return ut(this.h,this.s,this.l)},co.hcl=ft;var ts=ft.prototype=new lt;ts.brighter=function(t){return new ft(this.h,this.c,Math.min(100,this.l+es*(arguments.length?t:1)))},ts.darker=function(t){return new ft(this.h,this.c,Math.max(0,this.l-es*(arguments.length?t:1)))},ts.rgb=function(){return ht(this.h,this.c,this.l).rgb()},co.lab=dt;var es=18,rs=.95047,ns=1,is=1.08883,as=dt.prototype=new lt;as.brighter=function(t){return new dt(Math.min(100,this.l+es*(arguments.length?t:1)),this.a,this.b)},as.darker=function(t){return new dt(Math.max(0,this.l-es*(arguments.length?t:1)),this.a,this.b)},as.rgb=function(){return pt(this.l,this.a,this.b)},co.rgb=bt;var os=bt.prototype=new lt;os.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&i>e&&(e=i),r&&i>r&&(r=i),n&&i>n&&(n=i),new bt(Math.min(255,e/t),Math.min(255,r/t),Math.min(255,n/t))):new bt(i,i,i)},os.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new bt(t*this.r,t*this.g,t*this.b)},os.hsl=function(){return At(this.r,this.g,this.b)},os.toString=function(){return"#"+wt(this.r)+wt(this.g)+wt(this.b)};var ss=co.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ss.forEach(function(t,e){ss.set(t,xt(e))}),co.functor=Lt,co.xhr=St(x),co.dsv=function(t,e){function r(t,r,a){arguments.length<3&&(a=r,r=null);var o=Ct(t,e,null==r?n:i(r),a);return o.row=function(t){return arguments.length?o.response(null==(r=t)?n:i(t)):r},o}function n(t){return r.parse(t.responseText)}function i(t){return function(e){return r.parse(e.responseText,t)}}function a(e){return e.map(o).join(t)}function o(t){return s.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var s=new RegExp('["'+t+"\n]"),l=t.charCodeAt(0);return r.parse=function(t,e){var n;return r.parseRows(t,function(t,r){if(n)return n(t,r-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");n=e?function(t,r){return e(i(t),r)}:i})},r.parseRows=function(t,e){function r(){if(u>=c)return o;if(i)return i=!1,a;var e=u;if(34===t.charCodeAt(e)){for(var r=e;r++u;){var n=t.charCodeAt(u++),s=1;if(10===n)i=!0;else if(13===n)i=!0,10===t.charCodeAt(u)&&(++u,++s);else if(n!==l)continue;return t.slice(e,u-s)}return t.slice(e)}for(var n,i,a={},o={},s=[],c=t.length,u=0,f=0;(n=r())!==o;){for(var h=[];n!==a&&n!==o;)h.push(n),n=r();e&&null==(h=e(h,f++))||s.push(h)}return s},r.format=function(e){if(Array.isArray(e[0]))return r.formatRows(e);var n=new b,i=[];return e.forEach(function(t){for(var e in t)n.has(e)||i.push(n.add(e))}),[i.map(o).join(t)].concat(e.map(function(e){return i.map(function(t){return o(e[t])}).join(t)})).join("\n")},r.formatRows=function(t){return t.map(a).join("\n")},r},co.csv=co.dsv(",","text/csv"),co.tsv=co.dsv(" ","text/tab-separated-values");var ls,cs,us,fs,hs=this[w(this,"requestAnimationFrame")]||function(t){setTimeout(t,17)};co.timer=function(){Rt.apply(this,arguments)},co.timer.flush=function(){It(),Nt()},co.round=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)};var ds=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Ft);co.formatPrefix=function(t,e){var r=0;return(t=+t)&&(0>t&&(t*=-1),e&&(t=co.round(t,jt(t,e))),r=1+Math.floor(1e-12+Math.log(t)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),ds[8+r/3]};var ps=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,gs=co.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=co.round(t,jt(t,e))).toFixed(Math.max(0,Math.min(20,jt(t*(1+1e-15),e))))}}),vs=co.time={},ms=Date;Ut.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ys.setUTCDate.apply(this._,arguments)},setDay:function(){ys.setUTCDay.apply(this._,arguments)},setFullYear:function(){ys.setUTCFullYear.apply(this._,arguments)},setHours:function(){ys.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ys.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ys.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ys.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ys.setUTCSeconds.apply(this._,arguments)},setTime:function(){ys.setTime.apply(this._,arguments)}};var ys=Date.prototype;vs.year=Vt(function(t){return t=vs.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),vs.years=vs.year.range,vs.years.utc=vs.year.utc.range,vs.day=Vt(function(t){var e=new ms(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),vs.days=vs.day.range,vs.days.utc=vs.day.utc.range,vs.dayOfYear=function(t){var e=vs.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var r=vs[t]=Vt(function(t){return(t=vs.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){ -t.setDate(t.getDate()+7*Math.floor(e))},function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)-(r!==e)});vs[t+"s"]=r.range,vs[t+"s"].utc=r.utc.range,vs[t+"OfYear"]=function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)}}),vs.week=vs.sunday,vs.weeks=vs.sunday.range,vs.weeks.utc=vs.sunday.utc.range,vs.weekOfYear=vs.sundayOfYear;var bs={"-":"",_:" ",0:"0"},xs=/^\s*\d+/,_s=/^%/;co.locale=function(t){return{numberFormat:Dt(t),timeFormat:Ht(t)}};var ws=co.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});co.format=ws.numberFormat,co.geo={},fe.prototype={s:0,t:0,add:function(t){he(t,this.t,ks),he(ks.s,this.s,this),this.s?this.t+=ks.t:this.s=ks.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ks=new fe;co.geo.stream=function(t,e){t&&As.hasOwnProperty(t.type)?As[t.type](t,e):de(t,e)};var As={Feature:function(t,e){de(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++nt?4*Uo+t:t,Ls.lineStart=Ls.lineEnd=Ls.point=k}};co.geo.bounds=function(){function t(t,e){b.push(x=[u=t,h=t]),f>e&&(f=e),e>d&&(d=e)}function e(e,r){var n=me([e*Go,r*Go]);if(m){var i=be(m,n),a=[i[1],-i[0],0],o=be(a,i);we(o),o=ke(o);var l=e-p,c=l>0?1:-1,g=o[0]*Yo*c,v=wo(l)>180;if(v^(g>c*p&&c*e>g)){var y=o[1]*Yo;y>d&&(d=y)}else if(g=(g+360)%360-180,v^(g>c*p&&c*e>g)){var y=-o[1]*Yo;f>y&&(f=y)}else f>r&&(f=r),r>d&&(d=r);v?p>e?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e):h>=u?(u>e&&(u=e),e>h&&(h=e)):e>p?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e)}else t(e,r);m=n,p=e}function r(){_.point=e}function n(){x[0]=u,x[1]=h,_.point=t,m=null}function i(t,r){if(m){var n=t-p;y+=wo(n)>180?n+(n>0?360:-360):n}else g=t,v=r;Ls.point(t,r),e(t,r)}function a(){Ls.lineStart()}function o(){i(g,v),Ls.lineEnd(),wo(y)>Do&&(u=-(h=180)),x[0]=u,x[1]=h,m=null}function s(t,e){return(e-=t)<0?e+360:e}function l(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tEs?(u=-(h=180),f=-(d=90)):y>Do?d=90:-Do>y&&(f=-90),x[0]=u,x[1]=h}};return function(t){d=h=-(u=f=1/0),b=[],co.geo.stream(t,_);var e=b.length;if(e){b.sort(l);for(var r,n=1,i=b[0],a=[i];e>n;++n)r=b[n],c(r[0],i)||c(r[1],i)?(s(i[0],r[1])>s(i[0],i[1])&&(i[1]=r[1]),s(r[0],i[1])>s(i[0],i[1])&&(i[0]=r[0])):a.push(i=r);for(var o,r,p=-(1/0),e=a.length-1,n=0,i=a[e];e>=n;i=r,++n)r=a[n],(o=s(i[1],r[0]))>p&&(p=o,u=r[0],h=i[1])}return b=x=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[h,d]]}}(),co.geo.centroid=function(t){Ss=Cs=zs=Ps=Rs=Os=Is=Ns=js=Fs=Ds=0,co.geo.stream(t,Bs);var e=js,r=Fs,n=Ds,i=e*e+r*r+n*n;return Bo>i&&(e=Os,r=Is,n=Ns,Do>Cs&&(e=zs,r=Ps,n=Rs),i=e*e+r*r+n*n,Bo>i)?[NaN,NaN]:[Math.atan2(r,e)*Yo,nt(n/Math.sqrt(i))*Yo]};var Ss,Cs,zs,Ps,Rs,Os,Is,Ns,js,Fs,Ds,Bs={sphere:k,point:Me,lineStart:Ee,lineEnd:Le,polygonStart:function(){Bs.lineStart=Se},polygonEnd:function(){Bs.lineStart=Ee}},Us=Ie(ze,De,Ue,[-Uo,-Uo/2]),Vs=1e9;co.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),i=a(t),i.valid=!0,i},extent:function(s){return arguments.length?(a=Ge(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(co.geo.conicEqualArea=function(){return Ye(Xe)}).raw=Xe,co.geo.albers=function(){return co.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},co.geo.albersUsa=function(){function t(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}var e,r,n,i,a=co.geo.albers(),o=co.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=co.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};return t.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&.234>i&&n>=-.425&&-.214>n?o:i>=.166&&.234>i&&n>=-.214&&-.115>n?s:a).invert(t)},t.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},t.precision=function(e){return arguments.length?(a.precision(e),o.precision(e),s.precision(e),t):a.precision()},t.scale=function(e){return arguments.length?(a.scale(e),o.scale(.35*e),s.scale(e),t.translate(a.translate())):a.scale()},t.translate=function(e){if(!arguments.length)return a.translate();var c=a.scale(),u=+e[0],f=+e[1];return r=a.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(l).point,n=o.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+Do,f+.12*c+Do],[u-.214*c-Do,f+.234*c-Do]]).stream(l).point,i=s.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+Do,f+.166*c+Do],[u-.115*c-Do,f+.234*c-Do]]).stream(l).point,t},t.scale(1070)};var qs,Hs,Gs,Ys,Xs,Ws,Zs={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Hs=0,Zs.lineStart=We},polygonEnd:function(){Zs.lineStart=Zs.lineEnd=Zs.point=k,qs+=wo(Hs/2)}},Ks={point:Ze,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},$s={point:Qe,lineStart:Je,lineEnd:tr,polygonStart:function(){$s.lineStart=er},polygonEnd:function(){$s.point=Qe,$s.lineStart=Je,$s.lineEnd=tr}};co.geo.path=function(){function t(t){return t&&("function"==typeof s&&a.pointRadius(+s.apply(this,arguments)),o&&o.valid||(o=i(a)),co.geo.stream(t,o)),a.result()}function e(){return o=null,t}var r,n,i,a,o,s=4.5;return t.area=function(t){return qs=0,co.geo.stream(t,i(Zs)),qs},t.centroid=function(t){return zs=Ps=Rs=Os=Is=Ns=js=Fs=Ds=0,co.geo.stream(t,i($s)),Ds?[js/Ds,Fs/Ds]:Ns?[Os/Ns,Is/Ns]:Rs?[zs/Rs,Ps/Rs]:[NaN,NaN]},t.bounds=function(t){return Xs=Ws=-(Gs=Ys=1/0),co.geo.stream(t,i(Ks)),[[Gs,Ys],[Xs,Ws]]},t.projection=function(t){return arguments.length?(i=(r=t)?t.stream||ir(t):x,e()):r},t.context=function(t){return arguments.length?(a=null==(n=t)?new Ke:new rr(t),"function"!=typeof s&&a.pointRadius(s),e()):n},t.pointRadius=function(e){return arguments.length?(s="function"==typeof e?e:(a.pointRadius(+e),+e),t):s},t.projection(co.geo.albersUsa()).context(null)},co.geo.transform=function(t){return{stream:function(e){var r=new ar(e);for(var n in t)r[n]=t[n];return r}}},ar.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},co.geo.projection=sr,co.geo.projectionMutator=lr,(co.geo.equirectangular=function(){return sr(ur)}).raw=ur.invert=ur,co.geo.rotation=function(t){function e(e){return e=t(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e}return t=hr(t[0]%360*Go,t[1]*Go,t.length>2?t[2]*Go:0),e.invert=function(e){return e=t.invert(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e},e},fr.invert=ur,co.geo.circle=function(){function t(){var t="function"==typeof n?n.apply(this,arguments):n,e=hr(-t[0]*Go,-t[1]*Go,0).invert,i=[];return r(null,null,1,{point:function(t,r){i.push(t=e(t,r)),t[0]*=Yo,t[1]*=Yo}}),{type:"Polygon",coordinates:[i]}}var e,r,n=[0,0],i=6;return t.origin=function(e){return arguments.length?(n=e,t):n},t.angle=function(n){return arguments.length?(r=vr((e=+n)*Go,i*Go),t):e},t.precision=function(n){return arguments.length?(r=vr(e*Go,(i=+n)*Go),t):i},t.angle(90)},co.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Go,i=t[1]*Go,a=e[1]*Go,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),c=Math.cos(i),u=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-l*f*s)*r),l*u+c*f*s)},co.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return co.range(Math.ceil(a/v)*v,i,v).map(h).concat(co.range(Math.ceil(c/m)*m,l,m).map(d)).concat(co.range(Math.ceil(n/p)*p,r,p).filter(function(t){return wo(t%v)>Do}).map(u)).concat(co.range(Math.ceil(s/g)*g,o,g).filter(function(t){return wo(t%m)>Do}).map(f))}var r,n,i,a,o,s,l,c,u,f,h,d,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[h(a).concat(d(l).slice(1),h(i).reverse().slice(1),d(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(a=+e[0][0],i=+e[1][0],c=+e[0][1],l=+e[1][1],a>i&&(e=a,a=i,i=e),c>l&&(e=c,c=l,l=e),t.precision(y)):[[a,c],[i,l]]},t.minorExtent=function(e){return arguments.length?(n=+e[0][0],r=+e[1][0],s=+e[0][1],o=+e[1][1],n>r&&(e=n,n=r,r=e),s>o&&(e=s,s=o,o=e),t.precision(y)):[[n,s],[r,o]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=yr(s,o,90),f=br(n,r,y),h=yr(c,l,90),d=br(a,i,y),t):y},t.majorExtent([[-180,-90+Do],[180,90-Do]]).minorExtent([[-180,-80-Do],[180,80+Do]])},co.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}var e,r,n=xr,i=_r;return t.distance=function(){return co.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},t.source=function(r){return arguments.length?(n=r,e="function"==typeof r?null:r,t):n},t.target=function(e){return arguments.length?(i=e,r="function"==typeof e?null:e,t):i},t.precision=function(){return arguments.length?t:0},t},co.geo.interpolate=function(t,e){return wr(t[0]*Go,t[1]*Go,e[0]*Go,e[1]*Go)},co.geo.length=function(t){return Qs=0,co.geo.stream(t,Js),Qs};var Qs,Js={sphere:k,point:k,lineStart:kr,lineEnd:k,polygonStart:k,polygonEnd:k},tl=Ar(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(co.geo.azimuthalEqualArea=function(){return sr(tl)}).raw=tl;var el=Ar(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},x);(co.geo.azimuthalEquidistant=function(){return sr(el)}).raw=el,(co.geo.conicConformal=function(){return Ye(Mr)}).raw=Mr,(co.geo.conicEquidistant=function(){return Ye(Tr)}).raw=Tr;var rl=Ar(function(t){return 1/t},Math.atan);(co.geo.gnomonic=function(){return sr(rl)}).raw=rl,Er.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Ho]},(co.geo.mercator=function(){return Lr(Er)}).raw=Er;var nl=Ar(function(){return 1},Math.asin);(co.geo.orthographic=function(){return sr(nl)}).raw=nl;var il=Ar(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(co.geo.stereographic=function(){return sr(il)}).raw=il,Sr.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ho]},(co.geo.transverseMercator=function(){var t=Lr(Sr),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):(t=r(),[t[0],t[1],t[2]-90])},r([0,0,90])}).raw=Sr,co.geom={},co.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,i=Lt(r),a=Lt(n),o=t.length,s=[],l=[];for(e=0;o>e;e++)s.push([+i.call(this,t[e],e),+a.call(this,t[e],e),e]);for(s.sort(Rr),e=0;o>e;e++)l.push([s[e][0],-s[e][1]]);var c=Pr(s),u=Pr(l),f=u[0]===c[0],h=u[u.length-1]===c[c.length-1],d=[];for(e=c.length-1;e>=0;--e)d.push(t[s[c[e]][2]]);for(e=+f;e=n&&c.x<=a&&c.y>=i&&c.y<=o?[[n,o],[a,o],[a,i],[n,i]]:[];u.point=t[s]}),e}function r(t){return t.map(function(t,e){return{x:Math.round(a(t,e)/Do)*Do,y:Math.round(o(t,e)/Do)*Do,i:e}})}var n=Cr,i=zr,a=n,o=i,s=dl;return t?e(t):(e.links=function(t){return cn(r(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cn(r(t)).cells.forEach(function(r,n){for(var i,a,o=r.site,s=r.edges.sort(Yr),l=-1,c=s.length,u=s[c-1].edge,f=u.l===o?u.r:u.l;++l=c,h=n>=u,d=h<<1|f;t.leaf=!1,t=t.nodes[d]||(t.nodes[d]=pn()),f?i=c:s=c,h?o=u:l=u,a(t,e,r,n,i,o,s,l)}var u,f,h,d,p,g,v,m,y,b=Lt(s),x=Lt(l);if(null!=e)g=e,v=r,m=n,y=i;else if(m=y=-(g=v=1/0),f=[],h=[],p=t.length,o)for(d=0;p>d;++d)u=t[d],u.xm&&(m=u.x),u.y>y&&(y=u.y),f.push(u.x),h.push(u.y);else for(d=0;p>d;++d){var _=+b(u=t[d],d),w=+x(u,d);g>_&&(g=_),v>w&&(v=w),_>m&&(m=_),w>y&&(y=w),f.push(_),h.push(w)}var k=m-g,A=y-v;k>A?y=v+k:m=g+A;var M=pn();if(M.add=function(t){a(M,t,+b(t,++d),+x(t,d),g,v,m,y)},M.visit=function(t){gn(t,M,g,v,m,y)},M.find=function(t){return vn(M,t[0],t[1],g,v,m,y)},d=-1,null==e){for(;++d=0?t.slice(0,e):t,n=e>=0?t.slice(e+1):"in";return r=ml.get(r)||vl,n=yl.get(n)||x,kn(n(r.apply(null,uo.call(arguments,1))))},co.interpolateHcl=Nn,co.interpolateHsl=jn,co.interpolateLab=Fn,co.interpolateRound=Dn,co.transform=function(t){var e=ho.createElementNS(co.ns.prefix.svg,"g");return(co.transform=function(t){if(null!=t){e.setAttribute("transform",t);var r=e.transform.baseVal.consolidate()}return new Bn(r?r.matrix:bl)})(t)},Bn.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var bl={a:1,b:0,c:0,d:1,e:0,f:0};co.interpolateTransform=Zn,co.layout={},co.layout.bundle=function(){return function(t){for(var e=[],r=-1,n=t.length;++rs*s/m){if(g>l){var c=e.charge/l;t.px-=a*c,t.py-=o*c}return!0}if(e.point&&l&&g>l){var c=e.pointCharge/l;t.px-=a*c,t.py-=o*c}}return!e.charge}}function e(t){t.px=co.event.x,t.py=co.event.y,l.resume()}var r,n,i,a,o,s,l={},c=co.dispatch("start","tick","end"),u=[1,1],f=.9,h=xl,d=_l,p=-30,g=wl,v=.1,m=.64,y=[],b=[];return l.tick=function(){if((i*=.99)<.005)return r=null,c.end({type:"end",alpha:i=0}),!0;var e,n,l,h,d,g,m,x,_,w=y.length,k=b.length;for(n=0;k>n;++n)l=b[n],h=l.source,d=l.target,x=d.x-h.x,_=d.y-h.y,(g=x*x+_*_)&&(g=i*o[n]*((g=Math.sqrt(g))-a[n])/g,x*=g,_*=g,d.x-=x*(m=h.weight+d.weight?h.weight/(h.weight+d.weight):.5),d.y-=_*m,h.x+=x*(m=1-m),h.y+=_*m);if((m=i*v)&&(x=u[0]/2,_=u[1]/2,n=-1,m))for(;++n0?i=t:(r.c=null,r.t=NaN,r=null,c.end({type:"end",alpha:i=0})):t>0&&(c.start({type:"start",alpha:i=t}),r=Rt(l.tick)),l):i},l.start=function(){function t(t,n){if(!r){for(r=new Array(i),l=0;i>l;++l)r[l]=[];for(l=0;c>l;++l){var a=b[l];r[a.source.index].push(a.target),r[a.target.index].push(a.source)}}for(var o,s=r[e],l=-1,u=s.length;++le;++e)(n=y[e]).index=e,n.weight=0;for(e=0;c>e;++e)n=b[e],"number"==typeof n.source&&(n.source=y[n.source]),"number"==typeof n.target&&(n.target=y[n.target]),++n.source.weight,++n.target.weight;for(e=0;i>e;++e)n=y[e],isNaN(n.x)&&(n.x=t("x",f)),isNaN(n.y)&&(n.y=t("y",g)),isNaN(n.px)&&(n.px=n.x),isNaN(n.py)&&(n.py=n.y);if(a=[],"function"==typeof h)for(e=0;c>e;++e)a[e]=+h.call(this,b[e],e);else for(e=0;c>e;++e)a[e]=h;if(o=[],"function"==typeof d)for(e=0;c>e;++e)o[e]=+d.call(this,b[e],e);else for(e=0;c>e;++e)o[e]=d;if(s=[],"function"==typeof p)for(e=0;i>e;++e)s[e]=+p.call(this,y[e],e);else for(e=0;i>e;++e)s[e]=p;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return n||(n=co.behavior.drag().origin(x).on("dragstart.force",ei).on("drag.force",e).on("dragend.force",ri)),arguments.length?void this.on("mouseover.force",ni).on("mouseout.force",ii).call(n):n},co.rebind(l,c,"on")};var xl=20,_l=1,wl=1/0;co.layout.hierarchy=function(){function t(i){var a,o=[i],s=[];for(i.depth=0;null!=(a=o.pop());)if(s.push(a),(c=r.call(t,a,a.depth))&&(l=c.length)){for(var l,c,u;--l>=0;)o.push(u=c[l]),u.parent=a,u.depth=a.depth+1;n&&(a.value=0),a.children=c}else n&&(a.value=+n.call(t,a,a.depth)||0),delete a.children;return li(i,function(t){var r,i;e&&(r=t.children)&&r.sort(e),n&&(i=t.parent)&&(i.value+=t.value)}),s}var e=fi,r=ci,n=ui;return t.sort=function(r){return arguments.length?(e=r,t):e},t.children=function(e){return arguments.length?(r=e,t):r},t.value=function(e){return arguments.length?(n=e,t):n},t.revalue=function(e){return n&&(si(e,function(t){t.children&&(t.value=0)}),li(e,function(e){var r;e.children||(e.value=+n.call(t,e,e.depth)||0),(r=e.parent)&&(r.value+=e.value)})),e},t},co.layout.partition=function(){function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,c=-1;for(n=e.value?n/e.value:0;++cf?-1:1),p=co.sum(c),g=p?(f-l*d)/p:0,v=co.range(l),m=[];return null!=r&&v.sort(r===kl?function(t,e){return c[e]-c[t]}:function(t,e){return r(o[t],o[e])}),v.forEach(function(t){m[t]={data:o[t],value:s=c[t],startAngle:u,endAngle:u+=s*g+d,padAngle:h}}),m}var e=Number,r=kl,n=0,i=Vo,a=0;return t.value=function(r){return arguments.length?(e=r,t):e},t.sort=function(e){return arguments.length?(r=e,t):r},t.startAngle=function(e){return arguments.length?(n=e,t):n},t.endAngle=function(e){return arguments.length?(i=e,t):i},t.padAngle=function(e){return arguments.length?(a=e,t):a},t};var kl={};co.layout.stack=function(){function t(s,l){if(!(h=s.length))return s;var c=s.map(function(r,n){return e.call(t,r,n)}),u=c.map(function(e){return e.map(function(e,r){return[a.call(t,e,r),o.call(t,e,r)]})}),f=r.call(t,u,l);c=co.permute(c,f),u=co.permute(u,f);var h,d,p,g,v=n.call(t,u,l),m=c[0].length;for(p=0;m>p;++p)for(i.call(t,c[0][p],g=v[p],u[0][p][1]),d=1;h>d;++d)i.call(t,c[d][p],g+=u[d-1][p][1],u[d][p][1]);return s}var e=x,r=vi,n=mi,i=gi,a=di,o=pi;return t.values=function(r){return arguments.length?(e=r,t):e},t.order=function(e){return arguments.length?(r="function"==typeof e?e:Al.get(e)||vi,t):r},t.offset=function(e){return arguments.length?(n="function"==typeof e?e:Ml.get(e)||mi,t):n},t.x=function(e){return arguments.length?(a=e,t):a},t.y=function(e){return arguments.length?(o=e,t):o},t.out=function(e){return arguments.length?(i=e,t):i},t};var Al=co.map({"inside-out":function(t){var e,r,n=t.length,i=t.map(yi),a=t.map(bi),o=co.range(n).sort(function(t,e){return i[t]-i[e]}),s=0,l=0,c=[],u=[];for(e=0;n>e;++e)r=o[e],l>s?(s+=a[r],c.push(r)):(l+=a[r],u.push(r));return u.reverse().concat(c)},reverse:function(t){return co.range(t.length).reverse()},"default":vi}),Ml=co.map({silhouette:function(t){var e,r,n,i=t.length,a=t[0].length,o=[],s=0,l=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];n>s&&(s=n),o.push(n)}for(r=0;a>r;++r)l[r]=(s-o[r])/2;return l},wiggle:function(t){var e,r,n,i,a,o,s,l,c,u=t.length,f=t[0],h=f.length,d=[];for(d[0]=l=c=0,r=1;h>r;++r){for(e=0,i=0;u>e;++e)i+=t[e][r][1];for(e=0,a=0,s=f[r][0]-f[r-1][0];u>e;++e){for(n=0,o=(t[e][r][1]-t[e][r-1][1])/(2*s);e>n;++n)o+=(t[n][r][1]-t[n][r-1][1])/s;a+=o*t[e][r][1]}d[r]=l-=i?a/i*s:0,c>l&&(c=l)}for(r=0;h>r;++r)d[r]-=c;return d},expand:function(t){var e,r,n,i=t.length,a=t[0].length,o=1/i,s=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];if(n)for(e=0;i>e;e++)t[e][r][1]/=n;else for(e=0;i>e;e++)t[e][r][1]=o}for(r=0;a>r;++r)s[r]=0;return s},zero:mi});co.layout.histogram=function(){function t(t,a){for(var o,s,l=[],c=t.map(r,this),u=n.call(this,c,a),f=i.call(this,u,c,a),a=-1,h=c.length,d=f.length-1,p=e?1:1/h;++a0)for(a=-1;++a=u[0]&&s<=u[1]&&(o=l[co.bisect(f,s,1,d)-1],o.y+=p,o.push(t[a]));return l}var e=!0,r=Number,n=ki,i=_i;return t.value=function(e){return arguments.length?(r=e,t):r},t.range=function(e){return arguments.length?(n=Lt(e),t):n},t.bins=function(e){return arguments.length?(i="number"==typeof e?function(t){return wi(t,e)}:Lt(e),t):i},t.frequency=function(r){return arguments.length?(e=!!r,t):e},t},co.layout.pack=function(){function t(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],c=i[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,li(s,function(t){t.r=+u(t.value)}),li(s,Li),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/c))/2;li(s,function(t){t.r+=f}),li(s,Li),li(s,function(t){t.r-=f})}return zi(s,l/2,c/2,e?1:1/Math.max(2*s.r/l,2*s.r/c)),o}var e,r=co.layout.hierarchy().sort(Ai),n=0,i=[1,1];return t.size=function(e){return arguments.length?(i=e,t):i},t.radius=function(r){return arguments.length?(e=null==r||"function"==typeof r?r:+r,t):e},t.padding=function(e){return arguments.length?(n=+e,t):n},oi(t,r)},co.layout.tree=function(){function t(t,i){var u=o.call(this,t,i),f=u[0],h=e(f);if(li(h,r),h.parent.m=-h.z,si(h,n),c)si(f,a);else{var d=f,p=f,g=f;si(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=s(d,p)/2-d.x,m=l[0]/(p.x+s(p,d)/2+v),y=l[1]/(g.depth||1);si(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return u}function e(t){for(var e,r={A:null,children:[t]},n=[r];null!=(e=n.pop());)for(var i,a=e.children,o=0,s=a.length;s>o;++o)n.push((a[o]=i={_:a[o],parent:e,children:(i=a[o].children)&&i.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=i);return r.children[0]}function r(t){var e=t.children,r=t.parent.children,n=t.i?r[t.i-1]:null;if(e.length){ji(t);var a=(e[0].z+e[e.length-1].z)/2;n?(t.z=n.z+s(t._,n._),t.m=t.z-a):t.z=a}else n&&(t.z=n.z+s(t._,n._));t.parent.A=i(t,n,t.parent.A||r[0])}function n(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function i(t,e,r){if(e){for(var n,i=t,a=t,o=e,l=i.parent.children[0],c=i.m,u=a.m,f=o.m,h=l.m;o=Ii(o),i=Oi(i),o&&i;)l=Oi(l),a=Ii(a),a.a=t,n=o.z+f-i.z-c+s(o._,i._),n>0&&(Ni(Fi(o,t,r),t,n),c+=n,u+=n),f+=o.m,c+=i.m,h+=l.m,u+=a.m;o&&!Ii(a)&&(a.t=o,a.m+=f-u),i&&!Oi(l)&&(l.t=i,l.m+=c-h,r=t)}return r}function a(t){t.x*=l[0],t.y=t.depth*l[1]}var o=co.layout.hierarchy().sort(null).value(null),s=Ri,l=[1,1],c=null;return t.separation=function(e){return arguments.length?(s=e,t):s},t.size=function(e){return arguments.length?(c=null==(l=e)?a:null,t):c?null:l},t.nodeSize=function(e){return arguments.length?(c=null==(l=e)?null:a,t):c?l:null},oi(t,o)},co.layout.cluster=function(){function t(t,a){var o,s=e.call(this,t,a),l=s[0],c=0;li(l,function(t){var e=t.children;e&&e.length?(t.x=Bi(e),t.y=Di(e)):(t.x=o?c+=r(t,o):0,t.y=0,o=t)});var u=Ui(l),f=Vi(l),h=u.x-r(u,f)/2,d=f.x+r(f,u)/2;return li(l,i?function(t){t.x=(t.x-l.x)*n[0],t.y=(l.y-t.y)*n[1]}:function(t){t.x=(t.x-h)/(d-h)*n[0],t.y=(1-(l.y?t.y/l.y:1))*n[1]}),s}var e=co.layout.hierarchy().sort(null).value(null),r=Ri,n=[1,1],i=!1;return t.separation=function(e){return arguments.length?(r=e,t):r},t.size=function(e){return arguments.length?(i=null==(n=e),t):i?null:n},t.nodeSize=function(e){return arguments.length?(i=null!=(n=e),t):i?n:null},oi(t,e)},co.layout.treemap=function(){function t(t,e){for(var r,n,i=-1,a=t.length;++ie?0:e),r.area=isNaN(n)||0>=n?0:n}function e(r){var a=r.children;if(a&&a.length){var o,s,l,c=f(r),u=[],h=a.slice(),p=1/0,g="slice"===d?c.dx:"dice"===d?c.dy:"slice-dice"===d?1&r.depth?c.dy:c.dx:Math.min(c.dx,c.dy); -for(t(h,c.dx*c.dy/r.value),u.area=0;(l=h.length)>0;)u.push(o=h[l-1]),u.area+=o.area,"squarify"!==d||(s=n(u,g))<=p?(h.pop(),p=s):(u.area-=u.pop().area,i(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(i(u,g,c,!0),u.length=u.area=0),a.forEach(e)}}function r(e){var n=e.children;if(n&&n.length){var a,o=f(e),s=n.slice(),l=[];for(t(s,o.dx*o.dy/e.value),l.area=0;a=s.pop();)l.push(a),l.area+=a.area,null!=a.z&&(i(l,a.z?o.dx:o.dy,o,!s.length),l.length=l.area=0);n.forEach(r)}}function n(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++or&&(a=r),r>i&&(i=r));return n*=n,e*=e,n?Math.max(e*i*p/n,n/(e*a*p)):1/0}function i(t,e,r,n){var i,a=-1,o=t.length,s=r.x,c=r.y,u=e?l(t.area/e):0;if(e==r.dx){for((n||u>r.dy)&&(u=r.dy);++ar.dx)&&(u=r.dx);++ar&&(e=1),1>r&&(t=0),function(){var r,n,i;do r=2*Math.random()-1,n=2*Math.random()-1,i=r*r+n*n;while(!i||i>1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=co.random.normal.apply(co,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=co.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,r=0;t>r;r++)e+=Math.random();return e}}},co.scale={};var Tl={floor:x,ceil:x};co.scale.linear=function(){return $i([0,1],[0,1],_n,!1)};var El={s:1,g:1,p:1,r:1,e:1};co.scale.log=function(){return aa(co.scale.linear().domain([0,1]),10,!0,[1,10])};var Ll=co.format(".0e"),Sl={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};co.scale.pow=function(){return oa(co.scale.linear(),1,[0,1])},co.scale.sqrt=function(){return co.scale.pow().exponent(.5)},co.scale.ordinal=function(){return la([],{t:"range",a:[[]]})},co.scale.category10=function(){return co.scale.ordinal().range(Cl)},co.scale.category20=function(){return co.scale.ordinal().range(zl)},co.scale.category20b=function(){return co.scale.ordinal().range(Pl)},co.scale.category20c=function(){return co.scale.ordinal().range(Rl)};var Cl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(_t),zl=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(_t),Pl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(_t),Rl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(_t);co.scale.quantile=function(){return ca([],[])},co.scale.quantize=function(){return ua(0,1,[0,1])},co.scale.threshold=function(){return fa([.5],[0,1])},co.scale.identity=function(){return ha([0,1])},co.svg={},co.svg.arc=function(){function t(){var t=Math.max(0,+r.apply(this,arguments)),c=Math.max(0,+n.apply(this,arguments)),u=o.apply(this,arguments)-Ho,f=s.apply(this,arguments)-Ho,h=Math.abs(f-u),d=u>f?0:1;if(t>c&&(p=c,c=t,t=p),h>=qo)return e(c,d)+(t?e(t,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,k,A,M,T=0,E=0,L=[];if((m=(+l.apply(this,arguments)||0)/2)&&(v=a===Ol?Math.sqrt(t*t+c*c):+a.apply(this,arguments),d||(E*=-1),c&&(E=nt(v/c*Math.sin(m))),t&&(T=nt(v/t*Math.sin(m)))),c){y=c*Math.cos(u+E),b=c*Math.sin(u+E),x=c*Math.cos(f-E),_=c*Math.sin(f-E);var S=Math.abs(f-u-2*E)<=Uo?0:1;if(E&&ba(y,b,x,_)===d^S){var C=(u+f)/2;y=c*Math.cos(C),b=c*Math.sin(C),x=_=null}}else y=b=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),A=t*Math.cos(u+T),M=t*Math.sin(u+T);var z=Math.abs(u-f+2*T)<=Uo?0:1;if(T&&ba(w,k,A,M)===1-d^z){var P=(u+f)/2;w=t*Math.cos(P),k=t*Math.sin(P),A=M=null}}else w=k=0;if(h>Do&&(p=Math.min(Math.abs(c-t)/2,+i.apply(this,arguments)))>.001){g=c>t^d?0:1;var R=p,O=p;if(Uo>h){var I=null==A?[w,k]:null==x?[y,b]:Ir([y,b],[A,M],[x,_],[w,k]),N=y-I[0],j=b-I[1],F=x-I[0],D=_-I[1],B=1/Math.sin(Math.acos((N*F+j*D)/(Math.sqrt(N*N+j*j)*Math.sqrt(F*F+D*D)))/2),U=Math.sqrt(I[0]*I[0]+I[1]*I[1]);O=Math.min(p,(t-U)/(B-1)),R=Math.min(p,(c-U)/(B+1))}if(null!=x){var V=xa(null==A?[w,k]:[A,M],[y,b],c,R,d),q=xa([x,_],[w,k],c,R,d);p===R?L.push("M",V[0],"A",R,",",R," 0 0,",g," ",V[1],"A",c,",",c," 0 ",1-d^ba(V[1][0],V[1][1],q[1][0],q[1][1]),",",d," ",q[1],"A",R,",",R," 0 0,",g," ",q[0]):L.push("M",V[0],"A",R,",",R," 0 1,",g," ",q[0])}else L.push("M",y,",",b);if(null!=A){var H=xa([y,b],[A,M],t,-O,d),G=xa([w,k],null==x?[y,b]:[x,_],t,-O,d);p===O?L.push("L",G[0],"A",O,",",O," 0 0,",g," ",G[1],"A",t,",",t," 0 ",d^ba(G[1][0],G[1][1],H[1][0],H[1][1]),",",1-d," ",H[1],"A",O,",",O," 0 0,",g," ",H[0]):L.push("L",G[0],"A",O,",",O," 0 0,",g," ",H[0])}else L.push("L",w,",",k)}else L.push("M",y,",",b),null!=x&&L.push("A",c,",",c," 0 ",S,",",d," ",x,",",_),L.push("L",w,",",k),null!=A&&L.push("A",t,",",t," 0 ",z,",",1-d," ",A,",",M);return L.push("Z"),L.join("")}function e(t,e){return"M0,"+t+"A"+t+","+t+" 0 1,"+e+" 0,"+-t+"A"+t+","+t+" 0 1,"+e+" 0,"+t}var r=pa,n=ga,i=da,a=Ol,o=va,s=ma,l=ya;return t.innerRadius=function(e){return arguments.length?(r=Lt(e),t):r},t.outerRadius=function(e){return arguments.length?(n=Lt(e),t):n},t.cornerRadius=function(e){return arguments.length?(i=Lt(e),t):i},t.padRadius=function(e){return arguments.length?(a=e==Ol?Ol:Lt(e),t):a},t.startAngle=function(e){return arguments.length?(o=Lt(e),t):o},t.endAngle=function(e){return arguments.length?(s=Lt(e),t):s},t.padAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.centroid=function(){var t=(+r.apply(this,arguments)+ +n.apply(this,arguments))/2,e=(+o.apply(this,arguments)+ +s.apply(this,arguments))/2-Ho;return[Math.cos(e)*t,Math.sin(e)*t]},t};var Ol="auto";co.svg.line=function(){return _a(x)};var Il=co.map({linear:wa,"linear-closed":ka,step:Aa,"step-before":Ma,"step-after":Ta,basis:Pa,"basis-open":Ra,"basis-closed":Oa,bundle:Ia,cardinal:Sa,"cardinal-open":Ea,"cardinal-closed":La,monotone:Ua});Il.forEach(function(t,e){e.key=t,e.closed=/-closed$/.test(t)});var Nl=[0,2/3,1/3,0],jl=[0,1/3,2/3,0],Fl=[0,1/6,2/3,1/6];co.svg.line.radial=function(){var t=_a(Va);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},Ma.reverse=Ta,Ta.reverse=Ma,co.svg.area=function(){return qa(x)},co.svg.area.radial=function(){var t=qa(Va);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},co.svg.chord=function(){function t(t,s){var l=e(this,a,t,s),c=e(this,o,t,s);return"M"+l.p0+n(l.r,l.p1,l.a1-l.a0)+(r(l,c)?i(l.r,l.p1,l.r,l.p0):i(l.r,l.p1,c.r,c.p0)+n(c.r,c.p1,c.a1-c.a0)+i(c.r,c.p1,l.r,l.p0))+"Z"}function e(t,e,r,n){var i=e.call(t,r,n),a=s.call(t,i,n),o=l.call(t,i,n)-Ho,u=c.call(t,i,n)-Ho;return{r:a,a0:o,a1:u,p0:[a*Math.cos(o),a*Math.sin(o)],p1:[a*Math.cos(u),a*Math.sin(u)]}}function r(t,e){return t.a0==e.a0&&t.a1==e.a1}function n(t,e,r){return"A"+t+","+t+" 0 "+ +(r>Uo)+",1 "+e}function i(t,e,r,n){return"Q 0,0 "+n}var a=xr,o=_r,s=Ha,l=va,c=ma;return t.radius=function(e){return arguments.length?(s=Lt(e),t):s},t.source=function(e){return arguments.length?(a=Lt(e),t):a},t.target=function(e){return arguments.length?(o=Lt(e),t):o},t.startAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.endAngle=function(e){return arguments.length?(c=Lt(e),t):c},t},co.svg.diagonal=function(){function t(t,i){var a=e.call(this,t,i),o=r.call(this,t,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return l=l.map(n),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var e=xr,r=_r,n=Ga;return t.source=function(r){return arguments.length?(e=Lt(r),t):e},t.target=function(e){return arguments.length?(r=Lt(e),t):r},t.projection=function(e){return arguments.length?(n=e,t):n},t},co.svg.diagonal.radial=function(){var t=co.svg.diagonal(),e=Ga,r=t.projection;return t.projection=function(t){return arguments.length?r(Ya(e=t)):e},t},co.svg.symbol=function(){function t(t,n){return(Dl.get(e.call(this,t,n))||Za)(r.call(this,t,n))}var e=Wa,r=Xa;return t.type=function(r){return arguments.length?(e=Lt(r),t):e},t.size=function(e){return arguments.length?(r=Lt(e),t):r},t};var Dl=co.map({circle:Za,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Ul)),r=e*Ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/Bl),r=e*Bl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/Bl),r=e*Bl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});co.svg.symbolTypes=Dl.keys();var Bl=Math.sqrt(3),Ul=Math.tan(30*Go);zo.transition=function(t){for(var e,r,n=Vl||++Yl,i=to(t),a=[],o=ql||{time:Date.now(),ease:Ln,delay:0,duration:250},s=-1,l=this.length;++sa;a++){i.push(e=[]);for(var r=this[a],s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return $a(i,this.namespace,this.id)},Gl.tween=function(t,e){var r=this.id,n=this.namespace;return arguments.length<2?this.node()[n][r].tween.get(t):G(this,null==e?function(e){e[n][r].tween.remove(t)}:function(i){i[n][r].tween.set(t,e)})},Gl.attr=function(t,e){function r(){this.removeAttribute(s)}function n(){this.removeAttributeNS(s.space,s.local)}function i(t){return null==t?r:(t+="",function(){var e,r=this.getAttribute(s);return r!==t&&(e=o(r,t),function(t){this.setAttribute(s,e(t))})})}function a(t){return null==t?n:(t+="",function(){var e,r=this.getAttributeNS(s.space,s.local);return r!==t&&(e=o(r,t),function(t){this.setAttributeNS(s.space,s.local,e(t))})})}if(arguments.length<2){for(e in t)this.attr(e,t[e]);return this}var o="transform"==t?Zn:_n,s=co.ns.qualify(t);return Qa(this,"attr."+t,e,s.local?a:i)},Gl.attrTween=function(t,e){function r(t,r){var n=e.call(this,t,r,this.getAttribute(i));return n&&function(t){this.setAttribute(i,n(t))}}function n(t,r){var n=e.call(this,t,r,this.getAttributeNS(i.space,i.local));return n&&function(t){this.setAttributeNS(i.space,i.local,n(t))}}var i=co.ns.qualify(t);return this.tween("attr."+t,i.local?n:r)},Gl.style=function(t,e,r){function i(){this.style.removeProperty(t)}function a(e){return null==e?i:(e+="",function(){var i,a=n(this).getComputedStyle(this,null).getPropertyValue(t);return a!==e&&(i=_n(a,e),function(e){this.style.setProperty(t,i(e),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof t){2>o&&(e="");for(r in t)this.style(r,t[r],e);return this}r=""}return Qa(this,"style."+t,e,a)},Gl.styleTween=function(t,e,r){function i(i,a){var o=e.call(this,i,a,n(this).getComputedStyle(this,null).getPropertyValue(t));return o&&function(e){this.style.setProperty(t,o(e),r)}}return arguments.length<3&&(r=""),this.tween("style."+t,i)},Gl.text=function(t){return Qa(this,"text",t,Ja)},Gl.remove=function(){var t=this.namespace;return this.each("end.transition",function(){var e;this[t].count<2&&(e=this.parentNode)&&e.removeChild(this)})},Gl.ease=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].ease:("function"!=typeof t&&(t=co.ease.apply(co,arguments)),G(this,function(n){n[r][e].ease=t}))},Gl.delay=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].delay:G(this,"function"==typeof t?function(n,i,a){n[r][e].delay=+t.call(n,n.__data__,i,a)}:(t=+t,function(n){n[r][e].delay=t}))},Gl.duration=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].duration:G(this,"function"==typeof t?function(n,i,a){n[r][e].duration=Math.max(1,t.call(n,n.__data__,i,a))}:(t=Math.max(1,t),function(n){n[r][e].duration=t}))},Gl.each=function(t,e){var r=this.id,n=this.namespace;if(arguments.length<2){var i=ql,a=Vl;try{Vl=r,G(this,function(e,i,a){ql=e[n][r],t.call(e,e.__data__,i,a)})}finally{ql=i,Vl=a}}else G(this,function(i){var a=i[n][r];(a.event||(a.event=co.dispatch("start","end","interrupt"))).on(t,e)});return this},Gl.transition=function(){for(var t,e,r,n,i=this.id,a=++Yl,o=this.namespace,s=[],l=0,c=this.length;c>l;l++){s.push(t=[]);for(var e=this[l],u=0,f=e.length;f>u;u++)(r=e[u])&&(n=r[o][i],eo(r,u,o,a,{time:n.time,ease:n.ease,delay:n.delay+n.duration,duration:n.duration})),t.push(r)}return $a(s,o,a)},co.svg.axis=function(){function t(t){t.each(function(){var t,c=co.select(this),u=this.__chart__||r,f=this.__chart__=r.copy(),h=null==l?f.ticks?f.ticks.apply(f,s):f.domain():l,d=null==e?f.tickFormat?f.tickFormat.apply(f,s):x:e,p=c.selectAll(".tick").data(h,f),g=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Do),v=co.transition(p.exit()).style("opacity",Do).remove(),m=co.transition(p.order()).style("opacity",1),y=Math.max(i,0)+o,b=Yi(f),_=c.selectAll(".domain").data([0]),w=(_.enter().append("path").attr("class","domain"),co.transition(_));g.append("line"),g.append("text");var k,A,M,T,E=g.select("line"),L=m.select("line"),S=p.select("text").text(d),C=g.select("text"),z=m.select("text"),P="top"===n||"left"===n?-1:1;if("bottom"===n||"top"===n?(t=ro,k="x",M="y",A="x2",T="y2",S.attr("dy",0>P?"0em":".71em").style("text-anchor","middle"),w.attr("d","M"+b[0]+","+P*a+"V0H"+b[1]+"V"+P*a)):(t=no,k="y",M="x",A="y2",T="x2",S.attr("dy",".32em").style("text-anchor",0>P?"end":"start"),w.attr("d","M"+P*a+","+b[0]+"H0V"+b[1]+"H"+P*a)),E.attr(T,P*i),C.attr(M,P*y),L.attr(A,0).attr(T,P*i),z.attr(k,0).attr(M,P*y),f.rangeBand){var R=f,O=R.rangeBand()/2;u=f=function(t){return R(t)+O}}else u.rangeBand?u=f:v.call(t,f,u);g.call(t,u,f),m.call(t,f,f)})}var e,r=co.scale.linear(),n=Xl,i=6,a=6,o=3,s=[10],l=null;return t.scale=function(e){return arguments.length?(r=e,t):r},t.orient=function(e){return arguments.length?(n=e in Wl?e+"":Xl,t):n},t.ticks=function(){return arguments.length?(s=fo(arguments),t):s},t.tickValues=function(e){return arguments.length?(l=e,t):l},t.tickFormat=function(r){return arguments.length?(e=r,t):e},t.tickSize=function(e){var r=arguments.length;return r?(i=+e,a=+arguments[r-1],t):i},t.innerTickSize=function(e){return arguments.length?(i=+e,t):i},t.outerTickSize=function(e){return arguments.length?(a=+e,t):a},t.tickPadding=function(e){return arguments.length?(o=+e,t):o},t.tickSubdivide=function(){return arguments.length&&t},t};var Xl="bottom",Wl={top:1,right:1,bottom:1,left:1};co.svg.brush=function(){function t(n){n.each(function(){var n=co.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",a).on("touchstart.brush",a),o=n.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),n.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var s=n.selectAll(".resize").data(g,x);s.exit().remove(),s.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return Zl[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),s.style("display",t.empty()?"none":null);var l,f=co.transition(n),h=co.transition(o);c&&(l=Yi(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(f)),u&&(l=Yi(u),h.attr("y",l[0]).attr("height",l[1]-l[0]),i(f)),e(f)})}function e(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+f[+/e$/.test(t)]+","+h[+/^s/.test(t)]+")"})}function r(t){t.select(".extent").attr("x",f[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function i(t){t.select(".extent").attr("y",h[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function a(){function a(){32==co.event.keyCode&&(S||(b=null,z[0]-=f[1],z[1]-=h[1],S=2),T())}function g(){32==co.event.keyCode&&2==S&&(z[0]+=f[1],z[1]+=h[1],S=0,T())}function v(){var t=co.mouse(_),n=!1;x&&(t[0]+=x[0],t[1]+=x[1]),S||(co.event.altKey?(b||(b=[(f[0]+f[1])/2,(h[0]+h[1])/2]),z[0]=f[+(t[0]u?(i=n,n=u):i=u),g[0]!=n||g[1]!=i?(r?s=null:o=null,g[0]=n,g[1]=i,!0):void 0}function y(){v(),A.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),co.select("body").style("cursor",null),P.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),k({type:"brushend"})}var b,x,_=this,w=co.select(co.event.target),k=l.of(_,arguments),A=co.select(_),M=w.datum(),E=!/^(n|s)$/.test(M)&&c,L=!/^(e|w)$/.test(M)&&u,S=w.classed("extent"),C=$(_),z=co.mouse(_),P=co.select(n(_)).on("keydown.brush",a).on("keyup.brush",g);if(co.event.changedTouches?P.on("touchmove.brush",v).on("touchend.brush",y):P.on("mousemove.brush",v).on("mouseup.brush",y),A.interrupt().selectAll("*").interrupt(),S)z[0]=f[0]-z[0],z[1]=h[0]-z[1];else if(M){var R=+/w$/.test(M),O=+/^n/.test(M);x=[f[1-R]-z[0],h[1-O]-z[1]],z[0]=f[R],z[1]=h[O]}else co.event.altKey&&(b=z.slice());A.style("pointer-events","none").selectAll(".resize").style("display",null),co.select("body").style("cursor",w.style("cursor")),k({type:"brushstart"}),v()}var o,s,l=L(t,"brushstart","brush","brushend"),c=null,u=null,f=[0,0],h=[0,0],d=!0,p=!0,g=Kl[0];return t.event=function(t){t.each(function(){var t=l.of(this,arguments),e={x:f,y:h,i:o,j:s},r=this.__chart__||e;this.__chart__=e,Vl?co.select(this).transition().each("start.brush",function(){o=r.i,s=r.j,f=r.x,h=r.y,t({type:"brushstart"})}).tween("brush:brush",function(){var r=wn(f,e.x),n=wn(h,e.y);return o=s=null,function(i){f=e.x=r(i),h=e.y=n(i),t({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=e.i,s=e.j,t({type:"brush",mode:"resize"}),t({type:"brushend"})}):(t({type:"brushstart"}),t({type:"brush",mode:"resize"}),t({type:"brushend"}))})},t.x=function(e){return arguments.length?(c=e,g=Kl[!c<<1|!u],t):c},t.y=function(e){return arguments.length?(u=e,g=Kl[!c<<1|!u],t):u},t.clamp=function(e){return arguments.length?(c&&u?(d=!!e[0],p=!!e[1]):c?d=!!e:u&&(p=!!e),t):c&&u?[d,p]:c?d:u?p:null},t.extent=function(e){var r,n,i,a,l;return arguments.length?(c&&(r=e[0],n=e[1],u&&(r=r[0],n=n[0]),o=[r,n],c.invert&&(r=c(r),n=c(n)),r>n&&(l=r,r=n,n=l),r==f[0]&&n==f[1]||(f=[r,n])),u&&(i=e[0],a=e[1],c&&(i=i[1],a=a[1]),s=[i,a],u.invert&&(i=u(i),a=u(a)),i>a&&(l=i,i=a,a=l),i==h[0]&&a==h[1]||(h=[i,a])),t):(c&&(o?(r=o[0],n=o[1]):(r=f[0],n=f[1],c.invert&&(r=c.invert(r),n=c.invert(n)),r>n&&(l=r,r=n,n=l))),u&&(s?(i=s[0],a=s[1]):(i=h[0],a=h[1],u.invert&&(i=u.invert(i),a=u.invert(a)),i>a&&(l=i,i=a,a=l))),c&&u?[[r,i],[n,a]]:c?[r,n]:u&&[i,a])},t.clear=function(){return t.empty()||(f=[0,0],h=[0,0],o=s=null),t},t.empty=function(){return!!c&&f[0]==f[1]||!!u&&h[0]==h[1]},co.rebind(t,l,"on")};var Zl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Kl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],$l=vs.format=ws.timeFormat,Ql=$l.utc,Jl=Ql("%Y-%m-%dT%H:%M:%S.%LZ");$l.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?io:Jl,io.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},io.toString=Jl.toString,vs.second=Vt(function(t){return new ms(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),vs.seconds=vs.second.range,vs.seconds.utc=vs.second.utc.range,vs.minute=Vt(function(t){return new ms(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),vs.minutes=vs.minute.range,vs.minutes.utc=vs.minute.utc.range,vs.hour=Vt(function(t){var e=t.getTimezoneOffset()/60;return new ms(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),vs.hours=vs.hour.range,vs.hours.utc=vs.hour.utc.range,vs.month=Vt(function(t){return t=vs.day(t),t.setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),vs.months=vs.month.range,vs.months.utc=vs.month.utc.range;var tc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],ec=[[vs.second,1],[vs.second,5],[vs.second,15],[vs.second,30],[vs.minute,1],[vs.minute,5],[vs.minute,15],[vs.minute,30],[vs.hour,1],[vs.hour,3],[vs.hour,6],[vs.hour,12],[vs.day,1],[vs.day,2],[vs.week,1],[vs.month,1],[vs.month,3],[vs.year,1]],rc=$l.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",ze]]),nc={range:function(t,e,r){return co.range(Math.ceil(t/r)*r,+e,r).map(oo)},floor:x,ceil:x};ec.year=vs.year,vs.scale=function(){return ao(co.scale.linear(),ec,rc)};var ic=ec.map(function(t){return[t[0].utc,t[1]]}),ac=Ql.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",ze]]);ic.year=vs.year.utc,vs.scale.utc=function(){return ao(co.scale.linear(),ic,ac)},co.text=St(function(t){return t.responseText}),co.json=function(t,e){return Ct(t,"application/json",so,e)},co.html=function(t,e){return Ct(t,"text/html",lo,e)},co.xml=St(function(t){return t.responseXML}),"function"==typeof t&&t.amd?(this.d3=co,t(co)):"object"==typeof r&&r.exports?r.exports=co:this.d3=co}()},{}],73:[function(t,e,r){"use strict";function n(t,e){this.point=t,this.index=e}function i(t,e){for(var r=t.point,n=e.point,i=r.length,a=0;i>a;++a){var o=n[a]-r[a];if(o)return o}return 0}function a(t,e,r){if(1===t)return r?[[-1,0]]:[];var n=e.map(function(t,e){return[t[0],e]});n.sort(function(t,e){return t[0]-e[0]});for(var i=new Array(t-1),a=1;t>a;++a){var o=n[a-1],s=n[a];i[a-1]=[o[1],s[1]]}return r&&i.push([-1,i[0][1]],[i[t-1][1],-1]),i}function o(t,e){var r=t.length;if(0===r)return[];var o=t[0].length;if(1>o)return[];if(1===o)return a(r,t,e);for(var c=new Array(r),u=1,f=0;r>f;++f){for(var h=t[f],d=new Array(o+1),p=0,g=0;o>g;++g){var v=h[g];d[g]=v,p+=v*v}d[o]=p,c[f]=new n(d,f),u=Math.max(p,u)}l(c,i),r=c.length;for(var m=new Array(r+o+1),y=new Array(r+o+1),b=(o+1)*(o+1)*u,x=new Array(o+1),f=0;o>=f;++f)x[f]=0;x[o]=b,m[0]=x.slice(),y[0]=-1;for(var f=0;o>=f;++f){var d=x.slice();d[f]=1,m[f+1]=d,y[f+1]=-1}for(var f=0;r>f;++f){var _=c[f];m[f+o+1]=_.point,y[f+o+1]=_.index}var w=s(m,!1);if(w=e?w.filter(function(t){for(var e=0,r=0;o>=r;++r){var n=y[t[r]];if(0>n&&++e>=2)return!1;t[r]=n}return!0}):w.filter(function(t){for(var e=0;o>=e;++e){var r=y[t[e]];if(0>r)return!1;t[e]=r}return!0}),1&o)for(var f=0;f=i)return[];var a,o=new Array(i);if(r===t.length-1)for(a=0;i>a;++a)o[a]=e;else for(a=0;i>a;++a)o[a]=n(t,e,r+1);return o}function i(t,e){var r,n;for(r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return i(0|t,e);break;case"object":if("number"==typeof t.length)return n(t,e,0)}return[]}e.exports=a},{}],75:[function(e,r,n){(function(n,i){(function(){"use strict";function a(t){return"function"==typeof t||"object"==typeof t&&null!==t}function o(t){return"function"==typeof t}function s(t){Y=t}function l(t){K=t}function c(){return function(){n.nextTick(p)}}function u(){return function(){G(p)}}function f(){var t=0,e=new J(p),r=document.createTextNode("");return e.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}function h(){var t=new MessageChannel;return t.port1.onmessage=p,function(){t.port2.postMessage(0)}}function d(){return function(){setTimeout(p,1)}}function p(){for(var t=0;Z>t;t+=2){var e=rt[t],r=rt[t+1];e(r),rt[t]=void 0,rt[t+1]=void 0}Z=0}function g(){try{var t=e,r=t("vertx");return G=r.runOnLoop||r.runOnContext,u()}catch(n){return d()}}function v(t,e){var r=this,n=r._state;if(n===ot&&!t||n===st&&!e)return this;var i=new this.constructor(y),a=r._result;if(n){var o=arguments[n-1];K(function(){O(n,i,o,a)})}else C(r,i,t,e);return i}function m(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var r=new e(y);return T(r,t),r}function y(){}function b(){return new TypeError("You cannot resolve a promise with itself")}function x(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return lt.error=e,lt}}function w(t,e,r,n){try{t.call(e,r,n)}catch(i){return i}}function k(t,e,r){K(function(t){var n=!1,i=w(r,e,function(r){n||(n=!0,e!==r?T(t,r):L(t,r))},function(e){n||(n=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&i&&(n=!0,S(t,i))},t)}function A(t,e){e._state===ot?L(t,e._result):e._state===st?S(t,e._result):C(e,void 0,function(e){T(t,e)},function(e){S(t,e)})}function M(t,e,r){e.constructor===t.constructor&&r===nt&&constructor.resolve===it?A(t,e):r===lt?S(t,lt.error):void 0===r?L(t,e):o(r)?k(t,e,r):L(t,e)}function T(t,e){t===e?S(t,b()):a(e)?M(t,e,_(e)):L(t,e)}function E(t){t._onerror&&t._onerror(t._result),z(t)}function L(t,e){t._state===at&&(t._result=e,t._state=ot,0!==t._subscribers.length&&K(z,t))}function S(t,e){t._state===at&&(t._state=st,t._result=e,K(E,t))}function C(t,e,r,n){var i=t._subscribers,a=i.length;t._onerror=null,i[a]=e,i[a+ot]=r,i[a+st]=n,0===a&&t._state&&K(z,t)}function z(t){var e=t._subscribers,r=t._state;if(0!==e.length){for(var n,i,a=t._result,o=0;oo;o++)C(n.resolve(t[o]),void 0,e,r);return i}function F(t){var e=this,r=new e(y);return S(r,t),r}function D(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function B(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function U(t){this._id=dt++,this._state=void 0,this._result=void 0,this._subscribers=[],y!==t&&("function"!=typeof t&&D(),this instanceof U?I(this,t):B())}function V(t,e){this._instanceConstructor=t,this.promise=new t(y),Array.isArray(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?L(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&L(this.promise,this._result))):S(this.promise,this._validationError())}function q(){var t;if("undefined"!=typeof i)t=i;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var r=t.Promise;r&&"[object Promise]"===Object.prototype.toString.call(r.resolve())&&!r.cast||(t.Promise=pt)}var H;H=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var G,Y,X,W=H,Z=0,K=function(t,e){rt[Z]=t,rt[Z+1]=e,Z+=2,2===Z&&(Y?Y(p):X())},$="undefined"!=typeof window?window:void 0,Q=$||{},J=Q.MutationObserver||Q.WebKitMutationObserver,tt="undefined"!=typeof n&&"[object process]"==={}.toString.call(n),et="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,rt=new Array(1e3);X=tt?c():J?f():et?h():void 0===$&&"function"==typeof e?g():d();var nt=v,it=m,at=void 0,ot=1,st=2,lt=new P,ct=new P,ut=N,ft=j,ht=F,dt=0,pt=U;U.all=ut,U.race=ft,U.resolve=it,U.reject=ht,U._setScheduler=s,U._setAsap=l,U._asap=K,U.prototype={constructor:U,then:nt,"catch":function(t){return this.then(null,t)}};var gt=V;V.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},V.prototype._enumerate=function(){for(var t=this.length,e=this._input,r=0;this._state===at&&t>r;r++)this._eachEntry(e[r],r)},V.prototype._eachEntry=function(t,e){var r=this._instanceConstructor,n=r.resolve;if(n===it){var i=_(t);if(i===nt&&t._state!==at)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(r===pt){var a=new r(y);M(a,t,i),this._willSettleAt(a,e)}else this._willSettleAt(new r(function(e){e(t)}),e)}else this._willSettleAt(n(t),e)},V.prototype._settledAt=function(t,e,r){var n=this.promise;n._state===at&&(this._remaining--,t===st?S(n,r):this._result[e]=r),0===this._remaining&&L(n,this._result)},V.prototype._willSettleAt=function(t,e){var r=this;C(t,void 0,function(t){r._settledAt(ot,e,t)},function(t){r._settledAt(st,e,t)})};var vt=q,mt={Promise:pt,polyfill:vt -};"function"==typeof t&&t.amd?t(function(){return mt}):"undefined"!=typeof r&&r.exports?r.exports=mt:"undefined"!=typeof this&&(this.ES6Promise=mt),vt()}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:56}],76:[function(t,e,r){"use strict";function n(t){for(var e,r=t.length,n=0;r>n;n++)if(e=t.charCodeAt(n),(9>e||e>13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(8192>e||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var r=t;if(t=+t,0===t&&n(r))return!1}else if("number"!==e)return!1;return 1>t-t}},{}],77:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.gl=t,this.type=e,this.handle=r,this.length=n,this.usage=i}function i(t,e,r,n,i,a){var o=i.length*i.BYTES_PER_ELEMENT;if(0>a)return t.bufferData(e,i,n),o;if(o+a>r)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function a(t,e){for(var r=l.malloc(t.length,e),n=t.length,i=0;n>i;++i)r[i]=t[i];return r}function o(t,e){for(var r=1,n=e.length-1;n>=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}function s(t,e,r,i){if(r=r||t.ARRAY_BUFFER,i=i||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.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(i!==t.DYNAMIC_DRAW&&i!==t.STATIC_DRAW&&i!==t.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 a=t.createBuffer(),o=new n(t,r,a,0,i);return o.update(e),o}var l=t("typedarray-pool"),c=t("ndarray-ops"),u=t("ndarray"),f=["uint8","uint8_clamped","uint16","uint32","int8","int16","int32","float32"],h=n.prototype;h.bind=function(){this.gl.bindBuffer(this.type,this.handle)},h.unbind=function(){this.gl.bindBuffer(this.type,null)},h.dispose=function(){this.gl.deleteBuffer(this.handle)},h.update=function(t,e){if("number"!=typeof e&&(e=-1),this.bind(),"object"==typeof t&&"undefined"!=typeof t.shape){var r=t.dtype;if(f.indexOf(r)<0&&(r="float32"),this.type===this.gl.ELEMENT_ARRAY_BUFFER){var n=gl.getExtension("OES_element_index_uint");r=n&&"uint16"!==r?"uint32":"uint16"}if(r===t.dtype&&o(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=i(this.gl,this.type,this.length,this.usage,t.data,e):this.length=i(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=l.malloc(t.size,r),h=u(s,t.shape);c.assign(h,t),0>e?this.length=i(this.gl,this.type,this.length,this.usage,s,e):this.length=i(this.gl,this.type,this.length,this.usage,s.subarray(0,t.size),e),l.free(s)}}else if(Array.isArray(t)){var d;d=this.type===this.gl.ELEMENT_ARRAY_BUFFER?a(t,"uint16"):a(t,"float32"),0>e?this.length=i(this.gl,this.type,this.length,this.usage,d,e):this.length=i(this.gl,this.type,this.length,this.usage,d.subarray(0,t.length),e),l.free(d)}else if("object"==typeof t&&"number"==typeof t.length)this.length=i(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");t=0|t,0>=t&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=s},{ndarray:212,"ndarray-ops":211,"typedarray-pool":237}],78:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.shader=e,this.buffer=r,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.color=[0,0,0,1]}function i(t,e){var r=a(t.gl,l.vertex,l.fragment),i=o(t.gl),s=new n(t,r,i);return s.update(e),t.addObject(s),s}var a=t("gl-shader"),o=t("gl-buffer"),s=t("typedarray-pool"),l=t("./lib/shaders");e.exports=i;var c=[[1,0,0,1,0,0],[1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,1,0,0],[1,0,0,1,0,0],[1,0,-1,0,0,1],[1,0,-1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,1],[1,0,-1,0,0,1],[-1,0,-1,0,0,1],[-1,0,-1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,1],[-1,0,-1,0,0,1],[0,1,1,0,0,0],[0,1,-1,0,0,0],[0,-1,-1,0,0,0],[0,-1,-1,0,0,0],[0,1,1,0,0,0],[0,-1,1,0,0,0],[0,1,0,-1,1,0],[0,1,0,-1,-1,0],[0,1,0,1,-1,0],[0,1,0,1,1,0],[0,1,0,-1,1,0],[0,1,0,1,-1,0],[0,-1,0,-1,1,0],[0,-1,0,-1,-1,0],[0,-1,0,1,-1,0],[0,-1,0,1,1,0],[0,-1,0,-1,1,0],[0,-1,0,1,-1,0]],u=n.prototype;u.draw=function(){var t=[1,0,0,0,1,0,0,0,1],e=[1,1];return function(){var r=this.plot,n=this.shader,i=this.buffer,a=this.bounds,o=this.numPoints;if(o){var s=r.gl,l=r.dataBox,u=r.viewBox,f=r.pixelRatio,h=a[2]-a[0],d=a[3]-a[1],p=l[2]-l[0],g=l[3]-l[1];t[0]=2*h/p,t[4]=2*d/g,t[6]=2*(a[0]-l[0])/p-1,t[7]=2*(a[1]-l[1])/g-1;var v=u[2]-u[0],m=u[3]-u[1];e[0]=2*f/v,e[1]=2*f/m,i.bind(),n.bind(),n.uniforms.viewTransform=t,n.uniforms.pixelScale=e,n.uniforms.color=this.color,n.attributes.position.pointer(s.FLOAT,!1,16,0),n.attributes.pixelOffset.pointer(s.FLOAT,!1,16,8),s.drawArrays(s.TRIANGLES,0,o*c.length)}}}(),u.drawPick=function(t){return t},u.pick=function(t,e){return null},u.update=function(t){t=t||{};var e,r,n,i=t.positions||[],a=t.errors||[],o=1;"lineWidth"in t&&(o=+t.lineWidth);var l=5;"capSize"in t&&(l=+t.capSize),this.color=(t.color||[0,0,0,1]).slice();var u=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=this.numPoints=i.length>>1;for(e=0;f>e;++e)r=i[2*e],n=i[2*e+1],u[0]=Math.min(r,u[0]),u[1]=Math.min(n,u[1]),u[2]=Math.max(r,u[2]),u[3]=Math.max(n,u[3]);u[2]===u[0]&&(u[2]+=1),u[3]===u[1]&&(u[3]+=1);var h=1/(u[2]-u[0]),d=1/(u[3]-u[1]),p=u[0],g=u[1],v=s.mallocFloat32(f*c.length*4),m=0;for(e=0;f>e;++e){r=i[2*e],n=i[2*e+1];for(var y=a[4*e],b=a[4*e+1],x=a[4*e+2],_=a[4*e+3],w=0;wA?A*=y:A>0&&(A*=b),0>M?M*=x:M>0&&(M*=_),v[m++]=h*(r-p+A),v[m++]=d*(n-g+M),v[m++]=o*k[2]+(l+o)*k[4],v[m++]=o*k[3]+(l+o)*k[5]}}this.buffer.update(v),s.free(v)},u.dispose=function(){this.plot.removeObject(this),this.shader.dispose(),this.buffer.dispose()}},{"./lib/shaders":79,"gl-buffer":77,"gl-shader":156,"typedarray-pool":237}],79:[function(t,e,r){e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 pixelOffset;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvoid main() {\n vec3 scrPosition = viewTransform * vec3(position, 1);\n gl_Position = vec4(\n scrPosition.xy + scrPosition.z * pixelScale * pixelOffset,\n 0,\n scrPosition.z);\n}\n",fragment:"precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"}},{}],80:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.shader=n,this.buffer=e,this.vao=r,this.pixelRatio=1,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.lineWidth=[1,1,1],this.capSize=[10,10,10],this.lineCount=[0,0,0],this.lineOffset=[0,0,0],this.opacity=1}function i(t,e){for(var r=0;3>r;++r)t[0][r]=Math.min(t[0][r],e[r]),t[1][r]=Math.max(t[1][r],e[r])}function a(t,e,r,n){for(var i=h[n],a=0;a=1},f.isTransparent=function(){return this.opacity<1},f.drawTransparent=f.draw=function(t){var e=this.gl,r=this.shader.uniforms;this.shader.bind();var n=r.view=t.view||u,i=r.projection=t.projection||u;r.model=t.model||u,r.clipBounds=this.clipBounds,r.opacity=this.opacity;var a=n[12],o=n[13],s=n[14],l=n[15],c=this.pixelRatio*(i[3]*a+i[7]*o+i[11]*s+i[15]*l)/e.drawingBufferHeight;this.vao.bind();for(var f=0;3>f;++f)e.lineWidth(this.lineWidth[f]),r.capSize=this.capSize[f]*c,e.drawArrays(e.LINES,this.lineOffset[f],this.lineCount[f]);this.vao.unbind()};var h=function(){for(var t=new Array(3),e=0;3>e;++e){for(var r=[],n=1;2>=n;++n)for(var i=-1;1>=i;i+=2){var a=(n+e)%3,o=[0,0,0];o[a]=i,r.push(o)}t[e]=r}return t}();f.update=function(t){t=t||{},"lineWidth"in t&&(this.lineWidth=t.lineWidth,Array.isArray(this.lineWidth)||(this.lineWidth=[this.lineWidth,this.lineWidth,this.lineWidth])),"capSize"in t&&(this.capSize=t.capSize,Array.isArray(this.capSize)||(this.capSize=[this.capSize,this.capSize,this.capSize])),"opacity"in t&&(this.opacity=t.opacity);var e=t.color||[[0,0,0],[0,0,0],[0,0,0]],r=t.position,n=t.error;if(Array.isArray(e[0])||(e=[e,e,e]),r&&n){var o=[],s=r.length,l=0;this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.lineCount=[0,0,0];for(var c=0;3>c;++c){this.lineOffset[c]=l;t:for(var u=0;s>u;++u){for(var f=r[u],h=0;3>h;++h)if(isNaN(f[h])||!isFinite(f[h]))continue t;var d=n[u],p=e[c];if(Array.isArray(p[0])&&(p=e[u]),3===p.length&&(p=[p[0],p[1],p[2],1]),!isNaN(d[0][c])&&!isNaN(d[1][c])){if(d[0][c]<0){var g=f.slice();g[c]+=d[0][c],o.push(f[0],f[1],f[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,g),l+=2+a(o,g,p,c)}if(d[1][c]>0){var g=f.slice();g[c]+=d[1][c],o.push(f[0],f[1],f[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,g),l+=2+a(o,g,p,c)}}}this.lineCount[c]=l-this.lineOffset[c]}this.buffer.update(o)}},f.dispose=function(){this.shader.dispose(),this.buffer.dispose(),this.vao.dispose()}},{"./shaders/index":81,"gl-buffer":77,"gl-vao":185}],81:[function(t,e,r){"use strict";var n=t("gl-shader"),i="precision mediump 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}",a="precision mediump float;\n#define GLSLIFY 1\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(fragPosition, clipBounds[0])) || any(greaterThan(fragPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = opacity * fragColor;\n}";e.exports=function(t){return n(t,i,a,null,[{name:"position",type:"vec3"},{name:"offset",type:"vec3"},{name:"color",type:"vec4"}])}},{"gl-shader":156}],82:[function(t,e,r){"use strict";function n(t){var e=t.getParameter(t.FRAMEBUFFER_BINDING),r=t.getParameter(t.RENDERBUFFER_BINDING),n=t.getParameter(t.TEXTURE_BINDING_2D);return[e,r,n]}function i(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function a(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);y=new Array(r+1);for(var n=0;r>=n;++n){for(var i=new Array(r),a=0;n>a;++a)i[a]=t.COLOR_ATTACHMENT0+a;for(var a=n;r>a;++a)i[a]=t.NONE;y[n]=i}}function o(t){switch(t){case p:throw new Error("gl-fbo: Framebuffer unsupported");case g:throw new Error("gl-fbo: Framebuffer incomplete attachment");case v:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case m:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function s(t,e,r,n,i,a){if(!n)return null;var o=d(t,e,r,i,n);return o.magFilter=t.NEAREST,o.minFilter=t.NEAREST,o.mipSamples=1,o.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,a,t.TEXTURE_2D,o.handle,0),o}function l(t,e,r,n,i){var a=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,a),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,a),a}function c(t){var e=n(t.gl),r=t.gl,a=t.handle=r.createFramebuffer(),c=t._shape[0],u=t._shape[1],f=t.color.length,h=t._ext,d=t._useStencil,p=t._useDepth,g=t._colorType;r.bindFramebuffer(r.FRAMEBUFFER,a);for(var v=0;f>v;++v)t.color[v]=s(r,c,u,g,r.RGBA,r.COLOR_ATTACHMENT0+v);0===f?(t._color_rb=l(r,c,u,r.RGBA4,r.COLOR_ATTACHMENT0),h&&h.drawBuffersWEBGL(y[0])):f>1&&h.drawBuffersWEBGL(y[f]);var m=r.getExtension("WEBGL_depth_texture");m?d?t.depth=s(r,c,u,m.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p&&(t.depth=s(r,c,u,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):p&&d?t._depth_rb=l(r,c,u,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p?t._depth_rb=l(r,c,u,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(t._depth_rb=l(r,c,u,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null);for(var v=0;vl;++l)this.color[l]=null;this._color_rb=null,this.depth=null,this._depth_rb=null,this._colorType=n,this._useDepth=a,this._useStencil=o;var u=this,f=[0|e,0|r];Object.defineProperties(f,{0:{get:function(){return u._shape[0]},set:function(t){return u.width=t}},1:{get:function(){return u._shape[1]},set:function(t){return u.height=t}}}),this._shapeVector=f,c(this)}function f(t,e,r){if(t._destroyed)throw new Error("gl-fbo: Can't resize destroyed FBO");if(t._shape[0]!==e||t._shape[1]!==r){var a=t.gl,s=a.getParameter(a.MAX_RENDERBUFFER_SIZE);if(0>e||e>s||0>r||r>s)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var l=n(a),c=0;ce||e>o||0>r||r>o)throw new Error("gl-fbo: Parameters are too large for FBO");n=n||{};var s=1;if("color"in n){if(s=Math.max(0|n.color,0),0>s)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(s>1){if(!i)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(s>t.getParameter(i.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+s+" draw buffers")}}var l=t.UNSIGNED_BYTE,c=t.getExtension("OES_texture_float");if(n.float&&s>0){if(!c)throw new Error("gl-fbo: Context does not support floating point textures");l=t.FLOAT}else n.preferFloat&&s>0&&c&&(l=t.FLOAT);var f=!0;"depth"in n&&(f=!!n.depth);var h=!1;return"stencil"in n&&(h=!!n.stencil),new u(t,e,r,l,s,f,h,i)}var d=t("gl-texture2d");e.exports=h;var p,g,v,m,y=null,b=u.prototype;Object.defineProperties(b,{shape:{get:function(){return this._destroyed?[0,0]:this._shapeVector},set:function(t){if(Array.isArray(t)||(t=[0|t,0|t]),2!==t.length)throw new Error("gl-fbo: Shape vector must be length 2");var e=0|t[0],r=0|t[1];return f(this,e,r),[e,r]},enumerable:!1},width:{get:function(){return this._destroyed?0:this._shape[0]},set:function(t){return t=0|t,f(this,t,this._shape[1]),t},enumerable:!1},height:{get:function(){return this._destroyed?0:this._shape[1]},set:function(t){return t=0|t,f(this,this._shape[0],t),t},enumerable:!1}}),b.bind=function(){if(!this._destroyed){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,this.handle),t.viewport(0,0,this._shape[0],this._shape[1])}},b.dispose=function(){if(!this._destroyed){this._destroyed=!0;var t=this.gl;t.deleteFramebuffer(this.handle),this.handle=null,this.depth&&(this.depth.dispose(),this.depth=null),this._depth_rb&&(t.deleteRenderbuffer(this._depth_rb),this._depth_rb=null);for(var e=0;e2&&!this.usingDashes){var C=this.mitreShader;C.bind();var z=C.uniforms;z.matrix=t,z.color=s,z.screenShape=e,z.radius=l*p,C.attributes.p.pointer(f.FLOAT,!1,48,0),f.drawArrays(f.POINTS,0,u/3|0)}}}}(),h.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0],r=[0,0,0,0];return function(n){var i=this.plot,a=this.pickShader,o=this.lineBuffer,s=this.pickBuffer,l=this.width,c=this.numPoints,u=this.bounds,f=this.vertCount,h=i.gl,d=i.viewBox,p=i.dataBox,g=i.pickPixelRatio,v=u[2]-u[0],m=u[3]-u[1],y=p[2]-p[0],b=p[3]-p[1],x=d[2]-d[0],_=d[3]-d[1];if(this.pickOffset=n,!f)return n+c;t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(u[0]-p[0])/y-1,t[7]=2*(u[1]-p[1])/b-1,e[0]=x,e[1]=_,r[0]=255&n,r[1]=n>>>8&255,r[2]=n>>>16&255,r[3]=n>>>24,a.bind();var w=a.uniforms;w.matrix=t,w.width=l*g,w.pickOffset=r,w.screenShape=e;var k=a.attributes;return o.bind(),k.a.pointer(h.FLOAT,!1,16,0),k.d.pointer(h.FLOAT,!1,16,8),s.bind(),k.pick0.pointer(h.UNSIGNED_BYTE,!1,8,0),k.pick1.pointer(h.UNSIGNED_BYTE,!1,8,4),h.drawArrays(h.TRIANGLES,0,f),n+c}}(),h.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.data;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},h.update=function(t){t=t||{};var e=this.plot.gl;!!t.connectGaps;this.color=(t.color||[0,0,1,1]).slice(),this.width=+(t.width||1),this.fill=(t.fill||[!1,!1,!1,!1]).slice(),this.fillColor=i(t.fillColor||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]);for(var r=t.dashes||[1],n=0,a=0;a1,this.dashPattern=l(e,c(o,[n,1,4],[1,0,0])),this.dashPattern.minFilter=e.NEAREST,this.dashPattern.magFilter=e.NEAREST,this.dashLength=n,u.free(o);var d=t.positions;this.data=d;var p=this.bounds;p[0]=p[1]=1/0,p[2]=p[3]=-(1/0);var g=this.numPoints=d.length>>>1;if(0!==g){for(var a=0;g>a;++a){var v=d[2*a],m=d[2*a+1];isNaN(v)||isNaN(m)||(p[0]=Math.min(p[0],v),p[1]=Math.min(p[1],m),p[2]=Math.max(p[2],v),p[3]=Math.max(p[3],m))}p[0]===p[2]&&(p[2]+=1),p[3]===p[1]&&(p[3]+=1);for(var y=u.mallocFloat32(24*(g-1)),b=u.mallocUint32(12*(g-1)),x=y.length,_=b.length,s=g,w=0;s>1;){var k=--s,v=d[2*s],m=d[2*s+1],A=k-1,M=d[2*A],T=d[2*A+1];if(!(isNaN(v)||isNaN(m)||isNaN(M)||isNaN(T))){w+=1,v=(v-p[0])/(p[2]-p[0]),m=(m-p[1])/(p[3]-p[1]),M=(M-p[0])/(p[2]-p[0]),T=(T-p[1])/(p[3]-p[1]);var E=M-v,L=T-m,S=k|1<<24,C=k-1,z=k,P=k-1|1<<24;y[--x]=-L,y[--x]=-E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=-L,y[--x]=-E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=L,y[--x]=E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=-L,y[--x]=-E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C}}this.vertCount=6*w,this.lineBuffer.update(y.subarray(x)),this.pickBuffer.update(b.subarray(_)),u.free(y),u.free(b)}},h.dispose=function(){this.plot.removeObject(this),this.lineBuffer.dispose(),this.pickBuffer.dispose(),this.lineShader.dispose(),this.mitreShader.dispose(),this.fillShader.dispose(),this.pickShader.dispose(),this.dashPattern.dispose()}},{"./lib/shaders":83,"gl-buffer":77,"gl-shader":156,"gl-texture2d":181,ndarray:212,"typedarray-pool":237}],85:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, nextPosition;\nattribute float arcLength, lineWidth;\nattribute vec4 color;\n\nuniform vec2 screenShape;\nuniform float pixelRatio;\nuniform mat4 model, view, projection;\n\nvarying vec4 fragColor;\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\n\nvoid main() {\n vec4 projected = projection * view * model * vec4(position, 1.0);\n vec4 tangentClip = projection * view * model * vec4(nextPosition - position, 0.0);\n vec2 tangent = normalize(screenShape * tangentClip.xy);\n vec2 offset = 0.5 * pixelRatio * lineWidth * vec2(tangent.y, -tangent.x) / screenShape;\n\n gl_Position = vec4(projected.xy + projected.w * offset, projected.zw);\n\n worldPosition = position;\n pixelArcLength = arcLength;\n fragColor = color;\n}\n",a="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\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",o="precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1_0(highp float v) {\n highp 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 highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp 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 highp 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\n\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId/255.0, encode_float_1_0(pixelArcLength).xyz);\n}",s=[{ -name:"position",type:"vec3"},{name:"nextPosition",type:"vec3"},{name:"arcLength",type:"float"},{name:"lineWidth",type:"float"},{name:"color",type:"vec4"}];r.createShader=function(t){return n(t,i,a,null,s)},r.createPickShader=function(t){return n(t,i,o,null,s)}},{"gl-shader":156}],86:[function(t,e,r){"use strict";function n(t,e){for(var r=0,n=0;3>n;++n){var i=t[n]-e[n];r+=i*i}return Math.sqrt(r)}function i(t){for(var e=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],r=0;3>r;++r)e[0][r]=Math.max(t[0][r],e[0][r]),e[1][r]=Math.min(t[1][r],e[1][r]);return e}function a(t,e,r,n){this.arcLength=t,this.position=e,this.index=r,this.dataCoordinate=n}function o(t,e,r,n,i,a){this.gl=t,this.shader=e,this.pickShader=r,this.buffer=n,this.vao=i,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.points=[],this.arcLength=[],this.vertexCount=0,this.bounds=[[0,0,0],[0,0,0]],this.pickId=0,this.lineWidth=1,this.texture=a,this.dashScale=1,this.opacity=1,this.dirty=!0,this.pixelRatio=1}function s(t){var e=t.gl||t.scene&&t.scene.gl,r=g(e);r.attributes.position.location=0,r.attributes.nextPosition.location=1,r.attributes.arcLength.location=2,r.attributes.lineWidth.location=3,r.attributes.color.location=4;var n=v(e);n.attributes.position.location=0,n.attributes.nextPosition.location=1,n.attributes.arcLength.location=2,n.attributes.lineWidth.location=3,n.attributes.color.location=4;for(var i=l(e),a=c(e,[{buffer:i,size:3,offset:0,stride:48},{buffer:i,size:3,offset:12,stride:48},{buffer:i,size:1,offset:24,stride:48},{buffer:i,size:1,offset:28,stride:48},{buffer:i,size:4,offset:32,stride:48}]),s=d(new Array(1024),[256,1,4]),f=0;1024>f;++f)s.data[f]=255;var h=u(e,s);h.wrap=e.REPEAT;var p=new o(e,r,n,i,a,h);return p.update(t),p}e.exports=s;var l=t("gl-buffer"),c=t("gl-vao"),u=t("gl-texture2d"),f=t("glsl-read-float"),h=t("binary-search-bounds"),d=t("ndarray"),p=t("./lib/shaders"),g=p.createShader,v=p.createPickShader,m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],y=o.prototype;y.isTransparent=function(){return this.opacity<1},y.isOpaque=function(){return this.opacity>=1},y.pickSlots=1,y.setPickBase=function(t){this.pickId=t},y.drawTransparent=y.draw=function(t){var e=this.gl,r=this.shader,n=this.vao;r.bind(),r.uniforms={model:t.model||m,view:t.view||m,projection:t.projection||m,clipBounds:i(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},y.drawPick=function(t){var e=this.gl,r=this.pickShader,n=this.vao;r.bind(),r.uniforms={model:t.model||m,view:t.view||m,projection:t.projection||m,pickId:this.pickId,clipBounds:i(this.clipBounds),screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},y.update=function(t){var e,r;this.dirty=!0;var i=!!t.connectGaps;"dashScale"in t&&(this.dashScale=t.dashScale),"opacity"in t&&(this.opacity=+t.opacity);var a=t.position||t.positions;if(a){var o=t.color||t.colors||[0,0,0,1],s=t.lineWidth||1,l=[],c=[],u=[],f=0,p=0,g=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],v=!1;t:for(e=1;er;++r){if(isNaN(m[r])||isNaN(y[r])||!isFinite(m[r])||!isFinite(y[r])){if(!i&&l.length>0){for(var b=0;24>b;++b)l.push(l[l.length-12]);p+=2,v=!0}continue t}g[0][r]=Math.min(g[0][r],m[r],y[r]),g[1][r]=Math.max(g[1][r],m[r],y[r])}var x,_;Array.isArray(o[0])?(x=o[e-1],_=o[e]):x=_=o,3===x.length&&(x=[x[0],x[1],x[2],1]),3===_.length&&(_=[_[0],_[1],_[2],1]);var w;w=Array.isArray(s)?s[e-1]:s;var k=f;if(f+=n(m,y),v){for(r=0;2>r;++r)l.push(m[0],m[1],m[2],y[0],y[1],y[2],k,w,x[0],x[1],x[2],x[3]);p+=2,v=!1}l.push(m[0],m[1],m[2],y[0],y[1],y[2],k,w,x[0],x[1],x[2],x[3],m[0],m[1],m[2],y[0],y[1],y[2],k,-w,x[0],x[1],x[2],x[3],y[0],y[1],y[2],m[0],m[1],m[2],f,-w,_[0],_[1],_[2],_[3],y[0],y[1],y[2],m[0],m[1],m[2],f,w,_[0],_[1],_[2],_[3]),p+=4}if(this.buffer.update(l),c.push(f),u.push(a[a.length-1].slice()),this.bounds=g,this.vertexCount=p,this.points=u,this.arcLength=c,"dashes"in t){var A=t.dashes,M=A.slice();for(M.unshift(0),e=1;ee;++e){for(r=0;4>r;++r)T.set(e,0,r,0);1&h.le(M,M[M.length-1]*e/255)?T.set(e,0,0,0):T.set(e,0,0,255)}this.texture.setPixels(T)}}},y.dispose=function(){this.shader.dispose(),this.vao.dispose(),this.buffer.dispose()},y.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=f(t.value[0],t.value[1],t.value[2],0),r=h.le(this.arcLength,e);if(0>r)return null;if(r===this.arcLength.length-1)return new a(this.arcLength[this.arcLength.length-1],this.points[this.points.length-1].slice(),r);for(var n=this.points[r],i=this.points[Math.min(r+1,this.points.length-1)],o=(e-this.arcLength[r])/(this.arcLength[r+1]-this.arcLength[r]),s=1-o,l=[0,0,0],c=0;3>c;++c)l[c]=s*n[c]+o*i[c];var u=Math.min(.5>o?r:r+1,this.points.length-1);return new a(e,l,u,this.points[u])}},{"./lib/shaders":85,"binary-search-bounds":87,"gl-buffer":77,"gl-texture2d":181,"gl-vao":185,"glsl-read-float":88,ndarray:212}],87:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],88:[function(t,e,r){function n(t,e,r,n){return i[0]=n,i[1]=r,i[2]=e,i[3]=t,a[0]}e.exports=n;var i=new Uint8Array(4),a=new Float32Array(i.buffer)},{}],89:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=u*o-s*c,h=-u*a+s*l,d=c*a-o*l,p=r*f+n*h+i*d;return p?(p=1/p,t[0]=f*p,t[1]=(-u*n+i*c)*p,t[2]=(s*n-i*o)*p,t[3]=h*p,t[4]=(u*r-i*l)*p,t[5]=(-s*r+i*a)*p,t[6]=d*p,t[7]=(-c*r+n*l)*p,t[8]=(o*r-n*a)*p,t):null}e.exports=n},{}],90:[function(t,e,r){function n(t){var e=new Float32Array(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}e.exports=n},{}],91:[function(t,e,r){function n(){var t=new Float32Array(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],92:[function(t,e,r){function n(t){var e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],c=t[8],u=t[9],f=t[10],h=t[11],d=t[12],p=t[13],g=t[14],v=t[15],m=e*o-r*a,y=e*s-n*a,b=e*l-i*a,x=r*s-n*o,_=r*l-i*o,w=n*l-i*s,k=c*p-u*d,A=c*g-f*d,M=c*v-h*d,T=u*g-f*p,E=u*v-h*p,L=f*v-h*g;return m*L-y*E+b*T+x*M-_*A+w*k}e.exports=n},{}],93:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r+r,s=n+n,l=i+i,c=r*o,u=n*o,f=n*s,h=i*o,d=i*s,p=i*l,g=a*o,v=a*s,m=a*l;return t[0]=1-f-p,t[1]=u+m,t[2]=h-v,t[3]=0,t[4]=u-m,t[5]=1-c-p,t[6]=d+g,t[7]=0,t[8]=h+v,t[9]=d-g,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],94:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=n+n,l=i+i,c=a+a,u=n*s,f=n*l,h=n*c,d=i*l,p=i*c,g=a*c,v=o*s,m=o*l,y=o*c;return t[0]=1-(d+g),t[1]=f+y,t[2]=h-m,t[3]=0,t[4]=f-y,t[5]=1-(u+g),t[6]=p+v,t[7]=0,t[8]=h+m,t[9]=p-v,t[10]=1-(u+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}e.exports=n},{}],95:[function(t,e,r){function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],96:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],g=e[13],v=e[14],m=e[15],y=r*s-n*o,b=r*l-i*o,x=r*c-a*o,_=n*l-i*s,w=n*c-a*s,k=i*c-a*l,A=u*g-f*p,M=u*v-h*p,T=u*m-d*p,E=f*v-h*g,L=f*m-d*g,S=h*m-d*v,C=y*S-b*L+x*E+_*T-w*M+k*A;return C?(C=1/C,t[0]=(s*S-l*L+c*E)*C,t[1]=(i*L-n*S-a*E)*C,t[2]=(g*k-v*w+m*_)*C,t[3]=(h*w-f*k-d*_)*C,t[4]=(l*T-o*S-c*M)*C,t[5]=(r*S-i*T+a*M)*C,t[6]=(v*x-p*k-m*b)*C,t[7]=(u*k-h*x+d*b)*C,t[8]=(o*L-s*T+c*A)*C,t[9]=(n*T-r*L-a*A)*C,t[10]=(p*w-g*x+m*y)*C,t[11]=(f*x-u*w-d*y)*C,t[12]=(s*M-o*E-l*A)*C,t[13]=(r*E-n*M+i*A)*C,t[14]=(g*b-p*_-v*y)*C,t[15]=(u*_-f*b+h*y)*C,t):null}e.exports=n},{}],97:[function(t,e,r){function n(t,e,r,n){var a,o,s,l,c,u,f,h,d,p,g=e[0],v=e[1],m=e[2],y=n[0],b=n[1],x=n[2],_=r[0],w=r[1],k=r[2];return Math.abs(g-_)<1e-6&&Math.abs(v-w)<1e-6&&Math.abs(m-k)<1e-6?i(t):(f=g-_,h=v-w,d=m-k,p=1/Math.sqrt(f*f+h*h+d*d),f*=p,h*=p,d*=p,a=b*d-x*h,o=x*f-y*d,s=y*h-b*f,p=Math.sqrt(a*a+o*o+s*s),p?(p=1/p,a*=p,o*=p,s*=p):(a=0,o=0,s=0),l=h*s-d*o,c=d*a-f*s,u=f*o-h*a,p=Math.sqrt(l*l+c*c+u*u),p?(p=1/p,l*=p,c*=p,u*=p):(l=0,c=0,u=0),t[0]=a,t[1]=l,t[2]=f,t[3]=0,t[4]=o,t[5]=c,t[6]=h,t[7]=0,t[8]=s,t[9]=u,t[10]=d,t[11]=0,t[12]=-(a*g+o*v+s*m),t[13]=-(l*g+c*v+u*m),t[14]=-(f*g+h*v+d*m),t[15]=1,t)}var i=t("./identity");e.exports=n},{"./identity":95}],98:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],g=e[12],v=e[13],m=e[14],y=e[15],b=r[0],x=r[1],_=r[2],w=r[3];return t[0]=b*n+x*s+_*f+w*g,t[1]=b*i+x*l+_*h+w*v,t[2]=b*a+x*c+_*d+w*m,t[3]=b*o+x*u+_*p+w*y,b=r[4],x=r[5],_=r[6],w=r[7],t[4]=b*n+x*s+_*f+w*g,t[5]=b*i+x*l+_*h+w*v,t[6]=b*a+x*c+_*d+w*m,t[7]=b*o+x*u+_*p+w*y,b=r[8],x=r[9],_=r[10],w=r[11],t[8]=b*n+x*s+_*f+w*g,t[9]=b*i+x*l+_*h+w*v,t[10]=b*a+x*c+_*d+w*m,t[11]=b*o+x*u+_*p+w*y,b=r[12],x=r[13],_=r[14],w=r[15],t[12]=b*n+x*s+_*f+w*g,t[13]=b*i+x*l+_*h+w*v,t[14]=b*a+x*c+_*d+w*m,t[15]=b*o+x*u+_*p+w*y,t}e.exports=n},{}],99:[function(t,e,r){function n(t,e,r,n,i){var a=1/Math.tan(e/2),o=1/(n-i);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+n)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*n*o,t[15]=0,t}e.exports=n},{}],100:[function(t,e,r){function n(t,e,r,n){var i,a,o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w,k,A,M,T,E,L=n[0],S=n[1],C=n[2],z=Math.sqrt(L*L+S*S+C*C);return Math.abs(z)<1e-6?null:(z=1/z,L*=z,S*=z,C*=z,i=Math.sin(r),a=Math.cos(r),o=1-a,s=e[0],l=e[1],c=e[2],u=e[3],f=e[4],h=e[5],d=e[6],p=e[7],g=e[8],v=e[9],m=e[10],y=e[11],b=L*L*o+a,x=S*L*o+C*i,_=C*L*o-S*i,w=L*S*o-C*i,k=S*S*o+a,A=C*S*o+L*i,M=L*C*o+S*i,T=S*C*o-L*i,E=C*C*o+a,t[0]=s*b+f*x+g*_,t[1]=l*b+h*x+v*_,t[2]=c*b+d*x+m*_,t[3]=u*b+p*x+y*_,t[4]=s*w+f*k+g*A,t[5]=l*w+h*k+v*A,t[6]=c*w+d*k+m*A,t[7]=u*w+p*k+y*A,t[8]=s*M+f*T+g*E,t[9]=l*M+h*T+v*E,t[10]=c*M+d*T+m*E,t[11]=u*M+p*T+y*E,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}e.exports=n},{}],101:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+c*n,t[5]=o*i+u*n,t[6]=s*i+f*n,t[7]=l*i+h*n,t[8]=c*i-a*n,t[9]=u*i-o*n,t[10]=f*i-s*n,t[11]=h*i-l*n,t}e.exports=n},{}],102:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i-c*n,t[1]=o*i-u*n,t[2]=s*i-f*n,t[3]=l*i-h*n,t[8]=a*n+c*i,t[9]=o*n+u*i,t[10]=s*n+f*i,t[11]=l*n+h*i,t}e.exports=n},{}],103:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[4],u=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+c*n,t[1]=o*i+u*n,t[2]=s*i+f*n,t[3]=l*i+h*n,t[4]=c*i-a*n,t[5]=u*i-o*n,t[6]=f*i-s*n,t[7]=h*i-l*n,t}e.exports=n},{}],104:[function(t,e,r){function n(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}e.exports=n},{}],105:[function(t,e,r){function n(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g=r[0],v=r[1],m=r[2];return e===t?(t[12]=e[0]*g+e[4]*v+e[8]*m+e[12],t[13]=e[1]*g+e[5]*v+e[9]*m+e[13],t[14]=e[2]*g+e[6]*v+e[10]*m+e[14],t[15]=e[3]*g+e[7]*v+e[11]*m+e[15]):(n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],t[0]=n,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=c,t[7]=u,t[8]=f,t[9]=h,t[10]=d,t[11]=p,t[12]=n*g+s*v+f*m+e[12],t[13]=i*g+l*v+h*m+e[13],t[14]=a*g+c*v+d*m+e[14],t[15]=o*g+u*v+p*m+e[15]),t}e.exports=n},{}],106:[function(t,e,r){function n(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],a=e[6],o=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=a,t[11]=e[14],t[12]=i,t[13]=o,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}e.exports=n},{}],107:[function(t,e,r){"use strict";function n(t,e){for(var r=[0,0,0,0],n=0;4>n;++n)for(var i=0;4>i;++i)r[i]+=t[4*n+i]*e[n];return r}function i(t,e,r,i,a){for(var o=n(i,n(r,n(e,[t[0],t[1],t[2],1]))),s=0;3>s;++s)o[s]/=o[3];return[.5*a[0]*(1+o[0]),.5*a[1]*(1-o[1])]}function a(t,e){if(2===t.length){for(var r=0,n=0,i=0;2>i;++i)r+=Math.pow(e[i]-t[0][i],2),n+=Math.pow(e[i]-t[1][i],2);return r=Math.sqrt(r),n=Math.sqrt(n),1e-6>r+n?[1,0]:[n/(r+n),r/(n+r)]}if(3===t.length){var a=[0,0];return c(t[0],t[1],t[2],e,a),l(t,a)}return[]}function o(t,e){for(var r=[0,0,0],n=0;no;++o)r[o]+=a*i[o];return r}function s(t,e,r,n,s,l){if(1===t.length)return[0,t[0].slice()];for(var c=new Array(t.length),u=0;up;++p)d+=Math.pow(c[u][p]-e[p],2);h>d&&(h=d,f=u)}for(var g=a(c,e),v=0,u=0;3>u;++u){if(g[u]<-.001||g[u]>1.0001)return null;v+=g[u]}return Math.abs(v-1)>.001?null:[f,o(t,g),g]}var l=t("barycentric"),c=t("polytope-closest-point/lib/closest_point_2d.js");e.exports=s},{barycentric:110,"polytope-closest-point/lib/closest_point_2d.js":112}],108:[function(t,e,r){var n="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\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\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}",i="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(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\n\n\nfloat cookTorranceSpecular_1_1(\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_2_0(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\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\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(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\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 = cookTorranceSpecular_1_1(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}",a="precision mediump 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}",o="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}",s="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(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}",l="precision mediump 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}",c="precision mediump 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}",u="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if(any(lessThan(f_position, clipBounds[0])) || \n any(greaterThan(f_position, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId, f_id.xyz);\n}",f="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(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}",h="precision mediump 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}",d="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n";r.meshShader={vertex:n,fragment:i,attributes:[{name:"position",type:"vec3"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.wireShader={vertex:a,fragment:o,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.pointShader={vertex:s,fragment:l,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]},r.pickShader={vertex:c,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]},r.pointPickShader={vertex:f,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]},r.contourShader={vertex:h,fragment:d,attributes:[{name:"position",type:"vec3"}]}},{}],109:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w,k,A,M,T){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleColors=u,this.triangleNormals=h,this.triangleUVs=f,this.triangleIds=c,this.triangleVAO=d,this.triangleCount=0,this.lineWidth=1,this.edgePositions=p,this.edgeColors=v,this.edgeUVs=m,this.edgeIds=g,this.edgeVAO=y,this.edgeCount=0,this.pointPositions=b,this.pointColors=_,this.pointUVs=w,this.pointSizes=k,this.pointIds=x,this.pointVAO=A,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=M,this.contourVAO=T,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!0,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this._model=R,this._view=R,this._projection=R,this._resolution=[1,1]}function i(t){for(var e=w({colormap:t,nshades:256,format:"rgba"}),r=new Uint8Array(1024),n=0;256>n;++n){for(var i=e[n],a=0;3>a;++a)r[4*n+a]=i[a];r[4*n+3]=255*i[3]}return _(r,[256,256,4],[4,0,1])}function a(t,e,r){for(var n=new Array(e),i=0;e>i;++i)n[i]=0;for(var a=t.length,i=0;a>i;++i)for(var o=t[i],s=0;sn;++n)r[n]=t[n][2];return r}function s(t){var e=p(t,E);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.normal.location=4,e}function l(t){var e=p(t,L);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e}function c(t){var e=p(t,S);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.pointSize.location=4,e}function u(t){var e=p(t,C);return e.attributes.position.location=0,e.attributes.id.location=1,e}function f(t){var e=p(t,z);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.pointSize.location=4,e}function h(t){var e=p(t,P);return e.attributes.position.location=0,e}function d(t){var e=t.gl,r=s(e),i=l(e),a=c(e),o=u(e),d=f(e),p=h(e),y=m(e,_(new Uint8Array([255,255,255,255]),[1,1,4]));y.generateMipmap(),y.minFilter=e.LINEAR_MIPMAP_LINEAR,y.magFilter=e.LINEAR;var b=g(e),x=g(e),w=g(e),k=g(e),A=g(e),M=v(e,[{buffer:b,type:e.FLOAT,size:3},{buffer:A,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:x,type:e.FLOAT,size:4},{buffer:w,type:e.FLOAT,size:2},{buffer:k,type:e.FLOAT,size:3}]),T=g(e),E=g(e),L=g(e),S=g(e),C=v(e,[{buffer:T,type:e.FLOAT,size:3},{buffer:S,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:E,type:e.FLOAT,size:4},{buffer:L,type:e.FLOAT,size:2}]),z=g(e),P=g(e),R=g(e),O=g(e),I=g(e),N=v(e,[{buffer:z,type:e.FLOAT,size:3},{buffer:I,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:P,type:e.FLOAT,size:4},{buffer:R,type:e.FLOAT,size:2},{buffer:O,type:e.FLOAT,size:1}]),j=g(e),F=v(e,[{buffer:j,type:e.FLOAT,size:3}]),D=new n(e,y,r,i,a,o,d,p,b,A,x,w,k,M,T,S,E,L,C,z,I,P,R,O,N,j,F);return D.update(t),D}var p=t("gl-shader"),g=t("gl-buffer"),v=t("gl-vao"),m=t("gl-texture2d"),y=t("normals"),b=t("gl-mat4/multiply"),x=t("gl-mat4/invert"),_=t("ndarray"),w=t("colormap"),k=t("simplicial-complex-contour"),A=t("typedarray-pool"),M=t("./lib/shaders"),T=t("./lib/closest-point"),E=M.meshShader,L=M.wireShader,S=M.pointShader,C=M.pickShader,z=M.pointPickShader,P=M.contourShader,R=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],O=n.prototype;O.isOpaque=function(){return this.opacity>=1},O.isTransparent=function(){return this.opacity<1},O.pickSlots=1,O.setPickBase=function(t){this.pickId=t},O.highlight=function(t){if(!t||!this.contourEnable)return void(this.contourCount=0);for(var e=k(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=A.mallocFloat32(6*a),s=0,l=0;a>l;++l)for(var c=r[l],u=0;2>u;++u){var f=c[0];2===c.length&&(f=c[u]);for(var h=n[f][0],d=n[f][1],p=i[f],g=1-p,v=this.positions[h],m=this.positions[d],y=0;3>y;++y)o[s++]=p*v[y]+g*m[y]}this.contourCount=s/3|0,this.contourPositions.update(o.subarray(0,s)),A.free(o)},O.update=function(t){t=t||{};var e=this.gl;this.dirty=!0,"contourEnable"in t&&(this.contourEnable=t.contourEnable),"contourColor"in t&&(this.contourColor=t.contourColor),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"opacity"in t&&(this.opacity=t.opacity),t.texture?(this.texture.dispose(),this.texture=m(e,t.texture)):t.colormap&&(this.texture.shape=[256,256],this.texture.minFilter=e.LINEAR_MIPMAP_LINEAR,this.texture.magFilter=e.LINEAR,this.texture.setPixels(i(t.colormap)),this.texture.generateMipmap());var r=t.cells,n=t.positions;if(n&&r){var s=[],l=[],c=[],u=[],f=[],h=[],d=[],p=[],g=[],v=[],b=[],x=[],_=[],w=[];this.cells=r,this.positions=n;var k=t.vertexNormals,A=t.cellNormals;t.useFacetNormals&&!A&&(A=y.faceNormals(r,n)),A||k||(k=y.vertexNormals(r,n));var M=t.vertexColors,T=t.cellColors,E=t.meshColor||[1,1,1,1],L=t.vertexUVs,S=t.vertexIntensity,C=t.cellUVs,z=t.cellIntensity,P=1/0,R=-(1/0);if(!L&&!C)if(S)for(var O=0;OD;++D)!isNaN(F[D])&&isFinite(F[D])&&(this.bounds[0][D]=Math.min(this.bounds[0][D],F[D]),this.bounds[1][D]=Math.max(this.bounds[1][D],F[D]));var B=0,U=0,V=0;t:for(var O=0;OD;++D)if(isNaN(F[D])||!isFinite(F[D]))continue t;v.push(F[0],F[1],F[2]);var G;G=M?M[H]:T?T[O]:E,3===G.length?b.push(G[0],G[1],G[2],1):b.push(G[0],G[1],G[2],G[3]);var Y;Y=L?L[H]:S?[(S[H]-P)/(R-P),0]:C?C[O]:z?[(z[O]-P)/(R-P),0]:[(F[2]-P)/(R-P),0],x.push(Y[0],Y[1]),N?_.push(N[H]):_.push(j),w.push(O),V+=1;break;case 2:for(var D=0;2>D;++D)for(var H=q[D],F=n[H],X=0;3>X;++X)if(isNaN(F[X])||!isFinite(F[X]))continue t;for(var D=0;2>D;++D){var H=q[D],F=n[H];h.push(F[0],F[1],F[2]);var G;G=M?M[H]:T?T[O]:E,3===G.length?d.push(G[0],G[1],G[2],1):d.push(G[0],G[1],G[2],G[3]);var Y;Y=L?L[H]:S?[(S[H]-P)/(R-P),0]:C?C[O]:z?[(z[O]-P)/(R-P),0]:[(F[2]-P)/(R-P),0],p.push(Y[0],Y[1]),g.push(O)}U+=1;break;case 3:for(var D=0;3>D;++D)for(var H=q[D],F=n[H],X=0;3>X;++X)if(isNaN(F[X])||!isFinite(F[X]))continue t;for(var D=0;3>D;++D){var H=q[D],F=n[H];s.push(F[0],F[1],F[2]);var G;G=M?M[H]:T?T[O]:E,3===G.length?l.push(G[0],G[1],G[2],1):l.push(G[0],G[1],G[2],G[3]);var Y;Y=L?L[H]:S?[(S[H]-P)/(R-P),0]:C?C[O]:z?[(z[O]-P)/(R-P),0]:[(F[2]-P)/(R-P),0],u.push(Y[0],Y[1]);var W;W=k?k[H]:A[O],c.push(W[0],W[1],W[2]),f.push(O)}B+=1}}this.pointCount=V,this.edgeCount=U,this.triangleCount=B,this.pointPositions.update(v),this.pointColors.update(b),this.pointUVs.update(x),this.pointSizes.update(_),this.pointIds.update(new Uint32Array(w)),this.edgePositions.update(h),this.edgeColors.update(d),this.edgeUVs.update(p),this.edgeIds.update(new Uint32Array(g)),this.trianglePositions.update(s),this.triangleColors.update(l),this.triangleUVs.update(u),this.triangleNormals.update(c),this.triangleIds.update(new Uint32Array(f))}},O.drawTransparent=O.draw=function(t){t=t||{};for(var e=this.gl,r=t.model||R,n=t.view||R,i=t.projection||R,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;3>o;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);var s={model:r,view:n,projection:i,clipBounds:a,kambient:this.ambientLight,kdiffuse:this.diffuseLight,kspecular:this.specularLight,roughness:this.roughness,fresnel:this.fresnel,eyePosition:[0,0,0],lightPosition:[0,0,0],opacity:this.opacity,contourColor:this.contourColor,texture:0};this.texture.bind(0);var l=new Array(16);b(l,s.view,s.model),b(l,s.projection,l),x(l,l);for(var o=0;3>o;++o)s.eyePosition[o]=l[12+o]/l[15];for(var c=l[15],o=0;3>o;++o)c+=this.lightPosition[o]*l[4*o+3];for(var o=0;3>o;++o){for(var u=l[12+o],f=0;3>f;++f)u+=l[4*f+o]*this.lightPosition[f];s.lightPosition[o]=u/c}if(this.triangleCount>0){var h=this.triShader;h.bind(),h.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()}if(this.edgeCount>0&&this.lineWidth>0){var h=this.lineShader;h.bind(),h.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()}if(this.pointCount>0){var h=this.pointShader;h.bind(),h.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}if(this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0){var h=this.contourShader;h.bind(),h.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind()}},O.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||R,n=t.view||R,i=t.projection||R,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;3>o;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s={model:r,view:n,projection:i,clipBounds:a,pickId:this.pickId/255},l=this.pickShader;if(l.bind(),l.uniforms=s,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0){var l=this.pointPickShader;l.bind(),l.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}},O.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;for(var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions,i=new Array(r.length),a=0;ao;++o){for(var s=new Array(r+1),l=0;r>=l;++l)s[l]=t[l][o];i[o]=s}i[r]=new Array(r+1);for(var o=0;r>=o;++o)i[r][o]=1;for(var c=new Array(r+1),o=0;r>o;++o)c[o]=e[o];c[r]=1;var u=a(i,c),f=n(u[r+1]);0===f&&(f=1);for(var h=new Array(r+1),o=0;r>=o;++o)h[o]=n(u[o])/f;return h}e.exports=i;var a=t("robust-linear-solve")},{"robust-linear-solve":215}],111:[function(t,e,r){var n=1e-6;r.vertexNormals=function(t,e){for(var r=e.length,i=new Array(r),a=0;r>a;++a)i[a]=[0,0,0];for(var a=0;ay;++y)p[y]=f[y]-h[y],g+=p[y]*p[y],v[y]=d[y]-h[y],m+=v[y]*v[y];if(g*m>n)for(var b=i[l],x=1/Math.sqrt(g*m),y=0;3>y;++y){var _=(y+1)%3,w=(y+2)%3;b[y]+=x*(v[_]*p[w]-v[w]*p[_])}}for(var a=0;r>a;++a){for(var b=i[a],k=0,y=0;3>y;++y)k+=b[y]*b[y];if(k>n)for(var x=1/Math.sqrt(k),y=0;3>y;++y)b[y]*=x;else for(var y=0;3>y;++y)b[y]=0}return i},r.faceNormals=function(t,e){for(var r=t.length,i=new Array(r),a=0;r>a;++a){for(var o=t[a],s=new Array(3),l=0;3>l;++l)s[l]=e[o[l]];for(var c=new Array(3),u=new Array(3),l=0;3>l;++l)c[l]=s[1][l]-s[0][l],u[l]=s[2][l]-s[0][l];for(var f=new Array(3),h=0,l=0;3>l;++l){var d=(l+1)%3,p=(l+2)%3;f[l]=c[d]*u[p]-c[p]*u[d],h+=f[l]*f[l]}h=h>n?1/Math.sqrt(h):0;for(var l=0;3>l;++l)f[l]*=h;i[a]=f}return i}},{}],112:[function(t,e,r){"use strict";function n(t,e,r,n,s){i.length=x+_)if(0>x)0>_&&0>h?(_=0,-h>=c?(x=1,y=c+2*h+p):(x=-h/c,y=h*x+p)):(x=0,d>=0?(_=0,y=p):-d>=f?(_=1,y=f+2*d+p):(_=-d/f,y=d*_+p));else if(0>_)_=0,h>=0?(x=0,y=p):-h>=c?(x=1,y=c+2*h+p):(x=-h/c,y=h*x+p);else{var w=1/b;x*=w,_*=w,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p}else{var k,A,M,T;0>x?(k=u+h,A=f+d,A>k?(M=A-k,T=c-2*u+f,M>=T?(x=1,_=0,y=c+2*h+p):(x=M/T,_=1-x,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)):(x=0,0>=A?(_=1,y=f+2*d+p):d>=0?(_=0,y=p):(_=-d/f,y=d*_+p))):0>_?(k=u+d,A=c+h,A>k?(M=A-k,T=c-2*u+f,M>=T?(_=1,x=0,y=f+2*d+p):(_=M/T,x=1-_,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)):(_=0,0>=A?(x=1,y=c+2*h+p):h>=0?(x=0,y=p):(x=-h/c,y=h*x+p))):(M=f+d-u-h,0>=M?(x=0,_=1,y=f+2*d+p):(T=c-2*u+f,M>=T?(x=1,_=0,y=c+2*h+p):(x=M/T,_=1-x,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)))}for(var E=1-x-_,l=0;ly?0:y}var i=new Float64Array(4),a=new Float64Array(4),o=new Float64Array(4);e.exports=n},{}],113:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=0,n=0;e>n;++n)r=0|Math.max(r,t[n].length);return r-1}function i(t,e){for(var r=t.length,n=f.mallocUint8(r),i=0;r>i;++i)n[i]=t[i]o;++o)for(var s=t[o],e=s.length,l=0;e>l;++l)for(var c=0;l>c;++c){var d=s[c],p=s[l];i[a++]=0|Math.min(d,p),i[a++]=0|Math.max(d,p)}var g=a/2|0;h(u(i,[g,2]));for(var v=2,o=2;a>o;o+=2)i[o-2]===i[o]&&i[o-1]===i[o+1]||(i[v++]=i[o],i[v++]=i[o+1]);return u(i,[v/2|0,2])}function o(t,e,r,n){for(var i=t.data,a=t.shape[0],o=f.mallocDouble(a),s=0,l=0;a>l;++l){var c=i[2*l],h=i[2*l+1];if(r[c]!==r[h]){var d=e[c],p=e[h];i[2*s]=c,i[2*s+1]=h,o[s++]=(p-n)/(p-d)}}return t.shape[0]=s,u(o,[s])}function s(t,e){var r=f.mallocInt32(2*e),n=t.shape[0],i=t.data;r[0]=0;for(var a=0,o=0;n>o;++o){var s=i[2*o];if(s!==a){for(r[2*a+1]=o;++ai;++i)n[i]=[r[2*i],r[2*i+1]];return n}function c(t,e,r,c){r=r||0,"undefined"==typeof c&&(c=n(t));var u=t.length;if(0===u||1>c)return{cells:[],vertexIds:[],vertexWeights:[]};var h=i(e,+r),p=a(t,c),g=o(p,e,h,+r),v=s(p,0|e.length),m=d(c)(t,p.data,v,h),y=l(p),b=[].slice.call(g.data,0,g.shape[0]);return f.free(h),f.free(p.data),f.free(g.data),f.free(v),{cells:m,vertexIds:y,vertexWeights:b}}e.exports=c;var u=t("ndarray"),f=t("typedarray-pool"),h=t("ndarray-sort"),d=t("./lib/codegen")},{"./lib/codegen":114,ndarray:212,"ndarray-sort":117,"typedarray-pool":237}],114:[function(t,e,r){"use strict";function n(t){function e(t){if(!(t.length<=0)){c.push("R.push(");for(var e=0;e0&&c.push(","),c.push("[");for(var n=0;n0&&c.push(","),c.push("B(C,E,c[",i[0],"],c[",i[1],"])")}c.push("]")}c.push(");")}}var r=0,n=new Array(t+1);n[0]=[[]];for(var i=1;t>=i;++i)for(var s=n[i]=o(i),l=0;l>1,v=E[2*m+1];","if(v===b){return m}","if(b1;--i){t+1>i&&c.push("else "),c.push("if(l===",i,"){");for(var u=[],l=0;i>l;++l)u.push("(S[c["+l+"]]<<"+l+")");c.push("var M=",u.join("+"),";if(M===0||M===",(1<i;++i)n[i]=0,i===e&&(n[i]+=.5),i===r&&(n[i]+=.5);return n}function i(t,e){if(0===e||e===(1<=a;++a)if(e&1<=s;++s)~e&1<n;++n)r[n]=i(t,n);return r}e.exports=a;var o=t("convex-hull")},{"convex-hull":61}],116:[function(t,e,r){"use strict";function n(t){switch(t){case"uint8":return[l.mallocUint8,l.freeUint8];case"uint16":return[l.mallocUint16,l.freeUint16];case"uint32":return[l.mallocUint32,l.freeUint32];case"int8":return[l.mallocInt8,l.freeInt8];case"int16":return[l.mallocInt16,l.freeInt16];case"int32":return[l.mallocInt32,l.freeInt32];case"float32":return[l.mallocFloat,l.freeFloat];case"float64":return[l.mallocDouble,l.freeDouble];default:return null}}function i(t){for(var e=[],r=0;t>r;++r)e.push("s"+r);for(var r=0;t>r;++r)e.push("n"+r);for(var r=1;t>r;++r)e.push("d"+r);for(var r=1;t>r;++r)e.push("e"+r);for(var r=1;t>r;++r)e.push("f"+r);return e}function a(t,e){function r(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function a(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}var o=["'use strict'"],s=["ndarrayInsertionSort",t.join("d"),e].join(""),l=["left","right","data","offset"].concat(i(t.length)),c=n(e),u=["i,j,cptr,ptr=left*s0+offset"];if(t.length>1){for(var f=[],h=1;h1){o.push("dptr=0;sptr=ptr");for(var h=t.length-1;h>=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"left){","dptr=0","sptr=cptr-s0");for(var h=1;hb){break __l}"].join(""));for(var h=t.length-1;h>=1;--h)o.push("sptr+=e"+h,"dptr+=f"+h,"}");o.push("dptr=cptr;sptr=cptr-s0");for(var h=t.length-1;h>=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"left)&&("+r("cptr-s0")+">scratch)){",a("cptr",r("cptr-s0")),"cptr-=s0","}",a("cptr","scratch"));if(o.push("}"),t.length>1&&c&&o.push("free(scratch)"),o.push("} return "+s),c){var p=new Function("malloc","free",o.join("\n"));return p(c[0],c[1])}var p=new Function(o.join("\n"));return p()}function o(t,e,r){function a(t){return["(offset+",t,"*s0)"].join("")}function o(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function s(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}function l(e,r,n){if(1===e.length)_.push("ptr0="+a(e[0]));else for(var i=0;i=0;--i){var o=t[i];0!==o&&_.push(["for(i",o,"=0;i",o,"1)for(var i=0;i1?_.push("ptr_shift+=d"+o):_.push("ptr0+=d"+o),_.push("}"))}}function u(e,r,n,i){if(1===r.length)_.push("ptr0="+a(r[0]));else{for(var o=0;o1)for(var o=0;o=1;--o)n&&_.push("pivot_ptr+=f"+o),r.length>1?_.push("ptr_shift+=e"+o):_.push("ptr0+=e"+o),_.push("}")}function f(){t.length>1&&A&&_.push("free(pivot1)","free(pivot2)")}function h(e,r){var n="el"+e,i="el"+r;if(t.length>1){var s="__l"+ ++M;u(s,[n,i],!1,["comp=",o("ptr0"),"-",o("ptr1"),"\n","if(comp>0){tmp0=",n,";",n,"=",i,";",i,"=tmp0;break ",s,"}\n","if(comp<0){break ",s,"}"].join(""))}else _.push(["if(",o(a(n)),">",o(a(i)),"){tmp0=",n,";",n,"=",i,";",i,"=tmp0}"].join(""))}function d(e,r){t.length>1?l([e,r],!1,s("ptr0",o("ptr1"))):_.push(s(a(e),o(a(r))))}function p(e,r,n){if(t.length>1){var i="__l"+ ++M;u(i,[r],!0,[e,"=",o("ptr0"),"-pivot",n,"[pivot_ptr]\n","if(",e,"!==0){break ",i,"}"].join(""))}else _.push([e,"=",o(a(r)),"-pivot",n].join(""))}function g(e,r){t.length>1?l([e,r],!1,["tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1","tmp")].join("")):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1","tmp")].join(""))}function v(e,r,n){t.length>1?(l([e,r,n],!1,["tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1",o("ptr2")),"\n",s("ptr2","tmp")].join("")),_.push("++"+r,"--"+n)):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","ptr2=",a(n),"\n","++",r,"\n","--",n,"\n","tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1",o("ptr2")),"\n",s("ptr2","tmp")].join(""))}function m(t,e){g(t,e),_.push("--"+e)}function y(e,r,n){t.length>1?l([e,r],!0,[s("ptr0",o("ptr1")),"\n",s("ptr1",["pivot",n,"[pivot_ptr]"].join(""))].join("")):_.push(s(a(e),o(a(r))),s(a(r),"pivot"+n))}function b(e,r){_.push(["if((",r,"-",e,")<=",c,"){\n","insertionSort(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}else{\n",w,"(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}"].join(""))}function x(e,r,n){t.length>1?(_.push(["__l",++M,":while(true){"].join("")),l([e],!0,["if(",o("ptr0"),"!==pivot",r,"[pivot_ptr]){break __l",M,"}"].join("")),_.push(n,"}")):_.push(["while(",o(a(e)),"===pivot",r,"){",n,"}"].join(""))}var _=["'use strict'"],w=["ndarrayQuickSort",t.join("d"),e].join(""),k=["left","right","data","offset"].concat(i(t.length)),A=n(e),M=0;_.push(["function ",w,"(",k.join(","),"){"].join(""));var T=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1=0","comp_pivot2=0","comp=0"];if(t.length>1){for(var E=[],L=1;LL;++L)T.push("b_ptr"+L);T.push("ptr3","ptr4","ptr5","ptr6","ptr7","pivot_ptr","ptr_shift","elementSize="+E.join("*")),A?T.push("pivot1=malloc(elementSize)","pivot2=malloc(elementSize)"):T.push("pivot1=new Array(elementSize),pivot2=new Array(elementSize)")}else T.push("pivot1","pivot2");if(_.push("var "+T.join(",")),h(1,2),h(4,5),h(1,3),h(2,3),h(1,4),h(3,4),h(2,5),h(2,3),h(4,5),t.length>1?l(["el1","el2","el3","el4","el5","index1","index3","index5"],!0,["pivot1[pivot_ptr]=",o("ptr1"),"\n","pivot2[pivot_ptr]=",o("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",o("ptr0"),"\n","y=",o("ptr2"),"\n","z=",o("ptr4"),"\n",s("ptr5","x"),"\n",s("ptr6","y"),"\n",s("ptr7","z")].join("")):_.push(["pivot1=",o(a("el2")),"\n","pivot2=",o(a("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",o(a("el1")),"\n","y=",o(a("el3")),"\n","z=",o(a("el5")),"\n",s(a("index1"),"x"),"\n",s(a("index3"),"y"),"\n",s(a("index5"),"z")].join("")),d("index2","left"),d("index4","right"),_.push("if(pivots_are_equal){"),_.push("for(k=less;k<=great;++k){"),p("comp","k",1),_.push("if(comp===0){continue}"),_.push("if(comp<0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),_.push("while(true){"),p("comp","great",1),_.push("if(comp>0){"),_.push("great--"),_.push("}else if(comp<0){"),v("k","less","great"),_.push("break"),_.push("}else{"),m("k","great"),_.push("break"),_.push("}"),_.push("}"),_.push("}"),_.push("}"),_.push("}else{"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1<0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2>0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp>0){"),_.push("if(--greatindex5){"),x("less",1,"++less"),x("great",2,"--great"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1===0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2===0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp===0){"),_.push("if(--great1&&A){var S=new Function("insertionSort","malloc","free",_.join("\n"));return S(r,A[0],A[1])}var S=new Function("insertionSort",_.join("\n"));return S(r)}function s(t,e){var r=["'use strict'"],n=["ndarraySortWrapper",t.join("d"),e].join(""),s=["array"];r.push(["function ",n,"(",s.join(","),"){"].join(""));for(var l=["data=array.data,offset=array.offset|0,shape=array.shape,stride=array.stride"],u=0;u0?l.push(["d",v,"=s",v,"-d",p,"*n",p].join("")):l.push(["d",v,"=s",v].join("")),p=v);var d=t.length-1-u;0!==d&&(g>0?l.push(["e",d,"=s",d,"-e",g,"*n",g,",f",d,"=",f[d],"-f",g,"*n",g].join("")):l.push(["e",d,"=s",d,",f",d,"=",f[d]].join("")),g=d)}r.push("var "+l.join(","));var m=["0","n0-1","data","offset"].concat(i(t.length));r.push(["if(n0<=",c,"){","insertionSort(",m.join(","),")}else{","quickSort(",m.join(","),")}"].join("")),r.push("}return "+n);var y=new Function("insertionSort","quickSort",r.join("\n")),b=a(t,e),x=o(t,e,b);return y(b,x)}var l=t("typedarray-pool"),c=32;e.exports=s},{"typedarray-pool":237}],117:[function(t,e,r){"use strict";function n(t){var e=t.order,r=t.dtype,n=[e,r],o=n.join(":"),s=a[o];return s||(a[o]=s=i(e,r)),s(t),t}var i=t("./lib/compile_sort.js"),a={};e.exports=n},{"./lib/compile_sort.js":116}],118:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[0,0,0,1,1,0,1,1]),i=o(e,s.boxVert,s.lineFrag);return new n(t,r,i)}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawBox=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o){var s=this.plot,l=this.shader,c=s.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,l.uniforms.lo=t,l.uniforms.hi=e,l.uniforms.color=o,c.drawArrays(c.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":121,"gl-buffer":77,"gl-shader":156}],119:[function(t,e,r){"use strict";function n(t,e,r,n){this.plot=t,this.vbo=e,this.shader=r,this.tickShader=n,this.ticks=[[],[]]}function i(t,e){return t-e}function a(t){var e=t.gl,r=o(e),i=s(e,c.gridVert,c.gridFrag),a=s(e,c.tickVert,c.gridFrag),l=new n(t,r,i,a);return l}e.exports=a;var o=t("gl-buffer"),s=t("gl-shader"),l=t("binary-search-bounds"),c=t("./shaders"),u=n.prototype;u.draw=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){for(var n=this.plot,i=this.vbo,a=this.shader,o=this.ticks,s=n.gl,l=n._tickBounds,c=n.dataBox,u=n.viewBox,f=n.gridLineWidth,h=n.gridLineColor,d=n.gridLineEnable,p=n.pixelRatio,g=0;2>g;++g){var v=l[g],m=l[g+2],y=m-v,b=.5*(c[g+2]+c[g]),x=c[g+2]-c[g];e[g]=2*y/x,t[g]=2*(v-b)/x}a.bind(),i.bind(),a.attributes.dataCoord.pointer(),a.uniforms.dataShift=t,a.uniforms.dataScale=e;for(var _=0,g=0;2>g;++g){r[0]=r[1]=0,r[g]=1,a.uniforms.dataAxis=r,a.uniforms.lineWidth=f[g]/(u[g+2]-u[g])*p,a.uniforms.color=h[g];var w=6*o[g].length;d[g]&&w&&s.drawArrays(s.TRIANGLES,_,w),_+=w}}}(),u.drawTickMarks=function(){var t=[0,0],e=[0,0],r=[1,0],n=[0,1],a=[0,0],o=[0,0];return function(){for(var s=this.plot,c=this.vbo,u=this.tickShader,f=this.ticks,h=s.gl,d=s._tickBounds,p=s.dataBox,g=s.viewBox,v=s.pixelRatio,m=s.screenBox,y=m[2]-m[0],b=m[3]-m[1],x=g[2]-g[0],_=g[3]-g[1],w=0;2>w;++w){var k=d[w],A=d[w+2],M=A-k,T=.5*(p[w+2]+p[w]),E=p[w+2]-p[w];e[w]=2*M/E,t[w]=2*(k-T)/E}e[0]*=x/y,t[0]*=x/y,e[1]*=_/b,t[1]*=_/b,u.bind(),c.bind(),u.attributes.dataCoord.pointer();var L=u.uniforms;L.dataShift=t,L.dataScale=e;var S=s.tickMarkLength,C=s.tickMarkWidth,z=s.tickMarkColor,P=0,R=6*f[0].length,O=Math.min(l.ge(f[0],(p[0]-d[0])/(d[2]-d[0]),i),f[0].length),I=Math.min(l.gt(f[0],(p[2]-d[0])/(d[2]-d[0]),i),f[0].length),N=P+6*O,j=6*Math.max(0,I-O),F=Math.min(l.ge(f[1],(p[1]-d[1])/(d[3]-d[1]),i),f[1].length),D=Math.min(l.gt(f[1],(p[3]-d[1])/(d[3]-d[1]),i),f[1].length),B=R+6*F,U=6*Math.max(0,D-F);a[0]=2*(g[0]-S[1])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[1]*v/y,o[1]=C[1]*v/b,U&&(L.color=z[1],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,B,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[1]-S[0])/b-1,o[0]=C[0]*v/y,o[1]=S[0]*v/b,j&&(L.color=z[0],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,N,j)),a[0]=2*(g[2]+S[3])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[3]*v/y,o[1]=C[3]*v/b,U&&(L.color=z[3],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,B,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[3]+S[2])/b-1,o[0]=C[2]*v/y,o[1]=S[2]*v/b,j&&(L.color=z[2],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,N,j))}}(),u.update=function(){var t=[1,1,-1,-1,1,-1],e=[1,-1,1,1,-1,-1];return function(r){for(var n=r.ticks,i=r.bounds,a=new Float32Array(18*(n[0].length+n[1].length)),o=(this.plot.zeroLineEnable,0),s=[[],[]],l=0;2>l;++l)for(var c=s[l],u=n[l],f=i[l],h=i[l+2],d=0;dg;++g)a[o++]=p,a[o++]=t[g],a[o++]=e[g]}this.ticks=s,this.vbo.update(a)}}(),u.dispose=function(){this.vbo.dispose(),this.shader.dispose(),this.tickShader.dispose()}},{"./shaders":121,"binary-search-bounds":123,"gl-buffer":77,"gl-shader":156}],120:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[-1,-1,-1,1,1,-1,1,1]),i=o(e,s.lineVert,s.lineFrag),l=new n(t,r,i);return l}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawLine=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o,s){var l=this.plot,c=this.shader,u=l.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,c.uniforms.start=t,c.uniforms.end=e,c.uniforms.width=o*l.pixelRatio,c.uniforms.color=s,u.drawArrays(u.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":121,"gl-buffer":77,"gl-shader":156}],121:[function(t,e,r){"use strict";var n="precision lowp float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = vec4(color.xyz * color.w, color.w);\n}\n";e.exports={lineVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 start, end;\nuniform float width;\n\nvec2 perp(vec2 v) {\n return vec2(v.y, -v.x);\n}\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n vec2 delta = normalize(perp(start - end));\n vec2 offset = mix(start, end, 0.5 * (coord.y+1.0));\n gl_Position = vec4(screen(offset + 0.5 * width * delta * coord.x), 0, 1);\n}\n",lineFrag:n,textVert:"#define GLSLIFY 1\nattribute vec3 textCoordinate;\n\nuniform vec2 dataScale, dataShift, dataAxis, screenOffset, textScale;\nuniform float angle;\n\nvoid main() {\n float dataOffset = textCoordinate.z;\n vec2 glyphOffset = textCoordinate.xy;\n mat2 glyphMatrix = mat2(cos(angle), sin(angle), -sin(angle), cos(angle));\n vec2 screenCoordinate = dataAxis * (dataScale * dataOffset + dataShift) +\n glyphMatrix * glyphOffset * textScale + screenOffset;\n gl_Position = vec4(screenCoordinate, 0, 1);\n}\n",textFrag:n,gridVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale;\nuniform float lineWidth;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n pos += 10.0 * dataCoord.y * vec2(dataAxis.y, -dataAxis.x) + dataCoord.z * lineWidth;\n gl_Position = vec4(pos, 0, 1);\n}\n",gridFrag:n,boxVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 lo, hi;\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n gl_Position = vec4(screen(mix(lo, hi, coord)), 0, 1);\n}\n",tickVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale, screenOffset, tickScale;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n gl_Position = vec4(pos + tickScale*dataCoord.yz + screenOffset, 0, 1);\n}\n"}},{}],122:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r,this.tickOffset=[[],[]],this.tickX=[[],[]],this.labelOffset=[0,0],this.labelCount=[0,0]}function i(t){var e=t.gl,r=a(e),i=o(e,c.textVert,c.textFrag),s=new n(t,r,i);return s}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("text-cache"),l=t("binary-search-bounds"),c=t("./shaders"),u=n.prototype;u.drawTicks=function(){var t=[0,0],e=[0,0],r=[0,0];return function(n){var i=this.plot,a=this.shader,o=this.tickX[n],s=this.tickOffset[n],c=i.gl,u=i.viewBox,f=i.dataBox,h=i.screenBox,d=i.pixelRatio,p=i.tickEnable,g=i.tickPad,v=i.tickColor,m=i.tickAngle,y=(i.tickMarkLength,i.labelEnable),b=i.labelPad,x=i.labelColor,_=i.labelAngle,w=this.labelOffset[n],k=this.labelCount[n],A=l.lt(o,f[n]),M=l.le(o,f[n+2]);t[0]=t[1]=0,t[n]=1,e[n]=(u[2+n]+u[n])/(h[2+n]-h[n])-1;var T=2/h[2+(1^n)]-h[1^n];e[1^n]=T*u[1^n]-1,p[n]&&(e[1^n]-=T*d*g[n],M>A&&s[M]>s[A]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n],a.uniforms.angle=m[n],c.drawArrays(c.TRIANGLES,s[A],s[M]-s[A]))),y[n]&&k&&(e[1^n]-=T*d*b[n],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n],a.uniforms.angle=_[n],c.drawArrays(c.TRIANGLES,w,k)),e[1^n]=T*u[2+(1^n)]-1,p[n+2]&&(e[1^n]+=T*d*g[n+2],M>A&&s[M]>s[A]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n+2],a.uniforms.angle=m[n+2],c.drawArrays(c.TRIANGLES,s[A],s[M]-s[A]))),y[n+2]&&k&&(e[1^n]+=T*d*b[n+2],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n+2],a.uniforms.angle=_[n+2],c.drawArrays(c.TRIANGLES,w,k))}}(),u.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,i=r.gl,a=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,o=r.titleCenter,c=r.pixelRatio;if(this.titleCount){for(var u=0;2>u;++u)e[u]=2*(o[u]*c-a[u])/(a[2+u]-a[u])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,i.drawArrays(i.TRIANGLES,this.titleOffset,this.titleCount)}}}(),u.bind=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){var n=this.plot,i=this.shader,a=n._tickBounds,o=n.dataBox,s=n.screenBox,l=n.viewBox;i.bind();for(var c=0;2>c;++c){var u=a[c],f=a[c+2],h=f-u,d=.5*(o[c+2]+o[c]),p=o[c+2]-o[c],g=l[c],v=l[c+2],m=v-g,y=s[c],b=s[c+2],x=b-y;e[c]=2*h/p*m/x,t[c]=2*(u-d)/p*m/x}r[1]=2*n.pixelRatio/(s[3]-s[1]),r[0]=r[1]*(s[3]-s[1])/(s[2]-s[0]),i.uniforms.dataScale=e,i.uniforms.dataShift=t,i.uniforms.textScale=r,this.vbo.bind(),i.attributes.textCoordinate.pointer()}}(),u.update=function(t){for(var e=[],r=t.ticks,n=t.bounds,i=0;2>i;++i){for(var a=[Math.floor(e.length/3)],o=[-(1/0)],l=r[i],c=0;ci;++i){this.labelOffset[i]=Math.floor(e.length/3);for(var g=s(t.labelFont[i],t.labels[i]).data,p=t.labelSize[i],c=0;c>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],124:[function(t,e,r){"use strict";function n(t,e){this.gl=t,this.pickBuffer=e,this.screenBox=[0,0,t.drawingBufferWidth,t.drawingBufferHeight],this.viewBox=[0,0,0,0],this.dataBox=[-10,-10,10,10],this.gridLineEnable=[!0,!0],this.gridLineWidth=[1,1],this.gridLineColor=[[0,0,0,1],[0,0,0,1]],this.pixelRatio=1,this.tickMarkLength=[0,0,0,0],this.tickMarkWidth=[0,0,0,0],this.tickMarkColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.tickPad=[15,15,15,15],this.tickAngle=[0,0,0,0],this.tickEnable=[!0,!0,!0,!0],this.tickColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.labelPad=[15,15,15,15],this.labelAngle=[0,Math.PI/2,0,3*Math.PI/2],this.labelEnable=[!0,!0,!0,!0],this.labelColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.titleCenter=[0,0],this.titleEnable=!0,this.titleAngle=0,this.titleColor=[0,0,0,1],this.borderColor=[0,0,0,0],this.backgroundColor=[0,0,0,0],this.zeroLineEnable=[!0,!0],this.zeroLineWidth=[4,4],this.zeroLineColor=[[0,0,0,1],[0,0,0,1]],this.borderLineEnable=[!0,!0,!0,!0],this.borderLineWidth=[2,2,2,2],this.borderLineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.grid=null,this.text=null,this.line=null,this.box=null,this.objects=[],this.overlays=[],this._tickBounds=[1/0,1/0,-(1/0),-(1/0)],this.dirty=!1,this.pickDirty=!1,this.pickDelay=120,this.pickRadius=10,this._pickTimeout=null,this._drawPick=this.drawPick.bind(this),this._depthCounter=0}function i(t){for(var e=t.slice(),r=0;rp;++p)if(f[p]&&n[p]<=0&&n[p+2]>=0){var g=e[p]-n[p]*(e[p+2]-e[p])/(n[p+2]-n[p]);0===p?o.drawLine(g,e[1],g,e[3],d[p],h[p]):o.drawLine(e[0],g,e[2],g,d[p],h[p])}}for(var p=0;pp;++p)s.drawTicks(p);this.titleEnable&&s.drawTitle();for(var b=this.overlays,p=0;pc;++c){var u=s[c].slice(0);0!==u.length&&(u.sort(a),l[c]=Math.min(l[c],u[0].x),l[c+2]=Math.max(l[c+2],u[u.length-1].x))}this.grid.update({bounds:l,ticks:s}),this.text.update({bounds:l,ticks:s,labels:t.labels||["x","y"],labelSize:t.labelSize||[12,12],labelFont:t.labelFont||["sans-serif","sans-serif"],title:t.title||"",titleSize:t.titleSize||18,titleFont:t.titleFont||"sans-serif"}),this.setDirty()},h.dispose=function(){this.box.dispose(),this.grid.dispose(),this.text.dispose(),this.line.dispose();for(var t=this.objects.length-1;t>=0;--t)this.objects[t].dispose();this.objects.length=0;for(var t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},h.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},h.removeObject=function(t){for(var e=this.objects,r=0;rh;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){return n.setMode(t),n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s=1/t.clientHeight,l=s*(r-d),u=s*(a-p),f=h.flipX?1:-1,g=h.flipY?1:-1,v=Math.PI*h.rotateSpeed,m=i();if(1&e)o.shift?n.rotate(m,0,0,-l*v):n.rotate(m,f*v*l,-g*v*u,0);else if(2&e)n.pan(m,-h.translateSpeed*l*c,h.translateSpeed*u*c,0);else if(4&e){var y=h.zoomSpeed*u/window.innerHeight*(m-n.lastT())*50;n.pan(m,0,0,c*(Math.exp(y)-1))}d=r,p=a}),s(t,function(t,e,r){var a=h.flipX?1:-1,o=h.flipY?1:-1,s=i();if(Math.abs(t)>Math.abs(e))n.rotate(s,0,0,-t*a*Math.PI*h.rotateSpeed/window.innerWidth);else{var l=h.zoomSpeed*o*e/window.innerHeight*(s-n.lastT())/100;n.pan(s,0,0,c*(Math.exp(l)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":39,"mouse-change":200,"mouse-wheel":204,"right-now":214}],127:[function(t,e,r){!function(){"use strict";function t(e){e.permitHostObjects___&&e.permitHostObjects___(t)}function r(t){return!(t.substr(0,d.length)==d&&"___"===t.substr(t.length-3))}function n(t){if(t!==Object(t))throw new TypeError("Not an object: "+t);var e=t[p];if(e&&e.key===t)return e;if(h(t)){e={key:t};try{return f(t,p,{value:e,writable:!1,enumerable:!1,configurable:!1}),e}catch(r){return}}}function i(t){return t.prototype=null,Object.freeze(t)}function a(){y||"undefined"==typeof console||(y=!0,console.warn("WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future."))}if("undefined"==typeof ses||!ses.ok||ses.ok()){"undefined"!=typeof ses&&(ses.weakMapPermitHostObjects=t);var o=!1;if("function"==typeof WeakMap){var s=WeakMap;if("undefined"!=typeof navigator&&/Firefox/.test(navigator.userAgent));else{var l=new s,c=Object.freeze({});if(l.set(c,1),1===l.get(c))return void(e.exports=WeakMap);o=!0}}var u=(Object.prototype.hasOwnProperty,Object.getOwnPropertyNames),f=Object.defineProperty,h=Object.isExtensible,d="weakmap:",p=d+"ident:"+Math.random()+"___";if("undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues&&"function"==typeof ArrayBuffer&&"function"==typeof Uint8Array){var g=new ArrayBuffer(25),v=new Uint8Array(g);crypto.getRandomValues(v),p=d+"rand:"+Array.prototype.map.call(v,function(t){return(t%36).toString(36)}).join("")+"___"}if(f(Object,"getOwnPropertyNames",{value:function(t){return u(t).filter(r)}}),"getPropertyNames"in Object){var m=Object.getPropertyNames;f(Object,"getPropertyNames",{value:function(t){return m(t).filter(r)}})}!function(){var t=Object.freeze;f(Object,"freeze",{value:function(e){return n(e),t(e)}});var e=Object.seal;f(Object,"seal",{value:function(t){return n(t),e(t)}});var r=Object.preventExtensions;f(Object,"preventExtensions",{value:function(t){return n(t),r(t)}})}();var y=!1,b=0,x=function(){function t(t,e){var r,i=n(t);return i?c in i?i[c]:e:(r=s.indexOf(t),r>=0?l[r]:e)}function e(t){var e=n(t);return e?c in e:s.indexOf(t)>=0}function r(t,e){var r,i=n(t);return i?i[c]=e:(r=s.indexOf(t),r>=0?l[r]=e:(r=s.length,l[r]=e,s[r]=t)),this}function o(t){var e,r,i=n(t);return i?c in i&&delete i[c]:(e=s.indexOf(t),0>e?!1:(r=s.length-1,s[e]=void 0,l[e]=l[r],s[e]=s[r],s.length=r,l.length=r,!0))}this instanceof x||a();var s=[],l=[],c=b++;return Object.create(x.prototype,{get___:{value:i(t)},has___:{value:i(e)},set___:{value:i(r)},delete___:{value:i(o)}})};x.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},"delete":{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof s?!function(){function r(){function e(t,e){return u?c.has(t)?c.get(t):u.get___(t,e):c.get(t,e)}function r(t){return c.has(t)||(u?u.has___(t):!1)}function n(t){var e=!!c.delete(t);return u?u.delete___(t)||e:e}this instanceof x||a();var l,c=new s,u=void 0,f=!1;return l=o?function(t,e){return c.set(t,e),c.has(t)||(u||(u=new x),u.set(t,e)),this}:function(t,e){if(f)try{c.set(t,e)}catch(r){u||(u=new x),u.set___(t,e)}else c.set(t,e);return this},Object.create(x.prototype,{get___:{value:i(e)},has___:{value:i(r)},set___:{value:i(l)},delete___:{value:i(n)},permitHostObjects___:{value:i(function(e){if(e!==t)throw new Error("bogus call to permitHostObjects___");f=!0})}})}o&&"undefined"!=typeof Proxy&&(Proxy=void 0),r.prototype=x.prototype,e.exports=r,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=x)}}()},{}],128:[function(t,e,r){"use strict";function n(t){var e=s.get(t);if(!e||!t.isBuffer(e._triangleBuffer.buffer)){var r=a(t,new Float32Array([-1,-1,-1,4,4,-1]));e=o(t,[{buffer:r,type:t.FLOAT,size:2}]),e._triangleBuffer=r,s.set(t,e)}e.bind(),t.drawArrays(t.TRIANGLES,0,3),e.unbind()}var i="undefined"==typeof WeakMap?t("weak-map"):WeakMap,a=t("gl-buffer"),o=t("gl-vao"),s=new i;e.exports=n},{"gl-buffer":77,"gl-vao":185,"weak-map":127}],129:[function(t,e,r){"use strict";function n(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function i(t){this.gl=t,this.pixelRatio=1,this.bounds=[[-10,-10,-10],[10,10,10]],this.ticks=[[],[],[]],this.autoTicks=!0,this.tickSpacing=[1,1,1],this.tickEnable=[!0,!0,!0],this.tickFont=["sans-serif","sans-serif","sans-serif"],this.tickSize=[12,12,12],this.tickAngle=[0,0,0],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=[!0,!0,!0],this.labelFont="sans-serif",this.labelSize=[20,20,20],this.labelAngle=[0,0,0],this.labelColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.labelPad=[10,10,10],this.lineEnable=[!0,!0,!0],this.lineMirror=[!1,!1,!1],this.lineWidth=[1,1,1],this.lineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.lineTickEnable=[!0,!0,!0],this.lineTickMirror=[!1,!1,!1],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=[!0,!0,!0],this.gridWidth=[1,1,1],this.gridColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.zeroEnable=[!0,!0,!0],this.zeroLineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.zeroLineWidth=[2,2,2],this.backgroundEnable=[!1,!1,!1],this.backgroundColor=[[.8,.8,.8,.5],[.8,.8,.8,.5],[.8,.8,.8,.5]],this._firstInit=!0,this._text=null,this._lines=null,this._background=u(t)}function a(){this.primalOffset=[0,0,0],this.primalMinor=[0,0,0],this.mirrorOffset=[0,0,0],this.mirrorMinor=[0,0,0]}function o(t,e,r,n,i){for(var a=t.primalOffset,o=t.primalMinor,s=t.mirrorOffset,l=t.mirrorMinor,c=n[e],u=0;3>u;++u)if(e!==u){var f=a,h=s,d=o,p=l;c&1<0?(d[u]=-1,p[u]=0):(d[u]=0,p[u]=1)}}function s(t,e){var r=new i(t);return r.update(e),r}e.exports=s;var l=t("./lib/text.js"),c=t("./lib/lines.js"),u=t("./lib/background.js"),f=t("./lib/cube.js"),h=t("./lib/ticks.js"),d=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),p=i.prototype;p.update=function(t){function e(e,r,n){if(n in t){var i,a=t[n],o=this[n];(e?Array.isArray(a)&&Array.isArray(a[0]):Array.isArray(a))?this[n]=i=[r(a[0]),r(a[1]),r(a[2])]:this[n]=i=[r(a),r(a),r(a)];for(var s=0;3>s;++s)if(i[s]!==o[s])return!0}return!1}t=t||{};var r,n=e.bind(this,!1,Number),i=e.bind(this,!1,Boolean),a=e.bind(this,!1,String),o=e.bind(this,!0,function(t){if(Array.isArray(t)){if(3===t.length)return[+t[0],+t[1],+t[2],1];if(4===t.length)return[+t[0],+t[1],+t[2],+t[3]]}return[0,0,0,1]}),s=!1,u=!1;if("bounds"in t)for(var f=t.bounds,d=0;2>d;++d)for(var p=0;3>p;++p)f[d][p]!==this.bounds[d][p]&&(u=!0),this.bounds[d][p]=f[d][p];if("ticks"in t){r=t.ticks,s=!0,this.autoTicks=!1;for(var d=0;3>d;++d)this.tickSpacing[d]=0}else n("tickSpacing")&&(this.autoTicks=!0,u=!0);if(this._firstInit&&("ticks"in t||"tickSpacing"in t||(this.autoTicks=!0),u=!0,s=!0,this._firstInit=!1),u&&this.autoTicks&&(r=h.create(this.bounds,this.tickSpacing),s=!0),s){for(var d=0;3>d;++d)r[d].sort(function(t,e){return t.x-e.x});h.equal(r,this.ticks)?s=!1:this.ticks=r}i("tickEnable"),a("tickFont")&&(s=!0),n("tickSize"),n("tickAngle"),n("tickPad"),o("tickColor");var g=a("labels");a("labelFont")&&(g=!0),i("labelEnable"),n("labelSize"),n("labelPad"),o("labelColor"),i("lineEnable"),i("lineMirror"),n("lineWidth"),o("lineColor"),i("lineTickEnable"),i("lineTickMirror"),n("lineTickLength"),n("lineTickWidth"),o("lineTickColor"),i("gridEnable"),n("gridWidth"),o("gridColor"),i("zeroEnable"),o("zeroLineColor"),n("zeroLineWidth"),i("backgroundEnable"),o("backgroundColor"),this._text?this._text&&(g||s)&&this._text.update(this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont):this._text=l(this.gl,this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont),this._lines&&s&&(this._lines.dispose(),this._lines=null),this._lines||(this._lines=c(this.gl,this.bounds,this.ticks))};var g=[new a,new a,new a],v=[0,0,0],m={model:d,view:d,projection:d};p.isOpaque=function(){return!0},p.isTransparent=function(){return!1},p.drawTransparent=function(t){};var y=[0,0,0],b=[0,0,0],x=[0,0,0];p.draw=function(t){t=t||m;for(var e=this.gl,r=t.model||d,i=t.view||d,a=t.projection||d,s=this.bounds,l=f(r,i,a,s),c=l.cubeEdges,u=l.axis,h=i[12],p=i[13],_=i[14],w=i[15],k=this.pixelRatio*(a[3]*h+a[7]*p+a[11]*_+a[15]*w)/e.drawingBufferHeight,A=0;3>A;++A)this.lastCubeProps.cubeEdges[A]=c[A],this.lastCubeProps.axis[A]=u[A];for(var M=g,A=0;3>A;++A)o(g[A],A,this.bounds,c,u);for(var e=this.gl,T=v,A=0;3>A;++A)this.backgroundEnable[A]?T[A]=u[A]:T[A]=0;this._background.draw(r,i,a,s,T,this.backgroundColor),this._lines.bind(r,i,a,this);for(var A=0;3>A;++A){var E=[0,0,0];u[A]>0?E[A]=s[1][A]:E[A]=s[0][A];for(var L=0;2>L;++L){var S=(A+1+L)%3,C=(A+1+(1^L))%3;this.gridEnable[S]&&this._lines.drawGrid(S,C,this.bounds,E,this.gridColor[S],this.gridWidth[S]*this.pixelRatio)}for(var L=0;2>L;++L){var S=(A+1+L)%3,C=(A+1+(1^L))%3;this.zeroEnable[C]&&s[0][C]<=0&&s[1][C]>=0&&this._lines.drawZero(S,C,this.bounds,E,this.zeroLineColor[C],this.zeroLineWidth[C]*this.pixelRatio)}}for(var A=0;3>A;++A){this.lineEnable[A]&&this._lines.drawAxisLine(A,this.bounds,M[A].primalOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio),this.lineMirror[A]&&this._lines.drawAxisLine(A,this.bounds,M[A].mirrorOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio);for(var z=n(y,M[A].primalMinor),P=n(b,M[A].mirrorMinor),R=this.lineTickLength,L=0;3>L;++L){var O=k/r[5*L];z[L]*=R[L]*O,P[L]*=R[L]*O}this.lineTickEnable[A]&&this._lines.drawAxisTicks(A,M[A].primalOffset,z,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio),this.lineTickMirror[A]&&this._lines.drawAxisTicks(A,M[A].mirrorOffset,P,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio)}this._text.bind(r,i,a,this.pixelRatio);for(var A=0;3>A;++A){for(var I=M[A].primalMinor,N=n(x,M[A].primalOffset),L=0;3>L;++L)this.lineTickEnable[A]&&(N[L]+=k*I[L]*Math.max(this.lineTickLength[L],0)/r[5*L]);if(this.tickEnable[A]){for(var L=0;3>L;++L)N[L]+=k*I[L]*this.tickPad[L]/r[5*L];this._text.drawTicks(A,this.tickSize[A],this.tickAngle[A],N,this.tickColor[A])}if(this.labelEnable[A]){for(var L=0;3>L;++L)N[L]+=k*I[L]*this.labelPad[L]/r[5*L];N[A]+=.5*(s[0][A]+s[1][A]),this._text.drawLabel(A,this.labelSize[A],this.labelAngle[A],N,this.labelColor[A])}}},p.dispose=function(){this._text.dispose(),this._lines.dispose(),this._background.dispose(),this._lines=null,this._text=null,this._background=null,this.gl=null}},{"./lib/background.js":130,"./lib/cube.js":131,"./lib/lines.js":132,"./lib/text.js":134,"./lib/ticks.js":135}],130:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n}function i(t){for(var e=[],r=[],i=0,l=0;3>l;++l)for(var c=(l+1)%3,u=(l+2)%3,f=[0,0,0],h=[0,0,0],d=-1;1>=d;d+=2){r.push(i,i+2,i+1,i+1,i+2,i+3),f[l]=d,h[l]=d;for(var p=-1;1>=p;p+=2){f[c]=p;for(var g=-1;1>=g;g+=2)f[u]=g,e.push(f[0],f[1],f[2],h[0],h[1],h[2]),i+=1}var v=c;c=u,u=v}var m=a(t,new Float32Array(e)),y=a(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),b=o(t,[{buffer:m,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:m,type:t.FLOAT,size:3,offset:12,stride:24}],y),x=s(t);return x.attributes.position.location=0,x.attributes.normal.location=1,new n(t,m,b,x)}e.exports=i;var a=t("gl-buffer"),o=t("gl-vao"),s=t("./shaders").bg,l=n.prototype;l.draw=function(t,e,r,n,i,a){for(var o=!1,s=0;3>s;++s)o=o||i[s];if(o){var l=this.gl;l.enable(l.POLYGON_OFFSET_FILL),l.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:t,view:e,projection:r,bounds:n,enable:i,colors:a},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),l.disable(l.POLYGON_OFFSET_FILL)}},l.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders":133,"gl-buffer":77,"gl-vao":185}],131:[function(t,e,r){"use strict";function n(t,e,r){for(var n=0;4>n;++n){t[n]=r[12+n];for(var i=0;3>i;++i)t[n]+=e[i]*r[4*i+n]}}function i(t){for(var e=0;eg;++g){d[2]=a[g][2];for(var b=0;2>b;++b){d[1]=a[b][1];for(var x=0;2>x;++x)d[0]=a[x][0],n(f[l],d,u),l+=1}}for(var _=-1,g=0;8>g;++g){for(var w=f[g][3],k=0;3>k;++k)h[g][k]=f[g][k]/w;0>w&&(0>_?_=g:h[g][2]_){_=0;for(var A=0;3>A;++A){for(var M=(A+2)%3,T=(A+1)%3,E=-1,L=-1,S=0;2>S;++S){var C=S<E||0>L)L>E&&(_|=1<S;++S){var C=S<E&&(_|=1<g;++g)g!==_&&g!==O&&(0>I?I=g:h[I][1]>h[g][1]&&(I=g));for(var N=-1,g=0;3>g;++g){var j=I^1<N&&(N=j);var T=h[j];T[0]g;++g){var j=I^1<F&&(F=j);var T=h[j];T[0]>h[F][0]&&(F=j)}}var D=v;D[0]=D[1]=D[2]=0,D[o.log2(N^I)]=I&N,D[o.log2(I^F)]=I&F;var B=7^F;B===_||B===O?(B=7^N,D[o.log2(F^B)]=B&F):D[o.log2(N^B)]=B&N;for(var U=m,V=_,A=0;3>A;++A)V&1<t;++t)f[t]=[1,1,1,1],h[t]=[1,1,1]}();var g=[[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]],v=[1,1,1],m=[0,0,0],y={cubeEdges:v,axis:m}},{"bit-twiddle":50,"gl-mat4/invert":96,"gl-mat4/multiply":98,"robust-orientation":218,"split-polygon":137}],132:[function(t,e,r){"use strict";function n(t){return t[0]=t[1]=t[2]=0,t}function i(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function a(t,e,r,n,i,a,o,s){this.gl=t,this.vertBuffer=e,this.vao=r,this.shader=n,this.tickCount=i,this.tickOffset=a,this.gridCount=o,this.gridOffset=s}function o(t,e,r){var n=[],i=[0,0,0],o=[0,0,0],u=[0,0,0],f=[0,0,0];n.push(0,0,1,0,1,1,0,0,-1,0,0,-1,0,1,1,0,1,-1);for(var h=0;3>h;++h){for(var d=n.length/3|0,p=0;ph;++h)for(var p=u[h],g=2;g>=0;--g){var v=c[p[g]];s.push(l*v[0],-l*v[1],t)}}for(var s=(this.gl,[]),l=[0,0,0],c=[0,0,0],u=[0,0,0],d=[0,0,0],p=0;3>p;++p){u[p]=s.length/h|0,o(.5*(t[0][p]+t[1][p]),e[p],r),d[p]=(s.length/h|0)-u[p],l[p]=s.length/h|0;for(var g=0;g=0&&(i=r.length-n-1);var a=Math.pow(10,i),o=Math.round(t*e*a),s=o+"";if(s.indexOf("e")>=0)return s;var l=o/a,c=o%a;0>o?(l=0|-Math.ceil(l),c=0|-c):(l=0|Math.floor(l),c=0|c);var u=""+l;if(0>o&&(u="-"+u),i){for(var f=""+c;f.lengthi;++i){for(var a=[],o=(.5*(t[0][i]+t[1][i]),0);o*e[i]<=t[1][i];++o)a.push({x:o*e[i],text:n(e[i],o)});for(var o=-1;o*e[i]>=t[0][i];--o)a.push({x:o*e[i],text:n(e[i],o)});r.push(a)}return r}function a(t,e){for(var r=0;3>r;++r){if(t[r].length!==e[r].length)return!1;for(var n=0;na?a=0:a>1&&(a=1);for(var o=1-a,s=t.length,l=new Array(s),c=0;s>c;++c)l[c]=a*t[c]+o*r[c];return l}function a(t,e){for(var r=[],a=[],o=n(t[t.length-1],e),s=t[t.length-1],l=t[0],c=0;co&&u>0||o>0&&0>u){var f=i(s,u,l,o);r.push(f),a.push(f.slice())}0>u?a.push(l.slice()):u>0?r.push(l.slice()):(r.push(l.slice()),a.push(l.slice())),o=u}return{positive:r,negative:a}}function o(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;la&&c>0||a>0&&0>c)&&r.push(i(o,c,s,a)),c>=0&&r.push(s.slice()),a=c}return r}function s(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;la&&c>0||a>0&&0>c)&&r.push(i(o,c,s,a)),0>=c&&r.push(s.slice()),a=c}return r}var l=t("robust-dot-product"),c=t("robust-sum");e.exports=a,e.exports.positive=o,e.exports.negative=s},{"robust-dot-product":138,"robust-sum":221}],138:[function(t,e,r){"use strict";function n(t,e){for(var r=i(t[0],e[0]),n=1;na;++a){for(var o=p,s=g,l=0;3>l;++l)s[l]=o[l]=r[l];s[3]=o[3]=1,s[a]+=1,f(s,s,e),s[3]<0&&(t[a]=1/0),o[a]-=1,f(o,o,e),o[3]<0&&(t[a]=1/0);var c=(o[0]/o[3]-s[0]/s[3])*n,u=(o[1]/o[3]-s[1]/s[3])*i;t[a]=.25*Math.sqrt(c*c+u*u)}return t}function a(t,e,r,n,a){var f=e.model||h,p=e.view||h,g=e.projection||h,y=t.bounds,a=a||l(f,p,g,y),b=a.axis;a.edges;c(d,p,f),c(d,g,d);for(var x=v,_=0;3>_;++_)x[_].lo=1/0,x[_].hi=-(1/0),x[_].pixelsPerDataUnit=1/0;var w=o(u(d,d));u(d,d);for(var k=0;3>k;++k){var A=(k+1)%3,M=(k+2)%3,T=m;t:for(var _=0;2>_;++_){var E=[];if(b[k]<0!=!!_){T[k]=y[_][k];for(var L=0;2>L;++L){T[A]=y[L^_][A];for(var S=0;2>S;++S)T[M]=y[S^L^_][M],E.push(T.slice())}for(var L=0;LS;++S)x[S].lo=Math.min(x[S].lo,M[S]),x[S].hi=Math.max(x[S].hi,M[S]),S!==k&&(x[S].pixelsPerDataUnit=Math.min(x[S].pixelsPerDataUnit,Math.abs(C[S])))}}}return x}e.exports=a;var o=t("extract-frustum-planes"),s=t("split-polygon"),l=t("./lib/cube.js"),c=t("gl-mat4/multiply"),u=t("gl-mat4/transpose"),f=t("gl-vec4/transformMat4"),h=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),d=new Float32Array(16),p=[0,0,0,1],g=[0,0,0,1],v=[new n(1/0,-(1/0),1/0),new n(1/0,-(1/0),1/0),new n(1/0,-(1/0),1/0)],m=[0,0,0]},{"./lib/cube.js":131,"extract-frustum-planes":136,"gl-mat4/multiply":98,"gl-mat4/transpose":106,"gl-vec4/transformMat4":186,"split-polygon":137}],140:[function(t,e,r){"use strict";var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, color;\nattribute float weight;\n\nuniform mat4 model, view, projection;\nuniform vec3 coordinates[3];\nuniform vec4 colors[3];\nuniform vec2 screenShape;\nuniform float lineWidth;\n\nvarying vec4 fragColor;\n\nvoid main() {\n vec3 vertexPosition = mix(coordinates[0],\n mix(coordinates[2], coordinates[1], 0.5 * (position + 1.0)), abs(position));\n\n vec4 clipPos = projection * view * model * vec4(vertexPosition, 1.0);\n vec2 clipOffset = (projection * view * model * vec4(color, 0.0)).xy;\n vec2 delta = weight * clipOffset * screenShape;\n vec2 lineOffset = normalize(vec2(delta.y, -delta.x)) / screenShape;\n\n gl_Position = vec4(clipPos.xy + clipPos.w * 0.5 * lineWidth * lineOffset, clipPos.z, clipPos.w);\n fragColor = color.x * colors[0] + color.y * colors[1] + color.z * colors[2];\n}\n",a="precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}";e.exports=function(t){return n(t,i,a,null,[{name:"position",type:"vec3"},{name:"color",type:"vec3"},{name:"weight",type:"float"}])}},{"gl-shader":156}],141:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n,this.pixelRatio=1,this.bounds=[[-1e3,-1e3,-1e3],[1e3,1e3,1e3]],this.position=[0,0,0],this.lineWidth=[2,2,2],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.enabled=[!0,!0,!0],this.drawSides=[!0,!0,!0],this.axes=null}function i(t,e){function r(t,e,r,n,a,o){var s=[t,e,r,0,0,0,1];s[n+3]=1,s[n]=a,i.push.apply(i,s),s[6]=-1,i.push.apply(i,s),s[n]=o,i.push.apply(i,s),i.push.apply(i,s),s[6]=1,i.push.apply(i,s),s[n]=a,i.push.apply(i,s)}var i=[];r(0,0,0,0,0,1),r(0,0,0,1,0,1),r(0,0,0,2,0,1),r(1,0,0,1,-1,1),r(1,0,0,2,-1,1),r(0,1,0,0,-1,1),r(0,1,0,2,-1,1),r(0,0,1,0,-1,1),r(0,0,1,1,-1,1);var l=a(t,i),c=o(t,[{type:t.FLOAT,buffer:l,size:3,offset:0,stride:28},{type:t.FLOAT,buffer:l,size:3,offset:12,stride:28},{type:t.FLOAT,buffer:l,size:1,offset:24,stride:28}]),u=s(t);u.attributes.position.location=0,u.attributes.color.location=1,u.attributes.weight.location=2;var f=new n(t,l,c,u);return f.update(e),f}var a=t("gl-buffer"),o=t("gl-vao"),s=t("./shaders/index");e.exports=i;var l=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],c=n.prototype,u=[0,0,0],f=[0,0,0],h=[0,0];c.isTransparent=function(){return!1},c.drawTransparent=function(t){},c.draw=function(t){var e=this.gl,r=this.vao,n=this.shader;r.bind(),n.bind();var i,a=t.model||l,o=t.view||l,s=t.projection||l;this.axes&&(i=this.axes.lastCubeProps.axis);for(var c=u,d=f,p=0;3>p;++p)i&&i[p]<0?(c[p]=this.bounds[0][p],d[p]=this.bounds[1][p]):(c[p]=this.bounds[1][p],d[p]=this.bounds[0][p]);h[0]=e.drawingBufferWidth,h[1]=e.drawingBufferHeight,n.uniforms.model=a,n.uniforms.view=o,n.uniforms.projection=s,n.uniforms.coordinates=[this.position,c,d],n.uniforms.colors=this.colors,n.uniforms.screenShape=h;for(var p=0;3>p;++p)n.uniforms.lineWidth=this.lineWidth[p]*this.pixelRatio,this.enabled[p]&&(r.draw(e.TRIANGLES,6,6*p),this.drawSides[p]&&r.draw(e.TRIANGLES,12,18+12*p));r.unbind()},c.update=function(t){t&&("bounds"in t&&(this.bounds=t.bounds),"position"in t&&(this.position=t.position),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"colors"in t&&(this.colors=t.colors),"enabled"in t&&(this.enabled=t.enabled),"drawSides"in t&&(this.drawSides=t.drawSides))},c.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders/index":140,"gl-buffer":77,"gl-vao":185}],142:[function(t,e,r){"use strict";function n(){this.mouse=[-1,-1],this.screen=null,this.distance=1/0,this.index=null,this.dataCoordinate=null,this.dataPosition=null,this.object=null,this.data=null}function i(t,e){var r=null;try{r=t.getContext("webgl",e),r||(r=t.getContext("experimental-webgl",e))}catch(n){return null}return r}function a(t){var e=Math.round(Math.log(Math.abs(t))/Math.log(10));if(0>e){var r=Math.round(Math.pow(10,-e));return Math.ceil(t*r)/r}if(e>0){var r=Math.round(Math.pow(10,e));return Math.ceil(t/r)*r}return Math.ceil(t)}function o(t){return"boolean"==typeof t?t:!0}function s(t){function e(){if(!_&&H.autoResize){var t=w.parentNode,e=1,r=1;t&&t!==document.body?(e=t.clientWidth,r=t.clientHeight):(e=window.innerWidth,r=window.innerHeight);var n=0|Math.ceil(e*H.pixelRatio),i=0|Math.ceil(r*H.pixelRatio);if(n!==w.width||i!==w.height){w.width=n,w.height=i;var a=w.style;a.position=a.position||"absolute",a.left="0px",a.top="0px",a.width=e+"px",a.height=r+"px",F=!0}}}function r(){for(var t=O.length,e=j.length,r=0;e>r;++r)N[r]=0;t:for(var r=0;t>r;++r){var n=O[r],i=n.pickSlots;if(i){for(var a=0;e>a;++a)if(N[a]+i<255){I[r]=a,n.setPickBase(N[a]+1),N[a]+=i;continue t}var o=h(A,q);I[r]=e,j.push(o),N.push(i),n.setPickBase(1),e+=1}else I[r]=-1}for(;e>0&&0===N[e-1];)N.pop(),j.pop().dispose()}function s(){return H.contextLost?!0:void(A.isContextLost()&&(H.contextLost=!0,H.mouseListener.enabled=!1,H.selection.object=null,H.oncontextloss&&H.oncontextloss()))}function y(){if(!s()){A.colorMask(!0,!0,!0,!0),A.depthMask(!0),A.disable(A.BLEND),A.enable(A.DEPTH_TEST);for(var t=O.length,e=j.length,r=0;e>r;++r){var n=j[r];n.shape=G,n.begin();for(var i=0;t>i;++i)if(I[i]===r){var a=O[i];a.drawPick&&(a.pixelRatio=1,a.drawPick(V))}n.end()}}}function b(){if(!s()){e();var t=H.camera.tick();V.view=H.camera.matrix,F=F||t,D=D||t,z.pixelRatio=H.pixelRatio,R.pixelRatio=H.pixelRatio;var r=O.length,n=W[0],i=W[1];n[0]=n[1]=n[2]=1/0,i[0]=i[1]=i[2]=-(1/0);for(var o=0;r>o;++o){var l=O[o];l.pixelRatio=H.pixelRatio,l.axes=H.axes,F=F||!!l.dirty,D=D||!!l.dirty;var c=l.bounds;if(c)for(var f=c[0],h=c[1],d=0;3>d;++d)n[d]=Math.min(n[d],f[d]),i[d]=Math.max(i[d],h[d])}var g=H.bounds;if(H.autoBounds)for(var d=0;3>d;++d){if(i[d]d;++d)b=b||Z[0][d]!==g[0][d]||Z[1][d]!==g[1][d],Z[0][d]=g[0][d],Z[1][d]=g[1][d];if(b){for(var x=[0,0,0],o=0;3>o;++o)x[o]=a((g[1][o]-g[0][o])/10);z.autoTicks?z.update({bounds:g,tickSpacing:x}):z.update({bounds:g})}D=D||b,F=F||b;var _=A.drawingBufferWidth,w=A.drawingBufferHeight;q[0]=_,q[1]=w,G[0]=0|Math.max(_/H.pixelRatio,1),G[1]=0|Math.max(w/H.pixelRatio,1),v(B,H.fovy,_/w,H.zNear,H.zFar);for(var o=0;16>o;++o)U[o]=0;U[15]=1;for(var k=0,o=0;3>o;++o)k=Math.max(k,g[1][o]-g[0][o]);for(var o=0;3>o;++o)H.autoScale?U[5*o]=H.aspect[o]/(g[1][o]-g[0][o]):U[5*o]=1/k,H.autoCenter&&(U[12+o]=.5*-U[5*o]*(g[0][o]+g[1][o]));for(var o=0;r>o;++o){var l=O[o];l.axesBounds=g,H.clipToBounds&&(l.clipBounds=g)}if(T.object&&(H.snapToData?R.position=T.dataCoordinate:R.position=T.dataPosition,R.bounds=g),D&&(D=!1,y()),F){H.axesPixels=u(H.axes,V,_,w),H.onrender&&H.onrender(),A.bindFramebuffer(A.FRAMEBUFFER,null),A.viewport(0,0,_,w);var M=H.clearColor;A.clearColor(M[0],M[1],M[2],M[3]),A.clear(A.COLOR_BUFFER_BIT|A.DEPTH_BUFFER_BIT),A.depthMask(!0),A.colorMask(!0,!0,!0,!0),A.enable(A.DEPTH_TEST),A.depthFunc(A.LEQUAL),A.disable(A.BLEND),A.disable(A.CULL_FACE);var S=!1;z.enable&&(S=S||z.isTransparent(),z.draw(V)),R.axes=z,T.object&&R.draw(V),A.disable(A.CULL_FACE);for(var o=0;r>o;++o){var l=O[o];l.axes=z,l.pixelRatio=H.pixelRatio,l.isOpaque&&l.isOpaque()&&l.draw(V),l.isTransparent&&l.isTransparent()&&(S=!0)}if(S){E.shape=q,E.bind(),A.clear(A.DEPTH_BUFFER_BIT),A.colorMask(!1,!1,!1,!1),A.depthMask(!0),A.depthFunc(A.LESS),z.enable&&z.isTransparent()&&z.drawTransparent(V);for(var o=0;r>o;++o){var l=O[o];l.isOpaque&&l.isOpaque()&&l.draw(V)}A.enable(A.BLEND),A.blendEquation(A.FUNC_ADD),A.blendFunc(A.ONE,A.ONE_MINUS_SRC_ALPHA),A.colorMask(!0,!0,!0,!0),A.depthMask(!1),A.clearColor(0,0,0,0),A.clear(A.COLOR_BUFFER_BIT),z.isTransparent()&&z.drawTransparent(V);for(var o=0;r>o;++o){var l=O[o];l.isTransparent&&l.isTransparent()&&l.drawTransparent(V)}A.bindFramebuffer(A.FRAMEBUFFER,null),A.blendFunc(A.ONE,A.ONE_MINUS_SRC_ALPHA),A.disable(A.DEPTH_TEST),L.bind(),E.color[0].bind(0),L.uniforms.accumBuffer=0,p(A),A.disable(A.BLEND)}F=!1;for(var o=0;r>o;++o)O[o].dirty=!1}}}function x(){_||H.contextLost||(requestAnimationFrame(x),b())}t=t||{};var _=!1,w=(t.pixelRatio||parseFloat(window.devicePixelRatio),t.canvas);if(!w)if(w=document.createElement("canvas"),t.container){var k=t.container;k.appendChild(w)}else document.body.appendChild(w);var A=t.gl;if(A||(A=i(w,t.glOptions||{premultipliedAlpha:!0,antialias:!0})),!A)throw new Error("webgl not supported");var M=t.bounds||[[-10,-10,-10],[10,10,10]],T=new n,E=d(A,[A.drawingBufferWidth,A.drawingBufferHeight],{preferFloat:!0}),L=m(A),S=t.camera||{eye:[2,0,0],center:[0,0,0],up:[0,1,0],zoomMin:.1,zoomMax:100,mode:"turntable"},C=t.axes||{},z=c(A,C);z.enable=!C.disable;var P=t.spikes||{},R=f(A,P),O=[],I=[],N=[],j=[],F=!0,D=!0,B=new Array(16),U=new Array(16),V={view:null,projection:B,model:U},D=!0,q=[A.drawingBufferWidth,A.drawingBufferHeight],H={gl:A,contextLost:!1,pixelRatio:t.pixelRatio||parseFloat(window.devicePixelRatio),canvas:w,selection:T,camera:l(w,S),axes:z,axesPixels:null,spikes:R,bounds:M,objects:O,shape:q,aspect:t.aspectRatio||[1,1,1],pickRadius:t.pickRadius||10,zNear:t.zNear||.01,zFar:t.zFar||1e3,fovy:t.fovy||Math.PI/4,clearColor:t.clearColor||[0,0,0,0],autoResize:o(t.autoResize),autoBounds:o(t.autoBounds),autoScale:!!t.autoScale,autoCenter:o(t.autoCenter),clipToBounds:o(t.clipToBounds),snapToData:!!t.snapToData,onselect:t.onselect||null,onrender:t.onrender||null,onclick:t.onclick||null,cameraParams:V,oncontextloss:null,mouseListener:null},G=[A.drawingBufferWidth/H.pixelRatio|0,A.drawingBufferHeight/H.pixelRatio|0];H.autoResize&&e(),window.addEventListener("resize",e),H.update=function(t){_||(t=t||{},F=!0,D=!0)},H.add=function(t){_||(t.axes=z,O.push(t),I.push(-1),F=!0,D=!0,r())},H.remove=function(t){if(!_){var e=O.indexOf(t);0>e||(O.splice(e,1),I.pop(),F=!0,D=!0,r())}},H.dispose=function(){if(!_&&(_=!0,window.removeEventListener("resize",e),w.removeEventListener("webglcontextlost",s),H.mouseListener.enabled=!1,!H.contextLost)){z.dispose(),R.dispose();for(var t=0;ts;++s){var l=j[s].query(e,G[1]-r-1,H.pickRadius);if(l){if(l.distance>T.distance)continue;for(var c=0;i>c;++c){var u=O[c];if(I[c]===s){var f=u.pick(l);f&&(T.buttons=t,T.screen=l.coord,T.distance=l.distance,T.object=u,T.index=f.distance,T.dataPosition=f.position,T.dataCoordinate=f.dataCoordinate,T.data=f,o=!0)}}}}}a&&a!==T.object&&(a.highlight&&a.highlight(null),F=!0),T.object&&(T.object.highlight&&T.object.highlight(T.data),F=!0),o=o||T.object!==a,o&&H.onselect&&H.onselect(T),1&t&&!(1&X)&&H.onclick&&H.onclick(T),X=t}}),w.addEventListener("webglcontextlost",s);var W=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],Z=[W[0].slice(),W[1].slice()];return x(),H.redraw=function(){_||(F=!0,b())},H}e.exports=s;var l=t("3d-view-controls"),c=t("gl-axes3d"),u=t("gl-axes3d/properties"),f=t("gl-spikes3d"),h=t("gl-select-static"),d=t("gl-fbo"),p=t("a-big-triangle"),g=t("mouse-change"),v=t("gl-mat4/perspective"),m=t("./lib/shader")},{"./lib/shader":125,"3d-view-controls":126,"a-big-triangle":128,"gl-axes3d":129,"gl-axes3d/properties":139,"gl-fbo":82,"gl-mat4/perspective":99,"gl-select-static":155,"gl-spikes3d":141,"mouse-change":200}],143:[function(t,e,r){"use strict";e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n fragColor = color;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n",fragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n}\n",pickVertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 id;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\nuniform vec4 pickOffset;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n vec4 fragId = id + pickOffset;\n\n fragId.y += floor(fragId.x / 256.0);\n fragId.x -= floor(fragId.x / 256.0) * 256.0;\n\n fragId.z += floor(fragId.y / 256.0);\n fragId.y -= floor(fragId.y / 256.0) * 256.0;\n\n fragId.w += floor(fragId.z / 256.0);\n fragId.z -= floor(fragId.z / 256.0) * 256.0;\n\n fragColor = fragId / 255.0;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n",pickFragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = fragColor;\n}\n"}},{}],144:[function(t,e,r){"use strict";function n(t){if(t in h)return h[t];var e=u(t,{polygons:!0,font:"sans-serif",textAlign:"left",textBaseline:"alphabetic"}),r=[],n=[];e.forEach(function(t){t.forEach(function(t){for(var e=0;eo;++o)i[o]=Math.min(i[o],r[a+o]),i[2+o]=Math.max(i[2+o],r[a+o]);return h[t]={coords:r,normals:n,bounds:i}}function i(t,e,r,n,i,a,o){this.plot=t,this.shader=e,this.pickShader=r,this.positionBuffer=n,this.offsetBuffer=i,this.colorBuffer=a,this.idBuffer=o,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.numVertices=0,this.pickOffset=0,this.points=null}function a(t,e){var r=t.gl,n=o(r,f.vertex,f.fragment),a=o(r,f.pickVertex,f.pickFragment),l=s(r),c=s(r),u=s(r),h=s(r),d=new i(t,n,a,l,c,u,h);return d.update(e),t.addObject(d),d}e.exports=a;var o=t("gl-shader"),s=t("gl-buffer"),l=t("text-cache"),c=t("typedarray-pool"),u=t("vectorize-text"),f=t("./lib/shaders"),h={},d=i.prototype;!function(){function t(){var t=this.plot,n=this.bounds,i=t.viewBox,a=t.dataBox,o=t.pixelRatio,s=n[2]-n[0],l=n[3]-n[1],c=a[2]-a[0],u=a[3]-a[1];e[0]=2*s/c,e[4]=2*l/u,e[6]=2*(n[0]-a[0])/c-1,e[7]=2*(n[1]-a[1])/u-1;var f=i[2]-i[0],h=i[3]-i[1];r[0]=2*o/f,r[1]=2*o/h}var e=[1,0,0,0,1,0,0,0,1],r=[1,1];d.draw=function(){var n=this.plot,i=this.shader,a=this.numVertices;if(a){var o=n.gl;t.call(this),i.bind(),i.uniforms.pixelScale=r,i.uniforms.viewTransform=e,this.positionBuffer.bind(),i.attributes.position.pointer(),this.offsetBuffer.bind(),i.attributes.offset.pointer(),this.colorBuffer.bind(),i.attributes.color.pointer(o.UNSIGNED_BYTE,!0),o.drawArrays(o.TRIANGLES,0,a)}};var n=[0,0,0,0];d.drawPick=function(i){var a=this.plot,o=this.pickShader,s=this.numVertices,l=a.gl;if(this.pickOffset=i,!s)return i;for(var c=0;4>c;++c)n[c]=i>>8*c&255;return t.call(this),o.bind(),o.uniforms.pixelScale=r,o.uniforms.viewTransform=e,o.uniforms.pickOffset=n,this.positionBuffer.bind(),o.attributes.position.pointer(),this.offsetBuffer.bind(),o.attributes.offset.pointer(),this.idBuffer.bind(),o.attributes.id.pointer(l.UNSIGNED_BYTE,!1),l.drawArrays(l.TRIANGLES,0,s),i+this.numPoints}}(),d.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},d.update=function(t){t=t||{};var e=t.positions||[],r=t.colors||[],i=t.glyphs||[],a=t.sizes||[],o=t.borderWidths||[],s=t.borderColors||[];this.points=e;for(var u=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=0,h=0;h>1;for(var d=0;2>d;++d)u[d]=Math.min(u[d],e[2*h+d]),u[2+d]=Math.max(u[2+d],e[2*h+d])}u[0]===u[2]&&(u[2]+=1),u[3]===u[1]&&(u[3]+=1);for(var p=1/(u[2]-u[0]),g=1/(u[3]-u[1]),v=u[0],m=u[1],y=c.mallocFloat32(2*f),b=c.mallocFloat32(2*f),x=c.mallocUint8(4*f),_=c.mallocUint32(f),w=0,h=0;h=a?i(0,a-1,t,e,r,n):f(0,a-1,t,e,r,n)}function i(t,e,r,n,i,a){for(var o=t+1;e>=o;++o){for(var s=r[o],l=n[2*o],c=n[2*o+1],u=i[o],f=a[o],h=o;h>t;){var d=r[h-1],p=n[2*(h-1)];if((d-s||l-p)>=0)break;r[h]=d,n[2*h]=p,n[2*h+1]=n[2*h-1],i[h]=i[h-1],a[h]=a[h-1],h-=1}r[h]=s,n[2*h]=l,n[2*h+1]=c,i[h]=u,a[h]=f}}function a(t,e,r,n,i,a){var o=r[t],s=n[2*t],l=n[2*t+1],c=i[t],u=a[t];r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e],r[e]=o,n[2*e]=s,n[2*e+1]=l,i[e]=c,a[e]=u}function o(t,e,r,n,i,a){r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e]}function s(t,e,r,n,i,a,o){var s=n[t],l=i[2*t],c=i[2*t+1],u=a[t],f=o[t];n[t]=n[e],i[2*t]=i[2*e],i[2*t+1]=i[2*e+1],a[t]=a[e],o[t]=o[e],n[e]=n[r],i[2*e]=i[2*r],i[2*e+1]=i[2*r+1],a[e]=a[r],o[e]=o[r],n[r]=s,i[2*r]=l,i[2*r+1]=c,a[r]=u,o[r]=f}function l(t,e,r,n,i,a,o,s,l,c,u){s[t]=s[e],l[2*t]=l[2*e],l[2*t+1]=l[2*e+1],c[t]=c[e],u[t]=u[e],s[e]=r,l[2*e]=n,l[2*e+1]=i,c[e]=a,u[e]=o}function c(t,e,r,n,i){return(r[t]-r[e]||n[2*e]-n[2*t]||i[t]-i[e])<0}function u(t,e,r,n,i,a,o,s){return(e-a[t]||o[2*t]-r||i-s[t])<0}function f(t,e,r,n,d,p){var g=(e-t+1)/6|0,v=t+g,m=e-g,y=t+e>>1,b=y-g,x=y+g,_=v,w=b,k=y,A=x,M=m,T=t+1,E=e-1,L=0;c(_,w,r,n,d,p)&&(L=_,_=w,w=L),c(A,M,r,n,d,p)&&(L=A,A=M,M=L),c(_,k,r,n,d,p)&&(L=_,_=k,k=L),c(w,k,r,n,d,p)&&(L=w,w=k,k=L),c(_,A,r,n,d,p)&&(L=_,_=A,A=L),c(k,A,r,n,d,p)&&(L=k,k=A,A=L),c(w,M,r,n,d,p)&&(L=w,w=M,M=L),c(w,k,r,n,d,p)&&(L=w,w=k,k=L),c(A,M,r,n,d,p)&&(L=A,A=M,M=L);var S=r[w],C=n[2*w],z=n[2*w+1],P=d[w],R=p[w],O=r[A],I=n[2*A],N=n[2*A+1],j=d[A],F=p[A],D=_,B=k,U=M,V=v,q=y,H=m,G=r[D],Y=r[B],X=r[U];r[V]=G,r[q]=Y,r[H]=X;for(var W=0;2>W;++W){var Z=n[2*D+W],K=n[2*B+W],$=n[2*U+W];n[2*V+W]=Z,n[2*q+W]=K,n[2*H+W]=$}var Q=d[D],J=d[B],tt=d[U];d[V]=Q,d[q]=J,d[H]=tt;var et=p[D],rt=p[B],nt=p[U];p[V]=et,p[q]=rt,p[H]=nt,o(b,t,r,n,d,p),o(x,e,r,n,d,p);for(var it=T;E>=it;++it)if(u(it,S,C,z,P,r,n,d))it!==T&&a(it,T,r,n,d,p),++T;else if(!u(it,O,I,N,j,r,n,d))for(;;){if(u(E,O,I,N,j,r,n,d)){u(E,S,C,z,P,r,n,d)?(s(it,T,E,r,n,d,p),++T,--E):(a(it,E,r,n,d,p),--E);break}if(--E=T-2-t?i(t,T-2,r,n,d,p):f(t,T-2,r,n,d,p),h>=e-(E+2)?i(E+2,e,r,n,d,p):f(E+2,e,r,n,d,p),h>=E-T?i(T,E,r,n,d,p):f(T,E,r,n,d,p)}e.exports=n;var h=32},{}],148:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s){for(var l=r,c=r;n>c;++c){var u=t[2*c],f=t[2*c+1],h=e[c];u>=i&&o>=u&&f>=a&&s>=f&&(c===l?l+=1:(t[2*c]=t[2*l],t[2*c+1]=t[2*l+1],e[c]=e[l],t[2*l]=u,t[2*l+1]=f,e[l]=h,l+=1))}return l}function i(t,e,r){this.pixelSize=t,this.offset=e,this.count=r}function a(t,e,r,a){function l(i,a,o,s,c,u){var f=.5*o,h=s+1,d=c-s;r[_]=d,x[_++]=u;for(var p=0;2>p;++p)for(var g=0;2>g;++g){var v=i+p*f,m=a+g*f,y=n(t,e,h,c,v,m,v+f,m+f);if(y!==h){if(y-h>=Math.max(.9*d,32)){var b=c+s>>>1;l(v,m,f,h,b,u+1),h=b}l(v,m,f,h,y,u+1),h=y}}}var c=t.length>>>1;if(1>c)return[];for(var u=1/0,f=1/0,h=-(1/0),d=-(1/0),p=0;c>p;++p){var g=t[2*p],v=t[2*p+1];u=Math.min(u,g),h=Math.max(h,g),f=Math.min(f,v),d=Math.max(d,v),e[p]=p}u===h&&(h+=1+Math.abs(h)),f===d&&(d+=1+Math.abs(h));var m=1/(h-u),y=1/(d-f),b=Math.max(h-u,d-f);a=a||[0,0,0,0],a[0]=u,a[1]=f,a[2]=h,a[3]=d;var x=o.mallocInt32(c),_=0;l(u,f,b,0,c,0),s(x,t,e,r,c);for(var w=[],k=0,A=c,_=c-1;_>=0;--_){t[2*_]=(t[2*_]-u)*m,t[2*_+1]=(t[2*_+1]-f)*y;var M=x[_];M!==k&&(w.push(new i(b*Math.pow(.5,M),_+1,A-(_+1))),A=_+1,k=M)}return w.push(new i(b*Math.pow(.5,M+1),0,A)),o.free(x),w}var o=t("typedarray-pool"),s=t("./lib/sort");e.exports=a},{"./lib/sort":147,"typedarray-pool":237}],149:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.weightBuffer=n,this.shader=i,this.pickShader=a,this.scales=[],this.size=12,this.borderSize=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.pickOffset=0,this.points=null,this.xCoords=null}function i(t,e){var r=t.gl,i=o(r),s=o(r),l=o(r),c=a(r,u.pointVertex,u.pointFragment),f=a(r,u.pickVertex,u.pickFragment),h=new n(t,i,s,l,c,f);return h.update(e),t.addObject(h),h}var a=t("gl-shader"),o=t("gl-buffer"),s=t("binary-search-bounds"),l=t("snap-points-2d"),c=t("typedarray-pool"),u=t("./lib/shader");e.exports=i;var f=n.prototype;f.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.xCoords&&c.free(this.xCoords),this.plot.removeObject(this)},f.update=function(t){function e(e,r){return e in t?t[e]:r}t=t||{},this.size=e("size",12),this.color=e("color",[1,0,0,1]).slice(),this.borderSize=e("borderSize",1),this.borderColor=e("borderColor",[0,0,0,1]).slice(),this.xCoords&&c.free(this.xCoords);var r=t.positions,n=c.mallocFloat32(r.length),i=c.mallocInt32(r.length>>>1);n.set(r);var a=c.mallocFloat32(r.length);this.points=r,this.scales=l(n,i,a,this.bounds),this.offsetBuffer.update(n),this.pickBuffer.update(i),this.weightBuffer.update(a);for(var o=c.mallocFloat32(r.length>>>1),s=0,u=0;s>>1,this.pickOffset=0},f.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0,0,0];return function(r){var n=this.plot,i=this.pickShader,a=this.scales,o=this.offsetBuffer,l=this.pickBuffer,c=this.bounds,u=this.size,f=this.borderSize,h=n.gl,d=n.pickPixelRatio,p=n.viewBox,g=n.dataBox;if(0===this.pointCount)return r;var v=c[2]-c[0],m=c[3]-c[1],y=g[2]-g[0],b=g[3]-g[1],x=(p[2]-p[0])*d/n.pixelRatio,_=(p[3]-p[1])*d/n.pixelRatio,w=Math.min(y/x,b/_);t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(c[0]-g[0])/y-1,t[7]=2*(c[1]-g[1])/b-1,this.pickOffset=r,e[0]=255&r,e[1]=r>>8&255,e[2]=r>>16&255,e[3]=r>>24&255,i.bind(),i.uniforms.matrix=t,i.uniforms.color=this.color,i.uniforms.borderColor=this.borderColor,i.uniforms.pointSize=d*(u+f),i.uniforms.pickOffset=e,0===this.borderSize?i.uniforms.centerFraction=2:i.uniforms.centerFraction=u/(u+f+1.25),o.bind(),i.attributes.position.pointer(),l.bind(),i.attributes.pickId.pointer(h.UNSIGNED_BYTE);for(var k=this.xCoords,A=(g[0]-c[0]-w*u*d)/v,M=(g[2]-c[0]+w*u*d)/v,T=a.length-1;T>=0;--T){var E=a[T];if(!(E.pixelSize1)){var L=E.offset,S=E.count+L,C=s.ge(k,A,L,S-1),z=s.lt(k,M,C,S-1)+1;z>C&&h.drawArrays(h.POINTS,C,z-C)}}return r+this.pointCount}}(),f.draw=function(){var t=[1,0,0,0,1,0,0,0,1];return function(){var e=this.plot,r=this.shader,n=this.scales,i=this.offsetBuffer,a=this.bounds,o=this.size,l=this.borderSize,c=e.gl,u=e.pixelRatio,f=e.viewBox,h=e.dataBox;if(0!==this.pointCount){var d=a[2]-a[0],p=a[3]-a[1],g=h[2]-h[0],v=h[3]-h[1],m=f[2]-f[0],y=f[3]-f[1],b=Math.min(g/m,v/y);t[0]=2*d/g,t[4]=2*p/v,t[6]=2*(a[0]-h[0])/g-1,t[7]=2*(a[1]-h[1])/v-1,r.bind(),r.uniforms.matrix=t,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointSize=u*(o+l),r.uniforms.useWeight=1,0===this.borderSize?r.uniforms.centerFraction=2:r.uniforms.centerFraction=o/(o+l+1.25),i.bind(),r.attributes.position.pointer(),this.weightBuffer.bind(),r.attributes.weight.pointer();for(var x=this.xCoords,_=(h[0]-a[0]-b*o*u)/d,w=(h[2]-a[0]+b*o*u)/d,k=!0,A=n.length-1;A>=0;--A){var M=n[A];if(!(M.pixelSize1)){var T=M.offset,E=M.count+T,L=s.ge(x,_,T,E-1),S=s.lt(x,w,L,E-1)+1;S>L&&c.drawArrays(c.POINTS,L,S-L),k&&(k=!1,r.uniforms.useWeight=0)}}}}}(),f.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}}},{"./lib/shader":145,"binary-search-bounds":146,"gl-buffer":77,"gl-shader":156,"snap-points-2d":148,"typedarray-pool":237}],150:[function(t,e,r){"use strict";function n(t,e){var r=a[e];if(r||(r=a[e]={}),t in r)return r[t];for(var n=i(t,{textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),o=i(t,{triangles:!0,textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),s=[[1/0,1/0],[-(1/0),-(1/0)]],l=0;lu;++u)s[0][u]=Math.min(s[0][u],c[u]),s[1][u]=Math.max(s[1][u],c[u]);return r[t]=[o,n,s]}var i=t("vectorize-text");e.exports=n;var a={}},{"vectorize-text":239}],151:[function(t,e,r){function n(t,e){var r=i(t,e),n=r.attributes;return n.position.location=0,n.color.location=1,n.glyph.location=2,n.id.location=3,r}var i=t("gl-shader"),a="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1])) ) {\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}",o="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || any(greaterThan(position, clipBounds[1]))) {\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}",s="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) ||\n any(greaterThan(position, clipBounds[1])) ) {\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",l="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if(any(lessThan(dataCoordinate, fragClipBounds[0])) ||\n any(greaterThan(dataCoordinate, fragClipBounds[1])) ) {\n discard;\n } else {\n gl_FragColor = interpColor * opacity;\n }\n}\n",c="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if(any(lessThan(dataCoordinate, fragClipBounds[0])) || \n any(greaterThan(dataCoordinate, fragClipBounds[1])) ) {\n discard;\n } else {\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n }\n}",u=[{ -name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"glyph",type:"vec2"},{name:"id",type:"vec4"}],f={vertex:a,fragment:l,attributes:u},h={vertex:o,fragment:l,attributes:u},d={vertex:s,fragment:l,attributes:u},p={vertex:a,fragment:c,attributes:u},g={vertex:o,fragment:c,attributes:u},v={vertex:s,fragment:c,attributes:u};r.createPerspective=function(t){return n(t,f)},r.createOrtho=function(t){return n(t,h)},r.createProject=function(t){return n(t,d)},r.createPickPerspective=function(t){return n(t,p)},r.createPickOrtho=function(t){return n(t,g)},r.createPickProject=function(t){return n(t,v)}},{"gl-shader":156}],152:[function(t,e,r){"use strict";function n(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];return t[0]=e[0]*r+e[4]*n+e[8]*i+e[12]*a,t[1]=e[1]*r+e[5]*n+e[9]*i+e[13]*a,t[2]=e[2]*r+e[6]*n+e[10]*i+e[14]*a,t[3]=e[3]*r+e[7]*n+e[11]*i+e[15]*a,t}function i(t,e,r,i){return n(i,i,r),n(i,i,e),n(i,i,t)}function a(t,e){this.index=t,this.dataCoordinate=this.position=e}function o(t,e,r,n,i,o,s,l,c,u,f,h){this.gl=t,this.pixelRatio=1,this.shader=e,this.orthoShader=r,this.projectShader=n,this.pointBuffer=i,this.colorBuffer=o,this.glyphBuffer=s,this.idBuffer=l,this.vao=c,this.vertexCount=0,this.lineVertexCount=0,this.opacity=1,this.lineWidth=0,this.projectScale=[2/3,2/3,2/3],this.projectOpacity=[1,1,1],this.pickId=0,this.pickPerspectiveShader=u,this.pickOrthoShader=f,this.pickProjectShader=h,this.points=[],this._selectResult=new a(0,[0,0,0]),this.useOrtho=!0,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.axesProject=[!0,!0,!0],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.highlightId=[1,1,1,1],this.highlightScale=2,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.dirty=!0}function s(t){return t[0]=t[1]=t[2]=0,t}function l(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t}function c(t,e,r,n){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[r]=n,t}function u(t){for(var e=S,r=0;2>r;++r)for(var n=0;3>n;++n)e[r][n]=Math.max(Math.min(t[r][n],1e8),-1e8);return e}function f(t,e,r,n,a){var o,f=e.axesProject,h=e.gl,d=t.uniforms,p=r.model||x,g=r.view||x,v=r.projection||x,y=e.axesBounds,b=u(e.clipBounds);o=e.axes?e.axes.lastCubeProps.axis:[1,1,1],w[0]=2/h.drawingBufferWidth,w[1]=2/h.drawingBufferHeight,t.bind(),d.view=g,d.projection=v,d.screenSize=w,d.highlightId=e.highlightId,d.highlightScale=e.highlightScale,d.clipBounds=b,d.pickGroup=e.pickId/255,d.pixelRatio=e.pixelRatio;for(var _=0;3>_;++_)if(f[_]&&e.projectOpacity[_]<1===n){d.scale=e.projectScale[_],d.opacity=e.projectOpacity[_];for(var S=E,C=0;16>C;++C)S[C]=0;for(var C=0;4>C;++C)S[5*C]=1;S[5*_]=0,o[_]<0?S[12+_]=y[0][_]:S[12+_]=y[1][_],m(S,p,S),d.model=S;var z=(_+1)%3,P=(_+2)%3,R=s(k),O=s(A);R[z]=1,O[P]=1;var I=i(v,g,p,l(M,R)),N=i(v,g,p,l(T,O));if(Math.abs(I[1])>Math.abs(N[1])){var j=I;I=N,N=j,j=R,R=O,O=j;var F=z;z=P,P=F}I[0]<0&&(R[z]=-1),N[1]>0&&(O[P]=-1);for(var D=0,B=0,C=0;4>C;++C)D+=Math.pow(p[4*z+C],2),B+=Math.pow(p[4*P+C],2);R[z]/=Math.sqrt(D),O[P]/=Math.sqrt(B),d.axes[0]=R,d.axes[1]=O,d.fragClipBounds[0]=c(L,b[0],_,-1e8),d.fragClipBounds[1]=c(L,b[1],_,1e8),e.vao.draw(h.TRIANGLES,e.vertexCount),e.lineWidth>0&&(h.lineWidth(e.lineWidth),e.vao.draw(h.LINES,e.lineVertexCount,e.vertexCount))}}function h(t,e,r,n,i,a){var o=r.gl;if(r.vao.bind(),i===r.opacity<1||a){t.bind();var s=t.uniforms;s.model=n.model||x,s.view=n.view||x,s.projection=n.projection||x,w[0]=2/o.drawingBufferWidth,w[1]=2/o.drawingBufferHeight,s.screenSize=w,s.highlightId=r.highlightId,s.highlightScale=r.highlightScale,s.fragClipBounds=P,s.clipBounds=r.axes.bounds,s.opacity=r.opacity,s.pickGroup=r.pickId/255,s.pixelRatio=r.pixelRatio,r.vao.draw(o.TRIANGLES,r.vertexCount),r.lineWidth>0&&(o.lineWidth(r.lineWidth),r.vao.draw(o.LINES,r.lineVertexCount,r.vertexCount))}f(e,r,n,i,a),r.vao.unbind()}function d(t){var e=t.gl,r=y.createPerspective(e),n=y.createOrtho(e),i=y.createProject(e),a=y.createPickPerspective(e),s=y.createPickOrtho(e),l=y.createPickProject(e),c=p(e),u=p(e),f=p(e),h=p(e),d=g(e,[{buffer:c,size:3,type:e.FLOAT},{buffer:u,size:4,type:e.FLOAT},{buffer:f,size:2,type:e.FLOAT},{buffer:h,size:4,type:e.UNSIGNED_BYTE,normalized:!0}]),v=new o(e,r,n,i,c,u,f,h,d,a,s,l);return v.update(t),v}var p=t("gl-buffer"),g=t("gl-vao"),v=t("typedarray-pool"),m=t("gl-mat4/multiply"),y=t("./lib/shaders"),b=t("./lib/glyphs"),x=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];e.exports=d;var _=o.prototype;_.pickSlots=1,_.setPickBase=function(t){this.pickId=t},_.isTransparent=function(){if(this.opacity<1)return!0;for(var t=0;3>t;++t)if(this.axesProject[t]&&this.projectOpacity[t]<1)return!0;return!1},_.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;3>t;++t)if(this.axesProject[t]&&this.projectOpacity[t]>=1)return!0;return!1};var w=[0,0],k=[0,0,0],A=[0,0,0],M=[0,0,0,1],T=[0,0,0,1],E=x.slice(),L=[0,0,0],S=[[0,0,0],[0,0,0]],C=[-1e8,-1e8,-1e8],z=[1e8,1e8,1e8],P=[C,z];_.draw=function(t){var e=this.useOrtho?this.orthoShader:this.shader;h(e,this.projectShader,this,t,!1,!1)},_.drawTransparent=function(t){var e=this.useOrtho?this.orthoShader:this.shader;h(e,this.projectShader,this,t,!0,!1)},_.drawPick=function(t){var e=this.useOrtho?this.pickOrthoShader:this.pickPerspectiveShader;h(e,this.pickProjectShader,this,t,!1,!0)},_.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[2]+(t.value[1]<<8)+(t.value[0]<<16);if(e>=this.pointCount||0>e)return null;var r=this.points[e],n=this._selectResult;n.index=e;for(var i=0;3>i;++i)n.position[i]=n.dataCoordinate[i]=r[i];return n},_.highlight=function(t){if(t){var e=t.index,r=255&e,n=e>>8&255,i=e>>16&255;this.highlightId=[r/255,n/255,i/255,0]}else this.highlightId=[1,1,1,1]},_.update=function(t){if(t=t||{},"perspective"in t&&(this.useOrtho=!t.perspective),"orthographic"in t&&(this.useOrtho=!!t.orthographic),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"project"in t)if(Array.isArray(t.project))this.axesProject=t.project;else{var e=!!t.project;this.axesProject=[e,e,e]}if("projectScale"in t)if(Array.isArray(t.projectScale))this.projectScale=t.projectScale.slice();else{var r=+t.projectScale;this.projectScale=[r,r,r]}if("projectOpacity"in t)if(Array.isArray(t.projectOpacity))this.projectOpacity=t.projectOpacity.slice();else{var r=+t.projectOpacity;this.projectOpacity=[r,r,r]}"opacity"in t&&(this.opacity=t.opacity),this.dirty=!0;var n=t.position;if(n){var i=t.font||"normal",a=t.alignment||[0,0],o=[1/0,1/0,1/0],s=[-(1/0),-(1/0),-(1/0)],l=t.glyph,c=t.color,u=t.size,f=t.angle,h=t.lineColor,d=0,p=0,g=0,m=n.length;t:for(var y=0;m>y;++y){for(var x=n[y],_=0;3>_;++_)if(isNaN(x[_])||!isFinite(x[_]))continue t;var w;w=Array.isArray(l)?b(l[y],i):l?b(l,i):b("\u25cf",i);var k=w[0],A=w[1],M=w[2];p+=3*k.cells.length,g+=2*A.edges.length}var T=p+g,E=v.mallocFloat(3*T),L=v.mallocFloat(4*T),S=v.mallocFloat(2*T),C=v.mallocUint32(T),z=[0,a[1]],P=0,R=p,O=[0,0,0,1],I=[0,0,0,1],N=Array.isArray(c)&&Array.isArray(c[0]),j=Array.isArray(h)&&Array.isArray(h[0]);t:for(var y=0;m>y;++y){for(var x=n[y],_=0;3>_;++_){if(isNaN(x[_])||!isFinite(x[_])){d+=1;continue t}s[_]=Math.max(s[_],x[_]),o[_]=Math.min(o[_],x[_])}var w;w=Array.isArray(l)?b(l[y],i):l?b(l,i):b("\u25cf",i);var k=w[0],A=w[1],M=w[2];if(Array.isArray(c)){var F;if(F=N?c[y]:c,3===F.length){for(var _=0;3>_;++_)O[_]=F[_];O[3]=1}else if(4===F.length)for(var _=0;4>_;++_)O[_]=F[_]}else O[0]=O[1]=O[2]=0,O[3]=1;if(Array.isArray(h)){var F;if(F=j?h[y]:h,3===F.length){for(var _=0;3>_;++_)I[_]=F[_];I[_]=1}else if(4===F.length)for(var _=0;4>_;++_)I[_]=F[_]}else I[0]=I[1]=I[2]=0,I[3]=1;var D=.5;Array.isArray(u)?D=+u[y]:u?D=+u:this.useOrtho&&(D=12);var B=0;Array.isArray(f)?B=+f[y]:f&&(B=+f);for(var U=Math.cos(B),V=Math.sin(B),x=n[y],_=0;3>_;++_)s[_]=Math.max(s[_],x[_]),o[_]=Math.min(o[_],x[_]);a[0]<0?z[0]=a[0]*(1+M[1][0]):a[0]>0&&(z[0]=-a[0]*(1+M[0][0]));for(var q=k.cells,H=k.positions,_=0;_Y;++Y){for(var X=0;3>X;++X)E[3*P+X]=x[X];for(var X=0;4>X;++X)L[4*P+X]=O[X];C[P]=d;var W=H[G[Y]];S[2*P]=D*(U*W[0]-V*W[1]+z[0]),S[2*P+1]=D*(V*W[0]+U*W[1]+z[1]),P+=1}for(var q=A.edges,H=A.positions,_=0;_Y;++Y){for(var X=0;3>X;++X)E[3*R+X]=x[X];for(var X=0;4>X;++X)L[4*R+X]=I[X];C[R]=d;var W=H[G[Y]];S[2*R]=D*(U*W[0]-V*W[1]+z[0]),S[2*R+1]=D*(V*W[0]+U*W[1]+z[1]),R+=1}d+=1}this.vertexCount=p,this.lineVertexCount=g,this.pointBuffer.update(E),this.colorBuffer.update(L),this.glyphBuffer.update(S),this.idBuffer.update(new Uint32Array(C)),v.free(E),v.free(L),v.free(S),v.free(C),this.bounds=[o,s],this.points=n,this.pointCount=n.length}},_.dispose=function(){this.shader.dispose(),this.orthoShader.dispose(),this.pickPerspectiveShader.dispose(),this.pickOrthoShader.dispose(),this.vao.dispose(),this.pointBuffer.dispose(),this.colorBuffer.dispose(),this.glyphBuffer.dispose(),this.idBuffer.dispose()}},{"./lib/glyphs":150,"./lib/shaders":151,"gl-buffer":77,"gl-mat4/multiply":98,"gl-vao":185,"typedarray-pool":237}],153:[function(t,e,r){"use strict";r.boxVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n",r.boxFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"},{}],154:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.boxBuffer=e,this.boxShader=r,this.enabled=!0,this.selectBox=[1/0,1/0,-(1/0),-(1/0)],this.borderColor=[0,0,0,1],this.innerFill=!1,this.innerColor=[0,0,0,.25],this.outerFill=!0,this.outerColor=[0,0,0,.5],this.borderWidth=10}function i(t,e){var r=t.gl,i=o(r,[0,0,0,1,1,0,1,1]),l=a(r,s.boxVertex,s.boxFragment),c=new n(t,i,l);return c.update(e),t.addOverlay(c),c}var a=t("gl-shader"),o=t("gl-buffer"),s=t("./lib/shaders");e.exports=i;var l=n.prototype;l.draw=function(){if(this.enabled){var t=this.plot,e=this.selectBox,r=this.borderWidth,n=(this.innerFill,this.innerColor),i=(this.outerFill,this.outerColor),a=this.borderColor,o=t.box,s=t.screenBox,l=t.dataBox,c=t.viewBox,u=t.pixelRatio,f=(e[0]-l[0])*(c[2]-c[0])/(l[2]-l[0])+c[0],h=(e[1]-l[1])*(c[3]-c[1])/(l[3]-l[1])+c[1],d=(e[2]-l[0])*(c[2]-c[0])/(l[2]-l[0])+c[0],p=(e[3]-l[1])*(c[3]-c[1])/(l[3]-l[1])+c[1];if(f=Math.max(f,c[0]),h=Math.max(h,c[1]),d=Math.min(d,c[2]),p=Math.min(p,c[3]),!(f>d||h>p)){o.bind();var g=s[2]-s[0],v=s[3]-s[1];if(this.outerFill&&(o.drawBox(0,0,g,h,i),o.drawBox(0,h,f,p,i),o.drawBox(0,p,g,v,i),o.drawBox(d,h,g,p,i)),this.innerFill&&o.drawBox(f,h,d,p,n),r>0){var m=r*u;o.drawBox(f-m,h-m,d+m,h+m,a),o.drawBox(f-m,p-m,d+m,p+m,a),o.drawBox(f-m,h-m,f+m,p+m,a),o.drawBox(d-m,h-m,d+m,p+m,a)}}}},l.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},l.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":153,"gl-buffer":77,"gl-shader":156}],155:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.coord=[t,e],this.id=r,this.value=n,this.distance=i}function i(t,e,r){this.gl=t,this.fbo=e,this.buffer=r,this._readTimeout=null;var n=this;this._readCallback=function(){n.gl&&(e.bind(),t.readPixels(0,0,e.shape[0],e.shape[1],t.RGBA,t.UNSIGNED_BYTE,n.buffer),n._readTimeout=null)}}function a(t,e){var r=o(t,e),n=s.mallocUint8(e[0]*e[1]*4);return new i(t,r,n)}e.exports=a;var o=t("gl-fbo"),s=t("typedarray-pool"),l=t("ndarray"),c=t("bit-twiddle").nextPow2,u=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(255>_inline_34_arg0_||255>_inline_34_arg1_||255>_inline_34_arg2_||255>_inline_34_arg3_){var _inline_34_l=_inline_34_arg4_-_inline_34_arg6_[0],_inline_34_a=_inline_34_arg5_-_inline_34_arg6_[1],_inline_34_f=_inline_34_l*_inline_34_l+_inline_34_a*_inline_34_a;_inline_34_fthis.buffer.length){s.free(this.buffer);for(var n=this.buffer=s.mallocUint8(c(r*e*4)),i=0;r*e*4>i;++i)n[i]=255}return t}}}),f.begin=function(){var t=this.gl;this.shape;t&&(this.fbo.bind(),t.clearColor(1,1,1,1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT))},f.end=function(){var t=this.gl;t&&(t.bindFramebuffer(t.FRAMEBUFFER,null),this._readTimeout||clearTimeout(this._readTimeout),this._readTimeout=setTimeout(this._readCallback,1))},f.query=function(t,e,r){if(!this.gl)return null;var i=this.fbo.shape.slice();t=0|t,e=0|e,"number"!=typeof r&&(r=1);var a=0|Math.min(Math.max(t-r,0),i[0]),o=0|Math.min(Math.max(t+r,0),i[0]),s=0|Math.min(Math.max(e-r,0),i[1]),c=0|Math.min(Math.max(e+r,0),i[1]);if(a>=o||s>=c)return null;var f=[o-a,c-s],h=l(this.buffer,[f[0],f[1],4],[4,4*i[0],1],4*(a+i[0]*s)),d=u(h.hi(f[0],f[1],1),r,r),p=d[0],g=d[1];if(0>p||Math.pow(this.radius,2)=0){for(var A=0|k.type.charAt(k.type.length-1),M=new Array(A),T=0;A>T;++T)M[T]=_.length,x.push(k.name+"["+T+"]"),"number"==typeof k.location?_.push(k.location+T):Array.isArray(k.location)&&k.location.length===A&&"number"==typeof k.location[T]?_.push(0|k.location[T]):_.push(-1);b.push({name:k.name,type:k.type,locations:M})}else b.push({name:k.name,type:k.type,locations:[_.length]}),x.push(k.name),"number"==typeof k.location?_.push(0|k.location):_.push(-1)}for(var E=0,w=0;w<_.length;++w)if(_[w]<0){for(;_.indexOf(E)>=0;)E+=1;_[w]=E}var L=new Array(r.length);a(),d._relink=a,d.types={uniforms:l(r),attributes:l(n)},d.attributes=s(p,d,b,_),Object.defineProperty(d,"uniforms",o(p,d,r,L))},e.exports=a},{"./lib/GLError":157,"./lib/create-attributes":158,"./lib/create-uniforms":159,"./lib/reflect":160,"./lib/runtime-reflect":161,"./lib/shader-cache":162}],157:[function(t,e,r){function n(t,e,r){this.shortMessage=e||"",this.longMessage=r||"",this.rawError=t||"",this.message="gl-shader: "+(e||t||"")+(r?"\n"+r:""),this.stack=(new Error).stack}n.prototype=new Error,n.prototype.name="GLError",n.prototype.constructor=n,e.exports=n},{}],158:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}function i(t,e,r,i,a,o,s){for(var l=["gl","v"],c=[],u=0;a>u;++u)l.push("x"+u),c.push("x"+u);l.push("if(x0.length===void 0){return gl.vertexAttrib"+a+"f(v,"+c.join()+")}else{return gl.vertexAttrib"+a+"fv(v,x0)}");var f=Function.apply(null,l),h=new n(t,e,r,i,a,f);Object.defineProperty(o,s,{set:function(e){return t.disableVertexAttribArray(i[r]),f(t,i[r],e),e},get:function(){return h},enumerable:!0})}function a(t,e,r,n,a,o,s){for(var l=new Array(a),c=new Array(a),u=0;a>u;++u)i(t,e,r[u],n,a,l,u),c[u]=l[u];Object.defineProperty(l,"location",{set:function(t){if(Array.isArray(t))for(var e=0;a>e;++e)c[e].location=t[e];else for(var e=0;a>e;++e)c[e].location=t+e;return t},get:function(){for(var t=new Array(a),e=0;a>e;++e)t[e]=n[r[e]];return t},enumerable:!0}),l.pointer=function(e,i,o,s){e=e||t.FLOAT,i=!!i,o=o||a*a,s=s||0;for(var l=0;a>l;++l){var c=n[r[l]];t.vertexAttribPointer(c,a,e,i,o,s+l*a),t.enableVertexAttribArray(c)}};var f=new Array(a),h=t["vertexAttrib"+a+"fv"];Object.defineProperty(o,s,{set:function(e){for(var i=0;a>i;++i){var o=n[r[i]];if(t.disableVertexAttribArray(o),Array.isArray(e[0]))h.call(t,o,e[i]);else{for(var s=0;a>s;++s)f[s]=e[a*i+s];h.call(t,o,f)}}return e},get:function(){return l},enumerable:!0})}function o(t,e,r,n){for(var o={},l=0,c=r.length;c>l;++l){var u=r[l],f=u.name,h=u.type,d=u.locations;switch(h){case"bool":case"int":case"float":i(t,e,d[0],n,1,o,f);break;default:if(h.indexOf("vec")>=0){var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);i(t,e,d[0],n,p,o,f)}else{if(!(h.indexOf("mat")>=0))throw new s("","Unknown data type for attribute "+f+": "+h);var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);a(t,e,d,n,p,o,f)}}}return o}e.exports=o;var s=t("./GLError"),l=n.prototype;l.pointer=function(t,e,r,n){var i=this,a=i._gl,o=i._locations[i._index];a.vertexAttribPointer(o,i._dimension,t||a.FLOAT,!!e,r||0,n||0),a.enableVertexAttribArray(o)},l.set=function(t,e,r,n){return this._constFunc(this._locations[this._index],t,e,r,n)},Object.defineProperty(l,"location",{get:function(){return this._locations[this._index]},set:function(t){return t!==this._locations[this._index]&&(this._locations[this._index]=0|t,this._wrapper.program=null),0|t}})},{"./GLError":157}],159:[function(t,e,r){"use strict";function n(t){var e=new Function("y","return function(){return y}");return e(t)}function i(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e,r,a){function l(r){var n=new Function("gl","wrapper","locations","return function(){return gl.getUniform(wrapper.program,locations["+r+"])}");return n(t,e,a)}function c(t,e,r){switch(r){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+e+"],obj"+t+")";case"float":return"gl.uniform1f(locations["+e+"],obj"+t+")";default:var n=r.indexOf("vec");if(!(n>=0&&1>=n&&r.length===4+n)){if(0===r.indexOf("mat")&&4===r.length){var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+i+"fv(locations["+e+"],false,obj"+t+")"}throw new s("","Unknown uniform data type for "+name+": "+r)}var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+i+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+i+"fv(locations["+e+"],obj"+t+")";default:throw new s("","Unrecognized data type for vector "+name+": "+r)}}}function u(t,e){if("object"!=typeof e)return[[t,e]];var r=[];for(var n in e){var i=e[n],a=t;a+=parseInt(n)+""===n?"["+n+"]":"."+n,"object"==typeof i?r.push.apply(r,u(a,i)):r.push([a,i])}return r}function f(e){for(var n=["return function updateProperty(obj){"],i=u("",e),o=0;o=0&&1>=e&&t.length===4+e){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid data type");return"b"===t.charAt(0)?i(r,!1):i(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+t);return i(r*r,0)}throw new s("","Unknown uniform data type for "+name+": "+t)}}function d(t,e,i){if("object"==typeof i){var o=p(i);Object.defineProperty(t,e,{get:n(o),set:f(i),enumerable:!0,configurable:!1})}else a[i]?Object.defineProperty(t,e,{get:l(i),set:f(i),enumerable:!0,configurable:!1}):t[e]=h(r[i].type)}function p(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var c=1;ca;++a){var o=t.getActiveUniform(e,a);if(o){var s=n(t,o.type);if(o.size>1)for(var l=0;la;++a){var o=t.getActiveAttrib(e,a);o&&i.push({name:o.name,type:n(t,o.type)})}return i}r.uniforms=i,r.attributes=a;var o={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"},s=null},{}],162:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.id=t,this.src=e,this.type=r,this.shader=n,this.count=a,this.programs=[],this.cache=o}function i(t){this.gl=t,this.shaders=[{},{}],this.programs={}}function a(t,e,r){var n=t.createShader(e);if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){var i=t.getShaderInfoLog(n);try{var a=f(i,r,e)}catch(o){throw console.warn("Failed to format compiler error: "+o),new u(i,"Error compiling shader:\n"+i)}throw new u(i,a.short,a.long)}return n}function o(t,e,r,n,i){var a=t.createProgram();t.attachShader(a,e),t.attachShader(a,r);for(var o=0;on;++n){var a=t.programs[r[n]];a&&(delete t.programs[n],e.deleteProgram(a))}e.deleteShader(this.shader),delete t.shaders[this.type===e.FRAGMENT_SHADER|0][this.src]}};var g=i.prototype;g.getShaderReference=function(t,e){var r=this.gl,i=this.shaders[t===r.FRAGMENT_SHADER|0],o=i[e];if(o&&r.isShader(o.shader))o.count+=1;else{var s=a(r,t,e);o=i[e]=new n(p++,e,t,s,[],1,this)}return o},g.getProgram=function(t,e,r,n){var i=[t.id,e.id,r.join(":"),n.join(":")].join("@"),a=this.programs[i];return a&&this.gl.isProgram(a)||(this.programs[i]=a=o(this.gl,t.shader,e.shader,r,n),t.programs.push(i),e.programs.push(i)),a}},{"./GLError":157,"gl-format-compiler-error":163,"weakmap-shim":173}],163:[function(t,e,r){function n(t,e,r){"use strict";var n=o(e)||"of unknown name (see npm glsl-shader-name)",l="unknown type";void 0!==r&&(l=r===a.FRAGMENT_SHADER?"fragment":"vertex");for(var c=i("Error compiling %s shader %s:\n",l,n),u=i("%s%s",c,t),f=t.split("\n"),h={},d=0;ds;s++)if(g=i(t[s]),"string"===g)v[v.length]=t[s];else if("array"===g){if(c=t[s],c[2])for(n=e[d],l=0;l=0),c[8]){case"b":n=n.toString(2);break;case"c":n=String.fromCharCode(n);break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,c[6]?parseInt(c[6]):0);break;case"e":n=c[7]?n.toExponential(c[7]):n.toExponential();break;case"f":n=c[7]?parseFloat(n).toFixed(c[7]):parseFloat(n);break;case"g":n=c[7]?parseFloat(n).toPrecision(c[7]):parseFloat(n);break;case"o":n=n.toString(8);break;case"s":n=(n=String(n))&&c[7]?n.substring(0,c[7]):n;break;case"u":n>>>=0;break;case"x":n=n.toString(16);break;case"X":n=n.toString(16).toUpperCase()}o.json.test(c[8])?v[v.length]=n:(!o.number.test(c[8])||m&&!c[3]?y="":(y=m?"+":"-",n=n.toString().replace(o.sign,"")),f=c[4]?"0"===c[4]?"0":c[4].charAt(1):" ",h=c[6]-(y+n).length,u=c[6]&&h>0?a(f,h):"",v[v.length]=c[5]?y+n+u:"0"===f?y+u+n:u+y+n)}return v.join("")},r.cache={},r.parse=function(t){for(var e=t,r=[],n=[],i=0;e;){if(null!==(r=o.text.exec(e)))n[n.length]=r[0];else if(null!==(r=o.modulo.exec(e)))n[n.length]="%";else{if(null===(r=o.placeholder.exec(e)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){i|=1;var a=[],s=r[2],l=[];if(null===(l=o.key.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(a[a.length]=l[1];""!==(s=s.substring(l[0].length));)if(null!==(l=o.key_access.exec(s)))a[a.length]=l[1];else{if(null===(l=o.index_access.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");a[a.length]=l[1]}r[2]=a}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=r}e=e.substring(r[0].length)}return n};var s=function(t,e,n){return n=(e||[]).slice(0),n.splice(0,0,t),r.apply(null,n)};"undefined"!=typeof n?(n.sprintf=r,n.vsprintf=s):(e.sprintf=r,e.vsprintf=s,"function"==typeof t&&t.amd&&t(function(){return{sprintf:r,vsprintf:s}}))}("undefined"==typeof window?this:window)},{}],171:[function(t,e,r){function n(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:i(e,t)}}var i=t("./hidden-store.js");e.exports=n},{"./hidden-store.js":172}],172:[function(t,e,r){function n(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}e.exports=n},{}],173:[function(t,e,r){function n(){var t=i();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){t(e).value=r},has:function(e){return"value"in t(e)},"delete":function(e){return delete t(e).value}}}var i=t("./create-store.js");e.exports=n},{"./create-store.js":171}],174:[function(t,e,r){"use strict";function n(t){this.plot=t,this.enable=[!0,!0,!1,!1],this.width=[1,1,1,1],this.color=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.center=[1/0,1/0]}function i(t,e){var r=new n(t);return r.update(e),t.addOverlay(r),r}e.exports=i;var a=n.prototype;a.update=function(t){t=t||{},this.enable=(t.enable||[!0,!0,!1,!1]).slice(),this.width=(t.width||[1,1,1,1]).slice(),this.color=(t.color||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]).map(function(t){return t.slice()}),this.center=(t.center||[1/0,1/0]).slice(),this.plot.setOverlayDirty()},a.draw=function(){var t=this.enable,e=this.width,r=this.color,n=this.center,i=this.plot,a=i.line,o=i.dataBox,s=i.viewBox;if(a.bind(),o[0]<=n[0]&&n[0]<=o[2]&&o[1]<=n[1]&&n[1]<=o[3]){var l=s[0]+(n[0]-o[0])/(o[2]-o[0])*(s[2]-s[0]),c=s[1]+(n[1]-o[1])/(o[3]-o[1])*(s[3]-s[1]);t[0]&&a.drawLine(l,c,s[0],c,e[0],r[0]),t[1]&&a.drawLine(l,c,l,s[1],e[1],r[1]),t[2]&&a.drawLine(l,c,s[2],c,e[2],r[2]),t[3]&&a.drawLine(l,c,l,s[3],e[3],r[3])}},a.dispose=function(){this.plot.removeOverlay(this)}},{}],175:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute vec3 f;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 lightPosition, eyePosition;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n worldCoordinate = vec3(uv.zw, f.x);\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 //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",a="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(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\n\n\nfloat beckmannSpecular_1_1(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness) {\n return beckmannDistribution_2_0(dot(surfaceNormal, normalize(lightDirection + viewDirection)), roughness);\n}\n\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;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n if(kill > 0.0 ||\n any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n discard;\n }\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 = beckmannSpecular_1_1(L, V, N, roughness);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(colormap, vec2(value, value));\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",o="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\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",s="precision mediump float;\n#define GLSLIFY 1\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 any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n 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";r.createShader=function(t){var e=n(t,i,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createPickShader=function(t){var e=n(t,i,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createContourShader=function(t){var e=n(t,o,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e},r.createPickContourShader=function(t){var e=n(t,o,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e}},{"gl-shader":156}],176:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],177:[function(t,e,r){"use strict";function n(t){if(t in l)return l[t];for(var e=[],r=0;t>r;++r)e.push("out",r,"s=0.5*(inp",r,"l-inp",r,"r);");for(var n=["array"],i=["junk"],r=0;t>r;++r){n.push("array"),i.push("out"+r+"s");var a=o(t);a[r]=-1,n.push({array:0,offset:a.slice()}),a[r]=1,n.push({array:0,offset:a.slice()}),i.push("inp"+r+"l","inp"+r+"r")}return l[t]=s({args:n,pre:u,post:u,body:{body:e.join(""),args:i.map(function(t){return{name:t,lvalue:0===t.indexOf("out"),rvalue:0===t.indexOf("inp"),count:"junk"!==t|0}}),thisVars:[],localVars:[]},funcName:"fdTemplate"+t})}function i(t){function e(e){for(var r=a-e.length,n=[],i=[],s=[],l=0;a>l;++l)e.indexOf(l+1)>=0?s.push("0"):e.indexOf(-(l+1))>=0?s.push("s["+l+"]-1"):(s.push("-1"),n.push("1"),i.push("s["+l+"]-2"));var c=".lo("+n.join()+").hi("+i.join()+")";if(0===n.length&&(c=""),r>0){o.push("if(1");for(var l=0;a>l;++l)e.indexOf(l+1)>=0||e.indexOf(-(l+1))>=0||o.push("&&s[",l,"]>2");o.push("){grad",r,"(src.pick(",s.join(),")",c);for(var l=0;a>l;++l)e.indexOf(l+1)>=0||e.indexOf(-(l+1))>=0||o.push(",dst.pick(",s.join(),",",l,")",c);o.push(");")}for(var l=0;l1){dst.set(",s.join(),",",u,",0.5*(src.get(",h.join(),")-src.get(",d.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):o.push("if(s[",u,"]>1){diff(",f,",src.pick(",h.join(),")",c,",src.pick(",d.join(),")",c,");}else{zero(",f,");};");break;case"mirror":0===r?o.push("dst.set(",s.join(),",",u,",0);"):o.push("zero(",f,");");break;case"wrap":var p=s.slice(),g=s.slice();e[l]<0?(p[u]="s["+u+"]-2",g[u]="0"):(p[u]="s["+u+"]-1",g[u]="1"),0===r?o.push("if(s[",u,"]>2){dst.set(",s.join(),",",u,",0.5*(src.get(",p.join(),")-src.get(",g.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):o.push("if(s[",u,"]>2){diff(",f,",src.pick(",p.join(),")",c,",src.pick(",g.join(),")",c,");}else{zero(",f,");};");break;default:throw new Error("ndarray-gradient: Invalid boundary condition")}}r>0&&o.push("};")}var r=t.join(),i=c[r];if(i)return i;for(var a=t.length,o=["function gradient(dst,src){var s=src.shape.slice();"],s=0;1<
s;++s){for(var u=[],d=0;a>d;++d)s&1<=s;++s)v.push("grad"+s),m.push(n(s));v.push(o.join(""));var y=Function.apply(void 0,v),i=y.apply(void 0,m);return l[r]=i,i}function a(t,e,r){if(Array.isArray(r)){if(r.length!==e.dimension)throw new Error("ndarray-gradient: invalid boundary conditions")}else r="string"==typeof r?o(e.dimension,r):o(e.dimension,"clamp");if(t.dimension!==e.dimension+1)throw new Error("ndarray-gradient: output dimension must be +1 input dimension");if(t.shape[e.dimension]!==e.dimension)throw new Error("ndarray-gradient: output shape must match input shape");for(var n=0;nr;++r)for(o=o||e.surfaceProject[r],n=0;3>n;++n)s=s||e.contourProject[r][n];for(r=0;3>r;++r){var l=D.projections[r];for(n=0;16>n;++n)l[n]=0;for(n=0;4>n;++n)l[5*n]=1;l[5*r]=0,l[12+r]=e.axesBounds[+(a[r]>0)][r],k(l,t.model,l);var c=D.clipBounds[r];for(i=0;2>i;++i)for(n=0;3>n;++n)c[i][n]=t.clipBounds[i][n];c[0][r]=-1e8,c[1][r]=1e8}return D.showSurface=o,D.showContour=s,D}function s(t,e){t=t||{};var r=this.gl;r.disable(r.CULL_FACE),this._colorMap.bind(0);var n=B;n.model=t.model||R,n.view=t.view||R,n.projection=t.projection||R,n.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]],n.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]],n.contourColor=this.contourColor[0],n.inverseModel=A(n.inverseModel,n.model);for(var i=0;2>i;++i)for(var a=n.clipBounds[i],s=0;3>s;++s)a[s]=Math.min(Math.max(this.clipBounds[i][s],-1e8),1e8);n.kambient=this.ambientLight,n.kdiffuse=this.diffuseLight,n.kspecular=this.specularLight,n.roughness=this.roughness,n.fresnel=this.fresnel,n.opacity=this.opacity,n.height=0,n.permutation=V;var l=U;for(k(l,n.view,n.model),k(l,n.projection,l),A(l,l),i=0;3>i;++i)n.eyePosition[i]=l[12+i]/l[15];var c=l[15];for(i=0;3>i;++i)c+=this.lightPosition[i]*l[4*i+3];for(i=0;3>i;++i){var u=l[12+i];for(s=0;3>s;++s)u+=l[4*s+i]*this.lightPosition[s];n.lightPosition[i]=u/c}var f=o(n,this);if(f.showSurface&&e===this.opacity<1){for(this._shader.bind(),this._shader.uniforms=n,this._vao.bind(),this.showSurface&&this._vertexCount&&this._vao.draw(r.TRIANGLES,this._vertexCount),i=0;3>i;++i)this.surfaceProject[i]&&this.vertexCount&&(this._shader.uniforms.model=f.projections[i],this._shader.uniforms.clipBounds=f.clipBounds[i],this._vao.draw(r.TRIANGLES,this._vertexCount));this._vao.unbind()}if(f.showContour&&!e){var h=this._contourShader;n.kambient=1,n.kdiffuse=0,n.kspecular=0,n.opacity=1,h.bind(),h.uniforms=n;var d=this._contourVAO;for(d.bind(),i=0;3>i;++i)for(h.uniforms.permutation=I[i],r.lineWidth(this.contourWidth[i]),s=0;si;++i)for(h.uniforms.model=f.projections[i],h.uniforms.clipBounds=f.clipBounds[i],s=0;3>s;++s)if(this.contourProject[i][s]){h.uniforms.permutation=I[s],r.lineWidth(this.contourWidth[s]);for(var p=0;pi;++i)if(0!==this._dynamicCounts[i])for(h.uniforms.model=n.model,h.uniforms.clipBounds=n.clipBounds,h.uniforms.permutation=I[i],r.lineWidth(this.dynamicWidth[i]),h.uniforms.contourColor=this.dynamicColor[i],h.uniforms.contourTint=this.dynamicTint[i],h.uniforms.height=this.dynamicLevel[i],d.draw(r.LINES,this._dynamicCounts[i],this._dynamicOffsets[i]),s=0;3>s;++s)this.contourProject[s][i]&&(h.uniforms.model=f.projections[s],h.uniforms.clipBounds=f.clipBounds[s],d.draw(r.LINES,this._dynamicCounts[i],this._dynamicOffsets[i]));d.unbind()}}function l(t,e){var r=e.shape.slice(),n=t.shape.slice();b.assign(t.lo(1,1).hi(r[0],r[1]),e),b.assign(t.lo(1).hi(r[0],1),e.hi(r[0],1)),b.assign(t.lo(1,n[1]-1).hi(r[0],1),e.lo(0,r[1]-1).hi(r[0],1)),b.assign(t.lo(0,1).hi(1,r[1]),e.hi(1)),b.assign(t.lo(n[0]-1,1).hi(1,r[1]),e.lo(r[0]-1)),t.set(0,0,e.get(0,0)),t.set(0,n[1]-1,e.get(0,r[1]-1)),t.set(n[0]-1,0,e.get(r[0]-1,0)),t.set(n[0]-1,n[1]-1,e.get(r[0]-1,r[1]-1))}function c(t,e){return Array.isArray(t)?[e(t[0]),e(t[1]),e(t[2])]:[e(t),e(t),e(t)]}function u(t){return Array.isArray(t)?3===t.length?[t[0],t[1],t[2],1]:[t[0],t[1],t[2],t[3]]:[0,0,0,1]}function f(t){if(Array.isArray(t)){if(Array.isArray(t))return[u(t[0]),u(t[1]),u(t[2])];var e=u(t);return[e.slice(),e.slice(),e.slice()]}}function h(t){var e=t.gl,r=L(e),n=C(e),i=S(e),o=z(e),s=p(e),l=g(e,[{buffer:s,size:4,stride:P,offset:0},{buffer:s,size:3,stride:P,offset:16},{buffer:s,size:3,stride:P,offset:28}]),c=p(e),u=g(e,[{buffer:c,size:4,stride:20,offset:0},{buffer:c,size:1,stride:20,offset:16}]),f=p(e),h=g(e,[{buffer:f,size:2,type:e.FLOAT}]),d=v(e,1,N,e.RGBA,e.UNSIGNED_BYTE);d.minFilter=e.LINEAR,d.magFilter=e.LINEAR;var m=new a(e,[0,0],[[0,0,0],[0,0,0]],r,n,s,l,d,i,o,c,u,f,h),y={levels:[[],[],[]]};for(var b in t)y[b]=t[b];return y.colormap=y.colormap||"jet",m.update(y),m}e.exports=h;var d=t("bit-twiddle"),p=t("gl-buffer"),g=t("gl-vao"),v=t("gl-texture2d"),m=t("typedarray-pool"),y=t("colormap"),b=t("ndarray-ops"),x=t("ndarray-pack"),_=t("ndarray"),w=t("surface-nets"),k=t("gl-mat4/multiply"),A=t("gl-mat4/invert"),M=t("binary-search-bounds"),T=t("ndarray-gradient"),E=t("./lib/shaders"),L=E.createShader,S=E.createContourShader,C=E.createPickShader,z=E.createPickContourShader,P=40,R=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],O=[[0,0],[0,1],[1,0],[1,1],[1,0],[0,1]],I=[[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 t=0;3>t;++t){var e=I[t],r=(t+1)%3,n=(t+2)%3;e[r+0]=1,e[n+3]=1,e[t+6]=1}}();var N=265,j=a.prototype;j.isTransparent=function(){return this.opacity<1},j.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;3>t;++t)if(this._contourCounts[t].length>0||this._dynamicCounts[t]>0)return!0;return!1},j.pickSlots=1,j.setPickBase=function(t){this.pickId=t};var F=[0,0,0],D={showSurface:!1,showContour:!1,projections:[R.slice(),R.slice(),R.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]},B={model:R,view:R,projection:R,inverseModel:R.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1e3,1e3,1e3],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1},U=R.slice(),V=[1,0,0,0,1,0,0,0,1];j.draw=function(t){return s.call(this,t,!1)},j.drawTransparent=function(t){return s.call(this,t,!0)};var q={model:R,view:R,projection:R,inverseModel:R,clipBounds:[[0,0,0],[0,0,0]],height:0,shape:[0,0],pickId:0,lowerBound:[0,0,0],upperBound:[0,0,0],zOffset:0,permutation:[1,0,0,0,1,0,0,0,1],lightPosition:[0,0,0],eyePosition:[0,0,0]};j.drawPick=function(t){t=t||{};var e=this.gl;e.disable(e.CULL_FACE);var r=q;r.model=t.model||R,r.view=t.view||R,r.projection=t.projection||R,r.shape=this._field[2].shape,r.pickId=this.pickId/255,r.lowerBound=this.bounds[0],r.upperBound=this.bounds[1],r.permutation=V;for(var n=0;2>n;++n)for(var i=r.clipBounds[n],a=0;3>a;++a)i[a]=Math.min(Math.max(this.clipBounds[n][a],-1e8),1e8);var s=o(r,this);if(s.showSurface){for(this._pickShader.bind(),this._pickShader.uniforms=r,this._vao.bind(),this._vao.draw(e.TRIANGLES,this._vertexCount),n=0;3>n;++n)this.surfaceProject[n]&&(this._pickShader.uniforms.model=s.projections[n],this._pickShader.uniforms.clipBounds=s.clipBounds[n],this._vao.draw(e.TRIANGLES,this._vertexCount));this._vao.unbind()}if(s.showContour){var l=this._contourPickShader;l.bind(),l.uniforms=r;var c=this._contourVAO;for(c.bind(),a=0;3>a;++a)for(e.lineWidth(this.contourWidth[a]),l.uniforms.permutation=I[a],n=0;nn;++n)for(l.uniforms.model=s.projections[n],l.uniforms.clipBounds=s.clipBounds[n],a=0;3>a;++a)if(this.contourProject[n][a]){l.uniforms.permutation=I[a],e.lineWidth(this.contourWidth[a]);for(var u=0;u>4)/16)/255,i=Math.floor(n),a=n-i,o=e[1]*(t.value[1]+(15&t.value[2])/16)/255,s=Math.floor(o),l=o-s;i+=1,s+=1;var c=r.position;c[0]=c[1]=c[2]=0;for(var u=0;2>u;++u)for(var f=u?a:1-a,h=0;2>h;++h)for(var d=h?l:1-l,p=i+u,g=s+h,v=f*d,m=0;3>m;++m)c[m]+=this._field[m].get(p,g)*v;for(var y=this._pickResult.level,b=0;3>b;++b)if(y[b]=M.le(this.contourLevels[b],c[b]),y[b]<0)this.contourLevels[b].length>0&&(y[b]=0);else if(y[b]Math.abs(_-c[b])&&(y[b]+=1)}for(r.index[0]=.5>a?i:i+1,r.index[1]=.5>l?s:s+1,r.uv[0]=n/e[0],r.uv[1]=o/e[1],m=0;3>m;++m)r.dataCoordinate[m]=this._field[m].get(r.index[0],r.index[1]);return r},j.update=function(t){t=t||{},this.dirty=!0,"contourWidth"in t&&(this.contourWidth=c(t.contourWidth,Number)),"showContour"in t&&(this.showContour=c(t.showContour,Boolean)),"showSurface"in t&&(this.showSurface=!!t.showSurface),"contourTint"in t&&(this.contourTint=c(t.contourTint,Boolean)),"contourColor"in t&&(this.contourColor=f(t.contourColor)),"contourProject"in t&&(this.contourProject=c(t.contourProject,function(t){return c(t,Boolean)})),"surfaceProject"in t&&(this.surfaceProject=t.surfaceProject),"dynamicColor"in t&&(this.dynamicColor=f(t.dynamicColor)),"dynamicTint"in t&&(this.dynamicTint=c(t.dynamicTint,Number)),"dynamicWidth"in t&&(this.dynamicWidth=c(t.dynamicWidth,Number)),"opacity"in t&&(this.opacity=t.opacity),"colorBounds"in t&&(this.colorBounds=t.colorBounds);var e=t.field||t.coords&&t.coords[2]||null,r=!1;if(e||(e=this._field[2].shape[0]||this._field[2].shape[2]?this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2):this._field[2].hi(0,0)),"field"in t||"coords"in t){var n=(e.shape[0]+2)*(e.shape[1]+2);n>this._field[2].data.length&&(m.freeFloat(this._field[2].data),this._field[2].data=m.mallocFloat(d.nextPow2(n))),this._field[2]=_(this._field[2].data,[e.shape[0]+2,e.shape[1]+2]),l(this._field[2],e),this.shape=e.shape.slice();for(var a=this.shape,o=0;2>o;++o)this._field[2].size>this._field[o].data.length&&(m.freeFloat(this._field[o].data),this._field[o].data=m.mallocFloat(this._field[2].size)),this._field[o]=_(this._field[o].data,[a[0]+2,a[1]+2]);if(t.coords){var s=t.coords;if(!Array.isArray(s)||3!==s.length)throw new Error("gl-surface: invalid coordinates for x/y");for(o=0;2>o;++o){var u=s[o];for(y=0;2>y;++y)if(u.shape[y]!==a[y])throw new Error("gl-surface: coords have incorrect shape");l(this._field[o],u)}}else if(t.ticks){var h=t.ticks;if(!Array.isArray(h)||2!==h.length)throw new Error("gl-surface: invalid ticks");for(o=0;2>o;++o){var p=h[o];if((Array.isArray(p)||p.length)&&(p=_(p)),p.shape[0]!==a[o])throw new Error("gl-surface: invalid tick length");var g=_(p.data,a);g.stride[o]=p.stride[0],g.stride[1^o]=0,l(this._field[o],g)}}else{for(o=0;2>o;++o){var v=[0,0];v[o]=1,this._field[o]=_(this._field[o].data,[a[0]+2,a[1]+2],v,0)}this._field[0].set(0,0,0);for(var y=0;yo;++o)T(x.pick(o),b[o],"mirror");var k=_(m.mallocFloat(3*b[2].size),[a[0]+2,a[1]+2,3]);for(o=0;oI?(I=Math.max(Math.abs(z),Math.abs(P),Math.abs(R)),1e-8>I?(R=1,P=z=0,I=1):I=1/I):I=1/Math.sqrt(I),k.set(o,y,0,z*I),k.set(o,y,1,P*I),k.set(o,y,2,R*I)}m.free(x.data);var N=[1/0,1/0,1/0],j=[-(1/0),-(1/0),-(1/0)],F=1/0,D=-(1/0),B=(a[0]-1)*(a[1]-1)*6,U=m.mallocFloat(d.nextPow2(10*B)),V=0,q=0;for(o=0;oH;++H)for(var G=0;2>G;++G)for(var Y=0;3>Y;++Y){var X=this._field[Y].get(1+o+H,1+y+G);if(isNaN(X)||!isFinite(X))continue t}for(Y=0;6>Y;++Y){var W=o+O[Y][0],Z=y+O[Y][1],K=this._field[0].get(W+1,Z+1),$=this._field[1].get(W+1,Z+1);X=this._field[2].get(W+1,Z+1);var Q=X;z=k.get(W+1,Z+1,0),P=k.get(W+1,Z+1,1),R=k.get(W+1,Z+1,2),t.intensity&&(Q=t.intensity.get(W,Z)),U[V++]=W,U[V++]=Z,U[V++]=K,U[V++]=$,U[V++]=X,U[V++]=0,U[V++]=Q,U[V++]=z,U[V++]=P,U[V++]=R,N[0]=Math.min(N[0],K),N[1]=Math.min(N[1],$),N[2]=Math.min(N[2],X),F=Math.min(F,Q),j[0]=Math.max(j[0],K),j[1]=Math.max(j[1],$),j[2]=Math.max(j[2],X),D=Math.max(D,Q),q+=1}}for(t.intensityBounds&&(F=+t.intensityBounds[0],D=+t.intensityBounds[1]),o=6;V>o;o+=10)U[o]=(U[o]-F)/(D-F);this._vertexCount=q, -this._coordinateBuffer.update(U.subarray(0,V)),m.freeFloat(U),m.free(k.data),this.bounds=[N,j],this.intensity=t.intensity||this._field[2],this.intensityBounds[0]===F&&this.intensityBounds[1]===D||(r=!0),this.intensityBounds=[F,D]}if("levels"in t){var J=t.levels;for(J=Array.isArray(J[0])?J.slice():[[],[],J],o=0;3>o;++o)J[o]=J[o].slice(),J.sort(function(t,e){return t-e});t:for(o=0;3>o;++o){if(J[o].length!==this.contourLevels[o].length){r=!0;break}for(y=0;yet;++et){J=this.contourLevels[et];var rt=[],nt=[],it=[0,0,0];for(o=0;oY;++Y){var st=at.positions[ot[Y]],lt=st[0],ct=0|Math.floor(lt),ut=lt-ct,ft=st[1],ht=0|Math.floor(ft),dt=ft-ht,pt=!1;e:for(var gt=0;3>gt;++gt){it[gt]=0;var vt=(et+gt+1)%3;for(H=0;2>H;++H){var mt=H?ut:1-ut;for(W=0|Math.min(Math.max(ct+H,0),a[0]),G=0;2>G;++G){var yt=G?dt:1-dt;if(Z=0|Math.min(Math.max(ht+G,0),a[1]),X=2>gt?this._field[vt].get(W,Z):(this.intensity.get(W,Z)-this.intensityBounds[0])/(this.intensityBounds[1]-this.intensityBounds[0]),!isFinite(X)||isNaN(X)){pt=!0;break e}var bt=mt*yt;it[gt]+=bt*X}}}if(pt){if(Y>0){for(var xt=0;5>xt;++xt)tt.pop();q-=1}continue t}tt.push(it[0],it[1],st[0],st[1],it[2]),q+=1}}nt.push(q)}this._contourOffsets[et]=rt,this._contourCounts[et]=nt}var _t=m.mallocFloat(tt.length);for(o=0;ot;++t)m.freeFloat(this._field[t].data)},j.highlight=function(t){if(!t)return this._dynamicCounts=[0,0,0],this.dyanamicLevel=[NaN,NaN,NaN],void(this.highlightLevel=[-1,-1,-1]);for(var e=0;3>e;++e)this.enableHighlight[e]?this.highlightLevel[e]=t.level[e]:this.highlightLevel[e]=-1;var r;if(r=this.snapToData?t.dataCoordinate:t.position,this.enableDynamic[0]&&r[0]!==this.dynamicLevel[0]||this.enableDynamic[1]&&r[1]!==this.dynamicLevel[1]||this.enableDynamic[2]&&r[2]!==this.dynamicLevel[2]){for(var n=0,i=this.shape,a=m.mallocFloat(12*i[0]*i[1]),o=0;3>o;++o)if(this.enableDynamic[o]){this.dynamicLevel[o]=r[o];var s=(o+1)%3,l=(o+2)%3,c=this._field[o],u=this._field[s],f=this._field[l],h=(this.intensity,w(c,r[o])),d=h.cells,p=h.positions;for(this._dynamicOffsets[o]=n,e=0;ev;++v){var y=p[g[v]],b=+y[0],x=0|b,_=0|Math.min(x+1,i[0]),k=b-x,A=1-k,M=+y[1],T=0|M,E=0|Math.min(T+1,i[1]),L=M-T,S=1-L,C=A*S,z=A*L,P=k*S,R=k*L,O=C*u.get(x,T)+z*u.get(x,E)+P*u.get(_,T)+R*u.get(_,E),I=C*f.get(x,T)+z*f.get(x,E)+P*f.get(_,T)+R*f.get(_,E);if(isNaN(O)||isNaN(I)){v&&(n-=1);break}a[2*n+0]=O,a[2*n+1]=I,n+=1}this._dynamicCounts[o]=n-this._dynamicOffsets[o]}else this.dynamicLevel[o]=NaN,this._dynamicCounts[o]=0;this._dynamicBuffer.update(a.subarray(0,2*n)),m.freeFloat(a)}}},{"./lib/shaders":175,"binary-search-bounds":176,"bit-twiddle":50,colormap:59,"gl-buffer":77,"gl-mat4/invert":96,"gl-mat4/multiply":98,"gl-texture2d":181,"gl-vao":185,ndarray:212,"ndarray-gradient":177,"ndarray-ops":211,"ndarray-pack":178,"surface-nets":231,"typedarray-pool":237}],181:[function(t,e,r){"use strict";function n(t){v=[t.LINEAR,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_NEAREST],m=[t.NEAREST,t.LINEAR,t.NEAREST_MIPMAP_NEAREST,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_LINEAR],y=[t.REPEAT,t.CLAMP_TO_EDGE,t.MIRRORED_REPEAT]}function i(t,e,r){var n=t.gl,i=n.getParameter(n.MAX_TEXTURE_SIZE);if(0>e||e>i||0>r||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function a(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}function o(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function s(t,e,r,n,i,a,s,l){var c=l.dtype,u=l.shape.slice();if(u.length<2||u.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var f=0,h=0,v=o(u,l.stride.slice());"float32"===c?f=t.FLOAT:"float64"===c?(f=t.FLOAT,v=!1,c="float32"):"uint8"===c?f=t.UNSIGNED_BYTE:(f=t.UNSIGNED_BYTE,v=!1,c="uint8");var m=1;if(2===u.length)h=t.LUMINANCE,u=[u[0],u[1],1],l=d(l.data,u,[l.stride[0],l.stride[1],1],l.offset);else{if(3!==u.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===u[2])h=t.ALPHA;else if(2===u[2])h=t.LUMINANCE_ALPHA;else if(3===u[2])h=t.RGB;else{if(4!==u[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");h=t.RGBA}m=u[2]}if(h!==t.LUMINANCE&&h!==t.ALPHA||i!==t.LUMINANCE&&i!==t.ALPHA||(h=i),h!==i)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=l.size,x=s.indexOf(n)<0;if(x&&s.push(n),f===a&&v)0===l.offset&&l.data.length===y?x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,l.data):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,l.data):x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,l.data.subarray(l.offset,l.offset+y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,l.data.subarray(l.offset,l.offset+y));else{var _;_=a===t.FLOAT?g.mallocFloat32(y):g.mallocUint8(y);var w=d(_,u,[u[2],u[2]*u[0],1]);f===t.FLOAT&&a===t.UNSIGNED_BYTE?b(w,l):p.assign(w,l),x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,_.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,_.subarray(0,y)),a===t.FLOAT?g.freeFloat32(_):g.freeUint8(_)}}function l(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function c(t,e,r,n,i){var o=t.getParameter(t.MAX_TEXTURE_SIZE);if(0>e||e>o||0>r||r>o)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var s=l(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new a(t,s,e,r,n,i)}function u(t,e,r,n){var i=l(t);return t.texImage2D(t.TEXTURE_2D,0,r,r,n,e),new a(t,i,0|e.width,0|e.height,r,n)}function f(t,e){var r=e.dtype,n=e.shape.slice(),i=t.getParameter(t.MAX_TEXTURE_SIZE);if(n[0]<0||n[0]>i||n[1]<0||n[1]>i)throw new Error("gl-texture2d: Invalid texture size");var s=o(n,e.stride.slice()),c=0;"float32"===r?c=t.FLOAT:"float64"===r?(c=t.FLOAT,s=!1,r="float32"):"uint8"===r?c=t.UNSIGNED_BYTE:(c=t.UNSIGNED_BYTE,s=!1,r="uint8");var u=0;if(2===n.length)u=t.LUMINANCE,n=[n[0],n[1],1],e=d(e.data,n,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==n.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===n[2])u=t.ALPHA;else if(2===n[2])u=t.LUMINANCE_ALPHA;else if(3===n[2])u=t.RGB;else{if(4!==n[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");u=t.RGBA}}c!==t.FLOAT||t.getExtension("OES_texture_float")||(c=t.UNSIGNED_BYTE,s=!1);var f,h,v=e.size;if(s)f=0===e.offset&&e.data.length===v?e.data:e.data.subarray(e.offset,e.offset+v);else{var m=[n[2],n[2]*n[0],1];h=g.malloc(v,r);var y=d(h,n,m,0);"float32"!==r&&"float64"!==r||c!==t.UNSIGNED_BYTE?p.assign(y,e):b(y,e),f=h.subarray(0,v)}var x=l(t);return t.texImage2D(t.TEXTURE_2D,0,u,n[0],n[1],0,u,c,f),s||g.free(h),new a(t,x,n[0],n[1],u,c)}function h(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");if(v||n(t),"number"==typeof arguments[1])return c(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return c(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1];if(e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof HTMLVideoElement||e instanceof ImageData)return u(t,e,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return f(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")}var d=t("ndarray"),p=t("ndarray-ops"),g=t("typedarray-pool");e.exports=h;var v=null,m=null,y=null,b=function(t,e){p.muls(t,e,255)},x=a.prototype;Object.defineProperties(x,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;2>e;++e)if(y.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return i(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return t=0|t,i(this,t,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t=0|t,i(this,this._shape[0],t),t}}}),x.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},x.dispose=function(){this.gl.deleteTexture(this.handle)},x.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},x.setPixels=function(t,e,r,n){var i=this.gl;if(this.bind(),Array.isArray(e)?(n=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),n=n||0,t instanceof HTMLCanvasElement||t instanceof ImageData||t instanceof HTMLImageElement||t instanceof HTMLVideoElement){var a=this._mipLevels.indexOf(n)<0;a?(i.texImage2D(i.TEXTURE_2D,0,this.format,this.format,this.type,t),this._mipLevels.push(n)):i.texSubImage2D(i.TEXTURE_2D,n,e,r,this.format,this.type,t)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>n||r+t.shape[0]>this._shape[0]>>>n||0>e||0>r)throw new Error("gl-texture2d: Texture dimensions are out of bounds");s(i,e,r,n,this.format,this.type,this._mipLevels,t)}}},{ndarray:212,"ndarray-ops":211,"typedarray-pool":237}],182:[function(t,e,r){"use strict";function n(t,e,r){e?e.bind():t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);var n=0|t.getParameter(t.MAX_VERTEX_ATTRIBS);if(r){if(r.length>n)throw new Error("gl-vao: Too many vertex attributes");for(var i=0;ii;++i)t.disableVertexAttribArray(i)}else{t.bindBuffer(t.ARRAY_BUFFER,null);for(var i=0;n>i;++i)t.disableVertexAttribArray(i)}}e.exports=n},{}],183:[function(t,e,r){"use strict";function n(t){this.gl=t,this._elements=null,this._attributes=null,this._elementsType=t.UNSIGNED_SHORT}function i(t){return new n(t)}var a=t("./do-bind.js");n.prototype.bind=function(){a(this.gl,this._elements,this._attributes)},n.prototype.update=function(t,e,r){this._elements=e,this._attributes=t,this._elementsType=r||this.gl.UNSIGNED_SHORT},n.prototype.dispose=function(){},n.prototype.unbind=function(){},n.prototype.draw=function(t,e,r){r=r||0;var n=this.gl;this._elements?n.drawElements(t,e,this._elementsType,r):n.drawArrays(t,r,e)},e.exports=i},{"./do-bind.js":182}],184:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.location=t,this.dimension=e,this.a=r,this.b=n,this.c=i,this.d=a}function i(t,e,r){this.gl=t,this._ext=e,this.handle=r,this._attribs=[],this._useElements=!1,this._elementsType=t.UNSIGNED_SHORT}function a(t,e){return new i(t,e,e.createVertexArrayOES())}var o=t("./do-bind.js");n.prototype.bind=function(t){switch(this.dimension){case 1:t.vertexAttrib1f(this.location,this.a);break;case 2:t.vertexAttrib2f(this.location,this.a,this.b);break;case 3:t.vertexAttrib3f(this.location,this.a,this.b,this.c);break;case 4:t.vertexAttrib4f(this.location,this.a,this.b,this.c,this.d)}},i.prototype.bind=function(){this._ext.bindVertexArrayOES(this.handle);for(var t=0;tF;){switch(e=F,B){case f:F=L();break;case h:F=E();break;case d:F=T();break;case p:F=S();break;case g:F=P();break;case w:F=z();break;case v:F=R();break;case u:F=O();break;case x:F=M();break;case c:F=A()}if(e!==F)switch(W[e]){case"\n":H=0,++q;break;default:++H}}return D+=F,W=W.slice(F),V}function n(t){return U.length&&e(U.join("")),B=_,e("(eof)"),V}function A(){return U=U.length?[]:U,"/"===N&&"*"===I?(G=D+F-1,B=f,N=I,F+1):"/"===N&&"/"===I?(G=D+F-1,B=h,N=I,F+1):"#"===I?(B=d,G=D+F,F):/\s/.test(I)?(B=x,G=D+F,F):(Y=/\d/.test(I),X=/[^\w_]/.test(I),G=D+F,B=Y?g:X?p:u,F)}function M(){return/[^\s]/g.test(I)?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function T(){return"\n"===I&&"\\"!==N?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function E(){return T()}function L(){return"/"===I&&"*"===N?(U.push(I),e(U.join("")),B=c,F+1):(U.push(I),N=I,F+1)}function S(){if("."===N&&/\d/.test(I))return B=v,F;if("/"===N&&"*"===I)return B=f,F;if("/"===N&&"/"===I)return B=h,F;if("."===I&&U.length){for(;C(U););return B=v,F}if(";"===I||")"===I||"("===I){if(U.length)for(;C(U););return e(I),B=c,F+1}var t=2===U.length&&"="!==I;if(/[\w_\d\s]/.test(I)||t){for(;C(U););return B=c,F}return U.push(I),N=I,F+1}function C(t){for(var r,n,i=0;;){if(r=a.indexOf(t.slice(0,t.length+i).join("")),n=a[r],-1===r){if(i--+t.length>0)continue;n=t.slice(0,1).join("")}return e(n),G+=n.length,U=U.slice(n.length),U.length}}function z(){return/[^a-fA-F0-9]/.test(I)?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function P(){return"."===I?(U.push(I),B=v,N=I,F+1):/[eE]/.test(I)?(U.push(I),B=v,N=I,F+1):"x"===I&&1===U.length&&"0"===U[0]?(B=w,U.push(I),N=I,F+1):/[^\d]/.test(I)?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function R(){return"f"===I&&(U.push(I),N=I,F+=1),/[eE]/.test(I)?(U.push(I),N=I,F+1):"-"===I&&/[eE]/.test(N)?(U.push(I),N=I,F+1):/[^\d]/.test(I)?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function O(){if(/[^\d\w_]/.test(I)){var t=U.join("");return B=K.indexOf(t)>-1?b:Z.indexOf(t)>-1?y:m,e(U.join("")),B=c,F}return U.push(I),N=I,F+1}var I,N,j,F=0,D=0,B=c,U=[],V=[],q=1,H=0,G=0,Y=!1,X=!1,W="";t=t||{};var Z=o,K=i;return"300 es"===t.version&&(Z=l,K=s),function(t){return V=[],null!==t?r(t):n()}}e.exports=n;var i=t("./lib/literals"),a=t("./lib/operators"),o=t("./lib/builtins"),s=t("./lib/literals-300es"),l=t("./lib/builtins-300es"),c=999,u=9999,f=0,h=1,d=2,p=3,g=4,v=5,m=6,y=7,b=8,x=9,_=10,w=11,k=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":189,"./lib/builtins-300es":188,"./lib/literals":191,"./lib/literals-300es":190,"./lib/operators":192}],188:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["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","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"])},{"./builtins":189}],189:[function(t,e,r){e.exports=["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"]},{}],190:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","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"])},{"./literals":191}],191:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","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","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"]},{}],192:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],193:[function(t,e,r){function n(t,e){var r=i(e),n=[];return n=n.concat(r(t)),n=n.concat(r(null))}var i=t("./index");e.exports=n},{"./index":187}],194:[function(t,e,r){"use strict";function n(t,e,r){this.vertices=t,this.adjacent=e,this.boundary=r,this.lastVisited=-1}function i(t,e,r){this.vertices=t,this.cell=e,this.index=r}function a(t,e){return u(t.vertices,e.vertices)}function o(t){for(var e=["function orient(){var tuple=this.tuple;return test("],r=0;t>=r;++r)r>0&&e.push(","),e.push("tuple[",r,"]");e.push(")}return orient");var n=new Function("test",e.join("")),i=c[t+1];return i||(i=c),n(i)}function s(t,e,r){this.dimension=t,this.vertices=e,this.simplices=r,this.interior=r.filter(function(t){return!t.boundary}),this.tuple=new Array(t+1);for(var n=0;t>=n;++n)this.tuple[n]=this.vertices[n];var i=f[t];i||(i=f[t]=o(t)),this.orient=i}function l(t,e){var r=t.length;if(0===r)throw new Error("Must have at least d+1 points");var i=t[0].length;if(i>=r)throw new Error("Must input at least d+1 points");var a=t.slice(0,i+1),o=c.apply(void 0,a);if(0===o)throw new Error("Input not in general position");for(var l=new Array(i+1),u=0;i>=u;++u)l[u]=u;0>o&&(l[0]=1,l[1]=0);for(var f=new n(l,new Array(i+1),!1),h=f.adjacent,d=new Array(i+2),u=0;i>=u;++u){for(var p=l.slice(),g=0;i>=g;++g)g===u&&(p[g]=-1);var v=p[0];p[0]=p[1],p[1]=v;var m=new n(p,new Array(i+1),!0);h[u]=m,d[u]=m}d[i+1]=f;for(var u=0;i>=u;++u)for(var p=h[u].vertices,y=h[u].adjacent,g=0;i>=g;++g){var b=p[g];if(0>b)y[g]=f;else for(var x=0;i>=x;++x)h[x].vertices.indexOf(b)<0&&(y[g]=h[x])}for(var _=new s(i,a,d),w=!!e,u=i+1;r>u;++u)_.insert(t[u],w);return _.boundary()}e.exports=l;var c=t("robust-orientation"),u=t("simplicial-complex").compareCells;n.prototype.flip=function(){var t=this.vertices[0];this.vertices[0]=this.vertices[1],this.vertices[1]=t;var e=this.adjacent[0];this.adjacent[0]=this.adjacent[1],this.adjacent[1]=e};var f=[],h=s.prototype;h.handleBoundaryDegeneracy=function(t,e){var r=this.dimension,n=this.vertices.length-1,i=this.tuple,a=this.vertices,o=[t];for(t.lastVisited=-n;o.length>0;){t=o.pop();for(var s=(t.vertices,t.adjacent),l=0;r>=l;++l){var c=s[l];if(c.boundary&&!(c.lastVisited<=-n)){for(var u=c.vertices,f=0;r>=f;++f){var h=u[f];0>h?i[f]=e:i[f]=a[h]}var d=this.orient();if(d>0)return c;c.lastVisited=-n,0===d&&o.push(c)}}}return null},h.walk=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,a=this.tuple,o=e?this.interior.length*Math.random()|0:this.interior.length-1,s=this.interior[o];t:for(;!s.boundary;){for(var l=s.vertices,c=s.adjacent,u=0;n>=u;++u)a[u]=i[l[u]];s.lastVisited=r;for(var u=0;n>=u;++u){var f=c[u];if(!(f.lastVisited>=r)){var h=a[u];a[u]=t;var d=this.orient();if(a[u]=h,0>d){s=f;continue t}f.boundary?f.lastVisited=-r:f.lastVisited=r}}return}return s},h.addPeaks=function(t,e){var r=this.vertices.length-1,o=this.dimension,s=this.vertices,l=this.tuple,c=this.interior,u=this.simplices,f=[e];e.lastVisited=r,e.vertices[e.vertices.indexOf(-1)]=r,e.boundary=!1,c.push(e);for(var h=[];f.length>0;){var e=f.pop(),d=e.vertices,p=e.adjacent,g=d.indexOf(r);if(!(0>g))for(var v=0;o>=v;++v)if(v!==g){var m=p[v];if(m.boundary&&!(m.lastVisited>=r)){var y=m.vertices;if(m.lastVisited!==-r){for(var b=0,x=0;o>=x;++x)y[x]<0?(b=x,l[x]=t):l[x]=s[y[x]];var _=this.orient();if(_>0){y[b]=r,m.boundary=!1,c.push(m),f.push(m),m.lastVisited=r;continue}m.lastVisited=-r}var w=m.adjacent,k=d.slice(),A=p.slice(),M=new n(k,A,!0);u.push(M);var T=w.indexOf(e);if(!(0>T)){w[T]=M,A[g]=m,k[v]=-1,A[v]=e,p[v]=M,M.flip();for(var x=0;o>=x;++x){var E=k[x];if(!(0>E||E===r)){for(var L=new Array(o-1),S=0,C=0;o>=C;++C){var z=k[C];0>z||C===x||(L[S++]=z)}h.push(new i(L,M,x))}}}}}}h.sort(a);for(var v=0;v+1O||0>I||(P.cell.adjacent[P.index]=R.cell,R.cell.adjacent[R.index]=P.cell)}},h.insert=function(t,e){var r=this.vertices;r.push(t);var n=this.walk(t,e);if(n){for(var i=this.dimension,a=this.tuple,o=0;i>=o;++o){var s=n.vertices[o];0>s?a[o]=t:a[o]=r[s]}var l=this.orient(a);0>l||(0!==l||(n=this.handleBoundaryDegeneracy(n,t)))&&this.addPeaks(t,n)}},h.boundary=function(){for(var t=this.dimension,e=[],r=this.simplices,n=r.length,i=0;n>i;++i){var a=r[i];if(a.boundary){for(var o=new Array(t),s=a.vertices,l=0,c=0,u=0;t>=u;++u)s[u]>=0?o[l++]=s[u]:c=1&u;if(c===(1&t)){var f=o[0];o[0]=o[1],o[1]=f}e.push(o)}}return e}},{"robust-orientation":218,"simplicial-complex":197}],195:[function(t,e,r){arguments[4][50][0].apply(r,arguments)},{dup:50}],196:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;t>e;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n;var i=n.prototype;Object.defineProperty(i,"length",{get:function(){return this.roots.length}}),i.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},i.find=function(t){for(var e=t,r=this.roots;r[t]!==t;)t=r[t];for(;r[e]!==t;){var n=r[e];r[e]=t,e=n}return t},i.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],197:[function(t,e,r){"use strict";"use restrict";function n(t){for(var e=0,r=Math.max,n=0,i=t.length;i>n;++n)e=r(e,t[n].length);return e-1}function i(t){for(var e=-1,r=Math.max,n=0,i=t.length;i>n;++n)for(var a=t[n],o=0,s=a.length;s>o;++o)e=r(e,a[o]);return e+1}function a(t){for(var e=new Array(t.length),r=0,n=t.length;n>r;++r)e[r]=t[r].slice(0);return e}function o(t,e){var r=t.length,n=t.length-e.length,i=Math.min;if(n)return n;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:var a=t[0]+t[1]-e[0]-e[1];return a?a:i(t[0],t[1])-i(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(a=o+t[2]-(s+e[2]))return a;var l=i(t[0],t[1]),c=i(e[0],e[1]),a=i(l,t[2])-i(c,e[2]);return a?a:i(l+t[2],o)-i(c+e[2],s);default:var u=t.slice(0);u.sort();var f=e.slice(0);f.sort();for(var h=0;r>h;++h)if(n=u[h]-f[h])return n;return 0}}function s(t,e){return o(t[0],e[0])}function l(t,e){if(e){for(var r=t.length,n=new Array(r),i=0;r>i;++i)n[i]=[t[i],e[i]];n.sort(s);for(var i=0;r>i;++i)t[i]=n[i][0],e[i]=n[i][1];return t}return t.sort(o),t}function c(t){if(0===t.length)return[];for(var e=1,r=t.length,n=1;r>n;++n){var i=t[n];if(o(i,t[n-1])){if(n===e){e++;continue}t[e++]=i}}return t.length=e,t}function u(t,e){for(var r=0,n=t.length-1,i=-1;n>=r;){var a=r+n>>1,s=o(t[a],e);0>=s?(0===s&&(i=a),r=a+1):s>0&&(n=a-1)}return i}function f(t,e){for(var r=new Array(t.length),n=0,i=r.length;i>n;++n)r[n]=[];for(var a=[],n=0,s=e.length;s>n;++n)for(var l=e[n],c=l.length,f=1,h=1<f;++f){a.length=b.popCount(f);for(var d=0,p=0;c>p;++p)f&1<g))for(;;)if(r[g++].push(n),g>=t.length||0!==o(t[g],a))break}return r}function h(t,e){if(!e)return f(c(p(t,0)),t,0);for(var r=new Array(e),n=0;e>n;++n)r[n]=[];for(var n=0,i=t.length;i>n;++n)for(var a=t[n],o=0,s=a.length;s>o;++o)r[a[o]].push(n); -return r}function d(t){for(var e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0|i.length,o=1,s=1<o;++o){for(var c=[],u=0;a>u;++u)o>>>u&1&&c.push(i[u]);e.push(c)}return l(e)}function p(t,e){if(0>e)return[];for(var r=[],n=(1<r;++r)for(var i=t[r],a=0,o=i.length;o>a;++a){for(var s=new Array(i.length-1),c=0,u=0;o>c;++c)c!==a&&(s[u++]=i[c]);e.push(s)}return l(e)}function v(t,e){for(var r=new x(e),n=0;nr;++r)e[r]=r;return e}e.exports=n},{}],199:[function(t,e,r){e.exports=function(t){return!(null==t||!(t._isBuffer||t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)))}},{}],200:[function(t,e,r){"use strict";function n(t,e){function r(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==g.alt,g.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==g.shift,g.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==g.control,g.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==g.meta,g.meta=!!t.metaKey),e}function n(t,n){var a=i.x(n),o=i.y(n);"buttons"in n&&(t=0|n.buttons),(t!==h||a!==d||o!==p||r(n))&&(h=0|t,d=a||0,p=o||0,e(h,d,p,g))}function a(t){n(0,t)}function o(){(h||d||p||g.shift||g.alt||g.meta||g.control)&&(d=p=0,h=0,g.shift=g.alt=g.control=g.meta=!1,e(0,0,0,g))}function s(t){r(t)&&e(h,d,p,g)}function l(t){0===i.buttons(t)?n(0,t):n(h,t)}function c(t){n(h|i.buttons(t),t)}function u(t){n(h&~i.buttons(t),t)}function f(){v||(v=!0,t.addEventListener("mousemove",l),t.addEventListener("mousedown",c),t.addEventListener("mouseup",u),t.addEventListener("mouseleave",a),t.addEventListener("mouseenter",a),t.addEventListener("mouseout",a),t.addEventListener("mouseover",a),t.addEventListener("blur",o),t.addEventListener("keyup",s),t.addEventListener("keydown",s),t.addEventListener("keypress",s),t!==window&&(window.addEventListener("blur",o),window.addEventListener("keyup",s),window.addEventListener("keydown",s),window.addEventListener("keypress",s)))}e||(e=t,t=window);var h=0,d=0,p=0,g={shift:!1,alt:!1,control:!1,meta:!1},v=!1;f();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return v},set:function(t){t&&f()},enumerable:!0},buttons:{get:function(){return h},enumerable:!0},x:{get:function(){return d},enumerable:!0},y:{get:function(){return p},enumerable:!0},mods:{get:function(){return g},enumerable:!0}}),m}e.exports=n;var i=t("mouse-event")},{"mouse-event":201}],201:[function(t,e,r){"use strict";function n(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<=0&&r=0&&r+1=0&&n=0&&n+1=0&&s=0&&s+1=0&&i=0&&i+1=0&&l=0&&l+1=0&&h=0&&h+1e;++e)r=+arguments[e+1],i[e]=Math.floor(r),a[e]=r-i[e],o[e]=0<=i[e]&&i[e]e;++e){for(c=1,u=t.offset,l=0;n>l;++l)if(e&1<r;++r){t[r]=o[(n+1)*n+r];for(var i=0;n>i;++i)t[r]+=o[(n+1)*i+r]*e[i]}for(var a=o[(n+1)*(n+1)-1],i=0;n>i;++i)a+=o[(n+1)*i+n]*e[i];for(var s=1/a,r=0;n>r;++r)t[r]*=s;return t}),t}var i=t("ndarray-warp"),a=t("gl-matrix-invert");e.exports=n},{"gl-matrix-invert":206,"ndarray-warp":209}],211:[function(t,e,r){"use strict";function n(t){if(!t)return s;for(var e=0;e>",rrshift:">>>"};!function(){for(var t in l){var e=l[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var c={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in c){var e=c[t];r[t]=a({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var u={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in u){var e=u[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var f=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=o({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=o({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=o({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":68}],212:[function(t,e,r){function n(t,e){return t[0]-e[0]}function i(){var t,e=this.stride,r=new Array(e.length);for(t=0;te&&(r="View_Nil"+t);var n="generic"===t;if(-1===e){var a="function "+r+"(a){this.data=a;};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+r+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+r+"(a){return new "+r+"(a);}",o=new Function(a);return o()}if(0===e){var a="function "+r+"(a,d) {this.data = a;this.offset = d};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+r+"_copy() {return new "+r+"(this.data,this.offset)};proto.pick=function "+r+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+r+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+r+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+r+"(a,b,c,d){return new "+r+"(a,d)}",o=new Function("TrivialArray",a);return o(f[t][0])}var a=["'use strict'"],s=l(e),c=s.map(function(t){return"i"+t}),u="this.offset+"+s.map(function(t){return"this.stride["+t+"]*i"+t}).join("+"),h=s.map(function(t){return"b"+t}).join(","),d=s.map(function(t){return"c"+t}).join(",");a.push("function "+r+"(a,"+h+","+d+",d){this.data=a","this.shape=["+h+"]","this.stride=["+d+"]","this.offset=d|0}","var proto="+r+".prototype","proto.dtype='"+t+"'","proto.dimension="+e),a.push("Object.defineProperty(proto,'size',{get:function "+r+"_size(){return "+s.map(function(t){return"this.shape["+t+"]"}).join("*"),"}})"),1===e?a.push("proto.order=[0]"):(a.push("Object.defineProperty(proto,'order',{get:"),4>e?(a.push("function "+r+"_order(){"),2===e?a.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+c.join(",")+",v){"),n?a.push("return this.data.set("+u+",v)}"):a.push("return this.data["+u+"]=v}"),a.push("proto.get=function "+r+"_get("+c.join(",")+"){"),n?a.push("return this.data.get("+u+")}"):a.push("return this.data["+u+"]}"),a.push("proto.index=function "+r+"_index(",c.join(),"){return "+u+"}"),a.push("proto.hi=function "+r+"_hi("+c.join(",")+"){return new "+r+"(this.data,"+s.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+s.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=s.map(function(t){return"a"+t+"=this.shape["+t+"]"}),g=s.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+c.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+g.join(","));for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){d=i"+v+"|0;b+=c"+v+"*d;a"+v+"-=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+c.join(",")+"){var "+s.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+s.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'){d=i"+v+"|0;if(d<0){c+=b"+v+"*(a"+v+"-1);a"+v+"=ceil(-a"+v+"/d)}else{a"+v+"=ceil(a"+v+"/d)}b"+v+"*=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"b"+t}).join(",")+",c)}");for(var m=new Array(e),y=new Array(e),v=0;e>v;++v)m[v]="a[i"+v+"]",y[v]="b[i"+v+"]";a.push("proto.transpose=function "+r+"_transpose("+c+"){"+c.map(function(t,e){return t+"=("+t+"===undefined?"+e+":"+t+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+r+"(this.data,"+m.join(",")+","+y.join(",")+",this.offset)}"),a.push("proto.pick=function "+r+"_pick("+c+"){var a=[],b=[],c=this.offset");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+s.map(function(t){return"shape["+t+"]"}).join(",")+","+s.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}");var o=new Function("CTOR_LIST","ORDER",a.join("\n"));return o(f[t],i)}function o(t){if(c(t))return"buffer";if(u)switch(Object.prototype.toString.call(t)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(t)?"array":"generic"}function s(t,e,r,n){if(void 0===t){var i=f.array[0];return i([])}"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var s=e.length;if(void 0===r){r=new Array(s);for(var l=s-1,c=1;l>=0;--l)r[l]=c,c*=e[l]}if(void 0===n){n=0;for(var l=0;s>l;++l)r[l]<0&&(n-=(e[l]-1)*r[l])}for(var u=o(t),h=f[u];h.length<=s+1;)h.push(a(u,h.length-1));var i=h[s+1];return i(t,e,r,n)}var l=t("iota-array"),c=t("is-buffer"),u="undefined"!=typeof Float64Array,f={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=s},{"iota-array":198,"is-buffer":199}],213:[function(t,e,r){"use strict";function n(t,e){if("string"!=typeof t)throw new TypeError("repeat-string expects a string.");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;for(i===t&&"undefined"!=typeof i||(i=t,a="");r>a.length&&e>0&&(1&e&&(a+=t),e>>=1);)t+=t;return a.substr(0,r)}var i,a="";e.exports=n},{}],214:[function(t,e,r){(function(t){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],215:[function(t,e,r){"use strict";function n(t){for(var e="robustLinearSolve"+t+"d",r=["function ",e,"(A,b){return ["],n=0;t>n;++n){r.push("det([");for(var i=0;t>i;++i){i>0&&r.push(","),r.push("[");for(var a=0;t>a;++a)a>0&&r.push(","),a===n?r.push("+b[",i,"]"):r.push("+A[",i,"][",a,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var o=new Function("det",r.join(""));return o(6>t?s[t]:s)}function i(){return[0]}function a(t,e){return[[e[0]],[t[0][0]]]}function o(){for(;c.lengthi;++i)t.push("s"+i),r.push("case ",i,":return s",i,"(A,b);");r.push("}var s=CACHE[A.length];if(!s)s=CACHE[A.length]=g(A.length);return s(A,b)}return dispatchLinearSolve"),t.push("CACHE","g",r.join(""));var a=Function.apply(void 0,t);e.exports=a.apply(void 0,c.concat([c,n]));for(var i=0;l>i;++i)e.exports[i]=c[i]}var s=t("robust-determinant"),l=6,c=[i,a];o()},{"robust-determinant":217}],216:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i];r=a+o;var s=r-a,l=o-s;l&&(t[--n]=r,r=l)}for(var c=0,i=n;e>i;++i){var a=t[i],o=r;r=a+o;var s=r-a,l=o-s;l&&(t[c++]=l)}return t[c++]=r,t.length=c,t}e.exports=n},{}],217:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m[",r,"][",n,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("");for(var e=[],r=0;rn;++n)t.push("det"+n),r.push("case ",n,":return det",n,"(m);");r.push("}var det=CACHE[m.length];if(!det)det=CACHE[m.length]=gen(m.length);return det(m);}return robustDeterminant"),t.push("CACHE","gen",r.join(""));var i=Function.apply(void 0,t);e.exports=i.apply(void 0,g.concat([g,l]));for(var n=0;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-1,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;rc;++c)0===(1&c)?e.push.apply(e,s(n(a,c))):r.push.apply(r,s(n(a,c))), -l.push("m"+c);var u=o(e),g=o(r),v="orientation"+t+"Exact",m=["function ",v,"(",l.join(),"){var p=",u,",n=",g,",d=sub(p,n);return d[d.length-1];};return ",v].join(""),y=new Function("sum","prod","scale","sub",m);return y(h,f,d,p)}function c(t){var e=_[t.length];return e||(e=_[t.length]=l(t.length)),e.apply(void 0,t)}function u(){for(;_.length<=g;)_.push(l(_.length));for(var t=[],r=["slow"],n=0;g>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;g>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var f=t("two-product"),h=t("robust-sum"),d=t("robust-scale"),p=t("robust-subtract"),g=5,v=1.1102230246251565e-16,m=(3+16*v)*v,y=(7+56*v)*v,b=l(3),x=l(4),_=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,r){var n,i=(t[1]-r[1])*(e[0]-r[0]),a=(t[0]-r[0])*(e[1]-r[1]),o=i-a;if(i>0){if(0>=a)return o;n=i+a}else{if(!(0>i))return o;if(a>=0)return o;n=-(i+a)}var s=m*n;return o>=s||-s>=o?o:b(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],d=a*c,p=o*l,g=o*s,v=i*c,m=i*l,b=a*s,_=u*(d-p)+f*(g-v)+h*(m-b),w=(Math.abs(d)+Math.abs(p))*Math.abs(u)+(Math.abs(g)+Math.abs(v))*Math.abs(f)+(Math.abs(m)+Math.abs(b))*Math.abs(h),k=y*w;return _>k||-_>k?_:x(t,e,r,n)}];u()},{"robust-scale":219,"robust-subtract":220,"robust-sum":221,"two-product":235}],219:[function(t,e,r){"use strict";function n(t,e){var r=t.length;if(1===r){var n=i(t[0],e);return n[0]?n:[n[1]]}var o=new Array(2*r),s=[.1,.1],l=[.1,.1],c=0;i(t[0],e,s),s[0]&&(o[c++]=s[0]);for(var u=1;r>u;++u){i(t[u],e,l);var f=s[1];a(f,l[0],s),s[0]&&(o[c++]=s[0]);var h=l[1],d=s[1],p=h+d,g=p-h,v=d-g;s[1]=p,v&&(o[c++]=v)}return s[1]&&(o[c++]=s[1]),0===c&&(o[c++]=0),o.length=c,o}var i=t("two-product"),a=t("two-sum");e.exports=n},{"two-product":235,"two-sum":236}],220:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],-e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=-e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=-e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=-e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],221:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],222:[function(t,e,r){"use strict";function n(t){return t.split("").map(function(t){return t in i?i[t]:""}).join("")}e.exports=n;var i={" ":" ",0:"\u2070",1:"\xb9",2:"\xb2",3:"\xb3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079","+":"\u207a","-":"\u207b",a:"\u1d43",b:"\u1d47",c:"\u1d9c",d:"\u1d48",e:"\u1d49",f:"\u1da0",g:"\u1d4d",h:"\u02b0",i:"\u2071",j:"\u02b2",k:"\u1d4f",l:"\u02e1",m:"\u1d50",n:"\u207f",o:"\u1d52",p:"\u1d56",r:"\u02b3",s:"\u02e2",t:"\u1d57",u:"\u1d58",v:"\u1d5b",w:"\u02b7",x:"\u02e3",y:"\u02b8",z:"\u1dbb"}},{}],223:[function(t,e,r){"use strict";function n(t){return"a"+t}function i(t){return"d"+t}function a(t,e){return"c"+t+"_"+e}function o(t){return"s"+t}function s(t,e){return"t"+t+"_"+e}function l(t){return"o"+t}function c(t){return"x"+t}function u(t){return"p"+t}function f(t,e){return"d"+t+"_"+e}function h(t){return"i"+t}function d(t,e){return"u"+t+"_"+e}function p(t){return"b"+t}function g(t){return"y"+t}function v(t){return"e"+t}function m(t){return"v"+t}function y(t,e,r){for(var n=0,i=0;t>i;++i)e&1<e;++e)F.push(u(e),"+=",d(e,x[t]),";");F.push("}")}function z(t){for(var e=t-1;e>=0;--e)S(e,0);for(var r=[],e=0;I>e;++e)L[e]?r.push(i(e)+".get("+u(e)+")"):r.push(i(e)+"["+u(e)+"]");for(var e=0;b>e;++e)r.push(c(e));F.push(k,"[",T,"++]=phase(",r.join(),");");for(var e=0;t>e;++e)C(e);for(var n=0;I>n;++n)F.push(u(n),"+=",d(n,x[t]),";")}function P(t){for(var e=0;I>e;++e)L[e]?F.push(a(e,0),"=",i(e),".get(",u(e),");"):F.push(a(e,0),"=",i(e),"[",u(e),"];");for(var r=[],e=0;I>e;++e)r.push(a(e,0));for(var e=0;b>e;++e)r.push(c(e));F.push(p(0),"=",k,"[",T,"]=phase(",r.join(),");");for(var n=1;1<n;++n)F.push(p(n),"=",k,"[",T,"+",v(n),"];");for(var o=[],n=1;1<n;++n)o.push("("+p(0)+"!=="+p(n)+")");F.push("if(",o.join("||"),"){");for(var s=[],e=0;N>e;++e)s.push(h(e));for(var e=0;I>e;++e){s.push(a(e,0));for(var n=1;1<n;++n)L[e]?F.push(a(e,n),"=",i(e),".get(",u(e),"+",f(e,n),");"):F.push(a(e,n),"=",i(e),"[",u(e),"+",f(e,n),"];"),s.push(a(e,n))}for(var e=0;1<e;++e)s.push(p(e));for(var e=0;b>e;++e)s.push(c(e));F.push("vertex(",s.join(),");",m(0),"=",w,"[",T,"]=",A,"++;");for(var l=(1<n;++n)if(0===(t&~(1<0;_=_-1&g)x.push(w+"["+T+"+"+v(_)+"]");x.push(m(0));for(var _=0;I>_;++_)1&n?x.push(a(_,l),a(_,g)):x.push(a(_,g),a(_,l));1&n?x.push(d,y):x.push(y,d);for(var _=0;b>_;++_)x.push(c(_));F.push("if(",d,"!==",y,"){","face(",x.join(),")}")}F.push("}",T,"+=1;")}function R(){for(var t=1;1<t;++t)F.push(E,"=",v(t),";",v(t),"=",g(t),";",g(t),"=",E,";")}function O(t,e){if(0>t)return void P(e);z(t),F.push("if(",o(x[t]),">0){",h(x[t]),"=1;"),O(t-1,e|1<r;++r)F.push(u(r),"+=",d(r,x[t]),";");t===N-1&&(F.push(T,"=0;"),R()),S(t,2),O(t-1,e),t===N-1&&(F.push("if(",h(x[N-1]),"&1){",T,"=0;}"),R()),C(t),F.push("}")}var I=L.length,N=x.length;if(2>N)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var j="extractContour"+x.join("_"),F=[],D=[],B=[],U=0;I>U;++U)B.push(n(U));for(var U=0;b>U;++U)B.push(c(U));for(var U=0;N>U;++U)D.push(o(U)+"="+n(0)+".shape["+U+"]|0");for(var U=0;I>U;++U){D.push(i(U)+"="+n(U)+".data",l(U)+"="+n(U)+".offset|0");for(var V=0;N>V;++V)D.push(s(U,V)+"="+n(U)+".stride["+V+"]|0")}for(var U=0;I>U;++U){D.push(u(U)+"="+l(U)),D.push(a(U,0));for(var V=1;1<V;++V){for(var q=[],H=0;N>H;++H)V&1<U;++U)for(var V=0;N>V;++V){var G=[s(U,x[V])];V>0&&G.push(s(U,x[V-1])+"*"+o(x[V-1])),D.push(d(U,x[V])+"=("+G.join("-")+")|0")}for(var U=0;N>U;++U)D.push(h(U)+"=0");D.push(A+"=0");for(var Y=["2"],U=N-2;U>=0;--U)Y.push(o(x[U]));D.push(M+"=("+Y.join("*")+")|0",k+"=mallocUint32("+M+")",w+"=mallocUint32("+M+")",T+"=0"),D.push(p(0)+"=0");for(var V=1;1<V;++V){for(var X=[],W=[],H=0;N>H;++H)V&1<n&&e("Must have at least one array argument");var i=t.scalarArguments||0;0>i&&e("Scalar arg count must be > 0"),"function"!=typeof t.vertex&&e("Must specify vertex creation function"),"function"!=typeof t.cell&&e("Must specify cell creation function"),"function"!=typeof t.phase&&e("Must specify phase function");for(var a=t.getters||[],o=new Array(n),s=0;n>s;++s)a.indexOf(s)>=0?o[s]=!0:o[s]=!1;return b(t.vertex,t.cell,t.phase,i,r,o)}var _=t("typedarray-pool");e.exports=x;var w="V",k="P",A="N",M="Q",T="X",E="T"},{"typedarray-pool":237}],224:[function(t,e,r){function n(t){if(0>t)return Number("0/0");for(var e=s[0],r=s.length-1;r>0;--r)e+=s[r]/(t+r);var n=t+o+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}var i=7,a=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],o=607/128,s=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];e.exports=function l(t){if(.5>t)return Math.PI/(Math.sin(Math.PI*t)*l(1-t));if(t>100)return Math.exp(n(t));t-=1;for(var e=a[0],r=1;i+2>r;r++)e+=a[r]/(t+r);var o=t+i+.5;return Math.sqrt(2*Math.PI)*Math.pow(o,t+.5)*Math.exp(-o)*e},e.exports.log=n},{}],225:[function(t,e,r){"use strict";function n(t){var e=t.length;if(i>e){for(var r=1,n=0;e>n;++n)for(var o=0;n>o;++o)if(t[n]n;++n)s[n]=0;for(var r=1,n=0;e>n;++n)if(!s[n]){var l=1;s[n]=1;for(var o=t[n];o!==n;o=t[o]){if(s[o])return a.freeUint8(s),0;l+=1,s[o]=1}1&l||(r=-r)}return a.freeUint8(s),r}e.exports=n;var i=32,a=t("typedarray-pool")},{"typedarray-pool":237}],226:[function(t,e,r){"use strict";function n(t){var e=t.length;switch(e){case 0:case 1:return 0;case 2:return t[1]}var r,n,i,s=a.mallocUint32(e),l=a.mallocUint32(e),c=0;for(o(t,l),i=0;e>i;++i)s[i]=t[i];for(i=e-1;i>0;--i)n=l[i],r=s[i],s[i]=s[n],s[n]=r,l[i]=l[r],l[r]=n,c=(c+r)*i;return a.freeUint32(l),a.freeUint32(s),c}function i(t,e,r){switch(t){case 0:return r?r:[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}r=r||new Array(t);var n,i,a,o=1;for(r[0]=0,a=1;t>a;++a)r[a]=a,o=o*a|0;for(a=t-1;a>0;--a)n=e/o|0,e=e-n*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}var a=t("typedarray-pool"),o=t("invert-permutation");r.rank=n,r.unrank=i},{"invert-permutation":227,"typedarray-pool":237}],227:[function(t,e,r){"use strict";function n(t,e){e=e||new Array(t.length);for(var r=0;rt)return[];if(0===t)return[[0]];for(var e=0|Math.round(o(t+1)),r=[],n=0;e>n;++n){for(var s=i.unrank(t,n),l=[0],c=0,u=0;u= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":68}],230:[function(t,e,r){"use strict";function n(t,e){var r=[];return e=+e||0,i(t.hi(t.shape[0]-1),r,e),r}e.exports=n;var i=t("./lib/zc-core")},{"./lib/zc-core":229}],231:[function(t,e,r){"use strict";function n(t,e){var r=t.length,n=["'use strict';"],i="surfaceNets"+t.join("_")+"d"+e;n.push("var contour=genContour({","order:[",t.join(),"],","scalarArguments: 3,","phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },"),"generic"===e&&n.push("getters:[0],");for(var a=[],l=[],c=0;r>c;++c)a.push("d"+c),l.push("d"+c);for(var c=0;1<c;++c)a.push("v"+c),l.push("v"+c);for(var c=0;1<c;++c)a.push("p"+c),l.push("p"+c);a.push("a","b","c"),l.push("a","c"),n.push("vertex:function vertexFunc(",a.join(),"){");for(var u=[],c=0;1<c;++c)u.push("(p"+c+"<<"+c+")");n.push("var m=(",u.join("+"),")|0;if(m===0||m===",(1<<(1<=1<<(1<>>7){");for(var c=0;1<<(1<c;++c){if(1<<(1<128&&c%128===0){f.length>0&&h.push("}}");var d="vExtra"+f.length;n.push("case ",c>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&c,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;r>b;++b)p[b]=[],g[b]=[],v[b]=0,m[b]=0;for(var b=0;1<b;++b)for(var x=0;r>x;++x){var _=b^1<b)&&!(c&1<<_)!=!(c&1<w?(p[x].push("-v"+b+"-v"+_),v[x]+=2):(p[x].push("v"+b+"+v"+_),v[x]-=2),y+=1;for(var k=0;r>k;++k)k!==x&&(_&1<x;++x)if(0===p[x].length)A.push("d"+x+"-0.5");else{var M="";v[x]<0?M=v[x]+"*c":v[x]>0&&(M="+"+v[x]+"*c");var T=.5*(p[x].length/y),E=.5+.5*(m[x]/y);A.push("d"+x+"-"+E+"-"+T+"*("+p[x].join("+")+M+")/("+g[x].join("+")+")")}h.push("a.push([",A.join(),"]);","break;")}n.push("}},"),f.length>0&&h.push("}}");for(var L=[],c=0;1<c;++c)L.push("v"+c);L.push("c0","c1","p0","p1","a","b","c"),n.push("cell:function cellFunc(",L.join(),"){");var S=s(r-1);n.push("if(p0){b.push(",S.map(function(t){return"["+t.map(function(t){return"v"+t})+"]"}).join(),")}else{b.push(",S.map(function(t){var e=t.slice();return e.reverse(),"["+e.map(function(t){return"v"+t})+"]"}).join(),")}}});function ",i,"(array,level){var verts=[],cells=[];contour(array,verts,cells,level);return {positions:verts,cells:cells};} return ",i,";");for(var c=0;co;++o)i[o]=[r[o]],a[o]=[o];return{positions:i,cells:a}}function a(t,e){if(t.dimension<=0)return{positions:[],cells:[]};if(1===t.dimension)return i(t,e);var r=t.order.join()+"-"+t.dtype,a=c[r],e=+e||0;return a||(a=c[r]=n(t.order,t.dtype)),a(t,e)}e.exports=a;var o=t("ndarray-extract-contour"),s=t("triangulate-hypercube"),l=t("zero-crossings"),c={}},{"ndarray-extract-contour":223,"triangulate-hypercube":228,"zero-crossings":230}],232:[function(t,e,r){(function(r){"use strict";function n(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;ol;++l){var c=r[s[l]];n[i++]=c[0],n[i++]=c[1]+1.4,a=Math.max(c[0],a)}return{data:n,shape:a}}function i(t,e){var r=s[t];r||(r=s[t]={" ":{data:new Float32Array(0),shape:.2}});var o=r[e];if(!o)if(e.length<=1||!/\d/.test(e))o=r[e]=n(a(e,{triangles:!0,font:t,textAlign:"left",textBaseline:"alphabetic"}));else{for(var l=e.split(/(\d|\s)/),c=new Array(l.length),u=0,f=0,h=0;h0&&(f+=.02);for(var d=new Float32Array(u),p=0,g=-.5*f,h=0;h.5?l/(2-a-o):l/(a+o),a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,l:s}}function o(t,e,r){function n(t,e,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?t+6*(e-t)*r:.5>r?e:2/3>r?t+(e-t)*(2/3-r)*6:t}var i,a,o;if(t=T(t,360),e=T(e,100),r=T(r,100),0===e)i=a=o=r;else{var s=.5>r?r*(1+e):r+e-r*e,l=2*r-s;i=n(l,s,t+1/3),a=n(l,s,t),o=n(l,s,t-1/3)}return{r:255*i,g:255*a,b:255*o}}function s(t,e,r){t=T(t,255),e=T(e,255),r=T(r,255);var n,i,a=q(t,e,r),o=V(t,e,r),s=a,l=a-o;if(i=0===a?0:l/a,a==o)n=0;else{switch(a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,v:s}}function l(t,e,r){t=6*T(t,360),e=T(e,100),r=T(r,100);var n=B.floor(t),i=t-n,a=r*(1-e),o=r*(1-i*e),s=r*(1-(1-i)*e),l=n%6,c=[r,o,a,a,s,r][l],u=[s,r,r,o,a,a][l],f=[a,a,s,r,r,o][l];return{r:255*c,g:255*u,b:255*f}}function c(t,e,r,n){var i=[z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function u(t,e,r,n){var i=[z(R(n)),z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return i.join("")}function f(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s-=r/100,n.s=E(n.s),e(n)}function h(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s+=r/100,n.s=E(n.s),e(n)}function d(t){return e(t).desaturate(100)}function p(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l+=r/100,n.l=E(n.l),e(n)}function g(t,r){r=0===r?0:r||10;var n=e(t).toRgb();return n.r=q(0,V(255,n.r-U(255*-(r/100)))),n.g=q(0,V(255,n.g-U(255*-(r/100)))),n.b=q(0,V(255,n.b-U(255*-(r/100)))),e(n)}function v(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l-=r/100,n.l=E(n.l),e(n)}function m(t,r){var n=e(t).toHsl(),i=(U(n.h)+r)%360;return n.h=0>i?360+i:i,e(n)}function y(t){var r=e(t).toHsl();return r.h=(r.h+180)%360,e(r)}function b(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+120)%360,s:r.s,l:r.l}),e({h:(n+240)%360,s:r.s,l:r.l})]}function x(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+90)%360,s:r.s,l:r.l}),e({h:(n+180)%360,s:r.s,l:r.l}),e({h:(n+270)%360,s:r.s,l:r.l})]}function _(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+72)%360,s:r.s,l:r.l}),e({h:(n+216)%360,s:r.s,l:r.l})]}function w(t,r,n){r=r||6,n=n||30;var i=e(t).toHsl(),a=360/n,o=[e(t)];for(i.h=(i.h-(a*r>>1)+720)%360;--r;)i.h=(i.h+a)%360,o.push(e(i));return o}function k(t,r){r=r||6;for(var n=e(t).toHsv(),i=n.h,a=n.s,o=n.v,s=[],l=1/r;r--;)s.push(e({h:i,s:a,v:o})),o=(o+l)%1;return s}function A(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}function M(t){return t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=1),t}function T(t,e){S(t)&&(t="100%");var r=C(t);return t=V(e,q(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),B.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function E(t){return V(1,q(0,t))}function L(t){return parseInt(t,16)}function S(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function C(t){return"string"==typeof t&&-1!=t.indexOf("%")}function z(t){return 1==t.length?"0"+t:""+t}function P(t){return 1>=t&&(t=100*t+"%"),t}function R(t){return Math.round(255*parseFloat(t)).toString(16)}function O(t){return L(t)/255}function I(t){t=t.replace(j,"").replace(F,"").toLowerCase();var e=!1;if(G[t])t=G[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=X.rgb.exec(t))?{r:r[1],g:r[2],b:r[3]}:(r=X.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=X.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=X.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=X.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=X.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=X.hex8.exec(t))?{a:O(r[1]),r:L(r[2]),g:L(r[3]),b:L(r[4]),format:e?"name":"hex8"}:(r=X.hex6.exec(t))?{r:L(r[1]),g:L(r[2]),b:L(r[3]),format:e?"name":"hex"}:(r=X.hex3.exec(t))?{r:L(r[1]+""+r[1]),g:L(r[2]+""+r[2]),b:L(r[3]+""+r[3]),format:e?"name":"hex"}:!1}function N(t){var e,r;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==r&&"large"!==r&&(r="small"),{level:e,size:r}}var j=/^\s+/,F=/\s+$/,D=0,B=Math,U=B.round,V=B.min,q=B.max,H=B.random;e.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,r,n,i,a,o=this.toRgb();return t=o.r/255,e=o.g/255,r=o.b/255,n=.03928>=t?t/12.92:Math.pow((t+.055)/1.055,2.4),i=.03928>=e?e/12.92:Math.pow((e+.055)/1.055,2.4),a=.03928>=r?r/12.92:Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*i+.0722*a},setAlpha:function(t){return this._a=M(t),this._roundA=U(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=a(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=a(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return u(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:U(this._r),g:U(this._g),b:U(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+U(this._r)+", "+U(this._g)+", "+U(this._b)+")":"rgba("+U(this._r)+", "+U(this._g)+", "+U(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:U(100*T(this._r,255))+"%",g:U(100*T(this._g,255))+"%",b:U(100*T(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%)":"rgba("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:Y[c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+u(this._r,this._g,this._b,this._a),n=r,i=this._gradientType?"GradientType = 1, ":"";if(t){var a=e(t);n=a.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+r+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0,i=!e&&n&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return i?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return e(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(p,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(v,arguments)},desaturate:function(){return this._applyModification(f,arguments)},saturate:function(){return this._applyModification(h,arguments)},greyscale:function(){return this._applyModification(d,arguments)},spin:function(){return this._applyModification(m,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(w,arguments)},complement:function(){return this._applyCombination(y,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(_,arguments)},triad:function(){return this._applyCombination(b,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},e.fromRatio=function(t,r){if("object"==typeof t){var n={};for(var i in t)t.hasOwnProperty(i)&&("a"===i?n[i]=t[i]:n[i]=P(t[i]));t=n}return e(t,r)},e.equals=function(t,r){return t&&r?e(t).toRgbString()==e(r).toRgbString():!1},e.random=function(){return e.fromRatio({r:H(),g:H(),b:H()})},e.mix=function(t,r,n){n=0===n?0:n||50;var i,a=e(t).toRgb(),o=e(r).toRgb(),s=n/100,l=2*s-1,c=o.a-a.a;i=l*c==-1?l:(l+c)/(1+l*c),i=(i+1)/2;var u=1-i,f={r:o.r*i+a.r*u,g:o.g*i+a.g*u,b:o.b*i+a.b*u,a:o.a*s+a.a*(1-s)};return e(f)},e.readability=function(t,r){var n=e(t),i=e(r);return(Math.max(n.getLuminance(),i.getLuminance())+.05)/(Math.min(n.getLuminance(),i.getLuminance())+.05)},e.isReadable=function(t,r,n){var i,a,o=e.readability(t,r);switch(a=!1,i=N(n),i.level+i.size){case"AAsmall":case"AAAlarge":a=o>=4.5;break;case"AAlarge":a=o>=3;break;case"AAAsmall":a=o>=7}return a},e.mostReadable=function(t,r,n){var i,a,o,s,l=null,c=0;n=n||{},a=n.includeFallbackColors,o=n.level,s=n.size;for(var u=0;uc&&(c=i,l=e(r[u]));return e.isReadable(t,l,{level:o,size:s})||!a?l:(n.includeFallbackColors=!1,e.mostReadable(t,["#fff","#000"],n))};var G=e.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Y=e.hexNames=A(G),X=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",r="(?:"+e+")|(?:"+t+")",n="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",i="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof r&&r.exports?r.exports=e:"function"==typeof t&&t.amd?t(function(){return e}):window.tinycolor=e}()},{}],234:[function(e,r,n){!function(e,i){"object"==typeof n&&"undefined"!=typeof r?i(n):"function"==typeof t&&t.amd?t(["exports"],i):i(e.topojson={})}(this,function(t){"use strict";function e(){}function r(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0),t[0]=(r+=t[0])*i+o,t[1]=(n+=t[1])*a+s}}function n(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0);var l=(t[0]-o)/i|0,c=(t[1]-s)/a|0;t[0]=l-r,t[1]=c-n,r=l,n=c}}function i(t,e){for(var r,n=t.length,i=n-e;i<--n;)r=t[i],t[i++]=t[n],t[n]=r}function a(t,e){for(var r=0,n=t.length;n>r;){var i=r+n>>>1;t[i]t?~t:t],a=0,o=n.length;o>a;++a)e.push(r=n[a].slice()),u(r,a);0>t&&i(e,o)}function a(t){return t=t.slice(),u(t,0),t}function o(t){for(var e=[],r=0,i=t.length;i>r;++r)n(t[r],e);return e.length<2&&e.push(e[0].slice()),e}function s(t){for(var e=o(t);e.length<4;)e.push(e[0].slice());return e}function l(t){return t.map(s)}function c(t){var e=t.type;return"GeometryCollection"===e?{type:e,geometries:t.geometries.map(c)}:e in h?{type:e,coordinates:h[e](t)}:null}var u=r(t.transform),f=t.arcs,h={Point:function(t){return a(t.coordinates)},MultiPoint:function(t){return t.coordinates.map(a)},LineString:function(t){return o(t.arcs)},MultiLineString:function(t){return t.arcs.map(o)},Polygon:function(t){return l(t.arcs)},MultiPolygon:function(t){return t.arcs.map(l)}};return c(e)}function c(t,e){function r(e){var r,n=t.arcs[0>e?~e:e],i=n[0];return t.transform?(r=[0,0],n.forEach(function(t){r[0]+=t[0],r[1]+=t[1]})):r=n[n.length-1],0>e?[r,i]:[i,r]}function n(t,e){for(var r in t){var n=t[r];delete e[n.start],delete n.start,delete n.end,n.forEach(function(t){i[0>t?~t:t]=1}),s.push(n)}}var i={},a={},o={},s=[],l=-1;return e.forEach(function(r,n){var i,a=t.arcs[0>r?~r:r];a.length<3&&!a[1][0]&&!a[1][1]&&(i=e[++l],e[l]=r,e[n]=i)}),e.forEach(function(t){var e,n,i=r(t),s=i[0],l=i[1];if(e=o[s])if(delete o[e.end],e.push(t),e.end=l,n=a[l]){delete a[n.start];var c=n===e?e:e.concat(n);a[c.start=e.start]=o[c.end=n.end]=c}else a[e.start]=o[e.end]=e;else if(e=a[l])if(delete a[e.start],e.unshift(t),e.start=s,n=o[s]){delete o[n.end];var u=n===e?e:n.concat(e);a[u.start=n.start]=o[u.end=e.end]=u}else a[e.start]=o[e.end]=e;else e=[t],a[e.start=s]=o[e.end=l]=e}),n(o,a),n(a,o),e.forEach(function(t){i[0>t?~t:t]||s.push([t])}),s}function u(t){return l(t,f.apply(this,arguments))}function f(t,e,r){function n(t){var e=0>t?~t:t;(u[e]||(u[e]=[])).push({i:t,g:l})}function i(t){t.forEach(n)}function a(t){t.forEach(i)}function o(t){"GeometryCollection"===t.type?t.geometries.forEach(o):t.type in f&&(l=t,f[t.type](t.arcs))}var s=[];if(arguments.length>1){var l,u=[],f={LineString:i,MultiLineString:a,Polygon:a,MultiPolygon:function(t){t.forEach(a)}};o(e),u.forEach(arguments.length<3?function(t){s.push(t[0].i)}:function(t){r(t[0].g,t[t.length-1].g)&&s.push(t[0].i)})}else for(var h=0,d=t.arcs.length;d>h;++h)s.push(h);return{type:"MultiLineString",arcs:c(t,s)}}function h(t){var e=t[0],r=t[1],n=t[2];return Math.abs((e[0]-n[0])*(r[1]-e[1])-(e[0]-r[0])*(n[1]-e[1]))}function d(t){for(var e,r=-1,n=t.length,i=t[n-1],a=0;++re?~e:e]||(i[e]=[])).push(t)})}),a.push(t)}function n(e){return d(l(t,{type:"Polygon",arcs:[e]}).coordinates[0])>0}var i={},a=[],o=[];return e.forEach(function(t){"Polygon"===t.type?r(t.arcs):"MultiPolygon"===t.type&&t.arcs.forEach(r)}),a.forEach(function(t){if(!t._){var e=[],r=[t];for(t._=1,o.push(e);t=r.pop();)e.push(t),t.forEach(function(t){t.forEach(function(t){i[0>t?~t:t].forEach(function(t){t._||(t._=1,r.push(t))})})})}}),a.forEach(function(t){delete t._}),{type:"MultiPolygon",arcs:o.map(function(e){var r,a=[];if(e.forEach(function(t){t.forEach(function(t){t.forEach(function(t){i[0>t?~t:t].length<2&&a.push(t)})})}),a=c(t,a),(r=a.length)>1)for(var o,s=n(e[0][0]),l=0;r>l;++l)if(s===n(a[l])){o=a[0],a[0]=a[l],a[l]=o;break}return a})}}function v(t){function e(t,e){t.forEach(function(t){0>t&&(t=~t);var r=i[t];r?r.push(e):i[t]=[e]})}function r(t,r){t.forEach(function(t){e(t,r)})}function n(t,e){"GeometryCollection"===t.type?t.geometries.forEach(function(t){n(t,e)}):t.type in s&&s[t.type](t.arcs,e)}var i={},o=t.map(function(){return[]}),s={LineString:e,MultiLineString:r,Polygon:r,MultiPolygon:function(t,e){t.forEach(function(t){r(t,e)})}};t.forEach(n);for(var l in i)for(var c=i[l],u=c.length,f=0;u>f;++f)for(var h=f+1;u>h;++h){var d,p=c[f],g=c[h];(d=o[p])[l=a(d,g)]!==g&&d.splice(l,0,g),(d=o[g])[l=a(d,p)]!==p&&d.splice(l,0,p)}return o}function m(t,e){return t[1][2]-e[1][2]}function y(){function t(t,e){for(;e>0;){var r=(e+1>>1)-1,i=n[r];if(m(t,i)>=0)break;n[i._=e]=i,n[t._=e=r]=t}}function e(t,e){for(;;){var r=e+1<<1,a=r-1,o=e,s=n[o];if(i>a&&m(n[a],s)<0&&(s=n[o=a]),i>r&&m(n[r],s)<0&&(s=n[o=r]),o===e)break;n[s._=e]=s,n[t._=e=o]=t}}var r={},n=[],i=0;return r.push=function(e){return t(n[e._=i]=e,i++),i},r.pop=function(){if(!(0>=i)){var t,r=n[0];return--i>0&&(t=n[i],e(n[t._=0]=t,0)),r}},r.remove=function(r){var a,o=r._;if(n[o]===r)return o!==--i&&(a=n[i],(m(a,r)<0?t:e)(n[a._=o]=a,o)),o},r}function b(t,e){function i(t){s.remove(t),t[1][2]=e(t),s.push(t)}var a=r(t.transform),o=n(t.transform),s=y();return e||(e=h),t.arcs.forEach(function(t){var r,n,l,c,u=[],f=0;for(n=0,l=t.length;l>n;++n)c=t[n],a(t[n]=[c[0],c[1],1/0],n);for(n=1,l=t.length-1;l>n;++n)r=t.slice(n-1,n+2),r[1][2]=e(r),u.push(r),s.push(r);for(n=0,l=u.length;l>n;++n)r=u[n],r.previous=u[n-1],r.next=u[n+1];for(;r=s.pop();){var h=r.previous,d=r.next;r[1][2]0?r.pop():new ArrayBuffer(t)}function s(t){return new Uint8Array(o(t),0,t)}function l(t){return new Uint16Array(o(2*t),0,t)}function c(t){return new Uint32Array(o(4*t),0,t)}function u(t){return new Int8Array(o(t),0,t)}function f(t){return new Int16Array(o(2*t),0,t)}function h(t){return new Int32Array(o(4*t),0,t)}function d(t){return new Float32Array(o(4*t),0,t)}function p(t){return new Float64Array(o(8*t),0,t)}function g(t){return x?new Uint8ClampedArray(o(t),0,t):s(t)}function v(t){return new DataView(o(t),0,t)}function m(t){t=y.nextPow2(t);var e=y.log2(t),r=k[e];return r.length>0?r.pop():new n(t)}var y=t("bit-twiddle"),b=t("dup");e.__TYPEDARRAY_POOL||(e.__TYPEDARRAY_POOL={UINT8:b([32,0]),UINT16:b([32,0]),UINT32:b([32,0]),INT8:b([32,0]),INT16:b([32,0]),INT32:b([32,0]),FLOAT:b([32,0]),DOUBLE:b([32,0]),DATA:b([32,0]),UINT8C:b([32,0]),BUFFER:b([32,0])});var x="undefined"!=typeof Uint8ClampedArray,_=e.__TYPEDARRAY_POOL;_.UINT8C||(_.UINT8C=b([32,0])),_.BUFFER||(_.BUFFER=b([32,0]));var w=_.DATA,k=_.BUFFER;r.free=function(t){if(n.isBuffer(t))k[y.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|y.log2(e);w[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=a,r.freeArrayBuffer=i,r.freeBuffer=function(t){k[y.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return o(t);switch(e){case"uint8":return s(t);case"uint16":return l(t);case"uint32":return c(t);case"int8":return u(t);case"int16":return f(t);case"int32":return h(t);case"float":case"float32":return d(t);case"double":case"float64":return p(t);case"uint8_clamped":return g(t);case"buffer":return m(t);case"data":case"dataview":return v(t);default:return null}return null},r.mallocArrayBuffer=o,r.mallocUint8=s,r.mallocUint16=l,r.mallocUint32=c,r.mallocInt8=u,r.mallocInt16=f,r.mallocInt32=h,r.mallocFloat32=r.mallocFloat=d,r.mallocFloat64=r.mallocDouble=p,r.mallocUint8Clamped=g,r.mallocDataView=v,r.mallocBuffer=m,r.clearCache=function(){for(var t=0;32>t;++t)_.UINT8[t].length=0,_.UINT16[t].length=0,_.UINT32[t].length=0,_.INT8[t].length=0,_.INT16[t].length=0,_.INT32[t].length=0,_.FLOAT[t].length=0,_.DOUBLE[t].length=0,_.UINT8C[t].length=0,w[t].length=0,k[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":50,buffer:51,dup:74}],238:[function(t,e,r){"use strict";function n(t,e){for(var r=1,n=t.length,i=t[0],a=t[0],o=1;n>o;++o)if(a=i,i=t[o],e(i,a)){if(o===r){r++;continue}t[r++]=i}return t.length=r,t}function i(t){for(var e=1,r=t.length,n=t[0],i=t[0],a=1;r>a;++a,i=n)if(i=n,n=t[a],n!==i){if(a===e){e++;continue}t[e++]=n}return t.length=e,t}function a(t,e,r){return 0===t.length?t:e?(r||t.sort(e),n(t,e)):(r||t.sort(),i(t))}e.exports=a},{}],239:[function(t,e,r){"use strict";function n(t,e){return"object"==typeof e&&null!==e||(e={}),i(t,e.canvas||a,e.context||o,e)}e.exports=n;var i=t("./lib/vtext"),a=null,o=null;"undefined"!=typeof document&&(a=document.createElement("canvas"),a.width=8192,a.height=1024,o=a.getContext("2d"))},{"./lib/vtext":240}],240:[function(t,e,r){"use strict";function n(t,e,r){for(var n=e.textAlign||"start",i=e.textBaseline||"alphabetic",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;s>l;++l)for(var c=t[l],u=0;2>u;++u)a[u]=0|Math.min(a[u],c[u]),o[u]=0|Math.max(o[u],c[u]);var f=0;switch(n){case"center":f=-.5*(a[0]+o[0]);break;case"right":case"end":f=-o[0];break;case"left":case"start":f=-a[0];break;default:throw new Error("vectorize-text: Unrecognized textAlign: '"+n+"'")}var h=0;switch(i){case"hanging":case"top":h=-a[1];break;case"middle":h=-.5*(a[1]+o[1]);break;case"alphabetic":case"ideographic":h=-3*r;break;case"bottom":h=-o[1];break;default:throw new Error("vectorize-text: Unrecoginized textBaseline: '"+i+"'")}var d=1/r;return"lineHeight"in e?d*=+e.lineHeight:"width"in e?d=e.width/(o[0]-a[0]):"height"in e&&(d=e.height/(o[1]-a[1])),t.map(function(t){return[d*(t[0]+f),d*(t[1]+h)]})}function i(t,e,r,n){var i=0|Math.ceil(e.measureText(r).width+2*n);if(i>8192)throw new Error("vectorize-text: String too long (sorry, this will get fixed later)");var a=3*n;t.heights)){if(n>i){var l=n;n=i,i=l,l=o,o=s,s=l}e.isConstraint(n,i)||a(t[n],t[i],t[o],t[s])<0&&r.push(n,i)}}function i(t,e){for(var r=[],i=t.length,o=e.stars,s=0;i>s;++s)for(var l=o[s],c=1;cu||e.isConstraint(s,u))){for(var f=l[c-1],h=-1,d=1;dh||a(t[s],t[u],t[f],t[h])<0&&r.push(s,u)}}for(;r.length>0;){for(var u=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],p=1;pf||0>h||a(t[s],t[u],t[f],t[h])>=0||(e.flip(s,u),n(t,e,r,f,s,h),n(t,e,r,s,h,f),n(t,e,r,h,u,f),n(t,e,r,u,f,h))}}var a=t("robust-in-sphere")[4];t("binary-search-bounds");e.exports=i},{"binary-search-bounds":246,"robust-in-sphere":247}],243:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function i(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}function a(t,e){for(var r=t.cells(),a=r.length,o=0;a>o;++o){var s=r[o],l=s[0],c=s[1],u=s[2];u>c?l>c&&(s[0]=c,s[1]=u,s[2]=l):l>u&&(s[0]=u,s[1]=l,s[2]=c)}r.sort(i);for(var f=new Array(a),o=0;oo;++o)for(var s=r[o],y=0;3>y;++y){var l=s[y],c=s[(y+1)%3],b=p[3*o+y]=m.locate(c,l,t.opposite(c,l)),x=g[3*o+y]=t.isConstraint(l,c);0>b&&(x?d.push(o):(h.push(o),f[o]=1),e&&v.push([c,l,-1]))}return m}function o(t,e,r){for(var n=0,i=0;i0||l.length>0;){for(;s.length>0;){var d=s.pop();if(c[d]!==-i){c[d]=i;for(var p=(u[d],0);3>p;++p){var g=h[3*d+p];g>=0&&0===c[g]&&(f[3*d+p]?l.push(g):(s.push(g),c[g]=i))}}}var v=l;l=s,s=v,l.length=0,i=-i}var m=o(u,c,e);return r?m.concat(n.boundary):m}var l=t("binary-search-bounds");e.exports=s;var c=n.prototype;c.locate=function(){var t=[0,0,0];return function(e,r,n){var a=e,o=r,s=n;return n>r?e>r&&(a=r,o=n,s=e):e>n&&(a=n,o=e,s=r),0>a?-1:(t[0]=a,t[1]=o,t[2]=s,l.eq(this.cells,t,i))}}()},{"binary-search-bounds":246}],244:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.a=t,this.b=e,this.idx=r,this.lowerIds=n,this.upperIds=i}function i(t,e,r,n){this.a=t,this.b=e,this.type=r,this.idx=n}function a(t,e){var r=t.a[0]-e.a[0]||t.a[1]-e.a[1]||t.type-e.type;return r?r:t.type!==p&&(r=d(t.a,t.b,e.b))?r:t.idx-e.idx}function o(t,e){return d(t.a,t.b,e)}function s(t,e,r,n,i){for(var a=h.lt(e,n,o),s=h.gt(e,n,o),l=a;s>l;++l){for(var c=e[l],u=c.lowerIds,f=u.length;f>1&&d(r[u[f-2]],r[u[f-1]],n)>0;)t.push([u[f-1],u[f-2],i]),f-=1;u.length=f,u.push(i);for(var p=c.upperIds,f=p.length;f>1&&d(r[p[f-2]],r[p[f-1]],n)<0;)t.push([p[f-2],p[f-1],i]),f-=1;p.length=f,p.push(i)}}function l(t,e){var r;return(r=t.a[0]f;++f)l.push(new i(t[f],null,p,f));for(var f=0;o>f;++f){var h=e[f],d=t[h[0]],m=t[h[1]];d[0]m[0]&&l.push(new i(m,d,v,f),new i(d,m,g,f))}l.sort(a);for(var y=l[0].a[0]-(1+Math.abs(l[0].a[0]))*Math.pow(2,-52),b=[new n([y,1],[y,0],-1,[],[],[],[])],x=[],f=0,_=l.length;_>f;++f){var w=l[f],k=w.type;k===p?s(x,b,t,w.a,w.idx):k===v?c(b,t,w):u(b,t,w)}return x}var h=t("binary-search-bounds"),d=t("robust-orientation")[3],p=0,g=1,v=2;e.exports=f},{"binary-search-bounds":246,"robust-orientation":218}],245:[function(t,e,r){"use strict";function n(t,e){this.stars=t,this.edges=e}function i(t,e,r){for(var n=1,i=t.length;i>n;n+=2)if(t[n-1]===e&&t[n]===r)return t[n-1]=t[i-2],t[n]=t[i-1],void(t.length=i-2)}function a(t,e){for(var r=new Array(t),i=0;t>i;++i)r[i]=[];return new n(r,e)}var o=t("binary-search-bounds");e.exports=a;var s=n.prototype;s.isConstraint=function(){function t(t,e){return t[0]-e[0]||t[1]-e[1]}var e=[0,0];return function(r,n){return e[0]=Math.min(r,n),e[1]=Math.max(r,n),o.eq(this.edges,e,t)>=0}}(),s.removeTriangle=function(t,e,r){var n=this.stars;i(n[t],e,r),i(n[e],r,t),i(n[r],t,e)},s.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},s.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;i>n;n+=2)if(r[n]===t)return r[n-1];return-1},s.flip=function(t,e){var r=this.opposite(t,e),n=this.opposite(e,t);this.removeTriangle(t,e,r),this.removeTriangle(e,t,n),this.addTriangle(t,n,r),this.addTriangle(e,r,n)},s.edges=function(){for(var t=this.stars,e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0,o=i.length;o>a;a+=2)e.push([i[a],i[a+1]]);return e},s.cells=function(){for(var t=this.stars,e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0,o=i.length;o>a;a+=2){var s=i[a],l=i[a+1];rr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-2,"]"].join("")}return e}function a(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",a(t.slice(0,e)),",",a(t.slice(e)),")"].join("")}function o(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return o(e,t)}function s(t){return t&!0?"-":""}function l(t){if(2===t.length)return[["diff(",o(t[0][0],t[1][1]),",",o(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;rn;++n)r.push(["prod(m",t,"[",n,"],m",t,"[",n,"])"].join(""));return a(r)}function u(t){for(var e=[],r=[],o=i(t),s=0;t>s;++s)o[0][s]="1",o[t-1][s]="w"+s;for(var s=0;t>s;++s)0===(1&s)?e.push.apply(e,l(n(o,s))):r.push.apply(r,l(n(o,s)));for(var u=a(e),f=a(r),h="exactInSphere"+t,d=[],s=0;t>s;++s)d.push("m"+s);for(var p=["function ",h,"(",d.join(),"){"],s=0;t>s;++s){p.push("var w",s,"=",c(s,t),";");for(var g=0;t>g;++g)g!==s&&p.push("var w",s,"m",g,"=scale(w",s,",m",g,"[0]);")}p.push("var p=",u,",n=",f,",d=diff(p,n);return d[d.length-1];}return ",h);var x=new Function("sum","diff","prod","scale",p.join(""));return x(m,y,v,b)}function f(){return 0}function h(){return 0}function d(){return 0}function p(t){var e=_[t.length];return e||(e=_[t.length]=u(t.length)),e.apply(void 0,t)}function g(){for(;_.length<=x;)_.push(u(_.length));for(var t=[],r=["slow"],n=0;x>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function testInSphere(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;x>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var v=t("two-product"),m=t("robust-sum"),y=t("robust-subtract"),b=t("robust-scale"),x=6,_=[f,h,d];g()},{"robust-scale":219,"robust-subtract":220,"robust-sum":221,"two-product":235}],248:[function(t,e,r){"use strict";function n(t){var e=x(t),r=b(y(e),t);return 0>r?[e,w(e,1/0)]:r>0?[w(e,-(1/0)),e]:[e,e]}function i(t,e){for(var r=new Array(e.length),n=0;n=t.length)return o[e-t.length];var r=t[e];return[y(r[0]),y(r[1])]}for(var o=[],s=0;s=0;--s){var g=n[s],c=g[0],v=e[c],m=v[0],x=v[1],w=t[m],A=t[x];if((w[0]-A[0]||w[1]-A[1])<0){var M=m;m=x,x=M}v[0]=m;var T,E=v[1]=g[1];for(i&&(T=v[2]);s>0&&n[s-1][0]===c;){var g=n[--s],L=g[1];i?e.push([E,L,T]):e.push([E,L]),E=L}i?e.push([E,x,T]):e.push([E,x])}return o}function c(t,e,r){for(var i=t.length+e.length,a=new g(i),o=r,s=0;ss;++s){var p=a.find(s);p===s?(d[s]=f,t[f++]=t[s]):(h=!1,d[s]=-1)}if(t.length=f,h)return null;for(var s=0;i>s;++s)d[s]<0&&(d[s]=d[a.find(s)]);return d}function u(t,e){return t[0]-e[0]||t[1]-e[1]}function f(t,e){var r=t[0]-e[0]||t[1]-e[1];return r?r:t[2]e[2]?1:0}function h(t,e,r){if(0!==t.length){if(e)for(var n=0;n0||d.length>0}function p(t,e,r){var n,i=!1;if(r){n=e;for(var a=new Array(e.length),o=0;o0?r=r.shln(f):0>f&&(u=u.shln(-f)),l(r,u)}var i=t("./is-rat"),a=t("./lib/is-bn"),o=t("./lib/num-to-bn"),s=t("./lib/str-to-bn"),l=t("./lib/rationalize"),c=t("./div");e.exports=n},{"./div":252,"./is-rat":254,"./lib/is-bn":258,"./lib/num-to-bn":259,"./lib/rationalize":260,"./lib/str-to-bn":261}],254:[function(t,e,r){"use strict";function n(t){return Array.isArray(t)&&2===t.length&&i(t[0])&&i(t[1])}var i=t("./lib/is-bn");e.exports=n},{"./lib/is-bn":258}],255:[function(t,e,r){"use strict";function n(t){return t.cmp(new i(0))}var i=t("bn.js");e.exports=n},{"bn.js":263}],256:[function(t,e,r){"use strict";function n(t){var e=t.length,r=t.words,n=0;if(1===e)n=r[0];else if(2===e)n=r[0]+67108864*r[1];else for(var n=0,i=0;e>i;i++){var a=r[i];n+=a*Math.pow(67108864,i)}return t.sign?-n:n}e.exports=n},{}],257:[function(t,e,r){"use strict";function n(t){var e=a(i.lo(t));if(32>e)return e;var r=a(i.hi(t));return r>20?52:r+32}var i=t("double-bits"),a=t("bit-twiddle").countTrailingZeros;e.exports=n},{"bit-twiddle":50,"double-bits":274}],258:[function(t,e,r){"use strict";function n(t){return t&&"object"==typeof t&&Boolean(t.words)}t("bn.js");e.exports=n},{"bn.js":263}],259:[function(t,e,r){"use strict";function n(t){var e=a.exponent(t);return 52>e?new i(t):new i(t*Math.pow(2,52-e)).shln(e-52)}var i=t("bn.js"),a=t("double-bits");e.exports=n},{"bn.js":263,"double-bits":274}],260:[function(t,e,r){"use strict";function n(t,e){var r=a(t),n=a(e);if(0===r)return[i(0),i(1)];if(0===n)return[i(0),i(0)];0>n&&(t=t.neg(),e=e.neg());var o=t.gcd(e);return o.cmpn(1)?[t.div(o),e.div(o)]:[t,e]}var i=t("./num-to-bn"),a=t("./bn-sign");e.exports=n},{"./bn-sign":255,"./num-to-bn":259}],261:[function(t,e,r){"use strict";function n(t){return new i(t)}var i=t("bn.js");e.exports=n},{"bn.js":263}],262:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[0]),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":260}],263:[function(t,e,r){!function(t,e){"use strict";function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){return null!==t&&"object"==typeof t&&Array.isArray(t.words)?t:(this.sign=!1,this.words=null,this.length=0,this.red=null,"le"!==e&&"be"!==e||(r=e,e=10),void(null!==t&&this._init(t||0,e||10,r||"be")))}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),a=e;i>a;a++){var o=t.charCodeAt(a)-48;n<<=4,n|=o>=49&&54>=o?o-49+10:o>=17&&22>=o?o-17+10:15&o}return n}function o(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;a>o;o++){var s=t.charCodeAt(o)-48;i*=n,i+=s>=49?s-49+10:s>=17?s-17+10:s}return i}function s(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).ishln(this.n).isub(this.p),this.tmp=this._tmp()}function l(){s.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function c(){s.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function u(){s.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function f(){s.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function h(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function d(t){h.call(this,t),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).ishln(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.sign=!0,this.minv=this.minv.mod(this.r)}"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26,i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&36>=e),t=t.toString().replace(/\s+/g,"");var i=0;"-"===t[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.sign=!0),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initNumber=function(t,e,n){0>t&&(this.sign=!0,t=-t),67108864>t?(this.words=[67108863&t],this.length=1):4503599627370496>t?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(9007199254740992>t),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3){var s=t[i]|t[i-1]<<8|t[i-2]<<16;this.words[o]|=s<>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}else if("le"===n)for(var i=0,o=0;i>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}return this.strip()},i.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6){var o=a(t,r,r+6);this.words[i]|=o<>>26-n&4194303,n+=24,n>=26&&(n-=26,i++)}if(r+6!==e){var o=a(t,e,r+6);this.words[i]|=o<>>26-n&4194303}this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;67108863>=i;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,s=a%n,l=Math.min(a,a-s)+r,c=0,u=r;l>u;u+=n)c=o(t,u,u+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){for(var f=1,c=o(t,u,t.length,e),u=0;s>u;u++)f*=e;this.imuln(f),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},i.prototype.inspect=function(){return(this.red?""};var p=["","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"],g=[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],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176]; -i.prototype.toString=function(t,e){if(t=t||10,16===t||"hex"===t){for(var n="",i=0,e=0|e||1,a=0,o=0;o>>24-i&16777215,n=0!==a||o!==this.length-1?p[6-l.length]+l+n:l+n,i+=2,i>=26&&(i-=26,o--)}for(0!==a&&(n=a.toString(16)+n);n.length%e!==0;)n="0"+n;return this.sign&&(n="-"+n),n}if(t===(0|t)&&t>=2&&36>=t){var c=g[t],u=v[t],n="",f=this.clone();for(f.sign=!1;0!==f.cmpn(0);){var h=f.modn(u).toString(t);f=f.idivn(u),n=0!==f.cmpn(0)?p[c-h.length]+h+n:h+n}return 0===this.cmpn(0)&&(n="0"+n),this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(t){this.strip();var e=new Array(this.byteLength());e[0]=0;var r=this.clone();if("le"!==t)for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[e.length-n-1]=i}else for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[n]=i}return e},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0===(8191&e)&&(r+=13,e>>>=13),0===(127&e)&&(r+=7,e>>>=7),0===(15&e)&&(r+=4,e>>>=4),0===(3&e)&&(r+=2,e>>>=2),0===(1&e)&&r++,r},i.prototype.bitLength=function(){var t=0,e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.iand=function(t){this.sign=this.sign&&t.sign;var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.ixor=function(t){this.sign=this.sign||t.sign;var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);for(var n=t/26|0,i=t%26;this.length<=n;)this.words[this.length++]=0;return e?this.words[n]=this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26}for(;0!==i&&a>>26}if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(t.sign){t.sign=!1;var e=this.iadd(t);return t.sign=!0,e._normSign()}if(this.sign)return this.sign=!1,this.iadd(t),this.sign=!0,this._normSign();var r=this.cmp(t);if(0===r)return this.sign=!1,this.length=1,this.words[0]=0,this;var n,i;r>0?(n=this,i=t):(n=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e}for(;0!==a&&o>26,this.words[o]=67108863&e}if(0===a&&o>>26,a=67108863&r,o=Math.min(n,t.length-1),s=Math.max(0,n-this.length+1);o>=s;s++){var l=n-s,c=0|this.words[l],u=0|t.words[s],f=c*u,h=67108863&f;i=i+(f/67108864|0)|0,h=h+a|0,a=67108863&h,i=i+(h>>>26)|0}e.words[n]=a,r=i}return 0!==r?e.words[n]=r:e.length--,e.strip()},i.prototype._bigMulTo=function(t,e){e.sign=t.sign!==this.sign,e.length=this.length+t.length;for(var r=0,n=0,i=0;i=l;l++){var c=i-l,u=0|this.words[c],f=0|t.words[l],h=u*f,d=67108863&h;a=a+(h/67108864|0)|0,d=d+o|0,o=67108863&d,a=a+(d>>>26)|0,n+=a>>>26,a&=67108863}e.words[i]=o,r=a,a=n}return 0!==r?e.words[i]=r:e.length--,e.strip()},i.prototype.mulTo=function(t,e){var r;return r=this.length+t.length<63?this._smallMulTo(t,e):this._bigMulTo(t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.imul=function(t){if(0===this.cmpn(0)||0===t.cmpn(0))return this.words[0]=0,this.length=1,this;var e=this.length,r=t.length;this.sign=t.sign!==this.sign,this.length=this.length+t.length,this.words[this.length-1]=0;for(var n=this.length-2;n>=0;n--){for(var i=0,a=0,o=Math.min(n,r-1),s=Math.max(0,n-e+1);o>=s;s++){var l=n-s,c=this.words[l],u=t.words[s],f=c*u,h=67108863&f;i+=f/67108864|0,h+=a,a=67108863&h,i+=h>>>26}this.words[n]=a,this.words[n+1]+=i,i=0}for(var i=0,l=1;l>>26}return this.strip()},i.prototype.imuln=function(t){r("number"==typeof t);for(var e=0,n=0;n>=26,e+=i/67108864|0,e+=a>>>26,this.words[n]=67108863&a}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.ishln=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=67108863>>>26-e<<26-e;if(0!==e){for(var a=0,o=0;o>>26-e}a&&(this.words[o]=a,this.length++)}if(0!==n){for(var o=this.length-1;o>=0;o--)this.words[o+n]=this.words[o];for(var o=0;n>o;o++)this.words[o]=0;this.length+=n}return this.strip()},i.prototype.ishrn=function(t,e,n){r("number"==typeof t&&t>=0);var i;i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<c;c++)l.words[c]=this.words[c];l.length=o}if(0===o);else if(this.length>o){this.length-=o;for(var c=0;c=0&&(0!==u||c>=i);c--){var f=this.words[c];this.words[c]=u<<26-a|f>>>a,u=f&s}return l&&0!==u&&(l.words[l.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<t?this.isubn(-t):this.sign?1===this.length&&this.words[0]=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),0>t)return this.iaddn(-t);if(this.sign)return this.sign=!1,this.iaddn(t),this.sign=!0,this;this.words[0]-=t;for(var e=0;e>26)-(c/67108864|0),this.words[i+n]=67108863&l}for(;i>26,this.words[i+n]=67108863&l}if(0===s)return this.strip();r(-1===s),s=0;for(var i=0;i>26,this.words[i]=67108863&l}return this.sign=!0,this.strip()},i.prototype._wordDiv=function(t,e){var r=this.length-t.length,n=this.clone(),a=t,o=a.words[a.length-1],s=this._countBits(o);r=26-s,0!==r&&(a=a.shln(r),n.ishln(r),o=a.words[a.length-1]);var l,c=n.length-a.length;if("mod"!==e){l=new i(null),l.length=c+1,l.words=new Array(l.length);for(var u=0;u=0;h--){var d=67108864*n.words[a.length+h]+n.words[a.length+h-1];for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(a,d,h);n.sign;)d--,n.sign=!1,n._ishlnsubmul(a,1,h),0!==n.cmpn(0)&&(n.sign=!n.sign);l&&(l.words[h]=d)}return l&&l.strip(),n.strip(),"div"!==e&&0!==r&&n.ishrn(r),{div:l?l:null,mod:n}},i.prototype.divmod=function(t,e){if(r(0!==t.cmpn(0)),this.sign&&!t.sign){var n,a,o=this.neg().divmod(t,e);return"mod"!==e&&(n=o.div.neg()),"div"!==e&&(a=0===o.mod.cmpn(0)?o.mod:t.sub(o.mod)),{div:n,mod:a}}if(!this.sign&&t.sign){var n,o=this.divmod(t.neg(),e);return"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}}return this.sign&&t.sign?this.neg().divmod(t.neg(),e):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e)},i.prototype.div=function(t){return this.divmod(t,"div").div},i.prototype.mod=function(t){return this.divmod(t,"mod").mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(0===e.mod.cmpn(0))return e.div;var r=e.div.sign?e.mod.isub(t):e.mod,n=t.shrn(1),i=t.andln(1),a=r.cmp(n);return 0>a||1===i&&0===a?e.div:e.div.sign?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(67108863>=t);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+this.words[i])%t;return n},i.prototype.idivn=function(t){r(67108863>=t);for(var e=0,n=this.length-1;n>=0;n--){var i=this.words[n]+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=new i(0),l=new i(1),c=0;e.isEven()&&n.isEven();)e.ishrn(1),n.ishrn(1),++c;for(var u=n.clone(),f=e.clone();0!==e.cmpn(0);){for(;e.isEven();)e.ishrn(1),a.isEven()&&o.isEven()?(a.ishrn(1),o.ishrn(1)):(a.iadd(u).ishrn(1),o.isub(f).ishrn(1));for(;n.isEven();)n.ishrn(1),s.isEven()&&l.isEven()?(s.ishrn(1),l.ishrn(1)):(s.iadd(u).ishrn(1),l.isub(f).ishrn(1));e.cmp(n)>=0?(e.isub(n),a.isub(s),o.isub(l)):(n.isub(e),s.isub(a),l.isub(o))}return{a:s,b:l,gcd:n.ishln(c)}},i.prototype._invmp=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(;e.isEven();)e.ishrn(1),a.isEven()?a.ishrn(1):a.iadd(s).ishrn(1);for(;n.isEven();)n.ishrn(1),o.isEven()?o.ishrn(1):o.iadd(s).ishrn(1);e.cmp(n)>=0?(e.isub(n),a.isub(o)):(n.isub(e),o.isub(a))}return 0===e.cmpn(1)?a:o},i.prototype.gcd=function(t){if(0===this.cmpn(0))return t.clone();if(0===t.cmpn(0))return this.clone();var e=this.clone(),r=t.clone();e.sign=!1,r.sign=!1;for(var n=0;e.isEven()&&r.isEven();n++)e.ishrn(1),r.ishrn(1);for(;;){for(;e.isEven();)e.ishrn(1);for(;r.isEven();)r.ishrn(1);var i=e.cmp(r);if(0>i){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.ishln(n)},i.prototype.invm=function(t){return this.egcd(t).a.mod(t)},i.prototype.isEven=function(){return 0===(1&this.words[0])},i.prototype.isOdd=function(){return 1===(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<a;a++)this.words[a]=0;return this.words[n]|=i,this.length=n+1,this}for(var o=i,a=n;0!==o&&a>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.cmpn=function(t){var e=0>t;if(e&&(t=-t),this.sign&&!e)return-1;if(!this.sign&&e)return 1;t&=67108863,this.strip();var r;if(this.length>1)r=1;else{var n=this.words[0];r=n===t?0:t>n?-1:1}return this.sign&&(r=-r),r},i.prototype.cmp=function(t){if(this.sign&&!t.sign)return-1;if(!this.sign&&t.sign)return 1;var e=this.ucmp(t);return this.sign?-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length=0;r--){var n=this.words[r],i=t.words[r];if(n!==i){i>n?e=-1:n>i&&(e=1);break}}return e},i.red=function(t){return new h(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};s.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},s.prototype.ireduce=function(t){var e,r=t;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),e=r.bitLength();while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},s.prototype.split=function(t,e){t.ishrn(this.n,0,e)},s.prototype.imulK=function(t){return t.imul(this.k)},n(l,s),l.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;n>i;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var a=t.words[9];e.words[e.length++]=a&r;for(var i=10;i>>22,a=o}t.words[i-10]=a>>>22,t.length-=9},l.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e,r=0,n=0;n>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function y(t){if(m[t])return m[t];var y;if("k256"===t)y=new l;else if("p224"===t)y=new c;else if("p192"===t)y=new u;else{if("p25519"!==t)throw new Error("Unknown prime "+t);y=new f}return m[t]=y,y},h.prototype._verify1=function(t){r(!t.sign,"red works only with positives"),r(t.red,"red works only with red numbers")},h.prototype._verify2=function(t,e){r(!t.sign&&!e.sign,"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},h.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.mod(this.m)._forceRed(this)},h.prototype.neg=function(t){var e=t.clone();return e.sign=!e.sign,e.iadd(this.m)._forceRed(this)},h.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},h.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},h.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},h.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},h.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.shln(e))},h.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},h.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},h.prototype.isqr=function(t){return this.imul(t,t)},h.prototype.sqr=function(t){return this.mul(t,t)},h.prototype.sqrt=function(t){if(0===t.cmpn(0))return t.clone();var e=this.m.andln(3);if(r(e%2===1),3===e){var n=this.m.add(new i(1)).ishrn(2),a=this.pow(t,n);return a}for(var o=this.m.subn(1),s=0;0!==o.cmpn(0)&&0===o.andln(1);)s++,o.ishrn(1);r(0!==o.cmpn(0));var l=new i(1).toRed(this),c=l.redNeg(),u=this.m.subn(1).ishrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,o),a=this.pow(t,o.addn(1).ishrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(l);){for(var g=d,v=0;0!==g.cmp(l);v++)g=g.redSqr();r(p>v);var m=this.pow(h,new i(1).ishln(p-v-1));a=a.redMul(m),h=m.redSqr(),d=d.redMul(h),p=v}return a},h.prototype.invm=function(t){var e=t._invmp(this.m);return e.sign?(e.sign=!1,this.imod(e).redNeg()):this.imod(e)},h.prototype.pow=function(t,e){var r=[];if(0===e.cmpn(0))return new i(1);for(var n=e.clone();0!==n.cmpn(0);)r.push(n.andln(1)),n.ishrn(1);for(var a=t,o=0;o=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},d.prototype.mul=function(t,e){if(0===t.cmpn(0)||0===e.cmpn(0))return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).ishrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},d.prototype.invm=function(t){var e=this.imod(t._invmp(this.m).mul(this.r2));return e._forceRed(this)}}("undefined"==typeof e||e,this)},{}],264:[function(t,e,r){"use strict";function n(t){return i(t[0])*i(t[1])}var i=t("./lib/bn-sign");e.exports=n},{"./lib/bn-sign":255}],265:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":260}],266:[function(t,e,r){"use strict";function n(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var n=e.divmod(r),o=n.div,s=i(o),l=n.mod;if(0===l.cmpn(0))return s;if(s){var c=a(s)+4,u=i(l.shln(c).divRound(r));return 0>s&&(u=-u),s+u*Math.pow(2,-c)}var f=r.bitLength()-l.bitLength()+53,u=i(l.shln(f).divRound(r));return 1023>f?u*Math.pow(2,-f):(u*=Math.pow(2,-1023),u*Math.pow(2,1023-f))}var i=t("./lib/bn-to-num"),a=t("./lib/ctz");e.exports=n},{"./lib/bn-to-num":256,"./lib/ctz":257}],267:[function(t,e,r){"use strict";function n(t,e){for(var r=0;t>r;++r)if(!(e[r]<=e[r+t]))return!0;return!1}function i(t,e,r,i){for(var a=0,o=0,s=0,l=t.length;l>s;++s){var c=t[s];if(!n(e,c)){for(var u=0;2*e>u;++u)r[a++]=c[u];i[o++]=s}}return o}function a(t,e,r,n){var a=t.length,o=e.length;if(!(0>=a||0>=o)){var s=t[0].length>>>1;if(!(0>=s)){var l,c=f.mallocDouble(2*s*a),u=f.mallocInt32(a);if(a=i(t,s,c,u),a>0){if(1===s&&n)h.init(a),l=h.sweepComplete(s,r,0,a,c,u,0,a,c,u);else{var p=f.mallocDouble(2*s*o),g=f.mallocInt32(o);o=i(e,s,p,g),o>0&&(h.init(a+o),l=1===s?h.sweepBipartite(s,r,0,a,c,u,0,o,p,g):d(s,r,n,a,c,u,o,p,g),f.free(p),f.free(g))}f.free(c),f.free(u)}return l}}}function o(t,e){u.push([t,e])}function s(t){return u=[],a(t,t,o,!0),u}function l(t,e){return u=[],a(t,e,o,!1),u}function c(t,e,r){switch(arguments.length){case 1:return s(t);case 2:return"function"==typeof e?a(t,t,e,!0):l(t,e);case 3:return a(t,e,r,!1);default:throw new Error("box-intersect: Invalid arguments")}}e.exports=c;var u,f=t("typedarray-pool"),h=t("./lib/sweep"),d=t("./lib/intersect")},{"./lib/intersect":269,"./lib/sweep":273,"typedarray-pool":237}],268:[function(t,e,r){"use strict";function n(t,e,r){var n="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),i=["function ",n,"(",w.join(),"){","var ",c,"=2*",a,";"],l="for(var i="+u+","+p+"="+c+"*"+u+";i<"+f+";++i,"+p+"+="+c+"){var x0="+h+"["+o+"+"+p+"],x1="+h+"["+o+"+"+p+"+"+a+"],xi="+d+"[i];",k="for(var j="+g+","+b+"="+c+"*"+g+";j<"+v+";++j,"+b+"+="+c+"){var y0="+m+"["+o+"+"+b+"],"+(r?"y1="+m+"["+o+"+"+b+"+"+a+"],":"")+"yi="+y+"[j];";return t?i.push(l,_,":",k):i.push(k,_,":",l),r?i.push("if(y1"+v+"-"+g+"){"),t?(e(!0,!1),o.push("}else{"),e(!1,!1)):(o.push("if("+l+"){"),e(!0,!0),o.push("}else{"),e(!0,!1),o.push("}}else{if("+l+"){"),e(!1,!0),o.push("}else{"),e(!1,!1),o.push("}")),o.push("}}return "+r);var s=i.join("")+o.join(""),c=new Function(s);return c()}var a="d",o="ax",s="vv",l="fp",c="es",u="rs",f="re",h="rb",d="ri",p="rp",g="bs",v="be",m="bb",y="bi",b="bp",x="rv",_="Q",w=[a,o,s,u,f,h,d,g,v,m,y];r.partial=i(!1),r.full=i(!0)},{}],269:[function(t,e,r){"use strict";function n(t,e){var r=8*c.log2(e+1)*(t+1)|0,n=c.nextPow2(M*r);L.lengthS&&(l.free(S),S=l.mallocDouble(i))}function i(t,e,r,n,i,a,o,s,l){var c=M*t;L[c]=e,L[c+1]=r,L[c+2]=n,L[c+3]=i,L[c+4]=a,L[c+5]=o;var u=T*t;S[u]=s,S[u+1]=l}function a(t,e,r,n,i,a,o,s,l,c,u){var f=2*t,h=l*f,d=c[h+e];t:for(var p=i,g=i*f;a>p;++p,g+=f){var v=o[g+e],m=o[g+e+t];if(!(v>d||d>m||n&&d===v)){for(var y=s[p],b=e+1;t>b;++b){var v=o[g+b],m=o[g+b+t],x=c[h+b],_=c[h+b+t];if(x>m||v>_)continue t}var w;if(w=n?r(u,y):r(y,u),void 0!==w)return w}}}function o(t,e,r,n,i,a,o,s,l,c){var u=2*t,f=s*u,h=l[f+e];t:for(var d=n,p=n*u;i>d;++d,p+=u){var g=o[d];if(g!==c){var v=a[p+e],m=a[p+e+t];if(!(v>h||h>m)){for(var y=e+1;t>y;++y){var v=a[p+y],m=a[p+y+t],b=l[f+y],x=l[f+y+t];if(b>m||v>x)continue t}var _=r(g,c);if(void 0!==_)return _}}}}function s(t,e,r,s,l,c,u,g,E){n(t,s+u);var C,z=0,P=2*t;for(i(z++,0,0,s,0,u,r?16:0,-(1/0),1/0),r||i(z++,0,0,u,0,s,1,-(1/0),1/0);z>0;){z-=1;var R=z*M,O=L[R],I=L[R+1],N=L[R+2],j=L[R+3],F=L[R+4],D=L[R+5],B=z*T,U=S[B],V=S[B+1],q=1&D,H=!!(16&D),G=l,Y=c,X=g,W=E;if(q&&(G=g,Y=E,X=l,W=c),!(2&D&&(N=_(t,O,I,N,G,Y,V),I>=N)||4&D&&(I=w(t,O,I,N,G,Y,U),I>=N))){var Z=N-I,K=F-j;if(H){if(y>t*Z*(Z+K)){if(C=d.scanComplete(t,O,e,I,N,G,Y,j,F,X,W),void 0!==C)return C;continue}}else{if(t*Math.min(Z,K)t*Z*K){if(C=d.scanBipartite(t,O,e,q,I,N,G,Y,j,F,X,W),void 0!==C)return C;continue}}var $=b(t,O,I,N,G,Y,U,V);if($>I)if(v>t*($-I)){if(C=h(t,O+1,e,I,$,G,Y,j,F,X,W),void 0!==C)return C}else if(O===t-2){if(C=q?d.sweepBipartite(t,e,j,F,X,W,I,$,G,Y):d.sweepBipartite(t,e,I,$,G,Y,j,F,X,W),void 0!==C)return C}else i(z++,O+1,I,$,j,F,q,-(1/0),1/0),i(z++,O+1,j,F,I,$,1^q,-(1/0),1/0);if(N>$){var Q=p(t,O,j,F,X,W),J=X[P*Q+O],tt=x(t,O,Q,F,X,W,J);if(F>tt&&i(z++,O,$,N,tt,F,(4|q)+(H?16:0),J,V),Q>j&&i(z++,O,$,N,j,Q,(2|q)+(H?16:0),U,J),Q+1===tt){if(C=H?o(t,O,e,$,N,G,Y,Q,X,W[Q]):a(t,O,e,q,$,N,G,Y,Q,X,W[Q]),void 0!==C)return C}else if(tt>Q){var et;if(H){if(et=k(t,O,$,N,G,Y,J),et>$){var rt=x(t,O,$,et,G,Y,J);if(O===t-2){if(rt>$&&(C=d.sweepComplete(t,e,$,rt,G,Y,Q,tt,X,W),void 0!==C))return C;if(et>rt&&(C=d.sweepBipartite(t,e,rt,et,G,Y,Q,tt,X,W),void 0!==C))return C}else rt>$&&i(z++,O+1,$,rt,Q,tt,16,-(1/0),1/0),et>rt&&(i(z++,O+1,rt,et,Q,tt,0,-(1/0),1/0),i(z++,O+1,Q,tt,rt,et,1,-(1/0),1/0))}}else et=q?A(t,O,$,N,G,Y,J):k(t,O,$,N,G,Y,J),et>$&&(O===t-2?C=q?d.sweepBipartite(t,e,Q,tt,X,W,$,et,G,Y):d.sweepBipartite(t,e,$,et,G,Y,Q,tt,X,W):(i(z++,O+1,$,et,Q,tt,q,-(1/0),1/0),i(z++,O+1,Q,tt,$,et,1^q,-(1/0),1/0)))}}}}}e.exports=s;var l=t("typedarray-pool"),c=t("bit-twiddle"),u=t("./brute"),f=u.partial,h=u.full,d=t("./sweep"),p=t("./median"),g=t("./partition"),v=128,m=1<<22,y=1<<22,b=g("!(lo>=p0)&&!(p1>=hi)",["p0","p1"]),x=g("lo===p0",["p0"]),_=g("lol;++l,s+=o)for(var c=i[s],u=l,f=o*(l-1);u>r&&i[f+e]>c;--u,f-=o){for(var h=f,d=f+o,p=0;o>p;++p,++h,++d){var g=i[h];i[h]=i[d],i[d]=g}var v=a[u];a[u]=a[u-1],a[u-1]=v}}function i(t,e,r,i,a,l){if(r+1>=i)return r;for(var c=r,u=i,f=i+r>>>1,h=2*t,d=f,p=a[h*f+e];u>c;){if(s>u-c){n(t,e,c,u,a,l),p=a[h*f+e];break}var g=u-c,v=Math.random()*g+c|0,m=a[h*v+e],y=Math.random()*g+c|0,b=a[h*y+e],x=Math.random()*g+c|0,_=a[h*x+e];b>=m?_>=b?(d=y,p=b):m>=_?(d=v,p=m):(d=x,p=_):b>=_?(d=y,p=b):_>=m?(d=v,p=m):(d=x,p=_);for(var w=h*(u-1),k=h*d,A=0;h>A;++A,++w,++k){var M=a[w];a[w]=a[k],a[k]=M}var T=l[u-1];l[u-1]=l[d],l[d]=T,d=o(t,e,c,u-1,a,l,p);for(var w=h*(u-1),k=h*d,A=0;h>A;++A,++w,++k){var M=a[w];a[w]=a[k],a[k]=M}var T=l[u-1];if(l[u-1]=l[d],l[d]=T,d>f){for(u=d-1;u>c&&a[h*(u-1)+e]===p;)u-=1;u+=1}else{if(!(f>d))break;for(c=d+1;u>c&&a[h*c+e]===p;)c+=1}}return o(t,e,r,f,a,l,a[h*f+e])}e.exports=i;var a=t("./partition"),o=a("lo=0&&n.push("lo=e[k+n]"),t.indexOf("hi")>=0&&n.push("hi=e[k+o]"),r.push(i.replace("_",n.join()).replace("$",t)),Function.apply(void 0,r)}e.exports=n;var i="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 _;if($)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"},{}],272:[function(t,e,r){"use strict";function n(t,e){4*h>=e?i(0,e-1,t):f(0,e-1,t)}function i(t,e,r){for(var n=2*(t+1),i=t+1;e>=i;++i){for(var a=r[n++],o=r[n++],s=i,l=n-2;s-- >t;){var c=r[l-2],u=r[l-1];if(a>c)break;if(c===a&&o>u)break;r[l]=c,r[l+1]=u,l-=2}r[l]=a,r[l+1]=o}}function a(t,e,r){t*=2,e*=2;var n=r[t],i=r[t+1];r[t]=r[e],r[t+1]=r[e+1],r[e]=n,r[e+1]=i}function o(t,e,r){t*=2,e*=2,r[t]=r[e],r[t+1]=r[e+1]}function s(t,e,r,n){t*=2,e*=2,r*=2;var i=n[t],a=n[t+1];n[t]=n[e],n[t+1]=n[e+1],n[e]=n[r],n[e+1]=n[r+1],n[r]=i,n[r+1]=a}function l(t,e,r,n,i){t*=2,e*=2,i[t]=i[e],i[e]=r,i[t+1]=i[e+1],i[e+1]=n}function c(t,e,r){t*=2,e*=2;var n=r[t],i=r[e];return i>n?!1:n===i?r[t+1]>r[e+1]:!0}function u(t,e,r,n){t*=2;var i=n[t];return e>i?!0:i===e?n[t+1]>1,v=g-n,m=g+n,y=d,b=v,x=g,_=m,w=p,k=t+1,A=e-1,M=0;c(y,b,r)&&(M=y,y=b,b=M),c(_,w,r)&&(M=_,_=w,w=M),c(y,x,r)&&(M=y,y=x,x=M),c(b,x,r)&&(M=b,b=x,x=M),c(y,_,r)&&(M=y,y=_,_=M),c(x,_,r)&&(M=x,x=_,_=M),c(b,w,r)&&(M=b,b=w,w=M),c(b,x,r)&&(M=b,b=x,x=M),c(_,w,r)&&(M=_,_=w,w=M);for(var T=r[2*b],E=r[2*b+1],L=r[2*_],S=r[2*_+1],C=2*y,z=2*x,P=2*w,R=2*d,O=2*g,I=2*p,N=0;2>N;++N){var j=r[C+N],F=r[z+N],D=r[P+N];r[R+N]=j,r[O+N]=F,r[I+N]=D}o(v,t,r),o(m,e,r);for(var B=k;A>=B;++B)if(u(B,T,E,r))B!==k&&a(B,k,r),++k;else if(!u(B,L,S,r))for(;;){if(u(A,L,S,r)){u(A,T,E,r)?(s(B,k,A,r),++k,--A):(a(B,A,r),--A);break}if(--A=k-2-t?i(t,k-2,r):f(t,k-2,r),h>=e-(A+2)?i(A+2,e,r):f(A+2,e,r),h>=A-k?i(k,A,r):f(k,A,r)}e.exports=n;var h=32},{}],273:[function(t,e,r){"use strict";function n(t){var e=f.nextPow2(t);g.lengthk;++k){var A=s[k],M=b*k;_[p++]=o[M+x],_[p++]=-(A+1),_[p++]=o[M+w],_[p++]=A}for(var k=l;c>k;++k){var A=f[k]+d,T=b*k;_[p++]=u[T+x],_[p++]=-A,_[p++]=u[T+w],_[p++]=A}var E=p>>>1;h(_,E);for(var L=0,S=0,k=0;E>k;++k){var C=0|_[2*k+1];if(C>=d)C=C-d|0,i(m,y,S--,C);else if(C>=0)i(g,v,L--,C);else if(-d>=C){C=-C-d|0;for(var z=0;L>z;++z){var P=e(g[z],C);if(void 0!==P)return P}a(m,y,S++,C); -}else{C=-C-1|0;for(var z=0;S>z;++z){var P=e(C,m[z]);if(void 0!==P)return P}a(g,v,L++,C)}}}function s(t,e,r,n,o,s,l,c,u,f){for(var d=0,p=2*t,w=t-1,k=p-1,A=r;n>A;++A){var M=s[A]+1<<1,T=p*A;_[d++]=o[T+w],_[d++]=-M,_[d++]=o[T+k],_[d++]=M}for(var A=l;c>A;++A){var M=f[A]+1<<1,E=p*A;_[d++]=u[E+w],_[d++]=1|-M,_[d++]=u[E+k],_[d++]=1|M}var L=d>>>1;h(_,L);for(var S=0,C=0,z=0,A=0;L>A;++A){var P=0|_[2*A+1],R=1&P;if(L-1>A&&P>>1===_[2*A+3]>>1&&(R=2,A+=1),0>P){for(var O=-(P>>1)-1,I=0;z>I;++I){var N=e(b[I],O);if(void 0!==N)return N}if(0!==R)for(var I=0;S>I;++I){var N=e(g[I],O);if(void 0!==N)return N}if(1!==R)for(var I=0;C>I;++I){var N=e(m[I],O);if(void 0!==N)return N}0===R?a(g,v,S++,O):1===R?a(m,y,C++,O):2===R&&a(b,x,z++,O)}else{var O=(P>>1)-1;0===R?i(g,v,S--,O):1===R?i(m,y,C--,O):2===R&&i(b,x,z--,O)}}}function l(t,e,r,n,o,s,l,c,u,f,p,m){var y=0,b=2*t,x=e,w=e+t,k=1,A=1;n?A=d:k=d;for(var M=o;s>M;++M){var T=M+k,E=b*M;_[y++]=l[E+x],_[y++]=-T,_[y++]=l[E+w],_[y++]=T}for(var M=u;f>M;++M){var T=M+A,L=b*M;_[y++]=p[L+x],_[y++]=-T}var S=y>>>1;h(_,S);for(var C=0,M=0;S>M;++M){var z=0|_[2*M+1];if(0>z){var T=-z,P=!1;if(T>=d?(P=!n,T-=d):(P=!!n,T-=1),P)a(g,v,C++,T);else{var R=m[T],O=b*T,I=p[O+e+1],N=p[O+e+1+t];t:for(var j=0;C>j;++j){var F=g[j],D=b*F;if(!(NB;++B)if(p[O+B+t]y;++y){var b=y+d,x=p*y;_[f++]=a[x+v],_[f++]=-b,_[f++]=a[x+m],_[f++]=b}for(var y=s;l>y;++y){var b=y+1,w=p*y;_[f++]=c[w+v],_[f++]=-b}var k=f>>>1;h(_,k);for(var A=0,y=0;k>y;++y){var M=0|_[2*y+1];if(0>M){var b=-M;if(b>=d)g[A++]=b-d;else{b-=1;var T=u[b],E=p*b,L=c[E+e+1],S=c[E+e+1+t];t:for(var C=0;A>C;++C){var z=g[C],P=o[z];if(P===T)break;var R=p*z;if(!(SO;++O)if(c[E+O+t]=0;--C)if(g[C]===b){for(var O=C+1;A>O;++O)g[O-1]=g[O];break}--A}}}e.exports={init:n,sweepBipartite:o,sweepComplete:s,scanBipartite:l,scanComplete:c};var u=t("typedarray-pool"),f=t("bit-twiddle"),h=t("./sort"),d=1<<28,p=1024,g=u.mallocInt32(p),v=u.mallocInt32(p),m=u.mallocInt32(p),y=u.mallocInt32(p),b=u.mallocInt32(p),x=u.mallocInt32(p),_=u.mallocDouble(8*p)},{"./sort":272,"bit-twiddle":50,"typedarray-pool":237}],274:[function(t,e,r){(function(t){function r(t,e){return d[0]=t,d[1]=e,h[0]}function n(t){return h[0]=t,d[0]}function i(t){return h[0]=t,d[1]}function a(t,e){return d[1]=t,d[0]=e,h[0]}function o(t){return h[0]=t,d[1]}function s(t){return h[0]=t,d[0]}function l(t,e){return p.writeUInt32LE(t,0,!0),p.writeUInt32LE(e,4,!0),p.readDoubleLE(0,!0)}function c(t){return p.writeDoubleLE(t,0,!0),p.readUInt32LE(0,!0)}function u(t){return p.writeDoubleLE(t,0,!0),p.readUInt32LE(4,!0)}var f=!1;if("undefined"!=typeof Float64Array){var h=new Float64Array(1),d=new Uint32Array(h.buffer);h[0]=1,f=!0,1072693248===d[1]?(e.exports=function(t){return h[0]=t,[d[0],d[1]]},e.exports.pack=r,e.exports.lo=n,e.exports.hi=i):1072693248===d[0]?(e.exports=function(t){return h[0]=t,[d[1],d[0]]},e.exports.pack=a,e.exports.lo=o,e.exports.hi=s):f=!1}if(!f){var p=new t(8);e.exports=function(t){return p.writeDoubleLE(t,0,!0),[p.readUInt32LE(0,!0),p.readUInt32LE(4,!0)]},e.exports.pack=l,e.exports.lo=c,e.exports.hi=u}e.exports.sign=function(t){return e.exports.hi(t)>>>31},e.exports.exponent=function(t){var r=e.exports.hi(t);return(r<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){var r=e.exports.hi(t);return!(2146435072&r)}}).call(this,t("buffer").Buffer)},{buffer:51}],275:[function(t,e,r){"use strict";function n(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return 0>e?-a:a;var r=i.hi(t),n=i.lo(t);return e>t==t>0?n===o?(r+=1,n=0):n+=1:0===n?(n=o,r-=1):n-=1,i.pack(n,r)}var i=t("double-bits"),a=Math.pow(2,-1074),o=-1>>>0;e.exports=n},{"double-bits":274}],276:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),a=0;r>a;++a)n[a]=i(t[a],e[a]);return n}var i=t("big-rat/add");e.exports=n},{"big-rat/add":250}],277:[function(t,e,r){"use strict";function n(t){for(var e=new Array(t.length),r=0;rs;++s)o[s]=a(t[s],r);return o}var i=t("big-rat"),a=t("big-rat/mul");e.exports=n},{"big-rat":253,"big-rat/mul":262}],279:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),a=0;r>a;++a)n[a]=i(t[a],e[a]);return n}var i=t("big-rat/sub");e.exports=n},{"big-rat/sub":265}],280:[function(t,e,r){"use strict";function n(t,e,r,n){for(var i=0;2>i;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),c=r[i],u=n[i],f=Math.min(c,u),h=Math.max(c,u);if(s>h||f>l)return!1}return!0}function i(t,e,r,i){var o=a(t,r,i),s=a(e,r,i);if(o>0&&s>0||0>o&&0>s)return!1;var l=a(r,t,e),c=a(i,t,e);return l>0&&c>0||0>l&&0>c?!1:0===o&&0===s&&0===l&&0===c?n(t,e,r,i):!0}e.exports=i;var a=t("robust-orientation")[3]},{"robust-orientation":218}],281:[function(t,e,r){arguments[4][196][0].apply(r,arguments)},{dup:196}],282:[function(t,e,r){"use strict";function n(t,e){for(var r=i(t,e.length),n=new Array(e.length),a=new Array(e.length),o=[],s=0;s=l&&o.push(s)}for(;o.length>0;){var c=o.pop();n[c]=!1;for(var u=r[c],s=0;sn;++n){var a=t[n];e=Math.max(e,a[0],a[1])}e=(0|e)+1}e=0|e;for(var o=new Array(e),n=0;e>n;++n)o[n]=[];for(var n=0;r>n;++n){var a=t[n];o[a[0]].push(a[1]),o[a[1]].push(a[0])}for(var s=0;e>s;++s)i(o[s],function(t,e){return t-e});return o}e.exports=n;var i=t("uniq")},{uniq:238}],284:[function(t,e,r){"use strict";function n(t,e){function r(t,e){var r=c[e][t[e]];r.splice(r.indexOf(t),1)}function n(t,n,a){for(var o,s,l,u=0;2>u;++u)if(c[u][n].length>0){o=c[u][n][0],l=u;break}s=o[1^l];for(var f=0;2>f;++f)for(var h=c[f][n],d=0;d0&&(o=p,s=g,l=f)}return a?s:(o&&r(o,l),s)}function a(t,a){var o=c[a][t][0],s=[t];r(o,a);for(var l=o[1^a];;){for(;l!==t;)s.push(l),l=n(s[s.length-2],l,!1);if(c[0][t].length+c[1][t].length===0)break;var u=s[s.length-1],f=t,h=s[1],d=n(u,f,!0);if(i(e[u],e[f],e[h],e[d])<0)break;s.push(t),l=n(u,f)}return s}function o(t,e){return e[1]===e[e.length-1]}for(var s=0|e.length,l=t.length,c=[new Array(s),new Array(s)],u=0;s>u;++u)c[0][u]=[],c[1][u]=[];for(var u=0;l>u;++u){var f=t[u];c[0][f[0]].push(f),c[1][f[1]].push(f)}for(var h=[],u=0;s>u;++u)c[0][u].length+c[1][u].length===0&&h.push([u]);for(var u=0;s>u;++u)for(var d=0;2>d;++d){for(var p=[];c[d][u].length>0;){var g=(c[0][u].length,a(u,d));o(p,g)?p.push.apply(p,g):(p.length>0&&h.push(p),p=g)}p.length>0&&h.push(p)}return h}e.exports=n;var i=t("compare-angle")},{"compare-angle":285}],285:[function(t,e,r){"use strict";function n(t,e,r){var n=s(t[0],-e[0]),i=s(t[1],-e[1]),a=s(r[0],-e[0]),o=s(r[1],-e[1]),u=c(l(n,a),l(i,o));return u[u.length-1]>=0}function i(t,e,r,i){var s=a(e,r,i);if(0===s){var l=o(a(t,e,r)),c=o(a(t,e,i));if(l===c){if(0===l){var u=n(t,e,r),f=n(t,e,i);return u===f?0:u?1:-1}return 0}return 0===c?l>0?-1:n(t,e,i)?-1:1:0===l?c>0?1:n(t,e,r)?1:-1:o(c-l)}var h=a(t,e,r);if(h>0)return s>0&&a(t,e,i)>0?1:-1;if(0>h)return s>0||a(t,e,i)>0?1:-1;var d=a(t,e,i);return d>0?1:n(t,e,r)?1:-1}e.exports=i;var a=t("robust-orientation"),o=t("signum"),s=t("two-sum"),l=t("robust-product"),c=t("robust-sum")},{"robust-orientation":218,"robust-product":286,"robust-sum":221,signum:287,"two-sum":236}],286:[function(t,e,r){"use strict";function n(t,e){if(1===t.length)return a(e,t[0]);if(1===e.length)return a(t,e[0]);if(0===t.length||0===e.length)return[0];var r=[0];if(t.lengtht?-1:t>0?1:0}},{}],288:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],289:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}function i(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function a(t,e){var r=p(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function o(t,e){var r=t.intervals([]);r.push(e),a(t,r)}function s(t,e){var r=t.intervals([]),n=r.indexOf(e);return 0>n?y:(r.splice(n,1),a(t,r),b)}function l(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function u(t,e){for(var r=0;r>1],a=[],o=[],s=[],r=0;r3*(e+1)?o(this,t):this.left.insert(t):this.left=p([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?o(this,t):this.right.insert(t):this.right=p([t]);else{var r=m.ge(this.leftPoints,t,h),n=m.ge(this.rightPoints,t,d);this.leftPoints.splice(r,0,t),this.rightPoints.splice(n,0,t)}},_.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1))return s(this,t);var n=this.left.remove(t);return n===x?(this.left=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(t[0]>this.mid){if(!this.right)return y;var a=this.left?this.left.count:0;if(4*a>3*(e-1))return s(this,t);var n=this.right.remove(t);return n===x?(this.right=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(1===this.count)return this.leftPoints[0]===t?x:y;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var o=this,l=this.left;l.right;)o=l,l=l.right;if(o===this)l.right=this.right;else{var c=this.left,n=this.right;o.count-=l.count,o.right=l.left,l.left=c,l.right=n}i(this,l),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?i(this,this.left):i(this,this.right);return b}for(var c=m.ge(this.leftPoints,t,h);cthis.mid){if(this.right){var r=this.right.queryPoint(t,e);if(r)return r}return c(this.rightPoints,t,e)}return u(this.leftPoints,e)},_.queryInterval=function(t,e,r){if(tthis.mid&&this.right){var n=this.right.queryInterval(t,e,r);if(n)return n}return ethis.mid?c(this.rightPoints,t,r):u(this.leftPoints,r)};var w=g.prototype;w.insert=function(t){this.root?this.root.insert(t):this.root=new n(t[0],null,null,[t],[t])},w.remove=function(t){if(this.root){var e=this.root.remove(t);return e===x&&(this.root=null),e!==y}return!1},w.queryPoint=function(t,e){return this.root?this.root.queryPoint(t,e):void 0},w.queryInterval=function(t,e,r){return e>=t&&this.root?this.root.queryInterval(t,e,r):void 0},Object.defineProperty(w,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(w,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":288}],290:[function(t,e,r){"use strict";function n(t,e){var r,n;if(e[0][0]e[1][0])){var i=Math.min(t[0][1],t[1][1]),o=Math.max(t[0][1],t[1][1]),s=Math.min(e[0][1],e[1][1]),l=Math.max(e[0][1],e[1][1]);return s>o?o-s:i>l?i-l:o-l}r=e[1],n=e[0]}var c,u;t[0][1]e[1][0]))return n(e,t);r=e[1],i=e[0]}var o,s;if(t[0][0]t[1][0]))return-n(t,e);o=t[1],s=t[0]}var l=a(r,i,s),c=a(r,i,o);if(0>l){if(0>=c)return l}else if(l>0){if(c>=0)return l}else if(c)return c;if(l=a(s,o,i),c=a(s,o,r),0>l){if(0>=c)return l}else if(l>0){if(c>=0)return l}else if(c)return c;return i[0]-s[0]}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":218}],291:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function i(t){return new n(t._color,t.key,t.value,t.left,t.right,t._count)}function a(t,e){return new n(t,e.key,e.value,e.left,e.right,e._count)}function o(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function s(t,e){this._compare=t,this.root=e}function l(t,e){if(e.left){var r=l(t,e.left);if(r)return r}var r=t(e.key,e.value);return r?r:e.right?l(t,e.right):void 0}function c(t,e,r,n){var i=e(t,n.key);if(0>=i){if(n.left){var a=c(t,e,r,n.left);if(a)return a}var a=r(n.key,n.value);if(a)return a}return n.right?c(t,e,r,n.right):void 0}function u(t,e,r,n,i){var a,o=r(t,i.key),s=r(e,i.key);if(0>=o){if(i.left&&(a=u(t,e,r,n,i.left)))return a;if(s>0&&(a=n(i.key,i.value)))return a}return s>0&&i.right?u(t,e,r,n,i.right):void 0}function f(t,e){this.tree=t,this._stack=e}function h(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function d(t){for(var e,r,n,s,l=t.length-1;l>=0;--l){if(e=t[l],0===l)return void(e._color=m);if(r=t[l-1],r.left===e){if(n=r.right,n.right&&n.right._color===v){if(n=r.right=i(n),s=n.right=i(n.right),r.right=n.left,n.left=r,n.right=s,n._color=r._color,e._color=m,r._color=m,s._color=m,o(r),o(n),l>1){var c=t[l-2];c.left===r?c.left=n:c.right=n}return void(t[l-1]=n)}if(n.left&&n.left._color===v){if(n=r.right=i(n),s=n.left=i(n.left),r.right=s.left,n.left=s.right,s.left=r,s.right=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var c=t[l-2];c.left===r?c.left=s:c.right=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.right=a(v,n));r.right=a(v,n);continue}if(n=i(n),r.right=n.left,n.left=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var c=t[l-2];c.left===r?c.left=n:c.right=n}t[l-1]=n,t[l]=r,l+11){var c=t[l-2];c.right===r?c.right=n:c.left=n}return void(t[l-1]=n)}if(n.right&&n.right._color===v){if(n=r.left=i(n),s=n.right=i(n.right),r.left=s.right,n.right=s.left,s.right=r,s.left=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var c=t[l-2];c.right===r?c.right=s:c.left=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.left=a(v,n));r.left=a(v,n);continue}if(n=i(n),r.left=n.right,n.right=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var c=t[l-2];c.right===r?c.right=n:c.left=n}t[l-1]=n,t[l]=r,l+1t?-1:t>e?1:0}function g(t){return new s(t||p,null)}e.exports=g;var v=0,m=1,y=s.prototype;Object.defineProperty(y,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(y,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(y,"length",{get:function(){return this.root?this.root._count:0}}),y.insert=function(t,e){for(var r=this._compare,i=this.root,l=[],c=[];i;){var u=r(t,i.key);l.push(i),c.push(u),i=0>=u?i.left:i.right}l.push(new n(v,t,e,null,null,1));for(var f=l.length-2;f>=0;--f){var i=l[f];c[f]<=0?l[f]=new n(i._color,i.key,i.value,l[f+1],i.right,i._count+1):l[f]=new n(i._color,i.key,i.value,i.left,l[f+1],i._count+1)}for(var f=l.length-1;f>1;--f){var h=l[f-1],i=l[f];if(h._color===m||i._color===m)break;var d=l[f-2];if(d.left===h)if(h.left===i){var p=d.right;if(!p||p._color!==v){if(d._color=v,d.left=h.right,h._color=m,h.right=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.left===d?g.left=h:g.right=h}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else{var p=d.right;if(!p||p._color!==v){if(h.right=i.left,d._color=v,d.left=i.right,i._color=m,i.left=h,i.right=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.left===d?g.left=i:g.right=i}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else if(h.right===i){var p=d.left;if(!p||p._color!==v){if(d._color=v,d.right=h.left,h._color=m,h.left=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.right===d?g.right=h:g.left=h}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}else{var p=d.left;if(!p||p._color!==v){if(h.left=i.right,d._color=v,d.right=i.left,i._color=m,i.right=h,i.left=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.right===d?g.right=i:g.left=i}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}}return l[0]._color=m,new s(r,l[0])},y.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return l(t,this.root);case 2:return c(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return u(e,r,this._compare,t,this.root)}},Object.defineProperty(y,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(y,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),y.at=function(t){if(0>t)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},y.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>=a&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>a&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new f(this,n);r=0>=i?r.left:r.right}return new f(this,[])},y.remove=function(t){var e=this.find(t);return e?e.remove():this},y.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=0>=n?r.left:r.right}};var b=f.prototype;Object.defineProperty(b,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(b,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),b.clone=function(){return new f(this.tree,this._stack.slice())},b.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new n(r._color,r.key,r.value,r.left,r.right,r._count);for(var i=t.length-2;i>=0;--i){var r=t[i];r.left===t[i+1]?e[i]=new n(r._color,r.key,r.value,e[i+1],r.right,r._count):e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count)}if(r=e[e.length-1],r.left&&r.right){var a=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var o=e[a-1];e.push(new n(r._color,o.key,o.value,r.left,r.right,r._count)),e[a-1].key=r.key,e[a-1].value=r.value;for(var i=e.length-2;i>=a;--i)r=e[i],e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count);e[a-1].left=e[a]}if(r=e[e.length-1],r._color===v){var l=e[e.length-2];l.left===r?l.left=null:l.right===r&&(l.right=null),e.pop();for(var i=0;i0?this._stack[this._stack.length-1].key:void 0},enumerable:!0}),Object.defineProperty(b,"value",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1].value:void 0},enumerable:!0}),Object.defineProperty(b,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),b.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),b.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),i=e[e.length-1];r[r.length-1]=new n(i._color,i.key,t,i.left,i.right,i._count);for(var a=e.length-2;a>=0;--a)i=e[a],i.left===e[a+1]?r[a]=new n(i._color,i.key,i.value,r[a+1],i.right,i._count):r[a]=new n(i._color,i.key,i.value,i.left,r[a+1],i._count);return new s(this.tree._compare,r[0])},b.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],292:[function(t,e,r){"use strict";function n(t,e,r){this.slabs=t,this.coordinates=e,this.horizontal=r}function i(t,e){return t.y-e}function a(t,e){for(var r=null;t;){var n,i,o=t.key;o[0][0]s)t=t.left;else if(s>0)if(e[0]!==o[1][0])r=t,t=t.right;else{var l=a(t.right,e);if(l)return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l=a(t.right,e);if(l)return l;t=t.left}}return r}function o(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function s(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}function l(t){for(var e=t.length,r=2*e,i=new Array(r),a=0;e>a;++a){var l=t[a],c=l[0][0]a;){for(var v=i[a].x,m=[];r>a;){var y=i[a];if(y.x!==v)break;a+=1,y.segment[0][0]===y.x&&y.segment[1][0]===y.x?y.create&&(y.segment[0][1]e)return-1;var r=(this.slabs[e],a(this.slabs[e],t)),n=-1;if(r&&(n=r.value),this.coordinates[e]===t[0]){var o=null;if(r&&(o=r.key),e>0){var s=a(this.slabs[e-1],t);s&&(o?h(s.key,o)>0&&(o=s.key,n=s.value):(n=s.value,o=s.key))}var l=this.horizontal[e];if(l.length>0){var u=c.ge(l,t[1],i);if(u=l.length)return n;d=l[u]}}if(d.start)if(o){var p=f(o[0],o[1],[t[0],d.y]);o[0][0]>o[1][0]&&(p=-p),p>0&&(n=d.index)}else n=d.index;else d.y!==t[1]&&(n=d.index)}}}return n}},{"./lib/order-segments":290,"binary-search-bounds":288,"functional-red-black-tree":291,"robust-orientation":218}],293:[function(t,e,r){function n(){return!0}function i(t){return function(e,r){var i=t[e];return i?!!i.queryPoint(r,n):!1}}function a(t){for(var e={},r=0;rn)return 1;var i=t[n];if(!i){if(!(n>0&&e[n]===r[0]))return 1;i=t[n-1]}for(var a=1;i;){var o=i.key,s=f(r,o[0],o[1]);if(o[0][0]s)i=i.left;else{if(!(s>0))return 0;a=-1,i=i.right}else if(s>0)i=i.left;else{if(!(0>s))return 0;a=1,i=i.right}}return a}}function s(t){return 1}function l(t){return function(e){return t(e[0],e[1])?0:1}}function c(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}function u(t){for(var e=t.length,r=[],n=[],i=0;e>i;++i)for(var u=t[i],f=u.length,d=f-1,p=0;f>p;d=p++){var g=u[d],v=u[p];g[0]===v[0]?n.push([g,v]):r.push([g,v])}if(0===r.length)return 0===n.length?s:l(a(n));var m=h(r),y=o(m.slabs,m.coordinates);return 0===n.length?y:c(a(n),y)}e.exports=u;var f=t("robust-orientation")[3],h=t("slab-decomposition"),d=t("interval-tree-1d"),p=t("binary-search-bounds")},{"binary-search-bounds":288,"interval-tree-1d":289,"robust-orientation":218,"slab-decomposition":292}],294:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function i(t){for(var e=new Array(t),r=0;t>r;++r)e[r]=[];return e}function a(t,e){function r(t){for(var r=t.length,n=[0],i=0;r>i;++i){var a=e[t[i]],o=e[t[(i+1)%r]],s=c(-a[0],a[1]),l=c(-a[0],o[1]),f=c(o[0],a[1]),h=c(o[0],o[1]);n=u(n,u(u(s,l),u(f,h)))}return n[n.length-1]>0}function a(t){for(var e=t.length,r=0;e>r;++r)if(!O[t[r]])return!1;return!0}var d=h(t,e);t=d[0],e=d[1];for(var p=e.length,g=(t.length,o(t,e.length)),v=0;p>v;++v)if(g[v].length%2===1)throw new Error("planar-graph-to-polyline: graph must be manifold");var m=s(t,e);m=m.filter(r);for(var y=m.length,b=new Array(y),x=new Array(y),v=0;y>v;++v){b[v]=v;var _=new Array(y),w=m[v].map(function(t){return e[t]}),k=l([w]),A=0;t:for(var M=0;y>M;++M)if(_[M]=0,v!==M){for(var T=m[M],E=T.length,L=0;E>L;++L){var S=k(e[T[L]]);if(0!==S){0>S&&(_[M]=1,A+=1);continue t}}_[M]=1,A+=1}x[v]=[A,v,_]}x.sort(function(t,e){return e[0]-t[0]});for(var v=0;y>v;++v)for(var _=x[v],C=_[1],z=_[2],M=0;y>M;++M)z[M]&&(b[M]=C);for(var P=i(y),v=0;y>v;++v)P[v].push(b[v]),P[b[v]].push(v);for(var R={},O=n(p,!1),v=0;y>v;++v)for(var T=m[v],E=T.length,M=0;E>M;++M){var I=T[M],N=T[(M+1)%E],j=Math.min(I,N)+":"+Math.max(I,N);if(j in R){var F=R[j];P[F].push(v),P[v].push(F),O[I]=O[N]=!0}else R[j]=v}for(var D=[],B=n(y,-1),v=0;y>v;++v)b[v]!==v||a(m[v])?B[v]=-1:(D.push(v),B[v]=0);for(var d=[];D.length>0;){var U=D.pop(),V=P[U];f(V,function(t,e){return t-e});var q,H=V.length,G=B[U];if(0===G){var T=m[U];q=[T]}for(var v=0;H>v;++v){var Y=V[v];if(!(B[Y]>=0)&&(B[Y]=1^G,D.push(Y),0===G)){var T=m[Y];a(T)||(T.reverse(),q.push(T))}}0===G&&d.push(q)}return d}e.exports=a;var o=t("edges-to-adjacency-list"),s=t("planar-dual"),l=t("point-in-big-polygon"),c=t("two-product"),u=t("robust-sum"),f=t("uniq"),h=t("./lib/trim-leaves")},{"./lib/trim-leaves":282,"edges-to-adjacency-list":283,"planar-dual":284,"point-in-big-polygon":293,"robust-sum":221,"two-product":235,uniq:238}],295:[function(t,e,r){arguments[4][50][0].apply(r,arguments)},{dup:50}],296:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;t>e;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n,n.prototype.length=function(){return this.roots.length},n.prototype.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},n.prototype.find=function(t){for(var e=this.roots;e[t]!==t;){var r=e[t];e[t]=e[r],t=r}return t},n.prototype.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],297:[function(t,e,r){arguments[4][197][0].apply(r,arguments)},{"bit-twiddle":295,dup:197,"union-find":296}],298:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.abs(a(t,e,r)),i=Math.sqrt(Math.pow(e[0]-r[0],2)+Math.pow(e[1]-r[1],2));return n/i}function i(t,e,r){function i(t){if(x[t])return 1/0;var r=m[t],i=y[t];return 0>r||0>i?1/0:n(e[t],e[r],e[i])}function a(t,e){var r=M[t],n=M[e];M[t]=n,M[e]=r,T[r]=e,T[n]=t}function s(t){return b[M[t]]}function l(t){return 1&t?t-1>>1:(t>>1)-1}function c(t){for(var e=s(t);;){var r=e,n=2*t+1,i=2*(t+1),o=t;if(L>n){var l=s(n);r>l&&(o=n,r=l)}if(L>i){var c=s(i);r>c&&(o=i)}if(o===t)return t;a(t,o),t=o}}function u(t){for(var e=s(t);t>0;){var r=l(t);if(r>=0){var n=s(r);if(n>e){a(t,r),t=r;continue}}return t}}function f(){if(L>0){var t=M[0];return a(0,L-1),L-=1,c(0),t}return-1}function h(t,e){var r=M[t];return b[r]===e?t:(b[r]=-(1/0),u(t),f(),b[r]=e,L+=1,u(L-1))}function d(t){if(!x[t]){x[t]=!0;var e=m[t],r=y[t];m[r]>=0&&(m[r]=e),y[e]>=0&&(y[e]=r),T[e]>=0&&h(T[e],i(e)),T[r]>=0&&h(T[r],i(r))}}function p(t,e){if(t[e]<0)return e;var r=e,n=e;do{var i=t[n];if(!x[n]||0>i||i===n)break;if(n=i,i=t[n],!x[n]||0>i||i===n)break;n=i,r=t[r]}while(r!==n);for(var a=e;a!==n;a=t[a])t[a]=n;return n}for(var g=e.length,v=t.length,m=new Array(g),y=new Array(g),b=new Array(g),x=new Array(g),_=0;g>_;++_)m[_]=y[_]=-1,b[_]=1/0,x[_]=!1;for(var _=0;v>_;++_){var w=t[_];if(2!==w.length)throw new Error("Input must be a graph");var k=w[1],A=w[0];-1!==y[A]?y[A]=-2:y[A]=k,-1!==m[k]?m[k]=-2:m[k]=A}for(var M=[],T=new Array(g),_=0;g>_;++_){var E=b[_]=i(_);1/0>E?(T[_]=M.length,M.push(_)):T[_]=-1}for(var L=M.length,_=L>>1;_>=0;--_)c(_);for(;;){var S=f();if(0>S||b[S]>r)break;d(S)}for(var C=[],_=0;g>_;++_)x[_]||(T[_]=C.length,C.push(e[_].slice()));var z=(C.length,[]);return t.forEach(function(t){var e=p(m,t[0]),r=p(y,t[1]);if(e>=0&&r>=0&&e!==r){var n=T[e],i=T[r];n!==i&&z.push([n,i])}}),o.unique(o.normalize(z)),{positions:C,edges:z}}e.exports=i;var a=t("robust-orientation"),o=t("simplicial-complex")},{"robust-orientation":218,"simplicial-complex":297}],299:[function(t,e,r){"use strict";e.exports=["",{ -path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],300:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:o({},i,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":376,"../../plots/cartesian/constants":408,"../../plots/font_attributes":421,"./arrow_paths":299}],301:[function(t,e,r){"use strict";function n(t,e){function r(e,r){return c.coerce(t,n,v.layoutAttributes,e,r)}var n={};r("opacity"),r("align"),r("bgcolor");var i=r("bordercolor"),a=f.opacity(i);r("borderpad");var o=r("borderwidth"),s=r("showarrow");s&&(r("arrowcolor",a?n.bordercolor:f.defaultLine),r("arrowhead"),r("arrowsize"),r("arrowwidth",2*(a&&o||1)),r("ax"),r("ay"),c.noneOrAll(t,n,["ax","ay"])),r("text",s?" ":"new text"),r("textangle"),c.coerceFont(r,"font",e.font);for(var l=["x","y"],h=0;2>h;h++){var d=l[h],p={_fullLayout:e},g=u.coerceRef(t,n,p,d),m=.5;if("paper"!==g){var y=u.getFromId(p,g);if(m=y.range[0]+m*(y.range[1]-y.range[0]),-1!==["date","category"].indexOf(y.type)&&"string"==typeof t[d]){var b;"date"===y.type?(b=c.dateTime2ms(t[d]),b!==!1&&(t[d]=b)):(y._categories||[]).length&&(b=y._categories.indexOf(t[d]),-1!==b&&(t[d]=b))}}r(d,m),s||r(d+"anchor")}return c.noneOrAll(t,n,["x","y"]),n}function i(t){var e=t._fullLayout;e.annotations.forEach(function(e){var r=u.getFromId(t,e.xref),n=u.getFromId(t,e.yref);if(r||n){var i=(e._xsize||0)/2,a=e._xshift||0,o=(e._ysize||0)/2,s=e._yshift||0,l=i-a,c=i+a,f=o-s,h=o+s;if(e.showarrow){var d=3*e.arrowsize*e.arrowwidth;l=Math.max(l,d),c=Math.max(c,d),f=Math.max(f,d),h=Math.max(h,d)}r&&r.autorange&&u.expand(r,[r.l2c(e.x)],{ppadplus:c,ppadminus:l}),n&&n.autorange&&u.expand(n,[n.l2c(e.y)],{ppadplus:h,ppadminus:f})}})}function a(t,e,r,n,i,a,o,s){var l=r-t,c=i-t,u=o-i,f=n-e,h=a-e,d=s-a,p=l*d-u*f;if(0===p)return null;var g=(c*d-u*h)/p,v=(c*f-l*h)/p;return 0>v||v>1||0>g||g>1?null:{x:t+l*g,y:e+f*g}}var o=t("d3"),s=t("fast-isnumeric"),l=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),h=t("../drawing"),d=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var r=t.annotations||[],i=e.annotations=[],a=0;at?"left":t>2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var n=W.select(".annotation-math-group"),i=!n.empty(),s=h.bBox((i?n:tt).node()),d=s.width,m=s.height,y=Math.round(d+2*$),b=Math.round(m+2*$);U._w=d,U._h=m;var x=!1;if(["x","y"].forEach(function(e){var n,i=u.getFromId(t,U[e+"ref"]||e),a=(G+("x"===e?0:90))*Math.PI/180,o=y*Math.abs(Math.cos(a))+b*Math.abs(Math.sin(a)),s=U[e+"anchor"];if(i){if(!i.autorange&&(U[e]-i.range[0])*(U[e]-i.range[1])>0)return void(x=!0);H[e]=i._offset+i.l2p(U[e]),n=.5}else n=U[e],"y"===e&&(n=1-n),H[e]="x"===e?S.l+S.w*n:S.t+S.h*n;var l=0;l=U.showarrow?U["a"+e]:o*r(n,s),H[e]+=l,U["_"+e+"type"]=i&&i.type,U["_"+e+"size"]=o,U["_"+e+"shift"]=l}),x)return void W.remove();var w,k;U.showarrow&&(w=c.constrain(H.x-U.ax,1,_.width-1),k=c.constrain(H.y-U.ay,1,_.height-1)),H.x=c.constrain(H.x,1,_.width-1),H.y=c.constrain(H.y,1,_.height-1);var A=$-s.top,M=$-s.left;i?n.select("svg").attr({x:$-1,y:$}):(tt.attr({x:M,y:A}),tt.selectAll("tspan.line").attr({y:A,x:M})),Q.call(h.setRect,Z/2,Z/2,y-Z,b-Z);var T=Math.round(H.x-y/2),E=Math.round(H.y-b/2);W.call(c.setTranslate,T,E);var L="annotations["+e+"]",C=function(r,n){o.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var i=H.x+r,s=H.y+n,u=c.rotationXYMatrix(G,i,s),h=c.apply2DTransform(u),d=c.apply2DTransform2(u),p=Q.attr("width")/2,m=Q.attr("height")/2,y=[[i-p,s-m,i-p,s+m],[i-p,s+m,i+p,s+m],[i+p,s+m,i+p,s-m],[i+p,s-m,i-p,s-m]].map(d);if(!y.reduce(function(t,e){return t^!!a(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=a(i,s,w,k,t[0],t[1],t[2],t[3]);e&&(i=e.x,s=e.y)});var b=U.arrowwidth,x=U.arrowcolor,_=Y.append("g").style({opacity:f.opacity(x)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),A=_.append("path").attr("d","M"+i+","+s+"L"+w+","+k).style("stroke-width",b+"px").call(f.stroke,f.rgb(x));v.arrowhead(A,U.arrowhead,"end",U.arrowsize);var M=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(i-w)+","+(s-k),transform:"translate("+w+","+k+")"}).style("stroke-width",b+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var T,E,C;g.init({element:M.node(),prepFn:function(){var t=c.getTranslate(W);E=t.x,C=t.y,T={},V&&V.autorange&&(T[V._name+".autorange"]=!0),q&&q.autorange&&(T[q._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var r=h(E,C),n=r[0]+t,i=r[1]+e;W.call(c.setTranslate,n,i),T[L+".x"]=V?U.x+t/V._m:(w+t-S.l)/S.w,T[L+".y"]=q?U.y+e/q._m:1-(k+e-S.t)/S.h,X.attr({transform:"rotate("+G+","+n+","+i+")"})},doneFn:function(e){if(e){l.relayout(t,T);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}};U.showarrow&&C(0,0);var z=c.rotationXYMatrix(G,H.x,H.y),P=c.apply2DTransform(z);if(t._context.editable){var R,O,I;g.init({element:W.node(),prepFn:function(){var t=c.getTranslate(W);R=t.x,O=t.y,I={}},moveFn:function(t,e){W.call(c.setTranslate,R+t,O+e);var r="pointer";if(U.showarrow)I[L+".ax"]=U.ax+t,I[L+".ay"]=U.ay+e,C(t,e);else{if(V)I[L+".x"]=U.x+t/V._m;else{var n=U._xsize/S.w,i=U.x+U._xshift/S.w-n/2;I[L+".x"]=g.align(i+t/S.w,n,0,1,U.xanchor)}if(q)I[L+".y"]=U.y+e/q._m;else{var a=U._ysize/S.h,o=U.y-U._yshift/S.h-a/2;I[L+".y"]=g.align(o-e/S.h,a,0,1,U.yanchor)}V&&q||(r=g.getCursor(V?.5:I[L+".x"],q?.5:I[L+".y"],U.xanchor,U.yanchor))}var s=P(R,O),l=s[0]+t,u=s[1]+e;W.call(c.setTranslate,R+t,O+e),X.attr({transform:"rotate("+G+","+l+","+u+")"}),p(W,r)},doneFn:function(e){if(p(W),e){l.relayout(t,I);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}var b,x=t.layout,_=t._fullLayout;if(!s(e)||-1===e){if(!e&&Array.isArray(i))return x.annotations=i,v.supplyLayoutDefaults(x,_),void v.drawAll(t);if("remove"===i)return delete x.annotations,_.annotations=[],void v.drawAll(t);if(r&&"add"!==i){for(b=0;b<_.annotations.length;b++)v.draw(t,b,r,i);return}e=_.annotations.length,_.annotations.push({})}if(!r&&i){if("remove"===i){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),x.annotations.splice(e,1),b=e;b<_.annotations.length;b++)_._infolayer.selectAll('.annotation[data-index="'+(b+1)+'"]').attr("data-index",String(b)),v.draw(t,b);return}if("add"===i||c.isPlainObject(i)){_.annotations.splice(e,0,{});var w=c.isPlainObject(i)?c.extendFlat({},i):{text:"New text"};for(x.annotations?x.annotations.splice(e,0,w):x.annotations=[w],b=_.annotations.length-1;b>e;b--)_._infolayer.selectAll('.annotation[data-index="'+(b-1)+'"]').attr("data-index",String(b)),v.draw(t,b)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=x.annotations[e],A=_.annotations[e];if(k){var M={xref:k.xref,yref:k.yref},T={};"string"==typeof r&&r?T[r]=i:c.isPlainObject(r)&&(T=r);var E=Object.keys(T);for(b=0;bb;b++){var z=C[b];if(void 0===T[z]&&void 0!==k[z]){var P=u.getFromId(t,u.coerceRef(M,{},t,z)),R=u.getFromId(t,u.coerceRef(k,{},t,z)),O=k[z],I=A["_"+z+"type"];if(void 0!==T[z+"ref"]){var N="auto"===k[z+"anchor"],j="x"===z?S.w:S.h,F=(A["_"+z+"size"]||0)/(2*j);if(P&&R)O=(O-P.range[0])/(P.range[1]-P.range[0]),O=R.range[0]+O*(R.range[1]-R.range[0]);else if(P){if(O=(O-P.range[0])/(P.range[1]-P.range[0]),O=P.domain[0]+O*(P.domain[1]-P.domain[0]),N){var D=O+F,B=O-F;2/3>O+B?O=B:O+D>4/3&&(O=D)}}else R&&(N&&(1/3>O?O+=F:O>2/3&&(O-=F)),O=(O-R.domain[0])/(R.domain[1]-R.domain[0]),O=R.range[0]+O*(R.range[1]-R.range[0]))}R&&R===P&&I&&("log"===I&&"log"!==R.type?O=Math.pow(10,O):"log"!==I&&"log"===R.type&&(O=O>0?Math.log(O)/Math.LN10:void 0)),k[z]=O}}var U=n(k,_);_.annotations[e]=U;var V=u.getFromId(t,U.xref),q=u.getFromId(t,U.yref),H={x:0,y:0},G=+U.textangle||0,Y=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",U.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:U})}),X=Y.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),W=X.append("g"),Z=U.borderwidth,K=U.borderpad,$=Z+K,Q=W.append("rect").attr("class","bg").style("stroke-width",Z+"px").call(f.stroke,U.bordercolor).call(f.fill,U.bgcolor),J=U.font,tt=W.append("text").classed("annotation",!0).attr("data-unformatted",U.text).text(U.text);t._context.editable?tt.call(d.makeEditable,W).call(m).on("edit",function(r){U.text=r,this.attr({"data-unformatted":U.text}),this.call(m);var n={};n["annotations["+e+"].text"]=U.text,V&&V.autorange&&(n[V._name+".autorange"]=!0),q&&q.autorange&&(n[q._name+".autorange"]=!0),l.relayout(t,n)}):tt.call(m),X.attr({transform:"rotate("+G+","+H.x+","+H.y+")"}).call(h.setPosition,H.x,H.y)}},v.arrowhead=function(t,e,r,n){s(n)||(n=1);var i=t.node(),a=v.ARROWPATHS[e||0];if(a){"string"==typeof r&&r||(r="end");var l,c,u,d,p=(h.getPx(t,"stroke-width")||1)*n,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=r.indexOf("start")>=0,b=r.indexOf("end")>=0,x=a.backoff*p;if("line"===i.nodeName){if(l={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(l.y-c.y,l.x-c.x),d=u+Math.PI,x){var _=x*Math.cos(u),w=x*Math.sin(u);y&&(l.x-=_,l.y-=w,t.attr({x1:l.x,y1:l.y})),b&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===i.nodeName){var k=i.getTotalLength(),A="";if(y){var M=i.getPointAtLength(0),T=i.getPointAtLength(.1);u=Math.atan2(M.y-T.y,M.x-T.x),l=i.getPointAtLength(Math.min(x,k)),x&&(A="0px,"+x+"px,")}if(b){var E=i.getPointAtLength(k),L=i.getPointAtLength(k-.1);if(d=Math.atan2(E.y-L.y,E.x-L.x),c=i.getPointAtLength(Math.max(0,k-x)),x){var S=A?2*x:x;A+=k-S+"px,"+k+"px"}}else A&&(A+=k+"px");A&&t.style("stroke-dasharray",A)}var C=function(r,n){e>5&&(n=0),o.select(i.parentElement).append("path").attr({"class":t.attr("class"),d:a.path,transform:"translate("+r.x+","+r.y+")rotate("+180*n/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(l,u),b&&C(c,d)}},v.calcAutorange=function(t){var e=t._fullLayout,r=e.annotations;if(r.length&&t._fullData.length){var n={};r.forEach(function(t){n[t.xref]=!0,n[t.yref]=!0});var a=u.list(t).filter(function(t){return t.autorange&&n[t._id]});if(a.length)return c.syncOrAsync([v.drawAll,i],t)}}},{"../../lib":381,"../../lib/setcursor":389,"../../lib/svg_text_utils":393,"../../plotly":400,"../../plots/cartesian/axes":403,"../color":303,"../dragelement":323,"../drawing":325,"./arrow_paths":299,"./attributes":300,d3:72,"fast-isnumeric":76}],302:[function(t,e,r){"use strict";r.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],r.defaultLine="#444",r.lightLine="#eee",r.background="#fff",r.lightFraction=1e3/11},{}],303:[function(t,e,r){"use strict";function n(t){if(a(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var r=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!r)return t;var n=r[1].trim().split(/\s*[\s,]\s*/),i="a"===e.charAt(3)&&4===n.length;if(!i&&3!==n.length)return t;for(var o=0;o=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}var i=t("tinycolor2"),a=t("fast-isnumeric"),o=e.exports={},s=t("./attributes");o.defaults=s.defaults,o.defaultLine=s.defaultLine,o.lightLine=s.lightLine,o.background=s.background,o.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},o.rgb=function(t){return o.tinyRGB(i(t))},o.opacity=function(t){return t?i(t).getAlpha():0},o.addOpacity=function(t,e){var r=i(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},o.combine=function(t,e){var r=i(t).toRgb();if(1===r.a)return i(t).toRgbString();var n=i(e||o.background).toRgb(),a=1===n.a?n:{r:255*(1-n.a)+n.r*n.a,g:255*(1-n.a)+n.g*n.a,b:255*(1-n.a)+n.b*n.a},s={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return i(s).toRgbString()},o.stroke=function(t,e){var r=i(e);t.style({stroke:o.tinyRGB(r),"stroke-opacity":r.getAlpha()})},o.fill=function(t,e){var r=i(e);t.style({fill:o.tinyRGB(r),"fill-opacity":r.getAlpha()})},o.clean=function(t){if(t&&"object"==typeof t){var e,r,i,a,s=Object.keys(t);for(e=0;el&&(a[1]-=(ot-l)/2)):r.node()&&!r.classed("js-placeholder")&&(ot=h.bBox(e.node()).height),ot){if(ot+=5,"top"===x.titleside)Q.domain[1]-=ot/M.h,a[1]*=-1;else{Q.domain[0]+=ot/M.h;var u=Math.max(1,r.selectAll("tspan.line").size());a[1]+=(1-u)*l}e.attr("transform","translate("+a+")"),Q.setScale()}}it.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(M.h*(1-Q.domain[1]))+")");var f=it.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var r=[0===e?E[0]:(S[e]+S[e-1])/2,e===S.length-1?E[1]:(S[e]+S[e+1])/2].map(Q.c2p).map(Math.round);e!==S.length-1&&(r[1]+=r[1]>r[0]?1:-1);var a=z(t).replace("e-",""),o=i(a).toHexString();n.select(this).attr({x:Y,width:Math.max(D,2),y:n.min(r),height:Math.max(n.max(r)-n.min(r),2),fill:o})});var d=it.select(".cblines").selectAll("path.cbline").data(x.line.color&&x.line.width?L:[]);return d.enter().append("path").classed("cbline",!0),d.exit().remove(),d.each(function(t){n.select(this).attr("d","M"+Y+","+(Math.round(Q.c2p(t))+x.line.width/2%1)+"h"+D).call(h.lineGroupStyle,x.line.width,C(t),x.line.dash)}),Q._axislayer.selectAll("g."+Q._id+"tick,path").remove(),Q._pos=Y+D+(x.outlinewidth||0)/2-("outside"===x.ticks?1:0),Q.side="right",c.syncOrAsync([function(){return s.doTicks(t,Q,!0)},function(){if(-1===["top","bottom"].indexOf(x.titleside)){var e=Q.titlefont.size,r=Q._offset+Q._length/2,i=M.l+(Q.position||0)*M.w+("right"===Q.side?10+e*(Q.showticklabels?1:.5):-10-e*(Q.showticklabels?.5:0));w("h"+Q._id+"title",{avoid:{selection:n.select(t).selectAll("g."+Q._id+"tick"),side:x.titleside,offsetLeft:M.l,offsetTop:M.t,maxShift:A.width},attributes:{x:i,y:r,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,r){var n,i=b();n=o.traceIs(i,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var a={propContainer:Q,propName:n,traceIndex:i.index,dfltName:"colorscale",containerGroup:it.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;it.selectAll("."+s+",."+s+"-math-group").remove(),p.draw(t,e,u(a,r||{}))}function k(){var r=D+x.outlinewidth/2+h.bBox(Q._axislayer.node()).width;if(N=at.select("text"),N.node()&&!N.classed("js-placeholder")){var n,i=at.select(".h"+Q._id+"title-math-group").node();n=i&&-1!==["top","bottom"].indexOf(x.titleside)?h.bBox(i).width:h.bBox(at.node()).right-Y-M.l,r=Math.max(r,n)}var a=2*x.xpad+r+x.borderwidth+x.outlinewidth/2,s=Z-K;it.select(".cbbg").attr({x:Y-x.xpad-(x.borderwidth+x.outlinewidth)/2,y:K-H,width:Math.max(a,2),height:Math.max(s+2*H,2)}).call(d.fill,x.bgcolor).call(d.stroke,x.bordercolor).style({"stroke-width":x.borderwidth}),it.selectAll(".cboutline").attr({x:Y,y:K+x.ypad+("top"===x.titleside?ot:0),width:Math.max(D,2),height:Math.max(s-2*x.ypad-ot,2)}).call(d.stroke,x.outlinecolor).style({fill:"None","stroke-width":x.outlinewidth});var l=({center:.5,right:1}[x.xanchor]||0)*a;it.attr("transform","translate("+(M.l-l)+","+M.t+")"),o.autoMargin(t,e,{x:x.x,y:x.y,l:a*({right:1,center:.5}[x.xanchor]||0),r:a*({left:1,center:.5}[x.xanchor]||0),t:s*({bottom:1,middle:.5}[x.yanchor]||0),b:s*({top:1,middle:.5}[x.yanchor]||0)})}var A=t._fullLayout,M=A._size;if("function"!=typeof x.fillcolor&&"function"!=typeof x.line.color)return void A._infolayer.selectAll("g."+e).remove();var T,E=n.extent(("function"==typeof x.fillcolor?x.fillcolor:x.line.color).domain()),L=[],S=[],C="function"==typeof x.line.color?x.line.color:function(){return x.line.color},z="function"==typeof x.fillcolor?x.fillcolor:function(){return x.fillcolor},P=x.levels.end+x.levels.size/100,R=x.levels.size,O=1.001*E[0]-.001*E[1],I=1.001*E[1]-.001*E[0];for(T=x.levels.start;0>(T-P)*R;T+=R)T>O&&I>T&&L.push(T);if("function"==typeof x.fillcolor)if(x.filllevels)for(P=x.filllevels.end+x.filllevels.size/100,R=x.filllevels.size,T=x.filllevels.start;0>(T-P)*R;T+=R)T>E[0]&&T1){var nt=Math.pow(10,Math.floor(Math.log(rt)/Math.LN10));tt*=nt*c.roundUp(rt/nt,[2,5,10]),(Math.abs(x.levels.start)/x.levels.size+1e-6)%1<2e-6&&(Q.tick0=0)}Q.dtick=tt}Q.domain=[W+G,W+V-G],Q.setScale();var it=A._infolayer.selectAll("g."+e).data([0]);it.enter().append("g").classed(e,!0).each(function(){var t=n.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),it.attr("transform","translate("+Math.round(M.l)+","+Math.round(M.t)+")");var at=it.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(M.l)+",-"+Math.round(M.t)+")");Q._axislayer=it.select(".cbaxis");var ot=0;if(-1!==["top","bottom"].indexOf(x.titleside)){var st,lt=M.l+(x.x+q)*M.w,ct=Q.titlefont.size;st="top"===x.titleside?(1-(W+V-G))*M.h+M.t+3+.75*ct:(1-(W+G))*M.h+M.t-3-.25*ct,w(Q._id+"title",{attributes:{x:lt,y:st,"text-anchor":"start"}})}var ut=c.syncOrAsync([o.previousPromises,_,o.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,ht,dt;l.init({element:it.node(),prepFn:function(){ft=it.attr("transform"),f(it)},moveFn:function(t,e){it.attr("transform",ft+" translate("+t+","+e+")"),ht=l.align(X+t/M.w,B,0,1,x.xanchor),dt=l.align(W-e/M.h,V,0,1,x.yanchor);var r=l.getCursor(ht,dt,x.xanchor,x.yanchor);f(it,r)},doneFn:function(e){f(it),e&&void 0!==ht&&void 0!==dt&&a.restyle(t,{"colorbar.x":ht,"colorbar.y":dt},b().index)}})}return ut}function b(){var r,n,i=e.substr(2);for(r=0;ru*f?i.RdBu:u>=0?i.Reds:i.Blues,l.colorscale=h,s.reversescale&&(h=a(h)),s.colorscale=h)}},{"../../lib":381,"./flip_scale":313,"./scales":320}],311:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":320}],312:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,c,u){var f=u.prefix,h=u.cLetter,d=f.slice(0,f.length-1),p=f?i.nestedProperty(t,d).get()||{}:t,g=f?i.nestedProperty(e,d).get()||{}:e,v=p[h+"min"],m=p[h+"max"],y=p.colorscale,b=n(v)&&n(m)&&m>v;c(f+h+"auto",!b),c(f+h+"min"),c(f+h+"max");var x;void 0!==y&&(x=!s(y)),c(f+"autocolorscale",x);var _=c(f+"colorscale"),w=c(f+"reversescale");if(w&&(g.colorscale=l(_)),"marker.line."!==f){var k;f&&(k=a(p));var A=c(f+"showscale",k);A&&o(p,g,r)}}},{"../../lib":381,"../colorbar/defaults":305,"../colorbar/has_colorbar":307,"./flip_scale":313,"./is_valid_scale":317,"fast-isnumeric":76}],313:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=t.length,n=new Array(r),i=r-1,a=0;i>=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],314:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return e||(e=i),t?("string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e):e}},{"./default_scale":311,"./is_valid_scale_array":318,"./scales":320}],315:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(Array.isArray(o))for(var l=0;lh;h++)l=t[h],u[h]=e+l[0]*(r-e),f[h]=i(l[1]).toRgb();var d=n.scale.linear().domain(u).interpolate(n.interpolateObject).range(f);return function(t){if(a(t)){var n=o.constrain(t,e,r),l=d(n);return i(l).toRgbString()}return i(t).isValid()?t:s.defaultLine}}},{"../../lib":381,"../color":303,d3:72,"fast-isnumeric":76,tinycolor2:233}],320:[function(t,e,r){"use strict";e.exports={Greys:[[0,"rgb(0,0,0)"],[1,"rgb(255,255,255)"]],YlGnBu:[[0,"rgb(8,29,88)"],[.125,"rgb(37,52,148)"],[.25,"rgb(34,94,168)"],[.375,"rgb(29,145,192)"],[.5,"rgb(65,182,196)"],[.625,"rgb(127,205,187)"],[.75,"rgb(199,233,180)"],[.875,"rgb(237,248,217)"],[1,"rgb(255,255,217)"]],Greens:[[0,"rgb(0,68,27)"],[.125,"rgb(0,109,44)"],[.25,"rgb(35,139,69)"],[.375,"rgb(65,171,93)"],[.5,"rgb(116,196,118)"],[.625,"rgb(161,217,155)"],[.75,"rgb(199,233,192)"],[.875,"rgb(229,245,224)"],[1,"rgb(247,252,245)"]],YlOrRd:[[0,"rgb(128,0,38)"],[.125,"rgb(189,0,38)"],[.25,"rgb(227,26,28)"],[.375,"rgb(252,78,42)"],[.5,"rgb(253,141,60)"],[.625,"rgb(254,178,76)"],[.75,"rgb(254,217,118)"],[.875,"rgb(255,237,160)"],[1,"rgb(255,255,204)"]], -Bluered:[[0,"rgb(0,0,255)"],[1,"rgb(255,0,0)"]],RdBu:[[0,"rgb(5,10,172)"],[.35,"rgb(106,137,247)"],[.5,"rgb(190,190,190)"],[.6,"rgb(220,170,132)"],[.7,"rgb(230,145,90)"],[1,"rgb(178,10,28)"]],Reds:[[0,"rgb(220,220,220)"],[.2,"rgb(245,195,157)"],[.4,"rgb(245,160,105)"],[1,"rgb(178,10,28)"]],Blues:[[0,"rgb(5,10,172)"],[.35,"rgb(40,60,190)"],[.5,"rgb(70,100,245)"],[.6,"rgb(90,120,245)"],[.7,"rgb(106,137,247)"],[1,"rgb(220,220,220)"]],Picnic:[[0,"rgb(0,0,255)"],[.1,"rgb(51,153,255)"],[.2,"rgb(102,204,255)"],[.3,"rgb(153,204,255)"],[.4,"rgb(204,204,255)"],[.5,"rgb(255,255,255)"],[.6,"rgb(255,204,255)"],[.7,"rgb(255,153,255)"],[.8,"rgb(255,102,204)"],[.9,"rgb(255,102,102)"],[1,"rgb(255,0,0)"]],Rainbow:[[0,"rgb(150,0,90)"],[.125,"rgb(0,0,200)"],[.25,"rgb(0,25,255)"],[.375,"rgb(0,152,255)"],[.5,"rgb(44,255,150)"],[.625,"rgb(151,255,0)"],[.75,"rgb(255,234,0)"],[.875,"rgb(255,111,0)"],[1,"rgb(255,0,0)"]],Portland:[[0,"rgb(12,51,131)"],[.25,"rgb(10,136,186)"],[.5,"rgb(242,211,56)"],[.75,"rgb(242,143,56)"],[1,"rgb(217,30,30)"]],Jet:[[0,"rgb(0,0,131)"],[.125,"rgb(0,60,170)"],[.375,"rgb(5,255,255)"],[.625,"rgb(255,255,0)"],[.875,"rgb(250,0,0)"],[1,"rgb(128,0,0)"]],Hot:[[0,"rgb(0,0,0)"],[.3,"rgb(230,0,0)"],[.6,"rgb(255,210,0)"],[1,"rgb(255,255,255)"]],Blackbody:[[0,"rgb(0,0,0)"],[.2,"rgb(230,0,0)"],[.4,"rgb(230,210,0)"],[.7,"rgb(255,255,255)"],[1,"rgb(160,200,255)"]],Earth:[[0,"rgb(0,0,130)"],[.1,"rgb(0,180,180)"],[.2,"rgb(40,210,40)"],[.4,"rgb(230,230,50)"],[.6,"rgb(120,70,20)"],[1,"rgb(255,255,255)"]],Electric:[[0,"rgb(0,0,0)"],[.15,"rgb(30,0,100)"],[.4,"rgb(120,0,100)"],[.6,"rgb(160,90,0)"],[.8,"rgb(230,200,0)"],[1,"rgb(255,250,220)"]],Viridis:[[0,"#440154"],[.06274509803921569,"#48186a"],[.12549019607843137,"#472d7b"],[.18823529411764706,"#424086"],[.25098039215686274,"#3b528b"],[.3137254901960784,"#33638d"],[.3764705882352941,"#2c728e"],[.4392156862745098,"#26828e"],[.5019607843137255,"#21918c"],[.5647058823529412,"#1fa088"],[.6274509803921569,"#28ae80"],[.6901960784313725,"#3fbc73"],[.7529411764705882,"#5ec962"],[.8156862745098039,"#84d44b"],[.8784313725490196,"#addc30"],[.9411764705882353,"#d8e219"],[1,"#fde725"]]}},{}],321:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i){var a=(t-r)/(n-r),o=a+e/(n-r),s=(a+o)/2;return"left"===i||"bottom"===i?a:"center"===i||"middle"===i?s:"right"===i||"top"===i?o:2/3-s>a?a:o>4/3-s?o:s}},{}],322:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":381}],323:[function(t,e,r){"use strict";function n(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function i(t){t._dragging=!1,t._replotPending&&a.plot(t)}var a=t("../../plotly"),o=t("../../lib"),s=t("../../plots/cartesian/constants"),l=e.exports={};l.align=t("./align"),l.getCursor=t("./cursor");var c=t("./unhover");l.unhover=c.wrapped,l.unhoverRaw=c.raw,l.init=function(t){function e(e){return p._dragged=!1,p._dragging=!0,c=e.clientX,u=e.clientY,d=e.target,f=(new Date).getTime(),f-p._mouseDownTimev&&(g=Math.max(g-1,1)),t.doneFn&&t.doneFn(p._dragged,g),!p._dragged){var r=document.createEvent("MouseEvents");r.initEvent("click",!0,!0),d.dispatchEvent(r)}return i(p),p._dragged=!1,o.pauseEvent(e)}var c,u,f,h,d,p=o.getPlotDiv(t.element)||{},g=1,v=s.DBLCLICKDELAY;p._mouseDownTime||(p._mouseDownTime=0),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":381,"../../plotly":400,"../../plots/cartesian/constants":408,"./align":321,"./cursor":322,"./unhover":324}],324:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=e.exports={};i.wrapped=function(t,e,r){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),i.raw(t,e,r)},i.raw=function(t,e){var r=t._fullLayout;e||(e={}),e.target&&n.triggerHandler(t,"plotly_beforehover",e)===!1||(r._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":375}],325:[function(t,e,r){"use strict";function n(t,e,r,n){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],c=Math.pow(a*a+o*o,x/2),u=Math.pow(s*s+l*l,x/2),f=(u*u*a-c*c*s)*n,h=(u*u*o-c*c*l)*n,d=3*u*(c+u),p=3*c*(c+u);return[[i.round(e[0]+(d&&f/d),2),i.round(e[1]+(d&&h/d),2)],[i.round(e[0]-(p&&f/p),2),i.round(e[1]-(p&&h/p),2)]]}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../plots/plots"),s=t("../color"),l=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../traces/scatter/subtypes"),d=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,r,n){e&&e.family&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},p.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},p.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},p.setRect=function(t,e,r,n,i){t.call(p.setPosition,e,r).call(p.setSize,n,i)},p.translatePoints=function(t,e,r){t.each(function(t){var n=t.xp||e.c2p(t.x),o=t.yp||r.c2p(t.y),s=i.select(this);a(n)&&a(o)?"text"===this.nodeName?s.attr("x",n).attr("y",o):s.attr("transform","translate("+n+","+o+")"):s.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:1>e?1:Math.round(e):r||0},p.lineGroupStyle=function(t,e,r,n){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=n||a.dash||"";i.select(this).call(s.stroke,r||a.color).call(p.dashLine,l,o)})},p.dashLine=function(t,e,r){var n=Math.max(r,3);"solid"===e?e="":"dot"===e?e=n+"px,"+n+"px":"dash"===e?e=3*n+"px,"+3*n+"px":"longdash"===e?e=5*n+"px,"+5*n+"px":"dashdot"===e?e=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===e&&(e=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var r=i.select(this);try{r.call(s.fill,e[0].trace.fillcolor)}catch(n){console.log(n,t),r.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var r=e.marker,n=r.line;if(o.traceIs(e,"symbols")){var a=d(e);t.attr("d",function(t){var n;n="various"===t.ms||"various"===r.size?3:h.isBubble(e)?a(t.ms):(r.size||6)/2,t.mrc=n;var i=p.symbolNumber(t.mx||r.symbol)||0,o=i%100;return t.om=i%200>=100,p.symbolFuncs[o](n)+(i>=200?m:"")}).style("opacity",function(t){return(t.mo+1||r.opacity+1)-1})}var l=(e._input||{}).marker||{},c=p.tryColorscale(r,l,""),u=p.tryColorscale(r,l,"line.");t.each(function(t){var e,a,o;t.so?(o=n.outlierwidth,a=n.outliercolor,e=r.outliercolor):(o=(t.mlw+1||n.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,a="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(n.color)?s.defaultLine:n.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(r.color)?s.defaultLine:r.color||"rgba(0,0,0,0)");var l=i.select(this);t.om?l.call(s.stroke,e).style({"stroke-width":(o||1)+"px",fill:"none"}):(l.style("stroke-width",o+"px").call(s.fill,e),o&&l.call(s.stroke,a))})}},p.tryColorscale=function(t,e,r){var n=c.nestedProperty(t,r+"color").get(),i=c.nestedProperty(t,r+"colorscale").get(),o=c.nestedProperty(t,r+"cauto").get(),s=c.nestedProperty(t,r+"cmin"),u=c.nestedProperty(t,r+"cmax"),f=s.get(),h=u.get();return i&&Array.isArray(n)?(!o&&a(f)&&a(h)||(f=1/0,h=-(1/0),n.forEach(function(t){a(t)&&(f>t&&(f=+t),t>h&&(h=+t))}),f>h&&(f=0,h=1),s.set(f),u.set(h),c.nestedProperty(e,r+"cmin").set(f),c.nestedProperty(e,r+"cmax").set(h)),l.makeScaleFunction(i,f,h)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},b=1.3;p.textPointStyle=function(t,e){t.each(function(t){var r=i.select(this),n=t.tx||e.text;if(!n||Array.isArray(n))return void r.remove();var o=t.tp||e.textposition,s=-1!==o.indexOf("top")?"top":-1!==o.indexOf("bottom")?"bottom":"middle",l=-1!==o.indexOf("left")?"end":-1!==o.indexOf("right")?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=a(c)&&c>0?c:0,r.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",l).text(n).call(u.convertToTspans);var h=i.select(this.parentNode),d=r.selectAll("tspan.line"),g=((d[0].length||1)-1)*b+1,v=y[l]*f,m=.75*c+y[s]*f+(y[s]-1)*g*c/2;h.attr("transform","translate("+v+","+m+")"),g>1&&d.attr({x:r.attr("x"),y:r.attr("y")})})};var x=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,i="M"+t[0],a=[];for(r=1;rr;r++)o.push(n(t[r-1],t[r],t[r+1],e));for(o.push(n(t[a-1],t[a],t[0],e)),r=1;a>=r;r++)i+="C"+o[r-1][1]+" "+o[r][0]+" "+t[r];return i+="C"+o[a][1]+" "+o[0][0]+" "+t[0]+"Z"};var _={hv:function(t,e){return"H"+i.round(e[0],2)+"V"+i.round(e[1],2)},vh:function(t,e){return"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},hvh:function(t,e){return"H"+i.round((t[0]+e[0])/2,2)+"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},vhv:function(t,e){return"V"+i.round((t[1]+e[1])/2,2)+"H"+i.round(e[0],2)+"V"+i.round(e[1],2)}},w=function(t,e){return"L"+i.round(e[0],2)+","+i.round(e[1],2)};p.steps=function(t){var e=_[t]||w;return function(t){for(var r="M"+i.round(t[0][0],2)+","+i.round(t[0][1],2),n=1;n=A&&(i.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(l),c.extendFlat({},l)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var r="#"+e,n=i.select("base");n.size()&&n.attr("href")&&(r=window.location.href+r),t.attr("clip-path","url("+r+")")}},{"../../constants/xmlns_namespaces":369,"../../lib":381,"../../lib/svg_text_utils":393,"../../plots/plots":452,"../../traces/scatter/make_bubble_size_func":567,"../../traces/scatter/subtypes":573,"../color":303,"../colorscale":316,"./symbol_defs":326,d3:72,"fast-isnumeric":76}],326:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+","+r+"H"+e+"L0,-"+i+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+",-"+r+"H"+e+"L0,"+i+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M"+r+",-"+e+"V"+e+"L-"+i+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+r+",-"+e+"V"+e+"L"+i+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(t*-.309,2),o=n.round(.809*t,2);return"M"+e+","+a+"L"+r+","+o+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(e*-.309,2),c=n.round(.118*e,2),u=n.round(.809*e,2),f=n.round(.382*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+c+"L"+o+","+u+"L0,"+f+"L-"+o+","+u+"L-"+a+","+c+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:72}],327:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],328:[function(t,e,r){"use strict";function n(t,e,r,n){var a=e["error_"+n]||{},l=a.visible&&-1!==["linear","log"].indexOf(r.type),c=[];if(l){for(var u=s(a),f=0;fs;s++)o[s]={x:r[s],y:i[s]};return o[0].trace=t,n.calc({calcdata:[o],_fullLayout:e}),o},n.plot=t("./plot"),n.style=t("./style"),n.hoverInfo=function(t,e,r){(e.error_y||{}).visible&&(r.yerr=t.yh-t.y,e.error_y.symmetric||(r.yerrneg=t.y-t.ys)),(e.error_x||{}).visible&&(r.xerr=t.xh-t.x,e.error_x.symmetric||(r.xerrneg=t.x-t.xs))}},{"./attributes":327,"./calc":328,"./defaults":330,"./plot":332,"./style":333}],332:[function(t,e,r){"use strict";function n(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};return void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0))),void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0))),n}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),s=t("../../traces/scatter/subtypes");e.exports=function(t,e){var r=e.x(),l=e.y();t.each(function(t){var e=t[0].trace,c=e.error_x||{},u=e.error_y||{},f=s.hasMarkers(e)&&e.marker.maxdisplayed>0;if(u.visible||c.visible){var h=i.select(this).selectAll("g.errorbar").data(o.identity);h.enter().append("g").classed("errorbar",!0),h.each(function(t){var e=i.select(this),o=n(t,r,l);if(!f||t.vis){var s;if(u.visible&&a(o.x)&&a(o.yh)&&a(o.ys)){var h=u.width;s="M"+(o.x-h)+","+o.yh+"h"+2*h+"m-"+h+",0V"+o.ys,o.noYS||(s+="m-"+h+",0h"+2*h),e.append("path").classed("yerror",!0).attr("d",s)}if(c.visible&&a(o.y)&&a(o.xh)&&a(o.xs)){var d=(c.copy_ystyle?u:c).width;s="M"+o.xh+","+(o.y-d)+"v"+2*d+"m0,-"+d+"H"+o.xs,o.noXS||(s+="m0,-"+d+"v"+2*d),e.append("path").classed("xerror",!0).attr("d",s)}}})}})}},{"../../lib":381,"../../traces/scatter/subtypes":573,d3:72,"fast-isnumeric":76}],333:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":303,d3:72}],334:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",n.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",n.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":408}],335:[function(t,e,r){"use strict";function n(t,e,r){function n(r,n){return a.coerce(t,e,o,r,n)}e=e||{},n("source"),n("layer"),n("x"),n("y"),n("xanchor"),n("yanchor"),n("sizex"),n("sizey"),n("sizing"),n("opacity");for(var s=0;2>s;s++){var l={_fullLayout:r},c=["x","y"][s];i.coerceRef(t,e,l,c,"paper")}return e}var i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var r=t.images,i=e.images=[],a=0;a=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],339:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:a({},n,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":376,"../../plots/font_attributes":421,"../color/attributes":302}],340:[function(t,e,r){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],341:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/plots"),a=t("./attributes"),o=t("./helpers");e.exports=function(t,e,r){function s(t,e){return n.coerce(h,d,a,t,e)}for(var l,c,u,f,h=t.legend||{},d=e.legend={},p=0,g="normal",v=0;v1);if(y!==!1){if(s("bgcolor",e.paper_bgcolor),s("bordercolor"),s("borderwidth"),n.coerceFont(s,"font",e.font),s("orientation"),"h"===d.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(l=0,u="left",c=1.1,f="bottom"):(l=0,u="left",c=-.1,f="top")}s("traceorder",g),o.isGrouped(e.legend)&&s("tracegroupgap"),s("x",l),s("xanchor",u),s("y",c),s("yanchor",f),n.noneOrAll(h,d,["x","y"])}}},{"../../lib":381,"../../plots/plots":452,"./attributes":339,"./helpers":344}],342:[function(t,e,r){"use strict";function n(t,e){function r(r){u.util.convertToTspans(r,function(){r.selectAll("tspan.line").attr({x:r.attr("x")}),t.call(a,e)})}var n=t.data()[0][0],i=e._fullLayout,o=n.trace,s=h.traceIs(o,"pie"),l=o.index,c=s?n.label:o.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":c}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,i.legend.font).text(c),e._context.editable&&!s?f.call(u.util.makeEditable).call(r).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(r),this.text()||(t=" "),u.restyle(e,"name",t,l)}):f.call(r)}function i(t,e){var r=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],n=t.selectAll("rect").data([0]);n.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"),n.on("click",function(){if(!e._dragged){var n,i,a=t.data()[0][0],o=e._fullData,s=a.trace,l=s.legendgroup,c=[];if(h.traceIs(s,"pie")){var f=a.label,d=r.indexOf(f);-1===d?r.push(f):r.splice(d,1),u.relayout(e,"hiddenlabels",r)}else{if(""===l)c=[s.index];else for(var p=0;ptspan"),d=h[0].length||1;r=l*d,n=u.node()&&p.bBox(u.node()).width;var g=l*(.3+(1-d)/2);u.attr("y",g),h.attr("y",g)}r=Math.max(r,16)+3,a.attr({x:0,y:-r/2,height:r}),i.height=r,i.width=n}function o(t,e,r){var n=t._fullLayout,i=n.legend,a=i.borderwidth,o=b.isGrouped(i);if(b.isVertical(i))o&&e.each(function(t,e){f.setTranslate(this,0,e*i.tracegroupgap)}),i.width=0,i.height=0,r.each(function(t){var e=t[0],r=e.height,n=e.width;f.setTranslate(this,a,5+a+i.height+r/2),i.height+=r,i.width=Math.max(i.width,n)}),i.width+=45+2*a,i.height+=10+2*a,o&&(i.height+=(i._lgroupsLength-1)*i.tracegroupgap),r.selectAll(".legendtoggle").attr("width",(t._context.editable?0:i.width)+40),i.width=Math.ceil(i.width),i.height=Math.ceil(i.height);else if(o){i.width=0,i.height=0;for(var s=[i.width],l=e.data(),u=0,h=l.length;h>u;u++){var d=l[u].map(function(t){return t[0].width}),p=40+Math.max.apply(null,d);i.width+=i.tracegroupgap+p,s.push(i.width)}e.each(function(t,e){f.setTranslate(this,s[e],0)}),e.each(function(){var t=c.select(this),e=t.selectAll("g.traces"),r=0;e.each(function(t){var e=t[0],n=e.height;f.setTranslate(this,0,5+a+r+n/2),r+=n}),i.height=Math.max(i.height,r)}),i.height+=10+2*a,i.width+=2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}else i.width=0,i.height=0,r.each(function(t){var e=t[0],r=40+e.width,n=i.tracegroupgap||5;f.setTranslate(this,a+i.width,5+a+e.height/2),i.width+=n+r,i.height=Math.max(i.height,e.height)}),i.width+=2*a,i.height+=10+2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}function s(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center");var i="top";x.isBottomAnchor(r)?i="bottom":x.isMiddleAnchor(r)&&(i="middle"),h.autoMargin(t,"legend",{x:r.x,y:r.y,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:r.height*({top:1,middle:.5}[i]||0),t:r.height*({bottom:1,middle:.5}[i]||0)})}function l(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center"),h.autoMargin(t,"legend",{x:r.x,y:.5,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:0,t:0})}var c=t("d3"),u=t("../../plotly"),f=t("../../lib"),h=t("../../plots/plots"),d=t("../dragelement"),p=t("../drawing"),g=t("../color"),v=t("./constants"),m=t("./get_legend_data"),y=t("./style"),b=t("./helpers"),x=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e).call(f.setTranslate,0,e),E.call(p.setRect,j,t,v.scrollBarWidth,v.scrollBarHeight),A.select("rect").attr({y:b.borderwidth-e})}var r=t._fullLayout,a="legend"+r._uid;if(r._infolayer&&t.calcdata){var b=r.legend,_=r.showlegend&&m(t.calcdata,b),w=r.hiddenlabels||[];if(!r.showlegend||!_.length)return r._infolayer.selectAll(".legend").remove(),r._topdefs.select("#"+a).remove(),void h.autoMargin(t,"legend");"undefined"==typeof t.firstRender?t.firstRender=!0:t.firstRender&&(t.firstRender=!1);var k=r._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({"class":"legend","pointer-events":"all"});var A=r._topdefs.selectAll("#"+a).data([0]);A.enter().append("clipPath").attr("id",a).append("rect");var M=k.selectAll("rect.bg").data([0]);M.enter().append("rect").attr({"class":"bg","shape-rendering":"crispEdges"}).call(g.stroke,b.bordercolor).call(g.fill,b.bgcolor).style("stroke-width",b.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var E=k.selectAll("rect.scrollbar").data([0]);E.enter().append("rect").attr({"class":"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var L=T.selectAll("g.groups").data(_);L.enter().append("g").attr("class","groups"),L.exit().remove();var S=L.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return h.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(){c.select(this).call(n,t).call(i,t)}),t.firstRender&&(o(t,L,S),s(t));var C=0,z=r.width,P=0,R=r.height;o(t,L,S),b.height>R?l(t):s(t);var O=r._size,I=O.l+O.w*b.x,N=O.t+O.h*(1-b.y);x.isRightAnchor(b)?I-=b.width:x.isCenterAnchor(b)&&(I-=b.width/2),x.isBottomAnchor(b)?N-=b.height:x.isMiddleAnchor(b)&&(N-=b.height/2);var j=b.width,F=O.w;j>F?(I=O.l,j=F):(I+j>z&&(I=z-j),C>I&&(I=C),j=Math.min(z-I,b.width));var D=b.height,B=O.h;D>B?(N=O.t,D=B):(N+D>R&&(N=R-D),P>N&&(N=P),D=Math.min(R-N,b.height)),f.setTranslate(k,I,N),M.attr({width:j-b.borderwidth,height:D-b.borderwidth,x:b.borderwidth/2,y:b.borderwidth/2});var U=T.attr("data-scroll")||0;if(f.setTranslate(T,0,U),A.select("rect").attr({width:j-2*b.borderwidth,height:D-2*b.borderwidth,x:b.borderwidth-U,y:b.borderwidth}),T.call(p.setClipUrl,a),b.height-D>0&&!t._context.staticPlot){M.attr({width:j-2*b.borderwidth+v.scrollBarWidth+v.scrollBarMargin}),A.select("rect").attr({width:j-2*b.borderwidth+v.scrollBarWidth+v.scrollBarMargin}),t.firstRender&&e(v.scrollBarMargin,0);var V=D-v.scrollBarHeight-2*v.scrollBarMargin,q=b.height-D,H=v.scrollBarMargin,G=0;e(H,G),k.on("wheel",null),k.on("wheel",function(){G=f.constrain(T.attr("data-scroll")-c.event.deltaY/V*q,-q,0),H=v.scrollBarMargin-G/q*V,e(H,G),c.event.preventDefault()}),E.on(".drag",null),T.on(".drag",null);var Y=c.behavior.drag().on("drag",function(){H=f.constrain(c.event.y-v.scrollBarHeight/2,v.scrollBarMargin,v.scrollBarMargin+V),G=-(H-v.scrollBarMargin)/V*q,e(H,G)});E.call(Y),T.call(Y)}if(t._context.editable){var X,W,Z,K;k.classed("cursor-move",!0),d.init({element:k.node(),prepFn:function(){var t=f.getTranslate(k);Z=t.x,K=t.y},moveFn:function(t,e){var r=Z+t,n=K+e;f.setTranslate(k,r,n),X=d.align(r,0,O.l,O.l+O.w,b.xanchor),W=d.align(n,0,O.t+O.h,O.t,b.yanchor)},doneFn:function(e){e&&void 0!==X&&void 0!==W&&u.relayout(t,{"legend.x":X,"legend.y":W})}})}}}},{"../../lib":381,"../../plotly":400,"../../plots/plots":452,"../color":303,"../dragelement":323,"../drawing":325,"./anchor_utils":338,"./constants":340,"./get_legend_data":343,"./helpers":344,"./style":346,d3:72}],343:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("./helpers");e.exports=function(t,e){function r(t,r){if(""!==t&&i.isGrouped(e))-1===l.indexOf(t)?(l.push(t),c=!0,s[t]=[[r]]):s[t].push([r]);else{var n="~~i"+f;l.push(n),s[n]=[[r]],f++}}var a,o,s={},l=[],c=!1,u={},f=0;for(a=0;aa;a++)m=s[l[a]],y[a]=i.isReversed(e)?m.reverse():m;else{for(y=[new Array(b)],a=0;b>a;a++)m=s[l[a]][0],y[0][i.isReversed(e)?b-a-1:a]=m;b=1}return e._lgroupsLength=b,y}},{"../../plots/plots":452,"./helpers":344}],344:[function(t,e,r){"use strict";var n=t("../../plots/plots");r.legendGetsTrace=function(t){return t.visible&&n.traceIs(t,"showLegend")},r.isGrouped=function(t){return-1!==(t.traceorder||"").indexOf("grouped")},r.isVertical=function(t){return"h"!==t.orientation},r.isReversed=function(t){return-1!==(t.traceorder||"").indexOf("reversed")}},{"../../plots/plots":452}],345:[function(t,e,r){"use strict";var n=e.exports={};n.layoutAttributes=t("./attributes"),n.supplyLayoutDefaults=t("./defaults"),n.draw=t("./draw"),n.style=t("./style")},{"./attributes":339,"./defaults":341,"./draw":342,"./style":346}],346:[function(t,e,r){"use strict";function n(t){var e=t[0].trace,r=e.visible&&e.fill&&"none"!==e.fill,n=d.hasLines(e),i=l.select(this).select(".legendfill").selectAll("path").data(r?[t]:[]);i.enter().append("path").classed("js-fill",!0),i.exit().remove(),i.attr("d","M5,0h30v6h-30z").call(f.fillGroupStyle);var a=l.select(this).select(".legendlines").selectAll("path").data(n?[t]:[]);a.enter().append("path").classed("js-line",!0).attr("d","M5,0h30"),a.exit().remove(),a.call(f.lineGroupStyle)}function i(t){function e(t,e,r){var n=c.nestedProperty(o,t).get(),i=Array.isArray(n)&&e?e(n):n;if(r){if(ir[1])return r[1]}return i}function r(t){return t[0]}var n,i,a=t[0],o=a.trace,s=d.hasMarkers(o),u=d.hasText(o),h=d.hasLines(o);if(s||u||h){var p={},g={};s&&(p.mc=e("marker.color",r),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",r),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),h&&(g.line={width:e("line.width",r,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",r),p.ts=10,p.tc=e("textfont.color",r),p.tf=e("textfont.family",r)),n=[c.minExtend(a,p)],i=c.minExtend(o,g)}var v=l.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(s?n:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,i),s&&(n[0].mrc=3);var y=v.selectAll("g.pointtext").data(u?n:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,i)}function a(t){var e=t[0].trace,r=e.marker||{},n=r.line||{},i=l.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);i.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),i.exit().remove(),i.each(function(t){var e=(t.mlw+1||n.width+1)-1,i=l.select(this);i.style("stroke-width",e+"px").call(h.fill,t.mc||r.color),e&&i.call(h.stroke,t.mlc||n.color)})}function o(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);r.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.each(function(t){var r=(t.lw+1||e.line.width+1)-1,n=l.select(this);n.style("stroke-width",r+"px").call(h.fill,t.fc||e.fillcolor),r&&n.call(h.stroke,t.lc||e.line.color)})}function s(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);r.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.size()&&r.call(p,t[0],e)}var l=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),h=t("../color"),d=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=l.select(this),r=e.selectAll("g.legendfill").data([t]);r.enter().append("g").classed("legendfill",!0);var n=e.selectAll("g.legendlines").data([t]);n.enter().append("g").classed("legendlines",!0);var i=e.selectAll("g.legendsymbols").data([t]);i.enter().append("g").classed("legendsymbols",!0),i.style("opacity",t[0].trace.opacity),i.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(a).each(o).each(s).each(n).each(i)}},{"../../lib":381,"../../plots/plots":452,"../../traces/pie/style_one":552,"../../traces/scatter/subtypes":573,"../color":303,"../drawing":325,d3:72}],347:[function(t,e,r){"use strict";function n(t,e){var r=e.currentTarget,n=r.getAttribute("data-attr"),i=r.getAttribute("data-val")||!0,a=t._fullLayout,o={};if("zoom"===n){for(var s,l,u="in"===i?.5:2,h=(1+u)/2,d=(1-u)/2,p=c.Axes.list(t,null,!0),v=0;vy;y++){var b=s[y];h=m[b]={};for(var x=0;x1)return n(["resetViews","toggleHover"]),o(v,r);u&&(n(["zoom3d","pan3d","orbitRotation","tableRotation"]),n(["resetCameraDefault3d","resetCameraLastSave3d"]),n(["hoverClosest3d"])),h&&(n(["zoomInGeo","zoomOutGeo","resetGeo"]),n(["hoverClosestGeo"]));var m=i(s),y=[];return((c||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(c||g)&&a(l)&&(y.push("select2d"),y.push("lasso2d")),y.length&&n(y),!c&&!p||m||g||n(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&d?n(["toggleHover"]):p?n(["hoverClosestGl2d"]):c?n(["hoverClosestCartesian","hoverCompareCartesian"]):d&&n(["hoverClosestPie"]),o(v,r)}function i(t){for(var e=l.Axes.list({_fullLayout:t},null,!0),r=!0,n=0;n0);if(h){var d=i(e,r,s);l("x",d[0]),l("y",d[1]),a.noneOrAll(t,e,["x","y"]),l("xanchor"),l("yanchor"),a.coerceFont(l,"font",r.font),l("bgcolor"),l("bordercolor"),l("borderwidth")}}},{"../../lib":381,"./attributes":350,"./button_attributes":351,"./constants":352}],354:[function(t,e,r){"use strict";function n(t){for(var e=m.list(t,"x",!0),r=[],n=0;nr){var i=r;r=e,e=i}s.setAttributes(x,{"data-min":e,"data-max":r}),s.setAttributes(z,{x:e,width:r-e}),s.setAttributes(k,{width:e}),s.setAttributes(A,{x:r,width:h-r}),s.setAttributes(M,{transform:"translate("+(e-p-1)+")"}),s.setAttributes(L,{transform:"translate("+r+")"});var o=f.range[0],l=f.range[1],c=l-o,u=e/h*c+o,d=r/h*c+o;window.requestAnimationFrame?window.requestAnimationFrame(function(){n.relayout(t,"xaxis.range",[u,d])}):setTimeout(function(){n.relayout(t,"xaxis.range",[u,d])},16)}var c=t._fullLayout,u=c._infolayer.selectAll("g.range-slider"),f=c.xaxis.rangeslider,h=c._size.w,d=(c.height-c.margin.b-c.margin.t)*f.thickness,p=2,g=Math.floor(f.borderwidth/2),v=c.margin.l,m=c.height-d-c.margin.b,y=0,b=h,x=document.createElementNS(o,"g");s.setAttributes(x,{"class":"range-slider","data-min":y,"data-max":b,"pointer-events":"all",transform:"translate("+v+","+m+")" -});var _=document.createElementNS(o,"rect"),w=f.borderwidth%2===0?f.borderwidth:f.borderwidth-1;s.setAttributes(_,{fill:f.bgcolor,stroke:f.bordercolor,"stroke-width":f.borderwidth,height:d+w,width:h+w,transform:"translate(-"+g+", -"+g+")","shape-rendering":"crispEdges"});var k=document.createElementNS(o,"rect");s.setAttributes(k,{x:0,width:y,height:d,fill:"rgba(0,0,0,0.4)"});var A=document.createElementNS(o,"rect");s.setAttributes(A,{x:b,width:h-b,height:d,fill:"rgba(0,0,0,0.4)"});var M=document.createElementNS(o,"g"),T=document.createElementNS(o,"rect"),E=document.createElementNS(o,"rect");s.setAttributes(M,{transform:"translate("+(y-p-1)+")"}),s.setAttributes(T,{width:10,height:d,x:-6,fill:"transparent",cursor:"col-resize"}),s.setAttributes(E,{width:p,height:d/2,y:d/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(M,[E,T]);var L=document.createElementNS(o,"g"),S=document.createElementNS(o,"rect"),C=document.createElementNS(o,"rect");s.setAttributes(L,{transform:"translate("+b+")"}),s.setAttributes(S,{width:10,height:d,x:-2,fill:"transparent",cursor:"col-resize"}),s.setAttributes(C,{width:p,height:d/2,y:d/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(L,[C,S]);var z=document.createElementNS(o,"rect");s.setAttributes(z,{x:y,width:b-y,height:d,cursor:"ew-resize",fill:"transparent"}),x.addEventListener("mousedown",function(t){function e(t){var e=+t.clientX-a;switch(i){case z:x.style.cursor="ew-resize",r(+l+e,+s+e);break;case T:x.style.cursor="col-resize",r(+s+e,+l);break;case S:x.style.cursor="col-resize",r(+s,+l+e);break;default:x.style.cursor="ew-resize",r(o,o+e)}}function n(){window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",n),x.style.cursor="auto"}var i=t.target,a=t.clientX,o=a-x.getBoundingClientRect().left,s=x.getAttribute("data-min"),l=x.getAttribute("data-max");window.addEventListener("mousemove",e),window.addEventListener("mouseup",n)}),f.range||(f.range=i.getAutoRange(c.xaxis));var P=l(t,h,d);s.appendChildren(x,[_,P,k,A,z,M,L]),e(c.xaxis.range[0],c.xaxis.range[1]),u.data([0]).enter().append(function(){return f.setRange=e,x})}},{"../../constants/xmlns_namespaces":369,"../../lib":381,"../../plotly":400,"../../plots/cartesian/axes":403,"./helpers":360,"./range_plot":362}],359:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(t,e){return n.coerce(s,l,i,t,e)}if(t[r].rangeslider){var s="object"==typeof t[r].rangeslider?t[r].rangeslider:{},l=e[r].rangeslider={};if(o("bgcolor"),o("bordercolor"),o("borderwidth"),o("thickness"),o("visible"),o("range"),l.range&&!e[r].autorange){var c=l.range,u=e[r].range;c[0]=Math.min(c[0],u[0]),c[1]=Math.max(c[1],u[1])}else e[r]._needsExpand=!0;l.visible&&a.forEach(function(t){var r=e[t]||{};r.fixedrange=!0,e[t]=r})}}},{"../../lib":381,"./attributes":357}],360:[function(t,e,r){"use strict";r.setAttributes=function(t,e){for(var r in e)t.setAttribute(r,e[r])},r.appendChildren=function(t,e){for(var r=0;rl;l++){var c=s[l],u={_fullLayout:e},f=x.coerceRef(t,n,u,c);if("path"!==o){var h=.25,d=.75;if("paper"!==f){var p=x.getFromId(u,f),g=a(p);h=g(p.range[0]+h*(p.range[1]-p.range[0])),d=g(p.range[0]+d*(p.range[1]-p.range[0]))}r(c+"0",h),r(c+"1",d)}}return"path"===o?r("path"):b.noneOrAll(t,n,["x0","x1","y0","y1"]),n}function i(t){return"category"===t.type?t.c2l:t.d2l}function a(t){return"category"===t.type?t.l2c:t.l2d}function o(t,e){t.layout.shapes=e,k.supplyLayoutDefaults(t.layout,t._fullLayout),k.drawAll(t)}function s(t){delete t.layout.shapes,t._fullLayout.shapes=[],k.drawAll(t)}function l(t,e,r){for(var n=0;ne;i--)h(t,i).selectAll('[data-index="'+(i-1)+'"]').attr("data-index",i),k.draw(t,i)}function f(t,e,r,o){function s(e){var r=e.append("path").attr(z).style("opacity",S.opacity).call(_.stroke,P).call(_.fill,S.fillcolor).call(w.dashLine,S.line.dash,S.line.width);C&&r.call(w.setClipUrl,"clip"+t._fullLayout._uid+C)}var l,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},p={};"string"==typeof r&&r?p[r]=o:b.isPlainObject(r)&&(p=r);var v=Object.keys(p);for(l=0;ll;l++){var k=y[l];if(void 0===p[k]&&void 0!==u[k]){var A,M=k.charAt(0),T=x.getFromId(t,x.coerceRef(f,{},t,M)),E=x.getFromId(t,x.coerceRef(u,{},t,M)),L=u[k];void 0!==p[M+"ref"]&&(T?(A=i(T)(L),L=(A-T.range[0])/(T.range[1]-T.range[0])):L=(L-E.domain[0])/(E.domain[1]-E.domain[0]),E?(A=E.range[0]+L*(E.range[1]-E.range[0]),L=a(E)(A)):L=T.domain[0]+L*(T.domain[1]-T.domain[0])),u[k]=L}}var S=n(u,t._fullLayout);t._fullLayout.shapes[e]=S;var C,z={"data-index":e,"fill-rule":"evenodd",d:g(t,S)},P=S.line.width?S.line.color:"rgba(0,0,0,0)";if("below"!==S.layer)C=(S.xref+S.yref).replace(/paper/g,""),s(t._fullLayout._shapeUpperLayer);else if("paper"===S.xref&&"paper"===S.yref)C="",s(t._fullLayout._shapeLowerLayer);else{var R,O=t._fullLayout._plots||{},I=Object.keys(O);for(l=0,c=I.length;c>l;l++)R=O[I[l]],C=I[l],d(t,S,R.id)&&s(R.shapelayer)}}}function h(t,e){var r=t._fullLayout.shapes[e],n=t._fullLayout._shapeUpperLayer;return r?"below"===r.layer&&(n="paper"===r.xref&&"paper"===r.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):console.log("getShapeLayer: undefined shape: index",e),n}function d(t,e,r){var n=y.Axes.getFromId(t,r,"x")._id,i=y.Axes.getFromId(t,r,"y")._id;return"below"===e.layer&&(n===e.xref||i===e.yref)}function p(t){return function(e){return t(e.replace("_"," "))}}function g(t,e){var r,n,a,o,s=e.type,l=x.getFromId(t,e.xref),c=x.getFromId(t,e.yref),u=t._fullLayout._size;if(l?(r=i(l),n=function(t){return l._offset+l.l2p(r(t,!0))}):n=function(t){return u.l+u.w*t},c?(a=i(c),o=function(t){return c._offset+c.l2p(a(t,!0))}):o=function(t){return u.t+u.h*(1-t)},"path"===s)return l&&"date"===l.type&&(n=p(n)),c&&"date"===c.type&&(o=p(o)),k.convertPath(e.path,n,o);var f=n(e.x0),h=n(e.x1),d=o(e.y0),g=o(e.y1);if("line"===s)return"M"+f+","+d+"L"+h+","+g;if("rect"===s)return"M"+f+","+d+"H"+h+"V"+g+"H"+f+"Z";var v=(f+h)/2,m=(d+g)/2,y=Math.abs(v-f),b=Math.abs(m-d),_="A"+y+","+b,w=v+y+","+m,A=v+","+(m-b);return"M"+w+_+" 0 1,1 "+A+_+" 0 0,1 "+w+"Z"}function v(t,e,r,n,i){var a="category"===t.type?Number:t.d2c;if(void 0!==e)return[a(e),a(r)];if(n){var o,s,l,c,u,f=1/0,h=-(1/0),d=n.match(A);for("date"===t.type&&(a=p(a)),o=0;ou&&(f=u),u>h&&(h=u)));return h>=f?[f,h]:void 0}}var m=t("fast-isnumeric"),y=t("../../plotly"),b=t("../../lib"),x=t("../../plots/cartesian/axes"),_=t("../color"),w=t("../drawing"),k=e.exports={};k.layoutAttributes=t("./attributes"),k.supplyLayoutDefaults=function(t,e){for(var r=t.shapes||[],i=e.shapes=[],a=0;as&&(t="X"),t});return n>s&&(l=l.replace(/[\s,]*X.*/,""),console.log("ignoring extra params in segment "+t)),i+l})},k.calcAutorange=function(t){var e,r,n,i,a,o=t._fullLayout,s=o.shapes;if(s.length&&t._fullData.length)for(e=0;eh?r=h:(u.left-=b.offsetLeft,u.right-=b.offsetLeft,u.top-=b.offsetTop,u.bottom-=b.offsetTop,b.selection.each(function(){var t=l.bBox(this);s.bBoxIntersect(u,t,c)&&(r=Math.max(r,o*(t[b.side]-u[a])+c))}),r=Math.min(h,r)),r>0||0>h){var d={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[b.side];e.attr("transform","translate("+d+")")}}}function p(){E=0,L=!0,S=z,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)})}var g=r.propContainer,v=r.propName,m=r.traceIndex,y=r.dfltName,b=r.avoid||{},x=r.attributes,_=r.transform,w=r.containerGroup,k=t._fullLayout,A=g.titlefont.family,M=g.titlefont.size,T=g.titlefont.color,E=1,L=!1,S=g.title.trim();""===S&&(E=0),S.match(/Click to enter .+ title/)&&(E=.2,L=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var z="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==m?a.restyle(t,v,e,m):a.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(x).selectAll("tspan.line").attr(x)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",L)}},{"../../lib":381,"../../lib/svg_text_utils":393,"../../plotly":400,"../../plots/plots":452,"../color":303,"../drawing":325,d3:72,"fast-isnumeric":76}],366:[function(t,e,r){"use strict";e.exports={solid:[1],dot:[1,1],dash:[4,1],longdash:[8,1],dashdot:[4,1,1,1],longdashdot:[8,1,1,1]}},{}],367:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],368:[function(t,e,r){"use strict";e.exports={circle:"\u25cf","circle-open":"\u25cb",square:"\u25a0","square-open":"\u25a1",diamond:"\u25c6","diamond-open":"\u25c7",cross:"+",x:"\u274c"}},{}],369:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],370:[function(t,e,r){"use strict";var n=t("./plotly");r.version="1.11.0",r.plot=n.plot,r.newPlot=n.newPlot,r.restyle=n.restyle,r.relayout=n.relayout,r.redraw=n.redraw,r.extendTraces=n.extendTraces,r.prependTraces=n.prependTraces,r.addTraces=n.addTraces,r.deleteTraces=n.deleteTraces,r.moveTraces=n.moveTraces,r.purge=n.purge,r.setPlotConfig=t("./plot_api/set_plot_config"),r.register=n.register,r.toImage=t("./plot_api/to_image"),r.downloadImage=t("./snapshot/download"),r.Icons=t("../build/ploticon"),r.Plots=n.Plots,r.Fx=n.Fx,r.Snapshot=n.Snapshot,r.PlotSchema=n.PlotSchema,r.Queue=n.Queue,r.d3=t("d3")},{"../build/ploticon":2,"./plot_api/set_plot_config":398,"./plot_api/to_image":399,"./plotly":400,"./snapshot/download":467,d3:72}],371:[function(t,e,r){"use strict";"undefined"!=typeof MathJax?(r.MathJax=!0,MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:!0,displayAlign:"left",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]}}),MathJax.Hub.Configured()):r.MathJax=!1},{}],372:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){Array.isArray(t)&&(e[r]=t[n])}},{}],373:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("./nested_property"),o=t("../components/colorscale/get_scale"),s=(Object.keys(t("../components/colorscale/scales")),/^([2-9]|[1-9][0-9]+)$/);r.valObjects={data_array:{coerceFunction:function(t,e,r){Array.isArray(t)?e.set(t):void 0!==r&&e.set(r)}},enumerated:{coerceFunction:function(t,e,r,n){n.coerceNumber&&(t=+t),-1===n.values.indexOf(t)?e.set(r):e.set(t)}},"boolean":{coerceFunction:function(t,e,r){t===!0||t===!1?e.set(t):e.set(r)}},number:{coerceFunction:function(t,e,r,i){!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if(n.strict===!0&&"string"!=typeof t)return void e.set(r);var i=String(t);void 0===t||n.noBlank===!0&&!i?e.set(r):e.set(i)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r){var n=r.length;return"string"==typeof t&&t.substr(0,n)===r&&s.test(t.substr(n))?void e.set(t):void e.set(r)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"!=typeof t)return void e.set(r);if(-1!==n.extras.indexOf(t))return void e.set(t);for(var i=t.split("+"),a=0;a2)return!1;var l=o[0].split("-");if(l.length>3||3!==l.length&&o[1])return!1;if(4===l[0].length)r=Number(l[0]);else{if(2!==l[0].length)return!1;var c=(new Date).getFullYear();r=((Number(l[0])-c+70)%100+200)%100+c-70}return s(r)?1===l.length?new Date(r,0,1).getTime():(n=Number(l[1])-1,l[1].length>2||!(n>=0&&11>=n)?!1:2===l.length?new Date(r,n,1).getTime():(i=Number(l[2]),l[2].length>2||!(i>=1&&31>=i)?!1:(i=new Date(r,n,i).getTime(),o[1]?(l=o[1].split(":"),l.length>3?!1:(a=Number(l[0]),l[0].length>2||!(a>=0&&23>=a)?!1:(i+=36e5*a,1===l.length?i:(n=Number(l[1]),l[1].length>2||!(n>=0&&59>=n)?!1:(i+=6e4*n,2===l.length?i:(t=Number(l[2]),t>=0&&60>t?i+1e3*t:!1)))))):i))):!1},r.isDateTime=function(t){return r.dateTime2ms(t)!==!1},r.ms2DateTime=function(t,e){if("undefined"==typeof o)return void console.log("d3 is not defined");e||(e=0);var r=new Date(t),i=o.time.format("%Y-%m-%d")(r);return 7776e6>e?(i+=" "+n(r.getHours(),2),432e6>e&&(i+=":"+n(r.getMinutes(),2),108e5>e&&(i+=":"+n(r.getSeconds(),2),3e5>e&&(i+="."+n(r.getMilliseconds(),3)))),i.replace(/([:\s]00)*\.?[0]*$/,"")):i};var l={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},c={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},u=o.time.format.utc,f={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(u),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(u)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(u)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){c[t].forEach(function(e){f[t].D.push(u(e)),["H","I","D"].forEach(function(r){l[r].forEach(function(n){var i=f[t][r];i.push(u(e+"~"+n)),i.push(u(n+"~"+e))})})})});var h=/[a-z]*/g,d=function(t){return t.substr(0,3)},p=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,g=/[\s,\/\-\.\(\)]+/g,v=/~?([ap])~?m(~|$)/,m=function(t,e){return e+"m "},y=/\d\d\d\d/,b=/(^|~)[a-z]{3}/,x=/[ap]m/,_=/:/,w=/q([1-4])/,k=["31~mar","30~jun","30~sep","31~dec"],A=function(t,e){return k[e-1]},M=/ ?([+\-]\d\d:?\d\d|Z)$/;r.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(h,d).replace(p,"").replace(g,"~").replace(v,m).replace(w,A).trim().replace(M,"");var e,r,n=null,o=i(t),s=a(t);e=f[o][s],r=e.length;for(var l=0;r>l&&!(n=e[l].parse(t));l++);if(!(n instanceof Date))return!1;var c=n.getTimezoneOffset();return n.setTime(n.getTime()+60*c*1e3),n}},{d3:72,"fast-isnumeric":76}],375:[function(t,e,r){"use strict";var n=t("events").EventEmitter,i={init:function(t){if(t._ev instanceof n)return t;var e=new n;return t._ev=e,t.on=e.on.bind(e),t.once=e.once.bind(e),t.removeListener=e.removeListener.bind(e),t.removeAllListeners=e.removeAllListeners.bind(e),t.emit=function(r,n){"undefined"!=typeof jQuery&&jQuery(t).trigger(r,n),e.emit(r,n)},t},triggerHandler:function(t,e,r){var n,i;"undefined"!=typeof jQuery&&(n=jQuery(t).triggerHandler(e,r));var a=t._ev;if(!a)return n;var o=a._events[e];if(!o)return n;"function"==typeof o&&(o=[o]);for(var s=o.pop(),l=0;lp;p++){o=t[p];for(s in o)l=h[s],c=o[s],e&&c&&(i(c)||(u=a(c)))?(u?(u=!1,f=l&&a(l)?l:[]):f=l&&i(l)?l:{},h[s]=n([f,c],e,r)):("undefined"!=typeof c||r)&&(h[s]=c)}return h}var i=t("./is_plain_object.js"),a=Array.isArray;r.extendFlat=function(){return n(arguments,!1,!1)},r.extendDeep=function(){return n(arguments,!0,!1)},r.extendDeepAll=function(){return n(arguments,!0,!0)}},{"./is_plain_object.js":382}],377:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=0;ry;y++)f=s(p,y),d=l(e,y),m[y]=n(f,d);else m=n(p,e);return m}var s=t("tinycolor2"),l=t("fast-isnumeric"),c=t("../components/colorscale/make_scale_function"),u=t("../components/color/attributes").defaultLine,f=t("./str2rgbarray"),h=1;e.exports=o},{"../components/color/attributes":302,"../components/colorscale/make_scale_function":319,"./str2rgbarray":392,"fast-isnumeric":76,tinycolor2:233}],380:[function(t,e,r){"use strict";function n(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(e>r)break;t=t.slice(0,e)+l(t.slice(e+5,r))+t.slice(r+6)}return t}function i(t){return t.replace(/\/g,"\n")}function a(t){return t.replace(/\<.*\>/g,"")}function o(t){for(var e=0;(e=t.indexOf("&",e))>=0;){var r=t.indexOf(";",e);if(e>r)e+=1;else{var n=c[t.slice(e+1,r)];t=n?t.slice(0,e)+n+t.slice(r+1):t.slice(0,e)+t.slice(r+1)}}return t}function s(t){return""+o(a(n(i(t))))}var l=t("superscript-text"),c={mu:"\u03bc",amp:"&",lt:"<",gt:">"};e.exports=s},{"superscript-text":222}],381:[function(t,e,r){"use strict";var n=t("d3"),i=e.exports={};i.nestedProperty=t("./nested_property"),i.isPlainObject=t("./is_plain_object");var a=t("./coerce");i.valObjects=a.valObjects,i.coerce=a.coerce,i.coerce2=a.coerce2,i.coerceFont=a.coerceFont;var o=t("./dates");i.dateTime2ms=o.dateTime2ms,i.isDateTime=o.isDateTime,i.ms2DateTime=o.ms2DateTime,i.parseDate=o.parseDate;var s=t("./search");i.findBin=s.findBin,i.sorterAsc=s.sorterAsc,i.sorterDes=s.sorterDes,i.distinctVals=s.distinctVals,i.roundUp=s.roundUp;var l=t("./stats");i.aggNums=l.aggNums,i.len=l.len,i.mean=l.mean,i.variance=l.variance,i.stdev=l.stdev,i.interp=l.interp;var c=t("./matrix");i.init2dArray=c.init2dArray,i.transposeRagged=c.transposeRagged,i.dot=c.dot,i.translationMatrix=c.translationMatrix,i.rotationMatrix=c.rotationMatrix,i.rotationXYMatrix=c.rotationXYMatrix,i.apply2DTransform=c.apply2DTransform,i.apply2DTransform2=c.apply2DTransform2;var u=t("./extend");i.extendFlat=u.extendFlat,i.extendDeep=u.extendDeep,i.extendDeepAll=u.extendDeepAll,i.notifier=t("./notifier"),i.swapAttrs=function(t,e,r,n){r||(r="x"),n||(n="y");for(var a=0;ar?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},i.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},i.identity=function(t){return t},i.randstr=function f(t,e,r){if(r||(r=16),void 0===e&&(e=24),0>=e)return"0";var n,i,a,o=Math.log(Math.pow(2,e))/Math.log(r),s="";for(n=2;o===1/0;n*=2)o=Math.log(Math.pow(2,e/n))/Math.log(r)*n;var l=o-Math.floor(o);for(n=0;n-1||c!==1/0&&c>=Math.pow(2,e)?f(t,e,r):s},i.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={};return r.optionList=[],r._newoption=function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)},r["_"+e]=t,r},i.smooth=function(t,e){if(e=Math.round(e)||0,2>e)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,c=new Array(l),u=new Array(o);for(r=0;l>r;r++)c[r]=(1-Math.cos(Math.PI*(r+1)/e))/(2*e);for(r=0;o>r;r++){for(a=0,n=0;l>n;n++)i=r+n+1-e,-o>i?i-=s*Math.round(i/s):i>=s&&(i-=s*Math.floor(i/s)),0>i?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*c[n];u[r]=a}return u},i.promiseError=function(t){console.log(t,t.stack)},i.syncOrAsync=function(t,e,r){function n(){return i.markTime("async done "+o.name),i.syncOrAsync(t,e,r)}for(var a,o;t.length;){if(o=t.splice(0,1)[0],a=o(e),a&&a.then)return a.then(n).then(void 0,i.promiseError);i.markTime("sync done "+o.name)}return r&&r(e)},i.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},i.noneOrAll=function(t,e,r){if(t){var n,i,a=!1,o=!0;for(n=0;ni;i++)e[i][r]=t[i]},i.minExtend=function(t,e){var r={};"object"!=typeof e&&(e={});var n,a,o,s=3,l=Object.keys(t);for(n=0;nn;n++)r[n]=new Array(e);return r},r.transposeRagged=function(t){var e,r,n=0,i=t.length;for(e=0;i>e;e++)n=Math.max(n,t[e].length);var a=new Array(n);for(e=0;n>e;e++)for(a[e]=new Array(i),r=0;i>r;r++)a[e][r]=t[r][e];return a},r.dot=function(t,e){if(!t.length||!e.length||t.length!==e.length)return null;var n,i,a=t.length;if(t[0].length)for(n=new Array(a),i=0;a>i;i++)n[i]=r.dot(t[i],e);else if(e[0].length){var o=r.transposeRagged(e);for(n=new Array(o.length),i=0;ii;i++)n+=t[i]*e[i];return n},r.translationMatrix=function(t,e){return[[1,0,t],[0,1,e],[0,0,1]]},r.rotationMatrix=function(t){var e=t*Math.PI/180;return[[Math.cos(e),-Math.sin(e),0],[Math.sin(e),Math.cos(e),0],[0,0,1]]},r.rotationXYMatrix=function(t,e,n){return r.dot(r.dot(r.translationMatrix(e,n),r.rotationMatrix(t)),r.translationMatrix(-e,-n))},r.apply2DTransform=function(t){return function(){var e=arguments;3===e.length&&(e=e[0]);var n=1===arguments.length?e[0]:[e[0],e[1]];return r.dot(t,[n[0],n[1],1]).slice(0,2)}},r.apply2DTransform2=function(t){var e=r.apply2DTransform(t);return function(t){return e(t.slice(0,2)).concat(e(t.slice(2,4)))}}},{}],384:[function(t,e,r){"use strict";function n(t,e){return function(){var r,i,a,o,s,l=t;for(o=0;o=0;e--){if(n=t[e],o=!1,Array.isArray(n))for(r=n.length-1;r>=0;r--)c(n[r])?o?n[r]=void 0:n.pop():o=!0;else if("object"==typeof n&&null!==n)for(a=Object.keys(n),o=!1,r=a.length-1;r>=0;r--)c(n[a[r]])&&!i(n[a[r]],a[r])?delete n[a[r]]:o=!0;if(o)return}}function c(t){return void 0===t||null===t?!0:"object"!=typeof t?!1:Array.isArray(t)?!t.length:!Object.keys(t).length}function u(t,e,r){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:r,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,l=e.split(".");sr||r>a||o>n||n>s?!1:!e||!c(t)}function r(t,e){var r=t[0],l=t[1];if(i>r||r>a||o>l||l>s)return!1;var c,u,f,h,d,p=n.length,g=n[0][0],v=n[0][1],m=0;for(c=1;p>c;c++)if(u=g,f=v,g=n[c][0],v=n[c][1],h=Math.min(u,g),!(h>r||r>Math.max(u,g)||l>Math.max(f,v)))if(l=l&&r!==h&&m++}return m%2===1}var n=t.slice(),i=n[0][0],a=i,o=n[0][1],s=o;n.push(n[0]);for(var l=1;la;a++)if(o=[t[a][0]-l[0],t[a][1]-l[1]],s=n(o,c),0>s||s>u||Math.abs(n(o,h))>i)return!0;return!1};i.filter=function(t,e){function r(r){t.push(r);var s=n.length,l=i;n.splice(o+1);for(var c=l+1;c1){var s=t.pop();r(s)}return{addPt:r,raw:t,filtered:n}}},{"./matrix":383}],387:[function(t,e,r){"use strict";function n(t,e){for(var r,n=[],a=0;a=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;rt}function i(t,e){return e>=t}function a(t,e){return t>e}function o(t,e){return t>=e}var s=t("fast-isnumeric");r.findBin=function(t,e,r){if(s(e.start))return r?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var l,c,u=0,f=e.length,h=0;for(c=e[e.length-1]>=e[0]?r?n:i:r?o:a;f>u&&h++<100;)l=Math.floor((u+f)/2),c(e[l],t)?u=l+1:f=l;return h>90&&console.log("Long binary search..."),u-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;n>s;s++)e[s+1]>e[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,c=r?Math.ceil:Math.floor;a>i&&o++<100;)n=c((i+a)/2),e[n]<=t?i=n+s:a=n-l;return e[i]}},{"fast-isnumeric":76}],389:[function(t,e,r){"use strict";e.exports=function(t,e){(t.attr("class")||"").split(" ").forEach(function(e){0===e.indexOf("cursor-")&&t.classed(e,!1)}),e&&t.classed("cursor-"+e,!0)}},{}],390:[function(t,e,r){"use strict";var n=t("../components/color"),i=function(){};e.exports=function(t){for(var e in t)"function"==typeof t[e]&&(t[e]=i);t.destroy=function(){t.container.parentNode.removeChild(t.container)};var r=document.createElement("div");return r.textContent="Webgl is not supported by your browser - visit http://get.webgl.org for more info",r.style.cursor="pointer",r.style.fontSize="24px",r.style.color=n.defaults[0],t.container.appendChild(r),t.container.style.background="#FFFFFF",t.container.onclick=function(){window.open("http://get.webgl.org")},!1}},{"../components/color":303}],391:[function(t,e,r){"use strict";var n=t("fast-isnumeric");r.aggNums=function(t,e,i,a){var o,s;if(a||(a=i.length),n(e)||(e=!1),Array.isArray(i[0])){for(s=new Array(a),o=0;a>o;o++)s[o]=r.aggNums(t,e,i[o]);i=s}for(o=0;a>o;o++)n(e)?n(i[o])&&(e=t(+e,+i[o])):e=i[o];return e},r.len=function(t){return r.aggNums(function(t){return t+1},0,t)},r.mean=function(t,e){return e||(e=r.len(t)),r.aggNums(function(t,e){return t+e},0,t)/e},r.variance=function(t,e,i){return e||(e=r.len(t)),n(i)||(i=r.mean(t,e)),r.aggNums(function(t,e){return t+Math.pow(e-i,2)},0,t)/e},r.stdev=function(t,e,n){return Math.sqrt(r.variance(t,e,n))},r.interp=function(t,e){if(!n(e))throw"n should be a finite number";if(e=e*t.length-.5,0>e)return t[0];if(e>t.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"fast-isnumeric":76}],392:[function(t,e,r){"use strict";function n(t){return t=i(t),a.str2RgbaArray(t.toRgbString())}var i=t("tinycolor2"),a=t("arraytools");e.exports=n},{arraytools:49,tinycolor2:233}],393:[function(t,e,r){"use strict";function n(t,e){return t.node().getBoundingClientRect()[e]}function i(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function a(t,e,r){var n="math-output-"+l.Lib.randstr([],64),a=c.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(i(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,a.node()],function(){var e=c.select("body").select("#MathJax_SVG_glyphs");if(a.select(".MathJax_SVG").empty()||!a.select("svg").node())console.log("There was an error in the tex syntax.",t),r();else{var n=a.select("svg").node().getBoundingClientRect();r(a.select(".MathJax_SVG"),e,n)}a.remove()})}function o(t){for(var e=l.util.html_entity_decode(t),r=e.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),r=e&&e[2].toLowerCase(),n=h[r];if(void 0!==n){var i=e[1],a=e[3],o=a.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===r){if(i)return"";if("href"!==a.substr(0,4).toLowerCase())return"";var s=document.createElement("a");return s.href=a.substr(4).replace(/["'=]/g,""),-1===d.indexOf(s.protocol)?"":'"}if("br"===r)return"
";if(i)return"sup"===r?'':"sub"===r?'':"";var c=""}return l.util.xml_entity_encode(t).replace(/");i>0;i=r.indexOf("
",i+1))n.push(i);var a=0;n.forEach(function(t){for(var e=t+a,n=r.slice(0,e),i="",o=n.length-1;o>=0;o--){var s=n[o].match(/<(\/?).*>/i);if(s&&"
"!==n[o]){s[1]||(i=n[o]);break}}i&&(r.splice(e+1,0,i),r.splice(e,0,""),a+=2)});var o=r.join(""),s=o.split(/
/gi);return s.length>1&&(r=s.map(function(t,e){return''+t+""})),r.join("")}function s(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-c.top+"px",left:a()-c.left+"px","z-index":1e3}),this}}var l=t("../plotly"),c=t("d3"),u=t("../constants/xmlns_namespaces"),f=e.exports={};c.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),r=(new DOMParser).parseFromString(e,"application/xml"),n=r.documentElement.firstChild;n;)this.node().appendChild(this.node().ownerDocument.importNode(n,!0)),n=n.nextSibling;return r.querySelector("parsererror")?(console.log(r.querySelector("parsererror div").textContent),null):c.select(this.node().lastChild)},f.html_entity_decode=function(t){var e=c.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),r},f.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},f.convertToTspans=function(t,e){function r(){d.empty()||(p=u.attr("class")+"-math",d.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),h=t.appendSVG(s),h||t.text(i),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(u)}var i=t.text(),s=o(i),u=t,f=!u.attr("data-notex")&&s.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),h=i,d=c.select(u.node().parentNode);if(!d.empty()){var p=u.attr("class")?u.attr("class").split(" ")[0]:"text";p+="-math",d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=l.Lib.getPlotDiv(u.node());(v&&v._promises||[]).push(new Promise(function(t){u.style({visibility:"hidden"});var i={fontSize:parseInt(u.style("font-size"),10)};a(f[2],i,function(i,a,o){d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove();var s=i&&i.select("svg");if(!s||!s.node())return r(),void t();var l=d.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});l.node().appendChild(s.node()),a&&a.node()&&s.node().insertBefore(a.node().cloneNode(!0),s.node().firstChild),s.attr({"class":p,height:o.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=u.style("fill")||"black";s.select("g").attr({fill:c,stroke:c});var f=n(s,"width"),h=n(s,"height"),g=+u.attr("x")-f*{start:0,middle:.5,end:1}[u.attr("text-anchor")||"start"],v=parseInt(u.style("font-size"),10)||n(u,"height"),m=-v/4;"y"===p[0]?(l.attr({transform:"rotate("+[-90,+u.attr("x"),+u.attr("y")]+") translate("+[-f/2,m-h/2]+")"}),s.attr({x:+u.attr("x"),y:+u.attr("y")})):"l"===p[0]?s.attr({x:u.attr("x"),y:m-h/2}):"a"===p[0]?s.attr({x:0,y:m}):s.attr({x:g,y:+u.attr("y")+m-h/2}),e&&e.call(u,l),t(l)})}))}else r();return t}};var h={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},d=["http:","https:","mailto:"],p=new RegExp("]*)?/?>","g");f.plainText=function(t){return(t||"").replace(p," ")},f.makeEditable=function(t,e,r){function n(){a(),o.style({opacity:0});var t,e=h.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0})}function i(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}function a(){var t=c.select(l.Lib.getPlotDiv(o.node())),e=t.select(".svg-container"),n=e.append("div");n.classed("plugin-editable editable",!0).style({position:"absolute","font-family":o.style("font-family")||"Arial","font-size":o.style("font-size")||12,color:r.fill||o.style("fill")||"black",opacity:1,"background-color":r.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(o.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(r.text||o.attr("data-unformatted")).call(s(o,e,r)).on("blur",function(){o.text(this.textContent).style({opacity:1});var t,e=c.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0});var r=this.textContent;c.select(this).transition().duration(0).remove(),c.select(document).on("mouseup",null),u.edit.call(o,r)}).on("focus",function(){var t=this;c.select(document).on("mouseup",function(){return c.event.target===t?!1:void(document.activeElement===n.node()&&n.node().blur())})}).on("keyup",function(){27===c.event.which?(o.style({opacity:1}),c.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),u.cancel.call(o,this.textContent)):(u.input.call(o,this.textContent),c.select(this).call(s(o,e,r)))}).on("keydown",function(){13===c.event.which&&this.blur()}).call(i)}r||(r={});var o=this,u=c.dispatch("edit","input","cancel"),f=c.select(this.node()).style({"pointer-events":"all"}),h=e||f;return e&&f.style({"pointer-events":"none"}),r.immediate?n():h.on("click",n),c.rebind(this,u,"on")}},{"../constants/xmlns_namespaces":369,"../plotly":400,d3:72}],394:[function(t,e,r){"use strict";var n=e.exports={},i=t("../plots/geo/constants").locationmodeToLayer,a=t("topojson").feature;n.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},n.getTopojsonPath=function(t,e){return t+e+".json"},n.getTopojsonFeatures=function(t,e){var r=i[t.locationmode],n=e.objects[r];return a(e,n).features}},{"../plots/geo/constants":422,topojson:234}],395:[function(t,e,r){"use strict";function n(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function i(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function a(t,e){t._context||(t._context=R.extendFlat({},P.defaultConfig));var r=t._context;e&&(Object.keys(e).forEach(function(t){t in r&&("setBackground"===t&&"opaque"===e[t]?r[t]=i:r[t]=e[t])}),e.plot3dPixelRatio&&!r.plotGlPixelRatio&&(r.plotGlPixelRatio=r.plot3dPixelRatio)),r.staticPlot&&(r.editable=!1,r.autosizable=!1,r.scrollZoom=!1,r.doubleClick=!1,r.showTips=!1,r.showLink=!1,r.displayModeBar=!1)}function o(t,e,r){var n=S.select(t).selectAll(".plot-container").data([0]);n.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=n.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e),r&&(t.layout=r),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(w(t,{}),t._fullLayout.autosize=r.autosize=!0),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var a=t.framework.svg(),o=1,s=t._fullLayout.title;""!==s&&s||(o=0);var l="Click to enter title",c=function(){this.call(P.util.convertToTspans)},u=a.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":s}),s&&s!==l||(o=.2,u.attr({"data-unformatted":l}).text(l).style({opacity:o}).on("mouseover.opacity",function(){S.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){S.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),N.addLinks(t),Promise.resolve()}function s(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var n=P.Axes.list({_fullLayout:t});for(e=0;ee;e++){var o=t.annotations[e];o.ref&&("paper"===o.ref?(o.xref="paper",o.yref="paper"):"data"===o.ref&&(o.xref="x",o.yref="y"),delete o.ref),l(o,"xref"),l(o,"yref")}void 0===t.shapes||Array.isArray(t.shapes)||(console.log("shapes must be an array"),delete t.shapes);var s=(t.shapes||[]).length;for(e=0;s>e;e++){var c=t.shapes[e];l(c,"xref"),l(c,"yref")}var u=t.legend;u&&(u.x>3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var h=N.getSubplotIds(t,"gl3d");for(e=0;er;++r)b[r]=v[e]+m*y[2+4*r];d.camera={eye:{x:b[0],y:b[1],z:b[2]},center:{x:v[0],y:v[1],z:v[2]},up:{x:y[1],y:y[5],z:y[9]}},delete d.cameraposition}}return R.markTime("finished rest of cleanLayout, starting color"),F.clean(t),R.markTime("finished cleanLayout color.clean"),t}function l(t,e){var r=t[e],n=e.charAt(0);r&&"paper"!==r&&(t[e]=P.Axes.cleanId(r,n))}function c(t,e){for(var r=[],n=(t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid})),i=0;ia&&(s=R.randstr(n),-1!==r.indexOf(s));a++);o.uid=R.randstr(n),n.push(o.uid)}if(r.push(o.uid),"histogramy"===o.type&&"xbins"in o&&!("ybins"in o)&&(o.ybins=o.xbins,delete o.xbins),o.error_y&&"opacity"in o.error_y){var l=F.defaults,c=o.error_y.color||(N.traceIs(o,"bar")?F.defaultLine:l[i%l.length]);o.error_y.color=F.addOpacity(F.rgb(c),F.opacity(c)*o.error_y.opacity),delete o.error_y.opacity}if("bardir"in o&&("h"!==o.bardir||!N.traceIs(o,"bar")&&"histogram"!==o.type.substr(0,9)||(o.orientation="h",x(o)),delete o.bardir),"histogramy"===o.type&&x(o),"histogramx"!==o.type&&"histogramy"!==o.type||(o.type="histogram"),"scl"in o&&(o.colorscale=o.scl,delete o.scl),"reversescl"in o&&(o.reversescale=o.reversescl,delete o.reversescl),o.xaxis&&(o.xaxis=P.Axes.cleanId(o.xaxis,"x")),o.yaxis&&(o.yaxis=P.Axes.cleanId(o.yaxis,"y")),N.traceIs(o,"gl3d")&&o.scene&&(o.scene=N.subplotsRegistry.gl3d.cleanId(o.scene)),N.traceIs(o,"pie")||(Array.isArray(o.textposition)?o.textposition=o.textposition.map(u):o.textposition&&(o.textposition=u(o.textposition))),N.traceIs(o,"2dMap")&&("YIGnBu"===o.colorscale&&(o.colorscale="YlGnBu"),"YIOrRd"===o.colorscale&&(o.colorscale="YlOrRd")),N.traceIs(o,"markerColorscale")&&o.marker){var h=o.marker;"YIGnBu"===h.colorscale&&(h.colorscale="YlGnBu"),"YIOrRd"===h.colorscale&&(h.colorscale="YlOrRd")}if("surface"===o.type&&R.isPlainObject(o.contours)){var d=["x","y","z"];for(a=0;an?a.push(i+n):a.push(n);return a}function p(t,e,r){var n,i;for(n=0;n=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||0>i&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function g(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),p(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&p(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function v(t,e,r){var n,i;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),n=0;n=0&&l0){var s=_(t._boundingBoxMargins),l=s.left+s.right,c=s.bottom+s.top,u=a._container.node().getBoundingClientRect(),f=1-2*o.frameMargins;i=Math.round(f*(u.width-l)),n=Math.round(f*(u.height-c))}else r=window.getComputedStyle(t),n=parseFloat(r.height)||a.height,i=parseFloat(r.width)||a.width;return Math.abs(a.width-i)>1||Math.abs(a.height-n)>1?(a.height=t.layout.height=n,a.width=t.layout.width=i):"initial"!==a.autosize&&(delete e.autosize,a.autosize=t.layout.autosize=!0),N.sanitizeMargins(a),e}function k(t){var e=S.select(t),r=t._fullLayout;if(r._container=e.selectAll(".plot-container").data([0]),r._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),r._paperdiv=r._container.selectAll(".svg-container").data([0]),r._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===r.autosize&&(w(t,{}),r.autosize=!0,t.layout.autosize=!0),r._glcontainer=r._paperdiv.selectAll(".gl-container").data([0]),r._glcontainer.enter().append("div").classed("gl-container",!0),r._geocontainer=r._paperdiv.selectAll(".geo-container").data([0]),r._geocontainer.enter().append("div").classed("geo-container",!0),r._paperdiv.selectAll(".main-svg").remove(),r._paper=r._paperdiv.insert("svg",":first-child").classed("main-svg",!0),r._toppaper=r._paperdiv.append("svg").classed("main-svg",!0),!r._uid){var n=[];S.selectAll("defs").each(function(){this.id&&n.push(this.id.split("-")[1])}),r._uid=R.randstr(n)}r._paperdiv.selectAll(".main-svg").attr(W.svgAttrs),r._defs=r._paper.append("defs").attr("id","defs-"+r._uid),r._topdefs=r._toppaper.append("defs").attr("id","topdefs-"+r._uid),r._draggers=r._paper.append("g").classed("draglayer",!0);var i=r._paper.append("g").classed("layer-below",!0);r._imageLowerLayer=i.append("g").classed("imagelayer",!0),r._shapeLowerLayer=i.append("g").classed("shapelayer",!0);var a=P.Axes.getSubplots(t); -a.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,a),r._has("cartesian")&&M(t,a),r._ternarylayer=r._paper.append("g").classed("ternarylayer",!0);var o=r._paper.selectAll(".layer-subplot");r._imageSubplotLayer=o.selectAll(".imagelayer"),r._shapeSubplotLayer=o.selectAll(".shapelayer");var s=r._paper.append("g").classed("layer-above",!0);r._imageUpperLayer=s.append("g").classed("imagelayer",!0),r._shapeUpperLayer=s.append("g").classed("shapelayer",!0),r._pielayer=r._paper.append("g").classed("pielayer",!0),r._glimages=r._paper.append("g").classed("glimages",!0),r._geoimages=r._paper.append("g").classed("geoimages",!0),r._infolayer=r._toppaper.append("g").classed("infolayer",!0),r._zoomlayer=r._toppaper.append("g").classed("zoomlayer",!0),r._hoverlayer=r._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var l=R.syncOrAsync([T,function(){return P.Axes.doTicks(t,"redraw")},j.init],t);return l&&l.then&&t._promises.push(l),l}function A(t,e){function r(e,r){return function(){return P.Axes.getFromId(t,e,r)}}for(var n,i,a=t._fullLayout._plots={},o=0;o0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),A=w===_;x?t.framework===k&&!b&&A||(t.framework=k,k(t)):A?b&&k(t):(t.framework=k,k(t)),b&&P.Axes.saveRangeInitial(t);var M=t._fullLayout,E=!t.calcdata||t.calcdata.length!==(t.data||[]).length;E&&h(t);for(var L=0;LY.range[0]?[1,2]:[2,1]);else{var W=Y.range[0],Z=Y.range[1];"log"===O?(0>=W&&0>=Z&&i(q+".autorange",!0),0>=W?W=Z/1e6:0>=Z&&(Z=W/1e6),i(q+".range[0]",Math.log(W)/Math.LN10),i(q+".range[1]",Math.log(Z)/Math.LN10)):(i(q+".range[0]",Math.pow(10,W)),i(q+".range[1]",Math.pow(10,Z)))}else i(q+".autorange",!0)}if("reverse"===D)H.range?H.range.reverse():(i(q+".autorange",!0),H.range=[1,0]),G.autorange?_=!0:x=!0;else if("annotations"===z.parts[0]||"shapes"===z.parts[0]){var K=z.parts[1],$=z.parts[0],Q=p[$]||[],J=P[R.titleCase($)],tt=Q[K]||{};2===z.parts.length&&("add"===v[C]||R.isPlainObject(v[C])?E[C]="remove":"remove"===v[C]?-1===K?(E[$]=Q,delete E[C]):E[C]=tt:console.log("???",v)),!a(tt,"x")&&!a(tt,"y")||R.containsAny(C,["color","opacity","align","dash"])||(_=!0),J.draw(t,K,z.parts.slice(2).join("."),v[C]),delete v[C]}else if("images"===z.parts[0]){var rt=R.objectFromPath(e,O);R.extendDeepAll(t.layout,rt),U.supplyLayoutDefaults(t.layout,t._fullLayout),U.draw(t)}else 0===z.parts[0].indexOf("scene")?x=!0:0===z.parts[0].indexOf("geo")?x=!0:0===z.parts[0].indexOf("ternary")?x=!0:!g._has("gl2d")||-1===C.indexOf("axis")&&"plot_bgcolor"!==z.parts[0]?"hiddenlabels"===C?_=!0:-1!==z.parts[0].indexOf("legend")?m=!0:-1!==C.indexOf("title")?y=!0:-1!==z.parts[0].indexOf("bgcolor")?b=!0:z.parts.length>1&&R.containsAny(z.parts[1],["tick","exponent","grid","zeroline"])?y=!0:-1!==C.indexOf(".linewidth")&&-1!==C.indexOf("axis")?y=b=!0:z.parts.length>1&&-1!==z.parts[1].indexOf("line")?b=!0:z.parts.length>1&&"mirror"===z.parts[1]?y=b=!0:"margin.pad"===C?y=b=!0:"margin"===z.parts[0]||"autorange"===z.parts[1]||"rangemode"===z.parts[1]||"type"===z.parts[1]||"domain"===z.parts[1]||C.match(/^(bar|box|font)/)?_=!0:-1!==["hovermode","dragmode"].indexOf(C)?k=!0:-1===["hovermode","dragmode","height","width","autosize"].indexOf(C)&&(x=!0):x=!0,z.set(O)}I&&I.add(t,et,[t,E],et,[t,M]),v.autosize&&(v=w(t,v)),(v.height||v.width||v.autosize)&&(_=!0);var nt=Object.keys(v),it=[N.previousPromises];if(x||_)it.push(function(){return t.layout=void 0,_&&(t.calcdata=void 0),P.plot(t,"",p)});else if(nt.length&&(N.supplyDefaults(t),g=t._fullLayout,m&&it.push(function(){return V.draw(t),N.previousPromises(t)}),b&&it.push(T),y&&it.push(function(){return P.Axes.doTicks(t,"redraw"),L(t),N.previousPromises(t)}),k)){var at;for(X(t),at=N.getSubplotIds(g,"gl3d"),d=0;d1)};l(r.width)&&l(r.height)||o(new Error("Height and width should be pixel values."));var c=n.clone(e,{format:"png",height:r.height,width:r.width}),u=c.td;u.style.position="absolute",u.style.left="-5000px",document.body.appendChild(u);var f=n.getRedrawFunc(u);i.plot(u,c.data,c.layout,c.config).then(f).then(s).then(function(e){t(e)}).catch(function(t){o(t)})});return o}var i=t("../plotly"),a=t("fast-isnumeric");e.exports=n},{"../plotly":400,"../snapshot":469,"fast-isnumeric":76}],400:[function(t,e,r){"use strict";t("es6-promise").polyfill(),r.Lib=t("./lib"),r.util=t("./lib/svg_text_utils"),r.Queue=t("./lib/queue"),t("../build/plotcss"),r.MathJaxConfig=t("./fonts/mathjax_config"),r.defaultConfig=t("./plot_api/plot_config");var n=r.Plots=t("./plots/plots");r.Axes=t("./plots/cartesian/axes"),r.Fx=t("./plots/cartesian/graph_interact"),r.micropolar=t("./plots/polar/micropolar"),r.Color=t("./components/color"),r.Drawing=t("./components/drawing"),r.Colorscale=t("./components/colorscale"),r.Colorbar=t("./components/colorbar"),r.ErrorBars=t("./components/errorbars"),r.Annotations=t("./components/annotations"),r.Shapes=t("./components/shapes"),r.Legend=t("./components/legend"),r.Images=t("./components/images"),r.ModeBar=t("./components/modebar"),r.register=function(t){if(!t)throw new Error("No argument passed to Plotly.register.");t&&!Array.isArray(t)&&(t=[t]);for(var e=0;ec&&u>e&&(void 0===i[r]?a[f]=E.tickText(t,e):a[f]=s(t,e,String(i[r])),f++);return f=864e5?t._tickround="d":r>=36e5?t._tickround="H":r>=6e4?t._tickround="M":r>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(r/2)/Math.LN10);else{x(r)||(r=Number(r.substr(1))),t._tickround=2-Math.floor(Math.log(r)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var n=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(n)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((n-1)/3):t._tickexponent=n)}else"M"===r.charAt(0)?t._tickround=2===r.length?"m":"y":t._tickround=null}function o(t,e){var r=t.match(V),n=new Date(e);if(r){var i=Math.min(+r[1]||6,6),a=String(e/1e3%1+2.0000005).substr(2,i).replace(/0+$/,"")||"0";return b.time.format(t.replace(V,a))(n)}return b.time.format(t)(n)}function s(t,e,r){var n=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}function l(t,e,r,n){var i,a=e.x,s=t._tickround,l=new Date(a),c="";r&&t.hoverformat?i=o(t.hoverformat,a):t.tickformat?i=o(t.tickformat,a):(n&&(x(s)?s+=2:s={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[s]),"y"===s?i=N(l):"m"===s?i=j(l):(a!==t._tmin||r||(c="
"+N(l)),"d"===s?i=F(l):"H"===s?i=D(l):(a!==t._tmin||r||(c="
"+F(l)+", "+N(l)),i=B(l),"M"!==s&&(i+=U(l),"S"!==s&&(i+=h(y(a/1e3,1),t,"none",r).substr(1)))))),e.text=i+c}function c(t,e,r,n,i){var a=t.dtick,o=e.x;if(!n||"string"==typeof a&&"L"===a.charAt(0)||(a="L3"),t.tickformat||"string"==typeof a&&"L"===a.charAt(0))e.text=h(Math.pow(10,o),t,i,n);else if(x(a)||"D"===a.charAt(0)&&y(o+.01,1)<.1)if(-1!==["e","E","power"].indexOf(t.exponentformat)){var s=Math.round(o);0===s?e.text=1:1===s?e.text="10":s>1?e.text="10"+s+"":e.text="10\u2212"+-s+"",e.fontSize*=1.25}else e.text=h(Math.pow(10,o),t,"","fakehover"),"D1"===a&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==a.charAt(0))throw"unrecognized dtick "+String(a);e.text=String(Math.round(Math.pow(10,y(o,1)))),e.fontSize*=.75}if("D1"===t.dtick){var l=String(e.text).charAt(0);"0"!==l&&"1"!==l||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(0>o?.5:.25)))}}function u(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r=""),e.text=String(r)}function f(t,e,r,n,i){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide"),e.text=h(e.x,t,i,n)}function h(t,e,r,n){var i=0>t,o=e._tickround,s=r||e.exponentformat||"B",l=e._tickexponent,c=e.tickformat;if(n){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:x(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};a(u),o=(Number(u._tickround)||0)+4,l=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return b.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-o)/2;if("none"===s&&(l=0),t=Math.abs(t),f>t)t="0",i=!1;else{if(t+=f,l&&(t*=Math.pow(10,-l),o+=l),0===o)t=String(Math.floor(t));else if(0>o){t=String(Math.round(t)),t=t.substr(0,t.length+o);for(var h=o;0>h;h++)t+="0"}else{t=String(t);var p=t.indexOf(".")+1;p&&(t=t.substr(0,p+o).replace(/\.?0+$/,""))}t=d(t,e._gd._fullLayout.separators)}if(l&&"hide"!==s){var g;g=0>l?"\u2212"+-l:"power"!==s?"+"+l:String(l),"e"===s||("SI"===s||"B"===s)&&(l>12||-15>l)?t+="e"+g:"E"===s?t+="E"+g:"power"===s?t+="×10"+g+"":"B"===s&&9===l?t+="B":"SI"!==s&&"B"!==s||(t+=q[l/3+5])}return i?"\u2212"+t:t}function d(t,e){var r=e.charAt(0),n=e.charAt(1),i=t.split("."),a=i[0],o=i.length>1?r+i[1]:"";if(n&&(i.length>1||a.length>4))for(;H.test(a);)a=a.replace(H,"$1"+n+"$2");return a+o}function p(t,e){var r,n,i=[];for(r=0;r1)for(n=1;n2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},E.getAutoRange=function(t){var e,r=[],n=t._min[0].val,i=t._max[0].val;for(e=1;e0&&u>0&&f/u>h&&(l=o,c=s,h=f/u);return n===i?r=d?[n+1,"normal"!==t.rangemode?0:n-1]:["normal"!==t.rangemode?0:n-1,n+1]:h&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode&&l.val>=0?l={val:0,pad:0}:"nonnegative"===t.rangemode&&(l.val-h*l.pad<0&&(l={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),h=(c.val-l.val)/(t._length-l.pad-c.pad)),r=[l.val-h*l.pad,c.val+h*c.pad],r[0]===r[1]&&(r=[r[0]-1,r[0]+1]),d&&r.reverse()),r},E.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=E.getAutoRange(t);var r=t._gd.layout[t._name];r||(t._gd.layout[t._name]=r={}),r!==t&&(r.range=t.range.slice(),r.autorange=t.autorange)}},E.saveRangeInitial=function(t,e){for(var r=E.list(t,"",!0),n=!1,i=0;ip&&(p=g/10),c=t.c2l(p),u=t.c2l(g),y&&(c=Math.min(0,c),u=Math.max(0,u)),n(c)){for(d=!0,o=0;o=h?d=!1:s.val>=c&&s.pad<=h&&(t._min.splice(o,1),o--);d&&t._min.push({val:c,pad:y&&0===c?0:h})}if(n(u)){for(d=!0,o=0;o=u&&s.pad>=f?d=!1:s.val<=u&&s.pad<=f&&(t._max.splice(o,1),o--);d&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),r||(r={}),t._m||t.setScale();var a,o,s,l,c,u,f,h,d,p,g,v=e.length,m=r.padded?.05*t._length:0,y=r.tozero&&("linear"===t.type||"-"===t.type),b=n((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),_=n((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),w=n(r.vpadplus||r.vpad),k=n(r.vpadminus||r.vpad);for(a=0;6>a;a++)i(a);for(a=v-1;a>5;a--)i(a)}},E.autoBin=function(t,e,r,n){function i(t){return(1+100*(t-d)/f.dtick)%100<2}var a=w.aggNums(Math.min,null,t),o=w.aggNums(Math.max,null,t);if("category"===e.type)return{start:a-.5,end:o+.5,size:1};var s;if(r)s=(o-a)/r;else{var l=w.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(l.minDiff)/Math.LN10)),u=c*w.roundUp(l.minDiff/c,[.9,1.9,4.9,9.9],!0);s=Math.max(u,2*w.stdev(t)/Math.pow(t.length,n?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[a,o]};E.autoTicks(f,s);var h,d=E.tickIncrement(E.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;yg&&(p>.3*b||i(a)||i(o))){var _=f.dtick/2;d+=a>d+_?_:-_}var k=1+Math.floor((o-d)/f.dtick);h=d+k*f.dtick}else for(h=d;o>=h;)h=E.tickIncrement(h,f.dtick);return{start:d,end:h,size:f.dtick}},E.calcTicks=function(t){if("array"===t.tickmode)return n(t);if("auto"===t.tickmode||!t.dtick){var e,r=t.nticks;r||("category"===t.type?(e=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/e):(e="y"===t._id.charAt(0)?40:80,r=w.constrain(t._length/e,4,9)+1)),E.autoTicks(t,Math.abs(t.range[1]-t.range[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),a(t),t._tmin=E.tickFirst(t);var i=t.range[1]=s:s>=l)&&(o.push(l),!(o.length>1e3));l=E.tickIncrement(l,t.dtick,i));t._tmax=o[o.length-1];for(var c=new Array(o.length),u=0;u157788e5?(e/=315576e5,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*i(e,r,C)):e>12096e5?(e/=26298e5,t.dtick="M"+i(e,1,z)):e>432e5?(t.dtick=i(e,864e5,R),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=i(e,36e5,z):e>3e4?t.dtick=i(e,6e4,P):e>500?t.dtick=i(e,1e3,P):(r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,C));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var n=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/n,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+i(e,r,C)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,C));if(0===t.dtick&&(t.dtick=1),!x(t.dtick)&&"string"!=typeof t.dtick){var a=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(a)}},E.tickIncrement=function(t,e,r){var n=r?-1:1;if(x(e))return t+n*e;var i=e.charAt(0),a=n*Number(e.substr(1));if("M"===i){var o=new Date(t);return o.setMonth(o.getMonth()+a)}if("L"===i)return Math.log(Math.pow(10,t)+a)/Math.LN10;if("D"===i){var s="D2"===e?I:O,l=t+.01*n,c=w.roundUp(y(l,1),s,r);return Math.floor(l)+Math.log(b.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},E.tickFirst=function(t){var e=t.range[1]n:n>c;)c=E.tickIncrement(c,i,e);return c}if("L"===u)return Math.log(r((Math.pow(10,n)-a)/f)*f+a)/Math.LN10;if("D"===u){var h="D2"===i?I:O,d=w.roundUp(y(n,1),h,e);return Math.floor(n)+Math.log(b.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(i)};var N=b.time.format("%Y"),j=b.time.format("%b %Y"),F=b.time.format("%b %-d"),D=b.time.format("%b %-d %Hh"),B=b.time.format("%H:%M"),U=b.time.format(":%S"),V=/%(\d?)f/g;E.tickText=function(t,e,r){function n(n){var i;return void 0===n?!0:r?"none"===n:(i={first:t._tmin,last:t._tmax}[n],"all"!==n&&e!==i)}var i,a,o=s(t,e),h="array"===t.tickmode,d=r||h;if(h&&Array.isArray(t.ticktext)){var p=Math.abs(t.range[1]-t.range[0])/1e4;for(a=0;a1&&er&&(M=90),i(u,M)}c._lastangle=M}return o(e),e+" done"}function l(){c._boundingBox=r.node().getBoundingClientRect()}var u=r.selectAll("g."+C).data(y,S);if(!c.showticklabels||!x(n))return u.remove(),void o(e);var f,h,p,m,_;"x"===v?(_="bottom"===B?1:-1,f=function(t){return t.dx+I*_},m=n+(O+R)*_,h=function(t){return t.dy+m+t.fontSize*("bottom"===B?1:-.5)},p=function(t){return x(t)&&0!==t&&180!==t?0>t*_?"end":"start":"middle"}):(_="right"===B?1:-1,h=function(t){return t.dy+t.fontSize/2-I*_},f=function(t){return t.dx+n+(O+R+(90===Math.abs(c.tickangle)?t.fontSize/2:0))*_},p=function(t){return x(t)&&90===Math.abs(t)?"middle":"right"===B?"start":"end"});var A=0,M=0,E=[];u.enter().append("g").classed(C,1).append("text").attr("text-anchor","middle").each(function(e){var r=b.select(this),n=t._promises.length;r.call(T.setPosition,f(e),h(e)).call(T.font,e.font,e.fontSize,e.fontColor).text(e.text).call(k.convertToTspans),n=t._promises[n],n?E.push(t._promises.pop().then(function(){i(r,c.tickangle)})):i(r,c.tickangle)}),u.exit().remove(),u.each(function(t){A=Math.max(A,t.fontSize)}),i(u,c._lastangle||c.tickangle);var L=w.syncOrAsync([a,s,l]);return L&&L.then&&t._promises.push(L),L}function o(e){if(!r){var n,i,a,o,s=L.getFromId(t,e),l=b.select(t).selectAll("g."+e+"tick"),c={selection:l,side:s.side},f=e.charAt(0),h=t._fullLayout._size,d=1.5,p=s.titlefont.size;if(l.size()){var g=b.select(l.node().parentNode).attr("transform").match(/translate\(([-\.\d]+),([-\.\d]+)\)/);g&&(c.offsetLeft=+g[1],c.offsetTop=+g[2])}"x"===f?(i="free"===s.anchor?{_offset:h.t+(1-(s.position||0))*h.h,_length:0}:L.getFromId(t,s.anchor),a=s._offset+s._length/2,o=i._offset+("top"===s.side?-10-p*(d+(s.showticklabels?1:0)):i._length+10+p*(d+(s.showticklabels?1.5:.5))),s.rangeslider&&s.rangeslider.visible&&s._boundingBox&&(o+=(u.height-u.margin.b-u.margin.t)*s.rangeslider.thickness+s._boundingBox.height),c.side||(c.side="bottom")):(i="free"===s.anchor?{_offset:h.l+(s.position||0)*h.w,_length:0}:L.getFromId(t,s.anchor),o=s._offset+s._length/2,a=i._offset+("right"===s.side?i._length+10+p*(d+(s.showticklabels?1:.5)):-10-p*(d+(s.showticklabels?.5:0))),n={rotate:"-90",offset:0},c.side||(c.side="left")),A.draw(t,e+"title",{propContainer:s,propName:s._name+".title",dfltName:f.toUpperCase()+" axis",avoid:c,transform:n,attributes:{x:a,y:o,"text-anchor":"middle"}})}}function s(t,e){return t.visible!==!0||t.xaxis+t.yaxis!==e?!1:_.Plots.traceIs(t,"bar")&&t.orientation==={x:"h",y:"v"}[v]?!0:t.fill&&t.fill.charAt(t.fill.length-1)===v}function l(e,r,i){var a=e.gridlayer,o=e.zerolinelayer,l=e["hidegrid"+v]?[]:V,u=c._gridpath||"M0,0"+("x"===v?"v":"h")+r._length,f=a.selectAll("path."+z).data(c.showgrid===!1?[]:l,S);if(f.enter().append("path").classed(z,1).classed("crisp",1).attr("d",u).each(function(t){c.zeroline&&("linear"===c.type||"-"===c.type)&&Math.abs(t.x)g;g++){var y=c.mirrors[o._id+h[g]];"ticks"!==y&&"labels"!==y||(f[g]=!0)}return void 0!==n[2]&&(f[2]=!0),f.forEach(function(t,e){var r=n[e],i=U[e];t&&x(r)&&(d+=p(r+R*i,i*c.ticklen))}),i(r,d),l(e,o,t),a(r,n[3])}}).filter(function(t){return t&&t.then});return H.length?Promise.all(H):0},E.swap=function(t,e){for(var r=p(t,e),n=0;n2*n}function u(t){for(var e,r=Math.max(1,(t.length-1)/1e3),n=0,i=0,a=0;a2*n}var f=t("fast-isnumeric"),h=t("tinycolor2").mix,d=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),b=t("./tick_label_defaults"),x=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),A=t("./axis_ids");e.exports=function(t,e,r,i){function a(r,n){return d.coerce2(t,e,v,r,n)}var o=i.letter,s=i.font||{},l="Click to enter "+(i.title||o.toUpperCase()+" axis")+" title";i.name&&(e._name=i.name,e._id=A.name2id(i.name));var c=r("type");"-"===c&&(n(e,i.data),"-"===e.type?e.type="linear":c=t.type=e.type),_(e);var u=r("color"),p=u===t.color?u:s.color;r("title",l),d.coerceFont(r,"titlefont",{family:s.family,size:Math.round(1.2*s.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),M=r("autorange",!k);M&&r("rangemode");var T=r("range",[-1,"x"===o?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),d.noneOrAll(t.range,e.range,[0,1]),r("fixedrange"),m(t,e,r,c),b(t,e,r,c,i),y(t,e,r,i),x(t,e,r);var E=a("linecolor",u),L=a("linewidth"),S=r("showline",!!E||!!L);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&r("mirror");var C=a("gridcolor",h(u,i.bgColor,g).toRgbString()),z=a("gridwidth"),P=r("showgrid",i.showGrid||!!C||!!z);P||(delete e.gridcolor,delete e.gridwidth);var R=a("zerolinecolor",u),O=a("zerolinewidth"),I=r("zeroline",i.showGrid||!!R||!!O);return I||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===c?w(o,e.categoryorder,e.categoryarray,i.data):[],e}},{"../../components/color/attributes":302,"../../lib":381,"../plots":452,"./axis_ids":405,"./category_order_defaults":406,"./clean_datum":407,"./layout_attributes":412,"./ordered_categories":414,"./set_convert":417,"./tick_label_defaults":418,"./tick_mark_defaults":419,"./tick_value_defaults":420,"fast-isnumeric":76,tinycolor2:233}],405:[function(t,e,r){"use strict";function n(t,e,r){function n(t,r){for(var n=Object.keys(t),i=/^[xyz]axis[0-9]*/,a=[],o=0;o0;a&&(n="array");var o=r("categoryorder",n);"array"===o&&r("categoryarray"),a||"array"!==o||(e.categoryorder="trace")}}},{}],407:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return i.ms2DateTime(t);if("string"!=typeof t&&!n(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){console.log(e,t)}return t}},{"../../lib":381,"fast-isnumeric":76}],408:[function(t,e,r){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5}},{}],409:[function(t,e,r){"use strict";function n(t,e){var r,n=t.range[e],i=Math.abs(n-t.range[1-e]);return"date"===t.type?c.ms2DateTime(n,i):"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,o.format("."+r+"g")(Math.pow(10,n))):(r=Math.floor(Math.log(Math.abs(n))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,o.format("."+String(r)+"g")(n))}function i(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function a(t){o.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var o=t("d3"),s=t("tinycolor2"),l=t("../../plotly"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../components/color"),h=t("../../components/drawing"),d=t("../../lib/setcursor"),p=t("../../components/dragelement"),g=t("./axes"),v=t("./select"),m=t("./constants"),y=!0;e.exports=function(t,e,r,o,b,x,_,w){function k(t,e){for(var r=0;r.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+ht+", "+dt+")").attr("d",ot+"Z"),ut=ft.append("path").attr("class","zoombox-corners").style({fill:f.background,stroke:f.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+ht+", "+dt+")").attr("d","M0,0Z"),T();for(var a=0;ai?(lt="",it.r=it.l,it.t=it.b,ut.attr("d","M0,0Z")):(it.t=0,it.b=V,lt="x",ut.attr("d","M"+(it.l-.5)+","+(nt-H-.5)+"h-3v"+(2*H+1)+"h3ZM"+(it.r+.5)+","+(nt-H-.5)+"h3v"+(2*H+1)+"h-3Z")):!Z||i.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),ut.transition().style("opacity",1).duration(200),st=!0)}function L(t,e,r){var n,i,a;for(n=0;nzoom back out","long"),y=!1)))}function C(e,r){var i=1===(_+w).length;if(e)I();else if(2!==r||i){if(1===r&&i){var a=_?B[0]:D[0],o="s"===_||"w"===w?0:1,s=a._name+".range["+o+"]",c=n(a,o),f="left",h="middle";if(a.fixedrange)return;_?(h="n"===_?"top":"bottom","right"===a.side&&(f="right")):"e"===w&&(f="right"),J.call(u.makeEditable,null,{immediate:!0,background:j.paper_bgcolor,text:String(c),fill:a.tickfont?a.tickfont.color:"#444",horizontalAlign:f,verticalAlign:h}).on("edit",function(e){var r="category"===a.type?a.c2l(e):a.d2l(e);void 0!==r&&l.relayout(t,s,r)})}}else O()}function z(e){function r(t,e,r){if(!t.fixedrange){A(t.range);var n=t.range,i=n[0]+(n[1]-n[0])*e;t.range=[i+(n[0]-i)*r,i+(n[1]-i)*r]}}if(t._context.scrollZoom||j._enablescrollzoom){var n=t.querySelector(".plotly");if(!(n.scrollHeight-n.clientHeight>10||n.scrollWidth-n.clientWidth>10)){clearTimeout(gt);var i=-e.deltaY;if(isFinite(i)||(i=e.wheelDelta/10),!isFinite(i))return void console.log("did not find wheel motion attributes",e);var a,o=Math.exp(-Math.min(Math.max(i,-20),20)/100),s=mt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-s.left)/s.width,u=pt[0]+pt[2]*l,f=(s.bottom-e.clientY)/s.height,h=pt[1]+pt[3]*(1-f);if(w){for(a=0;a=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function i(t,e,r){for(var i=1-e,a=0,o=0;o0;n--)r.push(e);return r}function i(t,e){for(var r=[],n=0;nj||j>D.width||0>F||F>D.height)return _.unhoverRaw(t,e)}else j="xpx"in e?e.xpx:p[0]._length/2,F="ypx"in e?e.ypx:v[0]._length/2;if(x="xval"in e?n(d,e.xval):i(p,j),A="yval"in e?n(d,e.yval):i(v,F),!g(x[0])||!g(A[0]))return console.log("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var B=1/0;for(T=0;T1||-1!==L.hoverinfo.indexOf("name")?L.name:void 0,index:!1,distance:Math.min(B,k.MAXDIST),color:b.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},O=I.length,"array"===C){var U=e[T];"pointNumber"in U?(R.index=U.pointNumber,C="closest"):(C="","xval"in U&&(z=U.xval,C="x"),"yval"in U&&(P=U.yval,C=C?"closest":"y"))}else z=x[S],P=A[S];if(L._module&&L._module.hoverPoints){var V=L._module.hoverPoints(R,z,P,C);if(V)for(var q,H=0;HO&&(I.splice(0,O),B=I[0].distance)}if(0===I.length)return _.unhoverRaw(t,e);var G="y"===y&&N.length>1;I.sort(function(t,e){return t.distance-e.distance});var Y=b.combine(a.plot_bgcolor||b.background,a.paper_bgcolor),X={hovermode:y,rotateLabels:G,bgColor:Y,container:a._hoverlayer,outerContainer:a._paperdiv},W=c(I,X);u(I,G?"xa":"ya"),f(W,G);var Z=t._hoverdata,K=[];for(M=0;M128?"#000":b.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,r=u.textContent||"",r.length>15&&(r=r.substr(0,12)+"...")}void 0!==t.extraText&&(n+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(n+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(n+="y: "+t.yLabel+"
"),n+=(n?"z: ":"")+t.zLabel):M&&t[i+"Label"]===g?n=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(n=t.yLabel):n=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(n+=(n?"
":"")+t.text),""===n&&(""===r&&e.remove(),n=r);var f=e.select("text.nums").style("fill",c).call(x.setPosition,0,0).text(n).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(x.setPosition,0,0);var h=e.select("text.name"),v=0;r&&r!==n?(h.style("fill",l).text(r).call(x.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),h.selectAll("tspan.line").call(x.setPosition,0,0),v=h.node().getBoundingClientRect().width+2*P):(h.remove(),e.select("rect").remove()),e.select("path").style({fill:l,stroke:c});var m,k,E=f.node().getBoundingClientRect(),L=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),R=Math.abs(t.y1-t.y0),O=E.width+z+P+v;t.ty0=_-E.top,t.bx=E.width+2*P,t.by=E.height+2*P,t.anchor="start",t.txwidth=E.width,t.tx2width=v,t.offset=0,a?(t.pos=L,m=A>=S+R/2+O,k=S-R/2-O>=0,"top"!==t.idealAlign&&m||!k?m?(S+=R/2,t.anchor="start"):t.anchor="middle":(S-=R/2,t.anchor="end")):(t.pos=S,m=w>=L+C/2+O,k=L-C/2-O>=0,"left"!==t.idealAlign&&m||!k?m?(L+=C/2,t.anchor="start"):t.anchor="middle":(L-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&h.attr("text-anchor",t.anchor),e.attr("transform","translate("+L+","+S+")"+(a?"rotate("+T+")":""))}),S}function u(t,e){function r(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(.01>a)){if(-.01>i){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos>e.pmax-1&&(l.del=!0,c--);for(o=0;o=c);o++)if(l=t[o],l.pos=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos+l.dp+l.size>e.pmax&&(l.del=!0,c--)}}}for(var n,i,a,o,s,l,c,u=0,f=t.map(function(t,r){var n=t[e];return[{i:r,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===n._id.charAt(0)?L:1)/2,pmin:n._offset,pmax:n._offset+n._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(s=d.length-1;s>=0;s--)d[s].dp+=i;for(h.push.apply(h,d),f.splice(o+1,1),c=0,s=h.length-1;s>=0;s--)c+=h[s].dp;for(a=c/h.length,s=h.length-1;s>=0;s--)h[s].dp-=a;n=!1}else o++}f.forEach(r)}for(o=f.length-1;o>=0;o--){var v=f[o];for(s=v.length-1;s>=0;s--){var m=v[s],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var r=d.select(this);if(t.del)return void r.remove();var n="end"===t.anchor?-1:1,i=r.select("text.nums"),a={start:1,end:-1,middle:0}[t.anchor],o=a*(z+P),s=o+a*(t.txwidth+P),l=0,c=t.offset;"middle"===t.anchor&&(o-=t.tx2width/2,s-=t.tx2width/2),e&&(c*=-C,l=t.offset*S),r.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(n*z+l)+","+(z+c)+"v"+(t.by/2-z)+"h"+n*t.bx+"v-"+t.by+"H"+(n*z+l)+"V"+(c-z)+"Z"),i.call(x.setPosition,o+l,c+t.ty0-t.by/2+P).selectAll("tspan.line").attr({x:i.attr("x"),y:i.attr("y")}),t.tx2width&&(r.select("text.name, text.name tspan.line").call(x.setPosition,s+a*P+l,c+t.ty0-t.by/2+P),r.select("rect").call(x.setRect,s+(a-1)*t.tx2width/2+l,c-t.by/2-1,t.tx2width,t.by+2))})}function h(t,e,r){if(!e.target)return!1;if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}var d=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),b=t("../../components/color"),x=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),A=t("./dragbox"),M=e.exports={};M.unhover=_.unhover,M.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},M.supplyLayoutDefaults=function(t,e,r){function n(r,n){return v.coerce(t,e,M.layoutAttributes,r,n)}n("dragmode");var i;if(e._has("cartesian")){var a=e._isHoriz=M.isHoriz(r);i=a?"y":"x"}else i="closest";n("hovermode",i)},M.isHoriz=function(t){for(var e=!0,r=0;rt._lastHoverTime+k.HOVERMINTIME?(o(t,e,r),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){o(t,e,r),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},M.getDistanceFunction=function(t,e,r,n){return"closest"===t?n||a(e,r):"x"===t?e:r},M.getClosest=function(t,e,r){if(r.index!==!1)r.index>=0&&r.indext*e||0===t?k.MAXDIST*(.6-.3/Math.max(3,Math.abs(t-e))):1/0}},{"../../components/color":303,"../../components/dragelement":323,"../../components/drawing":325,"../../lib":381,"../../lib/events":375,"../../lib/svg_text_utils":393,"./axes":403,"./constants":408,"./dragbox":409,d3:72,"fast-isnumeric":76,tinycolor2:233}],411:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../plots"),a=t("./constants");r.name="cartesian",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex=a.idRegex,r.attrRegex=a.attrRegex,r.attributes=t("./attributes"),r.plot=function(t){function e(t,e){for(var r=[],n=0;nf[1]-.01&&(e.domain=[0,1]),i.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":381,"fast-isnumeric":76}],416:[function(t,e,r){"use strict";function n(t){return t._id}var i=t("../../lib/polygon"),a=t("../../components/color"),o=t("./axes"),s=t("./constants"),l=i.filter,c=i.tester,u=s.MINSELECT;e.exports=function(t,e,r,i,f){function h(t){var e="y"===t._id.charAt(0)?1:0;return function(r){return t.p2d(r[e])}}function d(t,e){return t-e}var p,g=i.gd._fullLayout._zoomlayer,v=i.element.getBoundingClientRect(),m=i.plotinfo.x()._offset,y=i.plotinfo.y()._offset,b=e-v.left,x=r-v.top,_=b,w=x,k="M"+b+","+x,A=i.xaxes[0]._length,M=i.yaxes[0]._length,T=i.xaxes.map(n),E=i.yaxes.map(n),L=i.xaxes.concat(i.yaxes);"lasso"===f&&(p=l([[b,x]],s.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",k+"Z");var C,z,P,R,O,I=g.append("path").attr("class","zoombox-corners").style({fill:a.background,stroke:a.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),N=[],j=i.gd,F=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(0>=e&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-3*u*Math.abs(n-i))}return o.BADNUM}function r(t){return Math.pow(10,t); -}function c(t){return i(t)?Number(t):o.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?r:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,r=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var n=l.getFromId(t._gd,t.overlaying);t.domain=n.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;2>e;e++)i(t.range[e])||(t.range[e]=i(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=r.t+(1-t.domain[1])*r.h,t._length=r.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=r.l+t.domain[0]*r.w,t._length=r.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw a.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return i(e)?n.round(t._b+t._m*e,2):o.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,r){return t.l2p(t.c2l(e,r))},t.p2c=function(e){return t.l2c(t.p2l(e))},-1!==["linear","log","-"].indexOf(t.type))t.c2d=c,t.d2c=function(t){return t=s(t),i(t)?Number(t):o.BADNUM},t.d2l=function(e,r){return"log"===t.type?t.c2l(t.d2c(e),r):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return i(t)?a.ms2DateTime(t):o.BADNUM},t.d2c=function(t){return i(t)?Number(t):a.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(a.dateTime2ms);!i(t.range[0])&&i(f[0])&&(t.range[0]=f[0]),!i(t.range[1])&&i(f[1])&&(t.range[1]=f[1])}catch(h){console.log(h,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&-1===t._categories.indexOf(e)&&t._categories.push(e);var r=t._categories.indexOf(e);return-1===r?o.BADNUM:r},t.d2l=t.d2c);t.makeCalcdata=function(e,r){var n,i,a;if(r in e)for(n=e[r],i=new Array(n.length),a=0;an?"0":"1.0"}var r=this.framework,n=r.select("g.choroplethlayer"),i=r.select("g.scattergeolayer"),a=this.projection,o=this.path,s=this.clipAngle;r.selectAll("path.basepath").attr("d",o),r.selectAll("path.graticulepath").attr("d",o),n.selectAll("path.choroplethlocation").attr("d",o),n.selectAll("path.basepath").attr("d",o),i.selectAll("path.js-line").attr("d",o),null!==s?(i.selectAll("path.point").style("opacity",e).attr("transform",t),i.selectAll("text").style("opacity",e).attr("transform",t)):(i.selectAll("path.point").attr("transform",t),i.selectAll("text").attr("transform",t))}},{"../../components/color":303,"../../components/drawing":325,"../../constants/xmlns_namespaces":369,"../../lib/filter_visible":377,"../../lib/topojson_utils":394,"../../plots/cartesian/axes":403,"./constants":422,"./projections":430,"./set_scale":431,"./zoom":432,"./zoom_reset":433,d3:72,topojson:234}],424:[function(t,e,r){"use strict";var n=t("./geo"),i=t("../../plots/plots");r.name="geo",r.attr="geo",r.idRoot="geo",r.idRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"geo");void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var o=0;o=n}function a(t,e){for(var r=e[0],n=e[1],i=!1,a=0,o=t.length,s=o-1;o>a;s=a++){var l=t[a],c=l[0],u=l[1],f=t[s],h=f[0],d=f[1];u>n^d>n&&(h-c)*(n-u)/(d-u)+c>r&&(i=!i)}return i}function o(t){return t?t/Math.sin(t):1}function s(t){return t>1?P:-1>t?-P:Math.asin(t)}function l(t){return t>1?0:-1>t?z:Math.acos(t)}function c(t,e){var r=(2+P)*Math.sin(e);e/=2;for(var n=0,i=1/0;10>n&&Math.abs(i)>S;n++){var a=Math.cos(e);e-=i=(e+Math.sin(e)*(a+2)-r)/(2*a*(1+a))}return[2/Math.sqrt(z*(4+z))*t*(1+Math.cos(e)),2*Math.sqrt(z/(4+z))*Math.sin(e)]}function u(t,e){function r(r,n){var i=j(r/e,n);return i[0]*=t,i}return arguments.length<2&&(e=t),1===e?j:e===1/0?h:(r.invert=function(r,n){var i=j.invert(r/t,n);return i[0]*=e,i},r)}function f(){var t=2,e=N(u),r=e(t);return r.coefficient=function(r){return arguments.length?e(t=+r):t},r}function h(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function d(t,e){return[3*t/(2*z)*Math.sqrt(z*z/3-e*e),e]}function p(t,e){return[t,1.25*Math.log(Math.tan(z/4+.4*e))]}function g(t){return function(e){var r,n=t*Math.sin(e),i=30;do e-=r=(e+Math.sin(e)-n)/(1+Math.cos(e));while(Math.abs(r)>S&&--i>0);return e/2}}function v(t,e,r){function n(r,n){return[t*r*Math.cos(n=i(n)),e*Math.sin(n)]}var i=g(r);return n.invert=function(n,i){var a=s(i/e);return[n/(t*Math.cos(a)),s((2*a+Math.sin(2*a))/r)]},n}function m(t,e){var r=e*e,n=r*r;return[t*(.8707-.131979*r+n*(-.013791+n*(.003971*r-.001529*n))),e*(1.007226+r*(.015085+n*(-.044475+.028874*r-.005916*n)))]}function y(t,e){var r,n=Math.min(18,36*Math.abs(e)/z),i=Math.floor(n),a=n-i,o=(r=D[i])[0],s=r[1],l=(r=D[++i])[0],c=r[1],u=(r=D[Math.min(19,++i)])[0],f=r[1];return[t*(l+a*(u-o)/2+a*a*(u-2*l+o)/2),(e>0?P:-P)*(c+a*(f-s)/2+a*a*(f-2*c+s)/2)]}function b(t,e){return[t*Math.cos(e),e]}function x(t,e){var r=Math.cos(e),n=o(l(r*Math.cos(t/=2)));return[2*r*Math.sin(t)*n,Math.sin(e)*n]}function _(t,e){var r=x(t,e);return[(r[0]+t/P)/2,(r[1]+e)/2]}t.geo.project=function(t,e){var n=e.stream;if(!n)throw new Error("not yet supported");return(t&&w.hasOwnProperty(t.type)?w[t.type]:r)(t,n)};var w={Feature:e,FeatureCollection:function(t,r){return{type:"FeatureCollection",features:t.features.map(function(t){return e(t,r)})}}},k=[],A=[],M={point:function(t,e){k.push([t,e])},result:function(){var t=k.length?k.length<2?{type:"Point",coordinates:k[0]}:{type:"MultiPoint",coordinates:k}:null;return k=[],t}},T={lineStart:n,point:function(t,e){k.push([t,e])},lineEnd:function(){k.length&&(A.push(k),k=[])},result:function(){var t=A.length?A.length<2?{type:"LineString",coordinates:A[0]}:{type:"MultiLineString",coordinates:A}:null;return A=[],t}},E={polygonStart:n,lineStart:n,point:function(t,e){k.push([t,e])},lineEnd:function(){var t=k.length;if(t){do k.push(k[0].slice());while(++t<4);A.push(k),k=[]}},polygonEnd:n,result:function(){if(!A.length)return null;var t=[],e=[];return A.forEach(function(r){i(r)?t.push([r]):e.push(r)}),e.forEach(function(e){var r=e[0];t.some(function(t){return a(t[0],r)?(t.push(e),!0):void 0})||t.push([e])}),A=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},L={Point:M,MultiPoint:M,LineString:T,MultiLineString:T,Polygon:E,MultiPolygon:E,Sphere:E},S=1e-6,C=S*S,z=Math.PI,P=z/2,R=(Math.sqrt(z),z/180),O=180/z,I=t.geo.projection,N=t.geo.projectionMutator;t.geo.interrupt=function(e){function r(t,r){for(var n=0>r?-1:1,i=l[+(0>r)],a=0,o=i.length-1;o>a&&t>i[a][2][0];++a);var s=e(t-i[a][1][0],r);return s[0]+=e(i[a][1][0],n*r>n*i[a][0][1]?i[a][0][1]:r)[0],s}function n(){s=l.map(function(t){return t.map(function(t){var r,n=e(t[0][0],t[0][1])[0],i=e(t[2][0],t[2][1])[0],a=e(t[1][0],t[0][1])[1],o=e(t[1][0],t[1][1])[1];return a>o&&(r=a,a=o,o=r),[[n,a],[i,o]]})})}function i(){for(var e=1e-6,r=[],n=0,i=l[0].length;i>n;++n){var o=l[0][n],s=180*o[0][0]/z,c=180*o[0][1]/z,u=180*o[1][1]/z,f=180*o[2][0]/z,h=180*o[2][1]/z;r.push(a([[s+e,c+e],[s+e,u-e],[f-e,u-e],[f-e,h+e]],30))}for(var n=l[1].length-1;n>=0;--n){var o=l[1][n],s=180*o[0][0]/z,c=180*o[0][1]/z,u=180*o[1][1]/z,f=180*o[2][0]/z,h=180*o[2][1]/z;r.push(a([[f-e,h-e],[f-e,u+e],[s+e,u+e],[s+e,c-e]],30))}return{type:"Polygon",coordinates:[t.merge(r)]}}function a(t,e){for(var r,n,i,a=-1,o=t.length,s=t[0],l=[];++ac;++c)l.push([s[0]+c*n,s[1]+c*i]);s=r}return l.push(r),l}function o(t,e){return Math.abs(t[0]-e[0])n)],a=l[+(0>n)],c=0,u=i.length;u>c;++c){var f=i[c];if(f[0][0]<=t&&tS&&--i>0);return[t/(.8707+(a=n*n)*(-.131979+a*(-.013791+a*a*a*(.003971-.001529*a)))),n]},(t.geo.naturalEarth=function(){return I(m)}).raw=m;var D=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];D.forEach(function(t){t[1]*=1.0144}),y.invert=function(t,e){var r=e/P,n=90*r,i=Math.min(18,Math.abs(n/5)),a=Math.max(0,Math.floor(i));do{var o=D[a][1],s=D[a+1][1],l=D[Math.min(19,a+2)][1],c=l-o,u=l-2*s+o,f=2*(Math.abs(r)-s)/c,h=u/c,d=f*(1-h*f*(1-2*h*f));if(d>=0||1===a){n=(e>=0?5:-5)*(d+i);var p,g=50;do i=Math.min(18,Math.abs(n)/5),a=Math.floor(i),d=i-a,o=D[a][1],s=D[a+1][1],l=D[Math.min(19,a+2)][1],n-=(p=(e>=0?P:-P)*(s+d*(l-o)/2+d*d*(l-2*s+o)/2)-e)*O;while(Math.abs(p)>C&&--g>0);break}}while(--a>=0);var v=D[a][0],m=D[a+1][0],y=D[Math.min(19,a+2)][0];return[t/(m+d*(y-v)/2+d*d*(y-2*m+v)/2),n*R]},(t.geo.robinson=function(){return I(y)}).raw=y,b.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return I(b)}).raw=b,x.invert=function(t,e){if(!(t*t+4*e*e>z*z+S)){var r=t,n=e,i=25;do{var a,o=Math.sin(r),s=Math.sin(r/2),c=Math.cos(r/2),u=Math.sin(n),f=Math.cos(n),h=Math.sin(2*n),d=u*u,p=f*f,g=s*s,v=1-p*c*c,m=v?l(f*c)*Math.sqrt(a=1/v):a=0,y=2*m*f*s-t,b=m*u-e,x=a*(p*g+m*f*c*d),_=a*(.5*o*h-2*m*u*s),w=.25*a*(h*s-m*u*p*o),k=a*(d*c+m*g*f),A=_*w-k*x;if(!A)break;var M=(b*_-y*k)/A,T=(y*w-b*x)/A;r-=M,n-=T}while((Math.abs(M)>S||Math.abs(T)>S)&&--i>0);return[r,n]}},(t.geo.aitoff=function(){return I(x)}).raw=x,_.invert=function(t,e){var r=t,n=e,i=25;do{var a,o=Math.cos(n),s=Math.sin(n),c=Math.sin(2*n),u=s*s,f=o*o,h=Math.sin(r),d=Math.cos(r/2),p=Math.sin(r/2),g=p*p,v=1-f*d*d,m=v?l(o*d)*Math.sqrt(a=1/v):a=0,y=.5*(2*m*o*p+r/P)-t,b=.5*(m*s+n)-e,x=.5*a*(f*g+m*o*d*u)+.5/P,_=a*(h*c/4-m*s*p),w=.125*a*(c*p-m*s*f*h),k=.5*a*(u*d+m*g*o)+.5,A=_*w-k*x,M=(b*_-y*k)/A,T=(y*w-b*x)/A;r-=M,n-=T}while((Math.abs(M)>S||Math.abs(T)>S)&&--i>0);return[r,n]},(t.geo.winkel3=function(){return I(_)}).raw=_}e.exports=n},{}],431:[function(t,e,r){"use strict";function n(t,e){var r=t.projection,n=t.lonaxis,o=t.lataxis,l=t.domain,c=t.framewidth||0,u=e.w*(l.x[1]-l.x[0]),f=e.h*(l.y[1]-l.y[0]),h=n.range[0]+s,d=n.range[1]-s,p=o.range[0]+s,g=o.range[1]-s,v=n._fullRange[0]+s,m=n._fullRange[1]-s,y=o._fullRange[0]+s,b=o._fullRange[1]-s;r._translate0=[e.l+u/2,e.t+f/2];var x=d-h,_=g-p,w=[h+x/2,p+_/2],k=r._rotate;r._center=[w[0]+k[0],w[1]+k[1]];var A=function(e){function n(t){return Math.min(_*u/(t[1][0]-t[0][0]),_*f/(t[1][1]-t[0][1]))}var o,s,l,x,_=e.scale(),w=r._translate0,k=i(h,p,d,g),A=i(v,y,m,b);l=a(e,k),o=n(l),x=a(e,A),r._fullScale=n(x),e.scale(o),l=a(e,k),s=[w[0]-l[0][0]+c,w[1]-l[0][1]+c],r._translate=s,e.translate(s),l=a(e,k),t._isAlbersUsa||e.clipExtent(l),o=r.scale*o,r._scale=o,t._width=Math.round(l[1][0])+c,t._height=Math.round(l[1][1])+c,t._marginX=(u-Math.round(l[1][0]))/2,t._marginY=(f-Math.round(l[1][1]))/2};return A}function i(t,e,r,n){var i=(r-t)/4;return{type:"Polygon",coordinates:[[[t,e],[t,n],[t+i,n],[t+2*i,n],[t+3*i,n],[r,n],[r,e],[r-i,e],[r-2*i,e],[r-3*i,e],[t,e]]]}}function a(t,e){return o.geo.path().projection(t).bounds(e)}var o=t("d3"),s=t("./constants/").clipPad;e.exports=n},{"./constants/":422,d3:72}],432:[function(t,e,r){"use strict";function n(t,e){var r;return(r=e._isScoped?a:e._clipAngle?s:o)(t,e.projection)}function i(t,e){var r=e._fullScale;return _.behavior.zoom().translate(t.translate()).scale(t.scale()).scaleExtent([.5*r,100*r])}function a(t,e){function r(){_.select(this).style(A)}function n(){o.scale(_.event.scale).translate(_.event.translate),t.render()}function a(){_.select(this).style(M)}var o=t.projection,s=i(o,e);return s.on("zoomstart",r).on("zoom",n).on("zoomend",a),s}function o(t,e){function r(t){return v.invert(t)}function n(t){var e=v(r(t));return Math.abs(e[0]-t[0])>y||Math.abs(e[1]-t[1])>y}function a(){_.select(this).style(A),l=_.mouse(this),c=v.rotate(),u=v.translate(),f=c,h=r(l)}function o(){return d=_.mouse(this),n(l)?(m.scale(v.scale()),void m.translate(v.translate())):(v.scale(_.event.scale),v.translate([u[0],_.event.translate[1]]),h?r(d)&&(g=r(d),p=[f[0]+(g[0]-h[0]),c[1],c[2]],v.rotate(p),f=p):(l=d,h=r(l)),void t.render())}function s(){_.select(this).style(M)}var l,c,u,f,h,d,p,g,v=t.projection,m=i(v,e),y=2;return m.on("zoomstart",a).on("zoom",o).on("zoomend",s),m}function s(t,e){function r(t){m++||t({type:"zoomstart"})}function n(t){t({type:"zoom"})}function a(t){--m||t({type:"zoomend"})}var o,s=t.projection,d={r:s.rotate(),k:s.scale()},p=i(s,e),g=x(p,"zoomstart","zoom","zoomend"),m=0,y=p.on;return p.on("zoomstart",function(){_.select(this).style(A);var t=_.mouse(this),e=s.rotate(),i=e,a=s.translate(),m=c(e);o=l(s,t),y.call(p,"zoom",function(){var r=_.mouse(this);if(s.scale(d.k=_.event.scale),o){if(l(s,r)){s.rotate(e).translate(a);var c=l(s,r),p=f(o,c),y=v(u(m,p)),b=d.r=h(y,o,i);isFinite(b[0])&&isFinite(b[1])&&isFinite(b[2])||(b=i),s.rotate(b),i=b}}else t=r,o=l(s,t);n(g.of(this,arguments))}),r(g.of(this,arguments))}).on("zoomend",function(){_.select(this).style(M),y.call(p,"zoom",null),a(g.of(this,arguments))}).on("zoom.redraw",function(){t.render()}),_.rebind(p,g,"on")}function l(t,e){var r=t.invert(e);return r&&isFinite(r[0])&&isFinite(r[1])&&m(r)}function c(t){var e=.5*t[0]*w,r=.5*t[1]*w,n=.5*t[2]*w,i=Math.sin(e),a=Math.cos(e),o=Math.sin(r),s=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return[a*s*c+i*o*l,i*s*c-a*o*l,a*o*c+i*s*l,a*s*l-i*o*c]}function u(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=e[0],s=e[1],l=e[2],c=e[3];return[r*o-n*s-i*l-a*c,r*s+n*o+i*c-a*l,r*l-n*c+i*o+a*s,r*c+n*l-i*s+a*o]}function f(t,e){if(t&&e){var r=b(t,e),n=Math.sqrt(y(r,r)),i=.5*Math.acos(Math.max(-1,Math.min(1,y(t,e)))),a=Math.sin(i)/n;return n&&[Math.cos(i),r[2]*a,-r[1]*a,r[0]*a]}}function h(t,e,r){var n=g(e,2,t[0]);n=g(n,1,t[1]),n=g(n,0,t[2]-r[2]);var i,a,o=e[0],s=e[1],l=e[2],c=n[0],u=n[1],f=n[2],h=Math.atan2(s,o)*k,p=Math.sqrt(o*o+s*s);Math.abs(u)>p?(a=(u>0?90:-90)-h,i=0):(a=Math.asin(u/p)*k-h,i=Math.sqrt(p*p-u*u));var v=180-a-2*h,m=(Math.atan2(f,c)-Math.atan2(l,i))*k,y=(Math.atan2(f,c)-Math.atan2(l,-i))*k,b=d(r[0],r[1],a,m),x=d(r[0],r[1],v,y);return x>=b?[a,m,r[2]]:[v,y,r[2]]}function d(t,e,r,n){var i=p(r-t),a=p(n-e);return Math.sqrt(i*i+a*a)}function p(t){return(t%360+540)%360-180}function g(t,e,r){var n=r*w,i=t.slice(),a=0===e?1:0,o=2===e?1:2,s=Math.cos(n),l=Math.sin(n);return i[a]=t[a]*s-t[o]*l,i[o]=t[o]*s+t[a]*l,i}function v(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*k,Math.asin(Math.max(-1,Math.min(1,2*(t[0]*t[2]-t[3]*t[1]))))*k,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*k]}function m(t){var e=t[0]*w,r=t[1]*w,n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function y(t,e){for(var r=0,n=0,i=t.length;i>n;++n)r+=t[n]*e[n];return r}function b(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]; -}function x(t){for(var e=0,r=arguments.length,n=[];++ed;++d){for(e=c[d],r=t[this.scene[e]._name],n=/Click to enter .+ title/.test(r.title)?"":r.title,p=0;2>=p;p+=2)this.labelEnable[d+p]=!1,this.labels[d+p]=o(n),this.labelColor[d+p]=s(r.titlefont.color),this.labelFont[d+p]=r.titlefont.family,this.labelSize[d+p]=r.titlefont.size,this.labelPad[d+p]=this.getLabelPad(e,r),this.tickEnable[d+p]=!1,this.tickColor[d+p]=s((r.tickfont||{}).color),this.tickAngle[d+p]="auto"===r.tickangle?0:Math.PI*-r.tickangle/180,this.tickPad[d+p]=this.getTickPad(r),this.tickMarkLength[d+p]=0,this.tickMarkWidth[d+p]=r.tickwidth||0,this.tickMarkColor[d+p]=s(r.tickcolor),this.borderLineEnable[d+p]=!1,this.borderLineColor[d+p]=s(r.linecolor),this.borderLineWidth[d+p]=r.linewidth||0;u=this.hasSharedAxis(r),a=this.hasAxisInDfltPos(e,r)&&!u,l=this.hasAxisInAltrPos(e,r)&&!u,i=r.mirror||!1,f=u?-1!==String(i).indexOf("all"):!!i,h=u?"allticks"===i:-1!==String(i).indexOf("ticks"),a?this.labelEnable[d]=!0:l&&(this.labelEnable[d+2]=!0),a?this.tickEnable[d]=r.showticklabels:l&&(this.tickEnable[d+2]=r.showticklabels),(a||f)&&(this.borderLineEnable[d]=r.showline),(l||f)&&(this.borderLineEnable[d+2]=r.showline),(a||h)&&(this.tickMarkLength[d]=this.getTickMarkLength(r)),(l||h)&&(this.tickMarkLength[d+2]=this.getTickMarkLength(r)),this.gridLineEnable[d]=r.showgrid,this.gridLineColor[d]=s(r.gridcolor),this.gridLineWidth[d]=r.gridwidth,this.zeroLineEnable[d]=r.zeroline,this.zeroLineColor[d]=s(r.zerolinecolor),this.zeroLineWidth[d]=r.zerolinewidth}},l.hasSharedAxis=function(t){var e=this.scene,r=a.Plots.getSubplotIds(e.fullLayout,"gl2d"),n=a.Axes.findSubplotsWithAxis(r,t);return 0!==n.indexOf(e.id)},l.hasAxisInDfltPos=function(t,e){var r=e.side;return"xaxis"===t?"bottom"===r:"yaxis"===t?"left"===r:void 0},l.hasAxisInAltrPos=function(t,e){var r=e.side;return"xaxis"===t?"top"===r:"yaxis"===t?"right"===r:void 0},l.getLabelPad=function(t,e){var r=1.5,n=e.titlefont.size,i=e.showticklabels;return"xaxis"===t?"top"===e.side?-10+n*(r+(i?1:0)):-10+n*(r+(i?.5:0)):"yaxis"===t?"right"===e.side?10+n*(r+(i?1:.5)):10+n*(r+(i?.5:0)):void 0},l.getTickPad=function(t){return"outside"===t.ticks?10+t.ticklen:15},l.getTickMarkLength=function(t){if(!t.ticks)return 0;var e=t.ticklen;return"inside"===t.ticks?-e:e},e.exports=i},{"../../lib/html2unicode":380,"../../lib/str2rgbarray":392,"../../plotly":400}],436:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("./scene2d"),a=n.Plots;r.name="gl2d",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex={x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},r.attrRegex={x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},r.attributes=t("../cartesian/attributes"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,n=a.getSubplotIds(e,"gl2d"),o=0;or;++r){var n=t[r],i=e[r];if(n.length!==i.length)return!0;for(var a=0;ao;++o,--s)for(var l=0;r>l;++l)for(var c=0;4>c;++c){var u=i[4*(r*o+l)+c];i[4*(r*o+l)+c]=i[4*(r*s+l)+c],i[4*(r*s+l)+c]=u}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticPlot&&this.container.removeChild(a),p},m.computeTickMarks=function(){this.xaxis._length=this.glplot.viewBox[2]-this.glplot.viewBox[0],this.yaxis._length=this.glplot.viewBox[3]-this.glplot.viewBox[1];for(var t=[s.calcTicks(this.xaxis),s.calcTicks(this.yaxis)],e=0;2>e;++e)for(var r=0;rk;++k)w[k]=Math.min(w[k],a.bounds[k]),w[k+2]=Math.max(w[k+2],a.bounds[k+2])}var A;for(n=0;2>n;++n)w[n]>w[n+2]&&(w[n]=-1,w[n+2]=1),A=this[v[n]],A._length=y.viewBox[n+2]-y.viewBox[n],s.doAutoRange(A);y.ticks=this.computeTickMarks();var M=this.xaxis.range,T=this.yaxis.range;y.dataBox=[M[0],T[0],M[1],T[1]],y.merge(r),o.update(y),this.glplot.draw()},m.draw=function(){if(!this.stopped){requestAnimationFrame(this.redraw);var t=this.glplot,e=this.camera,r=e.mouseListener,n=this.fullLayout;this.cameraChanged();var i=r.x*t.pixelRatio,a=this.canvas.height-t.pixelRatio*r.y;if(e.boxEnabled&&"zoom"===n.dragmode)this.selectBox.enabled=!0,this.selectBox.selectBox=[Math.min(e.boxStart[0],e.boxEnd[0]),Math.min(e.boxStart[1],e.boxEnd[1]),Math.max(e.boxStart[0],e.boxEnd[0]),Math.max(e.boxStart[1],e.boxEnd[1])],t.setDirty();else{this.selectBox.enabled=!1;var o=n._size,s=this.xaxis.domain,c=this.yaxis.domain,u=t.pick(i/t.pixelRatio+o.l+s[0]*o.w,a/t.pixelRatio-(o.t+(1-c[1])*o.h));if(u&&n.hovermode){var f=u.object._trace.handlePick(u);if(f&&(!this.lastPickResult||this.lastPickResult.trace!==f.trace||this.lastPickResult.dataCoord[0]!==f.dataCoord[0]||this.lastPickResult.dataCoord[1]!==f.dataCoord[1])){var h=this.lastPickResult=f;this.spikes.update({center:u.dataCoord}),h.screenCoord=[((t.viewBox[2]-t.viewBox[0])*(u.dataCoord[0]-t.dataBox[0])/(t.dataBox[2]-t.dataBox[0])+t.viewBox[0])/t.pixelRatio,(this.canvas.height-(t.viewBox[3]-t.viewBox[1])*(u.dataCoord[1]-t.dataBox[1])/(t.dataBox[3]-t.dataBox[1])-t.viewBox[1])/t.pixelRatio];var d=h.hoverinfo;if("all"!==d){var p=d.split("+");-1===p.indexOf("x")&&(h.traceCoord[0]=void 0),-1===p.indexOf("y")&&(h.traceCoord[1]=void 0),-1===p.indexOf("z")&&(h.traceCoord[2]=void 0),-1===p.indexOf("text")&&(h.textLabel=void 0),-1===p.indexOf("name")&&(h.name=void 0)}l.loneHover({x:h.screenCoord[0],y:h.screenCoord[1],xLabel:this.hoverFormatter("xaxis",h.traceCoord[0]),yLabel:this.hoverFormatter("yaxis",h.traceCoord[1]),zLabel:h.traceCoord[2],text:h.textLabel,name:h.name,color:h.color},{container:this.svgContainer}),this.lastPickResult={dataCoord:u.dataCoord}}}else!u&&this.lastPickResult&&(this.spikes.update({}),this.lastPickResult=null,l.loneUnhover(this.svgContainer))}t.draw()}},m.hoverFormatter=function(t,e){if(void 0!==e){var r=this[t];return s.tickText(r,r.c2l(e),"hover").text}}},{"../../lib/html2unicode":380,"../../lib/show_no_webgl_msg":390,"../../plots/cartesian/axes":403,"../../plots/cartesian/graph_interact":410,"./camera":434,"./convert":435,"gl-plot2d":124,"gl-select-box":154,"gl-spikes2d":174}],438:[function(t,e,r){"use strict";function n(t,e){t=t||document.body,e=e||{};var r=[.01,1/0];"distanceLimits"in e&&(r[0]=e.distanceLimits[0],r[1]=e.distanceLimits[1]),"zoomMin"in e&&(r[0]=e.zoomMin),"zoomMax"in e&&(r[1]=e.zoomMax);var n=a({center:e.center||[0,0,0],up:e.up||[0,1,0],eye:e.eye||[0,0,10],mode:e.mode||"orbit",distanceLimits:r}),l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0,u=t.clientWidth,f=t.clientHeight,h={keyBindingMode:"rotate",view:n,element:t,delay:e.delay||16,rotateSpeed:e.rotateSpeed||1,zoomSpeed:e.zoomSpeed||1,translateSpeed:e.translateSpeed||1,flipX:!!e.flipX,flipY:!!e.flipY,modes:n.modes,tick:function(){var e=i(),r=this.delay,a=e-2*r;n.idle(e-r),n.recalcMatrix(a),n.flush(e-(100+2*r));for(var o=!0,s=n.computedMatrix,h=0;16>h;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){var e=n.computedUp.slice(),r=n.computedEye.slice(),a=n.computedCenter.slice();if(n.setMode(t),"turntable"===t){var o=i();n._active.lookAt(o,r,a,e),n._active.lookAt(o+500,r,a,[0,0,1]),n._active.flush(o)}return n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s="rotate"===h.keyBindingMode,l="pan"===h.keyBindingMode,u="zoom"===h.keyBindingMode,f=!!o.control,g=!!o.alt,v=!!o.shift,m=!!(1&e),y=!!(2&e),b=!!(4&e),x=1/t.clientHeight,_=x*(r-d),w=x*(a-p),k=h.flipX?1:-1,A=h.flipY?1:-1,M=i(),T=Math.PI*h.rotateSpeed;if((s&&m&&!f&&!g&&!v||m&&!f&&!g&&v)&&n.rotate(M,k*T*_,-A*T*w,0),(l&&m&&!f&&!g&&!v||y||m&&f&&!g&&!v)&&n.pan(M,-h.translateSpeed*_*c,h.translateSpeed*w*c,0),u&&m&&!f&&!g&&!v||b||m&&!f&&g&&!v){var E=-h.zoomSpeed*w/window.innerHeight*(M-n.lastT())*100;n.pan(M,0,0,c*(Math.exp(E)-1))}return d=r,p=a,!0}),s(t,function(t,e){var r=h.flipX?1:-1,a=h.flipY?1:-1,o=i();if(Math.abs(t)>Math.abs(e))n.rotate(o,0,0,-t*r*Math.PI*h.rotateSpeed/window.innerWidth);else{var s=-h.zoomSpeed*a*e/window.innerHeight*(o-n.lastT())/100;n.pan(o,0,0,c*(Math.exp(s)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":39,"mouse-change":200,"mouse-wheel":204,"right-now":214}],439:[function(t,e,r){"use strict";function n(t,e){for(var r=0;3>r;++r){var n=o[r];e[n]._gd=t}}var i=t("./scene"),a=t("../plots"),o=["xaxis","yaxis","zaxis"];r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,o=a.getSubplotIds(e,"gl3d");e._paperdiv.style({width:e.width+"px",height:e.height+"px"}),t._context.setBackground(t,e.paper_bgcolor);for(var s=0;sr;++r){var n=t[c[r]];e.labels[r]=o(n.title),"titlefont"in n&&(n.titlefont.color&&(e.labelColor[r]=s(n.titlefont.color)),n.titlefont.family&&(e.labelFont[r]=n.titlefont.family),n.titlefont.size&&(e.labelSize[r]=n.titlefont.size)),"showline"in n&&(e.lineEnable[r]=n.showline),"linecolor"in n&&(e.lineColor[r]=s(n.linecolor)),"linewidth"in n&&(e.lineWidth[r]=n.linewidth),"showgrid"in n&&(e.gridEnable[r]=n.showgrid),"gridcolor"in n&&(e.gridColor[r]=s(n.gridcolor)),"gridwidth"in n&&(e.gridWidth[r]=n.gridwidth),"log"===n.type?e.zeroEnable[r]=!1:"zeroline"in n&&(e.zeroEnable[r]=n.zeroline),"zerolinecolor"in n&&(e.zeroLineColor[r]=s(n.zerolinecolor)),"zerolinewidth"in n&&(e.zeroLineWidth[r]=n.zerolinewidth),"ticks"in n&&n.ticks?e.lineTickEnable[r]=!0:e.lineTickEnable[r]=!1,"ticklen"in n&&(e.lineTickLength[r]=e._defaultLineTickLength[r]=n.ticklen),"tickcolor"in n&&(e.lineTickColor[r]=s(n.tickcolor)),"tickwidth"in n&&(e.lineTickWidth[r]=n.tickwidth),"tickangle"in n&&(e.tickAngle[r]="auto"===n.tickangle?0:Math.PI*-n.tickangle/180),"showticklabels"in n&&(e.tickEnable[r]=n.showticklabels),"tickfont"in n&&(n.tickfont.color&&(e.tickColor[r]=s(n.tickfont.color)),n.tickfont.family&&(e.tickFont[r]=n.tickfont.family),n.tickfont.size&&(e.tickSize[r]=n.tickfont.size)),"mirror"in n?-1!==["ticks","all","allticks"].indexOf(n.mirror)?(e.lineTickMirror[r]=!0,e.lineMirror[r]=!0):n.mirror===!0?(e.lineTickMirror[r]=!1,e.lineMirror[r]=!0):(e.lineTickMirror[r]=!1,e.lineMirror[r]=!1):e.lineMirror[r]=!1,"showbackground"in n&&n.showbackground!==!1?(e.backgroundEnable[r]=!0,e.backgroundColor[r]=s(n.backgroundcolor)):e.backgroundEnable[r]=!1}},e.exports=i},{"../../../lib/html2unicode":380,"../../../lib/str2rgbarray":392,arraytools:49}],444:[function(t,e,r){"use strict";function n(t,e,r,n){for(var a=r("bgcolor"),l=i.combine(a,n.paper_bgcolor),c=Object.keys(o.camera),u=0;ue;++e){var r=t[o[e]];this.enabled[e]=r.showspikes,this.colors[e]=a(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness}},e.exports=i},{"../../../lib/str2rgbarray":392}],447:[function(t,e,r){"use strict";function n(t){for(var e=new Array(3),r=0;3>r;++r){for(var n=t[r],i=new Array(n.length),a=0;au;++u){var f=i[s[u]];if(f._length=(r[u].hi-r[u].lo)*r[u].pixelsPerDataUnit/t.dataScale[u],Math.abs(f._length)===1/0)c[u]=[];else{f.range[0]=r[u].lo/t.dataScale[u],f.range[1]=r[u].hi/t.dataScale[u],f._m=1/(t.dataScale[u]*r[u].pixelsPerDataUnit),f.range[0]===f.range[1]&&(f.range[0]-=1,f.range[1]+=1);var h=f.tickmode;if("auto"===f.tickmode){f.tickmode="linear";var d=f.nticks||a.Lib.constrain(f._length/40,4,9);a.Axes.autoTicks(f,Math.abs(f.range[1]-f.range[0])/d)}for(var p=a.Axes.calcTicks(f),g=0;gu;++u){l[u]=.5*(t.glplot.bounds[0][u]+t.glplot.bounds[1][u]);for(var g=0;2>g;++g)e.bounds[g][u]=t.glplot.bounds[g][u]}t.contourLevels=n(c)}e.exports=i;var a=t("../../../plotly"),o=t("../../../lib/html2unicode"),s=["xaxis","yaxis","zaxis"],l=[0,0,0]},{"../../../lib/html2unicode":380,"../../../plotly":400}],448:[function(t,e,r){"use strict";function n(t,e){var r,n,i=[0,0,0,0];for(r=0;4>r;++r)for(n=0;4>n;++n)i[n]+=t[4*r+n]*e[r];return i}function i(t,e){var r=n(t.projection,n(t.view,n(t.model,[e[0],e[1],e[2],1])));return r}e.exports=i},{}],449:[function(t,e,r){"use strict";function n(t){function e(e,r){if("string"==typeof r)return r;var n=t.fullSceneLayout[e];return g.tickText(n,n.c2l(r),"hover").text}var r,n=t.svgContainer,i=t.container.getBoundingClientRect(),a=i.width,o=i.height;n.setAttributeNS(null,"viewBox","0 0 "+a+" "+o),n.setAttributeNS(null,"width",a),n.setAttributeNS(null,"height",o),A(t),t.glplot.axes.update(t.axesOptions);for(var s=Object.keys(t.traces),l=null,c=t.glplot.selection,u=0;ua;++a)l=u[T[a]],_(l);t?Array.isArray(t)||(t=[t]):t=[];var h=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]];for(a=0;ao;++o)h[0][o]>h[1][o]?d[o]=1:h[1][o]===h[0][o]?d[o]=1:d[o]=1/(h[1][o]-h[0][o]);for(this.dataScale=d,a=0;aa;++a){if(l=u[T[a]],c=l.type,c in x?(x[c].acc*=d[a],x[c].count+=1):x[c]={acc:d[a],count:1},l.autorange){for(y[0][a]=1/0,y[1][a]=-(1/0),o=0;oy[1][a])y[0][a]=-1,y[1][a]=1;else{var k=y[1][a]-y[0][a];y[0][a]-=k/32,y[1][a]+=k/32}}else{var A=u[T[a]].range;y[0][a]=A[0],y[1][a]=A[1]}y[0][a]===y[1][a]&&(y[0][a]-=1,y[1][a]+=1),b[a]=y[1][a]-y[0][a],this.glplot.bounds[0][a]=y[0][a]*d[a],this.glplot.bounds[1][a]=y[1][a]*d[a]}var M=[1,1,1];for(a=0;3>a;++a){l=u[T[a]],c=l.type;var E=x[c];M[a]=Math.pow(E.acc,1/E.count)/d[a]}var L,S=4;if("auto"===u.aspectmode)L=Math.max.apply(null,M)/Math.min.apply(null,M)<=S?M:[1,1,1];else if("cube"===u.aspectmode)L=[1,1,1];else if("data"===u.aspectmode)L=M;else{if("manual"!==u.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var C=u.aspectratio;L=[C.x,C.y,C.z]}u.aspectratio.x=f.aspectratio.x=L[0],u.aspectratio.y=f.aspectratio.y=L[1],u.aspectratio.z=f.aspectratio.z=L[2],this.glplot.aspect=L;var z=u.domain||null,P=e._size||null;if(z&&P){var R=this.container.style;R.position="absolute",R.left=P.l+z.x[0]*P.w+"px",R.top=P.t+(1-z.y[1])*P.h+"px",R.width=P.w*(z.x[1]-z.x[0])+"px",R.height=P.h*(z.y[1]-z.y[0])+"px"}this.glplot.redraw()}},M.destroy=function(){this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null},M.setCameraToDefault=function(){this.setCamera({eye:{x:1.25,y:1.25,z:1.25},center:{x:0,y:0,z:0},up:{x:0,y:0,z:1}})},M.getCamera=function(){return this.glplot.camera.view.recalcMatrix(this.camera.view.lastT()),c(this.glplot.camera)},M.setCamera=function(t){var e={};e[this.id]=t,this.glplot.camera.lookAt.apply(this,l(t)),this.graphDiv.emit("plotly_relayout",e)},M.saveCamera=function(t){function e(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return e[i[r]]&&t[i[r]][a[n]]===e[i[r]][a[n]]}var r=this.getCamera(),n=d.nestedProperty(t,this.id+".camera"),i=n.get(),a=!1;if(void 0===i)a=!0;else for(var o=0;3>o;o++)for(var s=0;3>s;s++)if(!e(r,i,o,s)){a=!0;break}return a&&n.set(r),a},M.updateFx=function(t,e){var r=this.camera;r&&("orbit"===t?(r.mode="orbit",r.keyBindingMode="rotate"):"turntable"===t?(r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate"):r.keyBindingMode=t),this.fullSceneLayout.hovermode=e},M.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(u),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,n=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var i=new Uint8Array(r*n*4);e.readPixels(0,0,r,n,e.RGBA,e.UNSIGNED_BYTE,i);for(var a=0,o=n-1;o>a;++a,--o)for(var s=0;r>s;++s)for(var l=0;4>l;++l){var c=i[4*(r*a+s)+l];i[4*(r*a+s)+l]=i[4*(r*o+s)+l],i[4*(r*o+s)+l]=c}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticMode&&this.container.removeChild(u),p},e.exports=a},{"../../lib":381,"../../lib/show_no_webgl_msg":390,"../../lib/str2rgbarray":392,"../../plots/cartesian/axes":403,"../../plots/cartesian/graph_interact":410,"../../plots/plots":452,"./camera":438,"./layout/convert":443,"./layout/spikes":446,"./layout/tick_marks":447,"./project":448,"./set_convert":450,"gl-plot3d":142}],450:[function(t,e,r){"use strict";var n=t("../cartesian/axes"),i=function(){};e.exports=function(t){n.setConvert(t),t.setScale=i}},{"../cartesian/axes":403}],451:[function(t,e,r){"use strict";var n=t("../plotly"),i=t("./font_attributes"),a=t("../components/color/attributes"),o=n.Lib.extendFlat;e.exports={font:{family:o({},i.family,{dflt:'"Open Sans", verdana, arial, sans-serif'}),size:o({},i.size,{dflt:12}),color:o({},i.color,{dflt:a.defaultLine})},title:{valType:"string",dflt:"Click to enter Plot title"},titlefont:o({},i,{}),autosize:{valType:"enumerated",values:[!0,!1,"initial"]},width:{valType:"number",min:10,dflt:700},height:{valType:"number",min:10,dflt:450},margin:{l:{valType:"number",min:0,dflt:80},r:{valType:"number",min:0,dflt:80},t:{valType:"number",min:0,dflt:100},b:{valType:"number",min:0,dflt:80},pad:{valType:"number",min:0,dflt:0},autoexpand:{valType:"boolean",dflt:!0}},paper_bgcolor:{valType:"color",dflt:a.background},plot_bgcolor:{valType:"color",dflt:a.background},separators:{valType:"string",dflt:".,"},hidesources:{valType:"boolean",dflt:!1},smith:{valType:"enumerated",values:[!1],dflt:!1},showlegend:{valType:"boolean"},_composedModules:{"*":"Fx"},_nestedModules:{xaxis:"Axes",yaxis:"Axes",scene:"gl3d",geo:"geo",legend:"Legend",annotations:"Annotations",shapes:"Shapes",images:"Images",ternary:"ternary"}}},{"../components/color/attributes":302,"../plotly":400,"./font_attributes":421}],452:[function(t,e,r){"use strict";function n(t){return"object"==typeof t&&(t=t.type),t}function i(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#","class":"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){f.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}function a(t,e){for(var r,n=Object.keys(e),i=0;i=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var s=r.select(".js-link-to-tool"),l=r.select(".js-link-spacer"),c=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&i(t,s),l.text(s.text()&&c.text()?" - ":"")},f.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",r=o.select(t).append("div").attr("id","hiddenform").style("display","none"),n=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),i=n.append("input").attr({type:"text",name:"data"});return i.node().value=f.graphJson(t,!1,"keepdata"),n.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1},f.supplyDefaults=function(t){var e,r,n=t._fullLayout||{},i=t._fullLayout={},o=t.layout||{},s=t._fullData||[],u=t._fullData=[],h=t.data||[],d=i._modules=[],p=i._basePlotModules=[];for(f.supplyLayoutGlobalDefaults(o,i),i._dataLength=h.length,e=0;ea&&(e=(r-1)/(i.l+i.r),i.l=Math.floor(e*i.l),i.r=Math.floor(e*i.r)),0>o&&(e=(n-1)/(i.t+i.b),i.t=Math.floor(e*i.t),i.b=Math.floor(e*i.b))}},f.autoMargin=function(t,e,r){var n=t._fullLayout;if(n._pushmargin||(n._pushmargin={}),n.margin.autoexpand!==!1){if(r){var i=void 0===r.pad?12:r.pad;r.l+r.r>.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0),n._pushmargin[e]={l:{val:r.x,size:r.l+i},r:{val:r.x,size:r.r+i},b:{val:r.y,size:r.b+i},t:{val:r.y,size:r.t+i}}}else delete n._pushmargin[e];t._replotting||f.doAutoMargin(t)}},f.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var r=e._size,n=JSON.stringify(r),i=Math.max(e.margin.l||0,0),a=Math.max(e.margin.r||0,0),o=Math.max(e.margin.t||0,0),c=Math.max(e.margin.b||0,0),u=e._pushmargin;return e.margin.autoexpand!==!1&&(u.base={l:{val:0,size:i},r:{val:1,size:a},t:{val:1,size:o},b:{val:0,size:c}},Object.keys(u).forEach(function(t){var r=u[t].l||{},n=u[t].b||{},l=r.val,f=r.size,h=n.val,d=n.size;Object.keys(u).forEach(function(t){if(s(f)&&u[t].r){var r=u[t].r.val,n=u[t].r.size;if(r>l){var p=(f*r+(n-e.width)*l)/(r-l),g=(n*(1-l)+(f-e.width)*(1-r))/(r-l);p>=0&&g>=0&&p+g>i+a&&(i=p,a=g)}}if(s(d)&&u[t].t){var v=u[t].t.val,m=u[t].t.size;if(v>h){var y=(d*v+(m-e.height)*h)/(v-h),b=(m*(1-h)+(d-e.height)*(1-v))/(v-h);y>=0&&b>=0&&y+b>c+o&&(c=y,o=b)}}})})),r.l=Math.round(i),r.r=Math.round(a),r.t=Math.round(o),r.b=Math.round(c),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,t._replotting||"{}"===n||n===JSON.stringify(e._size)?void 0:l.plot(t)},f.graphJson=function(t,e,r,n,i){function a(t){if("function"==typeof t)return null;if(c.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0&&!c.isPlainObject(t.stream))continue}else if("keepall"!==r&&(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0))continue;i[e]=a(t[e])}return i}return Array.isArray(t)?t.map(a):t&&t.getTime?c.ms2DateTime(t):t}(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&f.supplyDefaults(t);var o=i?t._fullData:t.data,s=i?t._fullLayout:t.layout,l={data:(o||[]).map(function(t){var r=a(t);return e&&delete r.fit,r})};return e||(l.layout=a(s)),t.framework&&t.framework.isPolar&&(l=t.framework.getConfig()),"object"===n?l:JSON.stringify(l)}},{"../components/color":303,"../lib":381,"../plotly":400,"./attributes":401,"./font_attributes":421,"./layout_attributes":451,d3:72,"fast-isnumeric":76}],453:[function(t,e,r){"use strict";var n=t("../../traces/scatter/attributes"),i=n.marker;e.exports={r:n.r,t:n.t,marker:{color:i.color,size:i.size,symbol:i.symbol,opacity:i.opacity}}},{"../../traces/scatter/attributes":554}],454:[function(t,e,r){"use strict";function n(t,e){var r={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return a({},e,r)}var i=t("../cartesian/layout_attributes"),a=t("../../lib/extend").extendFlat,o=a({},i.domain,{});e.exports={radialaxis:n("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:o,orientation:{valType:"number"}}),angularaxis:n("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:o}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":376,"../cartesian/layout_attributes":412}],455:[function(t,e,r){var n=t("../../plotly"),i=t("d3"),a=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},o=n.Lib.extendDeepAll;a.Axis=function(){function t(t){r=t||r;var c=l.data,f=l.layout;return("string"==typeof r||r.nodeName)&&(r=i.select(r)),r.datum(c).each(function(t,r){function l(t,e){return s(t)%360+f.orientation}var c=t.slice();u={data:a.util.cloneJson(c),layout:a.util.cloneJson(f)};var h=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[h],h=(h+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:i.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var d=c.filter(function(t,e){var r=t.visible;return"undefined"==typeof r||r===!0}),p=!1,g=d.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=i.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var r=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,n){t.yStack=[r],m.push(r),r=a.util.sumArrays(t.r,r)}),t.values});d=i.merge(y)}d.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var b=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;b=Math.max(10,b);var x,_=[f.margin.left+b,f.margin.top+b];if(p){var w=i.max(a.util.sumArrays(a.util.arrayLast(d).r[0],a.util.arrayLast(m)));x=[0,w]}else x=i.extent(a.util.flattenArray(d.map(function(t,e){return t.r})));f.radialAxis.domain!=a.DATAEXTENT&&(x[0]=0),n=i.scale.linear().domain(f.radialAxis.domain!=a.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:x).range([0,b]),u.layout.radialAxis.domain=n.domain();var k,A=a.util.flattenArray(d.map(function(t,e){return t.t})),M="string"==typeof A[0];M&&(A=a.util.deduplicate(A),k=A.slice(),A=i.range(A.length),d=d.map(function(t,e){var r=t;return t.t=[A],p&&(r.yStack=t.yStack),r}));var T=d.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===d.length,E=null===f.needsEndSpacing?M||!T:f.needsEndSpacing,L=f.angularAxis.domain&&f.angularAxis.domain!=a.DATAEXTENT&&!M&&f.angularAxis.domain[0]>=0,S=L?f.angularAxis.domain:i.extent(A),C=Math.abs(A[1]-A[0]);T&&!M&&(C=0);var z=S.slice();E&&M&&(z[1]+=C);var P=f.angularAxis.ticksCount||4;P>8&&(P=P/(P/8)+P%8),f.angularAxis.ticksStep&&(P=(z[1]-z[0])/P);var R=f.angularAxis.ticksStep||(z[1]-z[0])/(P*(f.minorTicks+1));k&&(R=Math.max(Math.round(R),1)),z[2]||(z[2]=R);var O=i.range.apply(this,z);if(O=O.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=i.scale.linear().domain(z.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=s.domain(),u.layout.angularAxis.endPadding=E?C:0,e=i.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var I="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",N=(new DOMParser).parseFromString(I,"application/xml"),j=this.appendChild(this.ownerDocument.importNode(N.documentElement,!0));e=i.select(j)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var F,D=e.select(".chart-group"),B={fill:"none",stroke:f.tickColor},U={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){F=e.select(".legend-group").attr({transform:"translate("+[b,f.margin.top]+")"}).style({display:"block"});var V=d.map(function(t,e){var r=a.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});a.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:o({},a.Legend.defaultConfig().legendConfig,{container:F,elements:V,reverseOrder:f.legend.reverseOrder})})();var q=F.node().getBBox();b=Math.min(f.width-q.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,b=Math.max(10,b),_=[f.margin.left+b,f.margin.top+b],n.range([0,b]),u.layout.radialAxis.domain=n.domain(),F.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else F=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),D.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(f.width-(f.margin.left+f.margin.right+2*b+(q?q.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*b))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),e.select(".outer-group").attr("transform","translate("+H+")"),f.title){var G=e.select("g.title-group text").style(U).text(f.title),Y=G.node().getBBox();G.attr({x:_[0]-Y.width/2,y:_[1]-b-20})}var X=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var W=X.selectAll("circle.grid-circle").data(n.ticks(5));W.enter().append("circle").attr({"class":"grid-circle"}).style(B),W.attr("r",n),W.exit().remove()}X.select("circle.outside-circle").attr({r:b}).style(B);var Z=e.select("circle.background-circle").attr({r:b}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var K=i.svg.axis().scale(n).ticks(5).tickSize(5);X.call(K).attr({transform:"rotate("+f.radialAxis.orientation+")"}),X.selectAll(".domain").style(B),X.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(U).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,U["font-size"]]+")":"translate("+[0,U["font-size"]]+")"}}),X.selectAll("g>line").style({stroke:"black"})}var $=e.select(".angular.axis-group").selectAll("g.angular-tick").data(O),Q=$.enter().append("g").classed("angular-tick",!0);$.attr({transform:function(t,e){return"rotate("+l(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),$.exit().remove(),Q.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(B),Q.selectAll(".minor").style({stroke:f.minorTickColor}),$.select("line.grid-line").attr({x1:f.tickLength?b-f.tickLength:0,x2:b}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),Q.append("text").classed("axis-text",!0).style(U);var J=$.select("text.axis-text").attr({x:b+f.labelOffset,dy:".35em",transform:function(t,e){var r=l(t,e),n=b+f.labelOffset,i=f.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?270>r&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(180>=r&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(U);f.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=i.max(D.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));F.attr({transform:"translate("+[b+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,rt=e.select("g.geometry-group").selectAll("g.geometry").data(d);if(rt.enter().append("g").attr({"class":function(t,e){return"geometry geometry"+e}}),rt.exit().remove(),d[0]||et){var nt=[];d.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=s,r.container=rt.filter(function(t,r){return r==e}),r.geometry=t.geometry,r.orientation=f.orientation,r.direction=f.direction,r.index=e,nt.push({data:t,geometryConfig:r})});var it=i.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(nt),at=[];it.forEach(function(t,e){"unstacked"===t.key?at=at.concat(t.values.map(function(t,e){return[t]})):at.push(t.values)}),at.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return o(a[r].defaultConfig(),t)});a[r]().config(n)()})}var ot,st,lt=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=a.tooltipPanel().config({container:ct,fontSize:8})(),ft=a.tooltipPanel().config({container:ct,fontSize:8})(),ht=a.tooltipPanel().config({container:ct,hasTick:!0})();if(!M){var dt=lt.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});D.on("mousemove.angular-guide",function(t,e){var r=a.util.getMousePos(Z).angle;dt.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-f.orientation)%360;ot=s.invert(n);var i=a.util.convertToCartesian(b+12,r+180);ut.text(a.util.round(ot)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){lt.select("line").style({opacity:0})})}var pt=lt.select("circle").style({stroke:"grey",fill:"none"});D.on("mousemove.radial-guide",function(t,e){var r=a.util.getMousePos(Z).radius;pt.attr({r:r}).style({opacity:.5}),st=n.invert(a.util.getMousePos(Z).radius);var i=a.util.convertToCartesian(r,f.radialAxis.orientation);ft.text(a.util.round(st)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),ht.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,r){var n=i.select(this),o=n.style("fill"),s="black",l=n.style("opacity")||1;if(n.attr({"data-opacity":l}),"none"!=o){n.attr({"data-fill":o}),s=i.hsl(o).darker().toString(),n.style({fill:s,opacity:1});var c={t:a.util.round(t[0]),r:a.util.round(t[1])};M&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),h=e.node().getBoundingClientRect(),d=[f.left+f.width/2-H[0]-h.left,f.top+f.height/2-H[1]-h.top];ht.config({color:s}).text(u),ht.move(d)}else o=n.style("stroke"),n.attr({"data-stroke":o}),s=i.hsl(o).darker().toString(),n.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0!=i.event.which?!1:void(i.select(this).attr("data-fill")&&ht.show())}).on("mouseout.tooltip",function(t,e){ht.hide();var r=i.select(this),n=r.attr("data-fill");n?r.style({fill:n,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})}),h}var e,r,n,s,l={ -data:[],layout:{}},c={},u={},f=i.dispatch("hover"),h={};return h.render=function(e){return t(e),this},h.config=function(t){if(!arguments.length)return l;var e=a.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),o(l.data[e],a.Axis.defaultConfig().data[0]),o(l.data[e],t)}),o(l.layout,a.Axis.defaultConfig().layout),o(l.layout,e.layout),this},h.getLiveConfig=function(){return u},h.getinputConfig=function(){return c},h.radialScale=function(t){return n},h.angularScale=function(t){return s},h.svg=function(){return e},i.rebind(h,f,"on"),h},a.Axis.defaultConfig=function(t,e){var r={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:i.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return r},a.util={},a.DATAEXTENT="dataExtent",a.AREA="AreaChart",a.LINE="LinePlot",a.DOT="DotPlot",a.BAR="BarChart",a.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},a.util._extend=function(t,e){for(var r in t)e[r]=t[r]},a.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},a.util.dataFromEquation2=function(t,e){var r=e||6,n=i.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180,i=t(n);return[e,i]});return n},a.util.dataFromEquation=function(t,e,r){var n=e||6,a=[],o=[];i.range(0,360+n,n).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},a.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return i.range(e).map(function(t,e){return r[e]||r[0]})},a.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=a.util.ensureArray(t[e],r)}),t},a.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},a.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},a.util.sumArrays=function(t,e){return i.zip(t,e).map(function(t,e){return i.sum(t)})},a.util.arrayLast=function(t){return t[t.length-1]},a.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},a.util.flattenArray=function(t){for(var e=[];!a.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},a.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},a.util.convertToCartesian=function(t,e){var r=e*Math.PI/180,n=t*Math.cos(r),i=t*Math.sin(r);return[n,i]},a.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},a.util.getMousePos=function(t){var e=i.mouse(t.node()),r=e[0],n=e[1],a={};return a.x=r,a.y=n,a.pos=e,a.angle=180*(Math.atan2(n,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+n*n),a},a.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;a>i;i++)e=t[i],e in r?(r[e]++,n[e]=r[e]):r[e]=1;return n},a.util.duplicates=function(t){return Object.keys(a.util.duplicatesCount(t))},a.util.translator=function(t,e,r,n){if(n){var i=r.slice();r=e,e=i}var a=e.reduce(function(t,e){return"undefined"!=typeof t?t[e]:void 0},t);"undefined"!=typeof a&&(e.reduce(function(t,r,n){return"undefined"!=typeof t?(n===e.length-1&&delete t[r],t[r]):void 0},t),r.reduce(function(t,e,n){return"undefined"==typeof t[e]&&(t[e]={}),n===r.length-1&&(t[e]=a),t[e]},t))},a.PolyChart=function(){function t(){var t=r[0].geometryConfig,e=t.container;"string"==typeof e&&(e=i.select(e)),e.datum(r).each(function(e,r){function n(e,r){var n=t.radialScale(e[1]),i=(t.angularScale(e[0])+t.orientation)*Math.PI/180;return{r:n,t:i}}function a(t){var e=t.r*Math.cos(t.t),r=t.r*Math.sin(t.t);return{x:e,y:r}}var o=!!e[0].data.yStack,l=e.map(function(t,e){return o?i.zip(t.data.t[0],t.data.r[0],t.data.yStack[0]):i.zip(t.data.t[0],t.data.r[0])}),c=t.angularScale,u=t.radialScale.domain()[0],f={};f.bar=function(r,n,a){var o=e[a].data,s=t.radialScale(r[1])-t.radialScale(0),l=t.radialScale(r[2]||0),u=o.barWidth;i.select(this).attr({"class":"mark bar",d:"M"+[[s+l,-u/2],[s+l,u/2],[l,u/2],[l,-u/2]].join("L")+"Z",transform:function(e,r){return"rotate("+(t.orientation+c(e[0]))+")"}})},f.dot=function(t,r,o){var s=t[2]?[t[0],t[1]+t[2]]:t,l=i.svg.symbol().size(e[o].data.dotSize).type(e[o].data.dotType)(t,r);i.select(this).attr({"class":"mark dot",d:l,transform:function(t,e){var r=a(n(s));return"translate("+[r.x,r.y]+")"}})};var h=i.svg.line.radial().interpolate(e[0].data.lineInterpolation).radius(function(e){return t.radialScale(e[1])}).angle(function(e){return t.angularScale(e[0])*Math.PI/180});f.line=function(r,n,a){var o=r[2]?l[a].map(function(t,e){return[t[0],t[1]+t[2]]}):l[a];if(i.select(this).each(f.dot).style({opacity:function(t,r){return+e[a].data.dotVisible},fill:v.stroke(r,n,a)}).attr({"class":"mark dot"}),!(n>0)){var s=i.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({"class":"line",d:h(o),transform:function(e,r){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(r,n,a)},"fill-opacity":0,stroke:function(t,e){return v.stroke(r,n,a)},"stroke-width":function(t,e){return v["stroke-width"](r,n,a)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](r,n,a)},opacity:function(t,e){return v.opacity(r,n,a)},display:function(t,e){return v.display(r,n,a)}})}};var d=t.angularScale.range(),p=Math.abs(d[1]-d[0])/l[0].length*Math.PI/180,g=i.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,r,n){i.select(this).attr({"class":"mark arc",d:g,transform:function(e,r){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var v={fill:function(t,r,n){return e[n].data.color},stroke:function(t,r,n){return e[n].data.strokeColor},"stroke-width":function(t,r,n){return e[n].data.strokeSize+"px"},"stroke-dasharray":function(t,r,n){return s[e[n].data.strokeDash]},opacity:function(t,r,n){return e[n].data.opacity},display:function(t,r,n){return"undefined"==typeof e[n].data.visible||e[n].data.visible?"block":"none"}},m=i.select(this).selectAll("g.layer").data(l);m.enter().append("g").attr({"class":"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({"class":"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,r=[a.PolyChart.defaultConfig()],n=i.dispatch("hover"),s={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){r[e]||(r[e]={}),o(r[e],a.PolyChart.defaultConfig()),o(r[e],t)}),this):r},t.getColorScale=function(){return e},i.rebind(t,n,"on"),t},a.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:i.scale.category20()}};return t},a.BarChart=function(){return a.PolyChart()},a.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},a.AreaChart=function(){return a.PolyChart()},a.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},a.DotPlot=function(){return a.PolyChart()},a.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},a.LinePlot=function(){return a.PolyChart()},a.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},a.Legend=function(){function t(){var r=e.legendConfig,n=e.data.map(function(t,e){return[].concat(t).map(function(t,n){var i=o({},r.elements[e]);return i.name=t,i.color=[].concat(r.elements[e].color)[n],i})}),a=i.merge(n);a=a.filter(function(t,e){return r.elements[e]&&(r.elements[e].visibleInLegend||"undefined"==typeof r.elements[e].visibleInLegend)}),r.reverseOrder&&(a=a.reverse());var s=r.container;("string"==typeof s||s.nodeName)&&(s=i.select(s));var l=a.map(function(t,e){return t.color}),c=r.fontSize,u=null==r.isContinuous?"number"==typeof a[0]:r.isContinuous,f=u?r.height:c*a.length,h=s.classed("legend-group",!0),d=h.selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=i.range(a.length),v=i.scale[u?"linear":"ordinal"]().domain(g).range(l),m=i.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var r=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=i.svg.symbolTypes.indexOf(t)?i.svg.symbol().type(t).size(r)():i.svg.symbol().type("square").size(r)()};if(u){var b=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);b.enter().append("stop"),b.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:r.height,width:r.colorBandWidth,fill:"url(#grad1)"})}else{var x=d.select(".legend-marks").selectAll("path.legend-mark").data(a);x.enter().append("path").classed("legend-mark",!0),x.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var r=t.symbol;return y(r,c)},fill:function(t,e){return v(e)}}),x.exit().remove()}var _=i.svg.axis().scale(m).orient("right"),w=d.select("g.legend-axis").attr({transform:"translate("+[u?r.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?r.textColor:"none"}),w.selectAll("text").style({fill:r.textColor,"font-size":r.fontSize}).text(function(t,e){return a[e].name}),t}var e=a.Legend.defaultConfig(),r=i.dispatch("hover");return t.config=function(t){return arguments.length?(o(e,t),this):e},i.rebind(t,r,"on"),t},a.Legend.defaultConfig=function(t,e){var r={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return r},a.tooltipPanel=function(){var t,e,r,n={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+a.tooltipPanel.uid++,l=10,c=function(){t=n.container.selectAll("g."+s).data([0]);var i=t.enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=i.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=i.append("text").attr({dx:n.padding+l,dy:.3*+n.fontSize}),c};return c.text=function(a){var o=i.hsl(n.color).l,s=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":n.fontSize+"px"}).text(f);var h=n.padding,d=e.node().getBBox(),p={fill:n.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[n.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),c},c.move=function(e){return t?(t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c):void 0},c.hide=function(){return t?(t.style({display:"none"}),c):void 0},c.show=function(){return t?(t.style({display:"block"}),c):void 0},c.config=function(t){return o(n,t),c},c},a.tooltipPanel.uid=1,a.adapter={},a.adapter.plotly=function(){var t={};return t.convert=function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=o({},t),i=[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]];return i.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",n.dotVisible===!0?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var n=a.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var i=n.indexOf(t.geometry);-1!=i&&(r.data[e].groupId=i)})}if(t.layout){var s=o({},t.layout),l=[[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]];if(l.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};i.entries(s.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),s.margin=f}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r},t}},{"../../plotly":400,"./micropolar_manager":456,d3:72}],456:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("d3"),a=t("./undo_manager"),o=e.exports={},s=n.Lib.extendDeepAll;o.framework=function(t){function e(e,a){return a&&(f=a),i.select(i.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),r=r?s(r,e):e,c||(c=n.micropolar.Axis()),u=n.micropolar.adapter.plotly().convert(r),c.config(u).render(f),t.data=r.data,t.layout=r.layout,o.fillLayout(t),r}var r,l,c,u,f,h=new a;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return r},e.getLiveConfig=function(){return n.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=n.micropolar.util.cloneJson(r);!function(e,r){h.add({undo:function(){r&&t(r)},redo:function(){t(e)}})}(e,l),l=n.micropolar.util.cloneJson(e)},e.undo=function(){h.undo()},e.redo=function(){h.redo()},e},o.fillLayout=function(t){var e=i.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:n.Color.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../plotly":400,"./undo_manager":457,d3:72}],457:[function(t,e,r){"use strict";e.exports=function(){function t(t,e){return t?(i=!0,t[e](),i=!1,this):this}var e,r=[],n=-1,i=!1;return{add:function(t){return i?this:(r.splice(n+1,r.length-n),r.push(t),n=r.length-1,this)},setCallback:function(t){e=t},undo:function(){var i=r[n];return i?(t(i,"undo"),n-=1,e&&e(i.undo),this):this},redo:function(){var i=r[n+1];return i?(t(i,"redo"),n+=1,e&&e(i.redo),this):this},clear:function(){r=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return ng;g++){var v=d[g];s=t[v]?t[v]:t[v]={},e[v]=l={},o("domain."+h,[g/p,(g+1)/p]),o("domain."+{x:"y",y:"x"}[h]),a.id=v,f(s,l,o,a)}}},{"../lib":381,"./plots":452}],459:[function(t,e,r){"use strict";var n=t("./ternary"),i=t("../../plots/plots");r.name="ternary",r.attr="subplot",r.idRoot="ternary",r.idRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"ternary"),o=0;o=o&&(d.min=0,p.min=0,g.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}var i=t("../../../components/color"),a=t("../../subplot_defaults"),o=t("./layout_attributes"),s=t("./axis_defaults"),l=["aaxis","baxis","caxis"];e.exports=function(t,e,r){a(t,e,r,{type:"ternary",attributes:o,handleDefaults:n,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../../components/color":303,"../../subplot_defaults":458,"./axis_defaults":462,"./layout_attributes":464}],464:[function(t,e,r){"use strict";var n=t("../../../components/color/attributes"),i=t("./axis_attributes");e.exports={domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},bgcolor:{valType:"color",dflt:n.background},sum:{valType:"number",dflt:1,min:0},aaxis:i,baxis:i,caxis:i}},{"../../../components/color/attributes":302,"./axis_attributes":461}],465:[function(t,e,r){"use strict";function n(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework()}function i(t){a.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var a=t("d3"),o=t("tinycolor2"),s=t("../../plotly"),l=t("../../lib"),c=t("../../components/color"),u=t("../../components/drawing"),f=t("../cartesian/set_convert"),h=t("../../lib/extend").extendFlat,d=t("../cartesian/axes"),p=t("../../lib/filter_visible"),g=t("../../components/dragelement"),v=t("../../components/titles"),m=t("../cartesian/select"),y=t("../cartesian/constants"),b=t("../cartesian/graph_interact");e.exports=n;var x=n.prototype;x.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={}},x.plot=function(t,e){var r,n=this,i=e[n.id],a=e._size;l.getPlotDiv(n.plotContainer.node())!==n.graphDiv&&(n.init(n.graphDiv._fullLayout),n.makeFramework()),n.adjustLayout(i,a);var o=n.traceHash,s={};for(r=0;r_*y?(a=y,i=a*_):(i=m,a=i/_),o=g*i/m,s=v*a/y,r=e.l+e.w*d-i/2,n=e.t+e.h*(1-p)-a/2,l.x0=r,l.y0=n,l.w=i,l.h=a,l.sum=b,l.xaxis={type:"linear",range:[x+2*k-b,b-x-2*w],domain:[d-o/2,d+o/2],_id:"x",_gd:l.graphDiv},f(l.xaxis),l.xaxis.setScale(),l.yaxis={type:"linear",range:[x,b-w-k],domain:[p-s/2,p+s/2],_id:"y",_gd:l.graphDiv},f(l.yaxis),l.yaxis.setScale();var A=l.yaxis.domain[0],M=l.aaxis=h({},t.aaxis,{range:[x,b-w-k],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[A,A+s*_],_axislayer:l.layers.aaxis,_gridlayer:l.layers.agrid,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l"+a+",-"+i/2});f(M);var T=l.baxis=h({},t.baxis,{range:[b-x-k,w],side:"bottom",_counterangle:30,domain:l.xaxis.domain,_axislayer:l.layers.baxis,_gridlayer:l.layers.bgrid,_counteraxis:l.aaxis,_pos:0,_gd:l.graphDiv,_id:"x",_length:i,_gridpath:"M0,0l-"+i/2+",-"+a});f(T),M._counteraxis=T;var E=l.caxis=h({},t.caxis,{range:[b-x-w,k],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[A,A+s*_],_axislayer:l.layers.caxis,_gridlayer:l.layers.cgrid,_counteraxis:l.baxis,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l-"+a+","+i/2});f(E);var L="M"+r+","+(n+a)+"h"+i+"l-"+i/2+",-"+a+"Z";l.clipDef.select("path").attr("d",L),l.layers.plotbg.select("path").attr("d",L);var S="translate("+r+","+n+")";l.plotContainer.selectAll(".scatterlayer,.maplayer,.zoom").attr("transform",S);var C="translate("+r+","+(n+a)+")";l.layers.baxis.attr("transform",C),l.layers.bgrid.attr("transform",C);var z="translate("+(r+i/2)+","+n+")rotate(30)";l.layers.aaxis.attr("transform",z),l.layers.agrid.attr("transform",z);var P="translate("+(r+i/2)+","+n+")rotate(-30)";l.layers.caxis.attr("transform",P),l.layers.cgrid.attr("transform",P),l.drawAxes(!0),l.plotContainer.selectAll(".crisp").classed("crisp",!1);var R=l.layers.axlines;R.select(".aline").attr("d",M.showline?"M"+r+","+(n+a)+"l"+i/2+",-"+a:"M0,0").call(c.stroke,M.linecolor||"#000").style("stroke-width",(M.linewidth||0)+"px"),R.select(".bline").attr("d",T.showline?"M"+r+","+(n+a)+"h"+i:"M0,0").call(c.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),R.select(".cline").attr("d",E.showline?"M"+(r+i/2)+","+n+"l"+i/2+","+a:"M0,0").call(c.stroke,E.linecolor||"#000").style("stroke-width",(E.linewidth||0)+"px")},x.drawAxes=function(t){var e=this,r=e.graphDiv,n=e.id.substr(7)+"title",i=e.aaxis,a=e.baxis,o=e.caxis;if(d.doTicks(r,i,!0),d.doTicks(r,a,!0),d.doTicks(r,o,!0),t){var s=Math.max(i.showticklabels?i.tickfont.size/2:0,(o.showticklabels?.75*o.tickfont.size:0)+("outside"===o.ticks?.87*o.ticklen:0));v.draw(r,"a"+n,{propContainer:i,propName:e.id+".aaxis.title",dfltName:"Component A",attributes:{x:e.x0+e.w/2,y:e.y0-i.titlefont.size/3-s,"text-anchor":"middle"}});var l=(a.showticklabels?a.tickfont.size:0)+("outside"===a.ticks?a.ticklen:0)+3;v.draw(r,"b"+n,{propContainer:a,propName:e.id+".baxis.title",dfltName:"Component B",attributes:{x:e.x0-l,y:e.y0+e.h+.83*a.titlefont.size+l,"text-anchor":"middle"}}),v.draw(r,"c"+n,{propContainer:o,propName:e.id+".caxis.title",dfltName:"Component C",attributes:{x:e.x0+e.w+l,y:e.y0+e.h+.83*o.titlefont.size+l,"text-anchor":"middle"}})}};var w=y.MINZOOM/2+.87,k="m-0.87,.5h"+w+"v3h-"+(w+5.2)+"l"+(w/2+2.6)+",-"+(.87*w+4.5)+"l2.6,1.5l-"+w/2+","+.87*w+"Z",A="m0.87,.5h-"+w+"v3h"+(w+5.2)+"l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-2.6,1.5l"+w/2+","+.87*w+"Z",M="m0,1l"+w/2+","+.87*w+"l2.6,-1.5l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-"+(w/2+2.6)+","+(.87*w+4.5)+"l2.6,1.5l"+w/2+",-"+.87*w+"Z",T="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",E=!0;x.initInteractions=function(){function t(t,e,r){var n=j.getBoundingClientRect();x=e-n.left,w=r-n.top,L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L,S=N.aaxis.range[1]-L.a,z=o(N.graphDiv._fullLayout[N.id].bgcolor).getLuminance(),P="M0,"+N.h+"L"+N.w/2+", 0L"+N.w+","+N.h+"Z",R=!1,O=D.append("path").attr("class","zoombox").style({fill:z>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",P),I=D.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),p()}function e(t,e){return 1-e/N.h}function r(t,e){return 1-(t+(N.h-e)/Math.sqrt(3))/N.w}function n(t,e){return(t-(N.h-e)/Math.sqrt(3))/N.w}function a(t,i){var a=x+t,o=w+i,s=Math.max(0,Math.min(1,e(x,w),e(a,o))),l=Math.max(0,Math.min(1,r(x,w),r(a,o))),c=Math.max(0,Math.min(1,n(x,w),n(a,o))),u=(s/2+c)*N.w,f=(1-s/2-l)*N.w,h=(u+f)/2,d=f-u,p=(1-s)*N.h,g=p-d/_;d.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),I.transition().style("opacity",1).duration(200),R=!0)}function u(t,e){if(C===L)return 2===e&&v(),i(F);i(F);var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r),E&&F.data&&F._context.showTips&&(l.notifier("Double-click to
zoom back out","long"),E=!1)}function f(){L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L}function h(t,e){var r=t/N.xaxis._m,n=e/N.yaxis._m;C={a:L.a-n,b:L.b+(r+n)/2,c:L.c-(r-n)/2};var i=[C.a,C.b,C.c].sort(),a={a:i.indexOf(C.a),b:i.indexOf(C.b),c:i.indexOf(C.c)};i[0]<0&&(i[1]+i[0]/2<0?(i[2]+=i[0]+i[1],i[0]=i[1]=0):(i[2]+=i[0]/2,i[1]+=i[0]/2,i[0]=0),C={a:i[a.a],b:i[a.b],c:i[a.c]},e=(L.a-C.a)*N.yaxis._m,t=(L.c-C.c-L.b+C.b)*N.xaxis._m);var o="translate("+(N.x0+t)+","+(N.y0+e)+")";N.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",o),N.aaxis.range=[C.a,N.sum-C.b-C.c],N.baxis.range=[N.sum-C.a-C.c,C.b],N.caxis.range=[N.sum-C.a-C.b,C.c],N.drawAxes(!1),N.plotContainer.selectAll(".crisp").classed("crisp",!1)}function d(t,e){if(t){var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r)}else 2===e&&v(); -}function p(){N.plotContainer.selectAll(".select-outline").remove()}function v(){var t={};t[N.id+".aaxis.min"]=0,t[N.id+".baxis.min"]=0,t[N.id+".caxis.min"]=0,F.emit("plotly_doubleclick",null),s.relayout(F,t)}var x,w,L,S,C,z,P,R,O,I,N=this,j=N.layers.plotbg.select("path").node(),F=N.graphDiv,D=N.layers.zoom,B={element:j,gd:F,plotinfo:{plot:D},doubleclick:v,subplot:N.id,prepFn:function(e,r,n){B.xaxes=[N.xaxis],B.yaxes=[N.yaxis];var i=F._fullLayout.dragmode;e.shiftKey&&(i="pan"===i?"zoom":"pan"),"lasso"===i?B.minDrag=1:B.minDrag=void 0,"zoom"===i?(B.moveFn=a,B.doneFn=u,t(e,r,n)):"pan"===i?(B.moveFn=h,B.doneFn=d,f(),p()):"select"!==i&&"lasso"!==i||m(e,r,n,B,i)}};g.init(B),j.onmousemove=function(t){b.hover(F,t,N.id),F._fullLayout._lasthover=j,F._fullLayout._hoversubplot=N.id},j.onmouseout=function(t){F._dragging||g.unhover(F,t)},j.onclick=function(t){b.click(F,t)},F._fullLayout._plots||(F._fullLayout._plots={}),F._fullLayout._plots[N.id]={overlays:[],xaxis:N.xaxis,yaxis:N.yaxis,x:function(){return N.xaxis},y:function(){return N.yaxis}}}},{"../../components/color":303,"../../components/dragelement":323,"../../components/drawing":325,"../../components/titles":365,"../../lib":381,"../../lib/extend":376,"../../lib/filter_visible":377,"../../plotly":400,"../cartesian/axes":403,"../cartesian/constants":408,"../cartesian/graph_interact":410,"../cartesian/select":416,"../cartesian/set_convert":417,d3:72,tinycolor2:233}],466:[function(t,e,r){"use strict";function n(t){var e;switch(t){case"themes__thumb":e={autosize:!0,width:150,height:150,title:"",showlegend:!1,margin:{l:5,r:5,t:5,b:5,pad:0},annotations:[]};break;case"thumbnail":e={title:"",hidesources:!0,showlegend:!1,borderwidth:0,bordercolor:"",margin:{l:1,r:1,t:1,b:1,pad:0},annotations:[]};break;default:e={}}return e}function i(t){var e=["xaxis","yaxis","zaxis"];return e.indexOf(t.slice(0,5))>-1}var a=t("../plotly"),o=a.Lib.extendFlat,s=a.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var r,l=t.data,c=t.layout,u=s([],l),f=s({},c,n(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var h=Object.keys(f);for(r=0;rl;l++)n(r[l])&&d.push({p:r[l],s:s[l],b:0});return a(e,"marker")&&o(e,e.marker.color,"marker","c"),a(e,"marker.line")&&o(e,e.marker.line.color,"marker.line","c"),d}},{"../../components/colorscale/calc":310,"../../components/colorscale/has_colorscale":315,"../../plots/cartesian/axes":403,"fast-isnumeric":76}],476:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("../scatter/xy_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=a(t,e,u);return f?(u("orientation",e.x&&!e.y?"h":"v"),u("text"),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),void s(t,e,i.defaultLine,{axis:"x",inherit:"y"})):void(e.visible=!1)}},{"../../components/color":303,"../../components/errorbars/defaults":330,"../../lib":381,"../bar/style_defaults":484,"../scatter/xy_defaults":575,"./attributes":474}],477:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../components/errorbars"),a=t("../../components/color");e.exports=function(t,e,r,o){var s,l=t.cd,c=l[0].trace,u=l[0].t,f=t.xa,h=t.ya,d="closest"===o?u.barwidth/2:u.dbar*(1-f._gd._fullLayout.bargap)/2;s="closest"!==o?function(t){return t.p}:"h"===c.orientation?function(t){return t.y}:function(t){return t.x};var p,g;"h"===c.orientation?(p=function(t){return n.inbox(t.b-e,t.x-e)+(t.x-e)/(t.x-t.b)},g=function(t){var e=s(t)-r;return n.inbox(e-d,e+d)}):(g=function(t){return n.inbox(t.b-r,t.y-r)+(t.y-r)/(t.y-t.b)},p=function(t){var r=s(t)-e;return n.inbox(r-d,r+d)});var v=n.getDistanceFunction(o,p,g);if(n.getClosest(l,v,t),t.index!==!1){var m=l[t.index],y=m.mcc||c.marker.color,b=m.mlcc||c.marker.line.color,x=m.mlw||c.marker.line.width;return a.opacity(y)?t.color=y:a.opacity(b)&&x&&(t.color=b),"h"===c.orientation?(t.x0=t.x1=f.c2p(m.x,!0),t.xLabelVal=m.s,t.y0=h.c2p(s(m)-d,!0),t.y1=h.c2p(s(m)+d,!0),t.yLabelVal=m.p):(t.y0=t.y1=h.c2p(m.y,!0),t.yLabelVal=m.s,t.x0=f.c2p(s(m)-d,!0),t.x1=f.c2p(s(m)+d,!0),t.xLabelVal=m.p),m.tx&&(t.text=m.tx),i.hoverInfo(m,c,t),[t]}}},{"../../components/color":303,"../../components/errorbars":331,"../../plots/cartesian/graph_interact":410}],478:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("./layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.calc=t("./calc"),n.setPositions=t("./set_positions"),n.colorbar=t("../scatter/colorbar"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.moduleType="trace",n.name="bar",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","oriented","markerColorscale","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":411,"../scatter/colorbar":557,"./arrays_to_calcdata":473,"./attributes":474,"./calc":475,"./defaults":476,"./hover":477,"./layout_attributes":479,"./layout_defaults":480,"./plot":481,"./set_positions":482,"./style":483}],479:[function(t,e,r){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","group","overlay","relative"],dflt:"group"},barnorm:{valType:"enumerated",values:["","fraction","percent"],dflt:""},bargap:{valType:"number",min:0,max:1},bargroupgap:{valType:"number",min:0,max:1,dflt:0}}},{}],480:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./layout_attributes");e.exports=function(t,e,r){function s(r,n){return a.coerce(t,e,o,r,n)}for(var l=!1,c=!1,u=!1,f={},h=0;h=2?a(t):t>e?Math.ceil(t):Math.floor(t)}var h,d,p,g;if("h"===s.orientation?(p=u.c2p(r.poffset+e.p,!0),g=u.c2p(r.poffset+e.p+r.barwidth,!0),h=c.c2p(e.b,!0),d=c.c2p(e.s+e.b,!0)):(h=c.c2p(r.poffset+e.p,!0),d=c.c2p(r.poffset+e.p+r.barwidth,!0),g=u.c2p(e.s+e.b,!0),p=u.c2p(e.b,!0)),!(i(h)&&i(d)&&i(p)&&i(g)&&h!==d&&p!==g))return void n.select(this).remove();var v=(e.mlw+1||s.marker.line.width+1||(e.trace?e.trace.marker.line.width:0)+1)-1,m=n.round(v/2%1,2);if(!t._context.staticPlot){var y=o.opacity(e.mc||s.marker.color),b=1>y||v>.01?a:l;h=b(h,d),d=b(d,h),p=b(p,g),g=b(g,p)}n.select(this).attr("d","M"+h+","+p+"V"+g+"H"+d+"V"+p+"Z")})}),h.call(s.plot,e)}},{"../../components/color":303,"../../components/errorbars":331,"../../lib":381,"./arrays_to_calcdata":473,d3:72,"fast-isnumeric":76}],482:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axes"),o=t("../../lib");e.exports=function(t,e){var r,s,l=t._fullLayout,c=e.x(),u=e.y();["v","h"].forEach(function(f){function h(e){function r(t){t[p]=t.p+h}var n=[];e.forEach(function(e){t.calcdata[e].forEach(function(t){n.push(t.p)})});var i=o.distinctVals(n),s=i.vals,c=i.minDiff,u=!1,f=[];"group"===l.barmode&&e.forEach(function(e){u||(t.calcdata[e].forEach(function(t){u||f.forEach(function(e){Math.abs(t.p-e)_&&(S=!0,M=_),_>A+R&&(S=!0,A=_))}a.expand(m,[M,A],{tozero:!0,padded:S})}else{var O=function(t){return t[g]=t.s,t.s};for(r=0;r1||0===s.bargap&&0===s.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),e.selectAll("g.points").each(function(t){var e=t[0].trace,r=e.marker,o=r.line,s=(e._input||{}).marker||{},l=a.tryColorscale(r,s,""),c=a.tryColorscale(r,s,"line.");n.select(this).selectAll("path").each(function(t){var e,a,s=(t.mlw+1||o.width+1)-1,u=n.select(this);e="mc"in t?t.mcc=l(t.mc):Array.isArray(r.color)?i.defaultLine:r.color,u.style("stroke-width",s+"px").call(i.fill,e),s&&(a="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(o.color)?i.defaultLine:o.color,u.call(i.stroke,a))})}),e.call(o.style)}},{"../../components/color":303,"../../components/drawing":325,"../../components/errorbars":331,d3:72}],484:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s){r("marker.color",o),i(t,"marker")&&a(t,e,s,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),i(t,"marker.line")&&a(t,e,s,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width")}},{"../../components/color":303,"../../components/colorscale/defaults":312,"../../components/colorscale/has_colorscale":315}],485:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/color/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=o.line;e.exports={y:{valType:"data_array"},x:{valType:"data_array"},x0:{valType:"any"},y0:{valType:"any"},whiskerwidth:{valType:"number",min:0,max:1,dflt:.5},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1},jitter:{valType:"number",min:0,max:1},pointpos:{valType:"number",min:-2,max:2},orientation:{valType:"enumerated",values:["v","h"]},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)"},symbol:a({},o.symbol,{arrayOk:!1}),opacity:a({},o.opacity,{arrayOk:!1,dflt:1}),size:a({},o.size,{arrayOk:!1}),color:a({},o.color,{arrayOk:!1}),line:{color:a({},s.color,{arrayOk:!1,dflt:i.defaultLine}),width:a({},s.width,{arrayOk:!1,dflt:0}),outliercolor:{valType:"color"},outlierwidth:{valType:"number",min:0,dflt:1}}},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2}},fillcolor:n.fillcolor}},{"../../components/color/attributes":302,"../../lib/extend":376,"../scatter/attributes":554}],486:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../../plots/cartesian/axes");e.exports=function(t,e){function r(t,e,r,a,o){var s;return r in e?p=a.makeCalcdata(e,r):(s=r+"0"in e?e[r+"0"]:"name"in e&&("category"===a.type||n(e.name)&&-1!==["linear","log"].indexOf(a.type)||i.isDateTime(e.name)&&"date"===a.type)?e.name:t.numboxes,s=a.d2c(s),p=o.map(function(){return s})),p}function o(t,e,r,a,o){var s,l,c,u,f=a.length,h=e.length,d=[],p=[];for(s=0;f>s;++s)l=a[s],t[s]={pos:l},p[s]=l-o,d[s]=[];for(p.push(a[f-1]+o),s=0;h>s;++s)u=e[s],n(u)&&(c=i.findBin(r[s],p),c>=0&&h>c&&d[c].push(u));return d}function s(t,e){var r,n,a,o;for(o=0;o1,m=r.dPos*(1-h.boxgap)*(1-h.boxgroupgap)/(v?t.numboxes:1),y=v?2*r.dPos*(-.5+(r.boxnum+.5)/t.numboxes)*(1-h.boxgap):0,b=m*g.whiskerwidth;return g.visible!==!0||r.emptybox?void a.select(this).remove():("h"===g.orientation?(l=p,f=d):(l=d,f=p),r.bPos=y,r.bdPos=m,n(),a.select(this).selectAll("path.box").data(o.identity).enter().append("path").attr("class","box").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=l.c2p(t.pos+y-b,!0),s=l.c2p(t.pos+y+b,!0),c=f.c2p(t.q1,!0),u=f.c2p(t.q3,!0),h=o.constrain(f.c2p(t.med,!0),Math.min(c,u)+1,Math.max(c,u)-1),d=f.c2p(g.boxpoints===!1?t.min:t.lf,!0),p=f.c2p(g.boxpoints===!1?t.max:t.uf,!0);"h"===g.orientation?a.select(this).attr("d","M"+h+","+r+"V"+n+"M"+c+","+r+"V"+n+"H"+u+"V"+r+"ZM"+c+","+e+"H"+d+"M"+u+","+e+"H"+p+(0===g.whiskerwidth?"":"M"+d+","+i+"V"+s+"M"+p+","+i+"V"+s)):a.select(this).attr("d","M"+r+","+h+"H"+n+"M"+r+","+c+"H"+n+"V"+u+"H"+r+"ZM"+e+","+c+"V"+d+"M"+e+","+u+"V"+p+(0===g.whiskerwidth?"":"M"+i+","+d+"H"+s+"M"+i+","+p+"H"+s))}),g.boxpoints&&a.select(this).selectAll("g.points").data(function(t){return t.forEach(function(t){t.t=r,t.trace=g}),t}).enter().append("g").attr("class","points").selectAll("path").data(function(t){var e,r,n,a,s,l,f,h="all"===g.boxpoints?t.val:t.val.filter(function(e){return et.uf}),d=(t.q3-t.q1)*u,p=[],v=0;if(g.jitter){for(e=0;et.lo&&(n.so=!0),n})}).enter().append("path").call(s.translatePoints,d,p),void(g.boxmean&&a.select(this).selectAll("path.mean").data(o.identity).enter().append("path").attr("class","mean").style("fill","none").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=f.c2p(t.mean,!0),o=f.c2p(t.mean-t.sd,!0),s=f.c2p(t.mean+t.sd,!0);"h"===g.orientation?a.select(this).attr("d","M"+i+","+r+"V"+n+("sd"!==g.boxmean?"":"m0,0L"+o+","+e+"L"+i+","+r+"L"+s+","+e+"Z")):a.select(this).attr("d","M"+r+","+i+"H"+n+("sd"!==g.boxmean?"":"m0,0L"+e+","+o+"L"+r+","+i+"L"+e+","+s+"Z"))})))})}},{"../../components/drawing":325,"../../lib":381,d3:72}],493:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib");e.exports=function(t,e){var r,o,s,l,c=t._fullLayout,u=e.x(),f=e.y(),h=["v","h"];for(o=0;ol&&(e.z=u.slice(0,l)),s("locationmode"),s("text"),s("marker.line.color"),s("marker.line.width"),i(t,e,o,s,{prefix:"",cLetter:"z"}),void s("hoverinfo",1===o._dataLength?"location+z+text":void 0)):void(e.visible=!1); -}},{"../../components/colorscale/defaults":312,"../../lib":381,"./attributes":495}],498:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../heatmap/colorbar"),n.calc=t("./calc"),n.plot=t("./plot").plot,n.moduleType="trace",n.name="choropleth",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","noOpacity"],n.meta={},e.exports=n},{"../../plots/geo":424,"../heatmap/colorbar":512,"./attributes":495,"./calc":496,"./defaults":497,"./plot":499}],499:[function(t,e,r){"use strict";function n(t,e){function r(e){var r=t.mockAxis;return o.tickText(r,r.c2l(e),"hover").text}var n=e.hoverinfo;if("none"===n)return function(t){delete t.nameLabel,delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("name"),s=-1!==i.indexOf("location"),l=-1!==i.indexOf("z"),c=-1!==i.indexOf("text"),u=!a&&s;return function(t){var n=[];u?t.nameLabel=t.id:(a&&(t.nameLabel=e.name),s&&n.push(t.id)),l&&n.push(r(t.z)),c&&n.push(t.tx),t.textLabel=n.join("
")}}function i(t){return function(e,r){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:r,location:e.id,z:e.z}]}}}var a=t("d3"),o=t("../../plots/cartesian/axes"),s=t("../../plots/cartesian/graph_interact"),l=t("../../components/color"),c=t("../../components/drawing"),u=t("../../components/colorscale/get_scale"),f=t("../../components/colorscale/make_scale_function"),h=t("../../lib/topojson_utils").getTopojsonFeatures,d=t("../../lib/geo_location_utils").locationToFeature,p=t("../../lib/array_to_calc_item"),g=t("../../plots/geo/constants"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){for(var r,n=[],i=t.locations,a=i.length,o=h(t,e),s=(t.marker||{}).line||{},l=0;a>l;l++)r=d(t.locationmode,i[l],o),void 0!==r&&(r.z=t.z[l],void 0!==t.text&&(r.tx=t.text[l]),p(s.color,r,"mlc",l),p(s.width,r,"mlw",l),n.push(r));return n.length>0&&(n[0].trace=t),n},m.plot=function(t,e,r){var o,l=t.framework,c=l.select("g.choroplethlayer"),u=l.select("g.baselayer"),f=l.select("g.baselayeroverchoropleth"),h=g.baseLayersOverChoropleth,d=c.selectAll("g.trace.choropleth").data(e,function(t){return t.uid});d.enter().append("g").attr("class","trace choropleth"),d.exit().remove(),d.each(function(e){function r(e,r){if(t.showHover){var n=t.projection(e.properties.ct);c(e),s.loneHover({x:n[0],y:n[1],name:e.nameLabel,text:e.textLabel},{container:t.hoverContainer.node()}),f=u(e,r),t.graphDiv.emit("plotly_hover",f)}}function o(e,r){t.graphDiv.emit("plotly_click",u(e,r))}var l=m.calcGeoJSON(e,t.topojson),c=n(t,e),u=i(e),f=null,h=a.select(this).selectAll("path.choroplethlocation").data(l);h.enter().append("path").classed("choroplethlocation",!0).on("mouseover",r).on("click",o).on("mouseout",function(){s.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",f)}).on("mousedown",function(){s.loneUnhover(t.hoverContainer)}).on("mouseup",r),h.exit().remove()}),f.selectAll("*").remove();for(var p=0;pr;r++)e=f[r],d[r]=e[0]*(t.zmax-t.zmin)+t.zmin,p[r]=e[1];var g=n.extent([t.zmin,t.zmax,a.start,a.start+l*(c-1)]),v=g[t.zminr;r++)e=f[r],d[r]=(e[0]*(c+u-1)-u/2)*l+o,p[r]=e[1];var y=n.scale.linear().interpolate(n.interpolateRgb).domain(d).range(p);return y}},{"../../components/colorscale/get_scale":314,d3:72}],507:[function(t,e,r){"use strict";function n(t,e,r){_.markTime("in Contour.plot");var n=r[0].trace,a=r[0].x,s=r[0].y,c=n.contours,u=n.uid,f=e.x(),h=e.y(),v=t._fullLayout,b="contour"+u,x=i(c,e,r[0]);if(n.visible!==!0)return v._paper.selectAll("."+b+",.hm"+u).remove(),void v._infolayer.selectAll(".cb"+u).remove();"heatmap"===c.coloring?(n.zauto&&n.autocontour===!1&&(n._input.zmin=n.zmin=c.start-c.size/2,n._input.zmax=n.zmax=n.zmin+x.length*c.size),k(t,e,[r])):v._paper.selectAll(".hm"+u).remove(),o(x),l(x);var w=f.c2p(a[0],!0),A=f.c2p(a[a.length-1],!0),M=h.c2p(s[0],!0),T=h.c2p(s[s.length-1],!0),E=[[w,T],[A,T],[A,M],[w,M]],L=d(e,r,b);p(L,E,c),g(L,x,E,c),m(L,x,c),y(L,e,r[0],E),_.markTime("done Contour.plot")}function i(t,e,r){for(var n=t.size||1,i=[],a=t.start;at?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);if(5===r||10===r){var n=(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4;return t>n?5===r?713:1114:5===r?104:208}return 15===r?0:r}function o(t){var e,r,n,i,o,s,l,c,u,f=t[0].z,h=f.length,d=f[0].length,p=2===h||2===d;for(r=0;h-1>r;r++)for(i=[],0===r&&(i=i.concat(A)),r===h-2&&(i=i.concat(M)),e=0;d-1>e;e++)for(n=i.slice(),0===e&&(n=n.concat(T)),e===d-2&&(n=n.concat(E)),o=e+","+r,s=[[f[r][e],f[r][e+1]],[f[r+1][e],f[r+1][e+1]]],u=0;ui;i++){if(s>20?(s=S[s][(l[0]||l[1])<0?0:1],t.crossings[o]=C[s]):delete t.crossings[o],l=L[s],!l){console.log("found bad marching index",s,e,t.level);break}if(d.push(h(t,e,l)),e[0]+=l[0],e[1]+=l[1],u(d[d.length-1],d[d.length-2])&&d.pop(),o=e.join(","),o===a&&l.join(",")===p||r&&(l[0]&&(e[0]<0||e[0]>v-2)||l[1]&&(e[1]<0||e[1]>g-2)))break;s=t.crossings[o]}1e4===i&&console.log("Infinite loop in contour?");var m,y,b,x,_,w,k,A=u(d[0],d[d.length-1]),M=0,T=.2*t.smoothing,E=[],z=0;for(i=1;i=z;i--)if(m=E[i],P>m){for(b=0,y=i-1;y>=z&&m+E[y]b&&m+E[b]e;)e++,r=Object.keys(i.crossings)[0].split(",").map(Number),s(i,r);1e4===e&&console.log("Infinite loop in contour?")}}function c(t,e,r){var n=0,i=0;return t>20&&e?208===t||1114===t?n=0===r[0]?1:-1:i=0===r[1]?1:-1:-1!==A.indexOf(t)?i=1:-1!==T.indexOf(t)?n=1:-1!==M.indexOf(t)?i=-1:n=-1,[n,i]}function u(t,e){return Math.abs(t[0]-e[0])<.01&&Math.abs(t[1]-e[1])<.01}function f(t,e){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function h(t,e,r){var n=e[0]+Math.max(r[0],0),i=e[1]+Math.max(r[1],0),a=t.z[i][n],o=t.xaxis,s=t.yaxis;if(r[1]){var l=(t.level-a)/(t.z[i][n+1]-a);return[o.c2p((1-l)*t.x[n]+l*t.x[n+1],!0),s.c2p(t.y[i],!0)]}var c=(t.level-a)/(t.z[i+1][n]-a);return[o.c2p(t.x[n],!0),s.c2p((1-c)*t.y[i]+c*t.y[i+1],!0)]}function d(t,e,r){var n=t.plot.select(".maplayer").selectAll("g.contour."+r).data(e);return n.enter().append("g").classed("contour",!0).classed(r,!0),n.exit().remove(),n}function p(t,e,r){var n=t.selectAll("g.contourbg").data([0]);n.enter().append("g").classed("contourbg",!0);var i=n.selectAll("path").data("fill"===r.coloring?[0]:[]);i.enter().append("path"),i.exit().remove(),i.attr("d","M"+e.join("L")+"Z").style("stroke","none")}function g(t,e,r,n){var i=t.selectAll("g.contourfill").data([0]);i.enter().append("g").classed("contourfill",!0);var a=i.selectAll("path").data("fill"===n.coloring?e:[]);a.enter().append("path"),a.exit().remove(),a.each(function(t){var e=v(t,r);e?x.select(this).attr("d",e).style("stroke","none"):x.select(this).remove()})}function v(t,e){function r(t){return Math.abs(t[1]-e[0][1])<.01}function n(t){return Math.abs(t[1]-e[2][1])<.01}function i(t){return Math.abs(t[0]-e[0][0])<.01}function a(t){return Math.abs(t[0]-e[2][0])<.01}for(var o,s,l,c,u,f,h=t.edgepaths.length||t.z[0][0]l;l++){if(!o){console.log("missing end?",d,t);break}for(r(o)&&!a(o)?s=e[1]:i(o)?s=e[0]:n(o)?s=e[3]:a(o)&&(s=e[2]),u=0;u=0&&(s=v,c=u):Math.abs(o[1]-s[1])<.01?Math.abs(o[1]-v[1])<.01&&(v[0]-o[0])*(s[0]-v[0])>=0&&(s=v,c=u):console.log("endpt to newendpt is not vert. or horz.",o,s,v)}if(o=s,c>=0)break;h+="L"+s}if(c===t.edgepaths.length){console.log("unclosed perimeter path");break}d=c,g=-1===p.indexOf(d),g&&(d=p[0],h+="Z")}for(d=0;de;e++)s.push(1);for(e=0;a>e;e++)i.push(s.slice());for(e=0;eo;o++)for(n=i(l,o),u[o]=new Array(n),s=0;n>s;s++)u[o][s]=e(a(l,o,s));return u}function i(t,e,r,n,i,a){var o,s,l,c=[],u=h.traceIs(t,"contour"),f=h.traceIs(t,"histogram"),d=h.traceIs(t,"gl2d");if(Array.isArray(e)&&!f&&"category"!==a.type){e=e.map(a.d2c);var p=e.length;if(!(i>=p))return u?e.slice(0,i):e.slice(0,i+1);if(u||d)c=e.slice(0,i);else if(1===i)c=[e[0]-.5,e[0]+.5];else{for(c=[1.5*e[0]-.5*e[1]],l=1;p>l;l++)c.push(.5*(e[l-1]+e[l]));c.push(1.5*e[p-1]-.5*e[p-2])}if(i>p){var g=c[c.length-1],v=g-c[c.length-2];for(l=p;i>l;l++)g+=v,c.push(g)}}else for(s=n||1,o=void 0===r?0:f||"category"===a.type?r:a.d2c(r),l=u||d?0:-.5;i>l;l++)c.push(o+s*l);return c}function a(t){return.5-.25*Math.min(1,.5*t)}function o(t,e,r){var n,i,o=1;if(Array.isArray(r))for(n=0;nn&&o>y;n++)o=l(t,e,a(o));return o>y&&console.log("interp2d didn't converge quickly",o),t}function s(t){var e,r,n,i,a,o,s,l,c=[],u={},f=[],h=t[0],d=[],p=[0,0,0],g=m(t);for(r=0;rn;n++)void 0===d[n]&&(o=(void 0!==d[n-1]?1:0)+(void 0!==d[n+1]?1:0)+(void 0!==e[n]?1:0)+(void 0!==h[n]?1:0),o?(0===r&&o++,0===n&&o++,r===t.length-1&&o++,n===d.length-1&&o++,4>o&&(u[[r,n]]=[r,n,o]),c.push([r,n,o])):f.push([r,n]));for(;f.length;){for(s={},l=!1,a=f.length-1;a>=0;a--)i=f[a],r=i[0],n=i[1],o=((u[[r-1,n]]||p)[2]+(u[[r+1,n]]||p)[2]+(u[[r,n-1]]||p)[2]+(u[[r,n+1]]||p)[2])/20,o&&(s[i]=[r,n,o],f.splice(a,1),l=!0);if(!l)throw"findEmpties iterated with no new neighbors";for(i in s)u[i]=s[i],c.push(s[i])}return c.sort(function(t,e){return e[2]-t[2]})}function l(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g,v=0;for(o=0;os;s++)l=b[s],c=t[i+l[0]],c&&(u=c[a+l[1]],void 0!==u&&(0===h?p=g=u:(p=Math.min(p,u),g=Math.max(g,u)),f++,h+=u));if(0===f)throw"iterateInterp2d order is wrong: no defined neighbors";t[i][a]=h/f,void 0===d?4>f&&(v=1):(t[i][a]=(1+r)*t[i][a]-r*d,g>p&&(v=Math.max(v,Math.abs(t[i][a]-d)/(g-p))))}return v}var c=t("fast-isnumeric"),u=t("../../lib"),f=t("../../plots/cartesian/axes"),h=t("../../plots/plots"),d=t("../histogram2d/calc"),p=t("../../components/colorscale/calc"),g=t("./has_columns"),v=t("./convert_column_xyz"),m=t("./max_row_length");e.exports=function(t,e){function r(t){E=e._input.zsmooth=e.zsmooth=!1,u.notifier("cannot fast-zsmooth: "+t)}u.markTime("start convert x&y");var a,l,c,y,b,x,_,w,k=f.getFromId(t,e.xaxis||"x"),A=f.getFromId(t,e.yaxis||"y"),M=h.traceIs(e,"contour"),T=h.traceIs(e,"histogram"),E=M?"best":e.zsmooth;if(k._minDtick=0,A._minDtick=0,u.markTime("done convert x&y"),T){var L=d(t,e);a=L.x,l=L.x0,c=L.dx,y=L.y,b=L.y0,x=L.dy,_=L.z}else g(e)&&v(e,k,A),a=e.x?k.makeCalcdata(e,"x"):[],y=e.y?A.makeCalcdata(e,"y"):[],l=e.x0||0,c=e.dx||1,b=e.y0||0,x=e.dy||1,_=n(e),(M||e.connectgaps)&&(e._emptypoints=s(_),e._interpz=o(_,e._emptypoints,e._interpz));if("fast"===E)if("log"===k.type||"log"===A.type)r("log axis found");else if(!T){if(a.length){var S=(a[a.length-1]-a[0])/(a.length-1),C=Math.abs(S/100);for(w=0;wC){r("x scale is not linear");break}}if(y.length&&"fast"===E){var z=(y[y.length-1]-y[0])/(y.length-1),P=Math.abs(z/100);for(w=0;wP){r("y scale is not linear");break}}}var R=m(_),O="scaled"===e.xtype?"":e.x,I=i(e,O,l,c,R,k),N="scaled"===e.ytype?"":e.y,j=i(e,N,b,x,_.length,A);f.expand(k,I),f.expand(A,j);var F={x:I,y:j,z:_};if(p(e,_,"","z"),M&&e.contours&&"heatmap"===e.contours.coloring){var D="contour"===e.type?"heatmap":"histogram2d";F.xfill=i(D,O,l,c,R,k),F.yfill=i(D,N,b,x,_.length,A)}return[F]};var y=.01,b=[[-1,0],[1,0],[0,-1],[0,1]]},{"../../components/colorscale/calc":310,"../../lib":381,"../../plots/cartesian/axes":403,"../../plots/plots":452,"../histogram2d/calc":531,"./convert_column_xyz":513,"./has_columns":515,"./max_row_length":518,"fast-isnumeric":76}],512:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c="cb"+r.uid,u=s(r.colorscale),f=r.zmin,h=r.zmax;if(i(f)||(f=a.aggNums(Math.min,null,r.z)),i(h)||(h=a.aggNums(Math.max,null,r.z)),t._fullLayout._infolayer.selectAll("."+c).remove(),!r.showscale)return void o.autoMargin(t,c);var d=e[0].t.cb=l(t,c);d.fillcolor(n.scale.linear().domain(u.map(function(t){return f+t[0]*(h-f)})).range(u.map(function(t){return t[1]}))).filllevels({start:f,end:h,size:(h-f)/254}).options(r.colorbar)(),a.markTime("done colorbar")}},{"../../components/colorbar/draw":306,"../../components/colorscale/get_scale":314,"../../lib":381,"../../plots/plots":452,d3:72,"fast-isnumeric":76}],513:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a=t.x.slice(),o=t.y.slice(),s=t.z,l=t.text,c=Math.min(a.length,o.length,s.length),u=void 0!==l&&!Array.isArray(l[0]);for(ci;i++)a[i]=e.d2c(a[i]),o[i]=r.d2c(o[i]);var f,h,d,p=n.distinctVals(a),g=p.vals,v=n.distinctVals(o),m=v.vals,y=n.init2dArray(m.length,g.length);for(u&&(d=n.init2dArray(m.length,g.length)),i=0;c>i;i++)f=n.findBin(a[i]+p.minDiff/2,g),h=n.findBin(o[i]+v.minDiff/2,m),y[h][f]=s[i],u&&(d[h][f]=l[i]);t.x=g,t.y=m,t.z=y,u&&(t.text=d)}},{"../../lib":381}],514:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./has_columns"),a=t("./xyz_defaults"),o=t("../../components/colorscale/defaults"),s=t("./attributes");e.exports=function(t,e,r,l){function c(r,i){return n.coerce(t,e,s,r,i)}var u=a(t,e,c);return u?(c("text"),c("zsmooth"),c("connectgaps",i(e)&&e.zsmooth!==!1),void o(t,e,l,c,{prefix:"",cLetter:"z"})):void(e.visible=!1)}},{"../../components/colorscale/defaults":312,"../../lib":381,"./attributes":510,"./has_columns":515,"./xyz_defaults":521}],515:[function(t,e,r){"use strict";e.exports=function(t){return!Array.isArray(t.z[0])}},{}],516:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../lib");e.exports=function(t,e,r,a,o){if(!(t.distancec||c>=m[0].length||0>u||u>m.length)return}else{if(n.inbox(e-g[0],e-g[g.length-1])>n.MAXDIST||n.inbox(r-v[0],r-v[v.length-1])>n.MAXDIST)return;if(o){var w;for(b=[2*g[0]-g[1]],w=1;w0;)_=v.c2p(C[M]),M--;for(x>_&&(w=_,_=x,x=w,N=!0),M=0;void 0===k&&M0;)A=m.c2p(z[M]),M--;if(k>A&&(w=k,k=A,A=w,j=!0),P&&(C=r[0].xfill,z=r[0].yfill),"fast"!==R){var F="best"===R?0:.5;x=Math.max(-F*v._length,x),_=Math.min((1+F)*v._length,_),k=Math.max(-F*m._length,k),A=Math.min((1+F)*m._length,A)}var D=Math.round(_-x),B=Math.round(A-k);if(!(0>=D||0>=B)){var U,V;"fast"===R?(U=I,V=O):(U=D,V=B);var q=document.createElement("canvas");q.width=U,q.height=V;var H,G,Y=q.getContext("2d"),X=i.scale.linear().domain(S.map(function(t){return t[0]})).range(S.map(function(t){var e=a(t[1]).toRgb();return[e.r,e.g,e.b,e.a]})).clamp(!0);"fast"===R?(H=N?function(t){return I-1-t}:o.identity,G=j?function(t){return O-1-t}:o.identity):(H=function(t){return o.constrain(Math.round(v.c2p(C[t])-x),0,D)},G=function(t){return o.constrain(Math.round(m.c2p(z[t])-k),0,B)});var W,Z,K,$,Q,J,tt=G(0),et=[tt,tt],rt=N?0:1,nt=j?0:1,it=0,at=0,ot=0,st=0;if(o.markTime("done init png"),R){var lt=0,ct=new Uint8Array(D*B*4);if("best"===R){var ut,ft,ht,dt=new Array(C.length),pt=new Array(z.length),gt=new Array(D);for(M=0;MM;M++)gt[M]=n(M,dt);for(Z=0;B>Z;Z++)for(ut=n(Z,pt),ft=T[ut.bin0],ht=T[ut.bin1],M=0;D>M;M++,lt+=4)J=d(ft,ht,gt[M],ut),h(ct,lt,J)}else for(Z=0;O>Z;Z++)for(Q=T[Z],et=G(Z),M=0;I>M;M++)J=f(Q[M],1),lt=4*(et*D+H(M)),h(ct,lt,J);var vt=Y.createImageData(D,B);vt.data.set(ct),Y.putImageData(vt,0,0)}else for(Z=0;O>Z;Z++)if(Q=T[Z],et.reverse(),et[nt]=G(Z+1),et[0]!==et[1]&&void 0!==et[0]&&void 0!==et[1])for(K=H(0),W=[K,K],M=0;I>M;M++)W.reverse(),W[rt]=H(M+1),W[0]!==W[1]&&void 0!==W[0]&&void 0!==W[1]&&($=Q[M],J=f($,(W[1]-W[0])*(et[1]-et[0])),Y.fillStyle="rgba("+J.join(",")+")",Y.fillRect(W[0],et[0],W[1]-W[0],et[1]-et[0]));o.markTime("done filling png"),at=Math.round(at/it),ot=Math.round(ot/it),st=Math.round(st/it);var mt=a("rgb("+at+","+ot+","+st+")");t._hmpixcount=(t._hmpixcount||0)+it,t._hmlumcount=(t._hmlumcount||0)+it*mt.getLuminance();var yt=e.plot.select(".imagelayer").selectAll("g.hm."+b).data([0]);yt.enter().append("g").classed("hm",!0).classed(b,!0),yt.exit().remove();var bt=yt.selectAll("image").data(r);bt.enter().append("svg:image"),bt.exit().remove(),bt.attr({xmlns:c.svg,"xlink:href":q.toDataURL("image/png"),height:B,width:D,x:x,y:k,preserveAspectRatio:"none"}),o.markTime("done showing png")}}var i=t("d3"),a=t("tinycolor2"),o=t("../../lib"),s=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),c=t("../../constants/xmlns_namespaces"),u=t("./max_row_length");e.exports=function(t,e,r){for(var i=0;i0&&(n=!0);for(var s=0;si;i++)e[i]?(t[i]/=e[i],n+=t[i]):t[i]=null;return n}},{}],524:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){return r("histnorm"),n.forEach(function(t){var e=r(t+"bins.start"),n=r(t+"bins.end"),i=r("autobin"+t,!(e&&n));r(i?"nbins"+t:t+"bins.size")}),e}},{}],525:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports={count:function(t,e,r){return r[t]++,1},sum:function(t,e,r,i){var a=i[e];return n(a)?(a=Number(a),r[t]+=a,a):0},avg:function(t,e,r,i,a){var o=i[e];return n(o)&&(o=Number(o),r[t]+=o,a[t]++),0},min:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]>a)return r[t]=a,a-r[t]}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]r&&c.length<5e3;)g=a.tickIncrement(r,b.size),c.push((r+g)/2),u.push(S),x&&_.push(r),E&&w.push(1/(g-r)),P&&k.push(0),r=g;var R=u.length;for(r=0;r=0&&R>m&&(A+=C(m,r,u,y,k));P&&(A=l(u,k)),z&&z(u,A,w);var O=Math.min(c.length,u.length),I=[],N=0,j=O-1;for(r=0;O>r;r++)if(u[r]){N=r;break}for(r=O-1;r>N;r--)if(u[r]){j=r;break}for(r=N;j>=r;r++)n(c[r])&&n(u[r])&&I.push({p:c[r],s:u[r],b:0});return I}}},{"../../lib":381,"../../plots/cartesian/axes":403,"./average":523,"./bin_functions":525,"./norm_functions":529,"fast-isnumeric":76}],527:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("./bin_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=u("x"),h=u("y");u("text");var d=u("orientation",h&&!f?"h":"v"),p=e["v"===d?"x":"y"];if(!p||!p.length)return void(e.visible=!1);var g=e["h"===d?"x":"y"];g&&u("histfunc");var v="h"===d?["y"]:["x"];a(t,e,u,v),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),s(t,e,i.defaultLine,{axis:"x",inherit:"y"})}},{"../../components/color":303,"../../components/errorbars/defaults":330,"../../lib":381,"../bar/style_defaults":484,"./attributes":522,"./bin_defaults":524}],528:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("../bar/layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("../bar/layout_defaults"),n.calc=t("./calc"),n.setPositions=t("../bar/set_positions"),n.plot=t("../bar/plot"),n.style=t("../bar/style"),n.colorbar=t("../scatter/colorbar"),n.hoverPoints=t("../bar/hover"),n.moduleType="trace",n.name="histogram",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","histogram","oriented","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":411,"../bar/hover":477,"../bar/layout_attributes":479,"../bar/layout_defaults":480,"../bar/plot":481,"../bar/set_positions":482,"../bar/style":483,"../scatter/colorbar":557,"./attributes":522,"./calc":526,"./defaults":527}],529:[function(t,e,r){"use strict";e.exports={percent:function(t,e){for(var r=t.length,n=100/e,i=0;r>i;i++)t[i]*=n},probability:function(t,e){for(var r=t.length,n=0;r>n;n++)t[n]/=e},density:function(t,e,r,n){var i=t.length;n=n||1;for(var a=0;i>a;a++)t[a]*=r[a]*n},"probability density":function(t,e,r,n){var i=t.length;n&&(e/=n);for(var a=0;i>a;a++)t[a]*=r[a]/e}}},{}],530:[function(t,e,r){"use strict";var n=t("../histogram/attributes"),i=t("../heatmap/attributes");e.exports={x:n.x,y:n.y,z:{valType:"data_array"},marker:{color:{valType:"data_array"}},histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zauto:i.zauto,zmin:i.zmin,zmax:i.zmax,colorscale:i.colorscale,autocolorscale:i.autocolorscale,reversescale:i.reversescale,showscale:i.showscale,zsmooth:i.zsmooth,_nestedModules:{colorbar:"Colorbar"}}},{"../heatmap/attributes":510,"../histogram/attributes":522}],531:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("../histogram/bin_functions"),o=t("../histogram/norm_functions"),s=t("../histogram/average");e.exports=function(t,e){var r,l,c,u,f,h,d=i.getFromId(t,e.xaxis||"x"),p=e.x?d.makeCalcdata(e,"x"):[],g=i.getFromId(t,e.yaxis||"y"),v=e.y?g.makeCalcdata(e,"y"):[],m=Math.min(p.length,v.length);p.length>m&&p.splice(m,p.length-m),v.length>m&&v.splice(m,v.length-m),n.markTime("done convert data"),!e.autobinx&&"xbins"in e||(e.xbins=i.autoBin(p,d,e.nbinsx,"2d"),"histogram2dcontour"===e.type&&(e.xbins.start-=e.xbins.size,e.xbins.end+=e.xbins.size),e._input.xbins=e.xbins),!e.autobiny&&"ybins"in e||(e.ybins=i.autoBin(v,g,e.nbinsy,"2d"),"histogram2dcontour"===e.type&&(e.ybins.start-=e.ybins.size,e.ybins.end+=e.ybins.size),e._input.ybins=e.ybins),n.markTime("done autoBin"),f=[];var y,b,x=[],_=[],w="string"==typeof e.xbins.size?[]:e.xbins,k="string"==typeof e.xbins.size?[]:e.ybins,A=0,M=[],T=e.histnorm,E=e.histfunc,L=-1!==T.indexOf("density"),S="max"===E||"min"===E,C=S?null:0,z=a.count,P=o[T],R=!1,O=[],I=[],N="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";N&&"count"!==E&&(R="avg"===E,z=a[E]);var j=e.xbins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6;for(h=j.start;F>h;h=i.tickIncrement(h,j.size))x.push(C),Array.isArray(w)&&w.push(h),R&&_.push(0);Array.isArray(w)&&w.push(h);var D=x.length;for(r=e.xbins.start,l=(h-r)/D,r+=l/2,j=e.ybins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6,h=j.start;F>h;h=i.tickIncrement(h,j.size))f.push(x.concat()),Array.isArray(k)&&k.push(h),R&&M.push(_.concat());Array.isArray(k)&&k.push(h);var B=f.length;for(c=e.ybins.start,u=(h-c)/B,c+=u/2,L&&(O=x.map(function(t,e){return Array.isArray(w)?1/(w[e+1]-w[e]):1/l}),I=f.map(function(t,e){return Array.isArray(k)?1/(k[e+1]-k[e]):1/u})),n.markTime("done making bins"),h=0;m>h;h++)y=n.findBin(p[h],w),b=n.findBin(v[h],k),y>=0&&D>y&&b>=0&&B>b&&(A+=z(y,h,f[b],N,M[b]));if(R)for(b=0;B>b;b++)A+=s(f[b],M[b]);if(P)for(b=0;B>b;b++)P(f[b],A,O,I[b]);return n.markTime("done binning"),{x:p,x0:r,dx:l,y:v,y0:c,dy:u,z:f}}},{"../../lib":381,"../../plots/cartesian/axes":403,"../histogram/average":523,"../histogram/bin_functions":525,"../histogram/norm_functions":529}],532:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./sample_defaults"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r){function s(r,i){return n.coerce(t,e,o,r,i)}i(t,e,s),s("zsmooth"),a(t,e,r,s,{prefix:"",cLetter:"z"})}},{"../../components/colorscale/defaults":312,"../../lib":381,"./attributes":530,"./sample_defaults":534}],533:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../heatmap/calc"),n.plot=t("../heatmap/plot"),n.colorbar=t("../heatmap/colorbar"),n.style=t("../heatmap/style"),n.hoverPoints=t("../heatmap/hover"),n.moduleType="trace",n.name="histogram2d",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":411,"../heatmap/calc":511,"../heatmap/colorbar":512,"../heatmap/hover":516,"../heatmap/plot":519,"../heatmap/style":520,"./attributes":530,"./defaults":532}],534:[function(t,e,r){"use strict";var n=t("../histogram/bin_defaults");e.exports=function(t,e,r){var i=r("x"),a=r("y");if(!(i&&i.length&&a&&a.length))return void(e.visible=!1);var o=r("z")||r("marker.color");o&&r("histfunc");var s=["x","y"];n(t,e,r,s)}},{"../histogram/bin_defaults":524}],535:[function(t,e,r){"use strict";var n=t("../histogram2d/attributes"),i=t("../contour/attributes");e.exports={x:n.x,y:n.y,z:n.z,marker:n.marker,histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zauto:i.zauto,zmin:i.zmin,zmax:i.zmax,colorscale:i.colorscale,autocolorscale:i.autocolorscale,reversescale:i.reversescale,showscale:i.showscale,autocontour:i.autocontour,ncontours:i.ncontours,contours:i.contours,line:i.line,_nestedModules:{colorbar:"Colorbar"}}},{"../contour/attributes":500,"../histogram2d/attributes":530}],536:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../histogram2d/sample_defaults"),a=t("../contour/style_defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,i){return n.coerce(t,e,o,r,i)}i(t,e,l);var c=n.coerce2(t,e,o,"contours.start"),u=n.coerce2(t,e,o,"contours.end"),f=l("autocontour",!(c&&u));l(f?"ncontours":"contours.size"),a(t,e,l,s)}},{"../../lib":381,"../contour/style_defaults":509,"../histogram2d/sample_defaults":534,"./attributes":535}],537:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../contour/calc"),n.plot=t("../contour/plot"),n.style=t("../contour/style"),n.colorbar=t("../contour/colorbar"),n.hoverPoints=t("../contour/hover"),n.moduleType="trace",n.name="histogram2dcontour",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","contour","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":411,"../contour/calc":501,"../contour/colorbar":502,"../contour/hover":504,"../contour/plot":507,"../contour/style":508,"./attributes":535,"./defaults":536}],538:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../surface/attributes"),a=t("../../lib/extend").extendFlat;e.exports={x:{valType:"data_array"},y:{valType:"data_array"},z:{valType:"data_array"},i:{valType:"data_array"},j:{valType:"data_array"},k:{valType:"data_array"},delaunayaxis:{valType:"enumerated",values:["x","y","z"],dflt:"z"},alphahull:{valType:"number",dflt:-1},intensity:{valType:"data_array"},color:{valType:"color"},vertexcolor:{valType:"data_array"},facecolor:{valType:"data_array"},opacity:a({},i.opacity),flatshading:{valType:"boolean",dflt:!1},contour:{show:a({},i.contours.x.show,{}),color:a({},i.contours.x.color),width:a({},i.contours.x.width)},colorscale:n.colorscale,reversescale:n.reversescale,showscale:n.showscale,lighting:a({},i.lighting),_nestedModules:{colorbar:"Colorbar"}}},{"../../components/colorscale/attributes":309,"../../lib/extend":376,"../surface/attributes":599}],539:[function(t,e,r){"use strict";function n(t,e,r){this.scene=t,this.uid=r,this.mesh=e,this.name="",this.color="#fff",this.data=null,this.showContour=!1}function i(t){return t.map(function(t){var e=t[0],r=c(t[1]),n=r.toRgb();return{index:e,rgb:[n.r,n.g,n.b,1]}})}function a(t){return t.map(d)}function o(t,e,r){for(var n=new Array(t.length),i=0;i0)s=f(t.alphahull,l);else{var c=["x","y","z"].indexOf(t.delaunayaxis);s=u(l.map(function(t){return[t[(c+1)%3],t[(c+2)%3]]}))}var p={positions:l,cells:s,ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,opacity:t.opacity,contourEnable:t.contour.show,contourColor:d(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",p.vertexIntensity=t.intensity,p.colormap=i(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolors[0],p.vertexColors=a(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],p.cellColors=a(t.facecolor)):(this.color=t.color,p.meshColor=d(t.color)),this.mesh.update(p)},p.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=s},{"../../lib/str2rgbarray":392,"alpha-shape":40,"convex-hull":61,"delaunay-triangulate":73,"gl-mesh3d":109,tinycolor2:233}],540:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/colorbar/defaults"),a=t("./attributes");e.exports=function(t,e,r,o){function s(r,i){return n.coerce(t,e,a,r,i)}function l(t){var e=t.map(function(t){var e=s(t);return e&&Array.isArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var c=l(["x","y","z"]),u=l(["i","j","k"]);return c?(u&&u.forEach(function(t){for(var e=0;el||(c=p[r],void 0!==c&&""!==c||(c=r),c=String(c),void 0===y[c]&&(y[c]=!0,u=a(e.marker.colors[r]),u.isValid()?(u=o.addOpacity(u,u.getAlpha()),m[c]||(m[c]=u)):m[c]?u=m[c]:(u=!1,b=!0),f=-1!==_.indexOf(c),f||(x+=l),g.push({v:l,label:c,color:u,i:r,hidden:f}))));if(e.sort&&g.sort(function(t,e){return e.v-t.v}),b)for(r=0;r")}return g};var l},{"../../components/color":303,"./helpers":546,"fast-isnumeric":76,tinycolor2:233}],545:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(r,a){return n.coerce(t,e,i,r,a)}var s=n.coerceFont,l=o("values");if(!Array.isArray(l)||!l.length)return void(e.visible=!1);var c=o("labels");Array.isArray(c)||(o("label0"),o("dlabel"));var u=o("marker.line.width");u&&o("marker.line.color");var f=o("marker.colors");Array.isArray(f)||(e.marker.colors=[]),o("scalegroup");var h=o("text"),d=o("textinfo",Array.isArray(h)?"text+percent":"percent");if(o("hoverinfo",1===a._dataLength?"label+text+value+percent":void 0),d&&"none"!==d){var p=o("textposition"),g=Array.isArray(p)||"auto"===p,v=g||"inside"===p,m=g||"outside"===p;if(v||m){var y=s(o,"textfont",a.font);v&&s(o,"insidetextfont",y),m&&s(o,"outsidetextfont",y)}}o("domain.x"),o("domain.y"),o("hole"),o("sort"),o("direction"),o("rotation"),o("pull")}},{"../../lib":381,"./attributes":542}],546:[function(t,e,r){"use strict";r.formatPiePercent=function(t){var e=(100*t).toPrecision(3);return-1!==e.indexOf(".")?e.replace(/[.]?0+$/,"")+"%":e+"%"},r.formatPieValue=function(t){var e=t.toPrecision(10);return-1!==e.indexOf(".")?e.replace(/[.]?0+$/,""):e}},{}],547:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.layoutAttributes=t("./layout_attributes"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.styleOne=t("./style_one"),n.moduleType="trace",n.name="pie",n.basePlotModule=t("./base_plot"),n.categories=["pie","showLegend"],n.meta={},e.exports=n},{"./attributes":542,"./base_plot":543,"./calc":544,"./defaults":545,"./layout_attributes":548,"./layout_defaults":549,"./plot":550,"./style":551,"./style_one":552}],548:[function(t,e,r){"use strict";e.exports={hiddenlabels:{valType:"data_array"}}},{}],549:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e){function r(r,a){return n.coerce(t,e,i,r,a)}r("hiddenlabels")}},{"../../lib":381,"./layout_attributes":548}],550:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,o=Math.PI*Math.min(e.v/r.vTotal,.5),s=1-r.trace.hole,l=i(e,r),c={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(c.scale>=1)return c;var u=a+1/(2*Math.tan(o)),f=r.r*Math.min(1/(Math.sqrt(u*u+.5)+u),s/(Math.sqrt(a*a+s/2)+a)),h={scale:2*f/t.height,rCenter:Math.cos(f/r.r)-f*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},d=1/a,p=d+1/(2*Math.tan(o)),g=r.r*Math.min(1/(Math.sqrt(p*p+.5)+p),s/(Math.sqrt(d*d+s/2)+d)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},m=v.scale>h.scale?v:h;return c.scale<1&&m.scale>c.scale?m:c}function i(t,e){if(t.v===e.vTotal&&!e.trace.hole)return 1;var r=Math.PI*Math.min(t.v/e.vTotal,.5);return Math.min(1/(1+1/Math.sin(r)),(1-e.trace.hole)/2)}function a(t,e){var r=e.pxmid[0],n=e.pxmid[1],i=t.width/2,a=t.height/2;return 0>r&&(i*=-1),0>n&&(a*=-1),{scale:1,rCenter:1,rotate:0,x:i+Math.abs(a)*(i>0?1:-1)/2,y:a/(1+r*r/(n*n)),outside:!0}}function o(t,e){function r(t,e){return t.pxmid[1]-e.pxmid[1]}function n(t,e){return e.pxmid[1]-t.pxmid[1]}function i(t,r){r||(r={});var n,i,a,s,h,d,g=r.labelExtraY+(o?r.yLabelMax:r.yLabelMin),v=o?t.yLabelMin:t.yLabelMax,m=o?t.yLabelMax:t.yLabelMin,y=t.cyFinal+c(t.px0[1],t.px1[1]),b=g-v;if(b*f>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(i=0;i=e.pull[a.i]||((t.pxmid[1]-a.pxmid[1])*f>0?(s=a.cyFinal+c(a.px0[1],a.px1[1]),b=s-v-t.labelExtraY,b*f>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-y)*f>0&&(n=3*u*Math.abs(i-p.indexOf(t)),h=a.cxFinal+l(a.px0[0],a.px1[0]),d=h+n-(t.cxFinal+t.pxmid[0])-t.labelExtraX,d*u>0&&(t.labelExtraX+=d)))}var a,o,s,l,c,u,f,h,d,p,g,v,m;for(o=0;2>o;o++)for(s=o?r:n,c=o?Math.max:Math.min,f=o?1:-1,a=0;2>a;a++){for(l=a?Math.max:Math.min,u=a?1:-1,h=t[o][a],h.sort(s),d=t[1-o][a],p=d.concat(h),v=[],g=0;gu&&(u=s.pull[a]);o.r=Math.min(r/c(s.tilt,Math.sin(l),s.depth),n/c(s.tilt,Math.cos(l),s.depth))/(2+2*u),o.cx=e.l+e.w*(s.domain.x[1]+s.domain.x[0])/2,o.cy=e.t+e.h*(2-s.domain.y[1]-s.domain.y[0])/2,s.scalegroup&&-1===d.indexOf(s.scalegroup)&&d.push(s.scalegroup)}for(a=0;af.vTotal/2?1:0)}function c(t,e,r){if(!t)return 1;var n=Math.sin(t*Math.PI/180);return Math.max(.01,r*n*Math.abs(e)+2*Math.sqrt(1-n*n*e*e))}var u=t("d3"),f=t("../../plots/cartesian/graph_interact"),h=t("../../components/color"),d=t("../../components/drawing"),p=t("../../lib/svg_text_utils"),g=t("./helpers");e.exports=function(t,e){var r=t._fullLayout;s(e,r._size);var c=r._pielayer.selectAll("g.trace").data(e);c.enter().append("g").attr({"stroke-linejoin":"round","class":"trace"}),c.exit().remove(),c.order(),c.each(function(e){var s=u.select(this),c=e[0],v=c.trace,m=0,y=(v.depth||0)*c.r*Math.sin(m)/2,b=v.tiltaxis||0,x=b*Math.PI/180,_=[y*Math.sin(x),y*Math.cos(x)],w=c.r*Math.cos(m),k=s.selectAll("g.part").data(v.tilt?["top","sides"]:["top"]);k.enter().append("g").attr("class",function(t){return t+" part"}),k.exit().remove(),k.order(),l(e),s.selectAll(".top").each(function(){var s=u.select(this).selectAll("g.slice").data(e);s.enter().append("g").classed("slice",!0),s.exit().remove();var l=[[[],[]],[[],[]]],m=!1;s.each(function(o){function s(e){var r=t._fullLayout,n=t._fullData[v.index],a=n.hoverinfo;if("all"===a&&(a="label+text+value+percent+name"),!t._dragging&&r.hovermode!==!1&&"none"!==a&&a){var s=i(o,c),l=k+o.pxmid[0]*(1-s),u=A+o.pxmid[1]*(1-s),h=[];-1!==a.indexOf("label")&&h.push(o.label),n.text&&n.text[o.i]&&-1!==a.indexOf("text")&&h.push(n.text[o.i]),-1!==a.indexOf("value")&&h.push(g.formatPieValue(o.v)),-1!==a.indexOf("percent")&&h.push(g.formatPiePercent(o.v/c.vTotal)),f.loneHover({x0:l-s*c.r,x1:l+s*c.r,y:u,text:h.join("
"),name:-1!==a.indexOf("name")?n.name:void 0,color:o.color,idealAlign:o.pxmid[0]<0?"left":"right"},{container:r._hoverlayer.node(),outerContainer:r._paper.node()}),f.hover(t,e,"pie"),E=!0}}function h(e){t.emit("plotly_unhover",{points:[e]}),E&&(f.loneUnhover(r._hoverlayer.node()),E=!1)}function y(){t._hoverdata=[o],t._hoverdata.trace=e.trace,f.click(t,{target:!0})}function x(t,e,r,n){return"a"+n*c.r+","+n*w+" "+b+" "+o.largeArc+(r?" 1 ":" 0 ")+n*(e[0]-t[0])+","+n*(e[1]-t[1])}if(o.hidden)return void u.select(this).selectAll("path,g").remove();l[o.pxmid[1]<0?0:1][o.pxmid[0]<0?0:1].push(o);var k=c.cx+_[0],A=c.cy+_[1],M=u.select(this),T=M.selectAll("path.surface").data([o]),E=!1;if(T.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),M.select("path.textline").remove(),M.on("mouseover",s).on("mouseout",h).on("click",y),v.pull){var L=+(Array.isArray(v.pull)?v.pull[o.i]:v.pull)||0;L>0&&(k+=L*o.pxmid[0],A+=L*o.pxmid[1])}o.cxFinal=k,o.cyFinal=A;var S=v.hole;if(o.v===c.vTotal){var C="M"+(k+o.px0[0])+","+(A+o.px0[1])+x(o.px0,o.pxmid,!0,1)+x(o.pxmid,o.px0,!0,1)+"Z";S?T.attr("d","M"+(k+S*o.px0[0])+","+(A+S*o.px0[1])+x(o.px0,o.pxmid,!1,S)+x(o.pxmid,o.px0,!1,S)+"Z"+C):T.attr("d",C)}else{var z=x(o.px0,o.px1,!0,1);if(S){var P=1-S;T.attr("d","M"+(k+S*o.px1[0])+","+(A+S*o.px1[1])+x(o.px1,o.px0,!1,S)+"l"+P*o.px0[0]+","+P*o.px0[1]+z+"Z")}else T.attr("d","M"+k+","+A+"l"+o.px0[0]+","+o.px0[1]+z+"Z")}var R=Array.isArray(v.textposition)?v.textposition[o.i]:v.textposition,O=M.selectAll("g.slicetext").data(o.text&&"none"!==R?[0]:[]);O.enter().append("g").classed("slicetext",!0),O.exit().remove(),O.each(function(){var t=u.select(this).selectAll("text").data([0]);t.enter().append("text").attr("data-notex",1),t.exit().remove(),t.text(o.text).attr({"class":"slicetext",transform:"","data-bb":"","text-anchor":"middle",x:0,y:0}).call(d.font,"outside"===R?v.outsidetextfont:v.insidetextfont).call(p.convertToTspans),t.selectAll("tspan.line").attr({x:0,y:0});var e,r=d.bBox(t.node());"outside"===R?e=a(r,o):(e=n(r,o,c),"auto"===R&&e.scale<1&&(t.call(d.font,v.outsidetextfont),v.outsidetextfont.family===v.insidetextfont.family&&v.outsidetextfont.size===v.insidetextfont.size||(t.attr({"data-bb":""}),r=d.bBox(t.node())),e=a(r,o)));var i=k+o.pxmid[0]*e.rCenter+(e.x||0),s=A+o.pxmid[1]*e.rCenter+(e.y||0);e.outside&&(o.yLabelMin=s-r.height/2,o.yLabelMid=s,o.yLabelMax=s+r.height/2,o.labelExtraX=0,o.labelExtraY=0,m=!0),t.attr("transform","translate("+i+","+s+")"+(e.scale<1?"scale("+e.scale+")":"")+(e.rotate?"rotate("+e.rotate+")":"")+"translate("+-(r.left+r.right)/2+","+-(r.top+r.bottom)/2+")")})}),m&&o(l,v),s.each(function(t){if(t.labelExtraX||t.labelExtraY){var e=u.select(this),r=e.select("g.slicetext text");r.attr("transform","translate("+t.labelExtraX+","+t.labelExtraY+")"+r.attr("transform"));var n=t.cxFinal+t.pxmid[0],i=t.cyFinal+t.pxmid[1],a="M"+n+","+i,o=(t.yLabelMax-t.yLabelMin)*(t.pxmid[0]<0?-1:1)/4;if(t.labelExtraX){var s=t.labelExtraX*t.pxmid[1]/t.pxmid[0],l=t.yLabelMid+t.labelExtraY-(t.cyFinal+t.pxmid[1]);a+=Math.abs(s)>Math.abs(l)?"l"+l*t.pxmid[0]/t.pxmid[1]+","+l+"H"+(n+t.labelExtraX+o):"l"+t.labelExtraX+","+s+"v"+(l-s)+"h"+o}else a+="V"+(t.yLabelMid+t.labelExtraY)+"h"+o;e.append("path").classed("textline",!0).call(h.stroke,v.outsidetextfont.color).attr({"stroke-width":Math.min(2,v.outsidetextfont.size/8),d:a,fill:"none"})}})})}),setTimeout(function(){c.selectAll("tspan").each(function(){var t=u.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":303,"../../components/drawing":325,"../../lib/svg_text_utils":393,"../../plots/cartesian/graph_interact":410,"./helpers":546,d3:72}],551:[function(t,e,r){"use strict";var n=t("d3"),i=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0],r=e.trace,a=n.select(this);a.style({opacity:r.opacity}),a.selectAll(".top path.surface").each(function(t){n.select(this).call(i,t,r)})})}},{"./style_one":552,d3:72}],552:[function(t,e,r){"use strict";var n=t("../../components/color");e.exports=function(t,e,r){var i=r.marker.line.color;Array.isArray(i)&&(i=i[e.i]||n.defaultLine);var a=r.marker.line.width||0;Array.isArray(a)&&(a=a[e.i]||0),t.style({"stroke-width":a,fill:e.color}).call(n.stroke,i)}},{"../../components/color":303}],553:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t){var e=t[0].trace,r=e.marker;if(n.mergeArray(e.text,t,"tx"),n.mergeArray(e.textposition,t,"tp"),e.textfont&&(n.mergeArray(e.textfont.size,t,"ts"),n.mergeArray(e.textfont.color,t,"tc"),n.mergeArray(e.textfont.family,t,"tf")),r&&r.line){var i=r.line;n.mergeArray(r.opacity,t,"mo"),n.mergeArray(r.symbol,t,"mx"),n.mergeArray(r.color,t,"mc"),n.mergeArray(i.color,t,"mlc"),n.mergeArray(i.width,t,"mlw")}}},{"../../lib":381}],554:[function(t,e,r){"use strict";var n=t("../../components/drawing");t("./constants");e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number",min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:{symbol:{valType:"enumerated",values:n.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},color:{valType:"color",arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number",dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},colorscale:{valType:"colorscale"},cauto:{valType:"boolean",dflt:!0},cmax:{valType:"number",dflt:null},cmin:{valType:"number",dflt:null},autocolorscale:{valType:"boolean",dflt:!0},reversescale:{valType:"boolean",dflt:!1},showscale:{valType:"boolean",dflt:!1},line:{color:{valType:"color",arrayOk:!0},width:{valType:"number",min:0,arrayOk:!0},colorscale:{ -valType:"colorscale"},cauto:{valType:"boolean",dflt:!0},cmax:{valType:"number",dflt:null},cmin:{valType:"number",dflt:null},autocolorscale:{valType:"boolean",dflt:!0},reversescale:{valType:"boolean",dflt:!1}}},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:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/drawing":325,"./constants":558}],555:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./subtypes"),s=t("./marker_colorscale_calc");e.exports=function(t,e){var r=i.getFromId(t,e.xaxis||"x"),l=i.getFromId(t,e.yaxis||"y");a.markTime("in Scatter.calc");var c=r.makeCalcdata(e,"x");a.markTime("finished convert x");var u=l.makeCalcdata(e,"y");a.markTime("finished convert y");var f,h,d,p=Math.min(c.length,u.length);r._minDtick=0,l._minDtick=0,c.length>p&&c.splice(p,c.length-p),u.length>p&&u.splice(p,u.length-p);var g={padded:!0},v={padded:!0};if(o.hasMarkers(e)){if(f=e.marker,h=f.size,Array.isArray(h)){var m={type:"linear"};i.setConvert(m),h=m.makeCalcdata(e.marker,"size"),h.length>p&&h.splice(p,h.length-p)}var y,b=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/b),3)}:function(t){return Math.max((t||0)/b,3)},g.ppad=v.ppad=Array.isArray(h)?h.map(y):y(h)}s(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||c[0]===c[p-1]&&u[0]===u[p-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(o.hasMarkers(e)||o.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||c[0]===c[p-1]&&u[0]===u[p-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(v.padded=!1):v.tozero=!0,a.markTime("ready for Axes.expand"),i.expand(r,c,g),a.markTime("done expand x"),i.expand(l,u,v),a.markTime("done expand y");var x=new Array(p);for(d=0;p>d;d++)x[d]=n(c[d])&&n(u[d])?{x:c[d],y:u[d]}:{x:!1,y:!1};return void 0!==typeof h&&a.mergeArray(h,x,"ms"),t.firstscatter=!1,x}},{"../../lib":381,"../../plots/cartesian/axes":403,"./marker_colorscale_calc":568,"./subtypes":573,"fast-isnumeric":76}],556:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i,a;for(e=0;e=0;i--)if(a=t[i],"scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}},{}],557:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c=r.marker,u="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void o.autoMargin(t,u);var f=s(c.colorscale),h=c.color,d=c.cmin,p=c.cmax;i(d)||(d=a.aggNums(Math.min,null,h)),i(p)||(p=a.aggNums(Math.max,null,h));var g=e[0].t.cb=l(t,u);g.fillcolor(n.scale.linear().domain(f.map(function(t){return d+t[0]*(p-d)})).range(f.map(function(t){return t[1]}))).filllevels({start:d,end:p,size:(p-d)/254}).options(c.colorbar)(),a.markTime("done colorbar")}},{"../../components/colorbar/draw":306,"../../components/colorscale/get_scale":314,"../../lib":381,"../../plots/plots":452,d3:72,"fast-isnumeric":76}],558:[function(t,e,r){"use strict";e.exports={PTS_LINESONLY:20}},{}],559:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("./constants"),o=t("./subtypes"),s=t("./xy_defaults"),l=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),h=t("./fillcolor_defaults"),d=t("../../components/errorbars/defaults");e.exports=function(t,e,r,p){function g(r,a){return n.coerce(t,e,i,r,a)}var v=s(t,e,g),m=vi(f))break;l=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,c=f,d=!1):m>y&&(m=y,u=f,d=!0)}if(d?(C[z++]=c,l!==u&&(C[z++]=u)):(u!==s&&(C[z++]=u),l!==c&&(C[z++]=c)),C[z++]=l,o>=t.length||!f)break;C[z++]=f,s=f}}else C[z++]=c}E.push(C.slice(0,z))}return E}},{"../../plots/cartesian/axes":403}],566:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=r("line.shape");"spline"===n&&r("line.smoothing")}},{}],567:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t){var e=t.marker,r=e.sizeref||1,i=e.sizemin||0,a="area"===e.sizemode?function(t){return Math.sqrt(t/r)}:function(t){return t/r};return function(t){var e=a(t/2);return n(e)&&e>0?Math.max(e,i):0}}},{"fast-isnumeric":76}],568:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("./subtypes");e.exports=function(t){if(a.hasMarkers(t)){var e=t.marker;n(t,"marker")&&i(t,e.color,"marker","c"),n(t,"marker.line")&&i(t,e.line.color,"marker.line","c")}}},{"../../components/colorscale/calc":310,"../../components/colorscale/has_colorscale":315,"./subtypes":573}],569:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l){var c,u=o.isBubble(t),f=(t.line||{}).color;f&&(r=f),l("marker.symbol"),l("marker.opacity",u?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),c=f&&e.marker.color!==f?f:u?n.background:n.defaultLine,l("marker.line.color",c),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",u?1:0),u&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode"))}},{"../../components/color":303,"../../components/colorscale/defaults":312,"../../components/colorscale/has_colorscale":315,"./subtypes":573}],570:[function(t,e,r){"use strict";function n(t,e,r){var n=e.x(),a=e.y(),o=i.extent(n.range.map(n.l2c)),s=i.extent(a.range.map(a.l2c));r.forEach(function(t,e){var n=t[0].trace;if(l.hasMarkers(n)){var i=n.marker.maxdisplayed;if(0!==i){var a=t.filter(function(t){return t.x>=o[0]&&t.x<=o[1]&&t.y>=s[0]&&t.y<=s[1]}),c=Math.ceil(a.length/i),u=0;r.forEach(function(t,r){var n=t[0].trace;l.hasMarkers(n)&&n.marker.maxdisplayed>0&&e>r&&u++});var f=Math.round(u*c/3+Math.floor(u/3)*c/7.1);t.forEach(function(t){delete t.vis}),a.forEach(function(t,e){0===Math.round((e+f)%c)&&(t.vis=!0)})}}})}var i=t("d3"),a=t("../../lib"),o=t("../../components/drawing"),s=t("../../components/errorbars"),l=t("./subtypes"),c=t("./arrays_to_calcdata"),u=t("./line_points");e.exports=function(t,e,r){function f(t){return t.filter(function(t){return t.vis})}n(t,e,r);var h=e.x(),d=e.y(),p=e.plot.select(".scatterlayer").selectAll("g.trace.scatter").data(r);p.enter().append("g").attr("class","trace scatter").style("stroke-miterlimit",2),p.call(s.plot,e);var g,v,m,y,b="";p.each(function(t){var e=t[0].trace,r=e.line,n=i.select(this);if(e.visible===!0&&(v=e.fill.charAt(e.fill.length-1),"x"!==v&&"y"!==v&&(v=""),t[0].node3=n,c(t),l.hasLines(e)||"none"!==e.fill)){var a,s,f,p,x,_="",w="";g="tozero"===e.fill.substr(0,6)||"toself"===e.fill||"to"===e.fill.substr(0,2)&&!b?n.append("path").classed("js-fill",!0):null,y&&(m=y.datum(t)),y=n.append("path").classed("js-fill",!0),-1!==["hv","vh","hvh","vhv"].indexOf(r.shape)?(f=o.steps(r.shape),p=o.steps(r.shape.split("").reverse().join(""))):f=p="spline"===r.shape?function(t){var e=t[t.length-1];return t[0][0]===e[0]&&t[0][1]===e[1]?o.smoothclosed(t.slice(1),r.smoothing):o.smoothopen(t,r.smoothing)}:function(t){return"M"+t.join("L")},x=function(t){return p(t.reverse())};var k=u(t,{xaxis:h,yaxis:d,connectGaps:e.connectgaps,baseTolerance:Math.max(r.width||1,3)/4,linear:"linear"===r.shape});if(k.length){for(var A=k[0][0],M=k[k.length-1],T=M[M.length-1],E=0;E1&&n.append("path").classed("js-line",!0).attr("d",a)}g?A&&T&&(v?("y"===v?A[1]=T[1]=d.c2p(0,!0):"x"===v&&(A[0]=T[0]=h.c2p(0,!0)),g.attr("d",_+"L"+T+"L"+A+"Z")):g.attr("d",_+"Z")):"tonext"===e.fill.substr(0,6)&&_&&b&&("tonext"===e.fill?m.attr("d",_+"Z"+b+"Z"):m.attr("d",_+"L"+b.substr(1)+"Z")),b=w}}}),p.selectAll("path:not([d])").remove(),p.append("g").attr("class","points").each(function(t){var e=t[0].trace,r=i.select(this),n=l.hasMarkers(e),s=l.hasText(e);!n&&!s||e.visible!==!0?r.remove():(n&&r.selectAll("path.point").data(e.marker.maxdisplayed?f:a.identity).enter().append("path").classed("point",!0).call(o.translatePoints,h,d),s&&r.selectAll("g").data(e.marker.maxdisplayed?f:a.identity).enter().append("g").append("text").call(o.translatePoints,h,d))})}},{"../../components/drawing":325,"../../components/errorbars":331,"../../lib":381,"./arrays_to_calcdata":553,"./line_points":565,"./subtypes":573,d3:72}],571:[function(t,e,r){"use strict";var n=t("./subtypes"),i=.2;e.exports=function(t,e){var r,a,o,s,l=t.cd,c=t.xaxis,u=t.yaxis,f=[],h=l[0].trace,d=h.index,p=h.marker;if(n.hasMarkers(h)||n.hasText(h)){var g=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(r=0;rs;s++){for(var l=[[0,0,0],[0,0,0]],c=0;3>c;c++)if(r[c])for(var u=0;2>u;u++)l[u][c]=r[c][s][u];o[s]=l}return o}var o=t("../../components/errorbars/compute_error");e.exports=a},{"../../components/errorbars/compute_error":329}],579:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.linePlot=null,this.scatterPlot=null,this.errorBars=null,this.textMarkers=null,this.delaunayMesh=null,this.color=null,this.mode="",this.dataPoints=[],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.textLabels=null,this.data=null}function i(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],s=[];for(n=0;ni;i++){var a=t[i];a&&a.copy_zstyle!==!1&&(a=t[2]),a&&(e[i]=a.width/2,r[i]=b(a.color),n=a.thickness)}return{capSize:e,color:r,lineWidth:n}}function o(t){var e=[0,0];return Array.isArray(t)?[0,-1]:(t.indexOf("bottom")>=0&&(e[1]+=1),t.indexOf("top")>=0&&(e[1]-=1),t.indexOf("left")>=0&&(e[0]-=1),t.indexOf("right")>=0&&(e[0]+=1),e)}function s(t,e){return e(4*t)}function l(t){return k[t]}function c(t,e,r,n,i){var a=null;if(Array.isArray(t)){a=[];for(var o=0;e>o;o++)void 0===t[o]?a[o]=n:a[o]=r(t[o],i)}else a=r(t,y.identity);return a}function u(t,e){var r,n,i,u,f,h,d=[],p=t.fullSceneLayout,g=t.dataScale,v=p.xaxis,m=p.yaxis,w=p.zaxis,k=e.marker,M=e.line,T=e.x||[],E=e.y||[],L=e.z||[],S=T.length;for(n=0;S>n;n++)i=v.d2l(T[n])*g[0],u=m.d2l(E[n])*g[1],f=w.d2l(L[n])*g[2],d[n]=[i,u,f];if(Array.isArray(e.text))h=e.text;else if(void 0!==e.text)for(h=new Array(S),n=0;S>n;n++)h[n]=e.text;if(r={position:d,mode:e.mode,text:h},"line"in e&&(r.lineColor=b(M.color),r.lineWidth=M.width,r.lineDashes=M.dash),"marker"in e){var C=_(e);r.scatterColor=x(k,1,S),r.scatterSize=c(k.size,S,s,20,C),r.scatterMarker=c(k.symbol,S,l,"\u25cf"),r.scatterLineWidth=k.line.width,r.scatterLineColor=x(k.line,1,S),r.scatterAngle=0}"textposition"in e&&(r.textOffset=o(e.textposition),r.textColor=x(e.textfont,1,S),r.textSize=c(e.textfont.size,S,y.identity,12),r.textFont=e.textfont.family,r.textAngle=0);var z=["x","y","z"];for(r.project=[!1,!1,!1],r.projectScale=[1,1,1],r.projectOpacity=[1,1,1],n=0;3>n;++n){var P=e.projection[z[n]];(r.project[n]=P.show)&&(r.projectOpacity[n]=P.opacity,r.projectScale[n]=P.scale)}r.errorBounds=A(e,g);var R=a([e.error_x,e.error_y,e.error_z]);return r.errorColor=R.color,r.errorLineWidth=R.lineWidth,r.errorCapSize=R.capSize,r.delaunayAxis=e.surfaceaxis,r.delaunayColor=b(e.surfacecolor),r}function f(t){if(Array.isArray(t)){var e=t[0];return Array.isArray(e)&&(t=e),"rgb("+t.slice(0,3).map(function(t){return Math.round(255*t)})+")"}return null}function h(t,e){var r=new n(t,e.uid);return r.update(e),r}var d=t("gl-line3d"),p=t("gl-scatter3d"),g=t("gl-error3d"),v=t("gl-mesh3d"),m=t("delaunay-triangulate"),y=t("../../lib"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/make_bubble_size_func"),w=t("../../constants/gl3d_dashes"),k=t("../../constants/gl_markers"),A=t("./calc_errors"),M=n.prototype;M.handlePick=function(t){if(t.object&&(t.object===this.linePlot||t.object===this.delaunayMesh||t.object===this.textMarkers||t.object===this.scatterPlot)){t.object.highlight&&t.object.highlight(null),this.scatterPlot&&(t.object=this.scatterPlot,this.scatterPlot.highlight(t.data)),this.textLabels&&void 0!==this.textLabels[t.data.index]?t.textLabel=this.textLabels[t.data.index]:t.textLabel="";var e=t.data.index;return t.traceCoordinate=[this.data.x[e],this.data.y[e],this.data.z[e]],!0}},M.update=function(t){var e,r,n,a,o=this.scene.glplot.gl,s=w.solid;this.data=t;var l=u(this.scene,t);"mode"in l&&(this.mode=l.mode),"lineDashes"in l&&l.lineDashes in w&&(s=w[l.lineDashes]),this.color=f(l.scatterColor)||f(l.lineColor),this.dataPoints=l.position,e={gl:o,position:l.position,color:l.lineColor,lineWidth:l.lineWidth||1,dashes:s[0],dashScale:s[1],opacity:t.opacity,connectGaps:t.connectgaps},-1!==this.mode.indexOf("lines")?this.linePlot?this.linePlot.update(e):(this.linePlot=d(e),this.scene.glplot.add(this.linePlot)):this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose(),this.linePlot=null);var c=t.opacity;if(t.marker&&t.marker.opacity&&(c*=t.marker.opacity),r={gl:o,position:l.position,color:l.scatterColor,size:l.scatterSize,glyph:l.scatterMarker,opacity:c,orthographic:!0,lineWidth:l.scatterLineWidth,lineColor:l.scatterLineColor,project:l.project,projectScale:l.projectScale,projectOpacity:l.projectOpacity},-1!==this.mode.indexOf("markers")?this.scatterPlot?this.scatterPlot.update(r):(this.scatterPlot=p(r),this.scatterPlot.highlightScale=1,this.scene.glplot.add(this.scatterPlot)):this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose(),this.scatterPlot=null),a={gl:o,position:l.position,glyph:l.text,color:l.textColor,size:l.textSize,angle:l.textAngle,alignment:l.textOffset,font:l.textFont,orthographic:!0,lineWidth:0,project:!1,opacity:t.opacity},this.textLabels=l.text,-1!==this.mode.indexOf("text")?this.textMarkers?this.textMarkers.update(a):(this.textMarkers=p(a),this.textMarkers.highlightScale=1,this.scene.glplot.add(this.textMarkers)):this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose(),this.textMarkers=null),n={gl:o,position:l.position,color:l.errorColor,error:l.errorBounds,lineWidth:l.errorLineWidth,capSize:l.errorCapSize,opacity:t.opacity},this.errorBars?l.errorBounds?this.errorBars.update(n):(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose(),this.errorBars=null):l.errorBounds&&(this.errorBars=g(n),this.scene.glplot.add(this.errorBars)),l.delaunayAxis>=0){var h=i(l.position,l.delaunayColor,l.delaunayAxis);h.opacity=t.opacity,this.delaunayMesh?this.delaunayMesh.update(h):(h.gl=o,this.delaunayMesh=v(h),this.scene.glplot.add(this.delaunayMesh))}else this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose(),this.delaunayMesh=null)},M.dispose=function(){this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose()),this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose()),this.errorBars&&(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose()),this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose()),this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose())},e.exports=h},{"../../constants/gl3d_dashes":367,"../../constants/gl_markers":368,"../../lib":381,"../../lib/gl_format_color":379,"../../lib/str2rgbarray":392,"../scatter/make_bubble_size_func":567,"./calc_errors":578,"delaunay-triangulate":73,"gl-error3d":80,"gl-line3d":86,"gl-mesh3d":109,"gl-scatter3d":152}],580:[function(t,e,r){"use strict";function n(t,e,r){var n=0,i=r("x"),a=r("y"),o=r("z");return i&&a&&o&&(n=Math.min(i.length,a.length,o.length),n=0&&h("surfacecolor",p||g);for(var v=["x","y","z"],m=0;3>m;++m){var y="projection."+v[m];h(y+".show")&&(h(y+".opacity"),h(y+".scale"))}c(t,e,r,{axis:"z"}),c(t,e,r,{axis:"y",inherit:"z"}),c(t,e,r,{axis:"x",inherit:"z"})}},{"../../components/errorbars/defaults":330,"../../lib":381,"../scatter/line_defaults":564,"../scatter/marker_defaults":569,"../scatter/subtypes":573,"../scatter/text_defaults":574,"./attributes":576}],581:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../constants/gl_markers":368,"../../plots/gl3d":439,"../scatter/colorbar":557,"./attributes":576,"./calc":577,"./convert":579,"./defaults":580}],582:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=n.line,l=o.line;e.exports={lon:{valType:"data_array"},lat:{valType:"data_array"},locations:{valType:"data_array"},locationmode:{valType:"enumerated",values:["ISO-3","USA-states","country names"],dflt:"ISO-3"},mode:a({},n.mode,{dflt:"markers"}),text:a({},n.text,{}),line:{color:s.color,width:s.width,dash:s.dash},marker:{symbol:o.symbol,opacity:o.opacity,size:o.size,sizeref:o.sizeref,sizemin:o.sizemin,sizemode:o.sizemode,color:o.color,colorscale:o.colorscale,cauto:o.cauto,cmax:o.cmax,cmin:o.cmin,autocolorscale:o.autocolorscale,reversescale:o.reversescale,showscale:o.showscale,line:{color:l.color,width:l.width,colorscale:l.colorscale,cauto:l.cauto,cmax:l.cmax,cmin:l.cmin,autocolorscale:l.autocolorscale,reversescale:l.reversescale}},textfont:n.textfont,textposition:n.textposition,hoverinfo:a({},i.hoverinfo,{flags:["lon","lat","location","text","name"]}),_nestedModules:{"marker.colorbar":"Colorbar"}}},{"../../lib/extend":376,"../../plots/attributes":401,"../scatter/attributes":554}],583:[function(t,e,r){"use strict";var n=t("../scatter/marker_colorscale_calc");e.exports=function(t,e){var r=[{x:!1,y:!1,trace:e,t:{}}];return n(e),r}},{"../scatter/marker_colorscale_calc":568}],584:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=0,o=r("locations");return o?(r("locationmode"),a=o.length):(n=r("lon")||[],i=r("lat")||[],a=Math.min(n.length,i.length),an;n++)r[n]=[t.lon[n],t.lat[n]];return{type:"LineString",coordinates:r,trace:t}}function a(t,e){function r(e){var r=t.mockAxis;return c.tickText(r,r.c2l(e),"hover").text+"\xb0"}var n=e.hoverinfo;if("none"===n)return function(t){delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("location")&&Array.isArray(e.locations),o=-1!==i.indexOf("lon"),s=-1!==i.indexOf("lat"),l=-1!==i.indexOf("text");return function(t){var n=[];a?n.push(t.location):o&&s?n.push("("+r(t.lon)+", "+r(t.lat)+")"):o?n.push("lon: "+r(t.lon)):s&&n.push("lat: "+r(t.lat)),l&&n.push(t.tx||e.text),t.textLabel=n.join("
")}}function o(t){var e=Array.isArray(t.locations);return function(r,n){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:n,lon:r.lon,lat:r.lat,location:e?r.location:null}]}}}var s=t("d3"),l=t("../../plots/cartesian/graph_interact"),c=t("../../plots/cartesian/axes"),u=t("../../lib/topojson_utils").getTopojsonFeatures,f=t("../../lib/geo_location_utils").locationToFeature,h=t("../../lib/array_to_calc_item"),d=t("../../components/color"),p=t("../../components/drawing"),g=t("../scatter/subtypes"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){var r,i,a,o,s=[],l=Array.isArray(t.locations);l?(o=t.locations,r=o.length,i=u(t,e),a=function(t,e){var r=f(t.locationmode,o[e],i);return void 0!==r?r.properties.ct:void 0}):(r=t.lon.length,a=function(t,e){return[t.lon[e],t.lat[e]]});for(var c=0;r>c;c++){var h=a(t,c);if(h){var d={lon:h[0],lat:h[1],location:l?t.locations[c]:null};n(t,d,c),s.push(d)}}return s.length>0&&(s[0].trace=t),s},m.plot=function(t,e){var r=t.framework.select(".scattergeolayer").selectAll("g.trace.scattergeo").data(e,function(t){return t.uid});r.enter().append("g").attr("class","trace scattergeo"),r.exit().remove(),r.selectAll("*").remove(),r.each(function(t){var e=s.select(this);g.hasLines(t)&&e.selectAll("path.js-line").data([i(t)]).enter().append("path").classed("js-line",!0)}),r.each(function(e){function r(r,n){if(t.showHover){var i=t.projection([r.lon,r.lat]);h(r),l.loneHover({x:i[0],y:i[1],name:v?e.name:void 0,text:r.textLabel,color:r.mc||(e.marker||{}).color},{container:t.hoverContainer.node()}),y=d(r,n),t.graphDiv.emit("plotly_hover",y)}}function n(e,r){t.graphDiv.emit("plotly_click",d(e,r))}var i=s.select(this),c=g.hasMarkers(e),u=g.hasText(e);if(c||u){var f=m.calcGeoJSON(e,t.topojson),h=a(t,e),d=o(e),p=e.hoverinfo,v="all"===p||-1!==p.indexOf("name"),y=null;c&&i.selectAll("path.point").data(f).enter().append("path").classed("point",!0).on("mouseover",r).on("click",n).on("mouseout",function(){l.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",y)}).on("mousedown",function(){ -l.loneUnhover(t.hoverContainer)}).on("mouseup",r),u&&i.selectAll("g").data(f).enter().append("g").append("text")}}),m.style(t)},m.style=function(t){var e=t.framework.selectAll("g.trace.scattergeo");e.style("opacity",function(t){return t.opacity}),e.each(function(t){s.select(this).selectAll("path.point").call(p.pointStyle,t),s.select(this).selectAll("text").call(p.textPointStyle,t)}),e.selectAll("path.js-line").style("fill","none").each(function(t){var e=t.trace,r=e.line||{};s.select(this).call(d.stroke,r.color).call(p.dashLine,r.dash||"",r.width||0)})}},{"../../components/color":303,"../../components/drawing":325,"../../lib/array_to_calc_item":372,"../../lib/geo_location_utils":378,"../../lib/topojson_utils":394,"../../plots/cartesian/axes":403,"../../plots/cartesian/graph_interact":410,"../scatter/subtypes":573,"./attributes":582,d3:72}],587:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../constants/gl2d_dashes"),a=t("../../constants/gl_markers"),o=t("../../lib/extend").extendFlat,s=n.line,l=n.marker,c=l.line;e.exports={x:n.x,x0:n.x0,dx:n.dx,y:n.y,y0:n.y0,dy:n.dy,text:o({},n.text,{}),mode:{valType:"flaglist",flags:["lines","markers"],extras:["none"]},line:{color:s.color,width:s.width,dash:{valType:"enumerated",values:Object.keys(i),dflt:"solid"}},marker:{color:l.color,symbol:{valType:"enumerated",values:Object.keys(a),dflt:"circle",arrayOk:!0},size:l.size,sizeref:l.sizeref,sizemin:l.sizemin,sizemode:l.sizemode,opacity:l.opacity,colorscale:l.colorscale,cauto:l.cauto,cmax:l.cmax,cmin:l.cmin,autocolorscale:l.autocolorscale,reversescale:l.reversescale,showscale:l.showscale,line:{color:c.color,width:c.width,colorscale:c.colorscale,cauto:c.cauto,cmax:c.cmax,cmin:c.cmin,autocolorscale:c.autocolorscale,reversescale:c.reversescale}},connectgaps:n.connectgaps,fill:o({},n.fill,{values:["none","tozeroy","tozerox"]}),fillcolor:n.fillcolor,_nestedModules:{error_x:"ErrorBars",error_y:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../constants/gl2d_dashes":366,"../../constants/gl_markers":368,"../../lib/extend":376,"../scatter/attributes":554}],588:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.pickXData=[],this.pickYData=[],this.xData=[],this.yData=[],this.textLabels=[],this.color="rgb(0, 0, 0)",this.name="",this.hoverinfo="all",this.connectgaps=!0,this.idToIndex=[],this.bounds=[0,0,0,0],this.hasLines=!1,this.lineOptions={positions:new Float32Array,color:[0,0,0,1],width:1,fill:[!1,!1,!1,!1],fillColor:[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],dashes:[1]},this.line=d(t.glplot,this.lineOptions),this.line._trace=this,this.hasErrorX=!1,this.errorXOptions={positions:new Float32Array,errors:new Float32Array,lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorX=p(t.glplot,this.errorXOptions),this.errorX._trace=this,this.hasErrorY=!1,this.errorYOptions={positions:new Float32Array,errors:new Float32Array,lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorY=p(t.glplot,this.errorYOptions),this.errorY._trace=this,this.hasMarkers=!1,this.scatterOptions={positions:new Float32Array,sizes:[],colors:[],glyphs:[],borderWidths:[],borderColors:[],size:12,color:[0,0,0,1],borderSize:1,borderColor:[0,0,0,1]},this.scatter=f(t.glplot,this.scatterOptions),this.scatter._trace=this,this.fancyScatter=h(t.glplot,this.scatterOptions),this.fancyScatter._trace=this}function i(t,e,r){return Array.isArray(e)||(e=[e]),a(t,e,r)}function a(t,e,r){for(var n=new Array(r),i=e[0],a=0;r>a;++a)n[a]=t(a>=e.length?i:e[a]);return n}function o(t,e,r){return l(S(t,r),L(e,r),r)}function s(t,e,r,n){var i=x(t,e,n);return i=Array.isArray(i[0])?i:a(v.identity,[i],n),l(i,L(r,n),n)}function l(t,e,r){for(var n=new Array(4*r),i=0;r>i;++i){for(var a=0;3>a;++a)n[4*i+a]=t[i][a];n[4*i+3]=t[i][3]*e[i]}return n}function c(t,e){if(void 0===Float32Array.slice){for(var r=new Float32Array(e),n=0;e>n;n++)r[n]=t[n];return r}return t.slice(0,e)}function u(t,e){var r=new n(t,e.uid);return r.update(e),r}var f=t("gl-scatter2d"),h=t("gl-scatter2d-fancy"),d=t("gl-line2d"),p=t("gl-error2d"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../plots/cartesian/axes"),y=t("../../components/errorbars"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/subtypes"),w=t("../scatter/make_bubble_size_func"),k=t("../scatter/get_trace_color"),A=t("../../constants/gl_markers"),M=t("../../constants/gl2d_dashes"),T=["xaxis","yaxis"],E=n.prototype;E.handlePick=function(t){var e=t.pointId;return(t.object!==this.line||this.connectgaps)&&(e=this.idToIndex[t.pointId]),{trace:this,dataCoord:t.dataCoord,traceCoord:[this.pickXData[e],this.pickYData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:Array.isArray(this.color)?this.color[e]:this.color,name:this.name,hoverinfo:this.hoverinfo}},E.isFancy=function(t){if("linear"!==this.scene.xaxis.type)return!0;if("linear"!==this.scene.yaxis.type)return!0;if(!t.x||!t.y)return!0;var e=t.marker||{};if(Array.isArray(e.symbol)||"circle"!==e.symbol||Array.isArray(e.size)||Array.isArray(e.line.width)||Array.isArray(e.opacity))return!0;var r=e.color;if(Array.isArray(r))return!0;var n=Array.isArray(e.line.color);return Array.isArray(n)?!0:this.hasErrorX?!0:!!this.hasErrorY};var L=i.bind(null,function(t){return+t}),S=i.bind(null,b),C=i.bind(null,function(t){return A[t]||"\u25cf"});E.update=function(t){t.visible!==!0?(this.hasLines=!1,this.hasErrorX=!1,this.hasErrorY=!1,this.hasMarkers=!1):(this.hasLines=_.hasLines(t),this.hasErrorX=t.error_x.visible===!0,this.hasErrorY=t.error_y.visible===!0,this.hasMarkers=_.hasMarkers(t)),this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.connectgaps=!!t.connectgaps,this.isFancy(t)?this.updateFancy(t):this.updateFast(t),this.color=k(t,{})},E.updateFast=function(t){for(var e,r,n=this.xData=this.pickXData=t.x,i=this.yData=this.pickYData=t.y,a=n.length,o=new Array(a),s=new Float32Array(2*a),l=this.bounds,u=0,f=0,h=0;a>h;++h)e=n[h],r=i[h],g(e)&&g(r)&&(o[u++]=h,s[f++]=e,s[f++]=r,l[0]=Math.min(l[0],e),l[1]=Math.min(l[1],r),l[2]=Math.max(l[2],e),l[3]=Math.max(l[3],r));s=c(s,f),this.idToIndex=o,this.updateLines(t,s),this.updateError("X",t),this.updateError("Y",t);var d;if(this.hasMarkers){this.scatterOptions.positions=s;var p=b(t.marker.color),v=b(t.marker.line.color),m=t.opacity*t.marker.opacity;p[3]*=m,this.scatterOptions.color=p,v[3]*=m,this.scatterOptions.borderColor=v,d=t.marker.size,this.scatterOptions.size=d,this.scatterOptions.borderSize=t.marker.line.width,this.scatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions),this.expandAxesFast(l,d)},E.updateFancy=function(t){var e=this.scene,r=e.xaxis,n=e.yaxis,a=this.bounds,o=this.pickXData=r.makeCalcdata(t,"x").slice(),l=this.pickYData=n.makeCalcdata(t,"y").slice();this.xData=o.slice(),this.yData=l.slice();var u,f,h,d,p,g,v,m,b=y.calcFromTrace(t,e.fullLayout),x=o.length,_=new Array(x),k=new Float32Array(2*x),A=new Float32Array(4*x),M=new Float32Array(4*x),T=0,E=0,S=0,z=0,P="log"===r.type?function(t){return r.d2l(t)}:function(t){return t},R="log"===n.type?function(t){return n.d2l(t)}:function(t){return t};for(u=0;x>u;++u)this.xData[u]=h=P(o[u]),this.yData[u]=d=R(l[u]),isNaN(h)||isNaN(d)||(_[T++]=u,k[E++]=h,k[E++]=d,p=A[S++]=h-b[u].xs||0,g=A[S++]=b[u].xh-h||0,A[S++]=0,A[S++]=0,M[z++]=0,M[z++]=0,v=M[z++]=d-b[u].ys||0,m=M[z++]=b[u].yh-d||0,a[0]=Math.min(a[0],h-p),a[1]=Math.min(a[1],d-v),a[2]=Math.max(a[2],h+g),a[3]=Math.max(a[3],d+m));k=c(k,E),this.idToIndex=_,this.updateLines(t,k),this.updateError("X",t,k,A),this.updateError("Y",t,k,M);var O;if(this.hasMarkers){this.scatterOptions.positions=k,this.scatterOptions.sizes=new Array(T),this.scatterOptions.glyphs=new Array(T),this.scatterOptions.borderWidths=new Array(T),this.scatterOptions.colors=new Array(4*T),this.scatterOptions.borderColors=new Array(4*T);var I,N=w(t),j=t.marker,F=j.opacity,D=t.opacity,B=s(j,F,D,x),U=C(j.symbol,x),V=L(j.line.width,x),q=s(j.line,F,D,x);for(O=i(N,j.size,x),u=0;T>u;++u)for(I=_[u],this.scatterOptions.sizes[u]=4*O[I],this.scatterOptions.glyphs[u]=U[I],this.scatterOptions.borderWidths[u]=.5*V[I],f=0;4>f;++f)this.scatterOptions.colors[4*u+f]=B[4*I+f],this.scatterOptions.borderColors[4*u+f]=q[4*I+f];this.fancyScatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions),this.expandAxesFancy(o,l,O)},E.updateLines=function(t,e){var r;if(this.hasLines){var n=e;if(!t.connectgaps){var i=0,a=this.xData,o=this.yData;for(n=new Float32Array(2*a.length),r=0;ro;o++)r=this.scene[T[o]],n=r._min,n||(n=[]),n.push({val:t[o],pad:a}),i=r._max,i||(i=[]),i.push({val:t[o+2],pad:a})},E.expandAxesFancy=function(t,e,r){var n=this.scene,i={padded:!0,ppad:r};m.expand(n.xaxis,t,i),m.expand(n.yaxis,e,i)},E.dispose=function(){this.line.dispose(),this.errorX.dispose(),this.errorY.dispose(),this.scatter.dispose(),this.fancyScatter.dispose()},e.exports=u},{"../../components/errorbars":331,"../../constants/gl2d_dashes":366,"../../constants/gl_markers":368,"../../lib":381,"../../lib/gl_format_color":379,"../../lib/str2rgbarray":392,"../../plots/cartesian/axes":403,"../scatter/get_trace_color":561,"../scatter/make_bubble_size_func":567,"../scatter/subtypes":573,"fast-isnumeric":76,"gl-error2d":78,"gl-line2d":84,"gl-scatter2d":149,"gl-scatter2d-fancy":144}],589:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/xy_defaults"),s=t("../scatter/marker_defaults"),l=t("../scatter/line_defaults"),c=t("../scatter/fillcolor_defaults"),u=t("../../components/errorbars/defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p=o(t,e,d);return p?(d("text"),d("mode",pr;r++)y=e.a[r],b=e.b[r],x=e.c[r],n(y)&&n(b)&&n(x)?(y=+y,b=+b,x=+x,_=v/(y+b+x),1!==_&&(y*=_,b*=_,x*=_),k=y,w=x-b,M[r]={x:w,y:k,a:y,b:b,c:x}):M[r]={x:!1,y:!1};var T,E;if(o.hasMarkers(e)&&(T=e.marker,E=T.size,Array.isArray(E))){var L={type:"linear"};i.setConvert(L),E=L.makeCalcdata(e.marker,"size"),E.length>A&&E.splice(A,E.length-A)}return s(e),void 0!==typeof E&&a.mergeArray(E,M,"ms"),M}},{"../../lib":381,"../../plots/cartesian/axes":403,"../scatter/marker_colorscale_calc":568,"../scatter/subtypes":573,"fast-isnumeric":76}],593:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/marker_defaults"),s=t("../scatter/line_defaults"),l=t("../scatter/line_shape_defaults"),c=t("../scatter/text_defaults"),u=t("../scatter/fillcolor_defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p,g=d("a"),v=d("b"),m=d("c");if(g?(p=g.length,v?(p=Math.min(p,v.length),m&&(p=Math.min(p,m.length))):p=m?Math.min(p,m.length):0):v&&m&&(p=Math.min(v.length,m.length)),!p)return void(e.visible=!1);g&&p"),s}}},{"../../plots/cartesian/axes":403,"../scatter/hover":562}],595:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../plots/ternary":459,"../scatter/colorbar":557,"./attributes":591,"./calc":592,"./defaults":593,"./hover":594,"./plot":596,"./select":597,"./style":598}],596:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e){for(var r={x:function(){return t.xaxis},y:function(){return t.yaxis},plot:t.plotContainer},i=new Array(e.length),a=t.graphDiv.calcdata,o=0;oe){for(var r=g/e,n=[0|Math.floor(t[0].shape[0]*r+1),0|Math.floor(t[0].shape[1]*r+1)],i=n[0]*n[1],o=0;or;++r)this.showContour[r]&&(e=!0,t[r]=this.scene.contourLevels[r]);e&&this.surface.update({levels:t})},v.update=function(t){var e,r=this.scene,n=r.fullSceneLayout,a=this.surface,s=t.opacity,l=i(t.colorscale,s),u=t.z,h=t.x,d=t.y,g=n.xaxis,v=n.yaxis,m=n.zaxis,y=r.dataScale,b=u[0].length,x=u.length,_=[c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x])],w=_[0],k=_[1],A=r.contourLevels;this.data=t,f(_[2],function(t,e){return m.d2l(u[e][t])*y[2]}),Array.isArray(h[0])?f(w,function(t,e){return g.d2l(h[e][t])*y[0]}):f(w,function(t){return g.d2l(h[t])*y[0]}),Array.isArray(d[0])?f(k,function(t,e){return v.d2l(d[e][t])*y[1]}):f(k,function(t,e){return v.d2l(d[e])*y[1]});var M={colormap:l,levels:[[],[],[]],showContour:[!0,!0,!0],showSurface:!t.hidesurface,contourProject:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],contourWidth:[1,1,1],contourColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],contourTint:[1,1,1],dynamicColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],dynamicWidth:[1,1,1],dynamicTint:[1,1,1],opacity:1};if(M.intensityBounds=[t.cmin,t.cmax],t.surfacecolor){var T=c(new Float32Array(b*x),[b,x]);f(T,function(e,r){return t.surfacecolor[r][e]}),_.push(T)}else M.intensityBounds[0]*=y[2],M.intensityBounds[1]*=y[2];this.dataScale=o(_),t.surfacecolor&&(M.intensity=_.pop()),"opacity"in t&&t.opacity<1&&(M.opacity=.25*t.opacity);var E=[!0,!0,!0],L=["x","y","z"];for(e=0;3>e;++e){var S=t.contours[L[e]];E[e]=S.highlight,M.showContour[e]=S.show||S.highlight,M.showContour[e]&&(M.contourProject[e]=[S.project.x,S.project.y,S.project.z],S.show?(this.showContour[e]=!0,M.levels[e]=A[e],a.highlightColor[e]=M.contourColor[e]=p(S.color),S.usecolormap?a.highlightTint[e]=M.contourTint[e]=0:a.highlightTint[e]=M.contourTint[e]=1,M.contourWidth[e]=S.width):this.showContour[e]=!1,S.highlight&&(M.dynamicColor[e]=p(S.highlightcolor),M.dynamicWidth[e]=S.highlightwidth))}M.coords=_,a.update(M),a.visible=t.visible,a.enableDynamic=E,a.snapToData=!0,"lighting"in t&&(a.ambientLight=t.lighting.ambient,a.diffuseLight=t.lighting.diffuse,a.specularLight=t.lighting.specular,a.roughness=t.lighting.roughness,a.fresnel=t.lighting.fresnel),s&&1>s&&(a.supportsTransparency=!0)},v.dispose=function(){this.scene.glplot.remove(this.surface),this.surface.dispose()},e.exports=s},{"../../lib/str2rgbarray":392,"gl-surface3d":180,ndarray:212,"ndarray-fill":205,"ndarray-homography":210,"ndarray-ops":211,tinycolor2:233}],603:[function(t,e,r){"use strict";function n(t,e,r){e in t&&!(r in t)&&(t[r]=t[e])}var i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}var c,u,f=l("z");if(!f)return void(e.visible=!1);var h=f[0].length,d=f.length;if(l("x"),l("y"),!Array.isArray(e.x))for(e.x=[],c=0;h>c;++c)e.x[c]=c;if(l("text"),!Array.isArray(e.y))for(e.y=[],c=0;d>c;++c)e.y[c]=c;l("lighting.ambient"),l("lighting.diffuse"),l("lighting.specular"),l("lighting.roughness"),l("lighting.fresnel"),l("hidesurface"),l("opacity");var p=l("surfacecolor");l("colorscale");var g=["x","y","z"];for(c=0;3>c;++c){var v="contours."+g[c],m=l(v+".show"),y=l(v+".highlight");if(m||y)for(u=0;3>u;++u)l(v+".project."+g[u]);m&&(l(v+".color"),l(v+".width"),l(v+".usecolormap")),y&&(l(v+".highlightcolor"),l(v+".highlightwidth"))}p||(n(t,"zmin","cmin"),n(t,"zmax","cmax"),n(t,"zauto","cauto")),a(t,e,s,l,{prefix:"",cLetter:"c"})}},{"../../components/colorscale/defaults":312,"../../lib":381,"./attributes":599}],604:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("./colorbar"),n.calc=t("./calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="surface",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","noOpacity"],n.meta={},e.exports=n},{"../../plots/gl3d":439,"./attributes":599,"./calc":600,"./colorbar":601,"./convert":602,"./defaults":603}]},{},[12])(12)}); \ No newline at end of file +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Plotly=t()}}(function(){var t;return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,function(e){var r=t[o][1][e];return i(r?r:e)},u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oh;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){return n.setMode(t),n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s=1/t.clientHeight,l=s*(r-d),u=s*(a-p),f=h.flipX?1:-1,g=h.flipY?1:-1,v=Math.PI*h.rotateSpeed,m=i();if(1&e)o.shift?n.rotate(m,0,0,-l*v):n.rotate(m,f*v*l,-g*v*u,0);else if(2&e)n.pan(m,-h.translateSpeed*l*c,h.translateSpeed*u*c,0);else if(4&e){var y=h.zoomSpeed*u/window.innerHeight*(m-n.lastT())*50;n.pan(m,0,0,c*(Math.exp(y)-1))}d=r,p=a}),s(t,function(t,e,r){var a=h.flipX?1:-1,o=h.flipY?1:-1,s=i();if(Math.abs(t)>Math.abs(e))n.rotate(s,0,0,-t*a*Math.PI*h.rotateSpeed/window.innerWidth);else{var l=h.zoomSpeed*o*e/window.innerHeight*(s-n.lastT())/100;n.pan(s,0,0,c*(Math.exp(l)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":21,"mouse-change":211,"mouse-wheel":213,"right-now":247}],21:[function(t,e,r){"use strict";function n(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map(function(e){return t[e]}),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.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}function i(t){t=t||{};var e=t.eye||[0,0,1],r=t.center||[0,0,0],i=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],c=t.mode||"turntable",u=a(),f=o(),h=s();return u.setDistanceLimits(l[0],l[1]),u.lookAt(0,e,r,i),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,i),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,i),new n({turntable:u,orbit:f,matrix:h},c)}e.exports=i;var a=t("turntable-camera-controller"),o=t("orbit-camera-controller"),s=t("matrix-camera-controller"),l=n.prototype,c=[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]];c.forEach(function(t){for(var e=t[0],r=[],n=0;ne)){var r=this._active,n=this._controllerList[e],i=Math.max(r.lastT(),n.lastT());r.recalcMatrix(i),n.setMatrix(i,r.computedMatrix),this._active=n,this._mode=t,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}}},l.getMode=function(){return this._mode}},{"matrix-camera-controller":209,"orbit-camera-controller":229,"turntable-camera-controller":279}],22:[function(t,e,r){"use strict";function n(t){var e=s.get(t);if(!e||!t.isBuffer(e._triangleBuffer.buffer)){var r=a(t,new Float32Array([-1,-1,-1,4,4,-1]));e=o(t,[{buffer:r,type:t.FLOAT,size:2}]),e._triangleBuffer=r,s.set(t,e)}e.bind(),t.drawArrays(t.TRIANGLES,0,3),e.unbind()}var i="undefined"==typeof WeakMap?t("weak-map"):WeakMap,a=t("gl-buffer"),o=t("gl-vao"),s=new i;e.exports=n},{"gl-buffer":107,"gl-vao":182,"weak-map":287}],23:[function(t,e,r){function n(t,e,r){e="number"==typeof e?e:1,r=r||": ";var n=t.split(/\r?\n/),a=String(n.length+e-1).length;return n.map(function(t,n){var o=n+e,s=String(o).length,l=i(o,a-s);return l+r+t}).join("\n")}var i=t("pad-left");e.exports=n},{"pad-left":230}],24:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(e+1),n=0;n=i;++i){for(var o=new Array(e),s=0;e>s;++s)o[s]=Math.pow(i+1-n,s);r[i]=o}var l=a.apply(void 0,r);if(l)return!0}return!1}function i(t){var e=t.length;if(0===e)return[];if(1===e)return[0];for(var r=t[0].length,i=[t[0]],a=[0],o=1;e>o;++o)if(i.push(t[o]),n(i,r)){if(a.push(o),a.length===r+1)return a}else i.pop();return a}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":253}],25:[function(t,e,r){"use strict";function n(t,e){return i(e).filter(function(r){for(var n=new Array(r.length),i=0;ia;a++)i.push(t+a*n);return i}function r(){for(var t=[].slice.call(arguments),e=t.map(function(t){return t.length}),r=Math.min.apply(null,e),n=[],i=0;r>i;i++){n[i]=[];for(var a=0;aa;a++)i.push([t[a],e[a],r[a]]);return i}function i(t){function e(t){for(var n=0;n>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3])),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}function c(t,e){var r,n;if("string"!=typeof t)return t;if(r=[],"#"===t[0]?(t=t.substr(1),3===t.length&&(t+=t),n=parseInt(t,16),r[0]=n>>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3]),n[4]?r[3]=parseFloat(n[4]):r[3]=1),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}var u={},f=/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,.*)?\)$/,h=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,?\s*(.*)?\)$/;return u.isPlainObject=t,u.linspace=e,u.zip3=n,u.sum=i,u.zip=r,u.isEqual=s,u.copy2D=a,u.copy1D=o,u.str2RgbArray=l,u.str2RgbaArray=c,u};e.exports=n()},{}],28:[function(t,e,r){e.exports=function(t){return atob(t)}},{}],29:[function(t,e,r){"use strict";function n(t){for(var e=0,r=0;ro;++o){for(var s=new Array(r+1),l=0;r>=l;++l)s[l]=t[l][o];i[o]=s}i[r]=new Array(r+1);for(var o=0;r>=o;++o)i[r][o]=1;for(var c=new Array(r+1),o=0;r>o;++o)c[o]=e[o];c[r]=1;var u=a(i,c),f=n(u[r+1]);0===f&&(f=1);for(var h=new Array(r+1),o=0;r>=o;++o)h[o]=n(u[o])/f;return h}e.exports=i;var a=t("robust-linear-solve")},{"robust-linear-solve":252}],30:[function(t,e,r){"use strict";function n(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;r>e;++e)l[e]=t[e],c[t.charCodeAt(e)]=e;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63}function i(t){var e,r,n,i,a,o,s=t.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===t[s-2]?2:"="===t[s-1]?1:0,o=new u(3*s/4-a),n=a>0?s-4:s;var l=0;for(e=0,r=0;n>e;e+=4,r+=3)i=c[t.charCodeAt(e)]<<18|c[t.charCodeAt(e+1)]<<12|c[t.charCodeAt(e+2)]<<6|c[t.charCodeAt(e+3)],o[l++]=i>>16&255,o[l++]=i>>8&255,o[l++]=255&i;return 2===a?(i=c[t.charCodeAt(e)]<<2|c[t.charCodeAt(e+1)]>>4,o[l++]=255&i):1===a&&(i=c[t.charCodeAt(e)]<<10|c[t.charCodeAt(e+1)]<<4|c[t.charCodeAt(e+2)]>>2,o[l++]=i>>8&255,o[l++]=255&i),o}function a(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function o(t,e,r){for(var n,i=[],o=e;r>o;o+=3)n=(t[o]<<16)+(t[o+1]<<8)+t[o+2],i.push(a(n));return i.join("")}function s(t){for(var e,r=t.length,n=r%3,i="",a=[],s=16383,c=0,u=r-n;u>c;c+=s)a.push(o(t,c,c+s>u?u:c+s));return 1===n?(e=t[r-1],i+=l[e>>2],i+=l[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=l[e>>10],i+=l[e>>4&63],i+=l[e<<2&63],i+="="),a.push(i),a.join("")}r.toByteArray=i,r.fromByteArray=s;var l=[],c=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],31:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]).add(e[0].mul(t[1])),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":41}],32:[function(t,e,r){"use strict";function n(t,e){return t[0].mul(e[1]).cmp(e[0].mul(t[1]))}e.exports=n},{}],33:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]),t[1].mul(e[0]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":41}],34:[function(t,e,r){"use strict";function n(t,e){if(i(t))return e?c(t,n(e)):[t[0].clone(),t[1].clone()];var r,u,f=0;if(a(t))r=t.clone();else if("string"==typeof t)r=s(t);else{if(0===t)return[o(0),o(1)];if(t===Math.floor(t))r=o(t);else{for(;t!==Math.floor(t);)t*=Math.pow(2,256),f-=256;r=o(t)}}if(i(e))r.mul(e[1]),u=e[0].clone();else if(a(e))u=e.clone();else if("string"==typeof e)u=s(e);else if(e)if(e===Math.floor(e))u=o(e);else{for(;e!==Math.floor(e);)e*=Math.pow(2,256),f+=256;u=o(e)}else u=o(1);return f>0?r=r.shln(f):0>f&&(u=u.shln(-f)),l(r,u)}var i=t("./is-rat"),a=t("./lib/is-bn"),o=t("./lib/num-to-bn"),s=t("./lib/str-to-bn"),l=t("./lib/rationalize"),c=t("./div");e.exports=n},{"./div":33,"./is-rat":35,"./lib/is-bn":39,"./lib/num-to-bn":40,"./lib/rationalize":41,"./lib/str-to-bn":42}],35:[function(t,e,r){"use strict";function n(t){return Array.isArray(t)&&2===t.length&&i(t[0])&&i(t[1])}var i=t("./lib/is-bn");e.exports=n},{"./lib/is-bn":39}],36:[function(t,e,r){"use strict";function n(t){return t.cmp(new i(0))}var i=t("bn.js");e.exports=n},{"bn.js":49}],37:[function(t,e,r){"use strict";function n(t){var e=t.length,r=t.words,n=0;if(1===e)n=r[0];else if(2===e)n=r[0]+67108864*r[1];else for(var n=0,i=0;e>i;i++){var a=r[i];n+=a*Math.pow(67108864,i)}return t.sign?-n:n}e.exports=n},{}],38:[function(t,e,r){"use strict";function n(t){var e=a(i.lo(t));if(32>e)return e;var r=a(i.hi(t));return r>20?52:r+32}var i=t("double-bits"),a=t("bit-twiddle").countTrailingZeros;e.exports=n},{"bit-twiddle":48,"double-bits":89}],39:[function(t,e,r){"use strict";function n(t){return t&&"object"==typeof t&&Boolean(t.words)}t("bn.js");e.exports=n},{"bn.js":49}],40:[function(t,e,r){"use strict";function n(t){var e=a.exponent(t);return 52>e?new i(t):new i(t*Math.pow(2,52-e)).shln(e-52)}var i=t("bn.js"),a=t("double-bits");e.exports=n},{"bn.js":49,"double-bits":89}],41:[function(t,e,r){"use strict";function n(t,e){var r=a(t),n=a(e);if(0===r)return[i(0),i(1)];if(0===n)return[i(0),i(0)];0>n&&(t=t.neg(),e=e.neg());var o=t.gcd(e);return o.cmpn(1)?[t.div(o),e.div(o)]:[t,e]}var i=t("./num-to-bn"),a=t("./bn-sign");e.exports=n},{"./bn-sign":36,"./num-to-bn":40}],42:[function(t,e,r){"use strict";function n(t){return new i(t)}var i=t("bn.js");e.exports=n},{"bn.js":49}],43:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[0]),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":41}],44:[function(t,e,r){"use strict";function n(t){return i(t[0])*i(t[1])}var i=t("./lib/bn-sign");e.exports=n},{"./lib/bn-sign":36}],45:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":41}],46:[function(t,e,r){"use strict";function n(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var n=e.divmod(r),o=n.div,s=i(o),l=n.mod;if(0===l.cmpn(0))return s;if(s){var c=a(s)+4,u=i(l.shln(c).divRound(r));return 0>s&&(u=-u),s+u*Math.pow(2,-c)}var f=r.bitLength()-l.bitLength()+53,u=i(l.shln(f).divRound(r));return 1023>f?u*Math.pow(2,-f):(u*=Math.pow(2,-1023),u*Math.pow(2,1023-f))}var i=t("./lib/bn-to-num"),a=t("./lib/ctz");e.exports=n},{"./lib/bn-to-num":37,"./lib/ctz":38}],47:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],48:[function(t,e,r){"use strict";"use restrict";function n(t){var e=32;return t&=-t,t&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}var i=32;r.INT_BITS=i,r.INT_MAX=2147483647,r.INT_MIN=-1<0)-(0>t)},r.abs=function(t){var e=t>>i-1;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(e>t)},r.max=function(t,e){return t^(t^e)&-(e>t)},r.isPow2=function(t){return!(t&t-1||!t)},r.log2=function(t){var e,r;return e=(t>65535)<<4,t>>>=e,r=(t>255)<<3,t>>>=r,e|=r,r=(t>15)<<2,t>>>=r,e|=r,r=(t>3)<<1,t>>>=r,e|=r,e|t>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return t-=t>>>1&1431655765,t=(858993459&t)+(t>>>2&858993459),16843009*(t+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,t&=15,27030>>>t&1};var a=new Array(256);!function(t){for(var e=0;256>e;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|a[t>>>16&255]<<8|a[t>>>24&255]},r.interleave2=function(t,e){return t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},r.deinterleave2=function(t,e){return t=t>>>e&1431655765,t=858993459&(t|t>>>1),t=252645135&(t|t>>>2),t=16711935&(t|t>>>4),t=65535&(t|t>>>16),t<<16>>16},r.interleave3=function(t,e,r){return t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t|=e<<1,r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),t|r<<2},r.deinterleave3=function(t,e){return t=t>>>e&1227133513,t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),t=1023&(t|t>>>16),t<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],49:[function(t,e,r){!function(t,e){"use strict";function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){return null!==t&&"object"==typeof t&&Array.isArray(t.words)?t:(this.sign=!1,this.words=null,this.length=0,this.red=null,"le"!==e&&"be"!==e||(r=e, +e=10),void(null!==t&&this._init(t||0,e||10,r||"be")))}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),a=e;i>a;a++){var o=t.charCodeAt(a)-48;n<<=4,n|=o>=49&&54>=o?o-49+10:o>=17&&22>=o?o-17+10:15&o}return n}function o(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;a>o;o++){var s=t.charCodeAt(o)-48;i*=n,i+=s>=49?s-49+10:s>=17?s-17+10:s}return i}function s(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).ishln(this.n).isub(this.p),this.tmp=this._tmp()}function l(){s.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function c(){s.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function u(){s.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function f(){s.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function h(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function d(t){h.call(this,t),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).ishln(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.sign=!0,this.minv=this.minv.mod(this.r)}"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26,i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&36>=e),t=t.toString().replace(/\s+/g,"");var i=0;"-"===t[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.sign=!0),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initNumber=function(t,e,n){0>t&&(this.sign=!0,t=-t),67108864>t?(this.words=[67108863&t],this.length=1):4503599627370496>t?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(9007199254740992>t),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3){var s=t[i]|t[i-1]<<8|t[i-2]<<16;this.words[o]|=s<>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}else if("le"===n)for(var i=0,o=0;i>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}return this.strip()},i.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6){var o=a(t,r,r+6);this.words[i]|=o<>>26-n&4194303,n+=24,n>=26&&(n-=26,i++)}if(r+6!==e){var o=a(t,e,r+6);this.words[i]|=o<>>26-n&4194303}this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;67108863>=i;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,s=a%n,l=Math.min(a,a-s)+r,c=0,u=r;l>u;u+=n)c=o(t,u,u+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){for(var f=1,c=o(t,u,t.length,e),u=0;s>u;u++)f*=e;this.imuln(f),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},i.prototype.inspect=function(){return(this.red?""};var p=["","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"],g=[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],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(t,e){if(t=t||10,16===t||"hex"===t){for(var n="",i=0,e=0|e||1,a=0,o=0;o>>24-i&16777215,n=0!==a||o!==this.length-1?p[6-l.length]+l+n:l+n,i+=2,i>=26&&(i-=26,o--)}for(0!==a&&(n=a.toString(16)+n);n.length%e!==0;)n="0"+n;return this.sign&&(n="-"+n),n}if(t===(0|t)&&t>=2&&36>=t){var c=g[t],u=v[t],n="",f=this.clone();for(f.sign=!1;0!==f.cmpn(0);){var h=f.modn(u).toString(t);f=f.idivn(u),n=0!==f.cmpn(0)?p[c-h.length]+h+n:h+n}return 0===this.cmpn(0)&&(n="0"+n),this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(t){this.strip();var e=new Array(this.byteLength());e[0]=0;var r=this.clone();if("le"!==t)for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[e.length-n-1]=i}else for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[n]=i}return e},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0===(8191&e)&&(r+=13,e>>>=13),0===(127&e)&&(r+=7,e>>>=7),0===(15&e)&&(r+=4,e>>>=4),0===(3&e)&&(r+=2,e>>>=2),0===(1&e)&&r++,r},i.prototype.bitLength=function(){var t=0,e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.iand=function(t){this.sign=this.sign&&t.sign;var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.ixor=function(t){this.sign=this.sign||t.sign;var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);for(var n=t/26|0,i=t%26;this.length<=n;)this.words[this.length++]=0;return e?this.words[n]=this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26}for(;0!==i&&a>>26}if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(t.sign){t.sign=!1;var e=this.iadd(t);return t.sign=!0,e._normSign()}if(this.sign)return this.sign=!1,this.iadd(t),this.sign=!0,this._normSign();var r=this.cmp(t);if(0===r)return this.sign=!1,this.length=1,this.words[0]=0,this;var n,i;r>0?(n=this,i=t):(n=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e}for(;0!==a&&o>26,this.words[o]=67108863&e}if(0===a&&o>>26,a=67108863&r,o=Math.min(n,t.length-1),s=Math.max(0,n-this.length+1);o>=s;s++){var l=n-s,c=0|this.words[l],u=0|t.words[s],f=c*u,h=67108863&f;i=i+(f/67108864|0)|0,h=h+a|0,a=67108863&h,i=i+(h>>>26)|0}e.words[n]=a,r=i}return 0!==r?e.words[n]=r:e.length--,e.strip()},i.prototype._bigMulTo=function(t,e){e.sign=t.sign!==this.sign,e.length=this.length+t.length;for(var r=0,n=0,i=0;i=l;l++){var c=i-l,u=0|this.words[c],f=0|t.words[l],h=u*f,d=67108863&h;a=a+(h/67108864|0)|0,d=d+o|0,o=67108863&d,a=a+(d>>>26)|0,n+=a>>>26,a&=67108863}e.words[i]=o,r=a,a=n}return 0!==r?e.words[i]=r:e.length--,e.strip()},i.prototype.mulTo=function(t,e){var r;return r=this.length+t.length<63?this._smallMulTo(t,e):this._bigMulTo(t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.imul=function(t){if(0===this.cmpn(0)||0===t.cmpn(0))return this.words[0]=0,this.length=1,this;var e=this.length,r=t.length;this.sign=t.sign!==this.sign,this.length=this.length+t.length,this.words[this.length-1]=0;for(var n=this.length-2;n>=0;n--){for(var i=0,a=0,o=Math.min(n,r-1),s=Math.max(0,n-e+1);o>=s;s++){var l=n-s,c=this.words[l],u=t.words[s],f=c*u,h=67108863&f;i+=f/67108864|0,h+=a,a=67108863&h,i+=h>>>26}this.words[n]=a,this.words[n+1]+=i,i=0}for(var i=0,l=1;l>>26}return this.strip()},i.prototype.imuln=function(t){r("number"==typeof t);for(var e=0,n=0;n>=26,e+=i/67108864|0,e+=a>>>26,this.words[n]=67108863&a}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.ishln=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=67108863>>>26-e<<26-e;if(0!==e){for(var a=0,o=0;o>>26-e}a&&(this.words[o]=a,this.length++)}if(0!==n){for(var o=this.length-1;o>=0;o--)this.words[o+n]=this.words[o];for(var o=0;n>o;o++)this.words[o]=0;this.length+=n}return this.strip()},i.prototype.ishrn=function(t,e,n){r("number"==typeof t&&t>=0);var i;i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<c;c++)l.words[c]=this.words[c];l.length=o}if(0===o);else if(this.length>o){this.length-=o;for(var c=0;c=0&&(0!==u||c>=i);c--){var f=this.words[c];this.words[c]=u<<26-a|f>>>a,u=f&s}return l&&0!==u&&(l.words[l.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<t?this.isubn(-t):this.sign?1===this.length&&this.words[0]=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),0>t)return this.iaddn(-t);if(this.sign)return this.sign=!1,this.iaddn(t),this.sign=!0,this;this.words[0]-=t;for(var e=0;e>26)-(c/67108864|0),this.words[i+n]=67108863&l}for(;i>26,this.words[i+n]=67108863&l}if(0===s)return this.strip();r(-1===s),s=0;for(var i=0;i>26,this.words[i]=67108863&l}return this.sign=!0,this.strip()},i.prototype._wordDiv=function(t,e){var r=this.length-t.length,n=this.clone(),a=t,o=a.words[a.length-1],s=this._countBits(o);r=26-s,0!==r&&(a=a.shln(r),n.ishln(r),o=a.words[a.length-1]);var l,c=n.length-a.length;if("mod"!==e){l=new i(null),l.length=c+1,l.words=new Array(l.length);for(var u=0;u=0;h--){var d=67108864*n.words[a.length+h]+n.words[a.length+h-1];for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(a,d,h);n.sign;)d--,n.sign=!1,n._ishlnsubmul(a,1,h),0!==n.cmpn(0)&&(n.sign=!n.sign);l&&(l.words[h]=d)}return l&&l.strip(),n.strip(),"div"!==e&&0!==r&&n.ishrn(r),{div:l?l:null,mod:n}},i.prototype.divmod=function(t,e){if(r(0!==t.cmpn(0)),this.sign&&!t.sign){var n,a,o=this.neg().divmod(t,e);return"mod"!==e&&(n=o.div.neg()),"div"!==e&&(a=0===o.mod.cmpn(0)?o.mod:t.sub(o.mod)),{div:n,mod:a}}if(!this.sign&&t.sign){var n,o=this.divmod(t.neg(),e);return"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}}return this.sign&&t.sign?this.neg().divmod(t.neg(),e):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e)},i.prototype.div=function(t){return this.divmod(t,"div").div},i.prototype.mod=function(t){return this.divmod(t,"mod").mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(0===e.mod.cmpn(0))return e.div;var r=e.div.sign?e.mod.isub(t):e.mod,n=t.shrn(1),i=t.andln(1),a=r.cmp(n);return 0>a||1===i&&0===a?e.div:e.div.sign?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(67108863>=t);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+this.words[i])%t;return n},i.prototype.idivn=function(t){r(67108863>=t);for(var e=0,n=this.length-1;n>=0;n--){var i=this.words[n]+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=new i(0),l=new i(1),c=0;e.isEven()&&n.isEven();)e.ishrn(1),n.ishrn(1),++c;for(var u=n.clone(),f=e.clone();0!==e.cmpn(0);){for(;e.isEven();)e.ishrn(1),a.isEven()&&o.isEven()?(a.ishrn(1),o.ishrn(1)):(a.iadd(u).ishrn(1),o.isub(f).ishrn(1));for(;n.isEven();)n.ishrn(1),s.isEven()&&l.isEven()?(s.ishrn(1),l.ishrn(1)):(s.iadd(u).ishrn(1),l.isub(f).ishrn(1));e.cmp(n)>=0?(e.isub(n),a.isub(s),o.isub(l)):(n.isub(e),s.isub(a),l.isub(o))}return{a:s,b:l,gcd:n.ishln(c)}},i.prototype._invmp=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(;e.isEven();)e.ishrn(1),a.isEven()?a.ishrn(1):a.iadd(s).ishrn(1);for(;n.isEven();)n.ishrn(1),o.isEven()?o.ishrn(1):o.iadd(s).ishrn(1);e.cmp(n)>=0?(e.isub(n),a.isub(o)):(n.isub(e),o.isub(a))}return 0===e.cmpn(1)?a:o},i.prototype.gcd=function(t){if(0===this.cmpn(0))return t.clone();if(0===t.cmpn(0))return this.clone();var e=this.clone(),r=t.clone();e.sign=!1,r.sign=!1;for(var n=0;e.isEven()&&r.isEven();n++)e.ishrn(1),r.ishrn(1);for(;;){for(;e.isEven();)e.ishrn(1);for(;r.isEven();)r.ishrn(1);var i=e.cmp(r);if(0>i){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.ishln(n)},i.prototype.invm=function(t){return this.egcd(t).a.mod(t)},i.prototype.isEven=function(){return 0===(1&this.words[0])},i.prototype.isOdd=function(){return 1===(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<a;a++)this.words[a]=0;return this.words[n]|=i,this.length=n+1,this}for(var o=i,a=n;0!==o&&a>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.cmpn=function(t){var e=0>t;if(e&&(t=-t),this.sign&&!e)return-1;if(!this.sign&&e)return 1;t&=67108863,this.strip();var r;if(this.length>1)r=1;else{var n=this.words[0];r=n===t?0:t>n?-1:1}return this.sign&&(r=-r),r},i.prototype.cmp=function(t){if(this.sign&&!t.sign)return-1;if(!this.sign&&t.sign)return 1;var e=this.ucmp(t);return this.sign?-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length=0;r--){var n=this.words[r],i=t.words[r];if(n!==i){i>n?e=-1:n>i&&(e=1);break}}return e},i.red=function(t){return new h(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};s.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},s.prototype.ireduce=function(t){var e,r=t;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),e=r.bitLength();while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},s.prototype.split=function(t,e){t.ishrn(this.n,0,e)},s.prototype.imulK=function(t){return t.imul(this.k)},n(l,s),l.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;n>i;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var a=t.words[9];e.words[e.length++]=a&r;for(var i=10;i>>22,a=o}t.words[i-10]=a>>>22,t.length-=9},l.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e,r=0,n=0;n>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function y(t){if(m[t])return m[t];var y;if("k256"===t)y=new l;else if("p224"===t)y=new c;else if("p192"===t)y=new u;else{if("p25519"!==t)throw new Error("Unknown prime "+t);y=new f}return m[t]=y,y},h.prototype._verify1=function(t){r(!t.sign,"red works only with positives"),r(t.red,"red works only with red numbers")},h.prototype._verify2=function(t,e){r(!t.sign&&!e.sign,"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},h.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.mod(this.m)._forceRed(this)},h.prototype.neg=function(t){var e=t.clone();return e.sign=!e.sign,e.iadd(this.m)._forceRed(this)},h.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},h.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},h.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},h.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},h.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.shln(e))},h.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},h.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},h.prototype.isqr=function(t){return this.imul(t,t)},h.prototype.sqr=function(t){return this.mul(t,t)},h.prototype.sqrt=function(t){if(0===t.cmpn(0))return t.clone();var e=this.m.andln(3);if(r(e%2===1),3===e){var n=this.m.add(new i(1)).ishrn(2),a=this.pow(t,n);return a}for(var o=this.m.subn(1),s=0;0!==o.cmpn(0)&&0===o.andln(1);)s++,o.ishrn(1);r(0!==o.cmpn(0));var l=new i(1).toRed(this),c=l.redNeg(),u=this.m.subn(1).ishrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,o),a=this.pow(t,o.addn(1).ishrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(l);){for(var g=d,v=0;0!==g.cmp(l);v++)g=g.redSqr();r(p>v);var m=this.pow(h,new i(1).ishln(p-v-1));a=a.redMul(m),h=m.redSqr(),d=d.redMul(h),p=v}return a},h.prototype.invm=function(t){var e=t._invmp(this.m);return e.sign?(e.sign=!1,this.imod(e).redNeg()):this.imod(e)},h.prototype.pow=function(t,e){var r=[];if(0===e.cmpn(0))return new i(1);for(var n=e.clone();0!==n.cmpn(0);)r.push(n.andln(1)),n.ishrn(1);for(var a=t,o=0;o=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},d.prototype.mul=function(t,e){if(0===t.cmpn(0)||0===e.cmpn(0))return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).ishrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},d.prototype.invm=function(t){var e=this.imod(t._invmp(this.m).mul(this.r2));return e._forceRed(this)}}("undefined"==typeof e||e,this)},{}],50:[function(t,e,r){"use strict";function n(t){var e,r,n,i=t.length,a=0;for(e=0;i>e;++e)a+=t[e].length;var o=new Array(a),s=0;for(e=0;i>e;++e){var l=t[e],c=l.length;for(r=0;c>r;++r){var u=o[s++]=new Array(c-1),f=0;for(n=0;c>n;++n)n!==r&&(u[f++]=l[n]);if(1&r){var h=u[1];u[1]=u[0],u[0]=h}}}return o}e.exports=n},{}],51:[function(t,e,r){"use strict";function n(t,e){for(var r=0;t>r;++r)if(!(e[r]<=e[r+t]))return!0;return!1}function i(t,e,r,i){for(var a=0,o=0,s=0,l=t.length;l>s;++s){var c=t[s];if(!n(e,c)){for(var u=0;2*e>u;++u)r[a++]=c[u];i[o++]=s}}return o}function a(t,e,r,n){var a=t.length,o=e.length;if(!(0>=a||0>=o)){var s=t[0].length>>>1;if(!(0>=s)){var l,c=f.mallocDouble(2*s*a),u=f.mallocInt32(a);if(a=i(t,s,c,u),a>0){if(1===s&&n)h.init(a),l=h.sweepComplete(s,r,0,a,c,u,0,a,c,u);else{var p=f.mallocDouble(2*s*o),g=f.mallocInt32(o);o=i(e,s,p,g),o>0&&(h.init(a+o),l=1===s?h.sweepBipartite(s,r,0,a,c,u,0,o,p,g):d(s,r,n,a,c,u,o,p,g),f.free(p),f.free(g))}f.free(c),f.free(u)}return l}}}function o(t,e){u.push([t,e])}function s(t){return u=[],a(t,t,o,!0),u}function l(t,e){return u=[],a(t,e,o,!1),u}function c(t,e,r){switch(arguments.length){case 1:return s(t);case 2:return"function"==typeof e?a(t,t,e,!0):l(t,e);case 3:return a(t,e,r,!1);default:throw new Error("box-intersect: Invalid arguments")}}e.exports=c;var u,f=t("typedarray-pool"),h=t("./lib/sweep"),d=t("./lib/intersect")},{"./lib/intersect":53,"./lib/sweep":57,"typedarray-pool":282}],52:[function(t,e,r){"use strict";function n(t,e,r){var n="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),i=["function ",n,"(",w.join(),"){","var ",c,"=2*",a,";"],l="for(var i="+u+","+p+"="+c+"*"+u+";i<"+f+";++i,"+p+"+="+c+"){var x0="+h+"["+o+"+"+p+"],x1="+h+"["+o+"+"+p+"+"+a+"],xi="+d+"[i];",k="for(var j="+g+","+b+"="+c+"*"+g+";j<"+v+";++j,"+b+"+="+c+"){var y0="+m+"["+o+"+"+b+"],"+(r?"y1="+m+"["+o+"+"+b+"+"+a+"],":"")+"yi="+y+"[j];";return t?i.push(l,_,":",k):i.push(k,_,":",l),r?i.push("if(y1"+v+"-"+g+"){"),t?(e(!0,!1),o.push("}else{"),e(!1,!1)):(o.push("if("+l+"){"),e(!0,!0),o.push("}else{"),e(!0,!1),o.push("}}else{if("+l+"){"),e(!1,!0),o.push("}else{"),e(!1,!1),o.push("}")),o.push("}}return "+r);var s=i.join("")+o.join(""),c=new Function(s);return c()}var a="d",o="ax",s="vv",l="fp",c="es",u="rs",f="re",h="rb",d="ri",p="rp",g="bs",v="be",m="bb",y="bi",b="bp",x="rv",_="Q",w=[a,o,s,u,f,h,d,g,v,m,y];r.partial=i(!1),r.full=i(!0)},{}],53:[function(t,e,r){"use strict";function n(t,e){var r=8*c.log2(e+1)*(t+1)|0,n=c.nextPow2(M*r);L.lengthS&&(l.free(S),S=l.mallocDouble(i))}function i(t,e,r,n,i,a,o,s,l){var c=M*t;L[c]=e,L[c+1]=r,L[c+2]=n,L[c+3]=i,L[c+4]=a,L[c+5]=o;var u=T*t;S[u]=s,S[u+1]=l}function a(t,e,r,n,i,a,o,s,l,c,u){var f=2*t,h=l*f,d=c[h+e];t:for(var p=i,g=i*f;a>p;++p,g+=f){var v=o[g+e],m=o[g+e+t];if(!(v>d||d>m||n&&d===v)){for(var y=s[p],b=e+1;t>b;++b){var v=o[g+b],m=o[g+b+t],x=c[h+b],_=c[h+b+t];if(x>m||v>_)continue t}var w;if(w=n?r(u,y):r(y,u),void 0!==w)return w}}}function o(t,e,r,n,i,a,o,s,l,c){var u=2*t,f=s*u,h=l[f+e];t:for(var d=n,p=n*u;i>d;++d,p+=u){var g=o[d];if(g!==c){var v=a[p+e],m=a[p+e+t];if(!(v>h||h>m)){for(var y=e+1;t>y;++y){var v=a[p+y],m=a[p+y+t],b=l[f+y],x=l[f+y+t];if(b>m||v>x)continue t}var _=r(g,c);if(void 0!==_)return _}}}}function s(t,e,r,s,l,c,u,g,E){n(t,s+u);var C,z=0,P=2*t;for(i(z++,0,0,s,0,u,r?16:0,-(1/0),1/0),r||i(z++,0,0,u,0,s,1,-(1/0),1/0);z>0;){z-=1;var R=z*M,O=L[R],I=L[R+1],N=L[R+2],j=L[R+3],F=L[R+4],B=L[R+5],D=z*T,U=S[D],V=S[D+1],q=1&B,H=!!(16&B),G=l,Y=c,X=g,W=E;if(q&&(G=g,Y=E,X=l,W=c),!(2&B&&(N=_(t,O,I,N,G,Y,V),I>=N)||4&B&&(I=w(t,O,I,N,G,Y,U),I>=N))){var Z=N-I,K=F-j;if(H){if(y>t*Z*(Z+K)){if(C=d.scanComplete(t,O,e,I,N,G,Y,j,F,X,W),void 0!==C)return C;continue}}else{if(t*Math.min(Z,K)t*Z*K){if(C=d.scanBipartite(t,O,e,q,I,N,G,Y,j,F,X,W),void 0!==C)return C;continue}}var Q=b(t,O,I,N,G,Y,U,V);if(Q>I)if(v>t*(Q-I)){if(C=h(t,O+1,e,I,Q,G,Y,j,F,X,W),void 0!==C)return C}else if(O===t-2){if(C=q?d.sweepBipartite(t,e,j,F,X,W,I,Q,G,Y):d.sweepBipartite(t,e,I,Q,G,Y,j,F,X,W),void 0!==C)return C}else i(z++,O+1,I,Q,j,F,q,-(1/0),1/0),i(z++,O+1,j,F,I,Q,1^q,-(1/0),1/0);if(N>Q){var $=p(t,O,j,F,X,W),J=X[P*$+O],tt=x(t,O,$,F,X,W,J);if(F>tt&&i(z++,O,Q,N,tt,F,(4|q)+(H?16:0),J,V),$>j&&i(z++,O,Q,N,j,$,(2|q)+(H?16:0),U,J),$+1===tt){if(C=H?o(t,O,e,Q,N,G,Y,$,X,W[$]):a(t,O,e,q,Q,N,G,Y,$,X,W[$]),void 0!==C)return C}else if(tt>$){var et;if(H){if(et=k(t,O,Q,N,G,Y,J),et>Q){var rt=x(t,O,Q,et,G,Y,J);if(O===t-2){if(rt>Q&&(C=d.sweepComplete(t,e,Q,rt,G,Y,$,tt,X,W),void 0!==C))return C;if(et>rt&&(C=d.sweepBipartite(t,e,rt,et,G,Y,$,tt,X,W),void 0!==C))return C}else rt>Q&&i(z++,O+1,Q,rt,$,tt,16,-(1/0),1/0),et>rt&&(i(z++,O+1,rt,et,$,tt,0,-(1/0),1/0),i(z++,O+1,$,tt,rt,et,1,-(1/0),1/0))}}else et=q?A(t,O,Q,N,G,Y,J):k(t,O,Q,N,G,Y,J),et>Q&&(O===t-2?C=q?d.sweepBipartite(t,e,$,tt,X,W,Q,et,G,Y):d.sweepBipartite(t,e,Q,et,G,Y,$,tt,X,W):(i(z++,O+1,Q,et,$,tt,q,-(1/0),1/0),i(z++,O+1,$,tt,Q,et,1^q,-(1/0),1/0)))}}}}}e.exports=s;var l=t("typedarray-pool"),c=t("bit-twiddle"),u=t("./brute"),f=u.partial,h=u.full,d=t("./sweep"),p=t("./median"),g=t("./partition"),v=128,m=1<<22,y=1<<22,b=g("!(lo>=p0)&&!(p1>=hi)",["p0","p1"]),x=g("lo===p0",["p0"]),_=g("lol;++l,s+=o)for(var c=i[s],u=l,f=o*(l-1);u>r&&i[f+e]>c;--u,f-=o){for(var h=f,d=f+o,p=0;o>p;++p,++h,++d){var g=i[h];i[h]=i[d],i[d]=g}var v=a[u];a[u]=a[u-1],a[u-1]=v}}function i(t,e,r,i,a,l){if(r+1>=i)return r;for(var c=r,u=i,f=i+r>>>1,h=2*t,d=f,p=a[h*f+e];u>c;){if(s>u-c){n(t,e,c,u,a,l),p=a[h*f+e];break}var g=u-c,v=Math.random()*g+c|0,m=a[h*v+e],y=Math.random()*g+c|0,b=a[h*y+e],x=Math.random()*g+c|0,_=a[h*x+e];b>=m?_>=b?(d=y,p=b):m>=_?(d=v,p=m):(d=x,p=_):b>=_?(d=y,p=b):_>=m?(d=v,p=m):(d=x,p=_);for(var w=h*(u-1),k=h*d,A=0;h>A;++A,++w,++k){var M=a[w];a[w]=a[k],a[k]=M}var T=l[u-1];l[u-1]=l[d],l[d]=T,d=o(t,e,c,u-1,a,l,p);for(var w=h*(u-1),k=h*d,A=0;h>A;++A,++w,++k){var M=a[w];a[w]=a[k],a[k]=M}var T=l[u-1];if(l[u-1]=l[d],l[d]=T,d>f){for(u=d-1;u>c&&a[h*(u-1)+e]===p;)u-=1;u+=1}else{if(!(f>d))break;for(c=d+1;u>c&&a[h*c+e]===p;)c+=1}}return o(t,e,r,f,a,l,a[h*f+e])}e.exports=i;var a=t("./partition"),o=a("lo=0&&n.push("lo=e[k+n]"),t.indexOf("hi")>=0&&n.push("hi=e[k+o]"),r.push(i.replace("_",n.join()).replace("$",t)),Function.apply(void 0,r)}e.exports=n;var i="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 _;if($)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"},{}],56:[function(t,e,r){"use strict";function n(t,e){4*h>=e?i(0,e-1,t):f(0,e-1,t)}function i(t,e,r){for(var n=2*(t+1),i=t+1;e>=i;++i){for(var a=r[n++],o=r[n++],s=i,l=n-2;s-- >t;){var c=r[l-2],u=r[l-1];if(a>c)break;if(c===a&&o>u)break;r[l]=c,r[l+1]=u,l-=2}r[l]=a,r[l+1]=o}}function a(t,e,r){t*=2,e*=2;var n=r[t],i=r[t+1];r[t]=r[e],r[t+1]=r[e+1],r[e]=n,r[e+1]=i}function o(t,e,r){t*=2,e*=2,r[t]=r[e],r[t+1]=r[e+1]}function s(t,e,r,n){t*=2,e*=2,r*=2;var i=n[t],a=n[t+1];n[t]=n[e],n[t+1]=n[e+1],n[e]=n[r],n[e+1]=n[r+1],n[r]=i,n[r+1]=a}function l(t,e,r,n,i){t*=2,e*=2,i[t]=i[e],i[e]=r,i[t+1]=i[e+1],i[e+1]=n}function c(t,e,r){t*=2,e*=2;var n=r[t],i=r[e];return i>n?!1:n===i?r[t+1]>r[e+1]:!0}function u(t,e,r,n){t*=2;var i=n[t];return e>i?!0:i===e?n[t+1]>1,v=g-n,m=g+n,y=d,b=v,x=g,_=m,w=p,k=t+1,A=e-1,M=0;c(y,b,r)&&(M=y,y=b,b=M),c(_,w,r)&&(M=_,_=w,w=M),c(y,x,r)&&(M=y,y=x,x=M),c(b,x,r)&&(M=b,b=x,x=M),c(y,_,r)&&(M=y,y=_,_=M),c(x,_,r)&&(M=x,x=_,_=M),c(b,w,r)&&(M=b,b=w,w=M),c(b,x,r)&&(M=b,b=x,x=M),c(_,w,r)&&(M=_,_=w,w=M);for(var T=r[2*b],E=r[2*b+1],L=r[2*_],S=r[2*_+1],C=2*y,z=2*x,P=2*w,R=2*d,O=2*g,I=2*p,N=0;2>N;++N){var j=r[C+N],F=r[z+N],B=r[P+N];r[R+N]=j,r[O+N]=F,r[I+N]=B}o(v,t,r),o(m,e,r);for(var D=k;A>=D;++D)if(u(D,T,E,r))D!==k&&a(D,k,r),++k;else if(!u(D,L,S,r))for(;;){if(u(A,L,S,r)){u(A,T,E,r)?(s(D,k,A,r),++k,--A):(a(D,A,r),--A);break}if(--A=k-2-t?i(t,k-2,r):f(t,k-2,r),h>=e-(A+2)?i(A+2,e,r):f(A+2,e,r),h>=A-k?i(k,A,r):f(k,A,r)}e.exports=n;var h=32},{}],57:[function(t,e,r){"use strict";function n(t){var e=f.nextPow2(t);g.lengthk;++k){var A=s[k],M=b*k;_[p++]=o[M+x],_[p++]=-(A+1),_[p++]=o[M+w],_[p++]=A}for(var k=l;c>k;++k){var A=f[k]+d,T=b*k;_[p++]=u[T+x],_[p++]=-A,_[p++]=u[T+w],_[p++]=A}var E=p>>>1;h(_,E);for(var L=0,S=0,k=0;E>k;++k){var C=0|_[2*k+1];if(C>=d)C=C-d|0,i(m,y,S--,C);else if(C>=0)i(g,v,L--,C);else if(-d>=C){C=-C-d|0;for(var z=0;L>z;++z){var P=e(g[z],C);if(void 0!==P)return P}a(m,y,S++,C)}else{C=-C-1|0;for(var z=0;S>z;++z){var P=e(C,m[z]);if(void 0!==P)return P}a(g,v,L++,C)}}}function s(t,e,r,n,o,s,l,c,u,f){for(var d=0,p=2*t,w=t-1,k=p-1,A=r;n>A;++A){var M=s[A]+1<<1,T=p*A;_[d++]=o[T+w],_[d++]=-M,_[d++]=o[T+k],_[d++]=M}for(var A=l;c>A;++A){var M=f[A]+1<<1,E=p*A;_[d++]=u[E+w],_[d++]=1|-M,_[d++]=u[E+k],_[d++]=1|M}var L=d>>>1;h(_,L);for(var S=0,C=0,z=0,A=0;L>A;++A){var P=0|_[2*A+1],R=1&P;if(L-1>A&&P>>1===_[2*A+3]>>1&&(R=2,A+=1),0>P){for(var O=-(P>>1)-1,I=0;z>I;++I){var N=e(b[I],O);if(void 0!==N)return N}if(0!==R)for(var I=0;S>I;++I){var N=e(g[I],O);if(void 0!==N)return N}if(1!==R)for(var I=0;C>I;++I){var N=e(m[I],O);if(void 0!==N)return N}0===R?a(g,v,S++,O):1===R?a(m,y,C++,O):2===R&&a(b,x,z++,O)}else{var O=(P>>1)-1;0===R?i(g,v,S--,O):1===R?i(m,y,C--,O):2===R&&i(b,x,z--,O)}}}function l(t,e,r,n,o,s,l,c,u,f,p,m){var y=0,b=2*t,x=e,w=e+t,k=1,A=1;n?A=d:k=d;for(var M=o;s>M;++M){var T=M+k,E=b*M;_[y++]=l[E+x],_[y++]=-T,_[y++]=l[E+w],_[y++]=T}for(var M=u;f>M;++M){var T=M+A,L=b*M;_[y++]=p[L+x],_[y++]=-T}var S=y>>>1;h(_,S);for(var C=0,M=0;S>M;++M){var z=0|_[2*M+1];if(0>z){var T=-z,P=!1;if(T>=d?(P=!n,T-=d):(P=!!n,T-=1),P)a(g,v,C++,T);else{var R=m[T],O=b*T,I=p[O+e+1],N=p[O+e+1+t];t:for(var j=0;C>j;++j){var F=g[j],B=b*F;if(!(ND;++D)if(p[O+D+t]y;++y){var b=y+d,x=p*y;_[f++]=a[x+v],_[f++]=-b,_[f++]=a[x+m],_[f++]=b}for(var y=s;l>y;++y){var b=y+1,w=p*y;_[f++]=c[w+v],_[f++]=-b}var k=f>>>1;h(_,k);for(var A=0,y=0;k>y;++y){var M=0|_[2*y+1];if(0>M){var b=-M;if(b>=d)g[A++]=b-d;else{b-=1;var T=u[b],E=p*b,L=c[E+e+1],S=c[E+e+1+t];t:for(var C=0;A>C;++C){var z=g[C],P=o[z];if(P===T)break;var R=p*z;if(!(SO;++O)if(c[E+O+t]=0;--C)if(g[C]===b){for(var O=C+1;A>O;++O)g[O-1]=g[O];break}--A}}}e.exports={init:n,sweepBipartite:o,sweepComplete:s,scanBipartite:l,scanComplete:c};var u=t("typedarray-pool"),f=t("bit-twiddle"),h=t("./sort"),d=1<<28,p=1024,g=u.mallocInt32(p),v=u.mallocInt32(p),m=u.mallocInt32(p),y=u.mallocInt32(p),b=u.mallocInt32(p),x=u.mallocInt32(p),_=u.mallocDouble(8*p)},{"./sort":56,"bit-twiddle":48,"typedarray-pool":282}],58:[function(t,e,r){(function(e){"use strict";function n(){try{var t=new Uint8Array(1);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function i(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(i()=e?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}function u(t,e){if(l(e),t=a(t,0>e?0:0|g(e)),!o.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;r++)t[r]=0;return t}function f(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!o.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|m(e,r);return t=a(t,n),t.write(e,r),t}function h(t,e){var r=0|g(e.length);t=a(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function d(t,e,r,n){if(e.byteLength,0>r||e.byteLength=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function v(t){return+t!=t&&(t=0),o.alloc(+t)}function m(t,e){if(o.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return X(t).length;default:if(n)return H(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if((void 0===e||0>e)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),0>=r)return"";if(r>>>=0,e>>>=0,e>=r)return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,r);case"utf8":case"utf-8":return L(this,e,r);case"ascii":return C(this,e,r);case"binary":return z(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function x(t,e,r,n){function i(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}var a=1,o=t.length,s=e.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,o/=2,s/=2,r/=2}for(var l=-1,c=0;o>r+c;c++)if(i(t,r+c)===i(e,-1===l?0:c-l)){if(-1===l&&(l=c),c-l+1===s)return(r+l)*a}else-1!==l&&(c-=c-l),l=-1;return-1}function _(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=e.length;if(a%2!==0)throw new Error("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;n>o;o++){var s=parseInt(e.substr(2*o,2),16);if(isNaN(s))return o;t[r+o]=s}return o}function w(t,e,r,n){return W(H(e,t.length-r),t,r,n)}function k(t,e,r,n){return W(G(e),t,r,n)}function A(t,e,r,n){return k(t,e,r,n)}function M(t,e,r,n){return W(X(e),t,r,n)}function T(t,e,r,n){return W(Y(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?K.fromByteArray(t):K.fromByteArray(t.slice(e,r))}function L(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;r>i;){var a=t[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(r>=i+s){var l,c,u,f;switch(s){case 1:128>a&&(o=a);break;case 2:l=t[i+1],128===(192&l)&&(f=(31&a)<<6|63&l,f>127&&(o=f));break;case 3:l=t[i+1],c=t[i+2],128===(192&l)&&128===(192&c)&&(f=(15&a)<<12|(63&l)<<6|63&c,f>2047&&(55296>f||f>57343)&&(o=f));break;case 4:l=t[i+1],c=t[i+2],u=t[i+3],128===(192&l)&&128===(192&c)&&128===(192&u)&&(f=(15&a)<<18|(63&l)<<12|(63&c)<<6|63&u,f>65535&&1114112>f&&(o=f))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return S(n)}function S(t){var e=t.length;if(J>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=J));return r}function C(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function z(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function P(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",a=e;r>a;a++)i+=q(t[a]);return i}function R(t,e,r){for(var n=t.slice(e,r),i="",a=0;at)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,r,n,i,a){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||a>e)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function N(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,a=Math.min(t.length-r,2);a>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function j(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,a=Math.min(t.length-r,4);a>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function F(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("Index out of range")}function B(t,e,r,n,i){return i||F(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),Q.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,i){return i||F(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),Q.write(t,e,r,n,52,8),r+8}function U(t){if(t=V(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function V(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function q(t){return 16>t?"0"+t.toString(16):t.toString(16)}function H(t,e){e=e||1/0;for(var r,n=t.length,i=null,a=[],o=0;n>o;o++){if(r=t.charCodeAt(o),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,128>r){if((e-=1)<0)break;a.push(r)}else if(2048>r){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function G(t){for(var e=[],r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function X(t){return K.toByteArray(U(t))}function W(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}function Z(t){return t!==t}var K=t("base64-js"),Q=t("ieee754"),$=t("isarray");r.Buffer=o,r.SlowBuffer=v,r.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),r.kMaxLength=i(),o.poolSize=8192,o._augment=function(t){return t.__proto__=o.prototype,t},o.from=function(t,e,r){return s(null,t,e,r)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(t,e,r){return c(null,t,e,r)},o.allocUnsafe=function(t){return u(null,t)},o.allocUnsafeSlow=function(t){return u(null,t)},o.isBuffer=function(t){return!(null==t||!t._isBuffer)},o.compare=function(t,e){if(!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,a=Math.min(r,n);a>i;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return n>r?-1:r>n?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!$(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);var r;if(void 0===e)for(e=0,r=0;re;e+=2)b(this,e,e+1);return this},o.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;t>e;e+=4)b(this,e,e+3),b(this,e+1,e+2);return this},o.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?L(this,0,t):y.apply(this,arguments)},o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:0===o.compare(this,t)},o.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},o.prototype.compare=function(t,e,r,n,i){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),0>e||r>t.length||0>n||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var a=i-n,s=r-e,l=Math.min(a,s),c=this.slice(n,i),u=t.slice(e,r),f=0;l>f;++f)if(c[f]!==u[f]){a=c[f],s=u[f];break}return s>a?-1:a>s?1:0},o.prototype.indexOf=function(t,e,r){if("string"==typeof e?(r=e,e=0):e>2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t&&(t=o.from(t,r)),o.isBuffer(t))return 0===t.length?-1:x(this,t,e,r);if("number"==typeof t)return o.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):x(this,[t],e,r);throw new TypeError("val must be string, number or Buffer")},o.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},o.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return w(this,t,e,r);case"ascii":return k(this,t,e,r);case"binary":return A(this,t,e,r);case"base64":return M(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var J=4096;o.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var n;if(o.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=o.prototype;else{var i=e-t;n=new o(i,void 0);for(var a=0;i>a;a++)n[a]=this[a+t]}return n},o.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||O(t,e,this.length);for(var n=this[t],i=1,a=0;++a0&&(i*=256);)n+=this[t+--e]*i;return n},o.prototype.readUInt8=function(t,e){return e||O(t,1,this.length),this[t]},o.prototype.readUInt16LE=function(t,e){return e||O(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUInt16BE=function(t,e){return e||O(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUInt32LE=function(t,e){return e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUInt32BE=function(t,e){return e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||O(t,e,this.length);for(var n=this[t],i=1,a=0;++a=i&&(n-=Math.pow(2,8*e)),n},o.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||O(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a},o.prototype.readInt8=function(t,e){return e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt16BE=function(t,e){e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt32LE=function(t,e){return e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,e){return e||O(t,4,this.length),Q.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return e||O(t,4,this.length),Q.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return e||O(t,8,this.length),Q.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return e||O(t,8,this.length),Q.read(this,t,!1,52,8)},o.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e=0|e,r=0|r,!n){var i=Math.pow(2,8*r)-1;I(this,t,e,r,i,0)}var a=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+a]=t/o&255;return e+r},o.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,1,255,0),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},o.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},o.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},o.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):j(this,t,e,!0),e+4},o.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},o.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var a=0,o=1,s=0;for(this[e]=255&t;++at&&0===s&&0!==this[e+a-1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+r},o.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)0>t&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+r},o.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,1,127,-128),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},o.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},o.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):j(this,t,e,!0),e+4},o.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},o.prototype.writeFloatLE=function(t,e,r){return B(this,t,e,!0,r)},o.prototype.writeFloatBE=function(t,e,r){return B(this,t,e,!1,r)},o.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},o.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},o.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-er&&n>e)for(i=a-1;i>=0;i--)t[i+e]=this[i+r];else if(1e3>a||!o.TYPED_ARRAY_SUPPORT)for(i=0;a>i;i++)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+a),e);return a},o.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);256>i&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t=255&t);if(0>e||this.length=r)return this;e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var a;if("number"==typeof t)for(a=e;r>a;a++)this[a]=t;else{var s=o.isBuffer(t)?t:H(new o(t,n).toString()),l=s.length;for(a=0;r-e>a;a++)this[a+e]=s[a%l]}return this};var tt=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":30,ieee754:198,isarray:59}],59:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],60:[function(t,e,r){"use strict";function n(t){return[Math.min(t[0],t[1]),Math.max(t[0],t[1])]}function i(t,e){return t[0]-e[0]||t[1]-e[1]}function a(t){return t.map(n).sort(i)}function o(t,e,r){return e in t?t[e]:r}function s(t,e,r){Array.isArray(e)?(r=r||{},e=e||[]):(r=e||{},e=[]);var n=!!o(r,"delaunay",!0),i=!!o(r,"interior",!0),s=!!o(r,"exterior",!0),h=!!o(r,"infinity",!1);if(!i&&!s||0===t.length)return[];var d=l(t,e);if(n||i!==s||h){for(var p=c(t.length,a(e)),g=0;gs)){if(n>i){var l=n;n=i,i=l,l=o,o=s,s=l}e.isConstraint(n,i)||a(t[n],t[i],t[o],t[s])<0&&r.push(n,i)}}function i(t,e){for(var r=[],i=t.length,o=e.stars,s=0;i>s;++s)for(var l=o[s],c=1;cu||e.isConstraint(s,u))){for(var f=l[c-1],h=-1,d=1;dh||a(t[s],t[u],t[f],t[h])<0&&r.push(s,u)}}for(;r.length>0;){for(var u=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],p=1;pf||0>h||a(t[s],t[u],t[f],t[h])>=0||(e.flip(s,u),n(t,e,r,f,s,h),n(t,e,r,s,h,f),n(t,e,r,h,u,f),n(t,e,r,u,f,h))}}var a=t("robust-in-sphere")[4];t("binary-search-bounds");e.exports=i},{"binary-search-bounds":65,"robust-in-sphere":251}],62:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function i(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}function a(t,e){for(var r=t.cells(),a=r.length,o=0;a>o;++o){var s=r[o],l=s[0],c=s[1],u=s[2];u>c?l>c&&(s[0]=c,s[1]=u,s[2]=l):l>u&&(s[0]=u,s[1]=l,s[2]=c)}r.sort(i);for(var f=new Array(a),o=0;oo;++o)for(var s=r[o],y=0;3>y;++y){var l=s[y],c=s[(y+1)%3],b=p[3*o+y]=m.locate(c,l,t.opposite(c,l)),x=g[3*o+y]=t.isConstraint(l,c);0>b&&(x?d.push(o):(h.push(o),f[o]=1),e&&v.push([c,l,-1]))}return m}function o(t,e,r){for(var n=0,i=0;i0||l.length>0;){for(;s.length>0;){var d=s.pop();if(c[d]!==-i){c[d]=i;for(var p=(u[d],0);3>p;++p){var g=h[3*d+p];g>=0&&0===c[g]&&(f[3*d+p]?l.push(g):(s.push(g),c[g]=i))}}}var v=l;l=s,s=v,l.length=0,i=-i}var m=o(u,c,e);return r?m.concat(n.boundary):m}var l=t("binary-search-bounds");e.exports=s;var c=n.prototype;c.locate=function(){var t=[0,0,0];return function(e,r,n){var a=e,o=r,s=n;return n>r?e>r&&(a=r,o=n,s=e):e>n&&(a=n,o=e,s=r),0>a?-1:(t[0]=a,t[1]=o,t[2]=s,l.eq(this.cells,t,i))}}()},{"binary-search-bounds":65}],63:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.a=t,this.b=e,this.idx=r,this.lowerIds=n,this.upperIds=i}function i(t,e,r,n){this.a=t,this.b=e,this.type=r,this.idx=n}function a(t,e){var r=t.a[0]-e.a[0]||t.a[1]-e.a[1]||t.type-e.type;return r?r:t.type!==p&&(r=d(t.a,t.b,e.b))?r:t.idx-e.idx}function o(t,e){return d(t.a,t.b,e)}function s(t,e,r,n,i){for(var a=h.lt(e,n,o),s=h.gt(e,n,o),l=a;s>l;++l){for(var c=e[l],u=c.lowerIds,f=u.length;f>1&&d(r[u[f-2]],r[u[f-1]],n)>0;)t.push([u[f-1],u[f-2],i]),f-=1;u.length=f,u.push(i);for(var p=c.upperIds,f=p.length;f>1&&d(r[p[f-2]],r[p[f-1]],n)<0;)t.push([p[f-2],p[f-1],i]),f-=1;p.length=f,p.push(i)}}function l(t,e){var r;return(r=t.a[0]f;++f)l.push(new i(t[f],null,p,f));for(var f=0;o>f;++f){var h=e[f],d=t[h[0]],m=t[h[1]];d[0]m[0]&&l.push(new i(m,d,v,f),new i(d,m,g,f))}l.sort(a);for(var y=l[0].a[0]-(1+Math.abs(l[0].a[0]))*Math.pow(2,-52),b=[new n([y,1],[y,0],-1,[],[],[],[])],x=[],f=0,_=l.length;_>f;++f){var w=l[f],k=w.type;k===p?s(x,b,t,w.a,w.idx):k===v?c(b,t,w):u(b,t,w)}return x}var h=t("binary-search-bounds"),d=t("robust-orientation")[3],p=0,g=1,v=2;e.exports=f},{"binary-search-bounds":65,"robust-orientation":253}],64:[function(t,e,r){"use strict";function n(t,e){this.stars=t,this.edges=e}function i(t,e,r){for(var n=1,i=t.length;i>n;n+=2)if(t[n-1]===e&&t[n]===r)return t[n-1]=t[i-2],t[n]=t[i-1],void(t.length=i-2)}function a(t,e){for(var r=new Array(t),i=0;t>i;++i)r[i]=[];return new n(r,e)}var o=t("binary-search-bounds");e.exports=a;var s=n.prototype;s.isConstraint=function(){function t(t,e){return t[0]-e[0]||t[1]-e[1]}var e=[0,0];return function(r,n){return e[0]=Math.min(r,n),e[1]=Math.max(r,n),o.eq(this.edges,e,t)>=0}}(),s.removeTriangle=function(t,e,r){var n=this.stars;i(n[t],e,r),i(n[e],r,t),i(n[r],t,e)},s.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},s.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;i>n;n+=2)if(r[n]===t)return r[n-1];return-1},s.flip=function(t,e){var r=this.opposite(t,e),n=this.opposite(e,t);this.removeTriangle(t,e,r),this.removeTriangle(e,t,n),this.addTriangle(t,n,r),this.addTriangle(e,r,n)},s.edges=function(){for(var t=this.stars,e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0,o=i.length;o>a;a+=2)e.push([i[a],i[a+1]]);return e},s.cells=function(){for(var t=this.stars,e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0,o=i.length;o>a;a+=2){var s=i[a],l=i[a+1];r>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],66:[function(t,e,r){"use strict";function n(t){for(var e=1,r=1;rn;++n)if(t[r]i;++i)r+=t[i]*e[i];return r}function i(t){var e=t.length;if(0===e)return[];var r=(t[0].length,o([t.length+1,t.length+1],1)),i=o([t.length+1],1);r[e][e]=0;for(var a=0;e>a;++a){for(var l=0;a>=l;++l)r[l][a]=r[a][l]=2*n(t[a],t[l]);i[a]=n(t[a],t[a])}for(var c=s(r,i),u=0,f=c[e+1],a=0;aa;++a){for(var f=c[a],d=0,l=0;ls;++s)r[s]+=t[a][s]*n[a];return r}var o=t("dup"),s=t("robust-linear-solve");a.barycenetric=i,e.exports=a},{dup:90,"robust-linear-solve":252}],68:[function(t,e,r){function n(t){for(var e=i(t),r=0,n=0;nr?[e,w(e,1/0)]:r>0?[w(e,-(1/0)),e]:[e,e]}function i(t,e){for(var r=new Array(e.length),n=0;n=t.length)return o[e-t.length];var r=t[e];return[y(r[0]),y(r[1])]}for(var o=[],s=0;s=0;--s){var g=n[s],c=g[0],v=e[c],m=v[0],x=v[1],w=t[m],A=t[x];if((w[0]-A[0]||w[1]-A[1])<0){var M=m;m=x,x=M}v[0]=m;var T,E=v[1]=g[1];for(i&&(T=v[2]);s>0&&n[s-1][0]===c;){var g=n[--s],L=g[1];i?e.push([E,L,T]):e.push([E,L]),E=L}i?e.push([E,x,T]):e.push([E,x])}return o}function c(t,e,r){for(var i=t.length+e.length,a=new g(i),o=r,s=0;ss;++s){var p=a.find(s);p===s?(d[s]=f,t[f++]=t[s]):(h=!1,d[s]=-1)}if(t.length=f,h)return null;for(var s=0;i>s;++s)d[s]<0&&(d[s]=d[a.find(s)]);return d}function u(t,e){return t[0]-e[0]||t[1]-e[1]}function f(t,e){var r=t[0]-e[0]||t[1]-e[1];return r?r:t[2]e[2]?1:0}function h(t,e,r){if(0!==t.length){if(e)for(var n=0;n0||d.length>0}function p(t,e,r){var n,i=!1;if(r){n=e;for(var a=new Array(e.length),o=0;on;++n)e=t[n],e=e.toString(16),r+=("00"+e).substr(e.length);return r}function i(t){return"rgba("+t.join(",")+")"}var a=t("arraytools"),o=t("clone"),s=t("./colorScales");e.exports=function(t){var e,r,l,c,u,f,h,d,p,g,v,m,y,b=[],x=[],_=[],w=[];if(a.isPlainObject(t)||(t={}),p=t.nshades||72,d=t.format||"hex",h=t.colormap,h||(h="jet"),"string"==typeof h){if(h=h.toLowerCase(),!s[h])throw Error(h+" not a supported colorscale");f=o(s[h])}else{if(!Array.isArray(h))throw Error("unsupported colormap option",h);f=o(h)}if(f.length>p)throw new Error(h+" map requires nshades to be at least size "+f.length);for(v=Array.isArray(t.alpha)?2!==t.alpha.length?[1,1]:o(t.alpha):"number"==typeof t.alpha?[t.alpha,t.alpha]:[1,1],e=f.map(function(t){return Math.round(t.index*p)}),v[0]<0&&(v[0]=0),v[1]<0&&(v[0]=0),v[0]>1&&(v[0]=1),v[1]>1&&(v[0]=1),y=0;y=0&&r[3]<=1||(r[3]=v[0]+(v[1]-v[0])*m);for(y=0;y=0}function i(t,e,r,i){var s=a(e,r,i);if(0===s){var l=o(a(t,e,r)),c=o(a(t,e,i));if(l===c){if(0===l){var u=n(t,e,r),f=n(t,e,i);return u===f?0:u?1:-1}return 0}return 0===c?l>0?-1:n(t,e,i)?-1:1:0===l?c>0?1:n(t,e,r)?1:-1:o(c-l)}var h=a(t,e,r);if(h>0)return s>0&&a(t,e,i)>0?1:-1;if(0>h)return s>0||a(t,e,i)>0?1:-1;var d=a(t,e,i);return d>0?1:n(t,e,r)?1:-1}e.exports=i;var a=t("robust-orientation"),o=t("signum"),s=t("two-sum"),l=t("robust-product"),c=t("robust-sum")},{"robust-orientation":253,"robust-product":254,"robust-sum":258,signum:259,"two-sum":281}],75:[function(t,e,r){function n(t,e){return t-e}function i(t,e){var r=t.length,i=t.length-e.length;if(i)return i;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:return t[0]+t[1]-e[0]-e[1]||a(t[0],t[1])-a(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(i=o+t[2]-(s+e[2]))return i;var l=a(t[0],t[1]),c=a(e[0],e[1]);return a(l,t[2])-a(c,e[2])||a(l+t[2],o)-a(c+e[2],s);case 4:var u=t[0],f=t[1],h=t[2],d=t[3],p=e[0],g=e[1],v=e[2],m=e[3];return u+f+h+d-(p+g+v+m)||a(u,f,h,d)-a(p,g,v,m,p)||a(u+f,u+h,u+d,f+h,f+d,h+d)-a(p+g,p+v,p+m,g+v,g+m,v+m)||a(u+f+h,u+f+d,u+h+d,f+h+d)-a(p+g+v,p+g+m,p+v+m,g+v+m);default:for(var y=t.slice().sort(n),b=e.slice().sort(n),x=0;r>x;++x)if(i=y[x]-b[x])return i;return 0}}e.exports=i;var a=Math.min},{}],76:[function(t,e,r){"use strict";function n(t,e){return i(t,e)||a(t)-a(e)}var i=t("compare-cell"),a=t("cell-orientation");e.exports=n},{"cell-orientation":66,"compare-cell":75}],77:[function(t,e,r){"use strict";function n(t){var e=t.length;if(0===e)return[];if(1===e)return[[0]];var r=t[0].length;return 0===r?[]:1===r?i(t):2===r?a(t):o(t,r)}var i=t("./lib/ch1d"),a=t("./lib/ch2d"),o=t("./lib/chnd");e.exports=n},{"./lib/ch1d":78,"./lib/ch2d":79,"./lib/chnd":80}],78:[function(t,e,r){"use strict";function n(t){for(var e=0,r=0,n=1;nt[r][0]&&(r=n);return r>e?[[e],[r]]:e>r?[[r],[e]]:[[e]]}e.exports=n},{}],79:[function(t,e,r){"use strict";function n(t){var e=i(t),r=e.length;if(2>=r)return[];for(var n=new Array(r),a=e[r-1],o=0;r>o;++o){var s=e[o];n[o]=[a,s],a=s}return n}e.exports=n;var i=t("monotone-convex-hull-2d")},{"monotone-convex-hull-2d":210}],80:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),i=0;ii;++i)e.indexOf(i)<0&&(n[a++]=t[i]);return n}function i(t,e){for(var r=t.length,n=e.length,i=0;r>i;++i)for(var a=t[i],o=0;os)a[o]=e[s];else{s-=n;for(var l=0;n>l;++l)s>=e[l]&&(s+=1);a[o]=s}}return t}function a(t,e){try{return o(t,!0)}catch(r){var a=s(t);if(a.length<=e)return[];var l=n(t,a),c=o(l,!0);return i(c,a)}}e.exports=a;var o=t("incremental-convex-hull"),s=t("affine-hull")},{"affine-hull":24,"incremental-convex-hull":199}],81:[function(t,e,r){e.exports={AFG:"afghan",ALA:"\\b\\wland",ALB:"albania",DZA:"algeria",ASM:"^(?=.*americ).*samoa",AND:"andorra",AGO:"angola",AIA:"anguill?a",ATA:"antarctica",ATG:"antigua",ARG:"argentin",ARM:"armenia",ABW:"^(?!.*bonaire).*\\baruba",AUS:"australia",AUT:"^(?!.*hungary).*austria|\\baustri.*\\bemp",AZE:"azerbaijan",BHS:"bahamas",BHR:"bahrain",BGD:"bangladesh|^(?=.*east).*paki?stan",BRB:"barbados",BLR:"belarus|byelo",BEL:"^(?!.*luxem).*belgium",BLZ:"belize|^(?=.*british).*honduras",BEN:"benin|dahome",BMU:"bermuda",BTN:"bhutan",BOL:"bolivia",BES:"^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands",BIH:"herzegovina|bosnia",BWA:"botswana|bechuana",BVT:"bouvet",BRA:"brazil",IOT:"british.?indian.?ocean",BRN:"brunei",BGR:"bulgaria",BFA:"burkina|\\bfaso|upper.?volta",BDI:"burundi",KHM:"cambodia|kampuchea|khmer",CMR:"cameroon",CAN:"canada",CPV:"verde",CYM:"cayman",CAF:"\\bcentral.african.republic",TCD:"\\bchad",CHL:"\\bchile",CHN:"^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai).*china",CXR:"christmas",CCK:"\\bcocos|keeling",COL:"colombia",COM:"comoro",COD:"\\bdem.*congo|congo.*\\bdem|congo.*\\bdr|\\bdr.*congo|belgian.?congo|congo.?free.?state|kinshasa|zaire|l.opoldville|drc|droc|rdc",COG:"^(?!.*\\bdem)(?!.*\\bdr)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l.opoldville)(?!.*free).*\\bcongo",COK:"\\bcook",CRI:"costa.?rica",CIV:"ivoire|ivory",HRV:"croatia",CUB:"\\bcuba",CUW:"^(?!.*bonaire).*\\bcura(c|\xe7)ao",CYP:"cyprus",CZE:"^(?=.*rep).*czech|czechia|bohemia",CSK:"czechoslovakia",DNK:"denmark",DJI:"djibouti",DMA:"dominica(?!n)",DOM:"dominican.rep",ECU:"ecuador",EGY:"egypt",SLV:"el.?salvador",GNQ:"guine.*eq|eq.*guine|^(?=.*span).*guinea",ERI:"eritrea",EST:"estonia",ETH:"ethiopia|abyssinia",FLK:"falkland|malvinas",FRO:"faroe|faeroe",FJI:"fiji",FIN:"finland",FRA:"^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul",GUF:"^(?=.*french).*guiana",PYF:"french.?polynesia|tahiti",ATF:"french.?southern",GAB:"gabon",GMB:"gambia",GEO:"^(?!.*south).*georgia",DDR:"german.?democratic.?republic|democratic.?republic.*germany|east.germany",DEU:"^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german",GHA:"ghana|gold.?coast",GIB:"gibraltar",GRC:"greece|hellenic|hellas",GRL:"greenland",GRD:"grenada",GLP:"guadeloupe",GUM:"\\bguam",GTM:"guatemala",GGY:"guernsey",GIN:"^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea",GNB:"bissau|^(?=.*portu).*guinea",GUY:"guyana|british.?guiana",HTI:"haiti",HMD:"heard.*mcdonald",VAT:"holy.?see|vatican|papal.?st",HND:"^(?!.*brit).*honduras",HKG:"hong.?kong",HUN:"^(?!.*austr).*hungary",ISL:"iceland",IND:"india(?!.*ocea)",IDN:"indonesia",IRN:"\\biran|persia",IRQ:"\\biraq|mesopotamia",IRL:"ireland",IMN:"^(?=.*isle).*\\bman",ISR:"israel",ITA:"italy",JAM:"jamaica",JPN:"japan",JEY:"jersey",JOR:"jordan",KAZ:"kazak",KEN:"kenya|british.?east.?africa|east.?africa.?prot",KIR:"kiribati",PRK:"^(?=.*democrat).*\\bkorea|^(?=.*people).*\\bkorea|^(?=.*north).*\\bkorea|dprk",KOR:"^(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea",KWT:"kuwait",KGZ:"kyrgyz|kirghiz",LAO:"\\blaos?\\b",LVA:"latvia",LBN:"lebanon",LSO:"lesotho|basuto",LBR:"liberia",LBY:"libya",LIE:"liechtenstein",LTU:"lithuania",LUX:"^(?!.*belg).*luxem",MAC:"maca(o|u)",MKD:"macedonia|fyrom",MDG:"madagascar|malagasy",MWI:"malawi|nyasa",MYS:"malaysia",MDV:"maldive",MLI:"\\bmali\\b",MLT:"\\bmalta",MHL:"marshall",MTQ:"martinique",MRT:"mauritania",MUS:"mauritius",MYT:"\\bmayotte",MEX:"\\bmexic",FSM:"micronesia",MDA:"moldov|b(a|e)ssarabia",MCO:"monaco",MNG:"mongolia",MNE:"^(?!.*serbia).*montenegro",MSR:"montserrat",MAR:"morocco|\\bmaroc",MOZ:"mozambique",MMR:"myanmar|burma",NAM:"namibia",NRU:"nauru",NPL:"nepal",NLD:"^(?!.*\\bant)(?!.*\\bcarib).*netherlands",ANT:"^(?=.*\\bant).*(nether|dutch)",NCL:"new.?caledonia",NZL:"new.?zealand",NIC:"nicaragua",NER:"\\bniger(?!ia)",NGA:"nigeria",NIU:"niue",NFK:"norfolk",MNP:"mariana",NOR:"norway",OMN:"\\boman|trucial",PAK:"^(?!.*east).*paki?stan",PLW:"palau",PSE:"palestin|\\bgaza|west.?bank",PAN:"panama",PNG:"papua|new.?guinea",PRY:"paraguay",PER:"peru",PHL:"philippines",PCN:"pitcairn",POL:"poland",PRT:"portugal",PRI:"puerto.?rico",QAT:"qatar",REU:"r(e|\xe9)union",ROU:"r(o|u|ou)mania",RUS:"\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics",RWA:"rwanda",BLM:"barth(e|\xe9)lemy",SHN:"helena",KNA:"kitts|\\bnevis",LCA:"\\blucia",MAF:"^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)",SPM:"miquelon",VCT:"vincent",WSM:"^(?!.*amer).*samoa",SMR:"san.?marino",STP:"\\bs(a|\xe3)o.?tom(e|\xe9)",SAU:"\\bsa\\w*.?arabia",SEN:"senegal",SRB:"^(?!.*monte).*serbia",SYC:"seychell",SLE:"sierra",SGP:"singapore",SXM:"^(?!.*martin)(?!.*saba).*maarten",SVK:"^(?!.*cze).*slovak",SVN:"slovenia",SLB:"solomon",SOM:"somali",ZAF:"\\bs\\w*.?africa",SGS:"south.?georgia|sandwich",SSD:"\\bs\\w*.?sudan",ESP:"spain",LKA:"sri.?lanka|ceylon",SDN:"^(?!.*\\bs(?!u)).*sudan",SUR:"surinam|dutch.?guiana",SJM:"svalbard",SWZ:"swaziland",SWE:"sweden",CHE:"switz|swiss",SYR:"syria",TWN:"taiwan|taipei|formosa",TJK:"tajik",TZA:"tanzania",THA:"thailand|\\bsiam",TLS:"^(?=.*leste).*timor|^(?=.*east).*timor",TGO:"togo",TKL:"tokelau",TON:"tonga",TTO:"trinidad|tobago",TUN:"tunisia",TUR:"turkey",TKM:"turkmen",TCA:"turks",TUV:"tuvalu",UGA:"uganda",UKR:"ukrain",ARE:"emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em",GBR:"united.?kingdom|britain|^u\\.?k\\.?$",USA:"united.?states|\\bu\\.?s\\.?a\\.?\\b|\\bu\\.?s\\.?\\b(?!.*islands)",UMI:"minor.?outlying.?is",URY:"uruguay",UZB:"uzbek",VUT:"vanuatu|new.?hebrides",VEN:"venezuela",VNM:"^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam",VGB:"^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin",VIR:"^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin",WLF:"futuna|wallis",ESH:"western.sahara",YEM:"^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen",YMD:"^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen",YUG:"yugoslavia",ZMB:"zambia|northern.?rhodesia",EAZ:"zanzibar",ZWE:"zimbabwe|^(?!.*northern).*rhodesia"}},{}],82:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=6*i*i-6*i,s=3*i*i-4*i+1,l=-6*i*i+6*i,c=3*i*i-2*i;if(t.length){a||(a=new Array(t.length));for(var u=t.length-1;u>=0;--u)a[u]=o*t[u]+s*e[u]+l*r[u]+c*n[u];return a}return o*t+s*e+l*r[u]+c*n}function i(t,e,r,n,i,a){var o=i-1,s=i*i,l=o*o,c=(1+2*i)*l,u=i*l,f=s*(3-2*i),h=s*o;if(t.length){a||(a=new Array(t.length));for(var d=t.length-1;d>=0;--d)a[d]=c*t[d]+u*e[d]+f*r[d]+h*n[d];return a}return c*t+u*e+f*r+h*n}e.exports=i,e.exports.derivative=n},{}],83:[function(t,e,r){"use strict";function n(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function i(t){var e=new n;e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===o){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(i),ir.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,a(e)}var a=t("./lib/thunk.js");e.exports=i},{"./lib/thunk.js":85}],84:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],c=[],u=0,f=0;for(n=0;a>n;++n)c.push(["i",n,"=0"].join(""));for(i=0;o>i;++i)for(n=0;a>n;++n)f=u,u=t[n],0===n?c.push(["d",i,"s",n,"=t",i,"p",u].join("")):c.push(["d",i,"s",n,"=(t",i,"p",u,"-s",f,"*t",i,"p",f,")"].join(""));for(l.push("var "+c.join(",")),n=a-1;n>=0;--n)u=t[n],l.push(["for(i",n,"=0;i",n,"n;++n){for(f=u,u=t[n],i=0;o>i;++i)l.push(["p",i,"+=d",i,"s",n].join(""));s&&(n>0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",u,"]"].join(""))),l.push("}")}return l.join("\n")}function i(t,e,r,i){for(var a=e.length,o=r.arrayArgs.length,s=r.blockSize,l=r.indexArgs.length>0,c=[],u=0;o>u;++u)c.push(["var offset",u,"=p",u].join(""));for(var u=t;a>u;++u)c.push(["for(var j"+u+"=SS[",e[u],"]|0;j",u,">0;){"].join("")),c.push(["if(j",u,"<",s,"){"].join("")),c.push(["s",e[u],"=j",u].join("")),c.push(["j",u,"=0"].join("")),c.push(["}else{s",e[u],"=",s].join("")),c.push(["j",u,"-=",s,"}"].join("")),l&&c.push(["index[",e[u],"]=j",u].join(""));for(var u=0;o>u;++u){for(var f=["offset"+u],h=t;a>h;++h)f.push(["j",h,"*t",u,"p",e[h]].join(""));c.push(["p",u,"=(",f.join("+"),")"].join(""))}c.push(n(e,r,i));for(var u=t;a>u;++u)c.push("}");return c.join("\n")}function a(t){for(var e=0,r=t[0].length;r>e;){for(var n=1;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}function l(t,e){for(var r=e[1].length-Math.abs(t.arrayBlockIndices[0])|0,l=new Array(t.arrayArgs.length),u=new Array(t.arrayArgs.length),f=0;fy;++y)_.push(["s",y,"=SS[",y,"]"].join(""));for(var f=0;fy;++y)_.push(["t",f,"p",y,"=t",f,"[",p[f]+y,"]"].join(""));for(var y=0;y0&&_.push("shape=SS.slice(0)"),t.indexArgs.length>0){for(var w=new Array(r),f=0;r>f;++f)w[f]="0";_.push(["index=[",w.join(","),"]"].join(""))}for(var f=0;f3&&x.push(o(t.pre,t,u));var T=o(t.body,t,u),E=a(v);r>E?x.push(i(E,v[0],t,T)):x.push(n(v[0],t,T)),t.post.body.length>3&&x.push(o(t.post,t,u)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+x.join("\n")+"\n----------");var L=[t.funcName||"unnamed","_cwise_loop_",l[0].join("s"),"m",E,s(u)].join(""),S=new Function(["function ",L,"(",b.join(","),"){",x.join("\n"),"} return ",L].join(""));return S()}var c=t("uniq");e.exports=l},{uniq:284}],85:[function(t,e,r){"use strict";function n(t){var e=["'use strict'","var CACHED={}"],r=[],n=t.funcName+"_cwise_thunk";e.push(["return function ",n,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],c=[],u=0;u0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[u]))),c.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[u])+"]"))}t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),e.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}"));for(var u=0;ut?-1:t>e?1:t>=e?0:NaN}function a(t){return null===t?NaN:+t}function o(t){return!isNaN(t)}function s(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}function l(t){return t.length}function c(t){for(var e=1;t*e%1;)e*=10;return e}function u(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function f(){this._=Object.create(null)}function h(t){return(t+="")===ko||t[0]===Ao?Ao+t:t}function d(t){return(t+="")[0]===Ao?t.slice(1):t}function p(t){return h(t)in this._}function g(t){return(t=h(t))in this._&&delete this._[t]}function v(){var t=[];for(var e in this._)t.push(d(e)); +return t}function m(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function b(){this._=Object.create(null)}function x(t){return t}function _(t,e,r){return function(){var n=r.apply(e,arguments);return n===e?t:n}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var r=0,n=Mo.length;n>r;++r){var i=Mo[r]+e;if(i in t)return i}}function k(){}function A(){}function M(t){function e(){for(var e,n=r,i=-1,a=n.length;++ir;r++)for(var i,a=t[r],o=0,s=a.length;s>o;o++)(i=a[o])&&e(i,o,r);return t}function Y(t){return Eo(t,Oo),t}function X(t){var e,r;return function(n,i,a){var o,s=t[a].update,l=s.length;for(a!=r&&(r=a,e=0),i>=e&&(e=i+1);!(o=s[e])&&++e0&&(t=t.slice(0,s));var c=Io.get(t);return c&&(t=c,l=K),s?e?i:n:e?k:a}function Z(t,e){return function(r){var n=co.event;co.event=r,e[0]=this.__data__;try{t.apply(this,e)}finally{co.event=n}}}function K(t,e){var r=Z(t,e);return function(t){var e=this,n=t.relatedTarget;n&&(n===e||8&n.compareDocumentPosition(e))||r.call(e,t)}}function Q(t){var r=".dragsuppress-"+ ++jo,i="click"+r,a=co.select(n(t)).on("touchmove"+r,T).on("dragstart"+r,T).on("selectstart"+r,T);if(null==No&&(No="onselectstart"in t?!1:w(t.style,"userSelect")),No){var o=e(t).style,s=o[No];o[No]="none"}return function(t){if(a.on(r,null),No&&(o[No]=s),t){var e=function(){a.on(i,null)};a.on(i,function(){T(),e()},!0),setTimeout(e,0)}}}function $(t,e){e.changedTouches&&(e=e.changedTouches[0]);var r=t.ownerSVGElement||t;if(r.createSVGPoint){var i=r.createSVGPoint();if(0>Fo){var a=n(t);if(a.scrollX||a.scrollY){r=co.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();Fo=!(o.f||o.e),r.remove()}}return Fo?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}function J(){return co.event.changedTouches[0].identifier}function tt(t){return t>0?1:0>t?-1:0}function et(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function rt(t){return t>1?0:-1>t?Uo:Math.acos(t)}function nt(t){return t>1?Ho:-1>t?-Ho:Math.asin(t)}function it(t){return((t=Math.exp(t))-1/t)/2}function at(t){return((t=Math.exp(t))+1/t)/2}function ot(t){return((t=Math.exp(2*t))-1)/(t+1)}function st(t){return(t=Math.sin(t/2))*t}function lt(){}function ct(t,e,r){return this instanceof ct?(this.h=+t,this.s=+e,void(this.l=+r)):arguments.length<2?t instanceof ct?new ct(t.h,t.s,t.l):kt(""+t,At,ct):new ct(t,e,r)}function ut(t,e,r){function n(t){return t>360?t-=360:0>t&&(t+=360),60>t?a+(o-a)*t/60:180>t?o:240>t?a+(o-a)*(240-t)/60:a}function i(t){return Math.round(255*n(t))}var a,o;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:0>e?0:e>1?1:e,r=0>r?0:r>1?1:r,o=.5>=r?r*(1+e):r+e-r*e,a=2*r-o,new bt(i(t+120),i(t),i(t-120))}function ft(t,e,r){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+r)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof dt?gt(t.l,t.a,t.b):gt((t=Mt((t=co.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,r)}function ht(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new dt(r,Math.cos(t*=Go)*e,Math.sin(t)*e)}function dt(t,e,r){return this instanceof dt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof dt?new dt(t.l,t.a,t.b):t instanceof ft?ht(t.h,t.c,t.l):Mt((t=bt(t)).r,t.g,t.b):new dt(t,e,r)}function pt(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return i=vt(i)*rs,n=vt(n)*ns,a=vt(a)*is,new bt(yt(3.2404542*i-1.5371385*n-.4985314*a),yt(-.969266*i+1.8760108*n+.041556*a),yt(.0556434*i-.2040259*n+1.0572252*a))}function gt(t,e,r){return t>0?new ft(Math.atan2(r,e)*Yo,Math.sqrt(e*e+r*r),t):new ft(NaN,NaN,t)}function vt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function mt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function bt(t,e,r){return this instanceof bt?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof bt?new bt(t.r,t.g,t.b):kt(""+t,bt,ut):new bt(t,e,r)}function xt(t){return new bt(t>>16,t>>8&255,255&t)}function _t(t){return xt(t)+""}function wt(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function kt(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(Et(i[0]),Et(i[1]),Et(i[2]))}return(a=ss.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o=o>>4|o,s=240&a,s=s>>4|s,l=15&a,l=l<<4|l):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function At(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=.5>l?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(r>e?6:0):e==o?(r-t)/s+2:(t-e)/s+4,n*=60):(n=NaN,i=l>0&&1>l?0:n),new ct(n,i,l)}function Mt(t,e,r){t=Tt(t),e=Tt(e),r=Tt(r);var n=mt((.4124564*t+.3575761*e+.1804375*r)/rs),i=mt((.2126729*t+.7151522*e+.072175*r)/ns),a=mt((.0193339*t+.119192*e+.9503041*r)/is);return dt(116*i-16,500*(n-i),200*(i-a))}function Tt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Et(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function Lt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,r,n){return 2===arguments.length&&"function"==typeof r&&(n=r,r=null),Ct(e,r,t,n)}}function Ct(t,e,r,n){function i(){var t,e=l.status;if(!e&&Pt(l)||e>=200&&300>e||304===e){try{t=r.call(a,l)}catch(n){return void o.error.call(a,n)}o.load.call(a,t)}else o.error.call(a,l)}var a={},o=co.dispatch("beforesend","progress","load","error"),s={},l=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(t)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(t){var e=co.event;co.event=t;try{o.progress.call(a,l)}finally{co.event=e}},a.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",a)},a.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",a):e},a.responseType=function(t){return arguments.length?(c=t,a):c},a.response=function(t){return r=t,a},["get","post"].forEach(function(t){a[t]=function(){return a.send.apply(a,[t].concat(fo(arguments)))}}),a.send=function(r,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),l.open(r,t,!0),null==e||"accept"in s||(s.accept=e+",*/*"),l.setRequestHeader)for(var u in s)l.setRequestHeader(u,s[u]);return null!=e&&l.overrideMimeType&&l.overrideMimeType(e),null!=c&&(l.responseType=c),null!=i&&a.on("error",i).on("load",function(t){i(null,t)}),o.beforesend.call(a,l),l.send(null==n?null:n),a},a.abort=function(){return l.abort(),a},co.rebind(a,o,"on"),null==n?a:a.get(zt(n))}function zt(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}function Pt(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Rt(t,e,r){var n=arguments.length;2>n&&(e=0),3>n&&(r=Date.now());var i=r+e,a={c:t,t:i,n:null};return cs?cs.n=a:ls=a,cs=a,us||(fs=clearTimeout(fs),us=1,hs(Ot)),a}function Ot(){var t=It(),e=Nt()-t;e>24?(isFinite(e)&&(clearTimeout(fs),fs=setTimeout(Ot,e)),us=0):(us=1,hs(Ot))}function It(){for(var t=Date.now(),e=ls;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Nt(){for(var t,e=ls,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}}function Bt(t){var e=t.decimal,r=t.thousands,n=t.grouping,i=t.currency,a=n&&r?function(t,e){for(var i=t.length,a=[],o=0,s=n[0],l=0;i>0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>e));)s=n[o=(o+1)%n.length];return a.reverse().join(r)}:x;return function(t){var r=ps.exec(t),n=r[1]||" ",o=r[2]||">",s=r[3]||"-",l=r[4]||"",c=r[5],u=+r[6],f=r[7],h=r[8],d=r[9],p=1,g="",v="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(c||"0"===n&&"="===o)&&(c=n="0",o="="),d){case"n":f=!0,d="g";break;case"%":p=100,v="%",d="f";break;case"p":p=100,v="%",d="r";break;case"b":case"o":case"x":case"X":"#"===l&&(g="0"+d.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,d="r"}"$"===l&&(g=i[0],v=i[1]),"r"!=d||h||(d="g"),null!=h&&("g"==d?h=Math.max(1,Math.min(21,h)):"e"!=d&&"f"!=d||(h=Math.max(0,Math.min(20,h)))),d=gs.get(d)||Dt;var b=c&&f;return function(t){var r=v;if(m&&t%1)return"";var i=0>t||0===t&&0>1/t?(t=-t,"-"):"-"===s?"":s;if(0>p){var l=co.formatPrefix(t,h);t=l.scale(t),r=l.symbol+v}else t*=p;t=d(t,h);var x,_,w=t.lastIndexOf(".");if(0>w){var k=y?t.lastIndexOf("e"):-1;0>k?(x=t,_=""):(x=t.substring(0,k),_=t.substring(k))}else x=t.substring(0,w),_=e+t.substring(w+1);!c&&f&&(x=a(x,1/0));var A=g.length+x.length+_.length+(b?0:i.length),M=u>A?new Array(A=u-A+1).join(n):"";return b&&(x=a(M+x,M.length?u-_.length:1/0)),i+=g,t=x+_,("<"===o?i+t+M:">"===o?M+i+t:"^"===o?M.substring(0,A>>=1)+i+t+M.substring(A):i+(b?t:M+t))+r}}}function Dt(t){return t+""}function Ut(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Vt(t,e,r){function n(e){var r=t(e),n=a(r,1);return n-e>e-r?r:n}function i(r){return e(r=t(new ms(r-1)),1),r}function a(t,r){return e(t=new ms(+t),r),t}function o(t,n,a){var o=i(t),s=[];if(a>1)for(;n>o;)r(o)%a||s.push(new Date(+o)),e(o,1);else for(;n>o;)s.push(new Date(+o)),e(o,1);return s}function s(t,e,r){try{ms=Ut;var n=new Ut;return n._=t,o(n,e,r)}finally{ms=Date}}t.floor=t,t.round=n,t.ceil=i,t.offset=a,t.range=o;var l=t.utc=qt(t);return l.floor=l,l.round=qt(n),l.ceil=qt(i),l.offset=qt(a),l.range=s,t}function qt(t){return function(e,r){try{ms=Ut;var n=new Ut;return n._=e,t(n,r)._}finally{ms=Date}}}function Ht(t){function e(t){function e(e){for(var r,i,a,o=[],s=-1,l=0;++ss;){if(n>=c)return-1;if(i=e.charCodeAt(s++),37===i){if(o=e.charAt(s++),a=S[o in bs?e.charAt(s++):o],!a||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}function n(t,e,r){w.lastIndex=0;var n=w.exec(e.slice(r));return n?(t.w=k.get(n[0].toLowerCase()),r+n[0].length):-1}function i(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.w=_.get(n[0].toLowerCase()),r+n[0].length):-1}function a(t,e,r){T.lastIndex=0;var n=T.exec(e.slice(r));return n?(t.m=E.get(n[0].toLowerCase()),r+n[0].length):-1}function o(t,e,r){A.lastIndex=0;var n=A.exec(e.slice(r));return n?(t.m=M.get(n[0].toLowerCase()),r+n[0].length):-1}function s(t,e,n){return r(t,L.c.toString(),e,n)}function l(t,e,n){return r(t,L.x.toString(),e,n)}function c(t,e,n){return r(t,L.X.toString(),e,n)}function u(t,e,r){var n=b.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)}var f=t.dateTime,h=t.date,d=t.time,p=t.periods,g=t.days,v=t.shortDays,m=t.months,y=t.shortMonths;e.utc=function(t){function r(t){try{ms=Ut;var e=new ms;return e._=t,n(e)}finally{ms=Date}}var n=e(t);return r.parse=function(t){try{ms=Ut;var e=n.parse(t);return e&&e._}finally{ms=Date}},r.toString=n.toString,r},e.multi=e.utc.multi=ue;var b=co.map(),x=Yt(g),_=Xt(g),w=Yt(v),k=Xt(v),A=Yt(m),M=Xt(m),T=Yt(y),E=Xt(y);p.forEach(function(t,e){b.set(t.toLowerCase(),e)});var L={a:function(t){return v[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return m[t.getMonth()]},c:e(f),d:function(t,e){return Gt(t.getDate(),e,2)},e:function(t,e){return Gt(t.getDate(),e,2)},H:function(t,e){return Gt(t.getHours(),e,2)},I:function(t,e){return Gt(t.getHours()%12||12,e,2)},j:function(t,e){return Gt(1+vs.dayOfYear(t),e,3)},L:function(t,e){return Gt(t.getMilliseconds(),e,3)},m:function(t,e){return Gt(t.getMonth()+1,e,2)},M:function(t,e){return Gt(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Gt(t.getSeconds(),e,2)},U:function(t,e){return Gt(vs.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Gt(vs.mondayOfYear(t),e,2)},x:e(h),X:e(d),y:function(t,e){return Gt(t.getFullYear()%100,e,2)},Y:function(t,e){return Gt(t.getFullYear()%1e4,e,4)},Z:le,"%":function(){return"%"}},S={a:n,A:i,b:a,B:o,c:s,d:re,e:re,H:ie,I:ie,j:ne,L:se,m:ee,M:ae,p:u,S:oe,U:Zt,w:Wt,W:Kt,x:l,X:c,y:$t,Y:Qt,Z:Jt,"%":ce};return e}function Gt(t,e,r){var n=0>t?"-":"",i=(n?-t:t)+"",a=i.length;return n+(r>a?new Array(r-a+1).join(e)+i:i)}function Yt(t){return new RegExp("^(?:"+t.map(co.requote).join("|")+")","i")}function Xt(t){for(var e=new f,r=-1,n=t.length;++r68?1900:2e3)}function ee(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function re(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function ne(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function ie(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function ae(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function oe(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function se(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function le(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=wo(e)/60|0,i=wo(e)%60;return r+Gt(n,"0",2)+Gt(i,"0",2)}function ce(t,e,r){_s.lastIndex=0;var n=_s.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function ue(t){for(var e=t.length,r=-1;++r=0?1:-1,s=o*r,l=Math.cos(e),c=Math.sin(e),u=a*c,f=i*l+u*Math.cos(s),h=u*o*Math.sin(s);Es.add(Math.atan2(h,f)),n=t,i=l,a=c}var e,r,n,i,a;Ls.point=function(o,s){Ls.point=t,n=(e=o)*Go,i=Math.cos(s=(r=s)*Go/2+Uo/4),a=Math.sin(s)},Ls.lineEnd=function(){t(e,r)}}function me(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function be(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function xe(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ke(t){return[Math.atan2(t[1],t[0]),nt(t[2])]}function Ae(t,e){return wo(t[0]-e[0])s;++s)i.point((r=t[s])[0],r[1]);return void i.lineEnd()}var l=new Oe(r,t,null,!0),c=new Oe(r,null,l,!1);l.o=c,a.push(l),o.push(c),l=new Oe(n,t,null,!1),c=new Oe(n,null,l,!0),l.o=c,a.push(l),o.push(c)}}),o.sort(e),Re(a),Re(o),a.length){for(var s=0,l=r,c=o.length;c>s;++s)o[s].e=l=!l;for(var u,f,h=a[0];;){for(var d=h,p=!0;d.v;)if((d=d.n)===h)return;u=d.z,i.lineStart();do{if(d.v=d.o.v=!0,d.e){if(p)for(var s=0,c=u.length;c>s;++s)i.point((f=u[s])[0],f[1]);else n(d.x,d.n.x,1,i);d=d.n}else{if(p){u=d.p.z;for(var s=u.length-1;s>=0;--s)i.point((f=u[s])[0],f[1])}else n(d.x,d.p.x,-1,i);d=d.p}d=d.o,u=d.z,p=!p}while(!d.v);i.lineEnd()}}}function Re(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n0){for(_||(a.polygonStart(),_=!0),a.lineStart();++o1&&2&e&&r.push(r.pop().concat(r.shift())),d.push(r.filter(Ne))}var d,p,g,v=e(a),m=i.invert(n[0],n[1]),y={point:o,lineStart:l,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=f,y.lineEnd=h,d=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=l,y.lineEnd=c,d=co.merge(d);var t=Ve(m,p);d.length?(_||(a.polygonStart(),_=!0),Pe(d,Fe,t,r,a)):t&&(_||(a.polygonStart(),_=!0),a.lineStart(),r(null,null,1,a),a.lineEnd()),_&&(a.polygonEnd(),_=!1),d=p=null},sphere:function(){a.polygonStart(),a.lineStart(),r(null,null,1,a),a.lineEnd(),a.polygonEnd()}},b=je(),x=e(b),_=!1;return y}}function Ne(t){return t.length>1}function je(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:k,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Fe(t,e){return((t=t.x)[0]<0?t[1]-Ho-Bo:Ho-t[1])-((e=e.x)[0]<0?e[1]-Ho-Bo:Ho-e[1])}function Be(t){var e,r=NaN,n=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?Uo:-Uo,l=wo(a-r);wo(l-Uo)0?Ho:-Ho),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=Uo&&(wo(r-i)Bo?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}function Ue(t,e,r,n){var i;if(null==t)i=r*Ho,n.point(-Uo,i),n.point(0,i),n.point(Uo,i),n.point(Uo,0),n.point(Uo,-i),n.point(0,-i),n.point(-Uo,-i),n.point(-Uo,0),n.point(-Uo,i);else if(wo(t[0]-e[0])>Bo){var a=t[0]s;++s){var c=e[s],u=c.length;if(u)for(var f=c[0],h=f[0],d=f[1]/2+Uo/4,p=Math.sin(d),g=Math.cos(d),v=1;;){v===u&&(v=0),t=c[v];var m=t[0],y=t[1]/2+Uo/4,b=Math.sin(y),x=Math.cos(y),_=m-h,w=_>=0?1:-1,k=w*_,A=k>Uo,M=p*b;if(Es.add(Math.atan2(M*w*Math.sin(k),g*x+M*Math.cos(k))),a+=A?_+w*Vo:_,A^h>=r^m>=r){var T=be(me(f),me(t));we(T);var E=be(i,T);we(E);var L=(A^_>=0?-1:1)*nt(E[2]);(n>L||n===L&&(T[0]||T[1]))&&(o+=A^_>=0?1:-1)}if(!v++)break;h=m,p=b,g=x,f=t}}return(-Bo>a||Bo>a&&-Bo>Es)^1&o}function qe(t){function e(t,e){return Math.cos(t)*Math.cos(e)>a}function r(t){var r,a,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(f,h){var d,p=[f,h],g=e(f,h),v=o?g?0:i(f,h):g?i(f+(0>f?Uo:-Uo),h):0;if(!r&&(c=l=g)&&t.lineStart(),g!==l&&(d=n(r,p),(Ae(r,d)||Ae(p,d))&&(p[0]+=Bo,p[1]+=Bo,g=e(p[0],p[1]))),g!==l)u=0,g?(t.lineStart(),d=n(p,r),t.point(d[0],d[1])):(d=n(r,p),t.point(d[0],d[1]),t.lineEnd()),r=d;else if(s&&r&&o^g){var m;v&a||!(m=n(p,r,!0))||(u=0,o?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||r&&Ae(r,p)||t.point(p[0],p[1]),r=p,l=g,a=v},lineEnd:function(){l&&t.lineEnd(),r=null},clean:function(){return u|(c&&l)<<1}}}function n(t,e,r){var n=me(t),i=me(e),o=[1,0,0],s=be(n,i),l=ye(s,s),c=s[0],u=l-c*c;if(!u)return!r&&t;var f=a*l/u,h=-a*c/u,d=be(o,s),p=_e(o,f),g=_e(s,h);xe(p,g);var v=d,m=ye(p,v),y=ye(v,v),b=m*m-y*(ye(p,p)-1);if(!(0>b)){var x=Math.sqrt(b),_=_e(v,(-m-x)/y);if(xe(_,p),_=ke(_),!r)return _;var w,k=t[0],A=e[0],M=t[1],T=e[1];k>A&&(w=k,k=A,A=w);var E=A-k,L=wo(E-Uo)E;if(!L&&M>T&&(w=M,M=T,T=w),S?L?M+T>0^_[1]<(wo(_[0]-k)Uo^(k<=_[0]&&_[0]<=A)){var C=_e(v,(-m+x)/y);return xe(C,p),[_,ke(C)]}}}function i(e,r){var n=o?t:Uo-t,i=0;return-n>e?i|=1:e>n&&(i|=2),-n>r?i|=4:r>n&&(i|=8),i}var a=Math.cos(t),o=a>0,s=wo(a)>Bo,l=vr(t,6*Go);return Ie(e,r,l,o?[0,-t]:[-Uo,t-Uo])}function He(t,e,r,n){return function(i){var a,o=i.a,s=i.b,l=o.x,c=o.y,u=s.x,f=s.y,h=0,d=1,p=u-l,g=f-c;if(a=t-l,p||!(a>0)){if(a/=p,0>p){if(h>a)return;d>a&&(d=a)}else if(p>0){if(a>d)return;a>h&&(h=a)}if(a=r-l,p||!(0>a)){if(a/=p,0>p){if(a>d)return;a>h&&(h=a)}else if(p>0){if(h>a)return;d>a&&(d=a)}if(a=e-c,g||!(a>0)){if(a/=g,0>g){if(h>a)return;d>a&&(d=a)}else if(g>0){if(a>d)return;a>h&&(h=a)}if(a=n-c,g||!(0>a)){if(a/=g,0>g){if(a>d)return;a>h&&(h=a)}else if(g>0){if(h>a)return;d>a&&(d=a)}return h>0&&(i.a={x:l+h*p,y:c+h*g}),1>d&&(i.b={x:l+d*p,y:c+d*g}),i}}}}}}function Ge(t,e,r,n){function i(n,i){return wo(n[0]-t)0?0:3:wo(n[0]-r)0?2:1:wo(n[1]-e)0?1:0:i>0?3:2}function a(t,e){return o(t.x,e.x)}function o(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}return function(s){function l(t){for(var e=0,r=v.length,n=t[1],i=0;r>i;++i)for(var a,o=1,s=v[i],l=s.length,c=s[0];l>o;++o)a=s[o],c[1]<=n?a[1]>n&&et(c,a,t)>0&&++e:a[1]<=n&&et(c,a,t)<0&&--e,c=a;return 0!==e}function c(a,s,l,c){var u=0,f=0;if(null==a||(u=i(a,l))!==(f=i(s,l))||o(a,s)<0^l>0){do c.point(0===u||3===u?t:r,u>1?n:e);while((u=(u+l+4)%4)!==f)}else c.point(s[0],s[1])}function u(i,a){return i>=t&&r>=i&&a>=e&&n>=a}function f(t,e){u(t,e)&&s.point(t,e)}function h(){S.point=p,v&&v.push(m=[]),A=!0,k=!1,_=w=NaN}function d(){g&&(p(y,b),x&&k&&E.rejoin(),g.push(E.buffer())),S.point=f,k&&s.lineEnd()}function p(t,e){t=Math.max(-Vs,Math.min(Vs,t)),e=Math.max(-Vs,Math.min(Vs,e));var r=u(t,e);if(v&&m.push([t,e]),A)y=t,b=e,x=r,A=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&k)s.point(t,e);else{var n={a:{x:_,y:w},b:{x:t,y:e}};L(n)?(k||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),M=!1):r&&(s.lineStart(),s.point(t,e),M=!1)}_=t,w=e,k=r}var g,v,m,y,b,x,_,w,k,A,M,T=s,E=je(),L=He(t,e,r,n),S={point:f,lineStart:h,lineEnd:d,polygonStart:function(){s=E,g=[],v=[],M=!0},polygonEnd:function(){s=T,g=co.merge(g);var e=l([t,n]),r=M&&e,i=g.length;(r||i)&&(s.polygonStart(),r&&(s.lineStart(),c(null,null,1,s),s.lineEnd()),i&&Pe(g,a,e,c,s),s.polygonEnd()),g=v=m=null}};return S}}function Ye(t){var e=0,r=Uo/3,n=lr(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*Uo/180,r=t[1]*Uo/180):[e/Uo*180,r/Uo*180]},i}function Xe(t,e){function r(t,e){var r=Math.sqrt(a-2*i*Math.sin(e))/i;return[r*Math.sin(t*=i),o-r*Math.cos(t)]}var n=Math.sin(t),i=(n+Math.sin(e))/2,a=1+n*(2*i-n),o=Math.sqrt(a)/i;return r.invert=function(t,e){var r=o-e;return[Math.atan2(t,r)/i,nt((a-(t*t+r*r)*i*i)/(2*i))]},r}function We(){function t(t,e){Hs+=i*t-n*e,n=t,i=e}var e,r,n,i;Zs.point=function(a,o){Zs.point=t,e=n=a,r=i=o},Zs.lineEnd=function(){t(e,r)}}function Ze(t,e){Gs>t&&(Gs=t),t>Xs&&(Xs=t),Ys>e&&(Ys=e),e>Ws&&(Ws=e)}function Ke(){function t(t,e){o.push("M",t,",",e,a)}function e(t,e){o.push("M",t,",",e),s.point=r}function r(t,e){o.push("L",t,",",e)}function n(){s.point=t}function i(){o.push("Z")}var a=Qe(4.5),o=[],s={point:t,lineStart:function(){s.point=e},lineEnd:n,polygonStart:function(){s.lineEnd=i},polygonEnd:function(){s.lineEnd=n,s.point=t},pointRadius:function(t){return a=Qe(t),s},result:function(){if(o.length){var t=o.join("");return o=[],t}}};return s}function Qe(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function $e(t,e){zs+=t,Ps+=e,++Rs}function Je(){function t(t,n){var i=t-e,a=n-r,o=Math.sqrt(i*i+a*a);Os+=o*(e+t)/2,Is+=o*(r+n)/2,Ns+=o,$e(e=t,r=n)}var e,r;Qs.point=function(n,i){Qs.point=t,$e(e=n,r=i)}}function tr(){Qs.point=$e}function er(){function t(t,e){var r=t-n,a=e-i,o=Math.sqrt(r*r+a*a);Os+=o*(n+t)/2,Is+=o*(i+e)/2,Ns+=o,o=i*t-n*e,js+=o*(n+t),Fs+=o*(i+e),Bs+=3*o,$e(n=t,i=e)}var e,r,n,i;Qs.point=function(a,o){Qs.point=t,$e(e=n=a,r=i=o)},Qs.lineEnd=function(){t(e,r)}}function rr(t){function e(e,r){t.moveTo(e+o,r),t.arc(e,r,o,0,Vo)}function r(e,r){t.moveTo(e,r),s.point=n}function n(e,r){t.lineTo(e,r)}function i(){s.point=e}function a(){t.closePath()}var o=4.5,s={point:e,lineStart:function(){s.point=r},lineEnd:i,polygonStart:function(){s.lineEnd=a},polygonEnd:function(){s.lineEnd=i,s.point=e},pointRadius:function(t){return o=t,s},result:k};return s}function nr(t){function e(t){return(s?n:r)(t)}function r(e){return or(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})}function n(e){function r(r,n){r=t(r,n),e.point(r[0],r[1])}function n(){b=NaN,A.point=a,e.lineStart()}function a(r,n){var a=me([r,n]),o=t(r,n);i(b,x,y,_,w,k,b=o[0],x=o[1],y=r,_=a[0],w=a[1],k=a[2],s,e),e.point(b,x)}function o(){A.point=r,e.lineEnd()}function l(){n(),A.point=c,A.lineEnd=u}function c(t,e){a(f=t,h=e),d=b,p=x,g=_,v=w,m=k,A.point=a}function u(){i(b,x,y,_,w,k,d,p,f,g,v,m,s,e),A.lineEnd=o,o()}var f,h,d,p,g,v,m,y,b,x,_,w,k,A={point:r,lineStart:n,lineEnd:o,polygonStart:function(){e.polygonStart(),A.lineStart=l},polygonEnd:function(){e.polygonEnd(),A.lineStart=n}};return A}function i(e,r,n,s,l,c,u,f,h,d,p,g,v,m){var y=u-e,b=f-r,x=y*y+b*b;if(x>4*a&&v--){var _=s+d,w=l+p,k=c+g,A=Math.sqrt(_*_+w*w+k*k),M=Math.asin(k/=A),T=wo(wo(k)-1)a||wo((y*C+b*z)/x-.5)>.3||o>s*d+l*p+c*g)&&(i(e,r,n,s,l,c,L,S,T,_/=A,w/=A,k,v,m),m.point(L,S),i(L,S,T,_,w,k,u,f,h,d,p,g,v,m))}}var a=.5,o=Math.cos(30*Go),s=16;return e.precision=function(t){return arguments.length?(s=(a=t*t)>0&&16,e):Math.sqrt(a)},e}function ir(t){var e=nr(function(e,r){return t([e*Yo,r*Yo])});return function(t){return cr(e(t))}}function ar(t){this.stream=t}function or(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart(); +},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sr(t){return lr(function(){return t})()}function lr(t){function e(t){return t=s(t[0]*Go,t[1]*Go),[t[0]*h+l,c-t[1]*h]}function r(t){return t=s.invert((t[0]-l)/h,(c-t[1])/h),t&&[t[0]*Yo,t[1]*Yo]}function n(){s=Ce(o=hr(m,y,b),a);var t=a(g,v);return l=d-t[0]*h,c=p+t[1]*h,i()}function i(){return u&&(u.valid=!1,u=null),e}var a,o,s,l,c,u,f=nr(function(t,e){return t=a(t,e),[t[0]*h+l,c-t[1]*h]}),h=150,d=480,p=250,g=0,v=0,m=0,y=0,b=0,_=Us,w=x,k=null,A=null;return e.stream=function(t){return u&&(u.valid=!1),u=cr(_(o,f(w(t)))),u.valid=!0,u},e.clipAngle=function(t){return arguments.length?(_=null==t?(k=t,Us):qe((k=+t)*Go),i()):k},e.clipExtent=function(t){return arguments.length?(A=t,w=t?Ge(t[0][0],t[0][1],t[1][0],t[1][1]):x,i()):A},e.scale=function(t){return arguments.length?(h=+t,n()):h},e.translate=function(t){return arguments.length?(d=+t[0],p=+t[1],n()):[d,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Go,v=t[1]%360*Go,n()):[g*Yo,v*Yo]},e.rotate=function(t){return arguments.length?(m=t[0]%360*Go,y=t[1]%360*Go,b=t.length>2?t[2]%360*Go:0,n()):[m*Yo,y*Yo,b*Yo]},co.rebind(e,f,"precision"),function(){return a=t.apply(this,arguments),e.invert=a.invert&&r,n()}}function cr(t){return or(t,function(e,r){t.point(e*Go,r*Go)})}function ur(t,e){return[t,e]}function fr(t,e){return[t>Uo?t-Vo:-Uo>t?t+Vo:t,e]}function hr(t,e,r){return t?e||r?Ce(pr(t),gr(e,r)):pr(t):e||r?gr(e,r):fr}function dr(t){return function(e,r){return e+=t,[e>Uo?e-Vo:-Uo>e?e+Vo:e,r]}}function pr(t){var e=dr(t);return e.invert=dr(-t),e}function gr(t,e){function r(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*n+s*i;return[Math.atan2(l*a-u*o,s*n-c*i),nt(u*a+l*o)]}var n=Math.cos(t),i=Math.sin(t),a=Math.cos(e),o=Math.sin(e);return r.invert=function(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*a-l*o;return[Math.atan2(l*a+c*o,s*n+u*i),nt(u*n-s*i)]},r}function vr(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=mr(r,i),a=mr(r,a),(o>0?a>i:i>a)&&(i+=o*Vo)):(i=t+o*Vo,a=t-.5*l);for(var c,u=i;o>0?u>a:a>u;u-=l)s.point((c=ke([r,-n*Math.cos(u),-n*Math.sin(u)]))[0],c[1])}}function mr(t,e){var r=me(e);r[0]-=t,we(r);var n=rt(-r[1]);return((-r[2]<0?-n:n)+2*Math.PI-Bo)%(2*Math.PI)}function yr(t,e,r){var n=co.range(t,e-Bo,r).concat(e);return function(t){return n.map(function(e){return[t,e]})}}function br(t,e,r){var n=co.range(t,e-Bo,r).concat(e);return function(t){return n.map(function(e){return[e,t]})}}function xr(t){return t.source}function _r(t){return t.target}function wr(t,e,r,n){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(n),s=Math.sin(n),l=i*Math.cos(t),c=i*Math.sin(t),u=o*Math.cos(r),f=o*Math.sin(r),h=2*Math.asin(Math.sqrt(st(n-e)+i*o*st(r-t))),d=1/Math.sin(h),p=h?function(t){var e=Math.sin(t*=h)*d,r=Math.sin(h-t)*d,n=r*l+e*u,i=r*c+e*f,o=r*a+e*s;return[Math.atan2(i,n)*Yo,Math.atan2(o,Math.sqrt(n*n+i*i))*Yo]}:function(){return[t*Yo,e*Yo]};return p.distance=h,p}function kr(){function t(t,i){var a=Math.sin(i*=Go),o=Math.cos(i),s=wo((t*=Go)-e),l=Math.cos(s);$s+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=n*a-r*o*l)*s),r*a+n*o*l),e=t,r=a,n=o}var e,r,n;Js.point=function(i,a){e=i*Go,r=Math.sin(a*=Go),n=Math.cos(a),Js.point=t},Js.lineEnd=function(){Js.point=Js.lineEnd=k}}function Ar(t,e){function r(e,r){var n=Math.cos(e),i=Math.cos(r),a=t(n*i);return[a*i*Math.sin(e),a*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),i=e(n),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,n*o),Math.asin(n&&r*a/n)]},r}function Mr(t,e){function r(t,e){o>0?-Ho+Bo>e&&(e=-Ho+Bo):e>Ho-Bo&&(e=Ho-Bo);var r=o/Math.pow(i(e),a);return[r*Math.sin(a*t),o-r*Math.cos(a*t)]}var n=Math.cos(t),i=function(t){return Math.tan(Uo/4+t/2)},a=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(i(e)/i(t)),o=n*Math.pow(i(t),a)/a;return a?(r.invert=function(t,e){var r=o-e,n=tt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(o/n,1/a))-Ho]},r):Er}function Tr(t,e){function r(t,e){var r=a-e;return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}var n=Math.cos(t),i=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),a=n/i+t;return wo(i)i;i++){for(;n>1&&et(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function Rr(t,e){return t[0]-e[0]||t[1]-e[1]}function Or(t,e,r){return(r[0]-e[0])*(t[1]-e[1])<(r[1]-e[1])*(t[0]-e[0])}function Ir(t,e,r,n){var i=t[0],a=r[0],o=e[0]-i,s=n[0]-a,l=t[1],c=r[1],u=e[1]-l,f=n[1]-c,h=(s*(l-c)-f*(i-a))/(f*o-s*u);return[i+h*o,l+h*u]}function Nr(t){var e=t[0],r=t[t.length-1];return!(e[0]-r[0]||e[1]-r[1])}function jr(){an(this),this.edge=this.site=this.circle=null}function Fr(t){var e=fl.pop()||new jr;return e.site=t,e}function Br(t){Zr(t),ll.remove(t),fl.push(t),an(t)}function Dr(t){var e=t.circle,r=e.x,n=e.cy,i={x:r,y:n},a=t.P,o=t.N,s=[t];Br(t);for(var l=a;l.circle&&wo(r-l.circle.x)u;++u)c=s[u],l=s[u-1],en(c.edge,l.site,c.site,i);l=s[0],c=s[f-1],c.edge=Jr(l.site,c.site,null,i),Wr(l),Wr(c)}function Ur(t){for(var e,r,n,i,a=t.x,o=t.y,s=ll._;s;)if(n=Vr(s,o)-a,n>Bo)s=s.L;else{if(i=a-qr(s,o),!(i>Bo)){n>-Bo?(e=s.P,r=s):i>-Bo?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=Fr(t);if(ll.insert(e,l),e||r){if(e===r)return Zr(e),r=Fr(e.site),ll.insert(l,r),l.edge=r.edge=Jr(e.site,l.site),Wr(e),void Wr(r);if(!r)return void(l.edge=Jr(e.site,l.site));Zr(e),Zr(r);var c=e.site,u=c.x,f=c.y,h=t.x-u,d=t.y-f,p=r.site,g=p.x-u,v=p.y-f,m=2*(h*v-d*g),y=h*h+d*d,b=g*g+v*v,x={x:(v*y-d*b)/m+u,y:(h*b-g*y)/m+f};en(r.edge,c,p,x),l.edge=Jr(c,t,null,x),r.edge=Jr(t,p,null,x),Wr(e),Wr(r)}}function Vr(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-(1/0);r=o.site;var s=r.x,l=r.y,c=l-e;if(!c)return s;var u=s-n,f=1/a-1/c,h=u/c;return f?(-h+Math.sqrt(h*h-2*f*(u*u/(-2*c)-l+c/2+i-a/2)))/f+n:(n+s)/2}function qr(t,e){var r=t.N;if(r)return Vr(r,e);var n=t.site;return n.y===e?n.x:1/0}function Hr(t){this.site=t,this.edges=[]}function Gr(t){for(var e,r,n,i,a,o,s,l,c,u,f=t[0][0],h=t[1][0],d=t[0][1],p=t[1][1],g=sl,v=g.length;v--;)if(a=g[v],a&&a.prepare())for(s=a.edges,l=s.length,o=0;l>o;)u=s[o].end(),n=u.x,i=u.y,c=s[++o%l].start(),e=c.x,r=c.y,(wo(n-e)>Bo||wo(i-r)>Bo)&&(s.splice(o,0,new rn(tn(a.site,u,wo(n-f)Bo?{x:f,y:wo(e-f)Bo?{x:wo(r-p)Bo?{x:h,y:wo(e-h)Bo?{x:wo(r-d)=-Do)){var d=l*l+c*c,p=u*u+f*f,g=(f*d-c*p)/h,v=(l*p-u*d)/h,f=v+s,m=hl.pop()||new Xr;m.arc=t,m.site=i,m.x=g+o,m.y=f+Math.sqrt(g*g+v*v),m.cy=f,t.circle=m;for(var y=null,b=ul._;b;)if(m.yv||v>=s)return;if(h>p){if(a){if(a.y>=c)return}else a={x:v,y:l};r={x:v,y:c}}else{if(a){if(a.yn||n>1)if(h>p){if(a){if(a.y>=c)return}else a={x:(l-i)/n,y:l};r={x:(c-i)/n,y:c}}else{if(a){if(a.yd){if(a){if(a.x>=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xa||f>o||n>h||i>d)){if(p=t.point){var p,g=e-t.x,v=r-t.y,m=g*g+v*v;if(l>m){var y=Math.sqrt(l=m);n=e-y,i=r-y,a=e+y,o=r+y,s=p}}for(var b=t.nodes,x=.5*(u+h),_=.5*(f+d),w=e>=x,k=r>=_,A=k<<1|w,M=A+4;M>A;++A)if(t=b[3&A])switch(3&A){case 0:c(t,u,f,x,_);break;case 1:c(t,x,f,h,_);break;case 2:c(t,u,_,x,d);break;case 3:c(t,x,_,h,d)}}}(t,n,i,a,o),s}function mn(t,e){t=co.rgb(t),e=co.rgb(e);var r=t.r,n=t.g,i=t.b,a=e.r-r,o=e.g-n,s=e.b-i;return function(t){return"#"+wt(Math.round(r+a*t))+wt(Math.round(n+o*t))+wt(Math.round(i+s*t))}}function yn(t,e){var r,n={},i={};for(r in t)r in e?n[r]=_n(t[r],e[r]):i[r]=t[r];for(r in e)r in t||(i[r]=e[r]);return function(t){for(r in n)i[r]=n[r](t);return i}}function bn(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function xn(t,e){var r,n,i,a=pl.lastIndex=gl.lastIndex=0,o=-1,s=[],l=[];for(t+="",e+="";(r=pl.exec(t))&&(n=gl.exec(e));)(i=n.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:bn(r,n)})),a=gl.lastIndex;return an;++n)s[(r=l[n]).i]=r.x(t);return s.join("")})}function _n(t,e){for(var r,n=co.interpolators.length;--n>=0&&!(r=co.interpolators[n](t,e)););return r}function wn(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;s>r;++r)n.push(_n(t[r],e[r]));for(;a>r;++r)i[r]=t[r];for(;o>r;++r)i[r]=e[r];return function(t){for(r=0;s>r;++r)i[r]=n[r](t);return i}}function kn(t){return function(e){return 0>=e?0:e>=1?1:t(e)}}function An(t){return function(e){return 1-t(1-e)}}function Mn(t){return function(e){return.5*(.5>e?t(2*e):2-t(2-2*e))}}function Tn(t){return t*t}function En(t){return t*t*t}function Ln(t){if(0>=t)return 0;if(t>=1)return 1;var e=t*t,r=e*t;return 4*(.5>t?r:3*(t-e)+r-.75)}function Sn(t){return function(e){return Math.pow(e,t)}}function Cn(t){return 1-Math.cos(t*Ho)}function zn(t){return Math.pow(2,10*(t-1))}function Pn(t){return 1-Math.sqrt(1-t*t)}function Rn(t,e){var r;return arguments.length<2&&(e=.45),arguments.length?r=e/Vo*Math.asin(1/t):(t=1,r=e/4),function(n){return 1+t*Math.pow(2,-10*n)*Math.sin((n-r)*Vo/e)}}function On(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function In(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Nn(t,e){t=co.hcl(t),e=co.hcl(e);var r=t.h,n=t.c,i=t.l,a=e.h-r,o=e.c-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.c:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ht(r+a*t,n+o*t,i+s*t)+""}}function jn(t,e){t=co.hsl(t),e=co.hsl(e);var r=t.h,n=t.s,i=t.l,a=e.h-r,o=e.s-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.s:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ut(r+a*t,n+o*t,i+s*t)+""}}function Fn(t,e){t=co.lab(t),e=co.lab(e);var r=t.l,n=t.a,i=t.b,a=e.l-r,o=e.a-n,s=e.b-i;return function(t){return pt(r+a*t,n+o*t,i+s*t)+""}}function Bn(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function Dn(t){var e=[t.a,t.b],r=[t.c,t.d],n=Vn(e),i=Un(e,r),a=Vn(qn(r,e,-i))||0;e[0]*r[1]180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(Hn(r)+"rotate(",null,")")-2,x:bn(t,e)})):e&&r.push(Hn(r)+"rotate("+e+")")}function Xn(t,e,r,n){t!==e?n.push({i:r.push(Hn(r)+"skewX(",null,")")-2,x:bn(t,e)}):e&&r.push(Hn(r)+"skewX("+e+")")}function Wn(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(Hn(r)+"scale(",null,",",null,")");n.push({i:i-4,x:bn(t[0],e[0])},{i:i-2,x:bn(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(Hn(r)+"scale("+e+")")}function Zn(t,e){var r=[],n=[];return t=co.transform(t),e=co.transform(e),Gn(t.translate,e.translate,r,n),Yn(t.rotate,e.rotate,r,n),Xn(t.skew,e.skew,r,n),Wn(t.scale,e.scale,r,n),t=e=null,function(t){for(var e,i=-1,a=n.length;++i=0;)r.push(i[n])}function li(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++or;++r)(e=t[r][1])>i&&(n=r,i=e);return n}function bi(t){return t.reduce(xi,0)}function xi(t,e){return t+e[1]}function _i(t,e){return wi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wi(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function ki(t){return[co.min(t),co.max(t)]}function Ai(t,e){return t.value-e.value}function Mi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ti(t,e){t._pack_next=e,e._pack_prev=t}function Ei(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function Li(t){function e(t){u=Math.min(t.x-t.r,u),f=Math.max(t.x+t.r,f),h=Math.min(t.y-t.r,h),d=Math.max(t.y+t.r,d)}if((r=t.children)&&(c=r.length)){var r,n,i,a,o,s,l,c,u=1/0,f=-(1/0),h=1/0,d=-(1/0);if(r.forEach(Si),n=r[0],n.x=-n.r,n.y=0,e(n),c>1&&(i=r[1],i.x=i.r,i.y=0,e(i),c>2))for(a=r[2],Pi(n,i,a),e(a),Mi(n,a),n._pack_prev=a,Mi(a,i),i=n._pack_next,o=3;c>o;o++){Pi(n,i,a=r[o]);var p=0,g=1,v=1;for(s=i._pack_next;s!==i;s=s._pack_next,g++)if(Ei(s,a)){p=1;break}if(1==p)for(l=n._pack_prev;l!==s._pack_prev&&!Ei(l,a);l=l._pack_prev,v++);p?(v>g||g==v&&i.ro;o++)a=r[o],a.x-=m,a.y-=y,b=Math.max(b,a.r+Math.sqrt(a.x*a.x+a.y*a.y));t.r=b,r.forEach(Ci)}}function Si(t){t._pack_next=t._pack_prev=t}function Ci(t){delete t._pack_next,delete t._pack_prev}function zi(t,e,r,n){var i=t.children;if(t.x=e+=n*t.x,t.y=r+=n*t.y,t.r*=n,i)for(var a=-1,o=i.length;++a=0;)e=i[a],e.z+=r,e.m+=r,r+=e.s+(n+=e.c)}function Fi(t,e,r){return t.a.parent===e.parent?t.a:r}function Bi(t){return 1+co.max(t,function(t){return t.y})}function Di(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ui(t){var e=t.children;return e&&e.length?Ui(e[0]):t}function Vi(t){var e,r=t.children;return r&&(e=r.length)?Vi(r[e-1]):t}function qi(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Hi(t,e){var r=t.x+e[3],n=t.y+e[0],i=t.dx-e[1]-e[3],a=t.dy-e[0]-e[2];return 0>i&&(r+=i/2,i=0),0>a&&(n+=a/2,a=0),{x:r,y:n,dx:i,dy:a}}function Gi(t){var e=t[0],r=t[t.length-1];return r>e?[e,r]:[r,e]}function Yi(t){return t.rangeExtent?t.rangeExtent():Gi(t.range())}function Xi(t,e,r,n){var i=r(t[0],t[1]),a=n(e[0],e[1]);return function(t){return a(i(t))}}function Wi(t,e){var r,n=0,i=t.length-1,a=t[n],o=t[i];return a>o&&(r=n,n=i,i=r,r=a,a=o,o=r),t[n]=e.floor(a),t[i]=e.ceil(o),t}function Zi(t){return t?{floor:function(e){return Math.floor(e/t)*t},ceil:function(e){return Math.ceil(e/t)*t}}:Tl}function Ki(t,e,r,n){var i=[],a=[],o=0,s=Math.min(t.length,e.length)-1;for(t[s]2?Ki:Xi,l=n?Qn:Kn;return o=i(t,e,l,r),s=i(e,t,l,_n),a}function a(t){return o(t)}var o,s;return a.invert=function(t){return s(t)},a.domain=function(e){return arguments.length?(t=e.map(Number),i()):t},a.range=function(t){return arguments.length?(e=t,i()):e},a.rangeRound=function(t){return a.range(t).interpolate(Bn)},a.clamp=function(t){return arguments.length?(n=t,i()):n},a.interpolate=function(t){return arguments.length?(r=t,i()):r},a.ticks=function(e){return ea(t,e)},a.tickFormat=function(e,r){return ra(t,e,r)},a.nice=function(e){return Ji(t,e),i()},a.copy=function(){return Qi(t,e,r,n)},i()}function $i(t,e){return co.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ji(t,e){return Wi(t,Zi(ta(t,e)[2])),Wi(t,Zi(ta(t,e)[2])),t}function ta(t,e){null==e&&(e=10);var r=Gi(t),n=r[1]-r[0],i=Math.pow(10,Math.floor(Math.log(n/e)/Math.LN10)),a=e/n*i;return.15>=a?i*=10:.35>=a?i*=5:.75>=a&&(i*=2),r[0]=Math.ceil(r[0]/i)*i,r[1]=Math.floor(r[1]/i)*i+.5*i,r[2]=i,r}function ea(t,e){return co.range.apply(co,ta(t,e))}function ra(t,e,r){var n=ta(t,e);if(r){var i=ps.exec(r);if(i.shift(),"s"===i[8]){var a=co.formatPrefix(Math.max(wo(n[0]),wo(n[1])));return i[7]||(i[7]="."+na(a.scale(n[2]))),i[8]="f",r=co.format(i.join("")),function(t){return r(a.scale(t))+a.symbol}}i[7]||(i[7]="."+ia(i[8],n)),r=i.join("")}else r=",."+na(n[2])+"f";return co.format(r)}function na(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ia(t,e){var r=na(e[2]);return t in El?Math.abs(r-na(Math.max(wo(e[0]),wo(e[1]))))+ +("e"!==t):r-2*("%"===t)}function aa(t,e,r,n){function i(t){return(r?Math.log(0>t?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function a(t){return r?Math.pow(e,t):-Math.pow(e,-t)}function o(e){return t(i(e))}return o.invert=function(e){return a(t.invert(e))},o.domain=function(e){return arguments.length?(r=e[0]>=0,t.domain((n=e.map(Number)).map(i)),o):n},o.base=function(r){return arguments.length?(e=+r,t.domain(n.map(i)),o):e},o.nice=function(){var e=Wi(n.map(i),r?Math:Sl);return t.domain(e),n=e.map(a),o},o.ticks=function(){var t=Gi(n),o=[],s=t[0],l=t[1],c=Math.floor(i(s)),u=Math.ceil(i(l)),f=e%1?2:e;if(isFinite(u-c)){if(r){for(;u>c;c++)for(var h=1;f>h;h++)o.push(a(c)*h);o.push(a(c))}else for(o.push(a(c));c++0;h--)o.push(a(c)*h);for(c=0;o[c]l;u--);o=o.slice(c,u)}return o},o.tickFormat=function(t,r){if(!arguments.length)return Ll;arguments.length<2?r=Ll:"function"!=typeof r&&(r=co.format(r));var n=Math.max(1,e*t/o.ticks().length);return function(t){var o=t/a(Math.round(i(t)));return e-.5>o*e&&(o*=e),n>=o?r(t):""}},o.copy=function(){return aa(t.copy(),e,r,n)},$i(o,t)}function oa(t,e,r){function n(e){return t(i(e))}var i=sa(e),a=sa(1/e);return n.invert=function(e){return a(t.invert(e))},n.domain=function(e){return arguments.length?(t.domain((r=e.map(Number)).map(i)),n):r},n.ticks=function(t){return ea(r,t)},n.tickFormat=function(t,e){return ra(r,t,e)},n.nice=function(t){return n.domain(Ji(r,t))},n.exponent=function(o){return arguments.length?(i=sa(e=o),a=sa(1/e),t.domain(r.map(i)),n):e},n.copy=function(){return oa(t.copy(),e,r)},$i(n,t)}function sa(t){return function(e){return 0>e?-Math.pow(-e,t):Math.pow(e,t)}}function la(t,e){function r(r){return a[((i.get(r)||("range"===e.t?i.set(r,t.push(r)):NaN))-1)%a.length]}function n(e,r){return co.range(t.length).map(function(t){return e+r*t})}var i,a,o;return r.domain=function(n){if(!arguments.length)return t;t=[],i=new f;for(var a,o=-1,s=n.length;++or?[NaN,NaN]:[r>0?s[r-1]:t[0],re?NaN:e/a+t,[e,e+1/a]},n.copy=function(){return ua(t,e,r)},i()}function fa(t,e){function r(r){return r>=r?e[co.bisect(t,r)]:void 0}return r.domain=function(e){return arguments.length?(t=e,r):t},r.range=function(t){return arguments.length?(e=t,r):e},r.invertExtent=function(r){return r=e.indexOf(r),[t[r-1],t[r]]},r.copy=function(){return fa(t,e)},r}function ha(t){function e(t){return+t}return e.invert=e,e.domain=e.range=function(r){return arguments.length?(t=r.map(e),e):t},e.ticks=function(e){return ea(t,e)},e.tickFormat=function(e,r){return ra(t,e,r)},e.copy=function(){return ha(t)},e}function da(){return 0}function pa(t){return t.innerRadius}function ga(t){return t.outerRadius}function va(t){return t.startAngle}function ma(t){return t.endAngle}function ya(t){return t&&t.padAngle}function ba(t,e,r,n){return(t-r)*e-(e-n)*t>0?0:1}function xa(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,c=-s*a,u=t[0]+l,f=t[1]+c,h=e[0]+l,d=e[1]+c,p=(u+h)/2,g=(f+d)/2,v=h-u,m=d-f,y=v*v+m*m,b=r-n,x=u*d-h*f,_=(0>m?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*m-v*_)/y,k=(-x*v-m*_)/y,A=(x*m+v*_)/y,M=(-x*v+m*_)/y,T=w-p,E=k-g,L=A-p,S=M-g;return T*T+E*E>L*L+S*S&&(w=A,k=M),[[w-l,k-c],[w*r/b,k*r/b]]}function _a(t){function e(e){function o(){c.push("M",a(t(u),s))}for(var l,c=[],u=[],f=-1,h=e.length,d=Lt(r),p=Lt(n);++f1?t.join("L"):t+"Z"}function ka(t){return t.join("L")+"Z"}function Aa(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1&&i.push("H",n[0]),i.join("")}function Ma(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var c=2;c9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));for(s=-1;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}function Ua(t){return t.length<3?wa(t):t[0]+Ca(t,Da(t))}function Va(t){for(var e,r,n,i=-1,a=t.length;++i=e?o(t-e):void(c.c=o)}function o(r){var i=p.active,a=p[i];a&&(a.timer.c=null,a.timer.t=NaN,--p.count,delete p[i],a.event&&a.event.interrupt.call(t,t.__data__,a.index));for(var o in p)if(n>+o){var f=p[o];f.timer.c=null,f.timer.t=NaN,--p.count,delete p[o]}c.c=s,Rt(function(){return c.c&&s(r||1)&&(c.c=null,c.t=NaN),1},0,l),p.active=n,g.event&&g.event.start.call(t,t.__data__,e),d=[],g.tween.forEach(function(r,n){(n=n.call(t,t.__data__,e))&&d.push(n)}),h=g.ease,u=g.duration}function s(i){for(var a=i/u,o=h(a),s=d.length;s>0;)d[--s].call(t,o);return a>=1?(g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[n]:delete t[r],1):void 0}var l,c,u,h,d,p=t[r]||(t[r]={active:0,count:0}),g=p[n];g||(l=i.time,c=Rt(a,0,l),g=p[n]={tween:new f,time:l,timer:c,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++p.count)}function ro(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate("+(isFinite(n)?n:r(t))+",0)"})}function no(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate(0,"+(isFinite(n)?n:r(t))+")"})}function io(t){return t.toISOString()}function ao(t,e,r){function n(e){return t(e)}function i(t,r){var n=t[1]-t[0],i=n/r,a=co.bisect(tc,i);return a==tc.length?[e.year,ta(t.map(function(t){return t/31536e6}),r)[2]]:a?e[i/tc[a-1]1?{floor:function(e){for(;r(e=t.floor(e));)e=oo(e-1);return e},ceil:function(e){for(;r(e=t.ceil(e));)e=oo(+e+1);return e}}:t))},n.ticks=function(t,e){var r=Gi(n.domain()),a=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return a&&(t=a[0],e=a[1]),t.range(r[0],oo(+r[1]+1),1>e?1:e)},n.tickFormat=function(){return r},n.copy=function(){return ao(t.copy(),e,r)},$i(n,t)}function oo(t){return new Date(t)}function so(t){return JSON.parse(t.responseText)}function lo(t){var e=ho.createRange();return e.selectNode(ho.body),e.createContextualFragment(t.responseText)}var co={version:"3.5.17"},uo=[].slice,fo=function(t){return uo.call(t)},ho=this.document;if(ho)try{fo(ho.documentElement.childNodes)[0].nodeType}catch(po){fo=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),ho)try{ho.createElement("DIV").style.setProperty("opacity",0,"")}catch(go){var vo=this.Element.prototype,mo=vo.setAttribute,yo=vo.setAttributeNS,bo=this.CSSStyleDeclaration.prototype,xo=bo.setProperty;vo.setAttribute=function(t,e){mo.call(this,t,e+"")},vo.setAttributeNS=function(t,e,r){yo.call(this,t,e,r+"")},bo.setProperty=function(t,e,r){xo.call(this,t,e+"",r)}}co.ascending=i,co.descending=function(t,e){return t>e?-1:e>t?1:e>=t?0:NaN},co.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},co.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},co.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}else{for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}return[r,i]},co.sum=function(t,e){var r,n=0,i=t.length,a=-1;if(1===arguments.length)for(;++a1?l/(u-1):void 0},co.deviation=function(){var t=co.variance.apply(this,arguments);return t?Math.sqrt(t):t};var _o=s(i);co.bisectLeft=_o.left,co.bisect=co.bisectRight=_o.right,co.bisector=function(t){return s(1===t.length?function(e,r){return i(t(e),r)}:t)},co.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,2>a&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},co.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},co.pairs=function(t){for(var e,r=0,n=t.length-1,i=t[0],a=new Array(0>n?0:n);n>r;)a[r]=[e=i,i=t[++r]];return a},co.transpose=function(t){if(!(i=t.length))return[];for(var e=-1,r=co.min(t,l),n=new Array(r);++e=0;)for(n=t[i],e=n.length;--e>=0;)r[--o]=n[e];return r};var wo=Math.abs;co.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r===1/0)throw new Error("infinite range");var n,i=[],a=c(wo(r)),o=-1;if(t*=a,e*=a,r*=a,0>r)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=a.length)return n?n.call(i,o):r?o.sort(r):o;for(var l,c,u,h,d=-1,p=o.length,g=a[s++],v=new f;++d=a.length)return t;var n=[],i=o[r++];return t.forEach(function(t,i){n.push({key:t,values:e(i,r)})}),i?n.sort(function(t,e){return i(t.key,e.key)}):n}var r,n,i={},a=[],o=[];return i.map=function(e,r){return t(r,e,0)},i.entries=function(r){return e(t(co.map,r,0),0)},i.key=function(t){return a.push(t),i},i.sortKeys=function(t){return o[a.length-1]=t,i},i.sortValues=function(t){return r=t,i},i.rollup=function(t){return n=t,i},i},co.set=function(t){var e=new b;if(t)for(var r=0,n=t.length;n>r;++r)e.add(t[r]);return e},u(b,{has:p,add:function(t){return this._[h(t+="")]=!0,t},remove:g,values:v,size:m,empty:y,forEach:function(t){for(var e in this._)t.call(this,d(e))}}),co.behavior={},co.rebind=function(t,e){for(var r,n=1,i=arguments.length;++n=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},co.event=null,co.requote=function(t){return t.replace(To,"\\$&")};var To=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Eo={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]},Lo=function(t,e){return e.querySelector(t)},So=function(t,e){return e.querySelectorAll(t)},Co=function(t,e){var r=t.matches||t[w(t,"matchesSelector")];return(Co=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(Lo=function(t,e){return Sizzle(t,e)[0]||null},So=Sizzle,Co=Sizzle.matchesSelector),co.selection=function(){return co.select(ho.documentElement)};var zo=co.selection.prototype=[];zo.select=function(t){var e,r,n,i,a=[];t=C(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Ro.hasOwnProperty(r)?{space:Ro[r],local:t}:t}},zo.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node();return t=co.ns.qualify(t),t.local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}for(e in t)this.each(P(e,t[e]));return this}return this.each(P(t,e))},zo.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=I(t)).length,i=-1;if(e=r.classList){for(;++ii){if("string"!=typeof t){2>i&&(e="");for(r in t)this.each(F(r,t[r],e));return this}if(2>i){var a=this.node();return n(a).getComputedStyle(a,null).getPropertyValue(t)}r=""}return this.each(F(t,e,r))},zo.property=function(t,e){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(e in t)this.each(B(e,t[e]));return this}return this.each(B(t,e))},zo.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},zo.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},zo.append=function(t){return t=D(t),this.select(function(){return this.appendChild(t.apply(this,arguments))})},zo.insert=function(t,e){return t=D(t),e=C(e),this.select(function(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)})},zo.remove=function(){return this.each(U)},zo.data=function(t,e){function r(t,r){var n,i,a,o=t.length,u=r.length,h=Math.min(o,u),d=new Array(u),p=new Array(u),g=new Array(o);if(e){var v,m=new f,y=new Array(o);for(n=-1;++nn;++n)p[n]=V(r[n]);for(;o>n;++n)g[n]=t[n]}p.update=d,p.parentNode=d.parentNode=g.parentNode=t.parentNode,s.push(p),l.push(d),c.push(g)}var n,i,a=-1,o=this.length;if(!arguments.length){for(t=new Array(o=(n=this[0]).length);++aa;a++){i.push(e=[]),e.parentNode=(r=this[a]).parentNode;for(var s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return S(i)},zo.order=function(){for(var t=-1,e=this.length;++t=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},zo.sort=function(t){t=H.apply(this,arguments);for(var e=-1,r=this.length;++et;t++)for(var r=this[t],n=0,i=r.length;i>n;n++){var a=r[n];if(a)return a}return null},zo.size=function(){var t=0;return G(this,function(){++t}),t};var Oo=[];co.selection.enter=Y,co.selection.enter.prototype=Oo,Oo.append=zo.append,Oo.empty=zo.empty,Oo.node=zo.node,Oo.call=zo.call,Oo.size=zo.size,Oo.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++sn){if("string"!=typeof t){2>n&&(e=!1);for(r in t)this.each(W(r,t[r],e));return this}if(2>n)return(n=this.node()["__on"+t])&&n._;r=!1}return this.each(W(t,e,r))};var Io=co.map({mouseenter:"mouseover",mouseleave:"mouseout"});ho&&Io.forEach(function(t){"on"+t in ho&&Io.remove(t)});var No,jo=0;co.mouse=function(t){return $(t,E())};var Fo=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;co.touch=function(t,e,r){if(arguments.length<3&&(r=e,e=E().changedTouches),e)for(var n,i=0,a=e.length;a>i;++i)if((n=e[i]).identifier===r)return $(t,n)},co.behavior.drag=function(){function t(){this.on("mousedown.drag",a).on("touchstart.drag",o)}function e(t,e,n,a,o){return function(){function s(){var t,r,n=e(h,g);n&&(t=n[0]-b[0],r=n[1]-b[1],p|=t|r,b=n,d({type:"drag",x:n[0]+c[0],y:n[1]+c[1],dx:t,dy:r}))}function l(){e(h,g)&&(m.on(a+v,null).on(o+v,null),y(p),d({type:"dragend"}))}var c,u=this,f=co.event.target.correspondingElement||co.event.target,h=u.parentNode,d=r.of(u,arguments),p=0,g=t(),v=".drag"+(null==g?"":"-"+g),m=co.select(n(f)).on(a+v,s).on(o+v,l),y=Q(f),b=e(h,g);i?(c=i.apply(u,arguments),c=[c.x-b[0],c.y-b[1]]):c=[0,0],d({type:"dragstart"})}}var r=L(t,"drag","dragstart","dragend"),i=null,a=e(k,co.mouse,n,"mousemove","mouseup"),o=e(J,co.touch,x,"touchmove","touchend");return t.origin=function(e){return arguments.length?(i=e,t):i},co.rebind(t,r,"on")},co.touches=function(t,e){return arguments.length<2&&(e=E().touches),e?fo(e).map(function(e){var r=$(t,e);return r.identifier=e.identifier,r}):[]};var Bo=1e-6,Do=Bo*Bo,Uo=Math.PI,Vo=2*Uo,qo=Vo-Bo,Ho=Uo/2,Go=Uo/180,Yo=180/Uo,Xo=Math.SQRT2,Wo=2,Zo=4;co.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],c=e[2],u=s-i,f=l-a,h=u*u+f*f;if(Do>h)n=Math.log(c/o)/Xo,r=function(t){return[i+t*u,a+t*f,o*Math.exp(Xo*t*n)]};else{var d=Math.sqrt(h),p=(c*c-o*o+Zo*h)/(2*o*Wo*d),g=(c*c-o*o-Zo*h)/(2*c*Wo*d),v=Math.log(Math.sqrt(p*p+1)-p),m=Math.log(Math.sqrt(g*g+1)-g);n=(m-v)/Xo,r=function(t){var e=t*n,r=at(v),s=o/(Wo*d)*(r*ot(Xo*e+v)-it(v));return[i+s*u,a+s*f,o*r/at(Xo*e+v)]}}return r.duration=1e3*n,r},co.behavior.zoom=function(){function t(t){t.on(z,f).on(Qo+".zoom",d).on("dblclick.zoom",p).on(O,h)}function e(t){return[(t[0]-A.x)/A.k,(t[1]-A.y)/A.k]}function r(t){return[t[0]*A.k+A.x,t[1]*A.k+A.y]}function i(t){A.k=Math.max(E[0],Math.min(E[1],t))}function a(t,e){e=r(e),A.x+=t[0]-e[0],A.y+=t[1]-e[1]}function o(e,r,n,o){e.__chart__={x:A.x,y:A.y,k:A.k},i(Math.pow(2,o)),a(v=r,n),e=co.select(e),S>0&&(e=e.transition().duration(S)),e.call(t.event)}function s(){_&&_.domain(x.range().map(function(t){return(t-A.x)/A.k}).map(x.invert)),k&&k.domain(w.range().map(function(t){return(t-A.y)/A.k}).map(w.invert))}function l(t){C++||t({type:"zoomstart"})}function c(t){s(),t({type:"zoom",scale:A.k,translate:[A.x,A.y]})}function u(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){s=1,a(co.mouse(i),h),c(o)}function r(){f.on(P,null).on(R,null),d(s),u(o)}var i=this,o=I.of(i,arguments),s=0,f=co.select(n(i)).on(P,t).on(R,r),h=e(co.mouse(i)),d=Q(i);Hl.call(i),l(o)}function h(){function t(){var t=co.touches(p);return d=A.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function r(){var e=co.event.target;co.select(e).on(x,n).on(_,s),w.push(e);for(var r=co.event.changedTouches,i=0,a=r.length;a>i;++i)v[r[i].identifier]=null;var l=t(),c=Date.now();if(1===l.length){if(500>c-b){var u=l[0];o(p,u,v[u.identifier],Math.floor(Math.log(A.k)/Math.LN2)+1),T()}b=c}else if(l.length>1){var u=l[0],f=l[1],h=u[0]-f[0],d=u[1]-f[1];m=h*h+d*d}}function n(){var t,e,r,n,o=co.touches(p);Hl.call(p);for(var s=0,l=o.length;l>s;++s,n=null)if(r=o[s],n=v[r.identifier]){if(e)break;t=r,e=n}if(n){var u=(u=r[0]-t[0])*u+(u=r[1]-t[1])*u,f=m&&Math.sqrt(u/m);t=[(t[0]+r[0])/2,(t[1]+r[1])/2],e=[(e[0]+n[0])/2,(e[1]+n[1])/2],i(f*d)}b=null,a(t,e),c(g)}function s(){if(co.event.touches.length){for(var e=co.event.changedTouches,r=0,n=e.length;n>r;++r)delete v[e[r].identifier];for(var i in v)return void t()}co.selectAll(w).on(y,null),k.on(z,f).on(O,h),M(),u(g)}var d,p=this,g=I.of(p,arguments),v={},m=0,y=".zoom-"+co.event.changedTouches[0].identifier,x="touchmove"+y,_="touchend"+y,w=[],k=co.select(p),M=Q(p);r(),l(g),k.on(z,null).on(O,r)}function d(){var t=I.of(this,arguments);y?clearTimeout(y):(Hl.call(this),g=e(v=m||co.mouse(this)),l(t)),y=setTimeout(function(){y=null,u(t)},50),T(),i(Math.pow(2,.002*Ko())*A.k),a(v,g),c(t)}function p(){var t=co.mouse(this),r=Math.log(A.k)/Math.LN2;o(this,t,e(t),co.event.shiftKey?Math.ceil(r)-1:Math.floor(r)+1)}var g,v,m,y,b,x,_,w,k,A={x:0,y:0,k:1},M=[960,500],E=$o,S=250,C=0,z="mousedown.zoom",P="mousemove.zoom",R="mouseup.zoom",O="touchstart.zoom",I=L(t,"zoomstart","zoom","zoomend");return Qo||(Qo="onwheel"in ho?(Ko=function(){return-co.event.deltaY*(co.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ho?(Ko=function(){return co.event.wheelDelta},"mousewheel"):(Ko=function(){return-co.event.detail},"MozMousePixelScroll")),t.event=function(t){t.each(function(){var t=I.of(this,arguments),e=A;Vl?co.select(this).transition().each("start.zoom",function(){A=this.__chart__||{x:0,y:0,k:1},l(t)}).tween("zoom:zoom",function(){var r=M[0],n=M[1],i=v?v[0]:r/2,a=v?v[1]:n/2,o=co.interpolateZoom([(i-A.x)/A.k,(a-A.y)/A.k,r/A.k],[(i-e.x)/e.k,(a-e.y)/e.k,r/e.k]);return function(e){var n=o(e),s=r/n[2];this.__chart__=A={x:i-n[0]*s,y:a-n[1]*s,k:s},c(t)}}).each("interrupt.zoom",function(){u(t)}).each("end.zoom",function(){u(t)}):(this.__chart__=A,l(t),c(t),u(t))})},t.translate=function(e){return arguments.length?(A={x:+e[0],y:+e[1],k:A.k},s(),t):[A.x,A.y]},t.scale=function(e){return arguments.length?(A={x:A.x,y:A.y,k:null},i(+e),s(),t):A.k},t.scaleExtent=function(e){return arguments.length?(E=null==e?$o:[+e[0],+e[1]],t):E},t.center=function(e){return arguments.length?(m=e&&[+e[0],+e[1]],t):m},t.size=function(e){return arguments.length?(M=e&&[+e[0],+e[1]],t):M},t.duration=function(e){return arguments.length?(S=+e,t):S},t.x=function(e){return arguments.length?(_=e,x=e.copy(),A={x:0,y:0,k:1},t):_},t.y=function(e){return arguments.length?(k=e,w=e.copy(),A={x:0,y:0,k:1},t):k},co.rebind(t,I,"on")};var Ko,Qo,$o=[0,1/0];co.color=lt,lt.prototype.toString=function(){return this.rgb()+""},co.hsl=ct;var Jo=ct.prototype=new lt;Jo.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,this.l/t)},Jo.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,t*this.l)},Jo.rgb=function(){return ut(this.h,this.s,this.l)},co.hcl=ft;var ts=ft.prototype=new lt;ts.brighter=function(t){return new ft(this.h,this.c,Math.min(100,this.l+es*(arguments.length?t:1)))},ts.darker=function(t){return new ft(this.h,this.c,Math.max(0,this.l-es*(arguments.length?t:1)))},ts.rgb=function(){return ht(this.h,this.c,this.l).rgb()},co.lab=dt;var es=18,rs=.95047,ns=1,is=1.08883,as=dt.prototype=new lt;as.brighter=function(t){return new dt(Math.min(100,this.l+es*(arguments.length?t:1)),this.a,this.b)},as.darker=function(t){return new dt(Math.max(0,this.l-es*(arguments.length?t:1)),this.a,this.b)},as.rgb=function(){return pt(this.l,this.a,this.b)},co.rgb=bt;var os=bt.prototype=new lt;os.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&i>e&&(e=i),r&&i>r&&(r=i),n&&i>n&&(n=i),new bt(Math.min(255,e/t),Math.min(255,r/t),Math.min(255,n/t))):new bt(i,i,i)},os.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new bt(t*this.r,t*this.g,t*this.b)},os.hsl=function(){return At(this.r,this.g,this.b)},os.toString=function(){return"#"+wt(this.r)+wt(this.g)+wt(this.b)};var ss=co.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ss.forEach(function(t,e){ss.set(t,xt(e))}),co.functor=Lt,co.xhr=St(x),co.dsv=function(t,e){function r(t,r,a){arguments.length<3&&(a=r,r=null);var o=Ct(t,e,null==r?n:i(r),a);return o.row=function(t){return arguments.length?o.response(null==(r=t)?n:i(t)):r},o}function n(t){return r.parse(t.responseText)}function i(t){return function(e){return r.parse(e.responseText,t)}}function a(e){return e.map(o).join(t)}function o(t){return s.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var s=new RegExp('["'+t+"\n]"),l=t.charCodeAt(0);return r.parse=function(t,e){var n;return r.parseRows(t,function(t,r){if(n)return n(t,r-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");n=e?function(t,r){return e(i(t),r)}:i})},r.parseRows=function(t,e){function r(){if(u>=c)return o;if(i)return i=!1,a;var e=u;if(34===t.charCodeAt(e)){for(var r=e;r++u;){var n=t.charCodeAt(u++),s=1;if(10===n)i=!0;else if(13===n)i=!0,10===t.charCodeAt(u)&&(++u,++s);else if(n!==l)continue;return t.slice(e,u-s)}return t.slice(e)}for(var n,i,a={},o={},s=[],c=t.length,u=0,f=0;(n=r())!==o;){for(var h=[];n!==a&&n!==o;)h.push(n),n=r();e&&null==(h=e(h,f++))||s.push(h)}return s},r.format=function(e){if(Array.isArray(e[0]))return r.formatRows(e);var n=new b,i=[];return e.forEach(function(t){for(var e in t)n.has(e)||i.push(n.add(e))}),[i.map(o).join(t)].concat(e.map(function(e){return i.map(function(t){return o(e[t])}).join(t)})).join("\n")},r.formatRows=function(t){return t.map(a).join("\n")},r},co.csv=co.dsv(",","text/csv"),co.tsv=co.dsv(" ","text/tab-separated-values");var ls,cs,us,fs,hs=this[w(this,"requestAnimationFrame")]||function(t){setTimeout(t,17)};co.timer=function(){Rt.apply(this,arguments)},co.timer.flush=function(){It(),Nt()},co.round=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)};var ds=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Ft);co.formatPrefix=function(t,e){var r=0;return(t=+t)&&(0>t&&(t*=-1),e&&(t=co.round(t,jt(t,e))),r=1+Math.floor(1e-12+Math.log(t)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),ds[8+r/3]};var ps=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,gs=co.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=co.round(t,jt(t,e))).toFixed(Math.max(0,Math.min(20,jt(t*(1+1e-15),e))))}}),vs=co.time={},ms=Date;Ut.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ys.setUTCDate.apply(this._,arguments)},setDay:function(){ys.setUTCDay.apply(this._,arguments)},setFullYear:function(){ys.setUTCFullYear.apply(this._,arguments)},setHours:function(){ys.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ys.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ys.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ys.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ys.setUTCSeconds.apply(this._,arguments)},setTime:function(){ys.setTime.apply(this._,arguments)}};var ys=Date.prototype;vs.year=Vt(function(t){return t=vs.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),vs.years=vs.year.range,vs.years.utc=vs.year.utc.range,vs.day=Vt(function(t){var e=new ms(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),vs.days=vs.day.range,vs.days.utc=vs.day.utc.range,vs.dayOfYear=function(t){var e=vs.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var r=vs[t]=Vt(function(t){return(t=vs.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)-(r!==e)});vs[t+"s"]=r.range,vs[t+"s"].utc=r.utc.range,vs[t+"OfYear"]=function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)}}),vs.week=vs.sunday,vs.weeks=vs.sunday.range,vs.weeks.utc=vs.sunday.utc.range,vs.weekOfYear=vs.sundayOfYear;var bs={"-":"",_:" ",0:"0"},xs=/^\s*\d+/,_s=/^%/;co.locale=function(t){return{numberFormat:Bt(t),timeFormat:Ht(t)}};var ws=co.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});co.format=ws.numberFormat,co.geo={},fe.prototype={s:0,t:0,add:function(t){he(t,this.t,ks),he(ks.s,this.s,this),this.s?this.t+=ks.t:this.s=ks.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ks=new fe;co.geo.stream=function(t,e){t&&As.hasOwnProperty(t.type)?As[t.type](t,e):de(t,e)};var As={Feature:function(t,e){de(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++nt?4*Uo+t:t,Ls.lineStart=Ls.lineEnd=Ls.point=k}};co.geo.bounds=function(){function t(t,e){b.push(x=[u=t,h=t]),f>e&&(f=e),e>d&&(d=e)}function e(e,r){var n=me([e*Go,r*Go]);if(m){var i=be(m,n),a=[i[1],-i[0],0],o=be(a,i);we(o),o=ke(o);var l=e-p,c=l>0?1:-1,g=o[0]*Yo*c,v=wo(l)>180;if(v^(g>c*p&&c*e>g)){var y=o[1]*Yo;y>d&&(d=y)}else if(g=(g+360)%360-180,v^(g>c*p&&c*e>g)){var y=-o[1]*Yo;f>y&&(f=y)}else f>r&&(f=r),r>d&&(d=r);v?p>e?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e):h>=u?(u>e&&(u=e),e>h&&(h=e)):e>p?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e)}else t(e,r);m=n,p=e}function r(){_.point=e}function n(){x[0]=u,x[1]=h,_.point=t,m=null}function i(t,r){if(m){var n=t-p;y+=wo(n)>180?n+(n>0?360:-360):n}else g=t,v=r;Ls.point(t,r),e(t,r)}function a(){Ls.lineStart()}function o(){i(g,v),Ls.lineEnd(),wo(y)>Bo&&(u=-(h=180)),x[0]=u,x[1]=h,m=null}function s(t,e){return(e-=t)<0?e+360:e}function l(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tEs?(u=-(h=180),f=-(d=90)):y>Bo?d=90:-Bo>y&&(f=-90),x[0]=u,x[1]=h}};return function(t){d=h=-(u=f=1/0),b=[],co.geo.stream(t,_);var e=b.length;if(e){b.sort(l);for(var r,n=1,i=b[0],a=[i];e>n;++n)r=b[n],c(r[0],i)||c(r[1],i)?(s(i[0],r[1])>s(i[0],i[1])&&(i[1]=r[1]),s(r[0],i[1])>s(i[0],i[1])&&(i[0]=r[0])):a.push(i=r);for(var o,r,p=-(1/0),e=a.length-1,n=0,i=a[e];e>=n;i=r,++n)r=a[n],(o=s(i[1],r[0]))>p&&(p=o,u=r[0],h=i[1])}return b=x=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[h,d]]}}(),co.geo.centroid=function(t){Ss=Cs=zs=Ps=Rs=Os=Is=Ns=js=Fs=Bs=0,co.geo.stream(t,Ds);var e=js,r=Fs,n=Bs,i=e*e+r*r+n*n;return Do>i&&(e=Os,r=Is,n=Ns,Bo>Cs&&(e=zs,r=Ps,n=Rs),i=e*e+r*r+n*n,Do>i)?[NaN,NaN]:[Math.atan2(r,e)*Yo,nt(n/Math.sqrt(i))*Yo]};var Ss,Cs,zs,Ps,Rs,Os,Is,Ns,js,Fs,Bs,Ds={sphere:k,point:Me,lineStart:Ee,lineEnd:Le,polygonStart:function(){Ds.lineStart=Se},polygonEnd:function(){Ds.lineStart=Ee}},Us=Ie(ze,Be,Ue,[-Uo,-Uo/2]),Vs=1e9;co.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),i=a(t),i.valid=!0,i},extent:function(s){return arguments.length?(a=Ge(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(co.geo.conicEqualArea=function(){return Ye(Xe)}).raw=Xe,co.geo.albers=function(){return co.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},co.geo.albersUsa=function(){function t(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}var e,r,n,i,a=co.geo.albers(),o=co.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=co.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};return t.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&.234>i&&n>=-.425&&-.214>n?o:i>=.166&&.234>i&&n>=-.214&&-.115>n?s:a).invert(t)},t.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},t.precision=function(e){return arguments.length?(a.precision(e),o.precision(e),s.precision(e),t):a.precision()},t.scale=function(e){return arguments.length?(a.scale(e),o.scale(.35*e),s.scale(e),t.translate(a.translate())):a.scale()},t.translate=function(e){if(!arguments.length)return a.translate();var c=a.scale(),u=+e[0],f=+e[1];return r=a.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(l).point,n=o.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+Bo,f+.12*c+Bo],[u-.214*c-Bo,f+.234*c-Bo]]).stream(l).point,i=s.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+Bo,f+.166*c+Bo],[u-.115*c-Bo,f+.234*c-Bo]]).stream(l).point,t},t.scale(1070)};var qs,Hs,Gs,Ys,Xs,Ws,Zs={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Hs=0,Zs.lineStart=We},polygonEnd:function(){Zs.lineStart=Zs.lineEnd=Zs.point=k,qs+=wo(Hs/2)}},Ks={point:Ze,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},Qs={point:$e,lineStart:Je,lineEnd:tr,polygonStart:function(){Qs.lineStart=er},polygonEnd:function(){Qs.point=$e,Qs.lineStart=Je,Qs.lineEnd=tr}};co.geo.path=function(){function t(t){return t&&("function"==typeof s&&a.pointRadius(+s.apply(this,arguments)),o&&o.valid||(o=i(a)),co.geo.stream(t,o)),a.result()}function e(){return o=null,t}var r,n,i,a,o,s=4.5;return t.area=function(t){return qs=0,co.geo.stream(t,i(Zs)),qs},t.centroid=function(t){return zs=Ps=Rs=Os=Is=Ns=js=Fs=Bs=0,co.geo.stream(t,i(Qs)),Bs?[js/Bs,Fs/Bs]:Ns?[Os/Ns,Is/Ns]:Rs?[zs/Rs,Ps/Rs]:[NaN,NaN]},t.bounds=function(t){return Xs=Ws=-(Gs=Ys=1/0),co.geo.stream(t,i(Ks)),[[Gs,Ys],[Xs,Ws]]},t.projection=function(t){return arguments.length?(i=(r=t)?t.stream||ir(t):x,e()):r},t.context=function(t){return arguments.length?(a=null==(n=t)?new Ke:new rr(t),"function"!=typeof s&&a.pointRadius(s),e()):n},t.pointRadius=function(e){return arguments.length?(s="function"==typeof e?e:(a.pointRadius(+e),+e),t):s},t.projection(co.geo.albersUsa()).context(null)},co.geo.transform=function(t){return{stream:function(e){var r=new ar(e);for(var n in t)r[n]=t[n];return r}}},ar.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},co.geo.projection=sr,co.geo.projectionMutator=lr,(co.geo.equirectangular=function(){return sr(ur)}).raw=ur.invert=ur,co.geo.rotation=function(t){function e(e){return e=t(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e}return t=hr(t[0]%360*Go,t[1]*Go,t.length>2?t[2]*Go:0),e.invert=function(e){return e=t.invert(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e},e},fr.invert=ur,co.geo.circle=function(){function t(){var t="function"==typeof n?n.apply(this,arguments):n,e=hr(-t[0]*Go,-t[1]*Go,0).invert,i=[];return r(null,null,1,{point:function(t,r){i.push(t=e(t,r)),t[0]*=Yo,t[1]*=Yo}}),{type:"Polygon",coordinates:[i]}}var e,r,n=[0,0],i=6;return t.origin=function(e){return arguments.length?(n=e,t):n},t.angle=function(n){return arguments.length?(r=vr((e=+n)*Go,i*Go),t):e},t.precision=function(n){return arguments.length?(r=vr(e*Go,(i=+n)*Go),t):i},t.angle(90)},co.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Go,i=t[1]*Go,a=e[1]*Go,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),c=Math.cos(i),u=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-l*f*s)*r),l*u+c*f*s)},co.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return co.range(Math.ceil(a/v)*v,i,v).map(h).concat(co.range(Math.ceil(c/m)*m,l,m).map(d)).concat(co.range(Math.ceil(n/p)*p,r,p).filter(function(t){return wo(t%v)>Bo}).map(u)).concat(co.range(Math.ceil(s/g)*g,o,g).filter(function(t){return wo(t%m)>Bo}).map(f))}var r,n,i,a,o,s,l,c,u,f,h,d,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[h(a).concat(d(l).slice(1),h(i).reverse().slice(1),d(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(a=+e[0][0],i=+e[1][0],c=+e[0][1],l=+e[1][1],a>i&&(e=a,a=i,i=e),c>l&&(e=c,c=l,l=e),t.precision(y)):[[a,c],[i,l]]},t.minorExtent=function(e){return arguments.length?(n=+e[0][0],r=+e[1][0],s=+e[0][1],o=+e[1][1],n>r&&(e=n,n=r,r=e),s>o&&(e=s,s=o,o=e),t.precision(y)):[[n,s],[r,o]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=yr(s,o,90),f=br(n,r,y),h=yr(c,l,90),d=br(a,i,y),t):y},t.majorExtent([[-180,-90+Bo],[180,90-Bo]]).minorExtent([[-180,-80-Bo],[180,80+Bo]])},co.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}var e,r,n=xr,i=_r;return t.distance=function(){return co.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},t.source=function(r){return arguments.length?(n=r,e="function"==typeof r?null:r,t):n},t.target=function(e){return arguments.length?(i=e,r="function"==typeof e?null:e,t):i},t.precision=function(){return arguments.length?t:0},t},co.geo.interpolate=function(t,e){return wr(t[0]*Go,t[1]*Go,e[0]*Go,e[1]*Go)},co.geo.length=function(t){return $s=0,co.geo.stream(t,Js),$s};var $s,Js={sphere:k,point:k,lineStart:kr,lineEnd:k,polygonStart:k,polygonEnd:k},tl=Ar(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(co.geo.azimuthalEqualArea=function(){return sr(tl)}).raw=tl;var el=Ar(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},x);(co.geo.azimuthalEquidistant=function(){return sr(el)}).raw=el,(co.geo.conicConformal=function(){return Ye(Mr)}).raw=Mr,(co.geo.conicEquidistant=function(){return Ye(Tr)}).raw=Tr;var rl=Ar(function(t){return 1/t},Math.atan);(co.geo.gnomonic=function(){return sr(rl)}).raw=rl,Er.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Ho]},(co.geo.mercator=function(){return Lr(Er)}).raw=Er;var nl=Ar(function(){return 1},Math.asin);(co.geo.orthographic=function(){return sr(nl)}).raw=nl;var il=Ar(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(co.geo.stereographic=function(){return sr(il)}).raw=il,Sr.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ho]},(co.geo.transverseMercator=function(){var t=Lr(Sr),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):(t=r(),[t[0],t[1],t[2]-90])},r([0,0,90])}).raw=Sr,co.geom={},co.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,i=Lt(r),a=Lt(n),o=t.length,s=[],l=[];for(e=0;o>e;e++)s.push([+i.call(this,t[e],e),+a.call(this,t[e],e),e]);for(s.sort(Rr),e=0;o>e;e++)l.push([s[e][0],-s[e][1]]);var c=Pr(s),u=Pr(l),f=u[0]===c[0],h=u[u.length-1]===c[c.length-1],d=[];for(e=c.length-1;e>=0;--e)d.push(t[s[c[e]][2]]);for(e=+f;e=n&&c.x<=a&&c.y>=i&&c.y<=o?[[n,o],[a,o],[a,i],[n,i]]:[];u.point=t[s]}),e}function r(t){return t.map(function(t,e){return{x:Math.round(a(t,e)/Bo)*Bo,y:Math.round(o(t,e)/Bo)*Bo,i:e}})}var n=Cr,i=zr,a=n,o=i,s=dl;return t?e(t):(e.links=function(t){return cn(r(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cn(r(t)).cells.forEach(function(r,n){for(var i,a,o=r.site,s=r.edges.sort(Yr),l=-1,c=s.length,u=s[c-1].edge,f=u.l===o?u.r:u.l;++l=c,h=n>=u,d=h<<1|f;t.leaf=!1,t=t.nodes[d]||(t.nodes[d]=pn()),f?i=c:s=c,h?o=u:l=u,a(t,e,r,n,i,o,s,l)}var u,f,h,d,p,g,v,m,y,b=Lt(s),x=Lt(l);if(null!=e)g=e,v=r,m=n,y=i;else if(m=y=-(g=v=1/0),f=[],h=[],p=t.length,o)for(d=0;p>d;++d)u=t[d],u.xm&&(m=u.x),u.y>y&&(y=u.y),f.push(u.x),h.push(u.y);else for(d=0;p>d;++d){var _=+b(u=t[d],d),w=+x(u,d);g>_&&(g=_),v>w&&(v=w),_>m&&(m=_),w>y&&(y=w),f.push(_),h.push(w)}var k=m-g,A=y-v;k>A?y=v+k:m=g+A;var M=pn();if(M.add=function(t){a(M,t,+b(t,++d),+x(t,d),g,v,m,y)},M.visit=function(t){gn(t,M,g,v,m,y)},M.find=function(t){return vn(M,t[0],t[1],g,v,m,y)},d=-1,null==e){for(;++d=0?t.slice(0,e):t,n=e>=0?t.slice(e+1):"in";return r=ml.get(r)||vl,n=yl.get(n)||x,kn(n(r.apply(null,uo.call(arguments,1))))},co.interpolateHcl=Nn,co.interpolateHsl=jn,co.interpolateLab=Fn,co.interpolateRound=Bn,co.transform=function(t){var e=ho.createElementNS(co.ns.prefix.svg,"g");return(co.transform=function(t){if(null!=t){e.setAttribute("transform",t);var r=e.transform.baseVal.consolidate()}return new Dn(r?r.matrix:bl)})(t)},Dn.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var bl={a:1,b:0,c:0,d:1,e:0,f:0};co.interpolateTransform=Zn,co.layout={},co.layout.bundle=function(){return function(t){for(var e=[],r=-1,n=t.length;++rs*s/m){if(g>l){var c=e.charge/l;t.px-=a*c,t.py-=o*c}return!0}if(e.point&&l&&g>l){var c=e.pointCharge/l;t.px-=a*c,t.py-=o*c}}return!e.charge}}function e(t){t.px=co.event.x,t.py=co.event.y,l.resume()}var r,n,i,a,o,s,l={},c=co.dispatch("start","tick","end"),u=[1,1],f=.9,h=xl,d=_l,p=-30,g=wl,v=.1,m=.64,y=[],b=[];return l.tick=function(){if((i*=.99)<.005)return r=null,c.end({type:"end",alpha:i=0}),!0;var e,n,l,h,d,g,m,x,_,w=y.length,k=b.length;for(n=0;k>n;++n)l=b[n],h=l.source,d=l.target,x=d.x-h.x,_=d.y-h.y,(g=x*x+_*_)&&(g=i*o[n]*((g=Math.sqrt(g))-a[n])/g,x*=g,_*=g,d.x-=x*(m=h.weight+d.weight?h.weight/(h.weight+d.weight):.5),d.y-=_*m,h.x+=x*(m=1-m),h.y+=_*m);if((m=i*v)&&(x=u[0]/2,_=u[1]/2,n=-1,m))for(;++n0?i=t:(r.c=null,r.t=NaN,r=null,c.end({type:"end",alpha:i=0})):t>0&&(c.start({type:"start",alpha:i=t}),r=Rt(l.tick)),l):i},l.start=function(){function t(t,n){if(!r){for(r=new Array(i),l=0;i>l;++l)r[l]=[];for(l=0;c>l;++l){var a=b[l];r[a.source.index].push(a.target),r[a.target.index].push(a.source)}}for(var o,s=r[e],l=-1,u=s.length;++le;++e)(n=y[e]).index=e,n.weight=0;for(e=0;c>e;++e)n=b[e],"number"==typeof n.source&&(n.source=y[n.source]),"number"==typeof n.target&&(n.target=y[n.target]),++n.source.weight,++n.target.weight;for(e=0;i>e;++e)n=y[e],isNaN(n.x)&&(n.x=t("x",f)),isNaN(n.y)&&(n.y=t("y",g)),isNaN(n.px)&&(n.px=n.x),isNaN(n.py)&&(n.py=n.y);if(a=[],"function"==typeof h)for(e=0;c>e;++e)a[e]=+h.call(this,b[e],e);else for(e=0;c>e;++e)a[e]=h;if(o=[],"function"==typeof d)for(e=0;c>e;++e)o[e]=+d.call(this,b[e],e);else for(e=0;c>e;++e)o[e]=d;if(s=[],"function"==typeof p)for(e=0;i>e;++e)s[e]=+p.call(this,y[e],e);else for(e=0;i>e;++e)s[e]=p;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return n||(n=co.behavior.drag().origin(x).on("dragstart.force",ei).on("drag.force",e).on("dragend.force",ri)),arguments.length?void this.on("mouseover.force",ni).on("mouseout.force",ii).call(n):n},co.rebind(l,c,"on")};var xl=20,_l=1,wl=1/0;co.layout.hierarchy=function(){function t(i){var a,o=[i],s=[];for(i.depth=0;null!=(a=o.pop());)if(s.push(a),(c=r.call(t,a,a.depth))&&(l=c.length)){for(var l,c,u;--l>=0;)o.push(u=c[l]),u.parent=a,u.depth=a.depth+1;n&&(a.value=0),a.children=c}else n&&(a.value=+n.call(t,a,a.depth)||0),delete a.children;return li(i,function(t){var r,i;e&&(r=t.children)&&r.sort(e),n&&(i=t.parent)&&(i.value+=t.value)}),s}var e=fi,r=ci,n=ui;return t.sort=function(r){return arguments.length?(e=r,t):e},t.children=function(e){return arguments.length?(r=e,t):r},t.value=function(e){return arguments.length?(n=e,t):n},t.revalue=function(e){return n&&(si(e,function(t){t.children&&(t.value=0)}),li(e,function(e){var r;e.children||(e.value=+n.call(t,e,e.depth)||0),(r=e.parent)&&(r.value+=e.value)})),e},t},co.layout.partition=function(){function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,c=-1;for(n=e.value?n/e.value:0;++cf?-1:1),p=co.sum(c),g=p?(f-l*d)/p:0,v=co.range(l),m=[];return null!=r&&v.sort(r===kl?function(t,e){return c[e]-c[t]}:function(t,e){return r(o[t],o[e])}),v.forEach(function(t){m[t]={data:o[t],value:s=c[t],startAngle:u,endAngle:u+=s*g+d,padAngle:h}}),m}var e=Number,r=kl,n=0,i=Vo,a=0;return t.value=function(r){return arguments.length?(e=r,t):e},t.sort=function(e){return arguments.length?(r=e,t):r},t.startAngle=function(e){return arguments.length?(n=e,t):n},t.endAngle=function(e){return arguments.length?(i=e,t):i},t.padAngle=function(e){return arguments.length?(a=e,t):a},t};var kl={};co.layout.stack=function(){function t(s,l){if(!(h=s.length))return s;var c=s.map(function(r,n){return e.call(t,r,n)}),u=c.map(function(e){return e.map(function(e,r){return[a.call(t,e,r),o.call(t,e,r)]})}),f=r.call(t,u,l);c=co.permute(c,f),u=co.permute(u,f);var h,d,p,g,v=n.call(t,u,l),m=c[0].length;for(p=0;m>p;++p)for(i.call(t,c[0][p],g=v[p],u[0][p][1]),d=1;h>d;++d)i.call(t,c[d][p],g+=u[d-1][p][1],u[d][p][1]);return s}var e=x,r=vi,n=mi,i=gi,a=di,o=pi;return t.values=function(r){return arguments.length?(e=r,t):e},t.order=function(e){return arguments.length?(r="function"==typeof e?e:Al.get(e)||vi,t):r},t.offset=function(e){return arguments.length?(n="function"==typeof e?e:Ml.get(e)||mi,t):n},t.x=function(e){return arguments.length?(a=e,t):a},t.y=function(e){return arguments.length?(o=e,t):o},t.out=function(e){return arguments.length?(i=e,t):i},t};var Al=co.map({"inside-out":function(t){var e,r,n=t.length,i=t.map(yi),a=t.map(bi),o=co.range(n).sort(function(t,e){return i[t]-i[e]}),s=0,l=0,c=[],u=[];for(e=0;n>e;++e)r=o[e],l>s?(s+=a[r],c.push(r)):(l+=a[r],u.push(r));return u.reverse().concat(c)},reverse:function(t){return co.range(t.length).reverse()},"default":vi}),Ml=co.map({silhouette:function(t){var e,r,n,i=t.length,a=t[0].length,o=[],s=0,l=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];n>s&&(s=n),o.push(n)}for(r=0;a>r;++r)l[r]=(s-o[r])/2;return l},wiggle:function(t){var e,r,n,i,a,o,s,l,c,u=t.length,f=t[0],h=f.length,d=[];for(d[0]=l=c=0,r=1;h>r;++r){for(e=0,i=0;u>e;++e)i+=t[e][r][1];for(e=0,a=0,s=f[r][0]-f[r-1][0];u>e;++e){for(n=0,o=(t[e][r][1]-t[e][r-1][1])/(2*s);e>n;++n)o+=(t[n][r][1]-t[n][r-1][1])/s;a+=o*t[e][r][1]}d[r]=l-=i?a/i*s:0,c>l&&(c=l)}for(r=0;h>r;++r)d[r]-=c;return d},expand:function(t){var e,r,n,i=t.length,a=t[0].length,o=1/i,s=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];if(n)for(e=0;i>e;e++)t[e][r][1]/=n;else for(e=0;i>e;e++)t[e][r][1]=o}for(r=0;a>r;++r)s[r]=0;return s},zero:mi});co.layout.histogram=function(){function t(t,a){for(var o,s,l=[],c=t.map(r,this),u=n.call(this,c,a),f=i.call(this,u,c,a),a=-1,h=c.length,d=f.length-1,p=e?1:1/h;++a0)for(a=-1;++a=u[0]&&s<=u[1]&&(o=l[co.bisect(f,s,1,d)-1],o.y+=p,o.push(t[a]));return l}var e=!0,r=Number,n=ki,i=_i;return t.value=function(e){return arguments.length?(r=e,t):r},t.range=function(e){return arguments.length?(n=Lt(e),t):n},t.bins=function(e){return arguments.length?(i="number"==typeof e?function(t){return wi(t,e)}:Lt(e),t):i},t.frequency=function(r){return arguments.length?(e=!!r,t):e},t},co.layout.pack=function(){function t(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],c=i[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,li(s,function(t){t.r=+u(t.value)}),li(s,Li),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/c))/2;li(s,function(t){t.r+=f}),li(s,Li),li(s,function(t){t.r-=f})}return zi(s,l/2,c/2,e?1:1/Math.max(2*s.r/l,2*s.r/c)),o}var e,r=co.layout.hierarchy().sort(Ai),n=0,i=[1,1];return t.size=function(e){return arguments.length?(i=e,t):i},t.radius=function(r){return arguments.length?(e=null==r||"function"==typeof r?r:+r,t):e},t.padding=function(e){return arguments.length?(n=+e,t):n},oi(t,r)},co.layout.tree=function(){function t(t,i){var u=o.call(this,t,i),f=u[0],h=e(f);if(li(h,r),h.parent.m=-h.z,si(h,n),c)si(f,a);else{var d=f,p=f,g=f;si(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=s(d,p)/2-d.x,m=l[0]/(p.x+s(p,d)/2+v),y=l[1]/(g.depth||1);si(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return u}function e(t){for(var e,r={A:null,children:[t]},n=[r];null!=(e=n.pop());)for(var i,a=e.children,o=0,s=a.length;s>o;++o)n.push((a[o]=i={_:a[o],parent:e,children:(i=a[o].children)&&i.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=i);return r.children[0]}function r(t){var e=t.children,r=t.parent.children,n=t.i?r[t.i-1]:null;if(e.length){ji(t);var a=(e[0].z+e[e.length-1].z)/2;n?(t.z=n.z+s(t._,n._),t.m=t.z-a):t.z=a}else n&&(t.z=n.z+s(t._,n._));t.parent.A=i(t,n,t.parent.A||r[0])}function n(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function i(t,e,r){if(e){for(var n,i=t,a=t,o=e,l=i.parent.children[0],c=i.m,u=a.m,f=o.m,h=l.m;o=Ii(o),i=Oi(i),o&&i;)l=Oi(l),a=Ii(a),a.a=t,n=o.z+f-i.z-c+s(o._,i._),n>0&&(Ni(Fi(o,t,r),t,n),c+=n,u+=n),f+=o.m,c+=i.m,h+=l.m,u+=a.m;o&&!Ii(a)&&(a.t=o,a.m+=f-u),i&&!Oi(l)&&(l.t=i,l.m+=c-h,r=t)}return r}function a(t){t.x*=l[0],t.y=t.depth*l[1]}var o=co.layout.hierarchy().sort(null).value(null),s=Ri,l=[1,1],c=null;return t.separation=function(e){return arguments.length?(s=e,t):s},t.size=function(e){return arguments.length?(c=null==(l=e)?a:null,t):c?null:l},t.nodeSize=function(e){return arguments.length?(c=null==(l=e)?null:a,t):c?l:null},oi(t,o)},co.layout.cluster=function(){function t(t,a){var o,s=e.call(this,t,a),l=s[0],c=0;li(l,function(t){var e=t.children;e&&e.length?(t.x=Di(e),t.y=Bi(e)):(t.x=o?c+=r(t,o):0,t.y=0,o=t)});var u=Ui(l),f=Vi(l),h=u.x-r(u,f)/2,d=f.x+r(f,u)/2;return li(l,i?function(t){t.x=(t.x-l.x)*n[0],t.y=(l.y-t.y)*n[1]}:function(t){t.x=(t.x-h)/(d-h)*n[0],t.y=(1-(l.y?t.y/l.y:1))*n[1]}),s}var e=co.layout.hierarchy().sort(null).value(null),r=Ri,n=[1,1],i=!1;return t.separation=function(e){return arguments.length?(r=e,t):r},t.size=function(e){return arguments.length?(i=null==(n=e),t):i?null:n},t.nodeSize=function(e){return arguments.length?(i=null!=(n=e),t):i?n:null},oi(t,e)},co.layout.treemap=function(){function t(t,e){for(var r,n,i=-1,a=t.length;++ie?0:e),r.area=isNaN(n)||0>=n?0:n}function e(r){var a=r.children;if(a&&a.length){var o,s,l,c=f(r),u=[],h=a.slice(),p=1/0,g="slice"===d?c.dx:"dice"===d?c.dy:"slice-dice"===d?1&r.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(t(h,c.dx*c.dy/r.value),u.area=0;(l=h.length)>0;)u.push(o=h[l-1]),u.area+=o.area,"squarify"!==d||(s=n(u,g))<=p?(h.pop(),p=s):(u.area-=u.pop().area,i(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(i(u,g,c,!0),u.length=u.area=0),a.forEach(e)}}function r(e){var n=e.children;if(n&&n.length){var a,o=f(e),s=n.slice(),l=[];for(t(s,o.dx*o.dy/e.value),l.area=0;a=s.pop();)l.push(a),l.area+=a.area,null!=a.z&&(i(l,a.z?o.dx:o.dy,o,!s.length),l.length=l.area=0);n.forEach(r)}}function n(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++or&&(a=r),r>i&&(i=r));return n*=n,e*=e,n?Math.max(e*i*p/n,n/(e*a*p)):1/0}function i(t,e,r,n){var i,a=-1,o=t.length,s=r.x,c=r.y,u=e?l(t.area/e):0;if(e==r.dx){for((n||u>r.dy)&&(u=r.dy);++ar.dx)&&(u=r.dx);++ar&&(e=1),1>r&&(t=0),function(){var r,n,i;do r=2*Math.random()-1,n=2*Math.random()-1,i=r*r+n*n;while(!i||i>1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=co.random.normal.apply(co,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=co.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,r=0;t>r;r++)e+=Math.random();return e}}},co.scale={};var Tl={floor:x,ceil:x};co.scale.linear=function(){return Qi([0,1],[0,1],_n,!1)};var El={s:1,g:1,p:1,r:1,e:1};co.scale.log=function(){return aa(co.scale.linear().domain([0,1]),10,!0,[1,10])};var Ll=co.format(".0e"),Sl={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};co.scale.pow=function(){return oa(co.scale.linear(),1,[0,1])},co.scale.sqrt=function(){return co.scale.pow().exponent(.5)},co.scale.ordinal=function(){return la([],{t:"range",a:[[]]})},co.scale.category10=function(){return co.scale.ordinal().range(Cl)},co.scale.category20=function(){return co.scale.ordinal().range(zl)},co.scale.category20b=function(){return co.scale.ordinal().range(Pl)},co.scale.category20c=function(){return co.scale.ordinal().range(Rl)};var Cl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(_t),zl=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(_t),Pl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(_t),Rl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(_t);co.scale.quantile=function(){return ca([],[])},co.scale.quantize=function(){return ua(0,1,[0,1])},co.scale.threshold=function(){return fa([.5],[0,1])},co.scale.identity=function(){return ha([0,1])},co.svg={},co.svg.arc=function(){function t(){var t=Math.max(0,+r.apply(this,arguments)),c=Math.max(0,+n.apply(this,arguments)),u=o.apply(this,arguments)-Ho,f=s.apply(this,arguments)-Ho,h=Math.abs(f-u),d=u>f?0:1;if(t>c&&(p=c,c=t,t=p),h>=qo)return e(c,d)+(t?e(t,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,k,A,M,T=0,E=0,L=[];if((m=(+l.apply(this,arguments)||0)/2)&&(v=a===Ol?Math.sqrt(t*t+c*c):+a.apply(this,arguments),d||(E*=-1),c&&(E=nt(v/c*Math.sin(m))),t&&(T=nt(v/t*Math.sin(m)))),c){y=c*Math.cos(u+E),b=c*Math.sin(u+E),x=c*Math.cos(f-E),_=c*Math.sin(f-E);var S=Math.abs(f-u-2*E)<=Uo?0:1;if(E&&ba(y,b,x,_)===d^S){var C=(u+f)/2;y=c*Math.cos(C),b=c*Math.sin(C),x=_=null}}else y=b=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),A=t*Math.cos(u+T),M=t*Math.sin(u+T);var z=Math.abs(u-f+2*T)<=Uo?0:1;if(T&&ba(w,k,A,M)===1-d^z){var P=(u+f)/2;w=t*Math.cos(P),k=t*Math.sin(P),A=M=null}}else w=k=0;if(h>Bo&&(p=Math.min(Math.abs(c-t)/2,+i.apply(this,arguments)))>.001){g=c>t^d?0:1;var R=p,O=p;if(Uo>h){var I=null==A?[w,k]:null==x?[y,b]:Ir([y,b],[A,M],[x,_],[w,k]),N=y-I[0],j=b-I[1],F=x-I[0],B=_-I[1],D=1/Math.sin(Math.acos((N*F+j*B)/(Math.sqrt(N*N+j*j)*Math.sqrt(F*F+B*B)))/2),U=Math.sqrt(I[0]*I[0]+I[1]*I[1]);O=Math.min(p,(t-U)/(D-1)),R=Math.min(p,(c-U)/(D+1))}if(null!=x){var V=xa(null==A?[w,k]:[A,M],[y,b],c,R,d),q=xa([x,_],[w,k],c,R,d);p===R?L.push("M",V[0],"A",R,",",R," 0 0,",g," ",V[1],"A",c,",",c," 0 ",1-d^ba(V[1][0],V[1][1],q[1][0],q[1][1]),",",d," ",q[1],"A",R,",",R," 0 0,",g," ",q[0]):L.push("M",V[0],"A",R,",",R," 0 1,",g," ",q[0])}else L.push("M",y,",",b);if(null!=A){var H=xa([y,b],[A,M],t,-O,d),G=xa([w,k],null==x?[y,b]:[x,_],t,-O,d);p===O?L.push("L",G[0],"A",O,",",O," 0 0,",g," ",G[1],"A",t,",",t," 0 ",d^ba(G[1][0],G[1][1],H[1][0],H[1][1]),",",1-d," ",H[1],"A",O,",",O," 0 0,",g," ",H[0]):L.push("L",G[0],"A",O,",",O," 0 0,",g," ",H[0])}else L.push("L",w,",",k)}else L.push("M",y,",",b),null!=x&&L.push("A",c,",",c," 0 ",S,",",d," ",x,",",_),L.push("L",w,",",k),null!=A&&L.push("A",t,",",t," 0 ",z,",",1-d," ",A,",",M);return L.push("Z"),L.join("")}function e(t,e){return"M0,"+t+"A"+t+","+t+" 0 1,"+e+" 0,"+-t+"A"+t+","+t+" 0 1,"+e+" 0,"+t}var r=pa,n=ga,i=da,a=Ol,o=va,s=ma,l=ya;return t.innerRadius=function(e){return arguments.length?(r=Lt(e),t):r},t.outerRadius=function(e){return arguments.length?(n=Lt(e),t):n},t.cornerRadius=function(e){return arguments.length?(i=Lt(e),t):i},t.padRadius=function(e){return arguments.length?(a=e==Ol?Ol:Lt(e),t):a},t.startAngle=function(e){return arguments.length?(o=Lt(e),t):o},t.endAngle=function(e){return arguments.length?(s=Lt(e),t):s},t.padAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.centroid=function(){var t=(+r.apply(this,arguments)+ +n.apply(this,arguments))/2,e=(+o.apply(this,arguments)+ +s.apply(this,arguments))/2-Ho;return[Math.cos(e)*t,Math.sin(e)*t]},t};var Ol="auto";co.svg.line=function(){return _a(x)};var Il=co.map({linear:wa,"linear-closed":ka,step:Aa,"step-before":Ma,"step-after":Ta,basis:Pa,"basis-open":Ra,"basis-closed":Oa,bundle:Ia,cardinal:Sa,"cardinal-open":Ea,"cardinal-closed":La,monotone:Ua});Il.forEach(function(t,e){e.key=t,e.closed=/-closed$/.test(t)});var Nl=[0,2/3,1/3,0],jl=[0,1/3,2/3,0],Fl=[0,1/6,2/3,1/6];co.svg.line.radial=function(){var t=_a(Va);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},Ma.reverse=Ta,Ta.reverse=Ma,co.svg.area=function(){return qa(x)},co.svg.area.radial=function(){var t=qa(Va);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},co.svg.chord=function(){function t(t,s){var l=e(this,a,t,s),c=e(this,o,t,s);return"M"+l.p0+n(l.r,l.p1,l.a1-l.a0)+(r(l,c)?i(l.r,l.p1,l.r,l.p0):i(l.r,l.p1,c.r,c.p0)+n(c.r,c.p1,c.a1-c.a0)+i(c.r,c.p1,l.r,l.p0))+"Z"}function e(t,e,r,n){var i=e.call(t,r,n),a=s.call(t,i,n),o=l.call(t,i,n)-Ho,u=c.call(t,i,n)-Ho;return{r:a,a0:o,a1:u,p0:[a*Math.cos(o),a*Math.sin(o)],p1:[a*Math.cos(u),a*Math.sin(u)]}}function r(t,e){return t.a0==e.a0&&t.a1==e.a1}function n(t,e,r){return"A"+t+","+t+" 0 "+ +(r>Uo)+",1 "+e}function i(t,e,r,n){return"Q 0,0 "+n}var a=xr,o=_r,s=Ha,l=va,c=ma;return t.radius=function(e){return arguments.length?(s=Lt(e),t):s},t.source=function(e){return arguments.length?(a=Lt(e),t):a},t.target=function(e){return arguments.length?(o=Lt(e),t):o},t.startAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.endAngle=function(e){return arguments.length?(c=Lt(e),t):c},t},co.svg.diagonal=function(){function t(t,i){var a=e.call(this,t,i),o=r.call(this,t,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return l=l.map(n),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var e=xr,r=_r,n=Ga;return t.source=function(r){return arguments.length?(e=Lt(r),t):e},t.target=function(e){return arguments.length?(r=Lt(e),t):r},t.projection=function(e){return arguments.length?(n=e,t):n},t},co.svg.diagonal.radial=function(){var t=co.svg.diagonal(),e=Ga,r=t.projection;return t.projection=function(t){return arguments.length?r(Ya(e=t)):e},t},co.svg.symbol=function(){function t(t,n){return(Bl.get(e.call(this,t,n))||Za)(r.call(this,t,n))}var e=Wa,r=Xa;return t.type=function(r){return arguments.length?(e=Lt(r),t):e},t.size=function(e){return arguments.length?(r=Lt(e),t):r},t};var Bl=co.map({circle:Za,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Ul)),r=e*Ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/Dl),r=e*Dl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/Dl),r=e*Dl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});co.svg.symbolTypes=Bl.keys();var Dl=Math.sqrt(3),Ul=Math.tan(30*Go);zo.transition=function(t){for(var e,r,n=Vl||++Yl,i=to(t),a=[],o=ql||{time:Date.now(),ease:Ln,delay:0,duration:250},s=-1,l=this.length;++sa;a++){i.push(e=[]);for(var r=this[a],s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return Qa(i,this.namespace,this.id)},Gl.tween=function(t,e){var r=this.id,n=this.namespace;return arguments.length<2?this.node()[n][r].tween.get(t):G(this,null==e?function(e){e[n][r].tween.remove(t)}:function(i){i[n][r].tween.set(t,e)})},Gl.attr=function(t,e){function r(){this.removeAttribute(s)}function n(){this.removeAttributeNS(s.space,s.local)}function i(t){return null==t?r:(t+="",function(){var e,r=this.getAttribute(s);return r!==t&&(e=o(r,t),function(t){this.setAttribute(s,e(t))})})}function a(t){return null==t?n:(t+="",function(){var e,r=this.getAttributeNS(s.space,s.local);return r!==t&&(e=o(r,t),function(t){this.setAttributeNS(s.space,s.local,e(t))})})}if(arguments.length<2){for(e in t)this.attr(e,t[e]);return this}var o="transform"==t?Zn:_n,s=co.ns.qualify(t);return $a(this,"attr."+t,e,s.local?a:i)},Gl.attrTween=function(t,e){function r(t,r){var n=e.call(this,t,r,this.getAttribute(i));return n&&function(t){this.setAttribute(i,n(t))}}function n(t,r){var n=e.call(this,t,r,this.getAttributeNS(i.space,i.local));return n&&function(t){this.setAttributeNS(i.space,i.local,n(t))}}var i=co.ns.qualify(t);return this.tween("attr."+t,i.local?n:r)},Gl.style=function(t,e,r){function i(){this.style.removeProperty(t)}function a(e){return null==e?i:(e+="",function(){var i,a=n(this).getComputedStyle(this,null).getPropertyValue(t);return a!==e&&(i=_n(a,e),function(e){this.style.setProperty(t,i(e),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof t){2>o&&(e="");for(r in t)this.style(r,t[r],e);return this}r=""}return $a(this,"style."+t,e,a)},Gl.styleTween=function(t,e,r){function i(i,a){var o=e.call(this,i,a,n(this).getComputedStyle(this,null).getPropertyValue(t));return o&&function(e){this.style.setProperty(t,o(e),r)}}return arguments.length<3&&(r=""),this.tween("style."+t,i)},Gl.text=function(t){return $a(this,"text",t,Ja)},Gl.remove=function(){var t=this.namespace;return this.each("end.transition",function(){var e;this[t].count<2&&(e=this.parentNode)&&e.removeChild(this)})},Gl.ease=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].ease:("function"!=typeof t&&(t=co.ease.apply(co,arguments)),G(this,function(n){n[r][e].ease=t}))},Gl.delay=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].delay:G(this,"function"==typeof t?function(n,i,a){n[r][e].delay=+t.call(n,n.__data__,i,a)}:(t=+t,function(n){n[r][e].delay=t}))},Gl.duration=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].duration:G(this,"function"==typeof t?function(n,i,a){n[r][e].duration=Math.max(1,t.call(n,n.__data__,i,a))}:(t=Math.max(1,t),function(n){n[r][e].duration=t}))},Gl.each=function(t,e){var r=this.id,n=this.namespace;if(arguments.length<2){var i=ql,a=Vl;try{Vl=r,G(this,function(e,i,a){ql=e[n][r],t.call(e,e.__data__,i,a)})}finally{ql=i,Vl=a}}else G(this,function(i){var a=i[n][r];(a.event||(a.event=co.dispatch("start","end","interrupt"))).on(t,e)});return this},Gl.transition=function(){for(var t,e,r,n,i=this.id,a=++Yl,o=this.namespace,s=[],l=0,c=this.length;c>l;l++){s.push(t=[]);for(var e=this[l],u=0,f=e.length;f>u;u++)(r=e[u])&&(n=r[o][i],eo(r,u,o,a,{time:n.time,ease:n.ease,delay:n.delay+n.duration,duration:n.duration})),t.push(r)}return Qa(s,o,a)},co.svg.axis=function(){function t(t){t.each(function(){var t,c=co.select(this),u=this.__chart__||r,f=this.__chart__=r.copy(),h=null==l?f.ticks?f.ticks.apply(f,s):f.domain():l,d=null==e?f.tickFormat?f.tickFormat.apply(f,s):x:e,p=c.selectAll(".tick").data(h,f),g=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Bo),v=co.transition(p.exit()).style("opacity",Bo).remove(),m=co.transition(p.order()).style("opacity",1),y=Math.max(i,0)+o,b=Yi(f),_=c.selectAll(".domain").data([0]),w=(_.enter().append("path").attr("class","domain"),co.transition(_));g.append("line"),g.append("text");var k,A,M,T,E=g.select("line"),L=m.select("line"),S=p.select("text").text(d),C=g.select("text"),z=m.select("text"),P="top"===n||"left"===n?-1:1;if("bottom"===n||"top"===n?(t=ro,k="x",M="y",A="x2",T="y2",S.attr("dy",0>P?"0em":".71em").style("text-anchor","middle"),w.attr("d","M"+b[0]+","+P*a+"V0H"+b[1]+"V"+P*a)):(t=no,k="y",M="x",A="y2",T="x2",S.attr("dy",".32em").style("text-anchor",0>P?"end":"start"),w.attr("d","M"+P*a+","+b[0]+"H0V"+b[1]+"H"+P*a)),E.attr(T,P*i),C.attr(M,P*y),L.attr(A,0).attr(T,P*i),z.attr(k,0).attr(M,P*y),f.rangeBand){var R=f,O=R.rangeBand()/2;u=f=function(t){return R(t)+O}}else u.rangeBand?u=f:v.call(t,f,u);g.call(t,u,f),m.call(t,f,f)})}var e,r=co.scale.linear(),n=Xl,i=6,a=6,o=3,s=[10],l=null;return t.scale=function(e){return arguments.length?(r=e,t):r},t.orient=function(e){return arguments.length?(n=e in Wl?e+"":Xl,t):n},t.ticks=function(){return arguments.length?(s=fo(arguments),t):s},t.tickValues=function(e){return arguments.length?(l=e,t):l},t.tickFormat=function(r){return arguments.length?(e=r,t):e},t.tickSize=function(e){var r=arguments.length;return r?(i=+e,a=+arguments[r-1],t):i},t.innerTickSize=function(e){return arguments.length?(i=+e,t):i},t.outerTickSize=function(e){return arguments.length?(a=+e,t):a},t.tickPadding=function(e){return arguments.length?(o=+e,t):o},t.tickSubdivide=function(){return arguments.length&&t},t};var Xl="bottom",Wl={top:1,right:1,bottom:1,left:1};co.svg.brush=function(){function t(n){n.each(function(){var n=co.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",a).on("touchstart.brush",a),o=n.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),n.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var s=n.selectAll(".resize").data(g,x);s.exit().remove(),s.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return Zl[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),s.style("display",t.empty()?"none":null);var l,f=co.transition(n),h=co.transition(o);c&&(l=Yi(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(f)),u&&(l=Yi(u),h.attr("y",l[0]).attr("height",l[1]-l[0]),i(f)),e(f)})}function e(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+f[+/e$/.test(t)]+","+h[+/^s/.test(t)]+")"})}function r(t){t.select(".extent").attr("x",f[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function i(t){t.select(".extent").attr("y",h[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function a(){function a(){32==co.event.keyCode&&(S||(b=null,z[0]-=f[1],z[1]-=h[1],S=2),T())}function g(){32==co.event.keyCode&&2==S&&(z[0]+=f[1],z[1]+=h[1],S=0,T())}function v(){var t=co.mouse(_),n=!1;x&&(t[0]+=x[0],t[1]+=x[1]),S||(co.event.altKey?(b||(b=[(f[0]+f[1])/2,(h[0]+h[1])/2]),z[0]=f[+(t[0]u?(i=n,n=u):i=u),g[0]!=n||g[1]!=i?(r?s=null:o=null,g[0]=n,g[1]=i,!0):void 0}function y(){v(),A.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),co.select("body").style("cursor",null),P.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),k({type:"brushend"})}var b,x,_=this,w=co.select(co.event.target),k=l.of(_,arguments),A=co.select(_),M=w.datum(),E=!/^(n|s)$/.test(M)&&c,L=!/^(e|w)$/.test(M)&&u,S=w.classed("extent"),C=Q(_),z=co.mouse(_),P=co.select(n(_)).on("keydown.brush",a).on("keyup.brush",g);if(co.event.changedTouches?P.on("touchmove.brush",v).on("touchend.brush",y):P.on("mousemove.brush",v).on("mouseup.brush",y),A.interrupt().selectAll("*").interrupt(),S)z[0]=f[0]-z[0],z[1]=h[0]-z[1];else if(M){var R=+/w$/.test(M),O=+/^n/.test(M);x=[f[1-R]-z[0],h[1-O]-z[1]],z[0]=f[R],z[1]=h[O]}else co.event.altKey&&(b=z.slice());A.style("pointer-events","none").selectAll(".resize").style("display",null),co.select("body").style("cursor",w.style("cursor")),k({type:"brushstart"}),v()}var o,s,l=L(t,"brushstart","brush","brushend"),c=null,u=null,f=[0,0],h=[0,0],d=!0,p=!0,g=Kl[0];return t.event=function(t){t.each(function(){var t=l.of(this,arguments),e={x:f,y:h,i:o,j:s},r=this.__chart__||e;this.__chart__=e,Vl?co.select(this).transition().each("start.brush",function(){o=r.i,s=r.j,f=r.x,h=r.y,t({type:"brushstart"})}).tween("brush:brush",function(){var r=wn(f,e.x),n=wn(h,e.y);return o=s=null,function(i){f=e.x=r(i),h=e.y=n(i),t({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=e.i,s=e.j,t({type:"brush",mode:"resize"}),t({type:"brushend"})}):(t({type:"brushstart"}),t({type:"brush",mode:"resize"}),t({type:"brushend"}))})},t.x=function(e){return arguments.length?(c=e,g=Kl[!c<<1|!u],t):c},t.y=function(e){return arguments.length?(u=e,g=Kl[!c<<1|!u],t):u},t.clamp=function(e){return arguments.length?(c&&u?(d=!!e[0],p=!!e[1]):c?d=!!e:u&&(p=!!e),t):c&&u?[d,p]:c?d:u?p:null},t.extent=function(e){var r,n,i,a,l;return arguments.length?(c&&(r=e[0],n=e[1],u&&(r=r[0],n=n[0]),o=[r,n],c.invert&&(r=c(r),n=c(n)),r>n&&(l=r,r=n,n=l),r==f[0]&&n==f[1]||(f=[r,n])),u&&(i=e[0],a=e[1],c&&(i=i[1],a=a[1]),s=[i,a],u.invert&&(i=u(i),a=u(a)),i>a&&(l=i,i=a,a=l),i==h[0]&&a==h[1]||(h=[i,a])),t):(c&&(o?(r=o[0],n=o[1]):(r=f[0],n=f[1],c.invert&&(r=c.invert(r),n=c.invert(n)),r>n&&(l=r,r=n,n=l))),u&&(s?(i=s[0],a=s[1]):(i=h[0],a=h[1],u.invert&&(i=u.invert(i),a=u.invert(a)),i>a&&(l=i,i=a,a=l))),c&&u?[[r,i],[n,a]]:c?[r,n]:u&&[i,a])},t.clear=function(){return t.empty()||(f=[0,0],h=[0,0],o=s=null),t},t.empty=function(){return!!c&&f[0]==f[1]||!!u&&h[0]==h[1]},co.rebind(t,l,"on")};var Zl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Kl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Ql=vs.format=ws.timeFormat,$l=Ql.utc,Jl=$l("%Y-%m-%dT%H:%M:%S.%LZ");Ql.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?io:Jl,io.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},io.toString=Jl.toString,vs.second=Vt(function(t){return new ms(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),vs.seconds=vs.second.range,vs.seconds.utc=vs.second.utc.range,vs.minute=Vt(function(t){return new ms(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),vs.minutes=vs.minute.range,vs.minutes.utc=vs.minute.utc.range,vs.hour=Vt(function(t){var e=t.getTimezoneOffset()/60;return new ms(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),vs.hours=vs.hour.range,vs.hours.utc=vs.hour.utc.range,vs.month=Vt(function(t){return t=vs.day(t),t.setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),vs.months=vs.month.range,vs.months.utc=vs.month.utc.range;var tc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],ec=[[vs.second,1],[vs.second,5],[vs.second,15],[vs.second,30],[vs.minute,1],[vs.minute,5],[vs.minute,15],[vs.minute,30],[vs.hour,1],[vs.hour,3],[vs.hour,6],[vs.hour,12],[vs.day,1],[vs.day,2],[vs.week,1],[vs.month,1],[vs.month,3],[vs.year,1]],rc=Ql.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",ze]]),nc={range:function(t,e,r){return co.range(Math.ceil(t/r)*r,+e,r).map(oo)},floor:x,ceil:x};ec.year=vs.year,vs.scale=function(){return ao(co.scale.linear(),ec,rc)};var ic=ec.map(function(t){return[t[0].utc,t[1]]}),ac=$l.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",ze]]);ic.year=vs.year.utc,vs.scale.utc=function(){return ao(co.scale.linear(),ic,ac)},co.text=St(function(t){return t.responseText}),co.json=function(t,e){return Ct(t,"application/json",so,e)},co.html=function(t,e){return Ct(t,"text/html",lo,e)},co.xml=St(function(t){return t.responseXML}),"function"==typeof t&&t.amd?(this.d3=co,t(co)):"object"==typeof r&&r.exports?r.exports=co:this.d3=co}()},{}],88:[function(t,e,r){"use strict";function n(t,e){this.point=t,this.index=e}function i(t,e){for(var r=t.point,n=e.point,i=r.length,a=0;i>a;++a){var o=n[a]-r[a];if(o)return o}return 0}function a(t,e,r){if(1===t)return r?[[-1,0]]:[];var n=e.map(function(t,e){return[t[0],e]});n.sort(function(t,e){return t[0]-e[0]});for(var i=new Array(t-1),a=1;t>a;++a){var o=n[a-1],s=n[a];i[a-1]=[o[1],s[1]]}return r&&i.push([-1,i[0][1]],[i[t-1][1],-1]),i}function o(t,e){var r=t.length;if(0===r)return[];var o=t[0].length;if(1>o)return[];if(1===o)return a(r,t,e);for(var c=new Array(r),u=1,f=0;r>f;++f){for(var h=t[f],d=new Array(o+1),p=0,g=0;o>g;++g){var v=h[g];d[g]=v,p+=v*v}d[o]=p,c[f]=new n(d,f),u=Math.max(p,u)}l(c,i),r=c.length;for(var m=new Array(r+o+1),y=new Array(r+o+1),b=(o+1)*(o+1)*u,x=new Array(o+1),f=0;o>=f;++f)x[f]=0;x[o]=b,m[0]=x.slice(),y[0]=-1;for(var f=0;o>=f;++f){var d=x.slice();d[f]=1,m[f+1]=d,y[f+1]=-1}for(var f=0;r>f;++f){var _=c[f];m[f+o+1]=_.point,y[f+o+1]=_.index}var w=s(m,!1);if(w=e?w.filter(function(t){for(var e=0,r=0;o>=r;++r){var n=y[t[r]];if(0>n&&++e>=2)return!1;t[r]=n}return!0}):w.filter(function(t){for(var e=0;o>=e;++e){var r=y[t[e]];if(0>r)return!1;t[e]=r}return!0}),1&o)for(var f=0;f>>31},e.exports.exponent=function(t){var r=e.exports.hi(t);return(r<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){var r=e.exports.hi(t);return!(2146435072&r)}}).call(this,t("buffer").Buffer)},{buffer:58}],90:[function(t,e,r){"use strict";function n(t,e,r){var i=0|t[r];if(0>=i)return[];var a,o=new Array(i);if(r===t.length-1)for(a=0;i>a;++a)o[a]=e;else for(a=0;i>a;++a)o[a]=n(t,e,r+1);return o}function i(t,e){var r,n;for(r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return i(0|t,e);break;case"object":if("number"==typeof t.length)return n(t,e,0)}return[]}e.exports=a},{}],91:[function(t,e,r){"use strict";function n(t,e){var r=t.length;if("number"!=typeof e){e=0;for(var n=0;r>n;++n){var a=t[n];e=Math.max(e,a[0],a[1])}e=(0|e)+1}e=0|e;for(var o=new Array(e),n=0;e>n;++n)o[n]=[];for(var n=0;r>n;++n){var a=t[n];o[a[0]].push(a[1]),o[a[1]].push(a[0])}for(var s=0;e>s;++s)i(o[s],function(t,e){return t-e});return o}e.exports=n;var i=t("uniq")},{uniq:284}],92:[function(e,r,n){(function(n,i){(function(){"use strict";function a(t){return"function"==typeof t||"object"==typeof t&&null!==t}function o(t){return"function"==typeof t}function s(t){Z=t}function l(t){J=t}function c(){return function(){n.nextTick(p)}}function u(){return function(){W(p)}}function f(){var t=0,e=new rt(p),r=document.createTextNode("");return e.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}function h(){var t=new MessageChannel;return t.port1.onmessage=p,function(){t.port2.postMessage(0)}}function d(){return function(){setTimeout(p,1)}}function p(){for(var t=0;$>t;t+=2){var e=at[t],r=at[t+1];e(r),at[t]=void 0,at[t+1]=void 0}$=0}function g(){try{var t=e,r=t("vertx");return W=r.runOnLoop||r.runOnContext,u()}catch(n){return d()}}function v(t,e){var r=this,n=new this.constructor(y);void 0===n[lt]&&j(n);var i=r._state;if(i){var a=arguments[i-1];J(function(){O(i,n,a,r._result)})}else C(r,n,t,e);return n}function m(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var r=new e(y);return T(r,t),r}function y(){}function b(){return new TypeError("You cannot resolve a promise with itself")}function x(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return ht.error=e,ht}}function w(t,e,r,n){try{t.call(e,r,n)}catch(i){return i}}function k(t,e,r){J(function(t){var n=!1,i=w(r,e,function(r){n||(n=!0,e!==r?T(t,r):L(t,r))},function(e){n||(n=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&i&&(n=!0,S(t,i))},t)}function A(t,e){e._state===ut?L(t,e._result):e._state===ft?S(t,e._result):C(e,void 0,function(e){T(t,e)},function(e){S(t,e)})}function M(t,e,r){e.constructor===t.constructor&&r===ot&&constructor.resolve===st?A(t,e):r===ht?S(t,ht.error):void 0===r?L(t,e):o(r)?k(t,e,r):L(t,e)}function T(t,e){t===e?S(t,b()):a(e)?M(t,e,_(e)):L(t,e)}function E(t){t._onerror&&t._onerror(t._result),z(t)}function L(t,e){t._state===ct&&(t._result=e,t._state=ut,0!==t._subscribers.length&&J(z,t))}function S(t,e){t._state===ct&&(t._state=ft,t._result=e,J(E,t))}function C(t,e,r,n){var i=t._subscribers,a=i.length;t._onerror=null,i[a]=e,i[a+ut]=r,i[a+ft]=n,0===a&&t._state&&J(z,t)}function z(t){var e=t._subscribers,r=t._state;if(0!==e.length){for(var n,i,a=t._result,o=0;oa;a++)e.resolve(t[a]).then(r,n)}:function(t,e){e(new TypeError("You must pass an array to race."))})}function D(t){var e=this,r=new e(y);return S(r,t),r}function U(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function V(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function q(t){this[lt]=N(),this._result=this._state=void 0,this._subscribers=[],y!==t&&("function"!=typeof t&&U(),this instanceof q?I(this,t):V())}function H(t,e){this._instanceConstructor=t,this.promise=new t(y),this.promise[lt]||j(this.promise),Q(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?L(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&L(this.promise,this._result))):S(this.promise,G())}function G(){return new Error("Array Methods must be provided an Array")}function Y(){var t;if("undefined"!=typeof i)t=i;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var r=t.Promise;r&&"[object Promise]"===Object.prototype.toString.call(r.resolve())&&!r.cast||(t.Promise=yt)}var X;X=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var W,Z,K,Q=X,$=0,J=function(t,e){at[$]=t,at[$+1]=e,$+=2,2===$&&(Z?Z(p):K())},tt="undefined"!=typeof window?window:void 0,et=tt||{},rt=et.MutationObserver||et.WebKitMutationObserver,nt="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),it="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,at=new Array(1e3);K=nt?c():rt?f():it?h():void 0===tt&&"function"==typeof e?g():d();var ot=v,st=m,lt=Math.random().toString(36).substring(16),ct=void 0,ut=1,ft=2,ht=new P,dt=new P,pt=0,gt=F,vt=B,mt=D,yt=q;q.all=gt,q.race=vt,q.resolve=st,q.reject=mt,q._setScheduler=s,q._setAsap=l,q._asap=J,q.prototype={constructor:q,then:ot,"catch":function(t){return this.then(null,t)}};var bt=H;H.prototype._enumerate=function(){for(var t=this.length,e=this._input,r=0;this._state===ct&&t>r;r++)this._eachEntry(e[r],r)},H.prototype._eachEntry=function(t,e){var r=this._instanceConstructor,n=r.resolve;if(n===st){var i=_(t);if(i===ot&&t._state!==ct)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(r===yt){var a=new r(y);M(a,t,i),this._willSettleAt(a,e)}else this._willSettleAt(new r(function(e){e(t)}),e)}else this._willSettleAt(n(t),e)},H.prototype._settledAt=function(t,e,r){var n=this.promise;n._state===ct&&(this._remaining--,t===ft?S(n,r):this._result[e]=r),0===this._remaining&&L(n,this._result)},H.prototype._willSettleAt=function(t,e){ +var r=this;C(t,void 0,function(t){r._settledAt(ut,e,t)},function(t){r._settledAt(ft,e,t)})};var xt=Y,_t={Promise:yt,polyfill:xt};"function"==typeof t&&t.amd?t(function(){return _t}):"undefined"!=typeof r&&r.exports?r.exports=_t:"undefined"!=typeof this&&(this.ES6Promise=_t),xt()}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:239}],93:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function a(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!a(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,l,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,l=0;n>l;l++)c[l].apply(this,a);return!0},n.prototype.addListener=function(t,e){var r;if(!i(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(r=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,a,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],a=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(s=a;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],94:[function(t,e,r){"use strict";function n(t,e,r){var n=e||0,i=r||1;return[[t[12]+t[0],t[13]+t[1],t[14]+t[2],t[15]+t[3]],[t[12]-t[0],t[13]-t[1],t[14]-t[2],t[15]-t[3]],[t[12]+t[4],t[13]+t[5],t[14]+t[6],t[15]+t[7]],[t[12]-t[4],t[13]-t[5],t[14]-t[6],t[15]-t[7]],[n*t[12]+t[8],n*t[13]+t[9],n*t[14]+t[10],n*t[15]+t[11]],[i*t[12]-t[8],i*t[13]-t[9],i*t[14]-t[10],i*t[15]-t[11]]]}e.exports=n},{}],95:[function(t,e,r){"use strict";function n(t){for(var e,r=t.length,n=0;r>n;n++)if(e=t.charCodeAt(n),(9>e||e>13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(8192>e||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var r=t;if(t=+t,0===t&&n(r))return!1}else if("number"!==e)return!1;return 1>t-t}},{}],96:[function(t,e,r){"use strict";function n(t,e,r){return Math.min(e,Math.max(t,r))}function i(t,e,r){this.dimension=t.length,this.bounds=[new Array(this.dimension),new Array(this.dimension)];for(var n=0;nr;++r)e[r]=0;return e}function o(t,e,r){switch(arguments.length){case 0:return new i([0],[0],0);case 1:if("number"==typeof t){var n=a(t);return new i(n,n,0)}return new i(t,a(t.length),0);case 2:if("number"==typeof e){var n=a(t.length);return new i(t,n,+e)}r=0;case 3:if(t.length!==e.length)throw new Error("state and velocity lengths must match");return new i(t,e,r)}}e.exports=o;var s=t("cubic-hermite"),l=t("binary-search-bounds"),c=i.prototype;c.flush=function(t){var e=l.gt(this._time,t)-1;0>=e||(this._time.splice(0,e),this._state.splice(0,e*this.dimension),this._velocity.splice(0,e*this.dimension))},c.curve=function(t){var e=this._time,r=e.length,i=l.le(e,t),a=this._scratch[0],o=this._state,c=this._velocity,u=this.dimension,f=this.bounds;if(0>i)for(var h=u-1,d=0;u>d;++d,--h)a[d]=o[h];else if(i>=r-1)for(var h=o.length-1,p=t-e[r-1],d=0;u>d;++d,--h)a[d]=o[h]+p*c[h];else{for(var h=u*(i+1)-1,g=e[i],v=e[i+1],m=v-g||1,y=this._scratch[1],b=this._scratch[2],x=this._scratch[3],_=this._scratch[4],w=!0,d=0;u>d;++d,--h)y[d]=o[h],x[d]=c[h]*m,b[d]=o[h+u],_[d]=c[h+u]*m,w=w&&y[d]===b[d]&&x[d]===_[d]&&0===x[d];if(w)for(var d=0;u>d;++d)a[d]=y[d];else s(y,x,b,_,(t-g)/m,a)}for(var k=f[0],A=f[1],d=0;u>d;++d)a[d]=n(k[d],A[d],a[d]);return a},c.dcurve=function(t){var e=this._time,r=e.length,n=l.le(e,t),i=this._scratch[0],a=this._state,o=this._velocity,c=this.dimension;if(n>=r-1)for(var u=a.length-1,f=(t-e[r-1],0);c>f;++f,--u)i[f]=o[u];else{for(var u=c*(n+1)-1,h=e[n],d=e[n+1],p=d-h||1,g=this._scratch[1],v=this._scratch[2],m=this._scratch[3],y=this._scratch[4],b=!0,f=0;c>f;++f,--u)g[f]=a[u],m[f]=o[u]*p,v[f]=a[u+c],y[f]=o[u+c]*p,b=b&&g[f]===v[f]&&m[f]===y[f]&&0===m[f];if(b)for(var f=0;c>f;++f)i[f]=0;else{s.derivative(g,m,v,y,(t-h)/p,i);for(var f=0;c>f;++f)i[f]/=p}}return i},c.lastT=function(){var t=this._time;return t[t.length-1]},c.stable=function(){for(var t=this._velocity,e=t.length,r=this.dimension-1;r>=0;--r)if(t[--e])return!1;return!0},c.jump=function(t){var e=this.lastT(),r=this.dimension;if(!(e>t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1];this._time.push(e,t);for(var u=0;2>u;++u)for(var f=0;r>f;++f)i.push(i[o++]),a.push(0);this._time.push(t);for(var f=r;f>0;--f)i.push(n(l[f-1],c[f-1],arguments[f])),a.push(0)}},c.push=function(t){var e=this.lastT(),r=this.dimension;if(!(e>t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=t-e,l=this.bounds,c=l[0],u=l[1],f=s>1e-6?1/s:0;this._time.push(t);for(var h=r;h>0;--h){var d=n(c[h-1],u[h-1],arguments[h]);i.push(d),a.push((d-i[o++])*f)}}},c.set=function(t){var e=this.dimension;if(!(t0;--l)r.push(n(o[l-1],s[l-1],arguments[l])),i.push(0)}},c.move=function(t){var e=this.lastT(),r=this.dimension;if(!(e>=t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1],u=t-e,f=u>1e-6?1/u:0;this._time.push(t);for(var h=r;h>0;--h){var d=arguments[h];i.push(n(l[h-1],c[h-1],i[o++]+d)),a.push(d*f)}}},c.idle=function(t){var e=this.lastT();if(!(e>t)){var r=this.dimension,i=this._state,a=this._velocity,o=i.length-r,s=this.bounds,l=s[0],c=s[1],u=t-e;this._time.push(t);for(var f=r-1;f>=0;--f)i.push(n(l[f],c[f],i[o]+u*a[o])),a.push(0),o+=1}}},{"binary-search-bounds":47,"cubic-hermite":82}],97:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function i(t){return new n(t._color,t.key,t.value,t.left,t.right,t._count)}function a(t,e){return new n(t,e.key,e.value,e.left,e.right,e._count)}function o(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function s(t,e){this._compare=t,this.root=e}function l(t,e){if(e.left){var r=l(t,e.left);if(r)return r}var r=t(e.key,e.value);return r?r:e.right?l(t,e.right):void 0}function c(t,e,r,n){var i=e(t,n.key);if(0>=i){if(n.left){var a=c(t,e,r,n.left);if(a)return a}var a=r(n.key,n.value);if(a)return a}return n.right?c(t,e,r,n.right):void 0}function u(t,e,r,n,i){var a,o=r(t,i.key),s=r(e,i.key);if(0>=o){if(i.left&&(a=u(t,e,r,n,i.left)))return a;if(s>0&&(a=n(i.key,i.value)))return a}return s>0&&i.right?u(t,e,r,n,i.right):void 0}function f(t,e){this.tree=t,this._stack=e}function h(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function d(t){for(var e,r,n,s,l=t.length-1;l>=0;--l){if(e=t[l],0===l)return void(e._color=m);if(r=t[l-1],r.left===e){if(n=r.right,n.right&&n.right._color===v){if(n=r.right=i(n),s=n.right=i(n.right),r.right=n.left,n.left=r,n.right=s,n._color=r._color,e._color=m,r._color=m,s._color=m,o(r),o(n),l>1){var c=t[l-2];c.left===r?c.left=n:c.right=n}return void(t[l-1]=n)}if(n.left&&n.left._color===v){if(n=r.right=i(n),s=n.left=i(n.left),r.right=s.left,n.left=s.right,s.left=r,s.right=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var c=t[l-2];c.left===r?c.left=s:c.right=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.right=a(v,n));r.right=a(v,n);continue}if(n=i(n),r.right=n.left,n.left=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var c=t[l-2];c.left===r?c.left=n:c.right=n}t[l-1]=n,t[l]=r,l+11){var c=t[l-2];c.right===r?c.right=n:c.left=n}return void(t[l-1]=n)}if(n.right&&n.right._color===v){if(n=r.left=i(n),s=n.right=i(n.right),r.left=s.right,n.right=s.left,s.right=r,s.left=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var c=t[l-2];c.right===r?c.right=s:c.left=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.left=a(v,n));r.left=a(v,n);continue}if(n=i(n),r.left=n.right,n.right=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var c=t[l-2];c.right===r?c.right=n:c.left=n}t[l-1]=n,t[l]=r,l+1t?-1:t>e?1:0}function g(t){return new s(t||p,null)}e.exports=g;var v=0,m=1,y=s.prototype;Object.defineProperty(y,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(y,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(y,"length",{get:function(){return this.root?this.root._count:0}}),y.insert=function(t,e){for(var r=this._compare,i=this.root,l=[],c=[];i;){var u=r(t,i.key);l.push(i),c.push(u),i=0>=u?i.left:i.right}l.push(new n(v,t,e,null,null,1));for(var f=l.length-2;f>=0;--f){var i=l[f];c[f]<=0?l[f]=new n(i._color,i.key,i.value,l[f+1],i.right,i._count+1):l[f]=new n(i._color,i.key,i.value,i.left,l[f+1],i._count+1)}for(var f=l.length-1;f>1;--f){var h=l[f-1],i=l[f];if(h._color===m||i._color===m)break;var d=l[f-2];if(d.left===h)if(h.left===i){var p=d.right;if(!p||p._color!==v){if(d._color=v,d.left=h.right,h._color=m,h.right=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.left===d?g.left=h:g.right=h}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else{var p=d.right;if(!p||p._color!==v){if(h.right=i.left,d._color=v,d.left=i.right,i._color=m,i.left=h,i.right=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.left===d?g.left=i:g.right=i}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else if(h.right===i){var p=d.left;if(!p||p._color!==v){if(d._color=v,d.right=h.left,h._color=m,h.left=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.right===d?g.right=h:g.left=h}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}else{var p=d.left;if(!p||p._color!==v){if(h.left=i.right,d._color=v,d.right=i.left,i._color=m,i.right=h,i.left=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.right===d?g.right=i:g.left=i}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}}return l[0]._color=m,new s(r,l[0])},y.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return l(t,this.root);case 2:return c(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return u(e,r,this._compare,t,this.root)}},Object.defineProperty(y,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(y,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),y.at=function(t){if(0>t)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},y.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>=a&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>a&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new f(this,n);r=0>=i?r.left:r.right}return new f(this,[])},y.remove=function(t){var e=this.find(t);return e?e.remove():this},y.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=0>=n?r.left:r.right}};var b=f.prototype;Object.defineProperty(b,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(b,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),b.clone=function(){return new f(this.tree,this._stack.slice())},b.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new n(r._color,r.key,r.value,r.left,r.right,r._count);for(var i=t.length-2;i>=0;--i){var r=t[i];r.left===t[i+1]?e[i]=new n(r._color,r.key,r.value,e[i+1],r.right,r._count):e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count)}if(r=e[e.length-1],r.left&&r.right){var a=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var o=e[a-1];e.push(new n(r._color,o.key,o.value,r.left,r.right,r._count)),e[a-1].key=r.key,e[a-1].value=r.value;for(var i=e.length-2;i>=a;--i)r=e[i],e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count);e[a-1].left=e[a]}if(r=e[e.length-1],r._color===v){var l=e[e.length-2];l.left===r?l.left=null:l.right===r&&(l.right=null),e.pop();for(var i=0;i0?this._stack[this._stack.length-1].key:void 0},enumerable:!0}),Object.defineProperty(b,"value",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1].value:void 0},enumerable:!0}),Object.defineProperty(b,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),b.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),b.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),i=e[e.length-1];r[r.length-1]=new n(i._color,i.key,t,i.left,i.right,i._count);for(var a=e.length-2;a>=0;--a)i=e[a],i.left===e[a+1]?r[a]=new n(i._color,i.key,i.value,r[a+1],i.right,i._count):r[a]=new n(i._color,i.key,i.value,i.left,r[a+1],i._count);return new s(this.tree._compare,r[0])},b.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],98:[function(t,e,r){function n(t){if(0>t)return Number("0/0");for(var e=s[0],r=s.length-1;r>0;--r)e+=s[r]/(t+r);var n=t+o+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}var i=7,a=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],o=607/128,s=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];e.exports=function l(t){if(.5>t)return Math.PI/(Math.sin(Math.PI*t)*l(1-t));if(t>100)return Math.exp(n(t));t-=1;for(var e=a[0],r=1;i+2>r;r++)e+=a[r]/(t+r);var o=t+i+.5;return Math.sqrt(2*Math.PI)*Math.pow(o,t+.5)*Math.exp(-o)*e},e.exports.log=n},{}],99:[function(t,e,r){"use strict";function n(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function i(t){this.gl=t,this.pixelRatio=1,this.bounds=[[-10,-10,-10],[10,10,10]],this.ticks=[[],[],[]],this.autoTicks=!0,this.tickSpacing=[1,1,1],this.tickEnable=[!0,!0,!0],this.tickFont=["sans-serif","sans-serif","sans-serif"],this.tickSize=[12,12,12],this.tickAngle=[0,0,0],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=[!0,!0,!0],this.labelFont="sans-serif",this.labelSize=[20,20,20],this.labelAngle=[0,0,0],this.labelColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.labelPad=[10,10,10],this.lineEnable=[!0,!0,!0],this.lineMirror=[!1,!1,!1],this.lineWidth=[1,1,1],this.lineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.lineTickEnable=[!0,!0,!0],this.lineTickMirror=[!1,!1,!1],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=[!0,!0,!0],this.gridWidth=[1,1,1],this.gridColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.zeroEnable=[!0,!0,!0],this.zeroLineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.zeroLineWidth=[2,2,2],this.backgroundEnable=[!1,!1,!1],this.backgroundColor=[[.8,.8,.8,.5],[.8,.8,.8,.5],[.8,.8,.8,.5]],this._firstInit=!0,this._text=null,this._lines=null,this._background=u(t)}function a(){this.primalOffset=[0,0,0],this.primalMinor=[0,0,0],this.mirrorOffset=[0,0,0],this.mirrorMinor=[0,0,0]}function o(t,e,r,n,i){for(var a=t.primalOffset,o=t.primalMinor,s=t.mirrorOffset,l=t.mirrorMinor,c=n[e],u=0;3>u;++u)if(e!==u){var f=a,h=s,d=o,p=l;c&1<0?(d[u]=-1,p[u]=0):(d[u]=0,p[u]=1)}}function s(t,e){var r=new i(t);return r.update(e),r}e.exports=s;var l=t("./lib/text.js"),c=t("./lib/lines.js"),u=t("./lib/background.js"),f=t("./lib/cube.js"),h=t("./lib/ticks.js"),d=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),p=i.prototype;p.update=function(t){function e(e,r,n){if(n in t){var i,a=t[n],o=this[n];(e?Array.isArray(a)&&Array.isArray(a[0]):Array.isArray(a))?this[n]=i=[r(a[0]),r(a[1]),r(a[2])]:this[n]=i=[r(a),r(a),r(a)];for(var s=0;3>s;++s)if(i[s]!==o[s])return!0}return!1}t=t||{};var r,n=e.bind(this,!1,Number),i=e.bind(this,!1,Boolean),a=e.bind(this,!1,String),o=e.bind(this,!0,function(t){if(Array.isArray(t)){if(3===t.length)return[+t[0],+t[1],+t[2],1];if(4===t.length)return[+t[0],+t[1],+t[2],+t[3]]}return[0,0,0,1]}),s=!1,u=!1;if("bounds"in t)for(var f=t.bounds,d=0;2>d;++d)for(var p=0;3>p;++p)f[d][p]!==this.bounds[d][p]&&(u=!0),this.bounds[d][p]=f[d][p];if("ticks"in t){r=t.ticks,s=!0,this.autoTicks=!1;for(var d=0;3>d;++d)this.tickSpacing[d]=0}else n("tickSpacing")&&(this.autoTicks=!0,u=!0);if(this._firstInit&&("ticks"in t||"tickSpacing"in t||(this.autoTicks=!0),u=!0,s=!0,this._firstInit=!1),u&&this.autoTicks&&(r=h.create(this.bounds,this.tickSpacing),s=!0),s){for(var d=0;3>d;++d)r[d].sort(function(t,e){return t.x-e.x});h.equal(r,this.ticks)?s=!1:this.ticks=r}i("tickEnable"),a("tickFont")&&(s=!0),n("tickSize"),n("tickAngle"),n("tickPad"),o("tickColor");var g=a("labels");a("labelFont")&&(g=!0),i("labelEnable"),n("labelSize"),n("labelPad"),o("labelColor"),i("lineEnable"),i("lineMirror"),n("lineWidth"),o("lineColor"),i("lineTickEnable"),i("lineTickMirror"),n("lineTickLength"),n("lineTickWidth"),o("lineTickColor"),i("gridEnable"),n("gridWidth"),o("gridColor"),i("zeroEnable"),o("zeroLineColor"),n("zeroLineWidth"),i("backgroundEnable"),o("backgroundColor"),this._text?this._text&&(g||s)&&this._text.update(this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont):this._text=l(this.gl,this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont),this._lines&&s&&(this._lines.dispose(),this._lines=null),this._lines||(this._lines=c(this.gl,this.bounds,this.ticks))};var g=[new a,new a,new a],v=[0,0,0],m={model:d,view:d,projection:d};p.isOpaque=function(){return!0},p.isTransparent=function(){return!1},p.drawTransparent=function(t){};var y=[0,0,0],b=[0,0,0],x=[0,0,0];p.draw=function(t){t=t||m;for(var e=this.gl,r=t.model||d,i=t.view||d,a=t.projection||d,s=this.bounds,l=f(r,i,a,s),c=l.cubeEdges,u=l.axis,h=i[12],p=i[13],_=i[14],w=i[15],k=this.pixelRatio*(a[3]*h+a[7]*p+a[11]*_+a[15]*w)/e.drawingBufferHeight,A=0;3>A;++A)this.lastCubeProps.cubeEdges[A]=c[A],this.lastCubeProps.axis[A]=u[A];for(var M=g,A=0;3>A;++A)o(g[A],A,this.bounds,c,u);for(var e=this.gl,T=v,A=0;3>A;++A)this.backgroundEnable[A]?T[A]=u[A]:T[A]=0;this._background.draw(r,i,a,s,T,this.backgroundColor),this._lines.bind(r,i,a,this);for(var A=0;3>A;++A){var E=[0,0,0];u[A]>0?E[A]=s[1][A]:E[A]=s[0][A];for(var L=0;2>L;++L){var S=(A+1+L)%3,C=(A+1+(1^L))%3;this.gridEnable[S]&&this._lines.drawGrid(S,C,this.bounds,E,this.gridColor[S],this.gridWidth[S]*this.pixelRatio)}for(var L=0;2>L;++L){var S=(A+1+L)%3,C=(A+1+(1^L))%3;this.zeroEnable[C]&&s[0][C]<=0&&s[1][C]>=0&&this._lines.drawZero(S,C,this.bounds,E,this.zeroLineColor[C],this.zeroLineWidth[C]*this.pixelRatio)}}for(var A=0;3>A;++A){this.lineEnable[A]&&this._lines.drawAxisLine(A,this.bounds,M[A].primalOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio),this.lineMirror[A]&&this._lines.drawAxisLine(A,this.bounds,M[A].mirrorOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio);for(var z=n(y,M[A].primalMinor),P=n(b,M[A].mirrorMinor),R=this.lineTickLength,L=0;3>L;++L){var O=k/r[5*L];z[L]*=R[L]*O,P[L]*=R[L]*O}this.lineTickEnable[A]&&this._lines.drawAxisTicks(A,M[A].primalOffset,z,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio),this.lineTickMirror[A]&&this._lines.drawAxisTicks(A,M[A].mirrorOffset,P,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio)}this._text.bind(r,i,a,this.pixelRatio);for(var A=0;3>A;++A){for(var I=M[A].primalMinor,N=n(x,M[A].primalOffset),L=0;3>L;++L)this.lineTickEnable[A]&&(N[L]+=k*I[L]*Math.max(this.lineTickLength[L],0)/r[5*L]);if(this.tickEnable[A]){for(var L=0;3>L;++L)N[L]+=k*I[L]*this.tickPad[L]/r[5*L];this._text.drawTicks(A,this.tickSize[A],this.tickAngle[A],N,this.tickColor[A])}if(this.labelEnable[A]){for(var L=0;3>L;++L)N[L]+=k*I[L]*this.labelPad[L]/r[5*L];N[A]+=.5*(s[0][A]+s[1][A]),this._text.drawLabel(A,this.labelSize[A],this.labelAngle[A],N,this.labelColor[A])}}},p.dispose=function(){this._text.dispose(),this._lines.dispose(),this._background.dispose(),this._lines=null,this._text=null,this._background=null,this.gl=null}},{"./lib/background.js":100,"./lib/cube.js":101,"./lib/lines.js":102,"./lib/text.js":104,"./lib/ticks.js":105}],100:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n}function i(t){for(var e=[],r=[],i=0,l=0;3>l;++l)for(var c=(l+1)%3,u=(l+2)%3,f=[0,0,0],h=[0,0,0],d=-1;1>=d;d+=2){r.push(i,i+2,i+1,i+1,i+2,i+3),f[l]=d,h[l]=d;for(var p=-1;1>=p;p+=2){f[c]=p;for(var g=-1;1>=g;g+=2)f[u]=g,e.push(f[0],f[1],f[2],h[0],h[1],h[2]),i+=1}var v=c;c=u,u=v}var m=a(t,new Float32Array(e)),y=a(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),b=o(t,[{buffer:m,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:m,type:t.FLOAT,size:3,offset:12,stride:24}],y),x=s(t);return x.attributes.position.location=0,x.attributes.normal.location=1,new n(t,m,b,x)}e.exports=i;var a=t("gl-buffer"),o=t("gl-vao"),s=t("./shaders").bg,l=n.prototype;l.draw=function(t,e,r,n,i,a){for(var o=!1,s=0;3>s;++s)o=o||i[s];if(o){var l=this.gl;l.enable(l.POLYGON_OFFSET_FILL),l.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:t,view:e,projection:r,bounds:n,enable:i,colors:a},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),l.disable(l.POLYGON_OFFSET_FILL)}},l.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders":103,"gl-buffer":107,"gl-vao":182}],101:[function(t,e,r){"use strict";function n(t,e,r){for(var n=0;4>n;++n){t[n]=r[12+n];for(var i=0;3>i;++i)t[n]+=e[i]*r[4*i+n]}}function i(t){for(var e=0;eg;++g){d[2]=a[g][2];for(var b=0;2>b;++b){d[1]=a[b][1];for(var x=0;2>x;++x)d[0]=a[x][0],n(f[l],d,u),l+=1}}for(var _=-1,g=0;8>g;++g){for(var w=f[g][3],k=0;3>k;++k)h[g][k]=f[g][k]/w;0>w&&(0>_?_=g:h[g][2]_){_=0;for(var A=0;3>A;++A){for(var M=(A+2)%3,T=(A+1)%3,E=-1,L=-1,S=0;2>S;++S){var C=S<E||0>L)L>E&&(_|=1<S;++S){var C=S<E&&(_|=1<g;++g)g!==_&&g!==O&&(0>I?I=g:h[I][1]>h[g][1]&&(I=g));for(var N=-1,g=0;3>g;++g){var j=I^1<N&&(N=j);var T=h[j];T[0]g;++g){var j=I^1<F&&(F=j);var T=h[j];T[0]>h[F][0]&&(F=j)}}var B=v;B[0]=B[1]=B[2]=0,B[o.log2(N^I)]=I&N,B[o.log2(I^F)]=I&F;var D=7^F;D===_||D===O?(D=7^N,B[o.log2(F^D)]=D&F):B[o.log2(N^D)]=D&N;for(var U=m,V=_,A=0;3>A;++A)V&1<t;++t)f[t]=[1,1,1,1],h[t]=[1,1,1]}();var g=[[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]],v=[1,1,1],m=[0,0,0],y={cubeEdges:v,axis:m}},{"bit-twiddle":48,"gl-mat4/invert":128,"gl-mat4/multiply":130,"robust-orientation":253,"split-polygon":270}],102:[function(t,e,r){"use strict";function n(t){return t[0]=t[1]=t[2]=0,t}function i(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function a(t,e,r,n,i,a,o,s){this.gl=t,this.vertBuffer=e,this.vao=r,this.shader=n,this.tickCount=i,this.tickOffset=a,this.gridCount=o,this.gridOffset=s}function o(t,e,r){var n=[],i=[0,0,0],o=[0,0,0],u=[0,0,0],f=[0,0,0];n.push(0,0,1,0,1,1,0,0,-1,0,0,-1,0,1,1,0,1,-1);for(var h=0;3>h;++h){for(var d=n.length/3|0,p=0;ph;++h)for(var p=u[h],g=2;g>=0;--g){var v=c[p[g]];s.push(l*v[0],-l*v[1],t)}}for(var s=(this.gl,[]),l=[0,0,0],c=[0,0,0],u=[0,0,0],d=[0,0,0],p=0;3>p;++p){u[p]=s.length/h|0,o(.5*(t[0][p]+t[1][p]),e[p],r),d[p]=(s.length/h|0)-u[p],l[p]=s.length/h|0;for(var g=0;g=0&&(i=r.length-n-1);var a=Math.pow(10,i),o=Math.round(t*e*a),s=o+"";if(s.indexOf("e")>=0)return s;var l=o/a,c=o%a;0>o?(l=0|-Math.ceil(l),c=0|-c):(l=0|Math.floor(l),c=0|c);var u=""+l;if(0>o&&(u="-"+u),i){for(var f=""+c;f.lengthi;++i){for(var a=[],o=(.5*(t[0][i]+t[1][i]),0);o*e[i]<=t[1][i];++o)a.push({x:o*e[i],text:n(e[i],o)});for(var o=-1;o*e[i]>=t[0][i];--o)a.push({x:o*e[i],text:n(e[i],o)});r.push(a)}return r}function a(t,e){for(var r=0;3>r;++r){if(t[r].length!==e[r].length)return!1;for(var n=0;na;++a){for(var o=p,s=g,l=0;3>l;++l)s[l]=o[l]=r[l];s[3]=o[3]=1,s[a]+=1,f(s,s,e),s[3]<0&&(t[a]=1/0),o[a]-=1,f(o,o,e),o[3]<0&&(t[a]=1/0);var c=(o[0]/o[3]-s[0]/s[3])*n,u=(o[1]/o[3]-s[1]/s[3])*i;t[a]=.25*Math.sqrt(c*c+u*u)}return t}function a(t,e,r,n,a){var f=e.model||h,p=e.view||h,g=e.projection||h,y=t.bounds,a=a||l(f,p,g,y),b=a.axis;a.edges;c(d,p,f),c(d,g,d);for(var x=v,_=0;3>_;++_)x[_].lo=1/0,x[_].hi=-(1/0),x[_].pixelsPerDataUnit=1/0;var w=o(u(d,d));u(d,d);for(var k=0;3>k;++k){var A=(k+1)%3,M=(k+2)%3,T=m;t:for(var _=0;2>_;++_){var E=[];if(b[k]<0!=!!_){T[k]=y[_][k];for(var L=0;2>L;++L){T[A]=y[L^_][A];for(var S=0;2>S;++S)T[M]=y[S^L^_][M],E.push(T.slice())}for(var L=0;LS;++S)x[S].lo=Math.min(x[S].lo,M[S]),x[S].hi=Math.max(x[S].hi,M[S]),S!==k&&(x[S].pixelsPerDataUnit=Math.min(x[S].pixelsPerDataUnit,Math.abs(C[S])))}}}return x}e.exports=a;var o=t("extract-frustum-planes"),s=t("split-polygon"),l=t("./lib/cube.js"),c=t("gl-mat4/multiply"),u=t("gl-mat4/transpose"),f=t("gl-vec4/transformMat4"),h=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),d=new Float32Array(16),p=[0,0,0,1],g=[0,0,0,1],v=[new n(1/0,-(1/0),1/0),new n(1/0,-(1/0),1/0),new n(1/0,-(1/0),1/0)],m=[0,0,0]},{"./lib/cube.js":101,"extract-frustum-planes":94,"gl-mat4/multiply":130,"gl-mat4/transpose":138,"gl-vec4/transformMat4":188,"split-polygon":270}],107:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.gl=t,this.type=e,this.handle=r,this.length=n,this.usage=i}function i(t,e,r,n,i,a){var o=i.length*i.BYTES_PER_ELEMENT;if(0>a)return t.bufferData(e,i,n),o;if(o+a>r)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function a(t,e){for(var r=l.malloc(t.length,e),n=t.length,i=0;n>i;++i)r[i]=t[i];return r}function o(t,e){for(var r=1,n=e.length-1;n>=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}function s(t,e,r,i){if(r=r||t.ARRAY_BUFFER,i=i||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.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(i!==t.DYNAMIC_DRAW&&i!==t.STATIC_DRAW&&i!==t.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 a=t.createBuffer(),o=new n(t,r,a,0,i);return o.update(e),o}var l=t("typedarray-pool"),c=t("ndarray-ops"),u=t("ndarray"),f=["uint8","uint8_clamped","uint16","uint32","int8","int16","int32","float32"],h=n.prototype;h.bind=function(){this.gl.bindBuffer(this.type,this.handle)},h.unbind=function(){this.gl.bindBuffer(this.type,null)},h.dispose=function(){this.gl.deleteBuffer(this.handle)},h.update=function(t,e){if("number"!=typeof e&&(e=-1),this.bind(),"object"==typeof t&&"undefined"!=typeof t.shape){var r=t.dtype;if(f.indexOf(r)<0&&(r="float32"),this.type===this.gl.ELEMENT_ARRAY_BUFFER){var n=gl.getExtension("OES_element_index_uint");r=n&&"uint16"!==r?"uint32":"uint16"}if(r===t.dtype&&o(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=i(this.gl,this.type,this.length,this.usage,t.data,e):this.length=i(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=l.malloc(t.size,r),h=u(s,t.shape);c.assign(h,t),0>e?this.length=i(this.gl,this.type,this.length,this.usage,s,e):this.length=i(this.gl,this.type,this.length,this.usage,s.subarray(0,t.size),e),l.free(s)}}else if(Array.isArray(t)){var d;d=this.type===this.gl.ELEMENT_ARRAY_BUFFER?a(t,"uint16"):a(t,"float32"),0>e?this.length=i(this.gl,this.type,this.length,this.usage,d,e):this.length=i(this.gl,this.type,this.length,this.usage,d.subarray(0,t.length),e),l.free(d)}else if("object"==typeof t&&"number"==typeof t.length)this.length=i(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");t=0|t,0>=t&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=s},{ndarray:225,"ndarray-ops":219,"typedarray-pool":282}],108:[function(t,e,r){e.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",34e3:"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"}},{}],109:[function(t,e,r){var n=t("./1.0/numbers");e.exports=function(t){return n[t]}},{"./1.0/numbers":108}],110:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.shader=e,this.buffer=r,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.color=[0,0,0,1]}function i(t,e){var r=a(t.gl,l.vertex,l.fragment),i=o(t.gl),s=new n(t,r,i);return s.update(e),t.addObject(s),s}var a=t("gl-shader"),o=t("gl-buffer"),s=t("typedarray-pool"),l=t("./lib/shaders");e.exports=i;var c=[[1,0,0,1,0,0],[1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,1,0,0],[1,0,0,1,0,0],[1,0,-1,0,0,1],[1,0,-1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,1],[1,0,-1,0,0,1],[-1,0,-1,0,0,1],[-1,0,-1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,1],[-1,0,-1,0,0,1],[0,1,1,0,0,0],[0,1,-1,0,0,0],[0,-1,-1,0,0,0],[0,-1,-1,0,0,0],[0,1,1,0,0,0],[0,-1,1,0,0,0],[0,1,0,-1,1,0],[0,1,0,-1,-1,0],[0,1,0,1,-1,0],[0,1,0,1,1,0],[0,1,0,-1,1,0],[0,1,0,1,-1,0],[0,-1,0,-1,1,0],[0,-1,0,-1,-1,0],[0,-1,0,1,-1,0],[0,-1,0,1,1,0],[0,-1,0,-1,1,0],[0,-1,0,1,-1,0]],u=n.prototype;u.draw=function(){var t=[1,0,0,0,1,0,0,0,1],e=[1,1];return function(){var r=this.plot,n=this.shader,i=this.buffer,a=this.bounds,o=this.numPoints;if(o){var s=r.gl,l=r.dataBox,u=r.viewBox,f=r.pixelRatio,h=a[2]-a[0],d=a[3]-a[1],p=l[2]-l[0],g=l[3]-l[1];t[0]=2*h/p,t[4]=2*d/g,t[6]=2*(a[0]-l[0])/p-1,t[7]=2*(a[1]-l[1])/g-1;var v=u[2]-u[0],m=u[3]-u[1];e[0]=2*f/v,e[1]=2*f/m,i.bind(),n.bind(),n.uniforms.viewTransform=t,n.uniforms.pixelScale=e,n.uniforms.color=this.color,n.attributes.position.pointer(s.FLOAT,!1,16,0),n.attributes.pixelOffset.pointer(s.FLOAT,!1,16,8),s.drawArrays(s.TRIANGLES,0,o*c.length)}}}(),u.drawPick=function(t){return t},u.pick=function(t,e){return null},u.update=function(t){t=t||{};var e,r,n,i=t.positions||[],a=t.errors||[],o=1;"lineWidth"in t&&(o=+t.lineWidth);var l=5;"capSize"in t&&(l=+t.capSize),this.color=(t.color||[0,0,0,1]).slice();var u=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=this.numPoints=i.length>>1;for(e=0;f>e;++e)r=i[2*e],n=i[2*e+1],u[0]=Math.min(r,u[0]),u[1]=Math.min(n,u[1]),u[2]=Math.max(r,u[2]),u[3]=Math.max(n,u[3]);u[2]===u[0]&&(u[2]+=1),u[3]===u[1]&&(u[3]+=1);var h=1/(u[2]-u[0]),d=1/(u[3]-u[1]),p=u[0],g=u[1],v=s.mallocFloat32(f*c.length*4),m=0;for(e=0;f>e;++e){r=i[2*e],n=i[2*e+1];for(var y=a[4*e],b=a[4*e+1],x=a[4*e+2],_=a[4*e+3],w=0;wA?A*=y:A>0&&(A*=b),0>M?M*=x:M>0&&(M*=_),v[m++]=h*(r-p+A),v[m++]=d*(n-g+M),v[m++]=o*k[2]+(l+o)*k[4],v[m++]=o*k[3]+(l+o)*k[5]}}this.buffer.update(v),s.free(v)},u.dispose=function(){this.plot.removeObject(this),this.shader.dispose(),this.buffer.dispose()}},{"./lib/shaders":111,"gl-buffer":107,"gl-shader":166,"typedarray-pool":282}],111:[function(t,e,r){e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 pixelOffset;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvoid main() {\n vec3 scrPosition = viewTransform * vec3(position, 1);\n gl_Position = vec4(\n scrPosition.xy + scrPosition.z * pixelScale * pixelOffset,\n 0,\n scrPosition.z);\n}\n",fragment:"precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"}},{}],112:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.shader=n,this.buffer=e,this.vao=r,this.pixelRatio=1,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.lineWidth=[1,1,1],this.capSize=[10,10,10],this.lineCount=[0,0,0],this.lineOffset=[0,0,0],this.opacity=1}function i(t,e){for(var r=0;3>r;++r)t[0][r]=Math.min(t[0][r],e[r]),t[1][r]=Math.max(t[1][r],e[r])}function a(t,e,r,n){for(var i=h[n],a=0;a=1},f.isTransparent=function(){return this.opacity<1},f.drawTransparent=f.draw=function(t){var e=this.gl,r=this.shader.uniforms;this.shader.bind();var n=r.view=t.view||u,i=r.projection=t.projection||u;r.model=t.model||u,r.clipBounds=this.clipBounds,r.opacity=this.opacity;var a=n[12],o=n[13],s=n[14],l=n[15],c=this.pixelRatio*(i[3]*a+i[7]*o+i[11]*s+i[15]*l)/e.drawingBufferHeight;this.vao.bind();for(var f=0;3>f;++f)e.lineWidth(this.lineWidth[f]),r.capSize=this.capSize[f]*c,e.drawArrays(e.LINES,this.lineOffset[f],this.lineCount[f]);this.vao.unbind()};var h=function(){for(var t=new Array(3),e=0;3>e;++e){for(var r=[],n=1;2>=n;++n)for(var i=-1;1>=i;i+=2){var a=(n+e)%3,o=[0,0,0];o[a]=i,r.push(o)}t[e]=r}return t}();f.update=function(t){t=t||{},"lineWidth"in t&&(this.lineWidth=t.lineWidth,Array.isArray(this.lineWidth)||(this.lineWidth=[this.lineWidth,this.lineWidth,this.lineWidth])),"capSize"in t&&(this.capSize=t.capSize,Array.isArray(this.capSize)||(this.capSize=[this.capSize,this.capSize,this.capSize])),"opacity"in t&&(this.opacity=t.opacity);var e=t.color||[[0,0,0],[0,0,0],[0,0,0]],r=t.position,n=t.error;if(Array.isArray(e[0])||(e=[e,e,e]),r&&n){var o=[],s=r.length,l=0;this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.lineCount=[0,0,0];for(var c=0;3>c;++c){this.lineOffset[c]=l;t:for(var u=0;s>u;++u){for(var f=r[u],h=0;3>h;++h)if(isNaN(f[h])||!isFinite(f[h]))continue t;var d=n[u],p=e[c];if(Array.isArray(p[0])&&(p=e[u]),3===p.length&&(p=[p[0],p[1],p[2],1]),!isNaN(d[0][c])&&!isNaN(d[1][c])){if(d[0][c]<0){var g=f.slice();g[c]+=d[0][c],o.push(f[0],f[1],f[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,g),l+=2+a(o,g,p,c)}if(d[1][c]>0){var g=f.slice();g[c]+=d[1][c],o.push(f[0],f[1],f[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,g),l+=2+a(o,g,p,c)}}}this.lineCount[c]=l-this.lineOffset[c]}this.buffer.update(o)}},f.dispose=function(){this.shader.dispose(),this.buffer.dispose(),this.vao.dispose()}},{"./shaders/index":113,"gl-buffer":107,"gl-vao":182}],113:[function(t,e,r){"use strict";var n=t("gl-shader"),i="precision mediump 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}",a="precision mediump float;\n#define GLSLIFY 1\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(fragPosition, clipBounds[0])) || any(greaterThan(fragPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = opacity * fragColor;\n}";e.exports=function(t){return n(t,i,a,null,[{name:"position",type:"vec3"},{name:"offset",type:"vec3"},{name:"color",type:"vec4"}])}},{"gl-shader":166}],114:[function(t,e,r){"use strict";function n(t){var e=t.getParameter(t.FRAMEBUFFER_BINDING),r=t.getParameter(t.RENDERBUFFER_BINDING),n=t.getParameter(t.TEXTURE_BINDING_2D);return[e,r,n]}function i(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function a(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);y=new Array(r+1);for(var n=0;r>=n;++n){for(var i=new Array(r),a=0;n>a;++a)i[a]=t.COLOR_ATTACHMENT0+a;for(var a=n;r>a;++a)i[a]=t.NONE;y[n]=i}}function o(t){switch(t){case p:throw new Error("gl-fbo: Framebuffer unsupported");case g:throw new Error("gl-fbo: Framebuffer incomplete attachment");case v:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case m:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function s(t,e,r,n,i,a){if(!n)return null;var o=d(t,e,r,i,n);return o.magFilter=t.NEAREST,o.minFilter=t.NEAREST,o.mipSamples=1,o.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,a,t.TEXTURE_2D,o.handle,0),o}function l(t,e,r,n,i){var a=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,a),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,a),a}function c(t){var e=n(t.gl),r=t.gl,a=t.handle=r.createFramebuffer(),c=t._shape[0],u=t._shape[1],f=t.color.length,h=t._ext,d=t._useStencil,p=t._useDepth,g=t._colorType;r.bindFramebuffer(r.FRAMEBUFFER,a);for(var v=0;f>v;++v)t.color[v]=s(r,c,u,g,r.RGBA,r.COLOR_ATTACHMENT0+v);0===f?(t._color_rb=l(r,c,u,r.RGBA4,r.COLOR_ATTACHMENT0),h&&h.drawBuffersWEBGL(y[0])):f>1&&h.drawBuffersWEBGL(y[f]);var m=r.getExtension("WEBGL_depth_texture");m?d?t.depth=s(r,c,u,m.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p&&(t.depth=s(r,c,u,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):p&&d?t._depth_rb=l(r,c,u,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p?t._depth_rb=l(r,c,u,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(t._depth_rb=l(r,c,u,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null);for(var v=0;vl;++l)this.color[l]=null;this._color_rb=null,this.depth=null,this._depth_rb=null,this._colorType=n,this._useDepth=a,this._useStencil=o;var u=this,f=[0|e,0|r];Object.defineProperties(f,{0:{get:function(){return u._shape[0]},set:function(t){return u.width=t}},1:{get:function(){return u._shape[1]},set:function(t){return u.height=t}}}),this._shapeVector=f,c(this)}function f(t,e,r){if(t._destroyed)throw new Error("gl-fbo: Can't resize destroyed FBO");if(t._shape[0]!==e||t._shape[1]!==r){var a=t.gl,s=a.getParameter(a.MAX_RENDERBUFFER_SIZE);if(0>e||e>s||0>r||r>s)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var l=n(a),c=0;ce||e>o||0>r||r>o)throw new Error("gl-fbo: Parameters are too large for FBO");n=n||{};var s=1;if("color"in n){if(s=Math.max(0|n.color,0),0>s)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(s>1){if(!i)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(s>t.getParameter(i.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+s+" draw buffers")}}var l=t.UNSIGNED_BYTE,c=t.getExtension("OES_texture_float");if(n.float&&s>0){if(!c)throw new Error("gl-fbo: Context does not support floating point textures");l=t.FLOAT}else n.preferFloat&&s>0&&c&&(l=t.FLOAT);var f=!0;"depth"in n&&(f=!!n.depth);var h=!1;return"stencil"in n&&(h=!!n.stencil),new u(t,e,r,l,s,f,h,i)}var d=t("gl-texture2d");e.exports=h;var p,g,v,m,y=null,b=u.prototype;Object.defineProperties(b,{shape:{get:function(){return this._destroyed?[0,0]:this._shapeVector},set:function(t){if(Array.isArray(t)||(t=[0|t,0|t]),2!==t.length)throw new Error("gl-fbo: Shape vector must be length 2");var e=0|t[0],r=0|t[1];return f(this,e,r),[e,r]},enumerable:!1},width:{get:function(){return this._destroyed?0:this._shape[0]},set:function(t){return t=0|t,f(this,t,this._shape[1]),t},enumerable:!1},height:{get:function(){return this._destroyed?0:this._shape[1]},set:function(t){return t=0|t,f(this,this._shape[0],t),t},enumerable:!1}}),b.bind=function(){if(!this._destroyed){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,this.handle),t.viewport(0,0,this._shape[0],this._shape[1])}},b.dispose=function(){if(!this._destroyed){this._destroyed=!0;var t=this.gl;t.deleteFramebuffer(this.handle),this.handle=null,this.depth&&(this.depth.dispose(),this.depth=null),this._depth_rb&&(t.deleteRenderbuffer(this._depth_rb),this._depth_rb=null);for(var e=0;e2&&!this.usingDashes){var C=this.mitreShader;C.bind();var z=C.uniforms;z.matrix=t,z.color=s,z.screenShape=e,z.radius=l*p,C.attributes.p.pointer(f.FLOAT,!1,48,0),f.drawArrays(f.POINTS,0,u/3|0)}}}}(),h.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0],r=[0,0,0,0];return function(n){var i=this.plot,a=this.pickShader,o=this.lineBuffer,s=this.pickBuffer,l=this.width,c=this.numPoints,u=this.bounds,f=this.vertCount,h=i.gl,d=i.viewBox,p=i.dataBox,g=i.pickPixelRatio,v=u[2]-u[0],m=u[3]-u[1],y=p[2]-p[0],b=p[3]-p[1],x=d[2]-d[0],_=d[3]-d[1];if(this.pickOffset=n,!f)return n+c;t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(u[0]-p[0])/y-1,t[7]=2*(u[1]-p[1])/b-1,e[0]=x,e[1]=_,r[0]=255&n,r[1]=n>>>8&255,r[2]=n>>>16&255,r[3]=n>>>24,a.bind();var w=a.uniforms;w.matrix=t,w.width=l*g,w.pickOffset=r,w.screenShape=e;var k=a.attributes;return o.bind(),k.a.pointer(h.FLOAT,!1,16,0),k.d.pointer(h.FLOAT,!1,16,8),s.bind(),k.pick0.pointer(h.UNSIGNED_BYTE,!1,8,0),k.pick1.pointer(h.UNSIGNED_BYTE,!1,8,4),h.drawArrays(h.TRIANGLES,0,f),n+c}}(),h.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.data;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},h.update=function(t){t=t||{};var e=this.plot.gl;!!t.connectGaps;this.color=(t.color||[0,0,1,1]).slice(),this.width=+(t.width||1),this.fill=(t.fill||[!1,!1,!1,!1]).slice(),this.fillColor=i(t.fillColor||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]);for(var r=t.dashes||[1],n=0,a=0;a1,this.dashPattern=l(e,c(o,[n,1,4],[1,0,0])),this.dashPattern.minFilter=e.NEAREST,this.dashPattern.magFilter=e.NEAREST,this.dashLength=n,u.free(o);var d=t.positions;this.data=d;var p=this.bounds;p[0]=p[1]=1/0,p[2]=p[3]=-(1/0);var g=this.numPoints=d.length>>>1;if(0!==g){for(var a=0;g>a;++a){var v=d[2*a],m=d[2*a+1];isNaN(v)||isNaN(m)||(p[0]=Math.min(p[0],v),p[1]=Math.min(p[1],m),p[2]=Math.max(p[2],v),p[3]=Math.max(p[3],m))}p[0]===p[2]&&(p[2]+=1),p[3]===p[1]&&(p[3]+=1);for(var y=u.mallocFloat32(24*(g-1)),b=u.mallocUint32(12*(g-1)),x=y.length,_=b.length,s=g,w=0;s>1;){var k=--s,v=d[2*s],m=d[2*s+1],A=k-1,M=d[2*A],T=d[2*A+1];if(!(isNaN(v)||isNaN(m)||isNaN(M)||isNaN(T))){w+=1,v=(v-p[0])/(p[2]-p[0]),m=(m-p[1])/(p[3]-p[1]),M=(M-p[0])/(p[2]-p[0]),T=(T-p[1])/(p[3]-p[1]);var E=M-v,L=T-m,S=k|1<<24,C=k-1,z=k,P=k-1|1<<24;y[--x]=-L,y[--x]=-E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=-L,y[--x]=-E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=L,y[--x]=E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=-L,y[--x]=-E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C}}this.vertCount=6*w,this.lineBuffer.update(y.subarray(x)),this.pickBuffer.update(b.subarray(_)),u.free(y),u.free(b)}},h.dispose=function(){this.plot.removeObject(this),this.lineBuffer.dispose(),this.pickBuffer.dispose(),this.lineShader.dispose(),this.mitreShader.dispose(),this.fillShader.dispose(),this.pickShader.dispose(),this.dashPattern.dispose()}},{"./lib/shaders":116,"gl-buffer":107,"gl-shader":166,"gl-texture2d":178,ndarray:225,"typedarray-pool":282}],118:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, nextPosition;\nattribute float arcLength, lineWidth;\nattribute vec4 color;\n\nuniform vec2 screenShape;\nuniform float pixelRatio;\nuniform mat4 model, view, projection;\n\nvarying vec4 fragColor;\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\n\nvoid main() {\n vec4 projected = projection * view * model * vec4(position, 1.0);\n vec4 tangentClip = projection * view * model * vec4(nextPosition - position, 0.0);\n vec2 tangent = normalize(screenShape * tangentClip.xy);\n vec2 offset = 0.5 * pixelRatio * lineWidth * vec2(tangent.y, -tangent.x) / screenShape;\n\n gl_Position = vec4(projected.xy + projected.w * offset, projected.zw);\n\n worldPosition = position;\n pixelArcLength = arcLength;\n fragColor = color;\n}\n",a="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\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",o="precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1_0(highp float v) {\n highp 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 highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp 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 highp 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\n\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId/255.0, encode_float_1_0(pixelArcLength).xyz);\n}",s=[{name:"position",type:"vec3"},{name:"nextPosition",type:"vec3"},{name:"arcLength",type:"float"},{name:"lineWidth",type:"float"},{name:"color",type:"vec4"}];r.createShader=function(t){return n(t,i,a,null,s)},r.createPickShader=function(t){return n(t,i,o,null,s)}},{"gl-shader":166}],119:[function(t,e,r){"use strict";function n(t,e){for(var r=0,n=0;3>n;++n){var i=t[n]-e[n];r+=i*i}return Math.sqrt(r)}function i(t){for(var e=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],r=0;3>r;++r)e[0][r]=Math.max(t[0][r],e[0][r]),e[1][r]=Math.min(t[1][r],e[1][r]);return e}function a(t,e,r,n){this.arcLength=t,this.position=e,this.index=r,this.dataCoordinate=n}function o(t,e,r,n,i,a){this.gl=t,this.shader=e,this.pickShader=r,this.buffer=n,this.vao=i,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.points=[],this.arcLength=[],this.vertexCount=0,this.bounds=[[0,0,0],[0,0,0]],this.pickId=0,this.lineWidth=1,this.texture=a,this.dashScale=1,this.opacity=1,this.dirty=!0,this.pixelRatio=1}function s(t){var e=t.gl||t.scene&&t.scene.gl,r=g(e);r.attributes.position.location=0,r.attributes.nextPosition.location=1,r.attributes.arcLength.location=2,r.attributes.lineWidth.location=3,r.attributes.color.location=4;var n=v(e);n.attributes.position.location=0,n.attributes.nextPosition.location=1,n.attributes.arcLength.location=2,n.attributes.lineWidth.location=3,n.attributes.color.location=4;for(var i=l(e),a=c(e,[{buffer:i,size:3,offset:0,stride:48},{buffer:i,size:3,offset:12,stride:48},{buffer:i,size:1,offset:24,stride:48},{buffer:i,size:1,offset:28,stride:48},{buffer:i,size:4,offset:32,stride:48}]),s=d(new Array(1024),[256,1,4]),f=0;1024>f;++f)s.data[f]=255;var h=u(e,s);h.wrap=e.REPEAT;var p=new o(e,r,n,i,a,h);return p.update(t),p}e.exports=s;var l=t("gl-buffer"),c=t("gl-vao"),u=t("gl-texture2d"),f=t("glsl-read-float"),h=t("binary-search-bounds"),d=t("ndarray"),p=t("./lib/shaders"),g=p.createShader,v=p.createPickShader,m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],y=o.prototype;y.isTransparent=function(){return this.opacity<1},y.isOpaque=function(){return this.opacity>=1},y.pickSlots=1,y.setPickBase=function(t){this.pickId=t},y.drawTransparent=y.draw=function(t){var e=this.gl,r=this.shader,n=this.vao;r.bind(),r.uniforms={model:t.model||m,view:t.view||m,projection:t.projection||m,clipBounds:i(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},y.drawPick=function(t){var e=this.gl,r=this.pickShader,n=this.vao;r.bind(),r.uniforms={model:t.model||m,view:t.view||m,projection:t.projection||m,pickId:this.pickId,clipBounds:i(this.clipBounds),screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},y.update=function(t){var e,r;this.dirty=!0;var i=!!t.connectGaps;"dashScale"in t&&(this.dashScale=t.dashScale),"opacity"in t&&(this.opacity=+t.opacity);var a=t.position||t.positions;if(a){var o=t.color||t.colors||[0,0,0,1],s=t.lineWidth||1,l=[],c=[],u=[],f=0,p=0,g=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],v=!1;t:for(e=1;er;++r){if(isNaN(m[r])||isNaN(y[r])||!isFinite(m[r])||!isFinite(y[r])){if(!i&&l.length>0){for(var b=0;24>b;++b)l.push(l[l.length-12]);p+=2,v=!0}continue t}g[0][r]=Math.min(g[0][r],m[r],y[r]),g[1][r]=Math.max(g[1][r],m[r],y[r])}var x,_;Array.isArray(o[0])?(x=o[e-1],_=o[e]):x=_=o,3===x.length&&(x=[x[0],x[1],x[2],1]),3===_.length&&(_=[_[0],_[1],_[2],1]);var w;w=Array.isArray(s)?s[e-1]:s;var k=f;if(f+=n(m,y),v){for(r=0;2>r;++r)l.push(m[0],m[1],m[2],y[0],y[1],y[2],k,w,x[0],x[1],x[2],x[3]);p+=2,v=!1}l.push(m[0],m[1],m[2],y[0],y[1],y[2],k,w,x[0],x[1],x[2],x[3],m[0],m[1],m[2],y[0],y[1],y[2],k,-w,x[0],x[1],x[2],x[3],y[0],y[1],y[2],m[0],m[1],m[2],f,-w,_[0],_[1],_[2],_[3],y[0],y[1],y[2],m[0],m[1],m[2],f,w,_[0],_[1],_[2],_[3]),p+=4}if(this.buffer.update(l),c.push(f),u.push(a[a.length-1].slice()),this.bounds=g,this.vertexCount=p,this.points=u,this.arcLength=c,"dashes"in t){var A=t.dashes,M=A.slice();for(M.unshift(0),e=1;ee;++e){for(r=0;4>r;++r)T.set(e,0,r,0);1&h.le(M,M[M.length-1]*e/255)?T.set(e,0,0,0):T.set(e,0,0,255)}this.texture.setPixels(T)}}},y.dispose=function(){this.shader.dispose(),this.vao.dispose(),this.buffer.dispose()},y.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=f(t.value[0],t.value[1],t.value[2],0),r=h.le(this.arcLength,e);if(0>r)return null;if(r===this.arcLength.length-1)return new a(this.arcLength[this.arcLength.length-1],this.points[this.points.length-1].slice(),r);for(var n=this.points[r],i=this.points[Math.min(r+1,this.points.length-1)],o=(e-this.arcLength[r])/(this.arcLength[r+1]-this.arcLength[r]),s=1-o,l=[0,0,0],c=0;3>c;++c)l[c]=s*n[c]+o*i[c];var u=Math.min(.5>o?r:r+1,this.points.length-1);return new a(e,l,u,this.points[u])}},{"./lib/shaders":118,"binary-search-bounds":47,"gl-buffer":107,"gl-texture2d":178,"gl-vao":182,"glsl-read-float":189,ndarray:225}],120:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*a-i*n;return o?(o=1/o,t[0]=a*o,t[1]=-n*o,t[2]=-i*o,t[3]=r*o,t):null}e.exports=n},{}],121:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=u*o-s*c,h=-u*a+s*l,d=c*a-o*l,p=r*f+n*h+i*d;return p?(p=1/p,t[0]=f*p,t[1]=(-u*n+i*c)*p,t[2]=(s*n-i*o)*p,t[3]=h*p,t[4]=(u*r-i*l)*p,t[5]=(-s*r+i*a)*p,t[6]=d*p,t[7]=(-c*r+n*l)*p,t[8]=(o*r-n*a)*p,t):null}e.exports=n},{}],122:[function(t,e,r){function n(t){var e=new Float32Array(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}e.exports=n},{}],123:[function(t,e,r){function n(){var t=new Float32Array(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],124:[function(t,e,r){function n(t){var e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],c=t[8],u=t[9],f=t[10],h=t[11],d=t[12],p=t[13],g=t[14],v=t[15],m=e*o-r*a,y=e*s-n*a,b=e*l-i*a,x=r*s-n*o,_=r*l-i*o,w=n*l-i*s,k=c*p-u*d,A=c*g-f*d,M=c*v-h*d,T=u*g-f*p,E=u*v-h*p,L=f*v-h*g;return m*L-y*E+b*T+x*M-_*A+w*k}e.exports=n},{}],125:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r+r,s=n+n,l=i+i,c=r*o,u=n*o,f=n*s,h=i*o,d=i*s,p=i*l,g=a*o,v=a*s,m=a*l;return t[0]=1-f-p,t[1]=u+m,t[2]=h-v,t[3]=0,t[4]=u-m,t[5]=1-c-p,t[6]=d+g,t[7]=0,t[8]=h+v,t[9]=d-g,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],126:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=n+n,l=i+i,c=a+a,u=n*s,f=n*l,h=n*c,d=i*l,p=i*c,g=a*c,v=o*s,m=o*l,y=o*c;return t[0]=1-(d+g),t[1]=f+y,t[2]=h-m,t[3]=0,t[4]=f-y,t[5]=1-(u+g),t[6]=p+v,t[7]=0,t[8]=h+m,t[9]=p-v,t[10]=1-(u+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}e.exports=n},{}],127:[function(t,e,r){function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],128:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],g=e[13],v=e[14],m=e[15],y=r*s-n*o,b=r*l-i*o,x=r*c-a*o,_=n*l-i*s,w=n*c-a*s,k=i*c-a*l,A=u*g-f*p,M=u*v-h*p,T=u*m-d*p,E=f*v-h*g,L=f*m-d*g,S=h*m-d*v,C=y*S-b*L+x*E+_*T-w*M+k*A;return C?(C=1/C,t[0]=(s*S-l*L+c*E)*C,t[1]=(i*L-n*S-a*E)*C,t[2]=(g*k-v*w+m*_)*C,t[3]=(h*w-f*k-d*_)*C,t[4]=(l*T-o*S-c*M)*C,t[5]=(r*S-i*T+a*M)*C,t[6]=(v*x-p*k-m*b)*C,t[7]=(u*k-h*x+d*b)*C,t[8]=(o*L-s*T+c*A)*C,t[9]=(n*T-r*L-a*A)*C,t[10]=(p*w-g*x+m*y)*C,t[11]=(f*x-u*w-d*y)*C,t[12]=(s*M-o*E-l*A)*C,t[13]=(r*E-n*M+i*A)*C,t[14]=(g*b-p*_-v*y)*C,t[15]=(u*_-f*b+h*y)*C,t):null}e.exports=n},{}],129:[function(t,e,r){function n(t,e,r,n){var a,o,s,l,c,u,f,h,d,p,g=e[0],v=e[1],m=e[2],y=n[0],b=n[1],x=n[2],_=r[0],w=r[1],k=r[2];return Math.abs(g-_)<1e-6&&Math.abs(v-w)<1e-6&&Math.abs(m-k)<1e-6?i(t):(f=g-_,h=v-w,d=m-k,p=1/Math.sqrt(f*f+h*h+d*d),f*=p,h*=p,d*=p,a=b*d-x*h,o=x*f-y*d,s=y*h-b*f,p=Math.sqrt(a*a+o*o+s*s),p?(p=1/p,a*=p,o*=p,s*=p):(a=0,o=0,s=0),l=h*s-d*o,c=d*a-f*s,u=f*o-h*a,p=Math.sqrt(l*l+c*c+u*u),p?(p=1/p,l*=p,c*=p,u*=p):(l=0,c=0,u=0),t[0]=a,t[1]=l,t[2]=f,t[3]=0,t[4]=o,t[5]=c,t[6]=h,t[7]=0,t[8]=s,t[9]=u,t[10]=d,t[11]=0,t[12]=-(a*g+o*v+s*m),t[13]=-(l*g+c*v+u*m),t[14]=-(f*g+h*v+d*m),t[15]=1,t)}var i=t("./identity");e.exports=n},{"./identity":127}],130:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],g=e[12],v=e[13],m=e[14],y=e[15],b=r[0],x=r[1],_=r[2],w=r[3];return t[0]=b*n+x*s+_*f+w*g,t[1]=b*i+x*l+_*h+w*v,t[2]=b*a+x*c+_*d+w*m,t[3]=b*o+x*u+_*p+w*y,b=r[4],x=r[5],_=r[6],w=r[7],t[4]=b*n+x*s+_*f+w*g,t[5]=b*i+x*l+_*h+w*v,t[6]=b*a+x*c+_*d+w*m,t[7]=b*o+x*u+_*p+w*y,b=r[8],x=r[9],_=r[10],w=r[11],t[8]=b*n+x*s+_*f+w*g,t[9]=b*i+x*l+_*h+w*v,t[10]=b*a+x*c+_*d+w*m,t[11]=b*o+x*u+_*p+w*y,b=r[12],x=r[13],_=r[14],w=r[15],t[12]=b*n+x*s+_*f+w*g,t[13]=b*i+x*l+_*h+w*v,t[14]=b*a+x*c+_*d+w*m,t[15]=b*o+x*u+_*p+w*y,t}e.exports=n},{}],131:[function(t,e,r){function n(t,e,r,n,i){var a=1/Math.tan(e/2),o=1/(n-i);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+n)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*n*o,t[15]=0,t}e.exports=n},{}],132:[function(t,e,r){function n(t,e,r,n){var i,a,o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w,k,A,M,T,E,L=n[0],S=n[1],C=n[2],z=Math.sqrt(L*L+S*S+C*C);return Math.abs(z)<1e-6?null:(z=1/z,L*=z,S*=z,C*=z,i=Math.sin(r),a=Math.cos(r),o=1-a,s=e[0],l=e[1],c=e[2],u=e[3],f=e[4],h=e[5],d=e[6],p=e[7],g=e[8],v=e[9],m=e[10],y=e[11],b=L*L*o+a,x=S*L*o+C*i,_=C*L*o-S*i,w=L*S*o-C*i,k=S*S*o+a,A=C*S*o+L*i,M=L*C*o+S*i,T=S*C*o-L*i,E=C*C*o+a,t[0]=s*b+f*x+g*_,t[1]=l*b+h*x+v*_,t[2]=c*b+d*x+m*_,t[3]=u*b+p*x+y*_,t[4]=s*w+f*k+g*A,t[5]=l*w+h*k+v*A,t[6]=c*w+d*k+m*A,t[7]=u*w+p*k+y*A,t[8]=s*M+f*T+g*E,t[9]=l*M+h*T+v*E,t[10]=c*M+d*T+m*E,t[11]=u*M+p*T+y*E,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}e.exports=n},{}],133:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+c*n,t[5]=o*i+u*n,t[6]=s*i+f*n,t[7]=l*i+h*n,t[8]=c*i-a*n,t[9]=u*i-o*n,t[10]=f*i-s*n,t[11]=h*i-l*n,t}e.exports=n},{}],134:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i-c*n,t[1]=o*i-u*n,t[2]=s*i-f*n,t[3]=l*i-h*n,t[8]=a*n+c*i,t[9]=o*n+u*i,t[10]=s*n+f*i,t[11]=l*n+h*i,t}e.exports=n},{}],135:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[4],u=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+c*n,t[1]=o*i+u*n,t[2]=s*i+f*n,t[3]=l*i+h*n,t[4]=c*i-a*n,t[5]=u*i-o*n,t[6]=f*i-s*n,t[7]=h*i-l*n,t}e.exports=n},{}],136:[function(t,e,r){function n(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}e.exports=n},{}],137:[function(t,e,r){function n(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g=r[0],v=r[1],m=r[2];return e===t?(t[12]=e[0]*g+e[4]*v+e[8]*m+e[12],t[13]=e[1]*g+e[5]*v+e[9]*m+e[13],t[14]=e[2]*g+e[6]*v+e[10]*m+e[14],t[15]=e[3]*g+e[7]*v+e[11]*m+e[15]):(n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],t[0]=n,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=c,t[7]=u,t[8]=f,t[9]=h,t[10]=d,t[11]=p,t[12]=n*g+s*v+f*m+e[12],t[13]=i*g+l*v+h*m+e[13],t[14]=a*g+c*v+d*m+e[14],t[15]=o*g+u*v+p*m+e[15]),t}e.exports=n},{}],138:[function(t,e,r){function n(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],a=e[6],o=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=a,t[11]=e[14],t[12]=i,t[13]=o,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}e.exports=n},{}],139:[function(t,e,r){"use strict";function n(t,e){switch(e.length){case 0:break;case 1:t[0]=1/e[0];break;case 4:i(t,e);break;case 9:a(t,e);break;case 16:o(t,e);break;default:throw new Error("currently supports matrices up to 4x4")}return t}e.exports=n;var i=t("gl-mat2/invert"),a=t("gl-mat3/invert"),o=t("gl-mat4/invert")},{"gl-mat2/invert":120,"gl-mat3/invert":121,"gl-mat4/invert":128}],140:[function(t,e,r){"use strict";function n(t,e){for(var r=[0,0,0,0],n=0;4>n;++n)for(var i=0;4>i;++i)r[i]+=t[4*n+i]*e[n];return r}function i(t,e,r,i,a){for(var o=n(i,n(r,n(e,[t[0],t[1],t[2],1]))),s=0;3>s;++s)o[s]/=o[3];return[.5*a[0]*(1+o[0]),.5*a[1]*(1-o[1])]}function a(t,e){if(2===t.length){for(var r=0,n=0,i=0;2>i;++i)r+=Math.pow(e[i]-t[0][i],2),n+=Math.pow(e[i]-t[1][i],2);return r=Math.sqrt(r),n=Math.sqrt(n),1e-6>r+n?[1,0]:[n/(r+n),r/(n+r)]}if(3===t.length){var a=[0,0];return c(t[0],t[1],t[2],e,a),l(t,a)}return[]}function o(t,e){for(var r=[0,0,0],n=0;no;++o)r[o]+=a*i[o];return r}function s(t,e,r,n,s,l){if(1===t.length)return[0,t[0].slice()];for(var c=new Array(t.length),u=0;up;++p)d+=Math.pow(c[u][p]-e[p],2);h>d&&(h=d,f=u)}for(var g=a(c,e),v=0,u=0;3>u;++u){if(g[u]<-.001||g[u]>1.0001)return null;v+=g[u]}return Math.abs(v-1)>.001?null:[f,o(t,g),g]}var l=t("barycentric"),c=t("polytope-closest-point/lib/closest_point_2d.js");e.exports=s},{barycentric:29,"polytope-closest-point/lib/closest_point_2d.js":238}],141:[function(t,e,r){var n="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\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\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}",i="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(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\n\n\nfloat cookTorranceSpecular_1_1(\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_2_0(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\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\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(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\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 = cookTorranceSpecular_1_1(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}",a="precision mediump 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}",o="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}",s="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(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}",l="precision mediump 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}",c="precision mediump 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}",u="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if(any(lessThan(f_position, clipBounds[0])) || \n any(greaterThan(f_position, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId, f_id.xyz);\n}",f="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(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}",h="precision mediump 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}",d="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n"; +r.meshShader={vertex:n,fragment:i,attributes:[{name:"position",type:"vec3"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.wireShader={vertex:a,fragment:o,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.pointShader={vertex:s,fragment:l,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]},r.pickShader={vertex:c,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]},r.pointPickShader={vertex:f,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]},r.contourShader={vertex:h,fragment:d,attributes:[{name:"position",type:"vec3"}]}},{}],142:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w,k,A,M,T){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleColors=u,this.triangleNormals=h,this.triangleUVs=f,this.triangleIds=c,this.triangleVAO=d,this.triangleCount=0,this.lineWidth=1,this.edgePositions=p,this.edgeColors=v,this.edgeUVs=m,this.edgeIds=g,this.edgeVAO=y,this.edgeCount=0,this.pointPositions=b,this.pointColors=_,this.pointUVs=w,this.pointSizes=k,this.pointIds=x,this.pointVAO=A,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=M,this.contourVAO=T,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!0,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this._model=I,this._view=I,this._projection=I,this._resolution=[1,1]}function i(t){for(var e=A({colormap:t,nshades:256,format:"rgba"}),r=new Uint8Array(1024),n=0;256>n;++n){for(var i=e[n],a=0;3>a;++a)r[4*n+a]=i[a];r[4*n+3]=255*i[3]}return k(r,[256,256,4],[4,0,1])}function a(t,e,r){for(var n=new Array(e),i=0;e>i;++i)n[i]=0;for(var a=t.length,i=0;a>i;++i)for(var o=t[i],s=0;sn;++n)r[n]=t[n][2];return r}function s(t){var e=v(t,S);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.normal.location=4,e}function l(t){var e=v(t,C);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e}function c(t){var e=v(t,z);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.pointSize.location=4,e}function u(t){var e=v(t,P);return e.attributes.position.location=0,e.attributes.id.location=1,e}function f(t){var e=v(t,R);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.pointSize.location=4,e}function h(t){var e=v(t,O);return e.attributes.position.location=0,e}function d(t){var e=t.gl,r=s(e),i=l(e),a=c(e),o=u(e),d=f(e),p=h(e),g=b(e,k(new Uint8Array([255,255,255,255]),[1,1,4]));g.generateMipmap(),g.minFilter=e.LINEAR_MIPMAP_LINEAR,g.magFilter=e.LINEAR;var v=m(e),x=m(e),_=m(e),w=m(e),A=m(e),M=y(e,[{buffer:v,type:e.FLOAT,size:3},{buffer:A,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:x,type:e.FLOAT,size:4},{buffer:_,type:e.FLOAT,size:2},{buffer:w,type:e.FLOAT,size:3}]),T=m(e),E=m(e),L=m(e),S=m(e),C=y(e,[{buffer:T,type:e.FLOAT,size:3},{buffer:S,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:E,type:e.FLOAT,size:4},{buffer:L,type:e.FLOAT,size:2}]),z=m(e),P=m(e),R=m(e),O=m(e),I=m(e),N=y(e,[{buffer:z,type:e.FLOAT,size:3},{buffer:I,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:P,type:e.FLOAT,size:4},{buffer:R,type:e.FLOAT,size:2},{buffer:O,type:e.FLOAT,size:1}]),j=m(e),F=y(e,[{buffer:j,type:e.FLOAT,size:3}]),B=new n(e,g,r,i,a,o,d,p,v,A,x,_,w,M,T,S,E,L,C,z,I,P,R,O,N,j,F);return B.update(t),B}var p=1e-6,g=1e-6,v=t("gl-shader"),m=t("gl-buffer"),y=t("gl-vao"),b=t("gl-texture2d"),x=t("normals"),_=t("gl-mat4/multiply"),w=t("gl-mat4/invert"),k=t("ndarray"),A=t("colormap"),M=t("simplicial-complex-contour"),T=t("typedarray-pool"),E=t("./lib/shaders"),L=t("./lib/closest-point"),S=E.meshShader,C=E.wireShader,z=E.pointShader,P=E.pickShader,R=E.pointPickShader,O=E.contourShader,I=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],N=n.prototype;N.isOpaque=function(){return this.opacity>=1},N.isTransparent=function(){return this.opacity<1},N.pickSlots=1,N.setPickBase=function(t){this.pickId=t},N.highlight=function(t){if(!t||!this.contourEnable)return void(this.contourCount=0);for(var e=M(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=T.mallocFloat32(6*a),s=0,l=0;a>l;++l)for(var c=r[l],u=0;2>u;++u){var f=c[0];2===c.length&&(f=c[u]);for(var h=n[f][0],d=n[f][1],p=i[f],g=1-p,v=this.positions[h],m=this.positions[d],y=0;3>y;++y)o[s++]=p*v[y]+g*m[y]}this.contourCount=s/3|0,this.contourPositions.update(o.subarray(0,s)),T.free(o)},N.update=function(t){t=t||{};var e=this.gl;this.dirty=!0,"contourEnable"in t&&(this.contourEnable=t.contourEnable),"contourColor"in t&&(this.contourColor=t.contourColor),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"lightPosition"in t&&(this.lightPosition=t.lightPosition),"opacity"in t&&(this.opacity=t.opacity),"ambient"in t&&(this.ambientLight=t.ambient),"diffuse"in t&&(this.diffuseLight=t.diffuse),"specular"in t&&(this.specularLight=t.specular),"roughness"in t&&(this.roughness=t.roughness),"fresnel"in t&&(this.fresnel=t.fresnel),t.texture?(this.texture.dispose(),this.texture=b(e,t.texture)):t.colormap&&(this.texture.shape=[256,256],this.texture.minFilter=e.LINEAR_MIPMAP_LINEAR,this.texture.magFilter=e.LINEAR,this.texture.setPixels(i(t.colormap)),this.texture.generateMipmap());var r=t.cells,n=t.positions;if(n&&r){var s=[],l=[],c=[],u=[],f=[],h=[],d=[],v=[],m=[],y=[],_=[],w=[],k=[],A=[];this.cells=r,this.positions=n;var M=t.vertexNormals,T=t.cellNormals,E=void 0===t.vertexNormalsEpsilon?p:t.vertexNormalsEpsilon,L=void 0===t.faceNormalsEpsilon?g:t.faceNormalsEpsilon;t.useFacetNormals&&!T&&(T=x.faceNormals(r,n,L)),T||M||(M=x.vertexNormals(r,n,E));var S=t.vertexColors,C=t.cellColors,z=t.meshColor||[1,1,1,1],P=t.vertexUVs,R=t.vertexIntensity,O=t.cellUVs,I=t.cellIntensity,N=1/0,j=-(1/0);if(!P&&!O)if(R)for(var F=0;Fq;++q)!isNaN(V[q])&&isFinite(V[q])&&(this.bounds[0][q]=Math.min(this.bounds[0][q],V[q]),this.bounds[1][q]=Math.max(this.bounds[1][q],V[q]));var H=0,G=0,Y=0;t:for(var F=0;Fq;++q)if(isNaN(V[q])||!isFinite(V[q]))continue t;y.push(V[0],V[1],V[2]);var Z;Z=S?S[W]:C?C[F]:z,3===Z.length?_.push(Z[0],Z[1],Z[2],1):_.push(Z[0],Z[1],Z[2],Z[3]);var K;K=P?P[W]:R?[(R[W]-N)/(j-N),0]:O?O[F]:I?[(I[F]-N)/(j-N),0]:[(V[2]-N)/(j-N),0],w.push(K[0],K[1]),D?k.push(D[W]):k.push(U),A.push(F),Y+=1;break;case 2:for(var q=0;2>q;++q)for(var W=X[q],V=n[W],Q=0;3>Q;++Q)if(isNaN(V[Q])||!isFinite(V[Q]))continue t;for(var q=0;2>q;++q){var W=X[q],V=n[W];h.push(V[0],V[1],V[2]);var Z;Z=S?S[W]:C?C[F]:z,3===Z.length?d.push(Z[0],Z[1],Z[2],1):d.push(Z[0],Z[1],Z[2],Z[3]);var K;K=P?P[W]:R?[(R[W]-N)/(j-N),0]:O?O[F]:I?[(I[F]-N)/(j-N),0]:[(V[2]-N)/(j-N),0],v.push(K[0],K[1]),m.push(F)}G+=1;break;case 3:for(var q=0;3>q;++q)for(var W=X[q],V=n[W],Q=0;3>Q;++Q)if(isNaN(V[Q])||!isFinite(V[Q]))continue t;for(var q=0;3>q;++q){var W=X[q],V=n[W];s.push(V[0],V[1],V[2]);var Z;Z=S?S[W]:C?C[F]:z,3===Z.length?l.push(Z[0],Z[1],Z[2],1):l.push(Z[0],Z[1],Z[2],Z[3]);var K;K=P?P[W]:R?[(R[W]-N)/(j-N),0]:O?O[F]:I?[(I[F]-N)/(j-N),0]:[(V[2]-N)/(j-N),0],u.push(K[0],K[1]);var $;$=M?M[W]:T[F],c.push($[0],$[1],$[2]),f.push(F)}H+=1}}this.pointCount=Y,this.edgeCount=G,this.triangleCount=H,this.pointPositions.update(y),this.pointColors.update(_),this.pointUVs.update(w),this.pointSizes.update(k),this.pointIds.update(new Uint32Array(A)),this.edgePositions.update(h),this.edgeColors.update(d),this.edgeUVs.update(v),this.edgeIds.update(new Uint32Array(m)),this.trianglePositions.update(s),this.triangleColors.update(l),this.triangleUVs.update(u),this.triangleNormals.update(c),this.triangleIds.update(new Uint32Array(f))}},N.drawTransparent=N.draw=function(t){t=t||{};for(var e=this.gl,r=t.model||I,n=t.view||I,i=t.projection||I,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;3>o;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);var s={model:r,view:n,projection:i,clipBounds:a,kambient:this.ambientLight,kdiffuse:this.diffuseLight,kspecular:this.specularLight,roughness:this.roughness,fresnel:this.fresnel,eyePosition:[0,0,0],lightPosition:[0,0,0],opacity:this.opacity,contourColor:this.contourColor,texture:0};this.texture.bind(0);var l=new Array(16);_(l,s.view,s.model),_(l,s.projection,l),w(l,l);for(var o=0;3>o;++o)s.eyePosition[o]=l[12+o]/l[15];for(var c=l[15],o=0;3>o;++o)c+=this.lightPosition[o]*l[4*o+3];for(var o=0;3>o;++o){for(var u=l[12+o],f=0;3>f;++f)u+=l[4*f+o]*this.lightPosition[f];s.lightPosition[o]=u/c}if(this.triangleCount>0){var h=this.triShader;h.bind(),h.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()}if(this.edgeCount>0&&this.lineWidth>0){var h=this.lineShader;h.bind(),h.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()}if(this.pointCount>0){var h=this.pointShader;h.bind(),h.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}if(this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0){var h=this.contourShader;h.bind(),h.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind()}},N.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||I,n=t.view||I,i=t.projection||I,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;3>o;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s={model:r,view:n,projection:i,clipBounds:a,pickId:this.pickId/255},l=this.pickShader;if(l.bind(),l.uniforms=s,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0){var l=this.pointPickShader;l.bind(),l.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}},N.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;for(var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions,i=new Array(r.length),a=0;ag;++g){var v=l[g],m=l[g+2],y=m-v,b=.5*(c[g+2]+c[g]),x=c[g+2]-c[g];e[g]=2*y/x,t[g]=2*(v-b)/x}a.bind(),i.bind(),a.attributes.dataCoord.pointer(),a.uniforms.dataShift=t,a.uniforms.dataScale=e;for(var _=0,g=0;2>g;++g){r[0]=r[1]=0,r[g]=1,a.uniforms.dataAxis=r,a.uniforms.lineWidth=f[g]/(u[g+2]-u[g])*p,a.uniforms.color=h[g];var w=6*o[g].length;d[g]&&w&&s.drawArrays(s.TRIANGLES,_,w),_+=w}}}(),u.drawTickMarks=function(){var t=[0,0],e=[0,0],r=[1,0],n=[0,1],a=[0,0],o=[0,0];return function(){for(var s=this.plot,c=this.vbo,u=this.tickShader,f=this.ticks,h=s.gl,d=s._tickBounds,p=s.dataBox,g=s.viewBox,v=s.pixelRatio,m=s.screenBox,y=m[2]-m[0],b=m[3]-m[1],x=g[2]-g[0],_=g[3]-g[1],w=0;2>w;++w){var k=d[w],A=d[w+2],M=A-k,T=.5*(p[w+2]+p[w]),E=p[w+2]-p[w];e[w]=2*M/E,t[w]=2*(k-T)/E}e[0]*=x/y,t[0]*=x/y,e[1]*=_/b,t[1]*=_/b,u.bind(),c.bind(),u.attributes.dataCoord.pointer();var L=u.uniforms;L.dataShift=t,L.dataScale=e;var S=s.tickMarkLength,C=s.tickMarkWidth,z=s.tickMarkColor,P=0,R=6*f[0].length,O=Math.min(l.ge(f[0],(p[0]-d[0])/(d[2]-d[0]),i),f[0].length),I=Math.min(l.gt(f[0],(p[2]-d[0])/(d[2]-d[0]),i),f[0].length),N=P+6*O,j=6*Math.max(0,I-O),F=Math.min(l.ge(f[1],(p[1]-d[1])/(d[3]-d[1]),i),f[1].length),B=Math.min(l.gt(f[1],(p[3]-d[1])/(d[3]-d[1]),i),f[1].length),D=R+6*F,U=6*Math.max(0,B-F);a[0]=2*(g[0]-S[1])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[1]*v/y,o[1]=C[1]*v/b,U&&(L.color=z[1],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,D,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[1]-S[0])/b-1,o[0]=C[0]*v/y,o[1]=S[0]*v/b,j&&(L.color=z[0],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,N,j)),a[0]=2*(g[2]+S[3])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[3]*v/y,o[1]=C[3]*v/b,U&&(L.color=z[3],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,D,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[3]+S[2])/b-1,o[0]=C[2]*v/y,o[1]=S[2]*v/b,j&&(L.color=z[2],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,N,j))}}(),u.update=function(){var t=[1,1,-1,-1,1,-1],e=[1,-1,1,1,-1,-1];return function(r){for(var n=r.ticks,i=r.bounds,a=new Float32Array(18*(n[0].length+n[1].length)),o=(this.plot.zeroLineEnable,0),s=[[],[]],l=0;2>l;++l)for(var c=s[l],u=n[l],f=i[l],h=i[l+2],d=0;dg;++g)a[o++]=p,a[o++]=t[g],a[o++]=e[g]}this.ticks=s,this.vbo.update(a)}}(),u.dispose=function(){this.vbo.dispose(),this.shader.dispose(),this.tickShader.dispose()}},{"./shaders":146,"binary-search-bounds":148,"gl-buffer":107,"gl-shader":166}],145:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[-1,-1,-1,1,1,-1,1,1]),i=o(e,s.lineVert,s.lineFrag),l=new n(t,r,i);return l}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawLine=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o,s){var l=this.plot,c=this.shader,u=l.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,c.uniforms.start=t,c.uniforms.end=e,c.uniforms.width=o*l.pixelRatio,c.uniforms.color=s,u.drawArrays(u.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":146,"gl-buffer":107,"gl-shader":166}],146:[function(t,e,r){"use strict";var n="precision lowp float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = vec4(color.xyz * color.w, color.w);\n}\n";e.exports={lineVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 start, end;\nuniform float width;\n\nvec2 perp(vec2 v) {\n return vec2(v.y, -v.x);\n}\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n vec2 delta = normalize(perp(start - end));\n vec2 offset = mix(start, end, 0.5 * (coord.y+1.0));\n gl_Position = vec4(screen(offset + 0.5 * width * delta * coord.x), 0, 1);\n}\n",lineFrag:n,textVert:"#define GLSLIFY 1\nattribute vec3 textCoordinate;\n\nuniform vec2 dataScale, dataShift, dataAxis, screenOffset, textScale;\nuniform float angle;\n\nvoid main() {\n float dataOffset = textCoordinate.z;\n vec2 glyphOffset = textCoordinate.xy;\n mat2 glyphMatrix = mat2(cos(angle), sin(angle), -sin(angle), cos(angle));\n vec2 screenCoordinate = dataAxis * (dataScale * dataOffset + dataShift) +\n glyphMatrix * glyphOffset * textScale + screenOffset;\n gl_Position = vec4(screenCoordinate, 0, 1);\n}\n",textFrag:n,gridVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale;\nuniform float lineWidth;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n pos += 10.0 * dataCoord.y * vec2(dataAxis.y, -dataAxis.x) + dataCoord.z * lineWidth;\n gl_Position = vec4(pos, 0, 1);\n}\n",gridFrag:n,boxVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 lo, hi;\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n gl_Position = vec4(screen(mix(lo, hi, coord)), 0, 1);\n}\n",tickVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale, screenOffset, tickScale;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n gl_Position = vec4(pos + tickScale*dataCoord.yz + screenOffset, 0, 1);\n}\n"}},{}],147:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r,this.tickOffset=[[],[]],this.tickX=[[],[]],this.labelOffset=[0,0],this.labelCount=[0,0]}function i(t){var e=t.gl,r=a(e),i=o(e,c.textVert,c.textFrag),s=new n(t,r,i);return s}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("text-cache"),l=t("binary-search-bounds"),c=t("./shaders"),u=n.prototype;u.drawTicks=function(){var t=[0,0],e=[0,0],r=[0,0];return function(n){var i=this.plot,a=this.shader,o=this.tickX[n],s=this.tickOffset[n],c=i.gl,u=i.viewBox,f=i.dataBox,h=i.screenBox,d=i.pixelRatio,p=i.tickEnable,g=i.tickPad,v=i.tickColor,m=i.tickAngle,y=(i.tickMarkLength,i.labelEnable),b=i.labelPad,x=i.labelColor,_=i.labelAngle,w=this.labelOffset[n],k=this.labelCount[n],A=l.lt(o,f[n]),M=l.le(o,f[n+2]);t[0]=t[1]=0,t[n]=1,e[n]=(u[2+n]+u[n])/(h[2+n]-h[n])-1;var T=2/h[2+(1^n)]-h[1^n];e[1^n]=T*u[1^n]-1,p[n]&&(e[1^n]-=T*d*g[n],M>A&&s[M]>s[A]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n],a.uniforms.angle=m[n],c.drawArrays(c.TRIANGLES,s[A],s[M]-s[A]))),y[n]&&k&&(e[1^n]-=T*d*b[n],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n],a.uniforms.angle=_[n],c.drawArrays(c.TRIANGLES,w,k)),e[1^n]=T*u[2+(1^n)]-1,p[n+2]&&(e[1^n]+=T*d*g[n+2],M>A&&s[M]>s[A]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n+2],a.uniforms.angle=m[n+2],c.drawArrays(c.TRIANGLES,s[A],s[M]-s[A]))),y[n+2]&&k&&(e[1^n]+=T*d*b[n+2],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n+2],a.uniforms.angle=_[n+2],c.drawArrays(c.TRIANGLES,w,k))}}(),u.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,i=r.gl,a=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,o=r.titleCenter,c=r.pixelRatio;if(this.titleCount){for(var u=0;2>u;++u)e[u]=2*(o[u]*c-a[u])/(a[2+u]-a[u])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,i.drawArrays(i.TRIANGLES,this.titleOffset,this.titleCount)}}}(),u.bind=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){var n=this.plot,i=this.shader,a=n._tickBounds,o=n.dataBox,s=n.screenBox,l=n.viewBox;i.bind();for(var c=0;2>c;++c){var u=a[c],f=a[c+2],h=f-u,d=.5*(o[c+2]+o[c]),p=o[c+2]-o[c],g=l[c],v=l[c+2],m=v-g,y=s[c],b=s[c+2],x=b-y;e[c]=2*h/p*m/x,t[c]=2*(u-d)/p*m/x}r[1]=2*n.pixelRatio/(s[3]-s[1]),r[0]=r[1]*(s[3]-s[1])/(s[2]-s[0]),i.uniforms.dataScale=e,i.uniforms.dataShift=t,i.uniforms.textScale=r,this.vbo.bind(),i.attributes.textCoordinate.pointer()}}(),u.update=function(t){for(var e=[],r=t.ticks,n=t.bounds,i=0;2>i;++i){for(var a=[Math.floor(e.length/3)],o=[-(1/0)],l=r[i],c=0;ci;++i){this.labelOffset[i]=Math.floor(e.length/3);for(var g=s(t.labelFont[i],t.labels[i]).data,p=t.labelSize[i],c=0;cp;++p)if(f[p]&&n[p]<=0&&n[p+2]>=0){var g=e[p]-n[p]*(e[p+2]-e[p])/(n[p+2]-n[p]);0===p?o.drawLine(g,e[1],g,e[3],d[p],h[p]):o.drawLine(e[0],g,e[2],g,d[p],h[p])}}for(var p=0;pp;++p)s.drawTicks(p);this.titleEnable&&s.drawTitle();for(var b=this.overlays,p=0;pc;++c){var u=s[c].slice(0);0!==u.length&&(u.sort(a),l[c]=Math.min(l[c],u[0].x),l[c+2]=Math.max(l[c+2],u[u.length-1].x))}this.grid.update({bounds:l,ticks:s}),this.text.update({bounds:l,ticks:s,labels:t.labels||["x","y"],labelSize:t.labelSize||[12,12],labelFont:t.labelFont||["sans-serif","sans-serif"],title:t.title||"",titleSize:t.titleSize||18,titleFont:t.titleFont||"sans-serif"}),this.setDirty()},h.dispose=function(){this.box.dispose(),this.grid.dispose(),this.text.dispose(),this.line.dispose();for(var t=this.objects.length-1;t>=0;--t)this.objects[t].dispose();this.objects.length=0;for(var t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},h.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},h.removeObject=function(t){for(var e=this.objects,r=0;re){var r=Math.round(Math.pow(10,-e));return Math.ceil(t*r)/r}if(e>0){var r=Math.round(Math.pow(10,e));return Math.ceil(t/r)*r}return Math.ceil(t)}function o(t){return"boolean"==typeof t?t:!0}function s(t){function e(){if(!_&&H.autoResize){var t=w.parentNode,e=1,r=1;t&&t!==document.body?(e=t.clientWidth,r=t.clientHeight):(e=window.innerWidth,r=window.innerHeight);var n=0|Math.ceil(e*H.pixelRatio),i=0|Math.ceil(r*H.pixelRatio);if(n!==w.width||i!==w.height){w.width=n,w.height=i;var a=w.style;a.position=a.position||"absolute",a.left="0px",a.top="0px",a.width=e+"px",a.height=r+"px",F=!0}}}function r(){for(var t=O.length,e=j.length,r=0;e>r;++r)N[r]=0;t:for(var r=0;t>r;++r){var n=O[r],i=n.pickSlots;if(i){for(var a=0;e>a;++a)if(N[a]+i<255){I[r]=a,n.setPickBase(N[a]+1),N[a]+=i;continue t}var o=h(A,q);I[r]=e,j.push(o),N.push(i),n.setPickBase(1),e+=1}else I[r]=-1}for(;e>0&&0===N[e-1];)N.pop(),j.pop().dispose()}function s(){return H.contextLost?!0:void(A.isContextLost()&&(H.contextLost=!0,H.mouseListener.enabled=!1,H.selection.object=null,H.oncontextloss&&H.oncontextloss()))}function y(){if(!s()){A.colorMask(!0,!0,!0,!0),A.depthMask(!0),A.disable(A.BLEND),A.enable(A.DEPTH_TEST);for(var t=O.length,e=j.length,r=0;e>r;++r){var n=j[r];n.shape=G,n.begin();for(var i=0;t>i;++i)if(I[i]===r){var a=O[i];a.drawPick&&(a.pixelRatio=1,a.drawPick(V))}n.end()}}}function b(){if(!s()){e();var t=H.camera.tick();V.view=H.camera.matrix,F=F||t,B=B||t,z.pixelRatio=H.pixelRatio,R.pixelRatio=H.pixelRatio;var r=O.length,n=W[0],i=W[1];n[0]=n[1]=n[2]=1/0,i[0]=i[1]=i[2]=-(1/0);for(var o=0;r>o;++o){var l=O[o];l.pixelRatio=H.pixelRatio,l.axes=H.axes,F=F||!!l.dirty,B=B||!!l.dirty;var c=l.bounds;if(c)for(var f=c[0],h=c[1],d=0;3>d;++d)n[d]=Math.min(n[d],f[d]),i[d]=Math.max(i[d],h[d])}var g=H.bounds;if(H.autoBounds)for(var d=0;3>d;++d){if(i[d]d;++d)b=b||Z[0][d]!==g[0][d]||Z[1][d]!==g[1][d],Z[0][d]=g[0][d],Z[1][d]=g[1][d];if(b){for(var x=[0,0,0],o=0;3>o;++o)x[o]=a((g[1][o]-g[0][o])/10);z.autoTicks?z.update({bounds:g,tickSpacing:x}):z.update({bounds:g})}B=B||b,F=F||b;var _=A.drawingBufferWidth,w=A.drawingBufferHeight;q[0]=_,q[1]=w,G[0]=0|Math.max(_/H.pixelRatio,1),G[1]=0|Math.max(w/H.pixelRatio,1),v(D,H.fovy,_/w,H.zNear,H.zFar);for(var o=0;16>o;++o)U[o]=0;U[15]=1;for(var k=0,o=0;3>o;++o)k=Math.max(k,g[1][o]-g[0][o]);for(var o=0;3>o;++o)H.autoScale?U[5*o]=H.aspect[o]/(g[1][o]-g[0][o]):U[5*o]=1/k,H.autoCenter&&(U[12+o]=.5*-U[5*o]*(g[0][o]+g[1][o]));for(var o=0;r>o;++o){var l=O[o];l.axesBounds=g,H.clipToBounds&&(l.clipBounds=g)}if(T.object&&(H.snapToData?R.position=T.dataCoordinate:R.position=T.dataPosition,R.bounds=g),B&&(B=!1,y()),F){H.axesPixels=u(H.axes,V,_,w),H.onrender&&H.onrender(),A.bindFramebuffer(A.FRAMEBUFFER,null),A.viewport(0,0,_,w);var M=H.clearColor;A.clearColor(M[0],M[1],M[2],M[3]),A.clear(A.COLOR_BUFFER_BIT|A.DEPTH_BUFFER_BIT),A.depthMask(!0),A.colorMask(!0,!0,!0,!0),A.enable(A.DEPTH_TEST),A.depthFunc(A.LEQUAL),A.disable(A.BLEND),A.disable(A.CULL_FACE);var S=!1;z.enable&&(S=S||z.isTransparent(),z.draw(V)),R.axes=z,T.object&&R.draw(V),A.disable(A.CULL_FACE);for(var o=0;r>o;++o){var l=O[o];l.axes=z,l.pixelRatio=H.pixelRatio,l.isOpaque&&l.isOpaque()&&l.draw(V),l.isTransparent&&l.isTransparent()&&(S=!0)}if(S){E.shape=q,E.bind(),A.clear(A.DEPTH_BUFFER_BIT),A.colorMask(!1,!1,!1,!1),A.depthMask(!0),A.depthFunc(A.LESS),z.enable&&z.isTransparent()&&z.drawTransparent(V);for(var o=0;r>o;++o){var l=O[o];l.isOpaque&&l.isOpaque()&&l.draw(V)}A.enable(A.BLEND),A.blendEquation(A.FUNC_ADD),A.blendFunc(A.ONE,A.ONE_MINUS_SRC_ALPHA),A.colorMask(!0,!0,!0,!0),A.depthMask(!1),A.clearColor(0,0,0,0),A.clear(A.COLOR_BUFFER_BIT),z.isTransparent()&&z.drawTransparent(V);for(var o=0;r>o;++o){var l=O[o];l.isTransparent&&l.isTransparent()&&l.drawTransparent(V)}A.bindFramebuffer(A.FRAMEBUFFER,null),A.blendFunc(A.ONE,A.ONE_MINUS_SRC_ALPHA),A.disable(A.DEPTH_TEST),L.bind(),E.color[0].bind(0),L.uniforms.accumBuffer=0,p(A),A.disable(A.BLEND)}F=!1;for(var o=0;r>o;++o)O[o].dirty=!1}}}function x(){_||H.contextLost||(requestAnimationFrame(x),b())}t=t||{};var _=!1,w=(t.pixelRatio||parseFloat(window.devicePixelRatio),t.canvas);if(!w)if(w=document.createElement("canvas"),t.container){var k=t.container;k.appendChild(w)}else document.body.appendChild(w);var A=t.gl;if(A||(A=i(w,t.glOptions||{premultipliedAlpha:!0,antialias:!0})),!A)throw new Error("webgl not supported");var M=t.bounds||[[-10,-10,-10],[10,10,10]],T=new n,E=d(A,[A.drawingBufferWidth,A.drawingBufferHeight],{preferFloat:!0}),L=m(A),S=t.camera||{eye:[2,0,0],center:[0,0,0],up:[0,1,0],zoomMin:.1,zoomMax:100,mode:"turntable"},C=t.axes||{},z=c(A,C);z.enable=!C.disable;var P=t.spikes||{},R=f(A,P),O=[],I=[],N=[],j=[],F=!0,B=!0,D=new Array(16),U=new Array(16),V={view:null,projection:D,model:U},B=!0,q=[A.drawingBufferWidth,A.drawingBufferHeight],H={gl:A,contextLost:!1,pixelRatio:t.pixelRatio||parseFloat(window.devicePixelRatio),canvas:w,selection:T,camera:l(w,S),axes:z,axesPixels:null,spikes:R,bounds:M,objects:O,shape:q,aspect:t.aspectRatio||[1,1,1],pickRadius:t.pickRadius||10,zNear:t.zNear||.01,zFar:t.zFar||1e3,fovy:t.fovy||Math.PI/4,clearColor:t.clearColor||[0,0,0,0],autoResize:o(t.autoResize),autoBounds:o(t.autoBounds),autoScale:!!t.autoScale,autoCenter:o(t.autoCenter),clipToBounds:o(t.clipToBounds),snapToData:!!t.snapToData,onselect:t.onselect||null,onrender:t.onrender||null,onclick:t.onclick||null,cameraParams:V,oncontextloss:null,mouseListener:null},G=[A.drawingBufferWidth/H.pixelRatio|0,A.drawingBufferHeight/H.pixelRatio|0];H.autoResize&&e(),window.addEventListener("resize",e),H.update=function(t){_||(t=t||{},F=!0,B=!0)},H.add=function(t){_||(t.axes=z,O.push(t),I.push(-1),F=!0,B=!0,r())},H.remove=function(t){if(!_){var e=O.indexOf(t);0>e||(O.splice(e,1),I.pop(),F=!0,B=!0,r())}},H.dispose=function(){if(!_&&(_=!0,window.removeEventListener("resize",e),w.removeEventListener("webglcontextlost",s),H.mouseListener.enabled=!1,!H.contextLost)){z.dispose(),R.dispose();for(var t=0;ts;++s){var l=j[s].query(e,G[1]-r-1,H.pickRadius);if(l){if(l.distance>T.distance)continue;for(var c=0;i>c;++c){var u=O[c];if(I[c]===s){var f=u.pick(l);f&&(T.buttons=t,T.screen=l.coord,T.distance=l.distance,T.object=u,T.index=f.distance,T.dataPosition=f.position,T.dataCoordinate=f.dataCoordinate,T.data=f,o=!0)}}}}}a&&a!==T.object&&(a.highlight&&a.highlight(null),F=!0),T.object&&(T.object.highlight&&T.object.highlight(T.data),F=!0),o=o||T.object!==a,o&&H.onselect&&H.onselect(T),1&t&&!(1&X)&&H.onclick&&H.onclick(T),X=t}}),w.addEventListener("webglcontextlost",s);var W=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],Z=[W[0].slice(),W[1].slice()];return x(),H.redraw=function(){_||(F=!0,b())},H}e.exports=s;var l=t("3d-view-controls"),c=t("gl-axes3d"),u=t("gl-axes3d/properties"),f=t("gl-spikes3d"),h=t("gl-select-static"),d=t("gl-fbo"),p=t("a-big-triangle"),g=t("mouse-change"),v=t("gl-mat4/perspective"),m=t("./lib/shader")},{"./lib/shader":150,"3d-view-controls":20,"a-big-triangle":22,"gl-axes3d":99,"gl-axes3d/properties":106,"gl-fbo":114,"gl-mat4/perspective":131,"gl-select-static":165,"gl-spikes3d":175,"mouse-change":211}],152:[function(t,e,r){function n(t,e,r,n){var i,a,o,s,l,c=e[0],u=e[1],f=e[2],h=e[3],d=r[0],p=r[1],g=r[2],v=r[3];return a=c*d+u*p+f*g+h*v,0>a&&(a=-a,d=-d,p=-p,g=-g,v=-v),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n),t[0]=s*c+l*d,t[1]=s*u+l*p,t[2]=s*f+l*g,t[3]=s*h+l*v,t}e.exports=n},{}],153:[function(t,e,r){"use strict";e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n fragColor = color;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n",fragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n}\n",pickVertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 id;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\nuniform vec4 pickOffset;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n vec4 fragId = id + pickOffset;\n\n fragId.y += floor(fragId.x / 256.0);\n fragId.x -= floor(fragId.x / 256.0) * 256.0;\n\n fragId.z += floor(fragId.y / 256.0);\n fragId.y -= floor(fragId.y / 256.0) * 256.0;\n\n fragId.w += floor(fragId.z / 256.0);\n fragId.z -= floor(fragId.z / 256.0) * 256.0;\n\n fragColor = fragId / 255.0;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n",pickFragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = fragColor;\n}\n"}},{}],154:[function(t,e,r){"use strict";function n(t){if(t in h)return h[t];var e=u(t,{polygons:!0,font:"sans-serif",textAlign:"left",textBaseline:"alphabetic"}),r=[],n=[];e.forEach(function(t){t.forEach(function(t){for(var e=0;eo;++o)i[o]=Math.min(i[o],r[a+o]),i[2+o]=Math.max(i[2+o],r[a+o]);return h[t]={coords:r,normals:n,bounds:i}}function i(t,e,r,n,i,a,o){this.plot=t,this.shader=e,this.pickShader=r,this.positionBuffer=n,this.offsetBuffer=i,this.colorBuffer=a,this.idBuffer=o,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.numVertices=0,this.pickOffset=0,this.points=null}function a(t,e){var r=t.gl,n=o(r,f.vertex,f.fragment),a=o(r,f.pickVertex,f.pickFragment),l=s(r),c=s(r),u=s(r),h=s(r),d=new i(t,n,a,l,c,u,h);return d.update(e),t.addObject(d),d}e.exports=a;var o=t("gl-shader"),s=t("gl-buffer"),l=t("text-cache"),c=t("typedarray-pool"),u=t("vectorize-text"),f=t("./lib/shaders"),h={},d=i.prototype;!function(){function t(){var t=this.plot,n=this.bounds,i=t.viewBox,a=t.dataBox,o=t.pixelRatio,s=n[2]-n[0],l=n[3]-n[1],c=a[2]-a[0],u=a[3]-a[1];e[0]=2*s/c,e[4]=2*l/u,e[6]=2*(n[0]-a[0])/c-1,e[7]=2*(n[1]-a[1])/u-1;var f=i[2]-i[0],h=i[3]-i[1];r[0]=2*o/f,r[1]=2*o/h}var e=[1,0,0,0,1,0,0,0,1],r=[1,1];d.draw=function(){var n=this.plot,i=this.shader,a=this.numVertices;if(a){var o=n.gl;t.call(this),i.bind(),i.uniforms.pixelScale=r,i.uniforms.viewTransform=e,this.positionBuffer.bind(),i.attributes.position.pointer(),this.offsetBuffer.bind(),i.attributes.offset.pointer(),this.colorBuffer.bind(),i.attributes.color.pointer(o.UNSIGNED_BYTE,!0),o.drawArrays(o.TRIANGLES,0,a)}};var n=[0,0,0,0];d.drawPick=function(i){var a=this.plot,o=this.pickShader,s=this.numVertices,l=a.gl;if(this.pickOffset=i,!s)return i;for(var c=0;4>c;++c)n[c]=i>>8*c&255;return t.call(this),o.bind(),o.uniforms.pixelScale=r,o.uniforms.viewTransform=e,o.uniforms.pickOffset=n,this.positionBuffer.bind(),o.attributes.position.pointer(),this.offsetBuffer.bind(),o.attributes.offset.pointer(),this.idBuffer.bind(),o.attributes.id.pointer(l.UNSIGNED_BYTE,!1),l.drawArrays(l.TRIANGLES,0,s),i+this.numPoints}}(),d.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},d.update=function(t){t=t||{};var e=t.positions||[],r=t.colors||[],i=t.glyphs||[],a=t.sizes||[],o=t.borderWidths||[],s=t.borderColors||[];this.points=e;for(var u=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=0,h=0;h>1;for(var d=0;2>d;++d)u[d]=Math.min(u[d],e[2*h+d]),u[2+d]=Math.max(u[2+d],e[2*h+d])}u[0]===u[2]&&(u[2]+=1),u[3]===u[1]&&(u[3]+=1);for(var p=1/(u[2]-u[0]),g=1/(u[3]-u[1]),v=u[0],m=u[1],y=c.mallocFloat32(2*f),b=c.mallocFloat32(2*f),x=c.mallocUint8(4*f),_=c.mallocUint32(f),w=0,h=0;h=a?i(0,a-1,t,e,r,n):f(0,a-1,t,e,r,n)}function i(t,e,r,n,i,a){for(var o=t+1;e>=o;++o){for(var s=r[o],l=n[2*o],c=n[2*o+1],u=i[o],f=a[o],h=o;h>t;){var d=r[h-1],p=n[2*(h-1)];if((d-s||l-p)>=0)break;r[h]=d,n[2*h]=p,n[2*h+1]=n[2*h-1],i[h]=i[h-1],a[h]=a[h-1],h-=1}r[h]=s,n[2*h]=l,n[2*h+1]=c,i[h]=u,a[h]=f}}function a(t,e,r,n,i,a){var o=r[t],s=n[2*t],l=n[2*t+1],c=i[t],u=a[t];r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e],r[e]=o,n[2*e]=s,n[2*e+1]=l,i[e]=c,a[e]=u}function o(t,e,r,n,i,a){r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e]}function s(t,e,r,n,i,a,o){var s=n[t],l=i[2*t],c=i[2*t+1],u=a[t],f=o[t];n[t]=n[e],i[2*t]=i[2*e],i[2*t+1]=i[2*e+1],a[t]=a[e],o[t]=o[e],n[e]=n[r],i[2*e]=i[2*r],i[2*e+1]=i[2*r+1],a[e]=a[r],o[e]=o[r],n[r]=s,i[2*r]=l,i[2*r+1]=c,a[r]=u,o[r]=f}function l(t,e,r,n,i,a,o,s,l,c,u){s[t]=s[e],l[2*t]=l[2*e],l[2*t+1]=l[2*e+1],c[t]=c[e],u[t]=u[e],s[e]=r,l[2*e]=n,l[2*e+1]=i,c[e]=a,u[e]=o}function c(t,e,r,n,i){return(r[t]-r[e]||n[2*e]-n[2*t]||i[t]-i[e])<0}function u(t,e,r,n,i,a,o,s){return(e-a[t]||o[2*t]-r||i-s[t])<0}function f(t,e,r,n,d,p){var g=(e-t+1)/6|0,v=t+g,m=e-g,y=t+e>>1,b=y-g,x=y+g,_=v,w=b,k=y,A=x,M=m,T=t+1,E=e-1,L=0;c(_,w,r,n,d,p)&&(L=_,_=w,w=L),c(A,M,r,n,d,p)&&(L=A,A=M,M=L),c(_,k,r,n,d,p)&&(L=_,_=k,k=L),c(w,k,r,n,d,p)&&(L=w,w=k,k=L),c(_,A,r,n,d,p)&&(L=_,_=A,A=L),c(k,A,r,n,d,p)&&(L=k,k=A,A=L),c(w,M,r,n,d,p)&&(L=w,w=M,M=L),c(w,k,r,n,d,p)&&(L=w,w=k,k=L),c(A,M,r,n,d,p)&&(L=A,A=M,M=L);var S=r[w],C=n[2*w],z=n[2*w+1],P=d[w],R=p[w],O=r[A],I=n[2*A],N=n[2*A+1],j=d[A],F=p[A],B=_,D=k,U=M,V=v,q=y,H=m,G=r[B],Y=r[D],X=r[U];r[V]=G,r[q]=Y,r[H]=X;for(var W=0;2>W;++W){var Z=n[2*B+W],K=n[2*D+W],Q=n[2*U+W];n[2*V+W]=Z,n[2*q+W]=K,n[2*H+W]=Q}var $=d[B],J=d[D],tt=d[U];d[V]=$,d[q]=J,d[H]=tt;var et=p[B],rt=p[D],nt=p[U];p[V]=et,p[q]=rt,p[H]=nt,o(b,t,r,n,d,p),o(x,e,r,n,d,p);for(var it=T;E>=it;++it)if(u(it,S,C,z,P,r,n,d))it!==T&&a(it,T,r,n,d,p),++T;else if(!u(it,O,I,N,j,r,n,d))for(;;){if(u(E,O,I,N,j,r,n,d)){u(E,S,C,z,P,r,n,d)?(s(it,T,E,r,n,d,p),++T,--E):(a(it,E,r,n,d,p),--E);break}if(--E=T-2-t?i(t,T-2,r,n,d,p):f(t,T-2,r,n,d,p),h>=e-(E+2)?i(E+2,e,r,n,d,p):f(E+2,e,r,n,d,p),h>=E-T?i(T,E,r,n,d,p):f(T,E,r,n,d,p)}e.exports=n;var h=32},{}],158:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s){for(var l=r,c=r;n>c;++c){var u=t[2*c],f=t[2*c+1],h=e[c];u>=i&&o>=u&&f>=a&&s>=f&&(c===l?l+=1:(t[2*c]=t[2*l],t[2*c+1]=t[2*l+1],e[c]=e[l],t[2*l]=u,t[2*l+1]=f,e[l]=h,l+=1))}return l}function i(t,e,r){this.pixelSize=t,this.offset=e,this.count=r}function a(t,e,r,a){function l(i,a,o,s,c,u){var f=.5*o,h=s+1,d=c-s;r[_]=d,x[_++]=u;for(var p=0;2>p;++p)for(var g=0;2>g;++g){var v=i+p*f,m=a+g*f,y=n(t,e,h,c,v,m,v+f,m+f);if(y!==h){if(y-h>=Math.max(.9*d,32)){var b=c+s>>>1;l(v,m,f,h,b,u+1),h=b}l(v,m,f,h,y,u+1),h=y}}}var c=t.length>>>1;if(1>c)return[];for(var u=1/0,f=1/0,h=-(1/0),d=-(1/0),p=0;c>p;++p){var g=t[2*p],v=t[2*p+1];u=Math.min(u,g),h=Math.max(h,g),f=Math.min(f,v),d=Math.max(d,v),e[p]=p}u===h&&(h+=1+Math.abs(h)),f===d&&(d+=1+Math.abs(h));var m=1/(h-u),y=1/(d-f),b=Math.max(h-u,d-f);a=a||[0,0,0,0],a[0]=u,a[1]=f,a[2]=h,a[3]=d;var x=o.mallocInt32(c),_=0;l(u,f,b,0,c,0),s(x,t,e,r,c);for(var w=[],k=0,A=c,_=c-1;_>=0;--_){t[2*_]=(t[2*_]-u)*m,t[2*_+1]=(t[2*_+1]-f)*y;var M=x[_];M!==k&&(w.push(new i(b*Math.pow(.5,M),_+1,A-(_+1))),A=_+1,k=M)}return w.push(new i(b*Math.pow(.5,M+1),0,A)),o.free(x),w}var o=t("typedarray-pool"),s=t("./lib/sort");e.exports=a},{"./lib/sort":157,"typedarray-pool":282}],159:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.weightBuffer=n,this.shader=i,this.pickShader=a,this.scales=[],this.size=12,this.borderSize=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.pickOffset=0,this.points=null,this.xCoords=null}function i(t,e){var r=t.gl,i=o(r),s=o(r),l=o(r),c=a(r,u.pointVertex,u.pointFragment),f=a(r,u.pickVertex,u.pickFragment),h=new n(t,i,s,l,c,f);return h.update(e),t.addObject(h),h}var a=t("gl-shader"),o=t("gl-buffer"),s=t("binary-search-bounds"),l=t("snap-points-2d"),c=t("typedarray-pool"),u=t("./lib/shader");e.exports=i;var f=n.prototype;f.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.xCoords&&c.free(this.xCoords),this.plot.removeObject(this)},f.update=function(t){function e(e,r){return e in t?t[e]:r}t=t||{},this.size=e("size",12),this.color=e("color",[1,0,0,1]).slice(),this.borderSize=e("borderSize",1),this.borderColor=e("borderColor",[0,0,0,1]).slice(),this.xCoords&&c.free(this.xCoords);var r=t.positions,n=c.mallocFloat32(r.length),i=c.mallocInt32(r.length>>>1);n.set(r);var a=c.mallocFloat32(r.length);this.points=r,this.scales=l(n,i,a,this.bounds),this.offsetBuffer.update(n),this.pickBuffer.update(i),this.weightBuffer.update(a);for(var o=c.mallocFloat32(r.length>>>1),s=0,u=0;s>>1,this.pickOffset=0},f.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0,0,0];return function(r){var n=this.plot,i=this.pickShader,a=this.scales,o=this.offsetBuffer,l=this.pickBuffer,c=this.bounds,u=this.size,f=this.borderSize,h=n.gl,d=n.pickPixelRatio,p=n.viewBox,g=n.dataBox;if(0===this.pointCount)return r;var v=c[2]-c[0],m=c[3]-c[1],y=g[2]-g[0],b=g[3]-g[1],x=(p[2]-p[0])*d/n.pixelRatio,_=(p[3]-p[1])*d/n.pixelRatio,w=Math.min(y/x,b/_);t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(c[0]-g[0])/y-1,t[7]=2*(c[1]-g[1])/b-1,this.pickOffset=r,e[0]=255&r,e[1]=r>>8&255,e[2]=r>>16&255,e[3]=r>>24&255,i.bind(),i.uniforms.matrix=t,i.uniforms.color=this.color,i.uniforms.borderColor=this.borderColor,i.uniforms.pointSize=d*(u+f),i.uniforms.pickOffset=e,0===this.borderSize?i.uniforms.centerFraction=2:i.uniforms.centerFraction=u/(u+f+1.25),o.bind(),i.attributes.position.pointer(),l.bind(),i.attributes.pickId.pointer(h.UNSIGNED_BYTE);for(var k=this.xCoords,A=(g[0]-c[0]-w*u*d)/v,M=(g[2]-c[0]+w*u*d)/v,T=a.length-1;T>=0;--T){var E=a[T];if(!(E.pixelSize1)){var L=E.offset,S=E.count+L,C=s.ge(k,A,L,S-1),z=s.lt(k,M,C,S-1)+1;z>C&&h.drawArrays(h.POINTS,C,z-C)}}return r+this.pointCount}}(),f.draw=function(){var t=[1,0,0,0,1,0,0,0,1];return function(){var e=this.plot,r=this.shader,n=this.scales,i=this.offsetBuffer,a=this.bounds,o=this.size,l=this.borderSize,c=e.gl,u=e.pixelRatio,f=e.viewBox,h=e.dataBox;if(0!==this.pointCount){var d=a[2]-a[0],p=a[3]-a[1],g=h[2]-h[0],v=h[3]-h[1],m=f[2]-f[0],y=f[3]-f[1],b=Math.min(g/m,v/y);t[0]=2*d/g,t[4]=2*p/v,t[6]=2*(a[0]-h[0])/g-1,t[7]=2*(a[1]-h[1])/v-1,r.bind(),r.uniforms.matrix=t,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointSize=u*(o+l),r.uniforms.useWeight=1,0===this.borderSize?r.uniforms.centerFraction=2:r.uniforms.centerFraction=o/(o+l+1.25),i.bind(),r.attributes.position.pointer(),this.weightBuffer.bind(),r.attributes.weight.pointer();for(var x=this.xCoords,_=(h[0]-a[0]-b*o*u)/d,w=(h[2]-a[0]+b*o*u)/d,k=!0,A=n.length-1;A>=0;--A){var M=n[A];if(!(M.pixelSize1)){var T=M.offset,E=M.count+T,L=s.ge(x,_,T,E-1),S=s.lt(x,w,L,E-1)+1;S>L&&c.drawArrays(c.POINTS,L,S-L),k&&(k=!1,r.uniforms.useWeight=0)}}}}}(),f.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}}},{"./lib/shader":155,"binary-search-bounds":156,"gl-buffer":107,"gl-shader":166,"snap-points-2d":158,"typedarray-pool":282}],160:[function(t,e,r){"use strict";function n(t,e){var r=a[e];if(r||(r=a[e]={}),t in r)return r[t];for(var n=i(t,{textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),o=i(t,{triangles:!0,textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),s=[[1/0,1/0],[-(1/0),-(1/0)]],l=0;lu;++u)s[0][u]=Math.min(s[0][u],c[u]),s[1][u]=Math.max(s[1][u],c[u]);return r[t]=[o,n,s]}var i=t("vectorize-text");e.exports=n;var a={}},{"vectorize-text":285}],161:[function(t,e,r){function n(t,e){var r=i(t,e),n=r.attributes;return n.position.location=0,n.color.location=1,n.glyph.location=2,n.id.location=3,r}var i=t("gl-shader"),a="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1])) ) {\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}",o="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || any(greaterThan(position, clipBounds[1]))) {\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}",s="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) ||\n any(greaterThan(position, clipBounds[1])) ) {\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",l="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if(any(lessThan(dataCoordinate, fragClipBounds[0])) ||\n any(greaterThan(dataCoordinate, fragClipBounds[1])) ) {\n discard;\n } else {\n gl_FragColor = interpColor * opacity;\n }\n}\n",c="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if(any(lessThan(dataCoordinate, fragClipBounds[0])) || \n any(greaterThan(dataCoordinate, fragClipBounds[1])) ) {\n discard;\n } else {\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n }\n}",u=[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"glyph",type:"vec2"},{name:"id",type:"vec4"}],f={vertex:a,fragment:l,attributes:u},h={vertex:o,fragment:l,attributes:u},d={vertex:s,fragment:l,attributes:u},p={vertex:a,fragment:c,attributes:u},g={vertex:o,fragment:c,attributes:u},v={vertex:s,fragment:c,attributes:u};r.createPerspective=function(t){return n(t,f)},r.createOrtho=function(t){return n(t,h)},r.createProject=function(t){return n(t,d)},r.createPickPerspective=function(t){return n(t,p)},r.createPickOrtho=function(t){return n(t,g)},r.createPickProject=function(t){return n(t,v)}},{"gl-shader":166}],162:[function(t,e,r){"use strict";function n(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];return t[0]=e[0]*r+e[4]*n+e[8]*i+e[12]*a,t[1]=e[1]*r+e[5]*n+e[9]*i+e[13]*a,t[2]=e[2]*r+e[6]*n+e[10]*i+e[14]*a,t[3]=e[3]*r+e[7]*n+e[11]*i+e[15]*a,t}function i(t,e,r,i){return n(i,i,r),n(i,i,e),n(i,i,t)}function a(t,e){this.index=t,this.dataCoordinate=this.position=e}function o(t,e,r,n,i,o,s,l,c,u,f,h){this.gl=t,this.pixelRatio=1,this.shader=e,this.orthoShader=r,this.projectShader=n,this.pointBuffer=i,this.colorBuffer=o,this.glyphBuffer=s,this.idBuffer=l,this.vao=c,this.vertexCount=0,this.lineVertexCount=0,this.opacity=1,this.lineWidth=0,this.projectScale=[2/3,2/3,2/3],this.projectOpacity=[1,1,1],this.pickId=0,this.pickPerspectiveShader=u,this.pickOrthoShader=f,this.pickProjectShader=h,this.points=[],this._selectResult=new a(0,[0,0,0]),this.useOrtho=!0,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.axesProject=[!0,!0,!0],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.highlightId=[1,1,1,1],this.highlightScale=2,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.dirty=!0}function s(t){return t[0]=t[1]=t[2]=0,t}function l(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t}function c(t,e,r,n){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[r]=n,t}function u(t){for(var e=S,r=0;2>r;++r)for(var n=0;3>n;++n)e[r][n]=Math.max(Math.min(t[r][n],1e8),-1e8);return e}function f(t,e,r,n,a){var o,f=e.axesProject,h=e.gl,d=t.uniforms,p=r.model||x,g=r.view||x,v=r.projection||x,y=e.axesBounds,b=u(e.clipBounds);o=e.axes?e.axes.lastCubeProps.axis:[1,1,1],w[0]=2/h.drawingBufferWidth,w[1]=2/h.drawingBufferHeight,t.bind(),d.view=g,d.projection=v,d.screenSize=w,d.highlightId=e.highlightId,d.highlightScale=e.highlightScale,d.clipBounds=b,d.pickGroup=e.pickId/255,d.pixelRatio=e.pixelRatio;for(var _=0;3>_;++_)if(f[_]&&e.projectOpacity[_]<1===n){d.scale=e.projectScale[_],d.opacity=e.projectOpacity[_];for(var S=E,C=0;16>C;++C)S[C]=0;for(var C=0;4>C;++C)S[5*C]=1;S[5*_]=0,o[_]<0?S[12+_]=y[0][_]:S[12+_]=y[1][_],m(S,p,S),d.model=S;var z=(_+1)%3,P=(_+2)%3,R=s(k),O=s(A);R[z]=1,O[P]=1;var I=i(v,g,p,l(M,R)),N=i(v,g,p,l(T,O));if(Math.abs(I[1])>Math.abs(N[1])){var j=I;I=N,N=j,j=R,R=O,O=j;var F=z;z=P,P=F}I[0]<0&&(R[z]=-1),N[1]>0&&(O[P]=-1);for(var B=0,D=0,C=0;4>C;++C)B+=Math.pow(p[4*z+C],2), +D+=Math.pow(p[4*P+C],2);R[z]/=Math.sqrt(B),O[P]/=Math.sqrt(D),d.axes[0]=R,d.axes[1]=O,d.fragClipBounds[0]=c(L,b[0],_,-1e8),d.fragClipBounds[1]=c(L,b[1],_,1e8),e.vao.draw(h.TRIANGLES,e.vertexCount),e.lineWidth>0&&(h.lineWidth(e.lineWidth),e.vao.draw(h.LINES,e.lineVertexCount,e.vertexCount))}}function h(t,e,r,n,i,a){var o=r.gl;if(r.vao.bind(),i===r.opacity<1||a){t.bind();var s=t.uniforms;s.model=n.model||x,s.view=n.view||x,s.projection=n.projection||x,w[0]=2/o.drawingBufferWidth,w[1]=2/o.drawingBufferHeight,s.screenSize=w,s.highlightId=r.highlightId,s.highlightScale=r.highlightScale,s.fragClipBounds=P,s.clipBounds=r.axes.bounds,s.opacity=r.opacity,s.pickGroup=r.pickId/255,s.pixelRatio=r.pixelRatio,r.vao.draw(o.TRIANGLES,r.vertexCount),r.lineWidth>0&&(o.lineWidth(r.lineWidth),r.vao.draw(o.LINES,r.lineVertexCount,r.vertexCount))}f(e,r,n,i,a),r.vao.unbind()}function d(t){var e=t.gl,r=y.createPerspective(e),n=y.createOrtho(e),i=y.createProject(e),a=y.createPickPerspective(e),s=y.createPickOrtho(e),l=y.createPickProject(e),c=p(e),u=p(e),f=p(e),h=p(e),d=g(e,[{buffer:c,size:3,type:e.FLOAT},{buffer:u,size:4,type:e.FLOAT},{buffer:f,size:2,type:e.FLOAT},{buffer:h,size:4,type:e.UNSIGNED_BYTE,normalized:!0}]),v=new o(e,r,n,i,c,u,f,h,d,a,s,l);return v.update(t),v}var p=t("gl-buffer"),g=t("gl-vao"),v=t("typedarray-pool"),m=t("gl-mat4/multiply"),y=t("./lib/shaders"),b=t("./lib/glyphs"),x=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];e.exports=d;var _=o.prototype;_.pickSlots=1,_.setPickBase=function(t){this.pickId=t},_.isTransparent=function(){if(this.opacity<1)return!0;for(var t=0;3>t;++t)if(this.axesProject[t]&&this.projectOpacity[t]<1)return!0;return!1},_.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;3>t;++t)if(this.axesProject[t]&&this.projectOpacity[t]>=1)return!0;return!1};var w=[0,0],k=[0,0,0],A=[0,0,0],M=[0,0,0,1],T=[0,0,0,1],E=x.slice(),L=[0,0,0],S=[[0,0,0],[0,0,0]],C=[-1e8,-1e8,-1e8],z=[1e8,1e8,1e8],P=[C,z];_.draw=function(t){var e=this.useOrtho?this.orthoShader:this.shader;h(e,this.projectShader,this,t,!1,!1)},_.drawTransparent=function(t){var e=this.useOrtho?this.orthoShader:this.shader;h(e,this.projectShader,this,t,!0,!1)},_.drawPick=function(t){var e=this.useOrtho?this.pickOrthoShader:this.pickPerspectiveShader;h(e,this.pickProjectShader,this,t,!1,!0)},_.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[2]+(t.value[1]<<8)+(t.value[0]<<16);if(e>=this.pointCount||0>e)return null;var r=this.points[e],n=this._selectResult;n.index=e;for(var i=0;3>i;++i)n.position[i]=n.dataCoordinate[i]=r[i];return n},_.highlight=function(t){if(t){var e=t.index,r=255&e,n=e>>8&255,i=e>>16&255;this.highlightId=[r/255,n/255,i/255,0]}else this.highlightId=[1,1,1,1]},_.update=function(t){if(t=t||{},"perspective"in t&&(this.useOrtho=!t.perspective),"orthographic"in t&&(this.useOrtho=!!t.orthographic),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"project"in t)if(Array.isArray(t.project))this.axesProject=t.project;else{var e=!!t.project;this.axesProject=[e,e,e]}if("projectScale"in t)if(Array.isArray(t.projectScale))this.projectScale=t.projectScale.slice();else{var r=+t.projectScale;this.projectScale=[r,r,r]}if("projectOpacity"in t)if(Array.isArray(t.projectOpacity))this.projectOpacity=t.projectOpacity.slice();else{var r=+t.projectOpacity;this.projectOpacity=[r,r,r]}"opacity"in t&&(this.opacity=t.opacity),this.dirty=!0;var n=t.position;if(n){var i=t.font||"normal",a=t.alignment||[0,0],o=[1/0,1/0,1/0],s=[-(1/0),-(1/0),-(1/0)],l=t.glyph,c=t.color,u=t.size,f=t.angle,h=t.lineColor,d=0,p=0,g=0,m=n.length;t:for(var y=0;m>y;++y){for(var x=n[y],_=0;3>_;++_)if(isNaN(x[_])||!isFinite(x[_]))continue t;var w;w=Array.isArray(l)?b(l[y],i):l?b(l,i):b("\u25cf",i);var k=w[0],A=w[1],M=w[2];p+=3*k.cells.length,g+=2*A.edges.length}var T=p+g,E=v.mallocFloat(3*T),L=v.mallocFloat(4*T),S=v.mallocFloat(2*T),C=v.mallocUint32(T),z=[0,a[1]],P=0,R=p,O=[0,0,0,1],I=[0,0,0,1],N=Array.isArray(c)&&Array.isArray(c[0]),j=Array.isArray(h)&&Array.isArray(h[0]);t:for(var y=0;m>y;++y){for(var x=n[y],_=0;3>_;++_){if(isNaN(x[_])||!isFinite(x[_])){d+=1;continue t}s[_]=Math.max(s[_],x[_]),o[_]=Math.min(o[_],x[_])}var w;w=Array.isArray(l)?b(l[y],i):l?b(l,i):b("\u25cf",i);var k=w[0],A=w[1],M=w[2];if(Array.isArray(c)){var F;if(F=N?c[y]:c,3===F.length){for(var _=0;3>_;++_)O[_]=F[_];O[3]=1}else if(4===F.length)for(var _=0;4>_;++_)O[_]=F[_]}else O[0]=O[1]=O[2]=0,O[3]=1;if(Array.isArray(h)){var F;if(F=j?h[y]:h,3===F.length){for(var _=0;3>_;++_)I[_]=F[_];I[_]=1}else if(4===F.length)for(var _=0;4>_;++_)I[_]=F[_]}else I[0]=I[1]=I[2]=0,I[3]=1;var B=.5;Array.isArray(u)?B=+u[y]:u?B=+u:this.useOrtho&&(B=12);var D=0;Array.isArray(f)?D=+f[y]:f&&(D=+f);for(var U=Math.cos(D),V=Math.sin(D),x=n[y],_=0;3>_;++_)s[_]=Math.max(s[_],x[_]),o[_]=Math.min(o[_],x[_]);a[0]<0?z[0]=a[0]*(1+M[1][0]):a[0]>0&&(z[0]=-a[0]*(1+M[0][0]));for(var q=k.cells,H=k.positions,_=0;_Y;++Y){for(var X=0;3>X;++X)E[3*P+X]=x[X];for(var X=0;4>X;++X)L[4*P+X]=O[X];C[P]=d;var W=H[G[Y]];S[2*P]=B*(U*W[0]-V*W[1]+z[0]),S[2*P+1]=B*(V*W[0]+U*W[1]+z[1]),P+=1}for(var q=A.edges,H=A.positions,_=0;_Y;++Y){for(var X=0;3>X;++X)E[3*R+X]=x[X];for(var X=0;4>X;++X)L[4*R+X]=I[X];C[R]=d;var W=H[G[Y]];S[2*R]=B*(U*W[0]-V*W[1]+z[0]),S[2*R+1]=B*(V*W[0]+U*W[1]+z[1]),R+=1}d+=1}this.vertexCount=p,this.lineVertexCount=g,this.pointBuffer.update(E),this.colorBuffer.update(L),this.glyphBuffer.update(S),this.idBuffer.update(new Uint32Array(C)),v.free(E),v.free(L),v.free(S),v.free(C),this.bounds=[o,s],this.points=n,this.pointCount=n.length}},_.dispose=function(){this.shader.dispose(),this.orthoShader.dispose(),this.pickPerspectiveShader.dispose(),this.pickOrthoShader.dispose(),this.vao.dispose(),this.pointBuffer.dispose(),this.colorBuffer.dispose(),this.glyphBuffer.dispose(),this.idBuffer.dispose()}},{"./lib/glyphs":160,"./lib/shaders":161,"gl-buffer":107,"gl-mat4/multiply":130,"gl-vao":182,"typedarray-pool":282}],163:[function(t,e,r){"use strict";r.boxVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n",r.boxFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"},{}],164:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.boxBuffer=e,this.boxShader=r,this.enabled=!0,this.selectBox=[1/0,1/0,-(1/0),-(1/0)],this.borderColor=[0,0,0,1],this.innerFill=!1,this.innerColor=[0,0,0,.25],this.outerFill=!0,this.outerColor=[0,0,0,.5],this.borderWidth=10}function i(t,e){var r=t.gl,i=o(r,[0,0,0,1,1,0,1,1]),l=a(r,s.boxVertex,s.boxFragment),c=new n(t,i,l);return c.update(e),t.addOverlay(c),c}var a=t("gl-shader"),o=t("gl-buffer"),s=t("./lib/shaders");e.exports=i;var l=n.prototype;l.draw=function(){if(this.enabled){var t=this.plot,e=this.selectBox,r=this.borderWidth,n=(this.innerFill,this.innerColor),i=(this.outerFill,this.outerColor),a=this.borderColor,o=t.box,s=t.screenBox,l=t.dataBox,c=t.viewBox,u=t.pixelRatio,f=(e[0]-l[0])*(c[2]-c[0])/(l[2]-l[0])+c[0],h=(e[1]-l[1])*(c[3]-c[1])/(l[3]-l[1])+c[1],d=(e[2]-l[0])*(c[2]-c[0])/(l[2]-l[0])+c[0],p=(e[3]-l[1])*(c[3]-c[1])/(l[3]-l[1])+c[1];if(f=Math.max(f,c[0]),h=Math.max(h,c[1]),d=Math.min(d,c[2]),p=Math.min(p,c[3]),!(f>d||h>p)){o.bind();var g=s[2]-s[0],v=s[3]-s[1];if(this.outerFill&&(o.drawBox(0,0,g,h,i),o.drawBox(0,h,f,p,i),o.drawBox(0,p,g,v,i),o.drawBox(d,h,g,p,i)),this.innerFill&&o.drawBox(f,h,d,p,n),r>0){var m=r*u;o.drawBox(f-m,h-m,d+m,h+m,a),o.drawBox(f-m,p-m,d+m,p+m,a),o.drawBox(f-m,h-m,f+m,p+m,a),o.drawBox(d-m,h-m,d+m,p+m,a)}}}},l.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},l.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":163,"gl-buffer":107,"gl-shader":166}],165:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.coord=[t,e],this.id=r,this.value=n,this.distance=i}function i(t,e,r){this.gl=t,this.fbo=e,this.buffer=r,this._readTimeout=null;var n=this;this._readCallback=function(){n.gl&&(e.bind(),t.readPixels(0,0,e.shape[0],e.shape[1],t.RGBA,t.UNSIGNED_BYTE,n.buffer),n._readTimeout=null)}}function a(t,e){var r=o(t,e),n=s.mallocUint8(e[0]*e[1]*4);return new i(t,r,n)}e.exports=a;var o=t("gl-fbo"),s=t("typedarray-pool"),l=t("ndarray"),c=t("bit-twiddle").nextPow2,u=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(255>_inline_34_arg0_||255>_inline_34_arg1_||255>_inline_34_arg2_||255>_inline_34_arg3_){var _inline_34_l=_inline_34_arg4_-_inline_34_arg6_[0],_inline_34_a=_inline_34_arg5_-_inline_34_arg6_[1],_inline_34_f=_inline_34_l*_inline_34_l+_inline_34_a*_inline_34_a;_inline_34_fthis.buffer.length){s.free(this.buffer);for(var n=this.buffer=s.mallocUint8(c(r*e*4)),i=0;r*e*4>i;++i)n[i]=255}return t}}}),f.begin=function(){var t=this.gl;this.shape;t&&(this.fbo.bind(),t.clearColor(1,1,1,1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT))},f.end=function(){var t=this.gl;t&&(t.bindFramebuffer(t.FRAMEBUFFER,null),this._readTimeout||clearTimeout(this._readTimeout),this._readTimeout=setTimeout(this._readCallback,1))},f.query=function(t,e,r){if(!this.gl)return null;var i=this.fbo.shape.slice();t=0|t,e=0|e,"number"!=typeof r&&(r=1);var a=0|Math.min(Math.max(t-r,0),i[0]),o=0|Math.min(Math.max(t+r,0),i[0]),s=0|Math.min(Math.max(e-r,0),i[1]),c=0|Math.min(Math.max(e+r,0),i[1]);if(a>=o||s>=c)return null;var f=[o-a,c-s],h=l(this.buffer,[f[0],f[1],4],[4,4*i[0],1],4*(a+i[0]*s)),d=u(h.hi(f[0],f[1],1),r,r),p=d[0],g=d[1];if(0>p||Math.pow(this.radius,2)=0){for(var A=0|k.type.charAt(k.type.length-1),M=new Array(A),T=0;A>T;++T)M[T]=_.length,x.push(k.name+"["+T+"]"),"number"==typeof k.location?_.push(k.location+T):Array.isArray(k.location)&&k.location.length===A&&"number"==typeof k.location[T]?_.push(0|k.location[T]):_.push(-1);b.push({name:k.name,type:k.type,locations:M})}else b.push({name:k.name,type:k.type,locations:[_.length]}),x.push(k.name),"number"==typeof k.location?_.push(0|k.location):_.push(-1)}for(var E=0,w=0;w<_.length;++w)if(_[w]<0){for(;_.indexOf(E)>=0;)E+=1;_[w]=E}var L=new Array(r.length);a(),d._relink=a,d.types={uniforms:l(r),attributes:l(n)},d.attributes=s(p,d,b,_),Object.defineProperty(d,"uniforms",o(p,d,r,L))},e.exports=a},{"./lib/GLError":167,"./lib/create-attributes":168,"./lib/create-uniforms":169,"./lib/reflect":170,"./lib/runtime-reflect":171,"./lib/shader-cache":172}],167:[function(t,e,r){function n(t,e,r){this.shortMessage=e||"",this.longMessage=r||"",this.rawError=t||"",this.message="gl-shader: "+(e||t||"")+(r?"\n"+r:""),this.stack=(new Error).stack}n.prototype=new Error,n.prototype.name="GLError",n.prototype.constructor=n,e.exports=n},{}],168:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}function i(t,e,r,i,a,o,s){for(var l=["gl","v"],c=[],u=0;a>u;++u)l.push("x"+u),c.push("x"+u);l.push("if(x0.length===void 0){return gl.vertexAttrib"+a+"f(v,"+c.join()+")}else{return gl.vertexAttrib"+a+"fv(v,x0)}");var f=Function.apply(null,l),h=new n(t,e,r,i,a,f);Object.defineProperty(o,s,{set:function(e){return t.disableVertexAttribArray(i[r]),f(t,i[r],e),e},get:function(){return h},enumerable:!0})}function a(t,e,r,n,a,o,s){for(var l=new Array(a),c=new Array(a),u=0;a>u;++u)i(t,e,r[u],n,a,l,u),c[u]=l[u];Object.defineProperty(l,"location",{set:function(t){if(Array.isArray(t))for(var e=0;a>e;++e)c[e].location=t[e];else for(var e=0;a>e;++e)c[e].location=t+e;return t},get:function(){for(var t=new Array(a),e=0;a>e;++e)t[e]=n[r[e]];return t},enumerable:!0}),l.pointer=function(e,i,o,s){e=e||t.FLOAT,i=!!i,o=o||a*a,s=s||0;for(var l=0;a>l;++l){var c=n[r[l]];t.vertexAttribPointer(c,a,e,i,o,s+l*a),t.enableVertexAttribArray(c)}};var f=new Array(a),h=t["vertexAttrib"+a+"fv"];Object.defineProperty(o,s,{set:function(e){for(var i=0;a>i;++i){var o=n[r[i]];if(t.disableVertexAttribArray(o),Array.isArray(e[0]))h.call(t,o,e[i]);else{for(var s=0;a>s;++s)f[s]=e[a*i+s];h.call(t,o,f)}}return e},get:function(){return l},enumerable:!0})}function o(t,e,r,n){for(var o={},l=0,c=r.length;c>l;++l){var u=r[l],f=u.name,h=u.type,d=u.locations;switch(h){case"bool":case"int":case"float":i(t,e,d[0],n,1,o,f);break;default:if(h.indexOf("vec")>=0){var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);i(t,e,d[0],n,p,o,f)}else{if(!(h.indexOf("mat")>=0))throw new s("","Unknown data type for attribute "+f+": "+h);var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);a(t,e,d,n,p,o,f)}}}return o}e.exports=o;var s=t("./GLError"),l=n.prototype;l.pointer=function(t,e,r,n){var i=this,a=i._gl,o=i._locations[i._index];a.vertexAttribPointer(o,i._dimension,t||a.FLOAT,!!e,r||0,n||0),a.enableVertexAttribArray(o)},l.set=function(t,e,r,n){return this._constFunc(this._locations[this._index],t,e,r,n)},Object.defineProperty(l,"location",{get:function(){return this._locations[this._index]},set:function(t){return t!==this._locations[this._index]&&(this._locations[this._index]=0|t,this._wrapper.program=null),0|t}})},{"./GLError":167}],169:[function(t,e,r){"use strict";function n(t){var e=new Function("y","return function(){return y}");return e(t)}function i(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e,r,a){function l(r){var n=new Function("gl","wrapper","locations","return function(){return gl.getUniform(wrapper.program,locations["+r+"])}");return n(t,e,a)}function c(t,e,r){switch(r){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+e+"],obj"+t+")";case"float":return"gl.uniform1f(locations["+e+"],obj"+t+")";default:var n=r.indexOf("vec");if(!(n>=0&&1>=n&&r.length===4+n)){if(0===r.indexOf("mat")&&4===r.length){var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+i+"fv(locations["+e+"],false,obj"+t+")"}throw new s("","Unknown uniform data type for "+name+": "+r)}var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+i+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+i+"fv(locations["+e+"],obj"+t+")";default:throw new s("","Unrecognized data type for vector "+name+": "+r)}}}function u(t,e){if("object"!=typeof e)return[[t,e]];var r=[];for(var n in e){var i=e[n],a=t;a+=parseInt(n)+""===n?"["+n+"]":"."+n,"object"==typeof i?r.push.apply(r,u(a,i)):r.push([a,i])}return r}function f(e){for(var n=["return function updateProperty(obj){"],i=u("",e),o=0;o=0&&1>=e&&t.length===4+e){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid data type");return"b"===t.charAt(0)?i(r,!1):i(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+t);return i(r*r,0)}throw new s("","Unknown uniform data type for "+name+": "+t)}}function d(t,e,i){if("object"==typeof i){var o=p(i);Object.defineProperty(t,e,{get:n(o),set:f(i),enumerable:!0,configurable:!1})}else a[i]?Object.defineProperty(t,e,{get:l(i),set:f(i),enumerable:!0,configurable:!1}):t[e]=h(r[i].type)}function p(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var c=1;ca;++a){var o=t.getActiveUniform(e,a);if(o){var s=n(t,o.type);if(o.size>1)for(var l=0;la;++a){var o=t.getActiveAttrib(e,a);o&&i.push({name:o.name,type:n(t,o.type)})}return i}r.uniforms=i,r.attributes=a;var o={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"},s=null},{}],172:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.id=t,this.src=e,this.type=r,this.shader=n,this.count=a,this.programs=[],this.cache=o}function i(t){this.gl=t,this.shaders=[{},{}],this.programs={}}function a(t,e,r){var n=t.createShader(e);if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){var i=t.getShaderInfoLog(n);try{var a=f(i,r,e)}catch(o){throw console.warn("Failed to format compiler error: "+o),new u(i,"Error compiling shader:\n"+i)}throw new u(i,a.short,a.long)}return n}function o(t,e,r,n,i){var a=t.createProgram();t.attachShader(a,e),t.attachShader(a,r);for(var o=0;on;++n){var a=t.programs[r[n]];a&&(delete t.programs[n],e.deleteProgram(a))}e.deleteShader(this.shader),delete t.shaders[this.type===e.FRAGMENT_SHADER|0][this.src]}};var g=i.prototype;g.getShaderReference=function(t,e){var r=this.gl,i=this.shaders[t===r.FRAGMENT_SHADER|0],o=i[e];if(o&&r.isShader(o.shader))o.count+=1;else{var s=a(r,t,e);o=i[e]=new n(p++,e,t,s,[],1,this)}return o},g.getProgram=function(t,e,r,n){var i=[t.id,e.id,r.join(":"),n.join(":")].join("@"),a=this.programs[i];return a&&this.gl.isProgram(a)||(this.programs[i]=a=o(this.gl,t.shader,e.shader,r,n),t.programs.push(i),e.programs.push(i)),a}},{"./GLError":167,"gl-format-compiler-error":115,"weakmap-shim":290}],173:[function(t,e,r){"use strict";function n(t){this.plot=t,this.enable=[!0,!0,!1,!1],this.width=[1,1,1,1],this.color=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.center=[1/0,1/0]}function i(t,e){var r=new n(t);return r.update(e),t.addOverlay(r),r}e.exports=i;var a=n.prototype;a.update=function(t){t=t||{},this.enable=(t.enable||[!0,!0,!1,!1]).slice(),this.width=(t.width||[1,1,1,1]).slice(),this.color=(t.color||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]).map(function(t){return t.slice()}),this.center=(t.center||[1/0,1/0]).slice(),this.plot.setOverlayDirty()},a.draw=function(){var t=this.enable,e=this.width,r=this.color,n=this.center,i=this.plot,a=i.line,o=i.dataBox,s=i.viewBox;if(a.bind(),o[0]<=n[0]&&n[0]<=o[2]&&o[1]<=n[1]&&n[1]<=o[3]){var l=s[0]+(n[0]-o[0])/(o[2]-o[0])*(s[2]-s[0]),c=s[1]+(n[1]-o[1])/(o[3]-o[1])*(s[3]-s[1]);t[0]&&a.drawLine(l,c,s[0],c,e[0],r[0]),t[1]&&a.drawLine(l,c,l,s[1],e[1],r[1]),t[2]&&a.drawLine(l,c,s[2],c,e[2],r[2]),t[3]&&a.drawLine(l,c,l,s[3],e[3],r[3])}},a.dispose=function(){this.plot.removeOverlay(this)}},{}],174:[function(t,e,r){"use strict";var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, color;\nattribute float weight;\n\nuniform mat4 model, view, projection;\nuniform vec3 coordinates[3];\nuniform vec4 colors[3];\nuniform vec2 screenShape;\nuniform float lineWidth;\n\nvarying vec4 fragColor;\n\nvoid main() {\n vec3 vertexPosition = mix(coordinates[0],\n mix(coordinates[2], coordinates[1], 0.5 * (position + 1.0)), abs(position));\n\n vec4 clipPos = projection * view * model * vec4(vertexPosition, 1.0);\n vec2 clipOffset = (projection * view * model * vec4(color, 0.0)).xy;\n vec2 delta = weight * clipOffset * screenShape;\n vec2 lineOffset = normalize(vec2(delta.y, -delta.x)) / screenShape;\n\n gl_Position = vec4(clipPos.xy + clipPos.w * 0.5 * lineWidth * lineOffset, clipPos.z, clipPos.w);\n fragColor = color.x * colors[0] + color.y * colors[1] + color.z * colors[2];\n}\n",a="precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}";e.exports=function(t){return n(t,i,a,null,[{name:"position",type:"vec3"},{name:"color",type:"vec3"},{name:"weight",type:"float"}])}},{"gl-shader":166}],175:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n,this.pixelRatio=1,this.bounds=[[-1e3,-1e3,-1e3],[1e3,1e3,1e3]],this.position=[0,0,0],this.lineWidth=[2,2,2],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.enabled=[!0,!0,!0],this.drawSides=[!0,!0,!0],this.axes=null}function i(t,e){function r(t,e,r,n,a,o){var s=[t,e,r,0,0,0,1];s[n+3]=1,s[n]=a,i.push.apply(i,s),s[6]=-1,i.push.apply(i,s),s[n]=o,i.push.apply(i,s),i.push.apply(i,s),s[6]=1,i.push.apply(i,s),s[n]=a,i.push.apply(i,s)}var i=[];r(0,0,0,0,0,1),r(0,0,0,1,0,1),r(0,0,0,2,0,1),r(1,0,0,1,-1,1),r(1,0,0,2,-1,1),r(0,1,0,0,-1,1),r(0,1,0,2,-1,1),r(0,0,1,0,-1,1),r(0,0,1,1,-1,1);var l=a(t,i),c=o(t,[{type:t.FLOAT,buffer:l,size:3,offset:0,stride:28},{type:t.FLOAT,buffer:l,size:3,offset:12,stride:28},{type:t.FLOAT,buffer:l,size:1,offset:24,stride:28}]),u=s(t);u.attributes.position.location=0,u.attributes.color.location=1,u.attributes.weight.location=2;var f=new n(t,l,c,u);return f.update(e),f}var a=t("gl-buffer"),o=t("gl-vao"),s=t("./shaders/index");e.exports=i;var l=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],c=n.prototype,u=[0,0,0],f=[0,0,0],h=[0,0];c.isTransparent=function(){return!1},c.drawTransparent=function(t){},c.draw=function(t){var e=this.gl,r=this.vao,n=this.shader;r.bind(),n.bind();var i,a=t.model||l,o=t.view||l,s=t.projection||l;this.axes&&(i=this.axes.lastCubeProps.axis);for(var c=u,d=f,p=0;3>p;++p)i&&i[p]<0?(c[p]=this.bounds[0][p],d[p]=this.bounds[1][p]):(c[p]=this.bounds[1][p],d[p]=this.bounds[0][p]);h[0]=e.drawingBufferWidth,h[1]=e.drawingBufferHeight,n.uniforms.model=a,n.uniforms.view=o,n.uniforms.projection=s,n.uniforms.coordinates=[this.position,c,d],n.uniforms.colors=this.colors,n.uniforms.screenShape=h;for(var p=0;3>p;++p)n.uniforms.lineWidth=this.lineWidth[p]*this.pixelRatio,this.enabled[p]&&(r.draw(e.TRIANGLES,6,6*p),this.drawSides[p]&&r.draw(e.TRIANGLES,12,18+12*p));r.unbind()},c.update=function(t){t&&("bounds"in t&&(this.bounds=t.bounds),"position"in t&&(this.position=t.position),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"colors"in t&&(this.colors=t.colors),"enabled"in t&&(this.enabled=t.enabled),"drawSides"in t&&(this.drawSides=t.drawSides))},c.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders/index":174,"gl-buffer":107,"gl-vao":182}],176:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute vec3 f;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 lightPosition, eyePosition;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n worldCoordinate = vec3(uv.zw, f.x);\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 //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",a="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(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\n\n\nfloat beckmannSpecular_1_1(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness) {\n return beckmannDistribution_2_0(dot(surfaceNormal, normalize(lightDirection + viewDirection)), roughness);\n}\n\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;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n if(kill > 0.0 ||\n any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n discard;\n }\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 = beckmannSpecular_1_1(L, V, N, roughness);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(colormap, vec2(value, value));\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",o="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\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",s="precision mediump float;\n#define GLSLIFY 1\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 any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n 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";r.createShader=function(t){var e=n(t,i,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createPickShader=function(t){var e=n(t,i,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0, +e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createContourShader=function(t){var e=n(t,o,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e},r.createPickContourShader=function(t){var e=n(t,o,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e}},{"gl-shader":166}],177:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.position=t,this.index=e,this.uv=r,this.level=n,this.dataCoordinate=i}function i(t){var e=x([y({colormap:t,nshades:N,format:"rgba"}).map(function(t){return[t[0],t[1],t[2],255*t[3]]})]);return b.divseq(e,255),e}function a(t,e,r,i,a,o,s,l,c,u,f,h,d,p){this.gl=t,this.shape=e,this.bounds=r,this.intensityBounds=[],this._shader=i,this._pickShader=a,this._coordinateBuffer=o,this._vao=s,this._colorMap=l,this._contourShader=c,this._contourPickShader=u,this._contourBuffer=f,this._contourVAO=h,this._contourOffsets=[[],[],[]],this._contourCounts=[[],[],[]],this._vertexCount=0,this._pickResult=new n([0,0,0],[0,0],[0,0],[0,0,0],[0,0,0]),this._dynamicBuffer=d,this._dynamicVAO=p,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=[[.5,.5,.5,1],[.5,.5,.5,1],[.5,.5,.5,1]],this.showContour=!0,this.showSurface=!0,this.enableHighlight=[!0,!0,!0],this.highlightColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.highlightTint=[1,1,1],this.highlightLevel=[-1,-1,-1],this.enableDynamic=[!0,!0,!0],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=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.surfaceProject=[!1,!1,!1],this.contourProject=[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],this.colorBounds=[!1,!1],this._field=[_(m.mallocFloat(1024),[0,0]),_(m.mallocFloat(1024),[0,0]),_(m.mallocFloat(1024),[0,0])],this.pickId=1,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.snapToData=!1,this.opacity=1,this.lightPosition=[10,1e4,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.dirty=!0}function o(t,e){var r,n,i,a=e.axes&&e.axes.lastCubeProps.axis||F,o=e.showSurface,s=e.showContour;for(r=0;3>r;++r)for(o=o||e.surfaceProject[r],n=0;3>n;++n)s=s||e.contourProject[r][n];for(r=0;3>r;++r){var l=B.projections[r];for(n=0;16>n;++n)l[n]=0;for(n=0;4>n;++n)l[5*n]=1;l[5*r]=0,l[12+r]=e.axesBounds[+(a[r]>0)][r],k(l,t.model,l);var c=B.clipBounds[r];for(i=0;2>i;++i)for(n=0;3>n;++n)c[i][n]=t.clipBounds[i][n];c[0][r]=-1e8,c[1][r]=1e8}return B.showSurface=o,B.showContour=s,B}function s(t,e){t=t||{};var r=this.gl;r.disable(r.CULL_FACE),this._colorMap.bind(0);var n=D;n.model=t.model||R,n.view=t.view||R,n.projection=t.projection||R,n.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]],n.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]],n.contourColor=this.contourColor[0],n.inverseModel=A(n.inverseModel,n.model);for(var i=0;2>i;++i)for(var a=n.clipBounds[i],s=0;3>s;++s)a[s]=Math.min(Math.max(this.clipBounds[i][s],-1e8),1e8);n.kambient=this.ambientLight,n.kdiffuse=this.diffuseLight,n.kspecular=this.specularLight,n.roughness=this.roughness,n.fresnel=this.fresnel,n.opacity=this.opacity,n.height=0,n.permutation=V;var l=U;for(k(l,n.view,n.model),k(l,n.projection,l),A(l,l),i=0;3>i;++i)n.eyePosition[i]=l[12+i]/l[15];var c=l[15];for(i=0;3>i;++i)c+=this.lightPosition[i]*l[4*i+3];for(i=0;3>i;++i){var u=l[12+i];for(s=0;3>s;++s)u+=l[4*s+i]*this.lightPosition[s];n.lightPosition[i]=u/c}var f=o(n,this);if(f.showSurface&&e===this.opacity<1){for(this._shader.bind(),this._shader.uniforms=n,this._vao.bind(),this.showSurface&&this._vertexCount&&this._vao.draw(r.TRIANGLES,this._vertexCount),i=0;3>i;++i)this.surfaceProject[i]&&this.vertexCount&&(this._shader.uniforms.model=f.projections[i],this._shader.uniforms.clipBounds=f.clipBounds[i],this._vao.draw(r.TRIANGLES,this._vertexCount));this._vao.unbind()}if(f.showContour&&!e){var h=this._contourShader;n.kambient=1,n.kdiffuse=0,n.kspecular=0,n.opacity=1,h.bind(),h.uniforms=n;var d=this._contourVAO;for(d.bind(),i=0;3>i;++i)for(h.uniforms.permutation=I[i],r.lineWidth(this.contourWidth[i]),s=0;si;++i)for(h.uniforms.model=f.projections[i],h.uniforms.clipBounds=f.clipBounds[i],s=0;3>s;++s)if(this.contourProject[i][s]){h.uniforms.permutation=I[s],r.lineWidth(this.contourWidth[s]);for(var p=0;pi;++i)if(0!==this._dynamicCounts[i])for(h.uniforms.model=n.model,h.uniforms.clipBounds=n.clipBounds,h.uniforms.permutation=I[i],r.lineWidth(this.dynamicWidth[i]),h.uniforms.contourColor=this.dynamicColor[i],h.uniforms.contourTint=this.dynamicTint[i],h.uniforms.height=this.dynamicLevel[i],d.draw(r.LINES,this._dynamicCounts[i],this._dynamicOffsets[i]),s=0;3>s;++s)this.contourProject[s][i]&&(h.uniforms.model=f.projections[s],h.uniforms.clipBounds=f.clipBounds[s],d.draw(r.LINES,this._dynamicCounts[i],this._dynamicOffsets[i]));d.unbind()}}function l(t,e){var r=e.shape.slice(),n=t.shape.slice();b.assign(t.lo(1,1).hi(r[0],r[1]),e),b.assign(t.lo(1).hi(r[0],1),e.hi(r[0],1)),b.assign(t.lo(1,n[1]-1).hi(r[0],1),e.lo(0,r[1]-1).hi(r[0],1)),b.assign(t.lo(0,1).hi(1,r[1]),e.hi(1)),b.assign(t.lo(n[0]-1,1).hi(1,r[1]),e.lo(r[0]-1)),t.set(0,0,e.get(0,0)),t.set(0,n[1]-1,e.get(0,r[1]-1)),t.set(n[0]-1,0,e.get(r[0]-1,0)),t.set(n[0]-1,n[1]-1,e.get(r[0]-1,r[1]-1))}function c(t,e){return Array.isArray(t)?[e(t[0]),e(t[1]),e(t[2])]:[e(t),e(t),e(t)]}function u(t){return Array.isArray(t)?3===t.length?[t[0],t[1],t[2],1]:[t[0],t[1],t[2],t[3]]:[0,0,0,1]}function f(t){if(Array.isArray(t)){if(Array.isArray(t))return[u(t[0]),u(t[1]),u(t[2])];var e=u(t);return[e.slice(),e.slice(),e.slice()]}}function h(t){var e=t.gl,r=L(e),n=C(e),i=S(e),o=z(e),s=p(e),l=g(e,[{buffer:s,size:4,stride:P,offset:0},{buffer:s,size:3,stride:P,offset:16},{buffer:s,size:3,stride:P,offset:28}]),c=p(e),u=g(e,[{buffer:c,size:4,stride:20,offset:0},{buffer:c,size:1,stride:20,offset:16}]),f=p(e),h=g(e,[{buffer:f,size:2,type:e.FLOAT}]),d=v(e,1,N,e.RGBA,e.UNSIGNED_BYTE);d.minFilter=e.LINEAR,d.magFilter=e.LINEAR;var m=new a(e,[0,0],[[0,0,0],[0,0,0]],r,n,s,l,d,i,o,c,u,f,h),y={levels:[[],[],[]]};for(var b in t)y[b]=t[b];return y.colormap=y.colormap||"jet",m.update(y),m}e.exports=h;var d=t("bit-twiddle"),p=t("gl-buffer"),g=t("gl-vao"),v=t("gl-texture2d"),m=t("typedarray-pool"),y=t("colormap"),b=t("ndarray-ops"),x=t("ndarray-pack"),_=t("ndarray"),w=t("surface-nets"),k=t("gl-mat4/multiply"),A=t("gl-mat4/invert"),M=t("binary-search-bounds"),T=t("ndarray-gradient"),E=t("./lib/shaders"),L=E.createShader,S=E.createContourShader,C=E.createPickShader,z=E.createPickContourShader,P=40,R=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],O=[[0,0],[0,1],[1,0],[1,1],[1,0],[0,1]],I=[[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 t=0;3>t;++t){var e=I[t],r=(t+1)%3,n=(t+2)%3;e[r+0]=1,e[n+3]=1,e[t+6]=1}}();var N=265,j=a.prototype;j.isTransparent=function(){return this.opacity<1},j.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;3>t;++t)if(this._contourCounts[t].length>0||this._dynamicCounts[t]>0)return!0;return!1},j.pickSlots=1,j.setPickBase=function(t){this.pickId=t};var F=[0,0,0],B={showSurface:!1,showContour:!1,projections:[R.slice(),R.slice(),R.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]},D={model:R,view:R,projection:R,inverseModel:R.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1e3,1e3,1e3],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1},U=R.slice(),V=[1,0,0,0,1,0,0,0,1];j.draw=function(t){return s.call(this,t,!1)},j.drawTransparent=function(t){return s.call(this,t,!0)};var q={model:R,view:R,projection:R,inverseModel:R,clipBounds:[[0,0,0],[0,0,0]],height:0,shape:[0,0],pickId:0,lowerBound:[0,0,0],upperBound:[0,0,0],zOffset:0,permutation:[1,0,0,0,1,0,0,0,1],lightPosition:[0,0,0],eyePosition:[0,0,0]};j.drawPick=function(t){t=t||{};var e=this.gl;e.disable(e.CULL_FACE);var r=q;r.model=t.model||R,r.view=t.view||R,r.projection=t.projection||R,r.shape=this._field[2].shape,r.pickId=this.pickId/255,r.lowerBound=this.bounds[0],r.upperBound=this.bounds[1],r.permutation=V;for(var n=0;2>n;++n)for(var i=r.clipBounds[n],a=0;3>a;++a)i[a]=Math.min(Math.max(this.clipBounds[n][a],-1e8),1e8);var s=o(r,this);if(s.showSurface){for(this._pickShader.bind(),this._pickShader.uniforms=r,this._vao.bind(),this._vao.draw(e.TRIANGLES,this._vertexCount),n=0;3>n;++n)this.surfaceProject[n]&&(this._pickShader.uniforms.model=s.projections[n],this._pickShader.uniforms.clipBounds=s.clipBounds[n],this._vao.draw(e.TRIANGLES,this._vertexCount));this._vao.unbind()}if(s.showContour){var l=this._contourPickShader;l.bind(),l.uniforms=r;var c=this._contourVAO;for(c.bind(),a=0;3>a;++a)for(e.lineWidth(this.contourWidth[a]),l.uniforms.permutation=I[a],n=0;nn;++n)for(l.uniforms.model=s.projections[n],l.uniforms.clipBounds=s.clipBounds[n],a=0;3>a;++a)if(this.contourProject[n][a]){l.uniforms.permutation=I[a],e.lineWidth(this.contourWidth[a]);for(var u=0;u>4)/16)/255,i=Math.floor(n),a=n-i,o=e[1]*(t.value[1]+(15&t.value[2])/16)/255,s=Math.floor(o),l=o-s;i+=1,s+=1;var c=r.position;c[0]=c[1]=c[2]=0;for(var u=0;2>u;++u)for(var f=u?a:1-a,h=0;2>h;++h)for(var d=h?l:1-l,p=i+u,g=s+h,v=f*d,m=0;3>m;++m)c[m]+=this._field[m].get(p,g)*v;for(var y=this._pickResult.level,b=0;3>b;++b)if(y[b]=M.le(this.contourLevels[b],c[b]),y[b]<0)this.contourLevels[b].length>0&&(y[b]=0);else if(y[b]Math.abs(_-c[b])&&(y[b]+=1)}for(r.index[0]=.5>a?i:i+1,r.index[1]=.5>l?s:s+1,r.uv[0]=n/e[0],r.uv[1]=o/e[1],m=0;3>m;++m)r.dataCoordinate[m]=this._field[m].get(r.index[0],r.index[1]);return r},j.update=function(t){t=t||{},this.dirty=!0,"contourWidth"in t&&(this.contourWidth=c(t.contourWidth,Number)),"showContour"in t&&(this.showContour=c(t.showContour,Boolean)),"showSurface"in t&&(this.showSurface=!!t.showSurface),"contourTint"in t&&(this.contourTint=c(t.contourTint,Boolean)),"contourColor"in t&&(this.contourColor=f(t.contourColor)),"contourProject"in t&&(this.contourProject=c(t.contourProject,function(t){return c(t,Boolean)})),"surfaceProject"in t&&(this.surfaceProject=t.surfaceProject),"dynamicColor"in t&&(this.dynamicColor=f(t.dynamicColor)),"dynamicTint"in t&&(this.dynamicTint=c(t.dynamicTint,Number)),"dynamicWidth"in t&&(this.dynamicWidth=c(t.dynamicWidth,Number)),"opacity"in t&&(this.opacity=t.opacity),"colorBounds"in t&&(this.colorBounds=t.colorBounds);var e=t.field||t.coords&&t.coords[2]||null,r=!1;if(e||(e=this._field[2].shape[0]||this._field[2].shape[2]?this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2):this._field[2].hi(0,0)),"field"in t||"coords"in t){var n=(e.shape[0]+2)*(e.shape[1]+2);n>this._field[2].data.length&&(m.freeFloat(this._field[2].data),this._field[2].data=m.mallocFloat(d.nextPow2(n))),this._field[2]=_(this._field[2].data,[e.shape[0]+2,e.shape[1]+2]),l(this._field[2],e),this.shape=e.shape.slice();for(var a=this.shape,o=0;2>o;++o)this._field[2].size>this._field[o].data.length&&(m.freeFloat(this._field[o].data),this._field[o].data=m.mallocFloat(this._field[2].size)),this._field[o]=_(this._field[o].data,[a[0]+2,a[1]+2]);if(t.coords){var s=t.coords;if(!Array.isArray(s)||3!==s.length)throw new Error("gl-surface: invalid coordinates for x/y");for(o=0;2>o;++o){var u=s[o];for(y=0;2>y;++y)if(u.shape[y]!==a[y])throw new Error("gl-surface: coords have incorrect shape");l(this._field[o],u)}}else if(t.ticks){var h=t.ticks;if(!Array.isArray(h)||2!==h.length)throw new Error("gl-surface: invalid ticks");for(o=0;2>o;++o){var p=h[o];if((Array.isArray(p)||p.length)&&(p=_(p)),p.shape[0]!==a[o])throw new Error("gl-surface: invalid tick length");var g=_(p.data,a);g.stride[o]=p.stride[0],g.stride[1^o]=0,l(this._field[o],g)}}else{for(o=0;2>o;++o){var v=[0,0];v[o]=1,this._field[o]=_(this._field[o].data,[a[0]+2,a[1]+2],v,0)}this._field[0].set(0,0,0);for(var y=0;yo;++o)T(x.pick(o),b[o],"mirror");var k=_(m.mallocFloat(3*b[2].size),[a[0]+2,a[1]+2,3]);for(o=0;oI?(I=Math.max(Math.abs(z),Math.abs(P),Math.abs(R)),1e-8>I?(R=1,P=z=0,I=1):I=1/I):I=1/Math.sqrt(I),k.set(o,y,0,z*I),k.set(o,y,1,P*I),k.set(o,y,2,R*I)}m.free(x.data);var N=[1/0,1/0,1/0],j=[-(1/0),-(1/0),-(1/0)],F=1/0,B=-(1/0),D=(a[0]-1)*(a[1]-1)*6,U=m.mallocFloat(d.nextPow2(10*D)),V=0,q=0;for(o=0;oH;++H)for(var G=0;2>G;++G)for(var Y=0;3>Y;++Y){var X=this._field[Y].get(1+o+H,1+y+G);if(isNaN(X)||!isFinite(X))continue t}for(Y=0;6>Y;++Y){var W=o+O[Y][0],Z=y+O[Y][1],K=this._field[0].get(W+1,Z+1),Q=this._field[1].get(W+1,Z+1);X=this._field[2].get(W+1,Z+1);var $=X;z=k.get(W+1,Z+1,0),P=k.get(W+1,Z+1,1),R=k.get(W+1,Z+1,2),t.intensity&&($=t.intensity.get(W,Z)),U[V++]=W,U[V++]=Z,U[V++]=K,U[V++]=Q,U[V++]=X,U[V++]=0,U[V++]=$,U[V++]=z,U[V++]=P,U[V++]=R,N[0]=Math.min(N[0],K),N[1]=Math.min(N[1],Q),N[2]=Math.min(N[2],X),F=Math.min(F,$),j[0]=Math.max(j[0],K),j[1]=Math.max(j[1],Q),j[2]=Math.max(j[2],X),B=Math.max(B,$),q+=1}}for(t.intensityBounds&&(F=+t.intensityBounds[0],B=+t.intensityBounds[1]),o=6;V>o;o+=10)U[o]=(U[o]-F)/(B-F);this._vertexCount=q,this._coordinateBuffer.update(U.subarray(0,V)),m.freeFloat(U),m.free(k.data),this.bounds=[N,j],this.intensity=t.intensity||this._field[2],this.intensityBounds[0]===F&&this.intensityBounds[1]===B||(r=!0),this.intensityBounds=[F,B]}if("levels"in t){var J=t.levels;for(J=Array.isArray(J[0])?J.slice():[[],[],J],o=0;3>o;++o)J[o]=J[o].slice(),J.sort(function(t,e){return t-e});t:for(o=0;3>o;++o){if(J[o].length!==this.contourLevels[o].length){r=!0;break}for(y=0;yet;++et){J=this.contourLevels[et];var rt=[],nt=[],it=[0,0,0];for(o=0;oY;++Y){var st=at.positions[ot[Y]],lt=st[0],ct=0|Math.floor(lt),ut=lt-ct,ft=st[1],ht=0|Math.floor(ft),dt=ft-ht,pt=!1;e:for(var gt=0;3>gt;++gt){it[gt]=0;var vt=(et+gt+1)%3;for(H=0;2>H;++H){var mt=H?ut:1-ut;for(W=0|Math.min(Math.max(ct+H,0),a[0]),G=0;2>G;++G){var yt=G?dt:1-dt;if(Z=0|Math.min(Math.max(ht+G,0),a[1]),X=2>gt?this._field[vt].get(W,Z):(this.intensity.get(W,Z)-this.intensityBounds[0])/(this.intensityBounds[1]-this.intensityBounds[0]),!isFinite(X)||isNaN(X)){pt=!0;break e}var bt=mt*yt;it[gt]+=bt*X}}}if(pt){if(Y>0){for(var xt=0;5>xt;++xt)tt.pop();q-=1}continue t}tt.push(it[0],it[1],st[0],st[1],it[2]),q+=1}}nt.push(q)}this._contourOffsets[et]=rt,this._contourCounts[et]=nt}var _t=m.mallocFloat(tt.length);for(o=0;ot;++t)m.freeFloat(this._field[t].data)},j.highlight=function(t){if(!t)return this._dynamicCounts=[0,0,0],this.dyanamicLevel=[NaN,NaN,NaN],void(this.highlightLevel=[-1,-1,-1]);for(var e=0;3>e;++e)this.enableHighlight[e]?this.highlightLevel[e]=t.level[e]:this.highlightLevel[e]=-1;var r;if(r=this.snapToData?t.dataCoordinate:t.position,this.enableDynamic[0]&&r[0]!==this.dynamicLevel[0]||this.enableDynamic[1]&&r[1]!==this.dynamicLevel[1]||this.enableDynamic[2]&&r[2]!==this.dynamicLevel[2]){for(var n=0,i=this.shape,a=m.mallocFloat(12*i[0]*i[1]),o=0;3>o;++o)if(this.enableDynamic[o]){this.dynamicLevel[o]=r[o];var s=(o+1)%3,l=(o+2)%3,c=this._field[o],u=this._field[s],f=this._field[l],h=(this.intensity,w(c,r[o])),d=h.cells,p=h.positions;for(this._dynamicOffsets[o]=n,e=0;ev;++v){var y=p[g[v]],b=+y[0],x=0|b,_=0|Math.min(x+1,i[0]),k=b-x,A=1-k,M=+y[1],T=0|M,E=0|Math.min(T+1,i[1]),L=M-T,S=1-L,C=A*S,z=A*L,P=k*S,R=k*L,O=C*u.get(x,T)+z*u.get(x,E)+P*u.get(_,T)+R*u.get(_,E),I=C*f.get(x,T)+z*f.get(x,E)+P*f.get(_,T)+R*f.get(_,E);if(isNaN(O)||isNaN(I)){v&&(n-=1);break}a[2*n+0]=O,a[2*n+1]=I,n+=1}this._dynamicCounts[o]=n-this._dynamicOffsets[o]}else this.dynamicLevel[o]=NaN,this._dynamicCounts[o]=0;this._dynamicBuffer.update(a.subarray(0,2*n)),m.freeFloat(a)}}},{"./lib/shaders":176,"binary-search-bounds":47,"bit-twiddle":48,colormap:73,"gl-buffer":107,"gl-mat4/invert":128,"gl-mat4/multiply":130,"gl-texture2d":178,"gl-vao":182,ndarray:225,"ndarray-gradient":216,"ndarray-ops":219,"ndarray-pack":220,"surface-nets":273,"typedarray-pool":282}],178:[function(t,e,r){"use strict";function n(t){v=[t.LINEAR,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_NEAREST],m=[t.NEAREST,t.LINEAR,t.NEAREST_MIPMAP_NEAREST,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_LINEAR],y=[t.REPEAT,t.CLAMP_TO_EDGE,t.MIRRORED_REPEAT]}function i(t,e,r){var n=t.gl,i=n.getParameter(n.MAX_TEXTURE_SIZE);if(0>e||e>i||0>r||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function a(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}function o(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function s(t,e,r,n,i,a,s,l){var c=l.dtype,u=l.shape.slice();if(u.length<2||u.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var f=0,h=0,v=o(u,l.stride.slice());"float32"===c?f=t.FLOAT:"float64"===c?(f=t.FLOAT,v=!1,c="float32"):"uint8"===c?f=t.UNSIGNED_BYTE:(f=t.UNSIGNED_BYTE,v=!1,c="uint8");var m=1;if(2===u.length)h=t.LUMINANCE,u=[u[0],u[1],1],l=d(l.data,u,[l.stride[0],l.stride[1],1],l.offset);else{if(3!==u.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===u[2])h=t.ALPHA;else if(2===u[2])h=t.LUMINANCE_ALPHA;else if(3===u[2])h=t.RGB;else{if(4!==u[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");h=t.RGBA}m=u[2]}if(h!==t.LUMINANCE&&h!==t.ALPHA||i!==t.LUMINANCE&&i!==t.ALPHA||(h=i),h!==i)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=l.size,x=s.indexOf(n)<0;if(x&&s.push(n),f===a&&v)0===l.offset&&l.data.length===y?x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,l.data):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,l.data):x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,l.data.subarray(l.offset,l.offset+y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,l.data.subarray(l.offset,l.offset+y));else{var _;_=a===t.FLOAT?g.mallocFloat32(y):g.mallocUint8(y);var w=d(_,u,[u[2],u[2]*u[0],1]);f===t.FLOAT&&a===t.UNSIGNED_BYTE?b(w,l):p.assign(w,l),x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,_.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,_.subarray(0,y)),a===t.FLOAT?g.freeFloat32(_):g.freeUint8(_)}}function l(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function c(t,e,r,n,i){var o=t.getParameter(t.MAX_TEXTURE_SIZE);if(0>e||e>o||0>r||r>o)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var s=l(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new a(t,s,e,r,n,i)}function u(t,e,r,n){var i=l(t);return t.texImage2D(t.TEXTURE_2D,0,r,r,n,e),new a(t,i,0|e.width,0|e.height,r,n)}function f(t,e){var r=e.dtype,n=e.shape.slice(),i=t.getParameter(t.MAX_TEXTURE_SIZE);if(n[0]<0||n[0]>i||n[1]<0||n[1]>i)throw new Error("gl-texture2d: Invalid texture size");var s=o(n,e.stride.slice()),c=0;"float32"===r?c=t.FLOAT:"float64"===r?(c=t.FLOAT,s=!1,r="float32"):"uint8"===r?c=t.UNSIGNED_BYTE:(c=t.UNSIGNED_BYTE,s=!1,r="uint8");var u=0;if(2===n.length)u=t.LUMINANCE,n=[n[0],n[1],1],e=d(e.data,n,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==n.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===n[2])u=t.ALPHA;else if(2===n[2])u=t.LUMINANCE_ALPHA;else if(3===n[2])u=t.RGB;else{if(4!==n[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");u=t.RGBA}}c!==t.FLOAT||t.getExtension("OES_texture_float")||(c=t.UNSIGNED_BYTE,s=!1);var f,h,v=e.size;if(s)f=0===e.offset&&e.data.length===v?e.data:e.data.subarray(e.offset,e.offset+v);else{var m=[n[2],n[2]*n[0],1];h=g.malloc(v,r);var y=d(h,n,m,0);"float32"!==r&&"float64"!==r||c!==t.UNSIGNED_BYTE?p.assign(y,e):b(y,e),f=h.subarray(0,v)}var x=l(t);return t.texImage2D(t.TEXTURE_2D,0,u,n[0],n[1],0,u,c,f),s||g.free(h),new a(t,x,n[0],n[1],u,c)}function h(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");if(v||n(t),"number"==typeof arguments[1])return c(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return c(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1];if(e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof HTMLVideoElement||e instanceof ImageData)return u(t,e,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return f(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")}var d=t("ndarray"),p=t("ndarray-ops"),g=t("typedarray-pool");e.exports=h;var v=null,m=null,y=null,b=function(t,e){p.muls(t,e,255)},x=a.prototype;Object.defineProperties(x,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;2>e;++e)if(y.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return i(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return t=0|t,i(this,t,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t=0|t,i(this,this._shape[0],t),t}}}),x.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},x.dispose=function(){this.gl.deleteTexture(this.handle)},x.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},x.setPixels=function(t,e,r,n){var i=this.gl;if(this.bind(),Array.isArray(e)?(n=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),n=n||0,t instanceof HTMLCanvasElement||t instanceof ImageData||t instanceof HTMLImageElement||t instanceof HTMLVideoElement){var a=this._mipLevels.indexOf(n)<0;a?(i.texImage2D(i.TEXTURE_2D,0,this.format,this.format,this.type,t),this._mipLevels.push(n)):i.texSubImage2D(i.TEXTURE_2D,n,e,r,this.format,this.type,t)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>n||r+t.shape[0]>this._shape[0]>>>n||0>e||0>r)throw new Error("gl-texture2d: Texture dimensions are out of bounds");s(i,e,r,n,this.format,this.type,this._mipLevels,t)}}},{ndarray:225,"ndarray-ops":219,"typedarray-pool":282}],179:[function(t,e,r){"use strict";function n(t,e,r){e?e.bind():t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);var n=0|t.getParameter(t.MAX_VERTEX_ATTRIBS);if(r){if(r.length>n)throw new Error("gl-vao: Too many vertex attributes");for(var i=0;ii;++i)t.disableVertexAttribArray(i)}else{t.bindBuffer(t.ARRAY_BUFFER,null);for(var i=0;n>i;++i)t.disableVertexAttribArray(i)}}e.exports=n},{}],180:[function(t,e,r){"use strict";function n(t){this.gl=t,this._elements=null,this._attributes=null,this._elementsType=t.UNSIGNED_SHORT}function i(t){return new n(t)}var a=t("./do-bind.js");n.prototype.bind=function(){a(this.gl,this._elements,this._attributes)},n.prototype.update=function(t,e,r){this._elements=e,this._attributes=t,this._elementsType=r||this.gl.UNSIGNED_SHORT},n.prototype.dispose=function(){},n.prototype.unbind=function(){},n.prototype.draw=function(t,e,r){r=r||0;var n=this.gl;this._elements?n.drawElements(t,e,this._elementsType,r):n.drawArrays(t,r,e)},e.exports=i},{"./do-bind.js":179}],181:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.location=t,this.dimension=e,this.a=r,this.b=n,this.c=i,this.d=a}function i(t,e,r){this.gl=t,this._ext=e,this.handle=r,this._attribs=[],this._useElements=!1,this._elementsType=t.UNSIGNED_SHORT}function a(t,e){return new i(t,e,e.createVertexArrayOES())}var o=t("./do-bind.js");n.prototype.bind=function(t){switch(this.dimension){case 1:t.vertexAttrib1f(this.location,this.a);break;case 2:t.vertexAttrib2f(this.location,this.a,this.b);break;case 3:t.vertexAttrib3f(this.location,this.a,this.b,this.c);break;case 4:t.vertexAttrib4f(this.location,this.a,this.b,this.c,this.d)}},i.prototype.bind=function(){this._ext.bindVertexArrayOES(this.handle);for(var t=0;t0&&(a=1/Math.sqrt(a), +t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t}e.exports=n},{}],188:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}e.exports=n},{}],189:[function(t,e,r){function n(t,e,r,n){return i[0]=n,i[1]=r,i[2]=e,i[3]=t,a[0]}e.exports=n;var i=new Uint8Array(4),a=new Float32Array(i.buffer)},{}],190:[function(t,e,r){function n(t){for(var e=Array.isArray(t)?t:i(t),r=0;rF;){switch(e=F,D){case f:F=L();break;case h:F=E();break;case d:F=T();break;case p:F=S();break;case g:F=P();break;case w:F=z();break;case v:F=R();break;case u:F=O();break;case x:F=M();break;case c:F=A()}if(e!==F)switch(W[e]){case"\n":H=0,++q;break;default:++H}}return B+=F,W=W.slice(F),V}function n(t){return U.length&&e(U.join("")),D=_,e("(eof)"),V}function A(){return U=U.length?[]:U,"/"===N&&"*"===I?(G=B+F-1,D=f,N=I,F+1):"/"===N&&"/"===I?(G=B+F-1,D=h,N=I,F+1):"#"===I?(D=d,G=B+F,F):/\s/.test(I)?(D=x,G=B+F,F):(Y=/\d/.test(I),X=/[^\w_]/.test(I),G=B+F,D=Y?g:X?p:u,F)}function M(){return/[^\s]/g.test(I)?(e(U.join("")),D=c,F):(U.push(I),N=I,F+1)}function T(){return"\r"!==I&&"\n"!==I||"\\"===N?(U.push(I),N=I,F+1):(e(U.join("")),D=c,F)}function E(){return T()}function L(){return"/"===I&&"*"===N?(U.push(I),e(U.join("")),D=c,F+1):(U.push(I),N=I,F+1)}function S(){if("."===N&&/\d/.test(I))return D=v,F;if("/"===N&&"*"===I)return D=f,F;if("/"===N&&"/"===I)return D=h,F;if("."===I&&U.length){for(;C(U););return D=v,F}if(";"===I||")"===I||"("===I){if(U.length)for(;C(U););return e(I),D=c,F+1}var t=2===U.length&&"="!==I;if(/[\w_\d\s]/.test(I)||t){for(;C(U););return D=c,F}return U.push(I),N=I,F+1}function C(t){for(var r,n,i=0;;){if(r=a.indexOf(t.slice(0,t.length+i).join("")),n=a[r],-1===r){if(i--+t.length>0)continue;n=t.slice(0,1).join("")}return e(n),G+=n.length,U=U.slice(n.length),U.length}}function z(){return/[^a-fA-F0-9]/.test(I)?(e(U.join("")),D=c,F):(U.push(I),N=I,F+1)}function P(){return"."===I?(U.push(I),D=v,N=I,F+1):/[eE]/.test(I)?(U.push(I),D=v,N=I,F+1):"x"===I&&1===U.length&&"0"===U[0]?(D=w,U.push(I),N=I,F+1):/[^\d]/.test(I)?(e(U.join("")),D=c,F):(U.push(I),N=I,F+1)}function R(){return"f"===I&&(U.push(I),N=I,F+=1),/[eE]/.test(I)?(U.push(I),N=I,F+1):"-"===I&&/[eE]/.test(N)?(U.push(I),N=I,F+1):/[^\d]/.test(I)?(e(U.join("")),D=c,F):(U.push(I),N=I,F+1)}function O(){if(/[^\d\w_]/.test(I)){var t=U.join("");return D=K.indexOf(t)>-1?b:Z.indexOf(t)>-1?y:m,e(U.join("")),D=c,F}return U.push(I),N=I,F+1}var I,N,j,F=0,B=0,D=c,U=[],V=[],q=1,H=0,G=0,Y=!1,X=!1,W="";t=t||{};var Z=o,K=i;return"300 es"===t.version&&(Z=l,K=s),function(t){return V=[],null!==t?r(t.replace?t.replace(/\r\n/g,"\n"):t):n()}}e.exports=n;var i=t("./lib/literals"),a=t("./lib/operators"),o=t("./lib/builtins"),s=t("./lib/literals-300es"),l=t("./lib/builtins-300es"),c=999,u=9999,f=0,h=1,d=2,p=3,g=4,v=5,m=6,y=7,b=8,x=9,_=10,w=11,k=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":193,"./lib/builtins-300es":192,"./lib/literals":195,"./lib/literals-300es":194,"./lib/operators":196}],192:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["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","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"])},{"./builtins":193}],193:[function(t,e,r){e.exports=["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"]},{}],194:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","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"])},{"./literals":195}],195:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","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","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"]},{}],196:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],197:[function(t,e,r){function n(t,e){var r=i(e),n=[];return n=n.concat(r(t)),n=n.concat(r(null))}var i=t("./index");e.exports=n},{"./index":191}],198:[function(t,e,r){r.read=function(t,e,r,n,i){var a,o,s=8*i-n-1,l=(1<>1,u=-7,f=r?i-1:0,h=r?-1:1,d=t[e+f];for(f+=h,a=d&(1<<-u)-1,d>>=-u,u+=s;u>0;a=256*a+t[e+f],f+=h,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+f],f+=h,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:(d?-1:1)*(1/0);o+=Math.pow(2,n),a-=c}return(d?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:a-1,p=n?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),e+=o+f>=1?h/l:h*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=u?(s=0,o=u):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,c-=8);t[r+d-p]|=128*g}},{}],199:[function(t,e,r){"use strict";function n(t,e,r){this.vertices=t,this.adjacent=e,this.boundary=r,this.lastVisited=-1}function i(t,e,r){this.vertices=t,this.cell=e,this.index=r}function a(t,e){return u(t.vertices,e.vertices)}function o(t){for(var e=["function orient(){var tuple=this.tuple;return test("],r=0;t>=r;++r)r>0&&e.push(","),e.push("tuple[",r,"]");e.push(")}return orient");var n=new Function("test",e.join("")),i=c[t+1];return i||(i=c),n(i)}function s(t,e,r){this.dimension=t,this.vertices=e,this.simplices=r,this.interior=r.filter(function(t){return!t.boundary}),this.tuple=new Array(t+1);for(var n=0;t>=n;++n)this.tuple[n]=this.vertices[n];var i=f[t];i||(i=f[t]=o(t)),this.orient=i}function l(t,e){var r=t.length;if(0===r)throw new Error("Must have at least d+1 points");var i=t[0].length;if(i>=r)throw new Error("Must input at least d+1 points");var a=t.slice(0,i+1),o=c.apply(void 0,a);if(0===o)throw new Error("Input not in general position");for(var l=new Array(i+1),u=0;i>=u;++u)l[u]=u;0>o&&(l[0]=1,l[1]=0);for(var f=new n(l,new Array(i+1),!1),h=f.adjacent,d=new Array(i+2),u=0;i>=u;++u){for(var p=l.slice(),g=0;i>=g;++g)g===u&&(p[g]=-1);var v=p[0];p[0]=p[1],p[1]=v;var m=new n(p,new Array(i+1),!0);h[u]=m,d[u]=m}d[i+1]=f;for(var u=0;i>=u;++u)for(var p=h[u].vertices,y=h[u].adjacent,g=0;i>=g;++g){var b=p[g];if(0>b)y[g]=f;else for(var x=0;i>=x;++x)h[x].vertices.indexOf(b)<0&&(y[g]=h[x])}for(var _=new s(i,a,d),w=!!e,u=i+1;r>u;++u)_.insert(t[u],w);return _.boundary()}e.exports=l;var c=t("robust-orientation"),u=t("simplicial-complex").compareCells;n.prototype.flip=function(){var t=this.vertices[0];this.vertices[0]=this.vertices[1],this.vertices[1]=t;var e=this.adjacent[0];this.adjacent[0]=this.adjacent[1],this.adjacent[1]=e};var f=[],h=s.prototype;h.handleBoundaryDegeneracy=function(t,e){var r=this.dimension,n=this.vertices.length-1,i=this.tuple,a=this.vertices,o=[t];for(t.lastVisited=-n;o.length>0;){t=o.pop();for(var s=(t.vertices,t.adjacent),l=0;r>=l;++l){var c=s[l];if(c.boundary&&!(c.lastVisited<=-n)){for(var u=c.vertices,f=0;r>=f;++f){var h=u[f];0>h?i[f]=e:i[f]=a[h]}var d=this.orient();if(d>0)return c;c.lastVisited=-n,0===d&&o.push(c)}}}return null},h.walk=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,a=this.tuple,o=e?this.interior.length*Math.random()|0:this.interior.length-1,s=this.interior[o];t:for(;!s.boundary;){for(var l=s.vertices,c=s.adjacent,u=0;n>=u;++u)a[u]=i[l[u]];s.lastVisited=r;for(var u=0;n>=u;++u){var f=c[u];if(!(f.lastVisited>=r)){var h=a[u];a[u]=t;var d=this.orient();if(a[u]=h,0>d){s=f;continue t}f.boundary?f.lastVisited=-r:f.lastVisited=r}}return}return s},h.addPeaks=function(t,e){var r=this.vertices.length-1,o=this.dimension,s=this.vertices,l=this.tuple,c=this.interior,u=this.simplices,f=[e];e.lastVisited=r,e.vertices[e.vertices.indexOf(-1)]=r,e.boundary=!1,c.push(e);for(var h=[];f.length>0;){var e=f.pop(),d=e.vertices,p=e.adjacent,g=d.indexOf(r);if(!(0>g))for(var v=0;o>=v;++v)if(v!==g){var m=p[v];if(m.boundary&&!(m.lastVisited>=r)){var y=m.vertices;if(m.lastVisited!==-r){for(var b=0,x=0;o>=x;++x)y[x]<0?(b=x,l[x]=t):l[x]=s[y[x]];var _=this.orient();if(_>0){y[b]=r,m.boundary=!1,c.push(m),f.push(m),m.lastVisited=r;continue}m.lastVisited=-r}var w=m.adjacent,k=d.slice(),A=p.slice(),M=new n(k,A,!0);u.push(M);var T=w.indexOf(e);if(!(0>T)){w[T]=M,A[g]=m,k[v]=-1,A[v]=e,p[v]=M,M.flip();for(var x=0;o>=x;++x){var E=k[x];if(!(0>E||E===r)){for(var L=new Array(o-1),S=0,C=0;o>=C;++C){var z=k[C];0>z||C===x||(L[S++]=z)}h.push(new i(L,M,x))}}}}}}h.sort(a);for(var v=0;v+1O||0>I||(P.cell.adjacent[P.index]=R.cell,R.cell.adjacent[R.index]=P.cell)}},h.insert=function(t,e){var r=this.vertices;r.push(t);var n=this.walk(t,e);if(n){for(var i=this.dimension,a=this.tuple,o=0;i>=o;++o){var s=n.vertices[o];0>s?a[o]=t:a[o]=r[s]}var l=this.orient(a);0>l||(0!==l||(n=this.handleBoundaryDegeneracy(n,t)))&&this.addPeaks(t,n)}},h.boundary=function(){for(var t=this.dimension,e=[],r=this.simplices,n=r.length,i=0;n>i;++i){var a=r[i];if(a.boundary){for(var o=new Array(t),s=a.vertices,l=0,c=0,u=0;t>=u;++u)s[u]>=0?o[l++]=s[u]:c=1&u;if(c===(1&t)){var f=o[0];o[0]=o[1],o[1]=f}e.push(o)}}return e}},{"robust-orientation":253,"simplicial-complex":263}],200:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}function i(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function a(t,e){var r=p(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function o(t,e){var r=t.intervals([]);r.push(e),a(t,r)}function s(t,e){var r=t.intervals([]),n=r.indexOf(e);return 0>n?y:(r.splice(n,1),a(t,r),b)}function l(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function u(t,e){for(var r=0;r>1],a=[],o=[],s=[],r=0;r3*(e+1)?o(this,t):this.left.insert(t):this.left=p([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?o(this,t):this.right.insert(t):this.right=p([t]);else{var r=m.ge(this.leftPoints,t,h),n=m.ge(this.rightPoints,t,d);this.leftPoints.splice(r,0,t),this.rightPoints.splice(n,0,t)}},_.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1))return s(this,t);var n=this.left.remove(t);return n===x?(this.left=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(t[0]>this.mid){if(!this.right)return y;var a=this.left?this.left.count:0;if(4*a>3*(e-1))return s(this,t);var n=this.right.remove(t);return n===x?(this.right=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(1===this.count)return this.leftPoints[0]===t?x:y;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var o=this,l=this.left;l.right;)o=l,l=l.right;if(o===this)l.right=this.right;else{var c=this.left,n=this.right;o.count-=l.count,o.right=l.left,l.left=c,l.right=n}i(this,l),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?i(this,this.left):i(this,this.right);return b}for(var c=m.ge(this.leftPoints,t,h);cthis.mid){if(this.right){var r=this.right.queryPoint(t,e);if(r)return r}return c(this.rightPoints,t,e)}return u(this.leftPoints,e)},_.queryInterval=function(t,e,r){if(tthis.mid&&this.right){var n=this.right.queryInterval(t,e,r);if(n)return n}return ethis.mid?c(this.rightPoints,t,r):u(this.leftPoints,r)};var w=g.prototype;w.insert=function(t){this.root?this.root.insert(t):this.root=new n(t[0],null,null,[t],[t])},w.remove=function(t){if(this.root){var e=this.root.remove(t);return e===x&&(this.root=null),e!==y}return!1},w.queryPoint=function(t,e){return this.root?this.root.queryPoint(t,e):void 0},w.queryInterval=function(t,e,r){return e>=t&&this.root?this.root.queryInterval(t,e,r):void 0},Object.defineProperty(w,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(w,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":47}],201:[function(t,e,r){"use strict";function n(t,e){e=e||new Array(t.length);for(var r=0;rr;++r)e[r]=r;return e}e.exports=n},{}],203:[function(t,e,r){e.exports=function(t){return!(null==t||!(t._isBuffer||t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)))}},{}],204:[function(t,e,r){"use strict";function n(t,e,r){for(var n=new Array(t),i=0;t>i;++i)n[i]=0,i===e&&(n[i]+=.5),i===r&&(n[i]+=.5);return n}function i(t,e){if(0===e||e===(1<=a;++a)if(e&1<=s;++s)~e&1<n;++n)r[n]=i(t,n);return r}e.exports=a;var o=t("convex-hull")},{"convex-hull":77}],205:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}function i(t,e){t[0][0]=e[0],t[0][1]=e[1],t[0][2]=e[2],t[1][0]=e[4],t[1][1]=e[5],t[1][2]=e[6],t[2][0]=e[8],t[2][1]=e[9],t[2][2]=e[10]}function a(t,e,r,n,i){t[0]=e[0]*n+r[0]*i,t[1]=e[1]*n+r[1]*i,t[2]=e[2]*n+r[2]*i}var o=t("./normalize"),s=t("gl-mat4/create"),l=t("gl-mat4/clone"),c=t("gl-mat4/determinant"),u=t("gl-mat4/invert"),f=t("gl-mat4/transpose"),h={length:t("gl-vec3/length"),normalize:t("gl-vec3/normalize"),dot:t("gl-vec3/dot"),cross:t("gl-vec3/cross")},d=s(),p=s(),g=[0,0,0,0],v=[[0,0,0],[0,0,0],[0,0,0]],m=[0,0,0];e.exports=function(t,e,r,s,y,b){if(e||(e=[0,0,0]),r||(r=[0,0,0]),s||(s=[0,0,0]),y||(y=[0,0,0,1]),b||(b=[0,0,0,1]),!o(d,t))return!1;if(l(p,d),p[3]=0,p[7]=0,p[11]=0,p[15]=1,Math.abs(c(p)<1e-8))return!1;var x=d[3],_=d[7],w=d[11],k=d[12],A=d[13],M=d[14],T=d[15];if(0!==x||0!==_||0!==w){g[0]=x,g[1]=_,g[2]=w,g[3]=T;var E=u(p,p);if(!E)return!1;f(p,p),n(y,g,p)}else y[0]=y[1]=y[2]=0,y[3]=1;if(e[0]=k,e[1]=A,e[2]=M,i(v,d),r[0]=h.length(v[0]),h.normalize(v[0],v[0]),s[0]=h.dot(v[0],v[1]),a(v[1],v[1],v[0],1,-s[0]),r[1]=h.length(v[1]),h.normalize(v[1],v[1]),s[0]/=r[1],s[1]=h.dot(v[0],v[2]),a(v[2],v[2],v[0],1,-s[1]),s[2]=h.dot(v[1],v[2]),a(v[2],v[2],v[1],1,-s[2]),r[2]=h.length(v[2]),h.normalize(v[2],v[2]),s[1]/=r[2],s[2]/=r[2],h.cross(m,v[1],v[2]),h.dot(v[0],m)<0)for(var L=0;3>L;L++)r[L]*=-1,v[L][0]*=-1,v[L][1]*=-1,v[L][2]*=-1;return b[0]=.5*Math.sqrt(Math.max(1+v[0][0]-v[1][1]-v[2][2],0)),b[1]=.5*Math.sqrt(Math.max(1-v[0][0]+v[1][1]-v[2][2],0)),b[2]=.5*Math.sqrt(Math.max(1-v[0][0]-v[1][1]+v[2][2],0)),b[3]=.5*Math.sqrt(Math.max(1+v[0][0]+v[1][1]+v[2][2],0)),v[2][1]>v[1][2]&&(b[0]=-b[0]),v[0][2]>v[2][0]&&(b[1]=-b[1]),v[1][0]>v[0][1]&&(b[2]=-b[2]),!0}},{"./normalize":206,"gl-mat4/clone":122,"gl-mat4/create":123,"gl-mat4/determinant":124,"gl-mat4/invert":128,"gl-mat4/transpose":138,"gl-vec3/cross":183,"gl-vec3/dot":184,"gl-vec3/length":185,"gl-vec3/normalize":187}],206:[function(t,e,r){e.exports=function(t,e){var r=e[15];if(0===r)return!1;for(var n=1/r,i=0;16>i;i++)t[i]=e[i]*n;return!0}},{}],207:[function(t,e,r){function n(t,e,r,n){if(0===u(e)||0===u(r))return!1;var i=c(e,h.translate,h.scale,h.skew,h.perspective,h.quaternion),a=c(r,d.translate,d.scale,d.skew,d.perspective,d.quaternion);return i&&a?(s(p.translate,h.translate,d.translate,n),s(p.skew,h.skew,d.skew,n),s(p.scale,h.scale,d.scale,n),s(p.perspective,h.perspective,d.perspective,n),f(p.quaternion,h.quaternion,d.quaternion,n),l(t,p.translate,p.scale,p.skew,p.perspective,p.quaternion),!0):!1}function i(){return{translate:a(),scale:a(1),skew:a(),perspective:o(),quaternion:o()}}function a(t){return[t||0,t||0,t||0]}function o(){return[0,0,0,1]}var s=t("gl-vec3/lerp"),l=t("mat4-recompose"),c=t("mat4-decompose"),u=t("gl-mat4/determinant"),f=t("quat-slerp"),h=i(),d=i(),p=i();e.exports=n},{"gl-mat4/determinant":124,"gl-vec3/lerp":186,"mat4-decompose":205,"mat4-recompose":208,"quat-slerp":240}],208:[function(t,e,r){var n={identity:t("gl-mat4/identity"),translate:t("gl-mat4/translate"),multiply:t("gl-mat4/multiply"),create:t("gl-mat4/create"),scale:t("gl-mat4/scale"),fromRotationTranslation:t("gl-mat4/fromRotationTranslation")},i=(n.create(),n.create());e.exports=function(t,e,r,a,o,s){return n.identity(t),n.fromRotationTranslation(t,s,e),t[3]=o[0],t[7]=o[1],t[11]=o[2],t[15]=o[3],n.identity(i),0!==a[2]&&(i[9]=a[2],n.multiply(t,t,i)),0!==a[1]&&(i[9]=0,i[8]=a[1],n.multiply(t,t,i)),0!==a[0]&&(i[8]=0,i[4]=a[0],n.multiply(t,t,i)),n.scale(t,t,r),t}},{"gl-mat4/create":123,"gl-mat4/fromRotationTranslation":126,"gl-mat4/identity":127,"gl-mat4/multiply":130,"gl-mat4/scale":136,"gl-mat4/translate":137}],209:[function(t,e,r){"use strict";function n(t){this._components=t.slice(),this._time=[0],this.prevMatrix=t.slice(),this.nextMatrix=t.slice(),this.computedMatrix=t.slice(),this.computedInverse=t.slice(),this.computedEye=[0,0,0],this.computedUp=[0,0,0],this.computedCenter=[0,0,0],this.computedRadius=[0],this._limits=[-(1/0),1/0]}function i(t){t=t||{};var e=t.matrix||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return new n(e)}var a=t("binary-search-bounds"),o=t("mat4-interpolate"),s=t("gl-mat4/invert"),l=t("gl-mat4/rotateX"),c=t("gl-mat4/rotateY"),u=t("gl-mat4/rotateZ"),f=t("gl-mat4/lookAt"),h=t("gl-mat4/translate"),d=(t("gl-mat4/scale"),t("gl-vec3/normalize")),p=[0,0,0];e.exports=i;var g=n.prototype;g.recalcMatrix=function(t){var e=this._time,r=a.le(e,t),n=this.computedMatrix;if(!(0>r)){var i=this._components;if(r===e.length-1)for(var l=16*r,c=0;16>c;++c)n[c]=i[l++];else{for(var u=e[r+1]-e[r],l=16*r,f=this.prevMatrix,h=!0,c=0;16>c;++c)f[c]=i[l++];for(var p=this.nextMatrix,c=0;16>c;++c)p[c]=i[l++],h=h&&f[c]===p[c];if(1e-6>u||h)for(var c=0;16>c;++c)n[c]=f[c];else o(n,f,p,(t-e[r])/u)}var g=this.computedUp;g[0]=n[1],g[1]=n[5],g[2]=n[6],d(g,g);var v=this.computedInverse;s(v,n);var m=this.computedEye,y=v[15];m[0]=v[12]/y,m[1]=v[13]/y,m[2]=v[14]/y;for(var b=this.computedCenter,x=Math.exp(this.computedRadius[0]),c=0;3>c;++c)b[c]=m[c]-n[2+4*c]*x}},g.idle=function(t){if(!(tn;++n)e.push(e[r++]);this._time.push(t)}},g.flush=function(t){var e=a.gt(this._time,t)-2;0>e||(this._time.slice(0,e),this._components.slice(0,16*e))},g.lastT=function(){return this._time[this._time.length-1]},g.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||p,n=n||this.computedUp,this.setMatrix(t,f(this.computedMatrix,e,r,n));for(var i=0,a=0;3>a;++a)i+=Math.pow(r[a]-e[a],2);i=Math.log(Math.sqrt(i)),this.computedRadius[0]=i},g.rotate=function(t,e,r,n){this.recalcMatrix(t);var i=this.computedInverse;e&&c(i,i,e),r&&l(i,i,r),n&&u(i,i,n),this.setMatrix(t,s(this.computedMatrix,i))};var v=[0,0,0];g.pan=function(t,e,r,n){v[0]=-(e||0),v[1]=-(r||0),v[2]=-(n||0),this.recalcMatrix(t);var i=this.computedInverse;h(i,i,v),this.setMatrix(t,s(i,i))},g.translate=function(t,e,r,n){v[0]=e||0,v[1]=r||0,v[2]=n||0,this.recalcMatrix(t);var i=this.computedMatrix;h(i,i,v),this.setMatrix(t,i)},g.setMatrix=function(t,e){if(!(tr;++r)this._components.push(e[r])}},g.setDistance=function(t,e){this.computedRadius[0]=e},g.setDistanceLimits=function(t,e){var r=this._limits;r[0]=t,r[1]=e},g.getDistanceLimits=function(t){var e=this._limits;return t?(t[0]=e[0],t[1]=e[1],t):e}},{"binary-search-bounds":47,"gl-mat4/invert":128,"gl-mat4/lookAt":129,"gl-mat4/rotateX":133,"gl-mat4/rotateY":134,"gl-mat4/rotateZ":135,"gl-mat4/scale":136,"gl-mat4/translate":137,"gl-vec3/normalize":187,"mat4-interpolate":207}],210:[function(t,e,r){"use strict";function n(t){var e=t.length;if(3>e){for(var r=new Array(e),n=0;e>n;++n)r[n]=n;return 2===e&&t[0][0]===t[1][0]&&t[0][1]===t[1][1]?[0]:r}for(var a=new Array(e),n=0;e>n;++n)a[n]=n;a.sort(function(e,r){var n=t[e][0]-t[r][0];return n?n:t[e][1]-t[r][1]});for(var o=[a[0],a[1]],s=[a[0],a[1]],n=2;e>n;++n){for(var l=a[n],c=t[l],u=o.length;u>1&&i(t[o[u-2]],t[o[u-1]],c)<=0;)u-=1,o.pop();for(o.push(l),u=s.length;u>1&&i(t[s[u-2]],t[s[u-1]],c)>=0;)u-=1,s.pop();s.push(l)}for(var r=new Array(s.length+o.length-2),f=0,n=0,h=o.length;h>n;++n)r[f++]=o[n];for(var d=s.length-2;d>0;--d)r[f++]=s[d];return r}e.exports=n;var i=t("robust-orientation")[3]},{"robust-orientation":253}],211:[function(t,e,r){"use strict";function n(t,e){function r(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==g.alt,g.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==g.shift,g.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==g.control,g.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==g.meta,g.meta=!!t.metaKey),e}function n(t,n){var a=i.x(n),o=i.y(n);"buttons"in n&&(t=0|n.buttons),(t!==h||a!==d||o!==p||r(n))&&(h=0|t,d=a||0,p=o||0,e&&e(h,d,p,g))}function a(t){n(0,t)}function o(){(h||d||p||g.shift||g.alt||g.meta||g.control)&&(d=p=0,h=0,g.shift=g.alt=g.control=g.meta=!1,e&&e(0,0,0,g))}function s(t){r(t)&&e&&e(h,d,p,g)}function l(t){0===i.buttons(t)?n(0,t):n(h,t)}function c(t){n(h|i.buttons(t),t)}function u(t){n(h&~i.buttons(t),t)}function f(){v||(v=!0,t.addEventListener("mousemove",l),t.addEventListener("mousedown",c),t.addEventListener("mouseup",u),t.addEventListener("mouseleave",a),t.addEventListener("mouseenter",a),t.addEventListener("mouseout",a),t.addEventListener("mouseover",a),t.addEventListener("blur",o),t.addEventListener("keyup",s),t.addEventListener("keydown",s),t.addEventListener("keypress",s),t!==window&&(window.addEventListener("blur",o),window.addEventListener("keyup",s),window.addEventListener("keydown",s),window.addEventListener("keypress",s)))}e||(e=t,t=window);var h=0,d=0,p=0,g={shift:!1,alt:!1,control:!1,meta:!1},v=!1;f();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return v},set:function(t){t&&f()},enumerable:!0},buttons:{get:function(){return h},enumerable:!0},x:{get:function(){return d},enumerable:!0},y:{get:function(){return p},enumerable:!0},mods:{get:function(){return g},enumerable:!0}}),m}e.exports=n;var i=t("mouse-event")},{"mouse-event":212}],212:[function(t,e,r){"use strict";function n(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<i;++i)e&1<e;++e)F.push(u(e),"+=",d(e,x[t]),";");F.push("}")}function z(t){for(var e=t-1;e>=0;--e)S(e,0);for(var r=[],e=0;I>e;++e)L[e]?r.push(i(e)+".get("+u(e)+")"):r.push(i(e)+"["+u(e)+"]");for(var e=0;b>e;++e)r.push(c(e));F.push(k,"[",T,"++]=phase(",r.join(),");");for(var e=0;t>e;++e)C(e);for(var n=0;I>n;++n)F.push(u(n),"+=",d(n,x[t]),";")}function P(t){for(var e=0;I>e;++e)L[e]?F.push(a(e,0),"=",i(e),".get(",u(e),");"):F.push(a(e,0),"=",i(e),"[",u(e),"];");for(var r=[],e=0;I>e;++e)r.push(a(e,0));for(var e=0;b>e;++e)r.push(c(e));F.push(p(0),"=",k,"[",T,"]=phase(",r.join(),");");for(var n=1;1<n;++n)F.push(p(n),"=",k,"[",T,"+",v(n),"];");for(var o=[],n=1;1<n;++n)o.push("("+p(0)+"!=="+p(n)+")");F.push("if(",o.join("||"),"){");for(var s=[],e=0;N>e;++e)s.push(h(e)); +for(var e=0;I>e;++e){s.push(a(e,0));for(var n=1;1<n;++n)L[e]?F.push(a(e,n),"=",i(e),".get(",u(e),"+",f(e,n),");"):F.push(a(e,n),"=",i(e),"[",u(e),"+",f(e,n),"];"),s.push(a(e,n))}for(var e=0;1<e;++e)s.push(p(e));for(var e=0;b>e;++e)s.push(c(e));F.push("vertex(",s.join(),");",m(0),"=",w,"[",T,"]=",A,"++;");for(var l=(1<n;++n)if(0===(t&~(1<0;_=_-1&g)x.push(w+"["+T+"+"+v(_)+"]");x.push(m(0));for(var _=0;I>_;++_)1&n?x.push(a(_,l),a(_,g)):x.push(a(_,g),a(_,l));1&n?x.push(d,y):x.push(y,d);for(var _=0;b>_;++_)x.push(c(_));F.push("if(",d,"!==",y,"){","face(",x.join(),")}")}F.push("}",T,"+=1;")}function R(){for(var t=1;1<t;++t)F.push(E,"=",v(t),";",v(t),"=",g(t),";",g(t),"=",E,";")}function O(t,e){if(0>t)return void P(e);z(t),F.push("if(",o(x[t]),">0){",h(x[t]),"=1;"),O(t-1,e|1<r;++r)F.push(u(r),"+=",d(r,x[t]),";");t===N-1&&(F.push(T,"=0;"),R()),S(t,2),O(t-1,e),t===N-1&&(F.push("if(",h(x[N-1]),"&1){",T,"=0;}"),R()),C(t),F.push("}")}var I=L.length,N=x.length;if(2>N)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var j="extractContour"+x.join("_"),F=[],B=[],D=[],U=0;I>U;++U)D.push(n(U));for(var U=0;b>U;++U)D.push(c(U));for(var U=0;N>U;++U)B.push(o(U)+"="+n(0)+".shape["+U+"]|0");for(var U=0;I>U;++U){B.push(i(U)+"="+n(U)+".data",l(U)+"="+n(U)+".offset|0");for(var V=0;N>V;++V)B.push(s(U,V)+"="+n(U)+".stride["+V+"]|0")}for(var U=0;I>U;++U){B.push(u(U)+"="+l(U)),B.push(a(U,0));for(var V=1;1<V;++V){for(var q=[],H=0;N>H;++H)V&1<U;++U)for(var V=0;N>V;++V){var G=[s(U,x[V])];V>0&&G.push(s(U,x[V-1])+"*"+o(x[V-1])),B.push(d(U,x[V])+"=("+G.join("-")+")|0")}for(var U=0;N>U;++U)B.push(h(U)+"=0");B.push(A+"=0");for(var Y=["2"],U=N-2;U>=0;--U)Y.push(o(x[U]));B.push(M+"=("+Y.join("*")+")|0",k+"=mallocUint32("+M+")",w+"=mallocUint32("+M+")",T+"=0"),B.push(p(0)+"=0");for(var V=1;1<V;++V){for(var X=[],W=[],H=0;N>H;++H)V&1<n&&e("Must have at least one array argument");var i=t.scalarArguments||0;0>i&&e("Scalar arg count must be > 0"),"function"!=typeof t.vertex&&e("Must specify vertex creation function"),"function"!=typeof t.cell&&e("Must specify cell creation function"),"function"!=typeof t.phase&&e("Must specify phase function");for(var a=t.getters||[],o=new Array(n),s=0;n>s;++s)a.indexOf(s)>=0?o[s]=!0:o[s]=!1;return b(t.vertex,t.cell,t.phase,i,r,o)}var _=t("typedarray-pool");e.exports=x;var w="V",k="P",A="N",M="Q",T="X",E="T"},{"typedarray-pool":282}],215:[function(t,e,r){"use strict";var n=t("cwise/lib/wrapper")({args:["index","array","scalar"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_4_arg1_=_inline_4_arg2_.apply(void 0,_inline_4_arg0_)}",args:[{name:"_inline_4_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_4_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_4_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"cwise",blockSize:64});e.exports=function(t,e){return n(t,e),t}},{"cwise/lib/wrapper":86}],216:[function(t,e,r){"use strict";function n(t){if(t in l)return l[t];for(var e=[],r=0;t>r;++r)e.push("out",r,"s=0.5*(inp",r,"l-inp",r,"r);");for(var n=["array"],i=["junk"],r=0;t>r;++r){n.push("array"),i.push("out"+r+"s");var a=o(t);a[r]=-1,n.push({array:0,offset:a.slice()}),a[r]=1,n.push({array:0,offset:a.slice()}),i.push("inp"+r+"l","inp"+r+"r")}return l[t]=s({args:n,pre:u,post:u,body:{body:e.join(""),args:i.map(function(t){return{name:t,lvalue:0===t.indexOf("out"),rvalue:0===t.indexOf("inp"),count:"junk"!==t|0}}),thisVars:[],localVars:[]},funcName:"fdTemplate"+t})}function i(t){function e(e){for(var r=a-e.length,n=[],i=[],s=[],l=0;a>l;++l)e.indexOf(l+1)>=0?s.push("0"):e.indexOf(-(l+1))>=0?s.push("s["+l+"]-1"):(s.push("-1"),n.push("1"),i.push("s["+l+"]-2"));var c=".lo("+n.join()+").hi("+i.join()+")";if(0===n.length&&(c=""),r>0){o.push("if(1");for(var l=0;a>l;++l)e.indexOf(l+1)>=0||e.indexOf(-(l+1))>=0||o.push("&&s[",l,"]>2");o.push("){grad",r,"(src.pick(",s.join(),")",c);for(var l=0;a>l;++l)e.indexOf(l+1)>=0||e.indexOf(-(l+1))>=0||o.push(",dst.pick(",s.join(),",",l,")",c);o.push(");")}for(var l=0;l1){dst.set(",s.join(),",",u,",0.5*(src.get(",h.join(),")-src.get(",d.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):o.push("if(s[",u,"]>1){diff(",f,",src.pick(",h.join(),")",c,",src.pick(",d.join(),")",c,");}else{zero(",f,");};");break;case"mirror":0===r?o.push("dst.set(",s.join(),",",u,",0);"):o.push("zero(",f,");");break;case"wrap":var p=s.slice(),g=s.slice();e[l]<0?(p[u]="s["+u+"]-2",g[u]="0"):(p[u]="s["+u+"]-1",g[u]="1"),0===r?o.push("if(s[",u,"]>2){dst.set(",s.join(),",",u,",0.5*(src.get(",p.join(),")-src.get(",g.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):o.push("if(s[",u,"]>2){diff(",f,",src.pick(",p.join(),")",c,",src.pick(",g.join(),")",c,");}else{zero(",f,");};");break;default:throw new Error("ndarray-gradient: Invalid boundary condition")}}r>0&&o.push("};")}var r=t.join(),i=c[r];if(i)return i;for(var a=t.length,o=["function gradient(dst,src){var s=src.shape.slice();"],s=0;1<
s;++s){for(var u=[],d=0;a>d;++d)s&1<=s;++s)v.push("grad"+s),m.push(n(s));v.push(o.join(""));var y=Function.apply(void 0,v),i=y.apply(void 0,m);return l[r]=i,i}function a(t,e,r){if(Array.isArray(r)){if(r.length!==e.dimension)throw new Error("ndarray-gradient: invalid boundary conditions")}else r="string"==typeof r?o(e.dimension,r):o(e.dimension,"clamp");if(t.dimension!==e.dimension+1)throw new Error("ndarray-gradient: output dimension must be +1 input dimension");if(t.shape[e.dimension]!==e.dimension)throw new Error("ndarray-gradient: output shape must match input shape");for(var n=0;nr;++r){t[r]=o[(n+1)*n+r];for(var i=0;n>i;++i)t[r]+=o[(n+1)*i+r]*e[i]}for(var a=o[(n+1)*(n+1)-1],i=0;n>i;++i)a+=o[(n+1)*i+n]*e[i];for(var s=1/a,r=0;n>r;++r)t[r]*=s;return t}),t}var i=t("ndarray-warp"),a=t("gl-matrix-invert");e.exports=n},{"gl-matrix-invert":139,"ndarray-warp":224}],218:[function(t,e,r){"use strict";function n(t,e){var r=Math.floor(e),n=e-r,i=r>=0&&r=0&&r+1=0&&n=0&&n+1=0&&s=0&&s+1=0&&i=0&&i+1=0&&l=0&&l+1=0&&h=0&&h+1e;++e)r=+arguments[e+1],i[e]=Math.floor(r),a[e]=r-i[e],o[e]=0<=i[e]&&i[e]e;++e){for(c=1,u=t.offset,l=0;n>l;++l)if(e&1<>",rrshift:">>>"};!function(){for(var t in l){var e=l[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var c={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in c){var e=c[t];r[t]=a({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var u={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in u){var e=u[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var f=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=o({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=o({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=o({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":83}],220:[function(t,e,r){"use strict";var n=t("ndarray"),i=t("./doConvert.js");e.exports=function(t,e){for(var r=[],a=t,o=1;a instanceof Array;)r.push(a.length),o*=a.length,a=a[0];return 0===r.length?n():(e||(e=n(new Float64Array(o),r)),i(e,t),e)}},{"./doConvert.js":221,ndarray:225}],221:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}",args:[{name:"_inline_1_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_1_i","_inline_1_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},funcName:"convert",blockSize:64})},{"cwise-compiler":83}],222:[function(t,e,r){"use strict";function n(t){switch(t){case"uint8":return[l.mallocUint8,l.freeUint8];case"uint16":return[l.mallocUint16,l.freeUint16];case"uint32":return[l.mallocUint32,l.freeUint32];case"int8":return[l.mallocInt8,l.freeInt8];case"int16":return[l.mallocInt16,l.freeInt16];case"int32":return[l.mallocInt32,l.freeInt32];case"float32":return[l.mallocFloat,l.freeFloat];case"float64":return[l.mallocDouble,l.freeDouble];default:return null}}function i(t){for(var e=[],r=0;t>r;++r)e.push("s"+r);for(var r=0;t>r;++r)e.push("n"+r);for(var r=1;t>r;++r)e.push("d"+r);for(var r=1;t>r;++r)e.push("e"+r);for(var r=1;t>r;++r)e.push("f"+r);return e}function a(t,e){function r(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function a(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}var o=["'use strict'"],s=["ndarrayInsertionSort",t.join("d"),e].join(""),l=["left","right","data","offset"].concat(i(t.length)),c=n(e),u=["i,j,cptr,ptr=left*s0+offset"];if(t.length>1){for(var f=[],h=1;h1){o.push("dptr=0;sptr=ptr");for(var h=t.length-1;h>=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"left){","dptr=0","sptr=cptr-s0");for(var h=1;hb){break __l}"].join(""));for(var h=t.length-1;h>=1;--h)o.push("sptr+=e"+h,"dptr+=f"+h,"}");o.push("dptr=cptr;sptr=cptr-s0");for(var h=t.length-1;h>=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"left)&&("+r("cptr-s0")+">scratch)){",a("cptr",r("cptr-s0")),"cptr-=s0","}",a("cptr","scratch"));if(o.push("}"),t.length>1&&c&&o.push("free(scratch)"),o.push("} return "+s),c){var p=new Function("malloc","free",o.join("\n"));return p(c[0],c[1])}var p=new Function(o.join("\n"));return p()}function o(t,e,r){function a(t){return["(offset+",t,"*s0)"].join("")}function o(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function s(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}function l(e,r,n){if(1===e.length)_.push("ptr0="+a(e[0]));else for(var i=0;i=0;--i){var o=t[i];0!==o&&_.push(["for(i",o,"=0;i",o,"1)for(var i=0;i1?_.push("ptr_shift+=d"+o):_.push("ptr0+=d"+o),_.push("}"))}}function u(e,r,n,i){if(1===r.length)_.push("ptr0="+a(r[0]));else{for(var o=0;o1)for(var o=0;o=1;--o)n&&_.push("pivot_ptr+=f"+o),r.length>1?_.push("ptr_shift+=e"+o):_.push("ptr0+=e"+o),_.push("}")}function f(){t.length>1&&A&&_.push("free(pivot1)","free(pivot2)")}function h(e,r){var n="el"+e,i="el"+r;if(t.length>1){var s="__l"+ ++M;u(s,[n,i],!1,["comp=",o("ptr0"),"-",o("ptr1"),"\n","if(comp>0){tmp0=",n,";",n,"=",i,";",i,"=tmp0;break ",s,"}\n","if(comp<0){break ",s,"}"].join(""))}else _.push(["if(",o(a(n)),">",o(a(i)),"){tmp0=",n,";",n,"=",i,";",i,"=tmp0}"].join(""))}function d(e,r){t.length>1?l([e,r],!1,s("ptr0",o("ptr1"))):_.push(s(a(e),o(a(r))))}function p(e,r,n){if(t.length>1){var i="__l"+ ++M;u(i,[r],!0,[e,"=",o("ptr0"),"-pivot",n,"[pivot_ptr]\n","if(",e,"!==0){break ",i,"}"].join(""))}else _.push([e,"=",o(a(r)),"-pivot",n].join(""))}function g(e,r){t.length>1?l([e,r],!1,["tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1","tmp")].join("")):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1","tmp")].join(""))}function v(e,r,n){t.length>1?(l([e,r,n],!1,["tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1",o("ptr2")),"\n",s("ptr2","tmp")].join("")),_.push("++"+r,"--"+n)):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","ptr2=",a(n),"\n","++",r,"\n","--",n,"\n","tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1",o("ptr2")),"\n",s("ptr2","tmp")].join(""))}function m(t,e){g(t,e),_.push("--"+e)}function y(e,r,n){t.length>1?l([e,r],!0,[s("ptr0",o("ptr1")),"\n",s("ptr1",["pivot",n,"[pivot_ptr]"].join(""))].join("")):_.push(s(a(e),o(a(r))),s(a(r),"pivot"+n))}function b(e,r){_.push(["if((",r,"-",e,")<=",c,"){\n","insertionSort(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}else{\n",w,"(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}"].join(""))}function x(e,r,n){t.length>1?(_.push(["__l",++M,":while(true){"].join("")),l([e],!0,["if(",o("ptr0"),"!==pivot",r,"[pivot_ptr]){break __l",M,"}"].join("")),_.push(n,"}")):_.push(["while(",o(a(e)),"===pivot",r,"){",n,"}"].join(""))}var _=["'use strict'"],w=["ndarrayQuickSort",t.join("d"),e].join(""),k=["left","right","data","offset"].concat(i(t.length)),A=n(e),M=0;_.push(["function ",w,"(",k.join(","),"){"].join(""));var T=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1=0","comp_pivot2=0","comp=0"];if(t.length>1){for(var E=[],L=1;LL;++L)T.push("b_ptr"+L);T.push("ptr3","ptr4","ptr5","ptr6","ptr7","pivot_ptr","ptr_shift","elementSize="+E.join("*")),A?T.push("pivot1=malloc(elementSize)","pivot2=malloc(elementSize)"):T.push("pivot1=new Array(elementSize),pivot2=new Array(elementSize)")}else T.push("pivot1","pivot2");if(_.push("var "+T.join(",")),h(1,2),h(4,5),h(1,3),h(2,3),h(1,4),h(3,4),h(2,5),h(2,3),h(4,5),t.length>1?l(["el1","el2","el3","el4","el5","index1","index3","index5"],!0,["pivot1[pivot_ptr]=",o("ptr1"),"\n","pivot2[pivot_ptr]=",o("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",o("ptr0"),"\n","y=",o("ptr2"),"\n","z=",o("ptr4"),"\n",s("ptr5","x"),"\n",s("ptr6","y"),"\n",s("ptr7","z")].join("")):_.push(["pivot1=",o(a("el2")),"\n","pivot2=",o(a("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",o(a("el1")),"\n","y=",o(a("el3")),"\n","z=",o(a("el5")),"\n",s(a("index1"),"x"),"\n",s(a("index3"),"y"),"\n",s(a("index5"),"z")].join("")),d("index2","left"),d("index4","right"),_.push("if(pivots_are_equal){"),_.push("for(k=less;k<=great;++k){"),p("comp","k",1),_.push("if(comp===0){continue}"),_.push("if(comp<0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),_.push("while(true){"),p("comp","great",1),_.push("if(comp>0){"),_.push("great--"),_.push("}else if(comp<0){"),v("k","less","great"),_.push("break"),_.push("}else{"),m("k","great"),_.push("break"),_.push("}"),_.push("}"),_.push("}"),_.push("}"),_.push("}else{"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1<0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2>0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp>0){"),_.push("if(--greatindex5){"),x("less",1,"++less"),x("great",2,"--great"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1===0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2===0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp===0){"),_.push("if(--great1&&A){var S=new Function("insertionSort","malloc","free",_.join("\n"));return S(r,A[0],A[1])}var S=new Function("insertionSort",_.join("\n"));return S(r)}function s(t,e){var r=["'use strict'"],n=["ndarraySortWrapper",t.join("d"),e].join(""),s=["array"];r.push(["function ",n,"(",s.join(","),"){"].join(""));for(var l=["data=array.data,offset=array.offset|0,shape=array.shape,stride=array.stride"],u=0;u0?l.push(["d",v,"=s",v,"-d",p,"*n",p].join("")):l.push(["d",v,"=s",v].join("")),p=v);var d=t.length-1-u;0!==d&&(g>0?l.push(["e",d,"=s",d,"-e",g,"*n",g,",f",d,"=",f[d],"-f",g,"*n",g].join("")):l.push(["e",d,"=s",d,",f",d,"=",f[d]].join("")),g=d)}r.push("var "+l.join(","));var m=["0","n0-1","data","offset"].concat(i(t.length));r.push(["if(n0<=",c,"){","insertionSort(",m.join(","),")}else{","quickSort(",m.join(","),")}"].join("")),r.push("}return "+n);var y=new Function("insertionSort","quickSort",r.join("\n")),b=a(t,e),x=o(t,e,b);return y(b,x)}var l=t("typedarray-pool"),c=32;e.exports=s},{"typedarray-pool":282}],223:[function(t,e,r){"use strict";function n(t){var e=t.order,r=t.dtype,n=[e,r],o=n.join(":"),s=a[o];return s||(a[o]=s=i(e,r)),s(t),t}var i=t("./lib/compile_sort.js"),a={};e.exports=n},{"./lib/compile_sort.js":222}],224:[function(t,e,r){"use strict";var n=t("ndarray-linear-interpolate"),i=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=new Array(_inline_18_arg4_)}",args:[{name:"_inline_18_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_18_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_18_arg2_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_18_arg3_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_18_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_19_arg2_(this_warped,_inline_19_arg0_),_inline_19_arg1_=_inline_19_arg3_.apply(void 0,this_warped)}",args:[{name:"_inline_19_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_19_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_19_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_19_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_19_arg4_",lvalue:!1,rvalue:!1,count:0}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warpND",blockSize:64}),a=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0]}", +args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_22_arg2_(this_warped,_inline_22_arg0_),_inline_22_arg1_=_inline_22_arg3_(_inline_22_arg4_,this_warped[0])}",args:[{name:"_inline_22_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_22_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_22_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_22_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_22_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp1D",blockSize:64}),o=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_25_arg2_(this_warped,_inline_25_arg0_),_inline_25_arg1_=_inline_25_arg3_(_inline_25_arg4_,this_warped[0],this_warped[1])}",args:[{name:"_inline_25_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_25_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_25_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_25_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_25_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp2D",blockSize:64}),s=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_28_arg2_(this_warped,_inline_28_arg0_),_inline_28_arg1_=_inline_28_arg3_(_inline_28_arg4_,this_warped[0],this_warped[1],this_warped[2])}",args:[{name:"_inline_28_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_28_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_28_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_28_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_28_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp3D",blockSize:64});e.exports=function(t,e,r){switch(e.shape.length){case 1:a(t,r,n.d1,e);break;case 2:o(t,r,n.d2,e);break;case 3:s(t,r,n.d3,e);break;default:i(t,r,n.bind(void 0,e),e.shape.length)}return t}},{"cwise/lib/wrapper":86,"ndarray-linear-interpolate":218}],225:[function(t,e,r){function n(t,e){return t[0]-e[0]}function i(){var t,e=this.stride,r=new Array(e.length);for(t=0;te&&(r="View_Nil"+t);var n="generic"===t;if(-1===e){var a="function "+r+"(a){this.data=a;};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+r+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+r+"(a){return new "+r+"(a);}",o=new Function(a);return o()}if(0===e){var a="function "+r+"(a,d) {this.data = a;this.offset = d};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+r+"_copy() {return new "+r+"(this.data,this.offset)};proto.pick=function "+r+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+r+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+r+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+r+"(a,b,c,d){return new "+r+"(a,d)}",o=new Function("TrivialArray",a);return o(f[t][0])}var a=["'use strict'"],s=l(e),c=s.map(function(t){return"i"+t}),u="this.offset+"+s.map(function(t){return"this.stride["+t+"]*i"+t}).join("+"),h=s.map(function(t){return"b"+t}).join(","),d=s.map(function(t){return"c"+t}).join(",");a.push("function "+r+"(a,"+h+","+d+",d){this.data=a","this.shape=["+h+"]","this.stride=["+d+"]","this.offset=d|0}","var proto="+r+".prototype","proto.dtype='"+t+"'","proto.dimension="+e),a.push("Object.defineProperty(proto,'size',{get:function "+r+"_size(){return "+s.map(function(t){return"this.shape["+t+"]"}).join("*"),"}})"),1===e?a.push("proto.order=[0]"):(a.push("Object.defineProperty(proto,'order',{get:"),4>e?(a.push("function "+r+"_order(){"),2===e?a.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+c.join(",")+",v){"),n?a.push("return this.data.set("+u+",v)}"):a.push("return this.data["+u+"]=v}"),a.push("proto.get=function "+r+"_get("+c.join(",")+"){"),n?a.push("return this.data.get("+u+")}"):a.push("return this.data["+u+"]}"),a.push("proto.index=function "+r+"_index(",c.join(),"){return "+u+"}"),a.push("proto.hi=function "+r+"_hi("+c.join(",")+"){return new "+r+"(this.data,"+s.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+s.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=s.map(function(t){return"a"+t+"=this.shape["+t+"]"}),g=s.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+c.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+g.join(","));for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){d=i"+v+"|0;b+=c"+v+"*d;a"+v+"-=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+c.join(",")+"){var "+s.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+s.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'){d=i"+v+"|0;if(d<0){c+=b"+v+"*(a"+v+"-1);a"+v+"=ceil(-a"+v+"/d)}else{a"+v+"=ceil(a"+v+"/d)}b"+v+"*=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"b"+t}).join(",")+",c)}");for(var m=new Array(e),y=new Array(e),v=0;e>v;++v)m[v]="a[i"+v+"]",y[v]="b[i"+v+"]";a.push("proto.transpose=function "+r+"_transpose("+c+"){"+c.map(function(t,e){return t+"=("+t+"===undefined?"+e+":"+t+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+r+"(this.data,"+m.join(",")+","+y.join(",")+",this.offset)}"),a.push("proto.pick=function "+r+"_pick("+c+"){var a=[],b=[],c=this.offset");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+s.map(function(t){return"shape["+t+"]"}).join(",")+","+s.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}");var o=new Function("CTOR_LIST","ORDER",a.join("\n"));return o(f[t],i)}function o(t){if(c(t))return"buffer";if(u)switch(Object.prototype.toString.call(t)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(t)?"array":"generic"}function s(t,e,r,n){if(void 0===t){var i=f.array[0];return i([])}"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var s=e.length;if(void 0===r){r=new Array(s);for(var l=s-1,c=1;l>=0;--l)r[l]=c,c*=e[l]}if(void 0===n){n=0;for(var l=0;s>l;++l)r[l]<0&&(n-=(e[l]-1)*r[l])}for(var u=o(t),h=f[u];h.length<=s+1;)h.push(a(u,h.length-1));var i=h[s+1];return i(t,e,r,n)}var l=t("iota-array"),c=t("is-buffer"),u="undefined"!=typeof Float64Array,f={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=s},{"iota-array":202,"is-buffer":203}],226:[function(t,e,r){"use strict";function n(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return 0>e?-a:a;var r=i.hi(t),n=i.lo(t);return e>t==t>0?n===o?(r+=1,n=0):n+=1:0===n?(n=o,r-=1):n-=1,i.pack(n,r)}var i=t("double-bits"),a=Math.pow(2,-1074),o=-1>>>0;e.exports=n},{"double-bits":89}],227:[function(t,e,r){var n=1e-6,i=1e-6;r.vertexNormals=function(t,e,r){for(var i=e.length,a=new Array(i),o=void 0===r?n:r,s=0;i>s;++s)a[s]=[0,0,0];for(var s=0;sx;++x)v[x]=d[x]-p[x],m+=v[x]*v[x],y[x]=g[x]-p[x],b+=y[x]*y[x];if(m*b>o)for(var _=a[u],w=1/Math.sqrt(m*b),x=0;3>x;++x){var k=(x+1)%3,A=(x+2)%3;_[x]+=w*(y[k]*v[A]-y[A]*v[k])}}for(var s=0;i>s;++s){for(var _=a[s],M=0,x=0;3>x;++x)M+=_[x]*_[x];if(M>o)for(var w=1/Math.sqrt(M),x=0;3>x;++x)_[x]*=w;else for(var x=0;3>x;++x)_[x]=0}return a},r.faceNormals=function(t,e,r){for(var n=t.length,a=new Array(n),o=void 0===r?i:r,s=0;n>s;++s){for(var l=t[s],c=new Array(3),u=0;3>u;++u)c[u]=e[l[u]];for(var f=new Array(3),h=new Array(3),u=0;3>u;++u)f[u]=c[1][u]-c[0][u],h[u]=c[2][u]-c[0][u];for(var d=new Array(3),p=0,u=0;3>u;++u){var g=(u+1)%3,v=(u+2)%3;d[u]=f[g]*h[v]-f[v]*h[g],p+=d[u]*d[u]}p=p>o?1/Math.sqrt(p):0;for(var u=0;3>u;++u)d[u]*=p;a[s]=d}return a}},{}],228:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c){var u=e+a+c;if(f>0){var f=Math.sqrt(u+1);t[0]=.5*(o-l)/f,t[1]=.5*(s-n)/f,t[2]=.5*(r-a)/f,t[3]=.5*f}else{var h=Math.max(e,a,c),f=Math.sqrt(2*h-u+1);e>=h?(t[0]=.5*f,t[1]=.5*(i+r)/f,t[2]=.5*(s+n)/f,t[3]=.5*(o-l)/f):a>=h?(t[0]=.5*(r+i)/f,t[1]=.5*f,t[2]=.5*(l+o)/f,t[3]=.5*(s-n)/f):(t[0]=.5*(n+s)/f,t[1]=.5*(o+l)/f,t[2]=.5*f,t[3]=.5*(r-i)/f)}return t}e.exports=n},{}],229:[function(t,e,r){"use strict";function n(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function i(t,e,r,n){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2)+Math.pow(n,2))}function a(t,e){var r=e[0],n=e[1],a=e[2],o=e[3],s=i(r,n,a,o);s>1e-6?(t[0]=r/s,t[1]=n/s,t[2]=a/s,t[3]=o/s):(t[0]=t[1]=t[2]=0,t[3]=1)}function o(t,e,r){this.radius=l([r]),this.center=l(e),this.rotation=l(t),this.computedRadius=this.radius.curve(0),this.computedCenter=this.center.curve(0),this.computedRotation=this.rotation.curve(0),this.computedUp=[.1,0,0],this.computedEye=[.1,0,0],this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.recalcMatrix(0)}function s(t){t=t||{};var e=t.center||[0,0,0],r=t.rotation||[0,0,0,1],n=t.radius||1;e=[].slice.call(e,0,3),r=[].slice.call(r,0,4),a(r,r);var i=new o(r,e,Math.log(n));return i.setDistanceLimits(t.zoomMin,t.zoomMax),("eye"in t||"up"in t)&&i.lookAt(0,t.eye,t.center,t.up),i}e.exports=s;var l=t("filtered-vector"),c=t("gl-mat4/lookAt"),u=t("gl-mat4/fromQuat"),f=t("gl-mat4/invert"),h=t("./lib/quatFromFrame"),d=o.prototype;d.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())},d.recalcMatrix=function(t){this.radius.curve(t),this.center.curve(t),this.rotation.curve(t);var e=this.computedRotation;a(e,e);var r=this.computedMatrix;u(r,e);var n=this.computedCenter,i=this.computedEye,o=this.computedUp,s=Math.exp(this.computedRadius[0]);i[0]=n[0]+s*r[2],i[1]=n[1]+s*r[6],i[2]=n[2]+s*r[10],o[0]=r[1],o[1]=r[5],o[2]=r[9];for(var l=0;3>l;++l){for(var c=0,f=0;3>f;++f)c+=r[l+4*f]*i[f];r[12+l]=-c}},d.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;16>n;++n)e[n]=r[n];return e}return r},d.idle=function(t){this.center.idle(t),this.radius.idle(t),this.rotation.idle(t)},d.flush=function(t){this.center.flush(t),this.radius.flush(t),this.rotation.flush(t)},d.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=a[1],s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],f=a[4],h=a[8],d=u*o+f*s+h*l;u-=o*d,f-=s*d,h-=l*d;var p=n(u,f,h);u/=p,f/=p,h/=p;var g=a[2],v=a[6],m=a[10],y=g*o+v*s+m*l,b=g*u+v*f+m*h;g-=y*o+b*u,v-=y*s+b*f,m-=y*l+b*h;var x=n(g,v,m);g/=x,v/=x,m/=x;var _=u*e+o*r,w=f*e+s*r,k=h*e+l*r;this.center.move(t,_,w,k);var A=Math.exp(this.computedRadius[0]);A=Math.max(1e-4,A+i),this.radius.set(t,Math.log(A))},d.rotate=function(t,e,r,a){this.recalcMatrix(t),e=e||0,r=r||0;var o=this.computedMatrix,s=o[0],l=o[4],c=o[8],u=o[1],f=o[5],h=o[9],d=o[2],p=o[6],g=o[10],v=e*s+r*u,m=e*l+r*f,y=e*c+r*h,b=-(p*y-g*m),x=-(g*v-d*y),_=-(d*m-p*v),w=Math.sqrt(Math.max(0,1-Math.pow(b,2)-Math.pow(x,2)-Math.pow(_,2))),k=i(b,x,_,w);k>1e-6?(b/=k,x/=k,_/=k,w/=k):(b=x=_=0,w=1);var A=this.computedRotation,M=A[0],T=A[1],E=A[2],L=A[3],S=M*w+L*b+T*_-E*x,C=T*w+L*x+E*b-M*_,z=E*w+L*_+M*x-T*b,P=L*w-M*b-T*x-E*_;if(a){b=d,x=p,_=g;var R=Math.sin(a)/n(b,x,_);b*=R,x*=R,_*=R,w=Math.cos(e),S=S*w+P*b+C*_-z*x,C=C*w+P*x+z*b-S*_,z=z*w+P*_+S*x-C*b,P=P*w-S*b-C*x-z*_}var O=i(S,C,z,P);O>1e-6?(S/=O,C/=O,z/=O,P/=O):(S=C=z=0,P=1),this.rotation.set(t,S,C,z,P)},d.lookAt=function(t,e,r,n){this.recalcMatrix(t),r=r||this.computedCenter,e=e||this.computedEye,n=n||this.computedUp;var i=this.computedMatrix;c(i,e,r,n);var o=this.computedRotation;h(o,i[0],i[1],i[2],i[4],i[5],i[6],i[8],i[9],i[10]),a(o,o),this.rotation.set(t,o[0],o[1],o[2],o[3]);for(var s=0,l=0;3>l;++l)s+=Math.pow(r[l]-e[l],2);this.radius.set(t,.5*Math.log(Math.max(s,1e-6))),this.center.set(t,r[0],r[1],r[2])},d.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},d.setMatrix=function(t,e){var r=this.computedRotation;h(r,e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]),a(r,r),this.rotation.set(t,r[0],r[1],r[2],r[3]);var n=this.computedMatrix;f(n,e);var i=n[15];if(Math.abs(i)>1e-6){var o=n[12]/i,s=n[13]/i,l=n[14]/i;this.recalcMatrix(t);var c=Math.exp(this.computedRadius[0]);this.center.set(t,o-n[2]*c,s-n[6]*c,l-n[10]*c),this.radius.idle(t)}else this.center.idle(t),this.radius.idle(t)},d.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},d.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-(1/0),e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},d.getDistanceLimits=function(t){var e=this.radius.bounds;return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},d.toJSON=function(){return this.recalcMatrix(this.lastT()),{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}},d.fromJSON=function(t){var e=this.lastT(),r=t.center;r&&this.center.set(e,r[0],r[1],r[2]);var n=t.rotation;n&&this.rotation.set(e,n[0],n[1],n[2],n[3]);var i=t.distance;i&&i>0&&this.radius.set(e,Math.log(i)),this.setDistanceLimits(t.zoomMin,t.zoomMax)}},{"./lib/quatFromFrame":228,"filtered-vector":96,"gl-mat4/fromQuat":125,"gl-mat4/invert":128,"gl-mat4/lookAt":129}],230:[function(t,e,r){"use strict";var n=t("repeat-string");e.exports=function(t,e,r){return r="undefined"!=typeof r?r+"":" ",n(r,e)+t}},{"repeat-string":246}],231:[function(t,e,r){e.exports=function(t,e){e||(e=[0,""]),t=String(t);var r=parseFloat(t,10);return e[0]=r,e[1]=t.match(/[\d.\-\+]*\s*(.*)/)[1]||"",e}},{}],232:[function(t,e,r){"use strict";function n(t){var e=t.length;if(i>e){for(var r=1,n=0;e>n;++n)for(var o=0;n>o;++o)if(t[n]n;++n)s[n]=0;for(var r=1,n=0;e>n;++n)if(!s[n]){var l=1;s[n]=1;for(var o=t[n];o!==n;o=t[o]){if(s[o])return a.freeUint8(s),0;l+=1,s[o]=1}1&l||(r=-r)}return a.freeUint8(s),r}e.exports=n;var i=32,a=t("typedarray-pool")},{"typedarray-pool":282}],233:[function(t,e,r){"use strict";function n(t){var e=t.length;switch(e){case 0:case 1:return 0;case 2:return t[1]}var r,n,i,s=a.mallocUint32(e),l=a.mallocUint32(e),c=0;for(o(t,l),i=0;e>i;++i)s[i]=t[i];for(i=e-1;i>0;--i)n=l[i],r=s[i],s[i]=s[n],s[n]=r,l[i]=l[r],l[r]=n,c=(c+r)*i;return a.freeUint32(l),a.freeUint32(s),c}function i(t,e,r){switch(t){case 0:return r?r:[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}r=r||new Array(t);var n,i,a,o=1;for(r[0]=0,a=1;t>a;++a)r[a]=a,o=o*a|0;for(a=t-1;a>0;--a)n=e/o|0,e=e-n*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}var a=t("typedarray-pool"),o=t("invert-permutation");r.rank=n,r.unrank=i},{"invert-permutation":201,"typedarray-pool":282}],234:[function(t,e,r){"use strict";function n(t,e){function r(t,e){var r=c[e][t[e]];r.splice(r.indexOf(t),1)}function n(t,n,a){for(var o,s,l,u=0;2>u;++u)if(c[u][n].length>0){o=c[u][n][0],l=u;break}s=o[1^l];for(var f=0;2>f;++f)for(var h=c[f][n],d=0;d0&&(o=p,s=g,l=f)}return a?s:(o&&r(o,l),s)}function a(t,a){var o=c[a][t][0],s=[t];r(o,a);for(var l=o[1^a];;){for(;l!==t;)s.push(l),l=n(s[s.length-2],l,!1);if(c[0][t].length+c[1][t].length===0)break;var u=s[s.length-1],f=t,h=s[1],d=n(u,f,!0);if(i(e[u],e[f],e[h],e[d])<0)break;s.push(t),l=n(u,f)}return s}function o(t,e){return e[1]===e[e.length-1]}for(var s=0|e.length,l=t.length,c=[new Array(s),new Array(s)],u=0;s>u;++u)c[0][u]=[],c[1][u]=[];for(var u=0;l>u;++u){var f=t[u];c[0][f[0]].push(f),c[1][f[1]].push(f)}for(var h=[],u=0;s>u;++u)c[0][u].length+c[1][u].length===0&&h.push([u]);for(var u=0;s>u;++u)for(var d=0;2>d;++d){for(var p=[];c[d][u].length>0;){var g=(c[0][u].length,a(u,d));o(p,g)?p.push.apply(p,g):(p.length>0&&h.push(p),p=g)}p.length>0&&h.push(p)}return h}e.exports=n;var i=t("compare-angle")},{"compare-angle":74}],235:[function(t,e,r){"use strict";function n(t,e){for(var r=i(t,e.length),n=new Array(e.length),a=new Array(e.length),o=[],s=0;s=l&&o.push(s)}for(;o.length>0;){var c=o.pop();n[c]=!1;for(var u=r[c],s=0;sn;++n)r[n]=e;return r}function i(t){for(var e=new Array(t),r=0;t>r;++r)e[r]=[];return e}function a(t,e){function r(t){for(var r=t.length,n=[0],i=0;r>i;++i){var a=e[t[i]],o=e[t[(i+1)%r]],s=c(-a[0],a[1]),l=c(-a[0],o[1]),f=c(o[0],a[1]),h=c(o[0],o[1]);n=u(n,u(u(s,l),u(f,h)))}return n[n.length-1]>0}function a(t){for(var e=t.length,r=0;e>r;++r)if(!O[t[r]])return!1;return!0}var d=h(t,e);t=d[0],e=d[1];for(var p=e.length,g=(t.length,o(t,e.length)),v=0;p>v;++v)if(g[v].length%2===1)throw new Error("planar-graph-to-polyline: graph must be manifold");var m=s(t,e);m=m.filter(r);for(var y=m.length,b=new Array(y),x=new Array(y),v=0;y>v;++v){b[v]=v;var _=new Array(y),w=m[v].map(function(t){return e[t]}),k=l([w]),A=0;t:for(var M=0;y>M;++M)if(_[M]=0,v!==M){for(var T=m[M],E=T.length,L=0;E>L;++L){var S=k(e[T[L]]);if(0!==S){0>S&&(_[M]=1,A+=1);continue t}}_[M]=1,A+=1}x[v]=[A,v,_]}x.sort(function(t,e){return e[0]-t[0]});for(var v=0;y>v;++v)for(var _=x[v],C=_[1],z=_[2],M=0;y>M;++M)z[M]&&(b[M]=C);for(var P=i(y),v=0;y>v;++v)P[v].push(b[v]),P[b[v]].push(v);for(var R={},O=n(p,!1),v=0;y>v;++v)for(var T=m[v],E=T.length,M=0;E>M;++M){var I=T[M],N=T[(M+1)%E],j=Math.min(I,N)+":"+Math.max(I,N);if(j in R){var F=R[j];P[F].push(v),P[v].push(F),O[I]=O[N]=!0}else R[j]=v}for(var B=[],D=n(y,-1),v=0;y>v;++v)b[v]!==v||a(m[v])?D[v]=-1:(B.push(v),D[v]=0);for(var d=[];B.length>0;){var U=B.pop(),V=P[U];f(V,function(t,e){return t-e});var q,H=V.length,G=D[U];if(0===G){var T=m[U];q=[T]}for(var v=0;H>v;++v){var Y=V[v];if(!(D[Y]>=0)&&(D[Y]=1^G,B.push(Y),0===G)){var T=m[Y];a(T)||(T.reverse(),q.push(T))}}0===G&&d.push(q)}return d}e.exports=a;var o=t("edges-to-adjacency-list"),s=t("planar-dual"),l=t("point-in-big-polygon"),c=t("two-product"),u=t("robust-sum"),f=t("uniq"),h=t("./lib/trim-leaves")},{"./lib/trim-leaves":235,"edges-to-adjacency-list":91,"planar-dual":234,"point-in-big-polygon":237,"robust-sum":258,"two-product":280,uniq:284}],237:[function(t,e,r){function n(){return!0}function i(t){return function(e,r){var i=t[e];return i?!!i.queryPoint(r,n):!1}}function a(t){for(var e={},r=0;rn)return 1;var i=t[n];if(!i){if(!(n>0&&e[n]===r[0]))return 1;i=t[n-1]}for(var a=1;i;){var o=i.key,s=f(r,o[0],o[1]);if(o[0][0]s)i=i.left;else{if(!(s>0))return 0;a=-1,i=i.right}else if(s>0)i=i.left;else{if(!(0>s))return 0;a=1,i=i.right}}return a}}function s(t){return 1}function l(t){return function(e){return t(e[0],e[1])?0:1}}function c(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}function u(t){for(var e=t.length,r=[],n=[],i=0;e>i;++i)for(var u=t[i],f=u.length,d=f-1,p=0;f>p;d=p++){var g=u[d],v=u[p];g[0]===v[0]?n.push([g,v]):r.push([g,v])}if(0===r.length)return 0===n.length?s:l(a(n));var m=h(r),y=o(m.slabs,m.coordinates);return 0===n.length?y:c(a(n),y)}e.exports=u;var f=t("robust-orientation")[3],h=t("slab-decomposition"),d=t("interval-tree-1d"),p=t("binary-search-bounds")},{"binary-search-bounds":47,"interval-tree-1d":200,"robust-orientation":253,"slab-decomposition":269}],238:[function(t,e,r){"use strict";function n(t,e,r,n,s){i.length=x+_)if(0>x)0>_&&0>h?(_=0,-h>=c?(x=1,y=c+2*h+p):(x=-h/c,y=h*x+p)):(x=0,d>=0?(_=0,y=p):-d>=f?(_=1,y=f+2*d+p):(_=-d/f,y=d*_+p));else if(0>_)_=0,h>=0?(x=0,y=p):-h>=c?(x=1,y=c+2*h+p):(x=-h/c,y=h*x+p);else{var w=1/b;x*=w,_*=w,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p}else{var k,A,M,T;0>x?(k=u+h,A=f+d,A>k?(M=A-k,T=c-2*u+f,M>=T?(x=1,_=0,y=c+2*h+p):(x=M/T,_=1-x,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)):(x=0,0>=A?(_=1,y=f+2*d+p):d>=0?(_=0,y=p):(_=-d/f,y=d*_+p))):0>_?(k=u+d,A=c+h,A>k?(M=A-k,T=c-2*u+f,M>=T?(_=1,x=0,y=f+2*d+p):(_=M/T,x=1-_,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)):(_=0,0>=A?(x=1,y=c+2*h+p):h>=0?(x=0,y=p):(x=-h/c,y=h*x+p))):(M=f+d-u-h,0>=M?(x=0,_=1,y=f+2*d+p):(T=c-2*u+f,M>=T?(x=1,_=0,y=c+2*h+p):(x=M/T,_=1-x,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)))}for(var E=1-x-_,l=0;ly?0:y}var i=new Float64Array(4),a=new Float64Array(4),o=new Float64Array(4);e.exports=n},{}],239:[function(t,e,r){function n(){u&&s&&(u=!1,s.length?c=s.concat(c):f=-1,c.length&&i())}function i(){if(!u){var t=setTimeout(n);u=!0;for(var e=c.length;e;){for(s=c,c=[];++f1)for(var r=1;ra;++a)n[a]=i(t[a],e[a]);return n}var i=t("big-rat/add");e.exports=n},{"big-rat/add":31}],242:[function(t,e,r){"use strict";function n(t){for(var e=new Array(t.length),r=0;rs;++s)o[s]=a(t[s],r);return o}var i=t("big-rat"),a=t("big-rat/mul");e.exports=n},{"big-rat":34,"big-rat/mul":43}],244:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),a=0;r>a;++a)n[a]=i(t[a],e[a]);return n}var i=t("big-rat/sub");e.exports=n},{"big-rat/sub":45}],245:[function(t,e,r){"use strict";function n(t){t.sort(a);for(var e=t.length,r=0,n=0;e>n;++n){var s=t[n],l=o(s);if(0!==l){if(r>0){var c=t[r-1];if(0===i(s,c)&&o(c)!==l){r-=1;continue}}t[r++]=s}}return t.length=r,t}var i=t("compare-cell"),a=t("compare-oriented-cell"),o=t("cell-orientation");e.exports=n},{"cell-orientation":66,"compare-cell":75,"compare-oriented-cell":76}],246:[function(t,e,r){"use strict";function n(t,e){if("string"!=typeof t)throw new TypeError("repeat-string expects a string.");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;for(i===t&&"undefined"!=typeof i||(i=t,a="");r>a.length&&e>0&&(1&e&&(a+=t),e>>=1);)t+=t;return a.substr(0,r)}var i,a="";e.exports=n},{}],247:[function(t,e,r){(function(t){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],248:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i];r=a+o;var s=r-a,l=o-s;l&&(t[--n]=r,r=l)}for(var c=0,i=n;e>i;++i){var a=t[i],o=r;r=a+o;var s=r-a,l=o-s;l&&(t[c++]=l)}return t[c++]=r,t.length=c,t}e.exports=n},{}],249:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m[",r,"][",n,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("");for(var e=[],r=0;rn;++n)t.push("det"+n),r.push("case ",n,":return det",n,"(m);");r.push("}var det=CACHE[m.length];if(!det)det=CACHE[m.length]=gen(m.length);return det(m);}return robustDeterminant"),t.push("CACHE","gen",r.join(""));var i=Function.apply(void 0,t);e.exports=i.apply(void 0,g.concat([g,l]));for(var n=0;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-2,"]"].join("")}return e}function a(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",a(t.slice(0,e)),",",a(t.slice(e)),")"].join("")}function o(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return o(e,t)}function s(t){return t&!0?"-":""}function l(t){if(2===t.length)return[["diff(",o(t[0][0],t[1][1]),",",o(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;rn;++n)r.push(["prod(m",t,"[",n,"],m",t,"[",n,"])"].join(""));return a(r)}function u(t){for(var e=[],r=[],o=i(t),s=0;t>s;++s)o[0][s]="1",o[t-1][s]="w"+s;for(var s=0;t>s;++s)0===(1&s)?e.push.apply(e,l(n(o,s))):r.push.apply(r,l(n(o,s)));for(var u=a(e),f=a(r),h="exactInSphere"+t,d=[],s=0;t>s;++s)d.push("m"+s);for(var p=["function ",h,"(",d.join(),"){"],s=0;t>s;++s){p.push("var w",s,"=",c(s,t),";");for(var g=0;t>g;++g)g!==s&&p.push("var w",s,"m",g,"=scale(w",s,",m",g,"[0]);")}p.push("var p=",u,",n=",f,",d=diff(p,n);return d[d.length-1];}return ",h);var x=new Function("sum","diff","prod","scale",p.join(""));return x(m,y,v,b)}function f(){return 0}function h(){return 0}function d(){return 0}function p(t){var e=_[t.length];return e||(e=_[t.length]=u(t.length)),e.apply(void 0,t)}function g(){for(;_.length<=x;)_.push(u(_.length));for(var t=[],r=["slow"],n=0;x>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function testInSphere(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;x>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var v=t("two-product"),m=t("robust-sum"),y=t("robust-subtract"),b=t("robust-scale"),x=6,_=[f,h,d];g()},{"robust-scale":255,"robust-subtract":257,"robust-sum":258,"two-product":280}],252:[function(t,e,r){"use strict";function n(t){for(var e="robustLinearSolve"+t+"d",r=["function ",e,"(A,b){return ["],n=0;t>n;++n){r.push("det([");for(var i=0;t>i;++i){i>0&&r.push(","),r.push("[");for(var a=0;t>a;++a)a>0&&r.push(","),a===n?r.push("+b[",i,"]"):r.push("+A[",i,"][",a,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var o=new Function("det",r.join(""));return o(6>t?s[t]:s)}function i(){return[0]}function a(t,e){return[[e[0]],[t[0][0]]]}function o(){for(;c.lengthi;++i)t.push("s"+i),r.push("case ",i,":return s",i,"(A,b);");r.push("}var s=CACHE[A.length];if(!s)s=CACHE[A.length]=g(A.length);return s(A,b)}return dispatchLinearSolve"),t.push("CACHE","g",r.join(""));var a=Function.apply(void 0,t);e.exports=a.apply(void 0,c.concat([c,n]));for(var i=0;l>i;++i)e.exports[i]=c[i]}var s=t("robust-determinant"),l=6,c=[i,a];o()},{"robust-determinant":249}],253:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-1,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join(""); +}function s(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;rc;++c)0===(1&c)?e.push.apply(e,s(n(a,c))):r.push.apply(r,s(n(a,c))),l.push("m"+c);var u=o(e),g=o(r),v="orientation"+t+"Exact",m=["function ",v,"(",l.join(),"){var p=",u,",n=",g,",d=sub(p,n);return d[d.length-1];};return ",v].join(""),y=new Function("sum","prod","scale","sub",m);return y(h,f,d,p)}function c(t){var e=_[t.length];return e||(e=_[t.length]=l(t.length)),e.apply(void 0,t)}function u(){for(;_.length<=g;)_.push(l(_.length));for(var t=[],r=["slow"],n=0;g>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;g>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var f=t("two-product"),h=t("robust-sum"),d=t("robust-scale"),p=t("robust-subtract"),g=5,v=1.1102230246251565e-16,m=(3+16*v)*v,y=(7+56*v)*v,b=l(3),x=l(4),_=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,r){var n,i=(t[1]-r[1])*(e[0]-r[0]),a=(t[0]-r[0])*(e[1]-r[1]),o=i-a;if(i>0){if(0>=a)return o;n=i+a}else{if(!(0>i))return o;if(a>=0)return o;n=-(i+a)}var s=m*n;return o>=s||-s>=o?o:b(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],d=a*c,p=o*l,g=o*s,v=i*c,m=i*l,b=a*s,_=u*(d-p)+f*(g-v)+h*(m-b),w=(Math.abs(d)+Math.abs(p))*Math.abs(u)+(Math.abs(g)+Math.abs(v))*Math.abs(f)+(Math.abs(m)+Math.abs(b))*Math.abs(h),k=y*w;return _>k||-_>k?_:x(t,e,r,n)}];u()},{"robust-scale":255,"robust-subtract":257,"robust-sum":258,"two-product":280}],254:[function(t,e,r){"use strict";function n(t,e){if(1===t.length)return a(e,t[0]);if(1===e.length)return a(t,e[0]);if(0===t.length||0===e.length)return[0];var r=[0];if(t.lengthu;++u){i(t[u],e,l);var f=s[1];a(f,l[0],s),s[0]&&(o[c++]=s[0]);var h=l[1],d=s[1],p=h+d,g=p-h,v=d-g;s[1]=p,v&&(o[c++]=v)}return s[1]&&(o[c++]=s[1]),0===c&&(o[c++]=0),o.length=c,o}var i=t("two-product"),a=t("two-sum");e.exports=n},{"two-product":280,"two-sum":281}],256:[function(t,e,r){"use strict";function n(t,e,r,n){for(var i=0;2>i;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),c=r[i],u=n[i],f=Math.min(c,u),h=Math.max(c,u);if(s>h||f>l)return!1}return!0}function i(t,e,r,i){var o=a(t,r,i),s=a(e,r,i);if(o>0&&s>0||0>o&&0>s)return!1;var l=a(r,t,e),c=a(i,t,e);return l>0&&c>0||0>l&&0>c?!1:0===o&&0===s&&0===l&&0===c?n(t,e,r,i):!0}e.exports=i;var a=t("robust-orientation")[3]},{"robust-orientation":253}],257:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],-e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=-e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=-e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=-e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],258:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],259:[function(t,e,r){"use strict";e.exports=function(t){return 0>t?-1:t>0?1:0}},{}],260:[function(t,e,r){"use strict";function n(t){return a(i(t))}e.exports=n;var i=t("boundary-cells"),a=t("reduce-simplicial-complex")},{"boundary-cells":50,"reduce-simplicial-complex":245}],261:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=0,n=0;e>n;++n)r=0|Math.max(r,t[n].length);return r-1}function i(t,e){for(var r=t.length,n=f.mallocUint8(r),i=0;r>i;++i)n[i]=t[i]o;++o)for(var s=t[o],e=s.length,l=0;e>l;++l)for(var c=0;l>c;++c){var d=s[c],p=s[l];i[a++]=0|Math.min(d,p),i[a++]=0|Math.max(d,p)}var g=a/2|0;h(u(i,[g,2]));for(var v=2,o=2;a>o;o+=2)i[o-2]===i[o]&&i[o-1]===i[o+1]||(i[v++]=i[o],i[v++]=i[o+1]);return u(i,[v/2|0,2])}function o(t,e,r,n){for(var i=t.data,a=t.shape[0],o=f.mallocDouble(a),s=0,l=0;a>l;++l){var c=i[2*l],h=i[2*l+1];if(r[c]!==r[h]){var d=e[c],p=e[h];i[2*s]=c,i[2*s+1]=h,o[s++]=(p-n)/(p-d)}}return t.shape[0]=s,u(o,[s])}function s(t,e){var r=f.mallocInt32(2*e),n=t.shape[0],i=t.data;r[0]=0;for(var a=0,o=0;n>o;++o){var s=i[2*o];if(s!==a){for(r[2*a+1]=o;++ai;++i)n[i]=[r[2*i],r[2*i+1]];return n}function c(t,e,r,c){r=r||0,"undefined"==typeof c&&(c=n(t));var u=t.length;if(0===u||1>c)return{cells:[],vertexIds:[],vertexWeights:[]};var h=i(e,+r),p=a(t,c),g=o(p,e,h,+r),v=s(p,0|e.length),m=d(c)(t,p.data,v,h),y=l(p),b=[].slice.call(g.data,0,g.shape[0]);return f.free(h),f.free(p.data),f.free(g.data),f.free(v),{cells:m,vertexIds:y,vertexWeights:b}}e.exports=c;var u=t("ndarray"),f=t("typedarray-pool"),h=t("ndarray-sort"),d=t("./lib/codegen")},{"./lib/codegen":262,ndarray:225,"ndarray-sort":223,"typedarray-pool":282}],262:[function(t,e,r){"use strict";function n(t){function e(t){if(!(t.length<=0)){c.push("R.push(");for(var e=0;e0&&c.push(","),c.push("[");for(var n=0;n0&&c.push(","),c.push("B(C,E,c[",i[0],"],c[",i[1],"])")}c.push("]")}c.push(");")}}var r=0,n=new Array(t+1);n[0]=[[]];for(var i=1;t>=i;++i)for(var s=n[i]=o(i),l=0;l>1,v=E[2*m+1];","if(v===b){return m}","if(b1;--i){t+1>i&&c.push("else "),c.push("if(l===",i,"){");for(var u=[],l=0;i>l;++l)u.push("(S[c["+l+"]]<<"+l+")");c.push("var M=",u.join("+"),";if(M===0||M===",(1<n;++n)e=r(e,t[n].length);return e-1}function i(t){for(var e=-1,r=Math.max,n=0,i=t.length;i>n;++n)for(var a=t[n],o=0,s=a.length;s>o;++o)e=r(e,a[o]);return e+1}function a(t){for(var e=new Array(t.length),r=0,n=t.length;n>r;++r)e[r]=t[r].slice(0);return e}function o(t,e){var r=t.length,n=t.length-e.length,i=Math.min;if(n)return n;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:var a=t[0]+t[1]-e[0]-e[1];return a?a:i(t[0],t[1])-i(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(a=o+t[2]-(s+e[2]))return a;var l=i(t[0],t[1]),c=i(e[0],e[1]),a=i(l,t[2])-i(c,e[2]);return a?a:i(l+t[2],o)-i(c+e[2],s);default:var u=t.slice(0);u.sort();var f=e.slice(0);f.sort();for(var h=0;r>h;++h)if(n=u[h]-f[h])return n;return 0}}function s(t,e){return o(t[0],e[0])}function l(t,e){if(e){for(var r=t.length,n=new Array(r),i=0;r>i;++i)n[i]=[t[i],e[i]];n.sort(s);for(var i=0;r>i;++i)t[i]=n[i][0],e[i]=n[i][1];return t}return t.sort(o),t}function c(t){if(0===t.length)return[];for(var e=1,r=t.length,n=1;r>n;++n){var i=t[n];if(o(i,t[n-1])){if(n===e){e++;continue}t[e++]=i}}return t.length=e,t}function u(t,e){for(var r=0,n=t.length-1,i=-1;n>=r;){var a=r+n>>1,s=o(t[a],e);0>=s?(0===s&&(i=a),r=a+1):s>0&&(n=a-1)}return i}function f(t,e){for(var r=new Array(t.length),n=0,i=r.length;i>n;++n)r[n]=[];for(var a=[],n=0,s=e.length;s>n;++n)for(var l=e[n],c=l.length,f=1,h=1<f;++f){a.length=b.popCount(f);for(var d=0,p=0;c>p;++p)f&1<g))for(;;)if(r[g++].push(n),g>=t.length||0!==o(t[g],a))break}return r}function h(t,e){if(!e)return f(c(p(t,0)),t,0);for(var r=new Array(e),n=0;e>n;++n)r[n]=[];for(var n=0,i=t.length;i>n;++n)for(var a=t[n],o=0,s=a.length;s>o;++o)r[a[o]].push(n);return r}function d(t){for(var e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0|i.length,o=1,s=1<o;++o){for(var c=[],u=0;a>u;++u)o>>>u&1&&c.push(i[u]);e.push(c)}return l(e)}function p(t,e){if(0>e)return[];for(var r=[],n=(1<r;++r)for(var i=t[r],a=0,o=i.length;o>a;++a){for(var s=new Array(i.length-1),c=0,u=0;o>c;++c)c!==a&&(s[u++]=i[c]);e.push(s)}return l(e)}function v(t,e){for(var r=new x(e),n=0;ne;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n,n.prototype.length=function(){return this.roots.length},n.prototype.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},n.prototype.find=function(t){for(var e=this.roots;e[t]!==t;){var r=e[t];e[t]=e[r],t=r}return t},n.prototype.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],267:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.abs(a(t,e,r)),i=Math.sqrt(Math.pow(e[0]-r[0],2)+Math.pow(e[1]-r[1],2));return n/i}function i(t,e,r){function i(t){if(x[t])return 1/0;var r=m[t],i=y[t];return 0>r||0>i?1/0:n(e[t],e[r],e[i])}function a(t,e){var r=M[t],n=M[e];M[t]=n,M[e]=r,T[r]=e,T[n]=t}function s(t){return b[M[t]]}function l(t){return 1&t?t-1>>1:(t>>1)-1}function c(t){for(var e=s(t);;){var r=e,n=2*t+1,i=2*(t+1),o=t;if(L>n){var l=s(n);r>l&&(o=n,r=l)}if(L>i){var c=s(i);r>c&&(o=i)}if(o===t)return t;a(t,o),t=o}}function u(t){for(var e=s(t);t>0;){var r=l(t);if(r>=0){var n=s(r);if(n>e){a(t,r),t=r;continue}}return t}}function f(){if(L>0){var t=M[0];return a(0,L-1),L-=1,c(0),t}return-1}function h(t,e){var r=M[t];return b[r]===e?t:(b[r]=-(1/0),u(t),f(),b[r]=e,L+=1,u(L-1))}function d(t){if(!x[t]){x[t]=!0;var e=m[t],r=y[t];m[r]>=0&&(m[r]=e),y[e]>=0&&(y[e]=r),T[e]>=0&&h(T[e],i(e)),T[r]>=0&&h(T[r],i(r))}}function p(t,e){if(t[e]<0)return e;var r=e,n=e;do{var i=t[n];if(!x[n]||0>i||i===n)break;if(n=i,i=t[n],!x[n]||0>i||i===n)break;n=i,r=t[r]}while(r!==n);for(var a=e;a!==n;a=t[a])t[a]=n;return n}for(var g=e.length,v=t.length,m=new Array(g),y=new Array(g),b=new Array(g),x=new Array(g),_=0;g>_;++_)m[_]=y[_]=-1,b[_]=1/0,x[_]=!1;for(var _=0;v>_;++_){var w=t[_];if(2!==w.length)throw new Error("Input must be a graph");var k=w[1],A=w[0];-1!==y[A]?y[A]=-2:y[A]=k,-1!==m[k]?m[k]=-2:m[k]=A}for(var M=[],T=new Array(g),_=0;g>_;++_){var E=b[_]=i(_);1/0>E?(T[_]=M.length,M.push(_)):T[_]=-1}for(var L=M.length,_=L>>1;_>=0;--_)c(_);for(;;){var S=f();if(0>S||b[S]>r)break;d(S)}for(var C=[],_=0;g>_;++_)x[_]||(T[_]=C.length,C.push(e[_].slice()));var z=(C.length,[]);return t.forEach(function(t){var e=p(m,t[0]),r=p(y,t[1]);if(e>=0&&r>=0&&e!==r){var n=T[e],i=T[r];n!==i&&z.push([n,i])}}),o.unique(o.normalize(z)),{positions:C,edges:z}}e.exports=i;var a=t("robust-orientation"),o=t("simplicial-complex")},{"robust-orientation":253,"simplicial-complex":265}],268:[function(t,e,r){"use strict";function n(t,e){var r,n;if(e[0][0]e[1][0])){var i=Math.min(t[0][1],t[1][1]),o=Math.max(t[0][1],t[1][1]),s=Math.min(e[0][1],e[1][1]),l=Math.max(e[0][1],e[1][1]);return s>o?o-s:i>l?i-l:o-l}r=e[1],n=e[0]}var c,u;t[0][1]e[1][0]))return n(e,t);r=e[1],i=e[0]}var o,s;if(t[0][0]t[1][0]))return-n(t,e);o=t[1],s=t[0]}var l=a(r,i,s),c=a(r,i,o);if(0>l){if(0>=c)return l}else if(l>0){if(c>=0)return l}else if(c)return c;if(l=a(s,o,i),c=a(s,o,r),0>l){if(0>=c)return l}else if(l>0){if(c>=0)return l}else if(c)return c;return i[0]-s[0]}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":253}],269:[function(t,e,r){"use strict";function n(t,e,r){this.slabs=t,this.coordinates=e,this.horizontal=r}function i(t,e){return t.y-e}function a(t,e){for(var r=null;t;){var n,i,o=t.key;o[0][0]s)t=t.left;else if(s>0)if(e[0]!==o[1][0])r=t,t=t.right;else{var l=a(t.right,e);if(l)return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l=a(t.right,e);if(l)return l;t=t.left}}return r}function o(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function s(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}function l(t){for(var e=t.length,r=2*e,i=new Array(r),a=0;e>a;++a){var l=t[a],c=l[0][0]a;){for(var v=i[a].x,m=[];r>a;){var y=i[a];if(y.x!==v)break;a+=1,y.segment[0][0]===y.x&&y.segment[1][0]===y.x?y.create&&(y.segment[0][1]e)return-1;var r=(this.slabs[e],a(this.slabs[e],t)),n=-1;if(r&&(n=r.value),this.coordinates[e]===t[0]){var o=null;if(r&&(o=r.key),e>0){var s=a(this.slabs[e-1],t);s&&(o?h(s.key,o)>0&&(o=s.key,n=s.value):(n=s.value,o=s.key))}var l=this.horizontal[e];if(l.length>0){var u=c.ge(l,t[1],i);if(u=l.length)return n;d=l[u]}}if(d.start)if(o){var p=f(o[0],o[1],[t[0],d.y]);o[0][0]>o[1][0]&&(p=-p),p>0&&(n=d.index)}else n=d.index;else d.y!==t[1]&&(n=d.index)}}}return n}},{"./lib/order-segments":268,"binary-search-bounds":47,"functional-red-black-tree":97,"robust-orientation":253}],270:[function(t,e,r){"use strict";function n(t,e){var r=c(l(t,e),[e[e.length-1]]);return r[r.length-1]}function i(t,e,r,n){var i=n-e,a=-e/i;0>a?a=0:a>1&&(a=1);for(var o=1-a,s=t.length,l=new Array(s),c=0;s>c;++c)l[c]=a*t[c]+o*r[c];return l}function a(t,e){for(var r=[],a=[],o=n(t[t.length-1],e),s=t[t.length-1],l=t[0],c=0;co&&u>0||o>0&&0>u){var f=i(s,u,l,o);r.push(f),a.push(f.slice())}0>u?a.push(l.slice()):u>0?r.push(l.slice()):(r.push(l.slice()),a.push(l.slice())),o=u}return{positive:r,negative:a}}function o(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;la&&c>0||a>0&&0>c)&&r.push(i(o,c,s,a)),c>=0&&r.push(s.slice()),a=c}return r}function s(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;la&&c>0||a>0&&0>c)&&r.push(i(o,c,s,a)),0>=c&&r.push(s.slice()),a=c}return r}var l=t("robust-dot-product"),c=t("robust-sum");e.exports=a,e.exports.positive=o,e.exports.negative=s},{"robust-dot-product":250,"robust-sum":258}],271:[function(e,r,n){!function(e){function r(){var t=arguments[0],e=r.cache;return e[t]&&e.hasOwnProperty(t)||(e[t]=r.parse(t)),r.format.call(null,e[t],arguments)}function i(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}function a(t,e){return Array(e+1).join(t)}var o={not_string:/[^s]/,number:/[diefg]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijosuxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};r.format=function(t,e){var n,s,l,c,u,f,h,d=1,p=t.length,g="",v=[],m=!0,y="";for(s=0;p>s;s++)if(g=i(t[s]),"string"===g)v[v.length]=t[s];else if("array"===g){if(c=t[s],c[2])for(n=e[d],l=0;l=0),c[8]){case"b":n=n.toString(2);break;case"c":n=String.fromCharCode(n);break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,c[6]?parseInt(c[6]):0);break;case"e":n=c[7]?n.toExponential(c[7]):n.toExponential();break;case"f":n=c[7]?parseFloat(n).toFixed(c[7]):parseFloat(n);break;case"g":n=c[7]?parseFloat(n).toPrecision(c[7]):parseFloat(n);break;case"o":n=n.toString(8);break;case"s":n=(n=String(n))&&c[7]?n.substring(0,c[7]):n;break;case"u":n>>>=0;break;case"x":n=n.toString(16);break;case"X":n=n.toString(16).toUpperCase()}o.json.test(c[8])?v[v.length]=n:(!o.number.test(c[8])||m&&!c[3]?y="":(y=m?"+":"-",n=n.toString().replace(o.sign,"")),f=c[4]?"0"===c[4]?"0":c[4].charAt(1):" ",h=c[6]-(y+n).length,u=c[6]&&h>0?a(f,h):"",v[v.length]=c[5]?y+n+u:"0"===f?y+u+n:u+y+n)}return v.join("")},r.cache={},r.parse=function(t){for(var e=t,r=[],n=[],i=0;e;){if(null!==(r=o.text.exec(e)))n[n.length]=r[0];else if(null!==(r=o.modulo.exec(e)))n[n.length]="%";else{if(null===(r=o.placeholder.exec(e)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){i|=1;var a=[],s=r[2],l=[];if(null===(l=o.key.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(a[a.length]=l[1];""!==(s=s.substring(l[0].length));)if(null!==(l=o.key_access.exec(s)))a[a.length]=l[1];else{if(null===(l=o.index_access.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");a[a.length]=l[1]}r[2]=a}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=r}e=e.substring(r[0].length)}return n};var s=function(t,e,n){return n=(e||[]).slice(0),n.splice(0,0,t),r.apply(null,n)};"undefined"!=typeof n?(n.sprintf=r,n.vsprintf=s):(e.sprintf=r,e.vsprintf=s,"function"==typeof t&&t.amd&&t(function(){return{sprintf:r,vsprintf:s}}))}("undefined"==typeof window?this:window)},{}],272:[function(t,e,r){"use strict";function n(t){return t.split("").map(function(t){return t in i?i[t]:""}).join("")}e.exports=n;var i={" ":" ",0:"\u2070",1:"\xb9",2:"\xb2",3:"\xb3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079","+":"\u207a","-":"\u207b",a:"\u1d43",b:"\u1d47",c:"\u1d9c",d:"\u1d48",e:"\u1d49",f:"\u1da0",g:"\u1d4d",h:"\u02b0",i:"\u2071",j:"\u02b2",k:"\u1d4f",l:"\u02e1",m:"\u1d50",n:"\u207f",o:"\u1d52",p:"\u1d56",r:"\u02b3",s:"\u02e2",t:"\u1d57",u:"\u1d58",v:"\u1d5b",w:"\u02b7",x:"\u02e3",y:"\u02b8",z:"\u1dbb"}},{}],273:[function(t,e,r){"use strict";function n(t,e){var r=t.length,n=["'use strict';"],i="surfaceNets"+t.join("_")+"d"+e;n.push("var contour=genContour({","order:[",t.join(),"],","scalarArguments: 3,","phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },"),"generic"===e&&n.push("getters:[0],");for(var a=[],l=[],c=0;r>c;++c)a.push("d"+c),l.push("d"+c);for(var c=0;1<c;++c)a.push("v"+c),l.push("v"+c);for(var c=0;1<c;++c)a.push("p"+c),l.push("p"+c);a.push("a","b","c"),l.push("a","c"),n.push("vertex:function vertexFunc(",a.join(),"){");for(var u=[],c=0;1<c;++c)u.push("(p"+c+"<<"+c+")");n.push("var m=(",u.join("+"),")|0;if(m===0||m===",(1<<(1<=1<<(1<>>7){");for(var c=0;1<<(1<c;++c){if(1<<(1<128&&c%128===0){f.length>0&&h.push("}}");var d="vExtra"+f.length;n.push("case ",c>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&c,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;r>b;++b)p[b]=[],g[b]=[],v[b]=0,m[b]=0;for(var b=0;1<b;++b)for(var x=0;r>x;++x){var _=b^1<b)&&!(c&1<<_)!=!(c&1<w?(p[x].push("-v"+b+"-v"+_),v[x]+=2):(p[x].push("v"+b+"+v"+_),v[x]-=2),y+=1;for(var k=0;r>k;++k)k!==x&&(_&1<x;++x)if(0===p[x].length)A.push("d"+x+"-0.5");else{var M="";v[x]<0?M=v[x]+"*c":v[x]>0&&(M="+"+v[x]+"*c");var T=.5*(p[x].length/y),E=.5+.5*(m[x]/y);A.push("d"+x+"-"+E+"-"+T+"*("+p[x].join("+")+M+")/("+g[x].join("+")+")")}h.push("a.push([",A.join(),"]);","break;")}n.push("}},"),f.length>0&&h.push("}}");for(var L=[],c=0;1<c;++c)L.push("v"+c);L.push("c0","c1","p0","p1","a","b","c"),n.push("cell:function cellFunc(",L.join(),"){");var S=s(r-1);n.push("if(p0){b.push(",S.map(function(t){return"["+t.map(function(t){return"v"+t})+"]"}).join(),")}else{b.push(",S.map(function(t){var e=t.slice();return e.reverse(),"["+e.map(function(t){return"v"+t})+"]"}).join(),")}}});function ",i,"(array,level){var verts=[],cells=[];contour(array,verts,cells,level);return {positions:verts,cells:cells};} return ",i,";");for(var c=0;co;++o)i[o]=[r[o]],a[o]=[o];return{positions:i,cells:a}}function a(t,e){if(t.dimension<=0)return{positions:[],cells:[]};if(1===t.dimension)return i(t,e);var r=t.order.join()+"-"+t.dtype,a=c[r],e=+e||0;return a||(a=c[r]=n(t.order,t.dtype)),a(t,e)}e.exports=a;var o=t("ndarray-extract-contour"),s=t("triangulate-hypercube"),l=t("zero-crossings"),c={}},{"ndarray-extract-contour":214,"triangulate-hypercube":278,"zero-crossings":292}],274:[function(t,e,r){(function(r){"use strict";function n(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;ol;++l){var c=r[s[l]];n[i++]=c[0],n[i++]=c[1]+1.4,a=Math.max(c[0],a)}return{data:n,shape:a}}function i(t,e){var r=s[t];r||(r=s[t]={" ":{data:new Float32Array(0),shape:.2}});var o=r[e];if(!o)if(e.length<=1||!/\d/.test(e))o=r[e]=n(a(e,{triangles:!0,font:t,textAlign:"left",textBaseline:"alphabetic"}));else{for(var l=e.split(/(\d|\s)/),c=new Array(l.length),u=0,f=0,h=0;h0&&(f+=.02);for(var d=new Float32Array(u),p=0,g=-.5*f,h=0;h.5?l/(2-a-o):l/(a+o),a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,l:s}}function o(t,e,r){function n(t,e,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?t+6*(e-t)*r:.5>r?e:2/3>r?t+(e-t)*(2/3-r)*6:t}var i,a,o;if(t=T(t,360),e=T(e,100),r=T(r,100),0===e)i=a=o=r;else{var s=.5>r?r*(1+e):r+e-r*e,l=2*r-s;i=n(l,s,t+1/3),a=n(l,s,t),o=n(l,s,t-1/3)}return{r:255*i,g:255*a,b:255*o}}function s(t,e,r){t=T(t,255),e=T(e,255),r=T(r,255);var n,i,a=q(t,e,r),o=V(t,e,r),s=a,l=a-o;if(i=0===a?0:l/a,a==o)n=0;else{switch(a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,v:s}}function l(t,e,r){t=6*T(t,360),e=T(e,100),r=T(r,100);var n=D.floor(t),i=t-n,a=r*(1-e),o=r*(1-i*e),s=r*(1-(1-i)*e),l=n%6,c=[r,o,a,a,s,r][l],u=[s,r,r,o,a,a][l],f=[a,a,s,r,r,o][l];return{r:255*c,g:255*u,b:255*f}}function c(t,e,r,n){var i=[z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function u(t,e,r,n){var i=[z(R(n)),z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return i.join("")}function f(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s-=r/100,n.s=E(n.s),e(n)}function h(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s+=r/100,n.s=E(n.s),e(n)}function d(t){return e(t).desaturate(100)}function p(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l+=r/100,n.l=E(n.l),e(n)}function g(t,r){r=0===r?0:r||10;var n=e(t).toRgb();return n.r=q(0,V(255,n.r-U(255*-(r/100)))),n.g=q(0,V(255,n.g-U(255*-(r/100)))),n.b=q(0,V(255,n.b-U(255*-(r/100)))),e(n)}function v(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l-=r/100,n.l=E(n.l),e(n)}function m(t,r){var n=e(t).toHsl(),i=(U(n.h)+r)%360;return n.h=0>i?360+i:i,e(n)}function y(t){var r=e(t).toHsl();return r.h=(r.h+180)%360,e(r)}function b(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+120)%360,s:r.s,l:r.l}),e({h:(n+240)%360,s:r.s,l:r.l})]}function x(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+90)%360,s:r.s,l:r.l}),e({h:(n+180)%360,s:r.s,l:r.l}),e({h:(n+270)%360,s:r.s,l:r.l})]}function _(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+72)%360,s:r.s,l:r.l}),e({h:(n+216)%360,s:r.s,l:r.l})]}function w(t,r,n){r=r||6,n=n||30;var i=e(t).toHsl(),a=360/n,o=[e(t)];for(i.h=(i.h-(a*r>>1)+720)%360;--r;)i.h=(i.h+a)%360,o.push(e(i));return o}function k(t,r){r=r||6;for(var n=e(t).toHsv(),i=n.h,a=n.s,o=n.v,s=[],l=1/r;r--;)s.push(e({h:i,s:a,v:o})),o=(o+l)%1;return s}function A(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}function M(t){return t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=1),t}function T(t,e){S(t)&&(t="100%");var r=C(t);return t=V(e,q(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),D.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function E(t){return V(1,q(0,t))}function L(t){return parseInt(t,16)}function S(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function C(t){return"string"==typeof t&&-1!=t.indexOf("%")}function z(t){return 1==t.length?"0"+t:""+t}function P(t){return 1>=t&&(t=100*t+"%"),t}function R(t){return Math.round(255*parseFloat(t)).toString(16)}function O(t){return L(t)/255}function I(t){t=t.replace(j,"").replace(F,"").toLowerCase();var e=!1;if(G[t])t=G[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=X.rgb.exec(t))?{r:r[1],g:r[2],b:r[3]}:(r=X.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=X.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=X.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=X.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=X.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=X.hex8.exec(t))?{a:O(r[1]),r:L(r[2]),g:L(r[3]),b:L(r[4]),format:e?"name":"hex8"}:(r=X.hex6.exec(t))?{r:L(r[1]),g:L(r[2]),b:L(r[3]),format:e?"name":"hex"}:(r=X.hex3.exec(t))?{r:L(r[1]+""+r[1]),g:L(r[2]+""+r[2]),b:L(r[3]+""+r[3]),format:e?"name":"hex"}:!1}function N(t){var e,r;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==r&&"large"!==r&&(r="small"),{level:e,size:r}}var j=/^\s+/,F=/\s+$/,B=0,D=Math,U=D.round,V=D.min,q=D.max,H=D.random;e.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3; +},getLuminance:function(){var t,e,r,n,i,a,o=this.toRgb();return t=o.r/255,e=o.g/255,r=o.b/255,n=.03928>=t?t/12.92:Math.pow((t+.055)/1.055,2.4),i=.03928>=e?e/12.92:Math.pow((e+.055)/1.055,2.4),a=.03928>=r?r/12.92:Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*i+.0722*a},setAlpha:function(t){return this._a=M(t),this._roundA=U(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=a(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=a(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return u(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:U(this._r),g:U(this._g),b:U(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+U(this._r)+", "+U(this._g)+", "+U(this._b)+")":"rgba("+U(this._r)+", "+U(this._g)+", "+U(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:U(100*T(this._r,255))+"%",g:U(100*T(this._g,255))+"%",b:U(100*T(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%)":"rgba("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:Y[c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+u(this._r,this._g,this._b,this._a),n=r,i=this._gradientType?"GradientType = 1, ":"";if(t){var a=e(t);n=a.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+r+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0,i=!e&&n&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return i?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return e(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(p,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(v,arguments)},desaturate:function(){return this._applyModification(f,arguments)},saturate:function(){return this._applyModification(h,arguments)},greyscale:function(){return this._applyModification(d,arguments)},spin:function(){return this._applyModification(m,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(w,arguments)},complement:function(){return this._applyCombination(y,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(_,arguments)},triad:function(){return this._applyCombination(b,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},e.fromRatio=function(t,r){if("object"==typeof t){var n={};for(var i in t)t.hasOwnProperty(i)&&("a"===i?n[i]=t[i]:n[i]=P(t[i]));t=n}return e(t,r)},e.equals=function(t,r){return t&&r?e(t).toRgbString()==e(r).toRgbString():!1},e.random=function(){return e.fromRatio({r:H(),g:H(),b:H()})},e.mix=function(t,r,n){n=0===n?0:n||50;var i,a=e(t).toRgb(),o=e(r).toRgb(),s=n/100,l=2*s-1,c=o.a-a.a;i=l*c==-1?l:(l+c)/(1+l*c),i=(i+1)/2;var u=1-i,f={r:o.r*i+a.r*u,g:o.g*i+a.g*u,b:o.b*i+a.b*u,a:o.a*s+a.a*(1-s)};return e(f)},e.readability=function(t,r){var n=e(t),i=e(r);return(Math.max(n.getLuminance(),i.getLuminance())+.05)/(Math.min(n.getLuminance(),i.getLuminance())+.05)},e.isReadable=function(t,r,n){var i,a,o=e.readability(t,r);switch(a=!1,i=N(n),i.level+i.size){case"AAsmall":case"AAAlarge":a=o>=4.5;break;case"AAlarge":a=o>=3;break;case"AAAsmall":a=o>=7}return a},e.mostReadable=function(t,r,n){var i,a,o,s,l=null,c=0;n=n||{},a=n.includeFallbackColors,o=n.level,s=n.size;for(var u=0;uc&&(c=i,l=e(r[u]));return e.isReadable(t,l,{level:o,size:s})||!a?l:(n.includeFallbackColors=!1,e.mostReadable(t,["#fff","#000"],n))};var G=e.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Y=e.hexNames=A(G),X=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",r="(?:"+e+")|(?:"+t+")",n="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",i="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof r&&r.exports?r.exports=e:"function"==typeof t&&t.amd?t(function(){return e}):window.tinycolor=e}()},{}],276:[function(t,e,r){"use strict";function n(t,e){var r=o(getComputedStyle(t).getPropertyValue(e));return r[0]*a(r[1],t)}function i(t,e){var r=document.createElement("div");r.style["font-size"]="128"+t,e.appendChild(r);var i=n(r,"font-size")/128;return e.removeChild(r),i}function a(t,e){switch(e=e||document.body,t=(t||"px").trim().toLowerCase(),e!==window&&e!==document||(e=document.body),t){case"%":return e.clientHeight/100;case"ch":case"ex":return i(t,e);case"em":return n(e,"font-size");case"rem":return n(document.body,"font-size");case"vw":return window.innerWidth/100;case"vh":return window.innerHeight/100;case"vmin":return Math.min(window.innerWidth,window.innerHeight)/100;case"vmax":return Math.max(window.innerWidth,window.innerHeight)/100;case"in":return s;case"cm":return s/2.54;case"mm":return s/25.4;case"pt":return s/72;case"pc":return s/6}return 1}var o=t("parse-unit");e.exports=a;var s=96},{"parse-unit":231}],277:[function(e,r,n){!function(e,i){"object"==typeof n&&"undefined"!=typeof r?i(n):"function"==typeof t&&t.amd?t(["exports"],i):i(e.topojson=e.topojson||{})}(this,function(t){"use strict";function e(){}function r(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0),t[0]=(r+=t[0])*i+o,t[1]=(n+=t[1])*a+s}}function n(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0);var l=Math.round((t[0]-o)/i),c=Math.round((t[1]-s)/a);t[0]=l-r,t[1]=c-n,r=l,n=c}}function i(t,e){for(var r,n=t.length,i=n-e;i<--n;)r=t[i],t[i++]=t[n],t[n]=r}function a(t,e){for(var r=0,n=t.length;n>r;){var i=r+n>>>1;t[i]t?~t:t],a=0,o=n.length;o>a;++a)e.push(r=n[a].slice()),u(r,a);0>t&&i(e,o)}function a(t){return t=t.slice(),u(t,0),t}function o(t){for(var e=[],r=0,i=t.length;i>r;++r)n(t[r],e);return e.length<2&&e.push(e[0].slice()),e}function s(t){for(var e=o(t);e.length<4;)e.push(e[0].slice());return e}function l(t){return t.map(s)}function c(t){var e=t.type;return"GeometryCollection"===e?{type:e,geometries:t.geometries.map(c)}:e in h?{type:e,coordinates:h[e](t)}:null}var u=r(t.transform),f=t.arcs,h={Point:function(t){return a(t.coordinates)},MultiPoint:function(t){return t.coordinates.map(a)},LineString:function(t){return o(t.arcs)},MultiLineString:function(t){return t.arcs.map(o)},Polygon:function(t){return l(t.arcs)},MultiPolygon:function(t){return t.arcs.map(l)}};return c(e)}function c(t,e){function r(e){var r,n=t.arcs[0>e?~e:e],i=n[0];return t.transform?(r=[0,0],n.forEach(function(t){r[0]+=t[0],r[1]+=t[1]})):r=n[n.length-1],0>e?[r,i]:[i,r]}function n(t,e){for(var r in t){var n=t[r];delete e[n.start],delete n.start,delete n.end,n.forEach(function(t){i[0>t?~t:t]=1}),s.push(n)}}var i={},a={},o={},s=[],l=-1;return e.forEach(function(r,n){var i,a=t.arcs[0>r?~r:r];a.length<3&&!a[1][0]&&!a[1][1]&&(i=e[++l],e[l]=r,e[n]=i)}),e.forEach(function(t){var e,n,i=r(t),s=i[0],l=i[1];if(e=o[s])if(delete o[e.end],e.push(t),e.end=l,n=a[l]){delete a[n.start];var c=n===e?e:e.concat(n);a[c.start=e.start]=o[c.end=n.end]=c}else a[e.start]=o[e.end]=e;else if(e=a[l])if(delete a[e.start],e.unshift(t),e.start=s,n=o[s]){delete o[n.end];var u=n===e?e:n.concat(e);a[u.start=n.start]=o[u.end=e.end]=u}else a[e.start]=o[e.end]=e;else e=[t],a[e.start=s]=o[e.end=l]=e}),n(o,a),n(a,o),e.forEach(function(t){i[0>t?~t:t]||s.push([t])}),s}function u(t){return l(t,f.apply(this,arguments))}function f(t,e,r){function n(t){var e=0>t?~t:t;(u[e]||(u[e]=[])).push({i:t,g:l})}function i(t){t.forEach(n)}function a(t){t.forEach(i)}function o(t){"GeometryCollection"===t.type?t.geometries.forEach(o):t.type in f&&(l=t,f[t.type](t.arcs))}var s=[];if(arguments.length>1){var l,u=[],f={LineString:i,MultiLineString:a,Polygon:a,MultiPolygon:function(t){t.forEach(a)}};o(e),u.forEach(arguments.length<3?function(t){s.push(t[0].i)}:function(t){r(t[0].g,t[t.length-1].g)&&s.push(t[0].i)})}else for(var h=0,d=t.arcs.length;d>h;++h)s.push(h);return{type:"MultiLineString",arcs:c(t,s)}}function h(t){var e=t[0],r=t[1],n=t[2];return Math.abs((e[0]-n[0])*(r[1]-e[1])-(e[0]-r[0])*(n[1]-e[1]))}function d(t){for(var e,r=-1,n=t.length,i=t[n-1],a=0;++re?~e:e]||(i[e]=[])).push(t)})}),a.push(t)}function n(e){return Math.abs(d(l(t,{type:"Polygon",arcs:[e]}).coordinates[0]))}var i={},a=[],o=[];return e.forEach(function(t){"Polygon"===t.type?r(t.arcs):"MultiPolygon"===t.type&&t.arcs.forEach(r)}),a.forEach(function(t){if(!t._){var e=[],r=[t];for(t._=1,o.push(e);t=r.pop();)e.push(t),t.forEach(function(t){t.forEach(function(t){i[0>t?~t:t].forEach(function(t){t._||(t._=1,r.push(t))})})})}}),a.forEach(function(t){delete t._}),{type:"MultiPolygon",arcs:o.map(function(e){var r,a=[];if(e.forEach(function(t){t.forEach(function(t){t.forEach(function(t){i[0>t?~t:t].length<2&&a.push(t)})})}),a=c(t,a),(r=a.length)>1)for(var o,s,l=1,u=n(a[0]);r>l;++l)(o=n(a[l]))>u&&(s=a[0],a[0]=a[l],a[l]=s,u=o);return a})}}function v(t){function e(t,e){t.forEach(function(t){0>t&&(t=~t);var r=i[t];r?r.push(e):i[t]=[e]})}function r(t,r){t.forEach(function(t){e(t,r)})}function n(t,e){"GeometryCollection"===t.type?t.geometries.forEach(function(t){n(t,e)}):t.type in s&&s[t.type](t.arcs,e)}var i={},o=t.map(function(){return[]}),s={LineString:e,MultiLineString:r,Polygon:r,MultiPolygon:function(t,e){t.forEach(function(t){r(t,e)})}};t.forEach(n);for(var l in i)for(var c=i[l],u=c.length,f=0;u>f;++f)for(var h=f+1;u>h;++h){var d,p=c[f],g=c[h];(d=o[p])[l=a(d,g)]!==g&&d.splice(l,0,g),(d=o[g])[l=a(d,p)]!==p&&d.splice(l,0,p)}return o}function m(t,e){return t[1][2]-e[1][2]}function y(){function t(t,e){for(;e>0;){var r=(e+1>>1)-1,i=n[r];if(m(t,i)>=0)break;n[i._=e]=i,n[t._=e=r]=t}}function e(t,e){for(;;){var r=e+1<<1,a=r-1,o=e,s=n[o];if(i>a&&m(n[a],s)<0&&(s=n[o=a]),i>r&&m(n[r],s)<0&&(s=n[o=r]),o===e)break;n[s._=e]=s,n[t._=e=o]=t}}var r={},n=[],i=0;return r.push=function(e){return t(n[e._=i]=e,i++),i},r.pop=function(){if(!(0>=i)){var t,r=n[0];return--i>0&&(t=n[i],e(n[t._=0]=t,0)),r}},r.remove=function(r){var a,o=r._;if(n[o]===r)return o!==--i&&(a=n[i],(m(a,r)<0?t:e)(n[a._=o]=a,o)),o},r}function b(t,e){function i(t){s.remove(t),t[1][2]=e(t),s.push(t)}var a=r(t.transform),o=n(t.transform),s=y();return e||(e=h),t.arcs.forEach(function(t){var r,n,l,c,u=[],f=0;for(n=0,l=t.length;l>n;++n)c=t[n],a(t[n]=[c[0],c[1],1/0],n);for(n=1,l=t.length-1;l>n;++n)r=t.slice(n-1,n+2),r[1][2]=e(r),u.push(r),s.push(r);for(n=0,l=u.length;l>n;++n)r=u[n],r.previous=u[n-1],r.next=u[n+1];for(;r=s.pop();){var h=r.previous,d=r.next;r[1][2]t)return[];if(0===t)return[[0]];for(var e=0|Math.round(o(t+1)),r=[],n=0;e>n;++n){for(var s=i.unrank(t,n),l=[0],c=0,u=0;uMath.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,s=0;3>s;++s)a+=t[s]*t[s],o+=i[s]*t[s];for(var s=0;3>s;++s)i[s]-=o/a*t[s];return h(i,i),i}function o(t,e,r,n,i,a,o,s){this.center=l(r),this.up=l(n),this.right=l(i),this.radius=l([a]),this.angle=l([o,s]),this.angle.bounds=[[-(1/0),-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var c=0;16>c;++c)this.computedMatrix[c]=.5;this.recalcMatrix(0)}function s(t){t=t||{};var e=t.center||[0,0,0],r=t.up||[0,1,0],i=t.right||a(r),s=t.radius||1,l=t.theta||0,c=t.phi||0;if(e=[].slice.call(e,0,3),r=[].slice.call(r,0,3),h(r,r),i=[].slice.call(i,0,3),h(i,i),"eye"in t){var u=t.eye,p=[u[0]-e[0],u[1]-e[1],u[2]-e[2]];f(i,p,r),n(i[0],i[1],i[2])<1e-6?i=a(r):h(i,i),s=n(p[0],p[1],p[2]);var g=d(r,p)/s,v=d(i,p)/s;c=Math.acos(g),l=Math.acos(v)}return s=Math.log(s),new o(t.zoomMin,t.zoomMax,e,r,i,s,l,c)}e.exports=s;var l=t("filtered-vector"),c=t("gl-mat4/invert"),u=t("gl-mat4/rotate"),f=t("gl-vec3/cross"),h=t("gl-vec3/normalize"),d=t("gl-vec3/dot"),p=o.prototype;p.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-(1/0),e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},p.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},p.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,i=0,a=0,o=0;3>o;++o)a+=e[o]*r[o],i+=e[o]*e[o];for(var s=Math.sqrt(i),l=0,o=0;3>o;++o)r[o]-=e[o]*a/i,l+=r[o]*r[o],e[o]/=s;for(var c=Math.sqrt(l),o=0;3>o;++o)r[o]/=c;var u=this.computedToward;f(u,e,r),h(u,u);for(var d=Math.exp(this.computedRadius[0]),p=this.computedAngle[0],g=this.computedAngle[1],v=Math.cos(p),m=Math.sin(p),y=Math.cos(g),b=Math.sin(g),x=this.computedCenter,_=v*y,w=m*y,k=b,A=-v*b,M=-m*b,T=y,E=this.computedEye,L=this.computedMatrix,o=0;3>o;++o){var S=_*r[o]+w*u[o]+k*e[o];L[4*o+1]=A*r[o]+M*u[o]+T*e[o],L[4*o+2]=S,L[4*o+3]=0}var C=L[1],z=L[5],P=L[9],R=L[2],O=L[6],I=L[10],N=z*I-P*O,j=P*R-C*I,F=C*O-z*R,B=n(N,j,F);N/=B,j/=B,F/=B,L[0]=N,L[4]=j,L[8]=F;for(var o=0;3>o;++o)E[o]=x[o]+L[2+4*o]*d;for(var o=0;3>o;++o){for(var l=0,D=0;3>D;++D)l+=L[o+4*D]*E[D];L[12+o]=-l}L[15]=1},p.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;16>n;++n)e[n]=r[n];return e}return r};var g=[0,0,0];p.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;g[0]=i[2],g[1]=i[6],g[2]=i[10];for(var a=this.computedUp,o=this.computedRight,s=this.computedToward,l=0;3>l;++l)i[4*l]=a[l],i[4*l+1]=o[l],i[4*l+2]=s[l];u(i,i,n,g);for(var l=0;3>l;++l)a[l]=i[4*l],o[l]=i[4*l+1];this.up.set(t,a[0],a[1],a[2]),this.right.set(t,o[0],o[1],o[2])}},p.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=(Math.exp(this.computedRadius[0]),a[1]),s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],f=a[4],h=a[8],d=u*o+f*s+h*l;u-=o*d,f-=s*d,h-=l*d;var p=n(u,f,h);u/=p,f/=p,h/=p;var g=u*e+o*r,v=f*e+s*r,m=h*e+l*r;this.center.move(t,g,v,m);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+i),this.radius.set(t,Math.log(y))},p.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},p.setMatrix=function(t,e,r,a){var o=1;"number"==typeof r&&(o=0|r),(0>o||o>3)&&(o=1);var s=(o+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var l=e[o],u=e[o+4],f=e[o+8];if(a){var h=Math.abs(l),d=Math.abs(u),p=Math.abs(f),g=Math.max(h,d,p);h===g?(l=0>l?-1:1,u=f=0):p===g?(f=0>f?-1:1,l=u=0):(u=0>u?-1:1,l=f=0)}else{var v=n(l,u,f);l/=v,u/=v,f/=v}var m=e[s],y=e[s+4],b=e[s+8],x=m*l+y*u+b*f;m-=l*x,y-=u*x,b-=f*x;var _=n(m,y,b);m/=_,y/=_,b/=_;var w=u*b-f*y,k=f*m-l*b,A=l*y-u*m,M=n(w,k,A);w/=M,k/=M,A/=M,this.center.jump(t,H,G,Y),this.radius.idle(t),this.up.jump(t,l,u,f),this.right.jump(t,m,y,b);var T,E;if(2===o){var L=e[1],S=e[5],C=e[9],z=L*m+S*y+C*b,P=L*w+S*k+C*A;T=0>N?-Math.PI/2:Math.PI/2,E=Math.atan2(P,z)}else{var R=e[2],O=e[6],I=e[10],N=R*l+O*u+I*f,j=R*m+O*y+I*b,F=R*w+O*k+I*A;T=Math.asin(i(N)),E=Math.atan2(F,j)}this.angle.jump(t,E,T),this.recalcMatrix(t);var B=e[2],D=e[6],U=e[10],V=this.computedMatrix;c(V,e);var q=V[15],H=V[12]/q,G=V[13]/q,Y=V[14]/q,X=Math.exp(this.computedRadius[0]);this.center.jump(t,H-B*X,G-D*X,Y-U*X)},p.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},p.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},p.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},p.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},p.lookAt=function(t,e,r,a){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter,a=a||this.computedUp;var o=a[0],s=a[1],l=a[2],c=n(o,s,l);if(!(1e-6>c)){o/=c,s/=c,l/=c;var u=e[0]-r[0],f=e[1]-r[1],h=e[2]-r[2],d=n(u,f,h);if(!(1e-6>d)){u/=d,f/=d,h/=d;var p=this.computedRight,g=p[0],v=p[1],m=p[2],y=o*g+s*v+l*m;g-=y*o,v-=y*s,m-=y*l;var b=n(g,v,m);if(!(.01>b&&(g=s*h-l*f,v=l*u-o*h,m=o*f-s*u,b=n(g,v,m),1e-6>b))){g/=b,v/=b,m/=b,this.up.set(t,o,s,l),this.right.set(t,g,v,m),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(d));var x=s*m-l*v,_=l*g-o*m,w=o*v-s*g,k=n(x,_,w);x/=k,_/=k,w/=k;var A=o*u+s*f+l*h,M=g*u+v*f+m*h,T=x*u+_*f+w*h,E=Math.asin(i(A)),L=Math.atan2(T,M),S=this.angle._state,C=S[S.length-1],z=S[S.length-2];C%=2*Math.PI;var P=Math.abs(C+2*Math.PI-L),R=Math.abs(C-L),O=Math.abs(C-2*Math.PI-L);R>P&&(C+=2*Math.PI),R>O&&(C-=2*Math.PI),this.angle.jump(this.angle.lastT(),C,z),this.angle.set(t,L,E)}}}}},{"filtered-vector":96,"gl-mat4/invert":128,"gl-mat4/rotate":132,"gl-vec3/cross":183,"gl-vec3/dot":184,"gl-vec3/normalize":187}],280:[function(t,e,r){"use strict";function n(t,e,r){var n=t*e,a=i*t,o=a-t,s=a-o,l=t-s,c=i*e,u=c-e,f=c-u,h=e-f,d=n-s*f,p=d-l*f,g=p-s*h,v=l*h-g;return r?(r[0]=v,r[1]=n,r):[v,n]}e.exports=n;var i=+(Math.pow(2,27)+1)},{}],281:[function(t,e,r){"use strict";function n(t,e,r){var n=t+e,i=n-t,a=n-i,o=e-i,s=t-a;return r?(r[0]=s+o,r[1]=n,r):[s+o,n]}e.exports=n},{}],282:[function(t,e,r){(function(e,n){"use strict";function i(t){if(t){var e=t.length||t.byteLength,r=y.log2(e);w[r].push(t)}}function a(t){i(t.buffer)}function o(t){var t=y.nextPow2(t),e=y.log2(t),r=w[e];return r.length>0?r.pop():new ArrayBuffer(t)}function s(t){return new Uint8Array(o(t),0,t)}function l(t){return new Uint16Array(o(2*t),0,t)}function c(t){return new Uint32Array(o(4*t),0,t)}function u(t){return new Int8Array(o(t),0,t)}function f(t){return new Int16Array(o(2*t),0,t)}function h(t){return new Int32Array(o(4*t),0,t)}function d(t){return new Float32Array(o(4*t),0,t)}function p(t){return new Float64Array(o(8*t),0,t)}function g(t){return x?new Uint8ClampedArray(o(t),0,t):s(t)}function v(t){return new DataView(o(t),0,t)}function m(t){t=y.nextPow2(t);var e=y.log2(t),r=k[e];return r.length>0?r.pop():new n(t)}var y=t("bit-twiddle"),b=t("dup");e.__TYPEDARRAY_POOL||(e.__TYPEDARRAY_POOL={UINT8:b([32,0]),UINT16:b([32,0]),UINT32:b([32,0]),INT8:b([32,0]),INT16:b([32,0]),INT32:b([32,0]),FLOAT:b([32,0]),DOUBLE:b([32,0]),DATA:b([32,0]),UINT8C:b([32,0]),BUFFER:b([32,0])});var x="undefined"!=typeof Uint8ClampedArray,_=e.__TYPEDARRAY_POOL;_.UINT8C||(_.UINT8C=b([32,0])),_.BUFFER||(_.BUFFER=b([32,0]));var w=_.DATA,k=_.BUFFER;r.free=function(t){if(n.isBuffer(t))k[y.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|y.log2(e);w[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=a,r.freeArrayBuffer=i,r.freeBuffer=function(t){k[y.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return o(t);switch(e){case"uint8":return s(t);case"uint16":return l(t);case"uint32":return c(t);case"int8":return u(t);case"int16":return f(t);case"int32":return h(t);case"float":case"float32":return d(t);case"double":case"float64":return p(t);case"uint8_clamped":return g(t);case"buffer":return m(t);case"data":case"dataview":return v(t);default:return null}return null},r.mallocArrayBuffer=o,r.mallocUint8=s,r.mallocUint16=l,r.mallocUint32=c,r.mallocInt8=u,r.mallocInt16=f,r.mallocInt32=h,r.mallocFloat32=r.mallocFloat=d,r.mallocFloat64=r.mallocDouble=p,r.mallocUint8Clamped=g,r.mallocDataView=v,r.mallocBuffer=m,r.clearCache=function(){for(var t=0;32>t;++t)_.UINT8[t].length=0,_.UINT16[t].length=0,_.UINT32[t].length=0,_.INT8[t].length=0,_.INT16[t].length=0,_.INT32[t].length=0,_.FLOAT[t].length=0,_.DOUBLE[t].length=0,_.UINT8C[t].length=0,w[t].length=0,k[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":48,buffer:58,dup:90}],283:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;t>e;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n;var i=n.prototype;Object.defineProperty(i,"length",{get:function(){return this.roots.length}}),i.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},i.find=function(t){for(var e=t,r=this.roots;r[t]!==t;)t=r[t];for(;r[e]!==t;){var n=r[e];r[e]=t,e=n}return t},i.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],284:[function(t,e,r){"use strict";function n(t,e){for(var r=1,n=t.length,i=t[0],a=t[0],o=1;n>o;++o)if(a=i,i=t[o],e(i,a)){if(o===r){r++;continue}t[r++]=i}return t.length=r,t}function i(t){for(var e=1,r=t.length,n=t[0],i=t[0],a=1;r>a;++a,i=n)if(i=n,n=t[a],n!==i){if(a===e){e++;continue}t[e++]=n}return t.length=e,t}function a(t,e,r){return 0===t.length?t:e?(r||t.sort(e),n(t,e)):(r||t.sort(),i(t))}e.exports=a},{}],285:[function(t,e,r){"use strict";function n(t,e){return"object"==typeof e&&null!==e||(e={}),i(t,e.canvas||a,e.context||o,e)}e.exports=n;var i=t("./lib/vtext"),a=null,o=null;"undefined"!=typeof document&&(a=document.createElement("canvas"),a.width=8192,a.height=1024,o=a.getContext("2d"))},{"./lib/vtext":286}],286:[function(t,e,r){"use strict";function n(t,e,r){for(var n=e.textAlign||"start",i=e.textBaseline||"alphabetic",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;s>l;++l)for(var c=t[l],u=0;2>u;++u)a[u]=0|Math.min(a[u],c[u]),o[u]=0|Math.max(o[u],c[u]);var f=0;switch(n){case"center":f=-.5*(a[0]+o[0]);break;case"right":case"end":f=-o[0];break;case"left":case"start":f=-a[0];break;default:throw new Error("vectorize-text: Unrecognized textAlign: '"+n+"'")}var h=0;switch(i){case"hanging":case"top":h=-a[1];break;case"middle":h=-.5*(a[1]+o[1]);break;case"alphabetic":case"ideographic":h=-3*r;break;case"bottom":h=-o[1];break;default:throw new Error("vectorize-text: Unrecoginized textBaseline: '"+i+"'")}var d=1/r;return"lineHeight"in e?d*=+e.lineHeight:"width"in e?d=e.width/(o[0]-a[0]):"height"in e&&(d=e.height/(o[1]-a[1])),t.map(function(t){return[d*(t[0]+f),d*(t[1]+h)]})}function i(t,e,r,n){var i=0|Math.ceil(e.measureText(r).width+2*n);if(i>8192)throw new Error("vectorize-text: String too long (sorry, this will get fixed later)");var a=3*n;t.height=0?l[r]:e)}function e(t){var e=n(t);return e?c in e:s.indexOf(t)>=0}function r(t,e){var r,i=n(t);return i?i[c]=e:(r=s.indexOf(t),r>=0?l[r]=e:(r=s.length,l[r]=e,s[r]=t)),this}function o(t){var e,r,i=n(t);return i?c in i&&delete i[c]:(e=s.indexOf(t),0>e?!1:(r=s.length-1,s[e]=void 0,l[e]=l[r],s[e]=s[r],s.length=r,l.length=r,!0))}this instanceof x||a();var s=[],l=[],c=b++;return Object.create(x.prototype,{get___:{value:i(t)},has___:{value:i(e)},set___:{value:i(r)},delete___:{value:i(o)}})};x.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0, +configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},"delete":{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof s?!function(){function r(){function e(t,e){return u?c.has(t)?c.get(t):u.get___(t,e):c.get(t,e)}function r(t){return c.has(t)||(u?u.has___(t):!1)}function n(t){var e=!!c.delete(t);return u?u.delete___(t)||e:e}this instanceof x||a();var l,c=new s,u=void 0,f=!1;return l=o?function(t,e){return c.set(t,e),c.has(t)||(u||(u=new x),u.set(t,e)),this}:function(t,e){if(f)try{c.set(t,e)}catch(r){u||(u=new x),u.set___(t,e)}else c.set(t,e);return this},Object.create(x.prototype,{get___:{value:i(e)},has___:{value:i(r)},set___:{value:i(l)},delete___:{value:i(n)},permitHostObjects___:{value:i(function(e){if(e!==t)throw new Error("bogus call to permitHostObjects___");f=!0})}})}o&&"undefined"!=typeof Proxy&&(Proxy=void 0),r.prototype=x.prototype,e.exports=r,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=x)}}()},{}],288:[function(t,e,r){function n(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:i(e,t)}}var i=t("./hidden-store.js");e.exports=n},{"./hidden-store.js":289}],289:[function(t,e,r){function n(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}e.exports=n},{}],290:[function(t,e,r){function n(){var t=i();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){t(e).value=r},has:function(e){return"value"in t(e)},"delete":function(e){return delete t(e).value}}}var i=t("./create-store.js");e.exports=n},{"./create-store.js":288}],291:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array",{offset:[1],array:0},"scalar","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\n var _inline_1_da = _inline_1_arg0_ - _inline_1_arg3_\n var _inline_1_db = _inline_1_arg1_ - _inline_1_arg3_\n if((_inline_1_da >= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":83}],292:[function(t,e,r){"use strict";function n(t,e){var r=[];return e=+e||0,i(t.hi(t.shape[0]-1),r,e),r}e.exports=n;var i=t("./lib/zc-core")},{"./lib/zc-core":291}],293:[function(t,e,r){"use strict";e.exports=["",{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],294:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:o({},i,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":367,"../../plots/cartesian/constants":398,"../../plots/font_attributes":411,"./arrow_paths":293}],295:[function(t,e,r){"use strict";function n(t,e){function r(e,r){return c.coerce(t,n,v.layoutAttributes,e,r)}var n={};r("opacity"),r("align"),r("bgcolor");var i=r("bordercolor"),a=f.opacity(i);r("borderpad");var o=r("borderwidth"),s=r("showarrow");s&&(r("arrowcolor",a?n.bordercolor:f.defaultLine),r("arrowhead"),r("arrowsize"),r("arrowwidth",2*(a&&o||1)),r("ax"),r("ay"),c.noneOrAll(t,n,["ax","ay"])),r("text",s?" ":"new text"),r("textangle"),c.coerceFont(r,"font",e.font);for(var l=["x","y"],h=0;2>h;h++){var d=l[h],p={_fullLayout:e},g=u.coerceRef(t,n,p,d),m=.5;if("paper"!==g){var y=u.getFromId(p,g);if(m=y.range[0]+m*(y.range[1]-y.range[0]),-1!==["date","category"].indexOf(y.type)&&"string"==typeof t[d]){var b;"date"===y.type?(b=c.dateTime2ms(t[d]),b!==!1&&(t[d]=b)):(y._categories||[]).length&&(b=y._categories.indexOf(t[d]),-1!==b&&(t[d]=b))}}r(d,m),s||r(d+"anchor")}return c.noneOrAll(t,n,["x","y"]),n}function i(t){var e=t._fullLayout;e.annotations.forEach(function(e){var r=u.getFromId(t,e.xref),n=u.getFromId(t,e.yref);if(r||n){var i=(e._xsize||0)/2,a=e._xshift||0,o=(e._ysize||0)/2,s=e._yshift||0,l=i-a,c=i+a,f=o-s,h=o+s;if(e.showarrow){var d=3*e.arrowsize*e.arrowwidth;l=Math.max(l,d),c=Math.max(c,d),f=Math.max(f,d),h=Math.max(h,d)}r&&r.autorange&&u.expand(r,[r.l2c(e.x)],{ppadplus:c,ppadminus:l}),n&&n.autorange&&u.expand(n,[n.l2c(e.y)],{ppadplus:h,ppadminus:f})}})}function a(t,e,r,n,i,a,o,s){var l=r-t,c=i-t,u=o-i,f=n-e,h=a-e,d=s-a,p=l*d-u*f;if(0===p)return null;var g=(c*d-u*h)/p,v=(c*f-l*h)/p;return 0>v||v>1||0>g||g>1?null:{x:t+l*g,y:e+f*g}}var o=t("d3"),s=t("fast-isnumeric"),l=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),h=t("../drawing"),d=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var r=t.annotations||[],i=e.annotations=[],a=0;at?"left":t>2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var n=W.select(".annotation-math-group"),i=!n.empty(),s=h.bBox((i?n:tt).node()),d=s.width,m=s.height,y=Math.round(d+2*Q),b=Math.round(m+2*Q);U._w=d,U._h=m;var x=!1;if(["x","y"].forEach(function(e){var n,i=u.getFromId(t,U[e+"ref"]||e),a=(G+("x"===e?0:90))*Math.PI/180,o=y*Math.abs(Math.cos(a))+b*Math.abs(Math.sin(a)),s=U[e+"anchor"];if(i){if(!i.autorange&&(U[e]-i.range[0])*(U[e]-i.range[1])>0)return void(x=!0);H[e]=i._offset+i.l2p(U[e]),n=.5}else n=U[e],"y"===e&&(n=1-n),H[e]="x"===e?S.l+S.w*n:S.t+S.h*n;var l=0;l=U.showarrow?U["a"+e]:o*r(n,s),H[e]+=l,U["_"+e+"type"]=i&&i.type,U["_"+e+"size"]=o,U["_"+e+"shift"]=l}),x)return void W.remove();var w,k;U.showarrow&&(w=c.constrain(H.x-U.ax,1,_.width-1),k=c.constrain(H.y-U.ay,1,_.height-1)),H.x=c.constrain(H.x,1,_.width-1),H.y=c.constrain(H.y,1,_.height-1);var A=Q-s.top,M=Q-s.left;i?n.select("svg").attr({x:Q-1,y:Q}):(tt.attr({x:M,y:A}),tt.selectAll("tspan.line").attr({y:A,x:M})),$.call(h.setRect,Z/2,Z/2,y-Z,b-Z);var T=Math.round(H.x-y/2),E=Math.round(H.y-b/2);W.attr("transform","translate("+T+", "+E+")");var L="annotations["+e+"]",C=function(r,n){o.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var i=H.x+r,s=H.y+n,u=c.rotationXYMatrix(G,i,s),d=c.apply2DTransform(u),p=c.apply2DTransform2(u),m=$.attr("width")/2,y=$.attr("height")/2,b=[[i-m,s-y,i-m,s+y],[i-m,s+y,i+m,s+y],[i+m,s+y,i+m,s-y],[i+m,s-y,i-m,s-y]].map(p);if(!b.reduce(function(t,e){return t^!!a(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){b.forEach(function(t){var e=a(i,s,w,k,t[0],t[1],t[2],t[3]);e&&(i=e.x,s=e.y)});var x=U.arrowwidth,_=U.arrowcolor,A=Y.append("g").style({opacity:f.opacity(_)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),M=A.append("path").attr("d","M"+i+","+s+"L"+w+","+k).style("stroke-width",x+"px").call(f.stroke,f.rgb(_));v.arrowhead(M,U.arrowhead,"end",U.arrowsize);var T=A.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(i-w)+","+(s-k),transform:"translate("+w+","+k+")"}).style("stroke-width",x+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var E,C,z;g.init({element:T.node(),prepFn:function(){C=Number(W.attr("x")),z=Number(W.attr("y")),E={},V&&V.autorange&&(E[V._name+".autorange"]=!0),q&&q.autorange&&(E[q._name+".autorange"]=!0)},moveFn:function(t,e){A.attr("transform","translate("+t+","+e+")");var r=d(C,z),n=r[0]+t,i=r[1]+e;W.call(h.setPosition,n,i),E[L+".x"]=V?U.x+t/V._m:(w+t-S.l)/S.w,E[L+".y"]=q?U.y+e/q._m:1-(k+e-S.t)/S.h,X.attr({transform:"rotate("+G+","+n+","+i+")"})},doneFn:function(e){if(e){l.relayout(t,E);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}};U.showarrow&&C(0,0);var z=c.rotationXYMatrix(G,H.x,H.y),P=c.apply2DTransform(z);if(t._context.editable){var R,O,I;g.init({element:W.node(),prepFn:function(){R=Number(W.attr("x")),O=Number(W.attr("y")),I={}},moveFn:function(t,e){W.call(h.setPosition,R+t,O+e);var r="pointer";if(U.showarrow)I[L+".ax"]=U.ax+t,I[L+".ay"]=U.ay+e,C(t,e);else{if(V)I[L+".x"]=U.x+t/V._m;else{var n=U._xsize/S.w,i=U.x+U._xshift/S.w-n/2;I[L+".x"]=g.align(i+t/S.w,n,0,1,U.xanchor)}if(q)I[L+".y"]=U.y+e/q._m;else{var a=U._ysize/S.h,o=U.y-U._yshift/S.h-a/2;I[L+".y"]=g.align(o-e/S.h,a,0,1,U.yanchor)}V&&q||(r=g.cursor(V?.5:I[L+".x"],q?.5:I[L+".y"],U.xanchor,U.yanchor))}var s=P(R,O),l=s[0]+t,c=s[1]+e;W.call(h.setPosition,l,c),X.attr({transform:"rotate("+G+","+l+","+c+")"}),p(W,r)},doneFn:function(e){if(p(W),e){l.relayout(t,I);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}var b,x=t.layout,_=t._fullLayout;if(!s(e)||-1===e){if(!e&&Array.isArray(i))return x.annotations=i,v.supplyLayoutDefaults(x,_),void v.drawAll(t);if("remove"===i)return delete x.annotations,_.annotations=[],void v.drawAll(t);if(r&&"add"!==i){for(b=0;b<_.annotations.length;b++)v.draw(t,b,r,i);return}e=_.annotations.length,_.annotations.push({})}if(!r&&i){if("remove"===i){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),x.annotations.splice(e,1),b=e;b<_.annotations.length;b++)_._infolayer.selectAll('.annotation[data-index="'+(b+1)+'"]').attr("data-index",String(b)),v.draw(t,b);return}if("add"===i||c.isPlainObject(i)){_.annotations.splice(e,0,{});var w=c.isPlainObject(i)?c.extendFlat({},i):{text:"New text"};for(x.annotations?x.annotations.splice(e,0,w):x.annotations=[w],b=_.annotations.length-1;b>e;b--)_._infolayer.selectAll('.annotation[data-index="'+(b-1)+'"]').attr("data-index",String(b)),v.draw(t,b)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=x.annotations[e],A=_.annotations[e];if(k){var M={xref:k.xref,yref:k.yref},T={};"string"==typeof r&&r?T[r]=i:c.isPlainObject(r)&&(T=r);var E=Object.keys(T);for(b=0;bb;b++){var z=C[b];if(void 0===T[z]&&void 0!==k[z]){var P=u.getFromId(t,u.coerceRef(M,{},t,z)),R=u.getFromId(t,u.coerceRef(k,{},t,z)),O=k[z],I=A["_"+z+"type"];if(void 0!==T[z+"ref"]){var N="auto"===k[z+"anchor"],j="x"===z?S.w:S.h,F=(A["_"+z+"size"]||0)/(2*j);if(P&&R)O=(O-P.range[0])/(P.range[1]-P.range[0]),O=R.range[0]+O*(R.range[1]-R.range[0]);else if(P){if(O=(O-P.range[0])/(P.range[1]-P.range[0]),O=P.domain[0]+O*(P.domain[1]-P.domain[0]),N){var B=O+F,D=O-F;2/3>O+D?O=D:O+B>4/3&&(O=B)}}else R&&(N&&(1/3>O?O+=F:O>2/3&&(O-=F)),O=(O-R.domain[0])/(R.domain[1]-R.domain[0]),O=R.range[0]+O*(R.range[1]-R.range[0]))}R&&R===P&&I&&("log"===I&&"log"!==R.type?O=Math.pow(10,O):"log"!==I&&"log"===R.type&&(O=O>0?Math.log(O)/Math.LN10:void 0)),k[z]=O}}var U=n(k,_);_.annotations[e]=U;var V=u.getFromId(t,U.xref),q=u.getFromId(t,U.yref),H={x:0,y:0},G=+U.textangle||0,Y=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",U.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:U})}),X=Y.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),W=X.append("g"),Z=U.borderwidth,K=U.borderpad,Q=Z+K,$=W.append("rect").attr("class","bg").style("stroke-width",Z+"px").call(f.stroke,U.bordercolor).call(f.fill,U.bgcolor),J=U.font,tt=W.append("text").classed("annotation",!0).attr("data-unformatted",U.text).text(U.text);t._context.editable?tt.call(d.makeEditable,W).call(m).on("edit",function(r){U.text=r,this.attr({"data-unformatted":U.text}),this.call(m);var n={};n["annotations["+e+"].text"]=U.text,V&&V.autorange&&(n[V._name+".autorange"]=!0),q&&q.autorange&&(n[q._name+".autorange"]=!0),l.relayout(t,n)}):tt.call(m),X.attr({transform:"rotate("+G+","+H.x+","+H.y+")"}).call(h.setPosition,H.x,H.y)}},v.arrowhead=function(t,e,r,n){s(n)||(n=1);var i=t.node(),a=v.ARROWPATHS[e||0];if(a){"string"==typeof r&&r||(r="end");var l,c,u,d,p=(h.getPx(t,"stroke-width")||1)*n,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=r.indexOf("start")>=0,b=r.indexOf("end")>=0,x=a.backoff*p;if("line"===i.nodeName){if(l={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(l.y-c.y,l.x-c.x),d=u+Math.PI,x){var _=x*Math.cos(u),w=x*Math.sin(u);y&&(l.x-=_,l.y-=w,t.attr({x1:l.x,y1:l.y})),b&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===i.nodeName){var k=i.getTotalLength(),A="";if(y){var M=i.getPointAtLength(0),T=i.getPointAtLength(.1);u=Math.atan2(M.y-T.y,M.x-T.x),l=i.getPointAtLength(Math.min(x,k)),x&&(A="0px,"+x+"px,")}if(b){var E=i.getPointAtLength(k),L=i.getPointAtLength(k-.1);if(d=Math.atan2(E.y-L.y,E.x-L.x),c=i.getPointAtLength(Math.max(0,k-x)),x){var S=A?2*x:x;A+=k-S+"px,"+k+"px"}}else A&&(A+=k+"px");A&&t.style("stroke-dasharray",A)}var C=function(r,n){e>5&&(n=0),o.select(i.parentElement).append("path").attr({"class":t.attr("class"),d:a.path,transform:"translate("+r.x+","+r.y+")rotate("+180*n/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(l,u),b&&C(c,d)}},v.calcAutorange=function(t){var e=t._fullLayout,r=e.annotations;if(r.length&&t._fullData.length){var n={};r.forEach(function(t){n[t.xref]=!0,n[t.yref]=!0});var a=u.list(t).filter(function(t){return t.autorange&&n[t._id]});if(a.length)return c.syncOrAsync([v.drawAll,i],t)}}},{"../../lib":372,"../../lib/setcursor":380,"../../lib/svg_text_utils":384,"../../plotly":390,"../../plots/cartesian/axes":393,"../color":297,"../dragelement":317,"../drawing":319,"./arrow_paths":293,"./attributes":294,d3:87,"fast-isnumeric":95}],296:[function(t,e,r){"use strict";r.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],r.defaultLine="#444",r.lightLine="#eee",r.background="#fff",r.lightFraction=1e3/11},{}],297:[function(t,e,r){"use strict";function n(t){if(a(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var r=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!r)return t;var n=r[1].trim().split(/\s*[\s,]\s*/),i="a"===e.charAt(3)&&4===n.length;if(!i&&3!==n.length)return t;for(var o=0;o=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}var i=t("tinycolor2"),a=t("fast-isnumeric"),o=e.exports={},s=t("./attributes");o.defaults=s.defaults,o.defaultLine=s.defaultLine,o.lightLine=s.lightLine,o.background=s.background,o.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},o.rgb=function(t){return o.tinyRGB(i(t))},o.opacity=function(t){return t?i(t).getAlpha():0},o.addOpacity=function(t,e){var r=i(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},o.combine=function(t,e){var r=i(t).toRgb();if(1===r.a)return i(t).toRgbString();var n=i(e||o.background).toRgb(),a=1===n.a?n:{r:255*(1-n.a)+n.r*n.a,g:255*(1-n.a)+n.g*n.a,b:255*(1-n.a)+n.b*n.a},s={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return i(s).toRgbString()},o.stroke=function(t,e){var r=i(e);t.style({stroke:o.tinyRGB(r),"stroke-opacity":r.getAlpha()})},o.fill=function(t,e){var r=i(e);t.style({fill:o.tinyRGB(r),"fill-opacity":r.getAlpha()})},o.clean=function(t){if(t&&"object"==typeof t){var e,r,i,a,s=Object.keys(t);for(e=0;el&&(a[1]-=(ot-l)/2)):r.node()&&!r.classed("js-placeholder")&&(ot=h.bBox(e.node()).height),ot){if(ot+=5,"top"===x.titleside)$.domain[1]-=ot/M.h,a[1]*=-1;else{$.domain[0]+=ot/M.h;var u=Math.max(1,r.selectAll("tspan.line").size());a[1]+=(1-u)*l}e.attr("transform","translate("+a+")"),$.setScale()}}it.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(M.h*(1-$.domain[1]))+")");var f=it.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var r=[0===e?E[0]:(S[e]+S[e-1])/2,e===S.length-1?E[1]:(S[e]+S[e+1])/2].map($.c2p).map(Math.round);e!==S.length-1&&(r[1]+=r[1]>r[0]?1:-1);var a=z(t).replace("e-",""),o=i(a).toHexString();n.select(this).attr({x:Y,width:Math.max(B,2),y:n.min(r),height:Math.max(n.max(r)-n.min(r),2),fill:o})});var d=it.select(".cblines").selectAll("path.cbline").data(x.line.color&&x.line.width?L:[]);return d.enter().append("path").classed("cbline",!0),d.exit().remove(),d.each(function(t){n.select(this).attr("d","M"+Y+","+(Math.round($.c2p(t))+x.line.width/2%1)+"h"+B).call(h.lineGroupStyle,x.line.width,C(t),x.line.dash)}),$._axislayer.selectAll("g."+$._id+"tick,path").remove(),$._pos=Y+B+(x.outlinewidth||0)/2-("outside"===x.ticks?1:0),$.side="right",c.syncOrAsync([function(){return s.doTicks(t,$,!0)},function(){if(-1===["top","bottom"].indexOf(x.titleside)){var e=$.titlefont.size,r=$._offset+$._length/2,i=M.l+($.position||0)*M.w+("right"===$.side?10+e*($.showticklabels?1:.5):-10-e*($.showticklabels?.5:0));w("h"+$._id+"title",{avoid:{selection:n.select(t).selectAll("g."+$._id+"tick"),side:x.titleside,offsetLeft:M.l,offsetTop:M.t,maxShift:A.width},attributes:{x:i,y:r,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,r){var n,i=b();n=o.traceIs(i,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var a={propContainer:$,propName:n,traceIndex:i.index,dfltName:"colorscale",containerGroup:it.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;it.selectAll("."+s+",."+s+"-math-group").remove(),p.draw(t,e,u(a,r||{}))}function k(){var r=B+x.outlinewidth/2+h.bBox($._axislayer.node()).width;if(N=at.select("text"),N.node()&&!N.classed("js-placeholder")){var n,i=at.select(".h"+$._id+"title-math-group").node();n=i&&-1!==["top","bottom"].indexOf(x.titleside)?h.bBox(i).width:h.bBox(at.node()).right-Y-M.l,r=Math.max(r,n)}var a=2*x.xpad+r+x.borderwidth+x.outlinewidth/2,s=Z-K;it.select(".cbbg").attr({x:Y-x.xpad-(x.borderwidth+x.outlinewidth)/2,y:K-H,width:Math.max(a,2),height:Math.max(s+2*H,2)}).call(d.fill,x.bgcolor).call(d.stroke,x.bordercolor).style({"stroke-width":x.borderwidth}),it.selectAll(".cboutline").attr({x:Y,y:K+x.ypad+("top"===x.titleside?ot:0),width:Math.max(B,2),height:Math.max(s-2*x.ypad-ot,2)}).call(d.stroke,x.outlinecolor).style({fill:"None","stroke-width":x.outlinewidth});var l=({center:.5,right:1}[x.xanchor]||0)*a;it.attr("transform","translate("+(M.l-l)+","+M.t+")"),o.autoMargin(t,e,{x:x.x,y:x.y,l:a*({right:1,center:.5}[x.xanchor]||0),r:a*({left:1,center:.5}[x.xanchor]||0),t:s*({bottom:1,middle:.5}[x.yanchor]||0),b:s*({top:1,middle:.5}[x.yanchor]||0)})}var A=t._fullLayout,M=A._size;if("function"!=typeof x.fillcolor&&"function"!=typeof x.line.color)return void A._infolayer.selectAll("g."+e).remove();var T,E=n.extent(("function"==typeof x.fillcolor?x.fillcolor:x.line.color).domain()),L=[],S=[],C="function"==typeof x.line.color?x.line.color:function(){return x.line.color},z="function"==typeof x.fillcolor?x.fillcolor:function(){return x.fillcolor},P=x.levels.end+x.levels.size/100,R=x.levels.size,O=1.001*E[0]-.001*E[1],I=1.001*E[1]-.001*E[0];for(T=x.levels.start;0>(T-P)*R;T+=R)T>O&&I>T&&L.push(T);if("function"==typeof x.fillcolor)if(x.filllevels)for(P=x.filllevels.end+x.filllevels.size/100,R=x.filllevels.size,T=x.filllevels.start;0>(T-P)*R;T+=R)T>E[0]&&T1){var nt=Math.pow(10,Math.floor(Math.log(rt)/Math.LN10));tt*=nt*c.roundUp(rt/nt,[2,5,10]),(Math.abs(x.levels.start)/x.levels.size+1e-6)%1<2e-6&&($.tick0=0)}$.dtick=tt}$.domain=[W+G,W+V-G],$.setScale();var it=A._infolayer.selectAll("g."+e).data([0]);it.enter().append("g").classed(e,!0).each(function(){var t=n.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),it.attr("transform","translate("+Math.round(M.l)+","+Math.round(M.t)+")");var at=it.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(M.l)+",-"+Math.round(M.t)+")");$._axislayer=it.select(".cbaxis");var ot=0;if(-1!==["top","bottom"].indexOf(x.titleside)){var st,lt=M.l+(x.x+q)*M.w,ct=$.titlefont.size;st="top"===x.titleside?(1-(W+V-G))*M.h+M.t+3+.75*ct:(1-(W+G))*M.h+M.t-3-.25*ct,w($._id+"title",{attributes:{x:lt,y:st,"text-anchor":"start"}})}var ut=c.syncOrAsync([o.previousPromises,_,o.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,ht,dt;l.init({element:it.node(),prepFn:function(){ft=it.attr("transform"),f(it)},moveFn:function(t,e){it.attr("transform",ft+" translate("+t+","+e+")"),ht=l.align(X+t/M.w,D,0,1,x.xanchor),dt=l.align(W-e/M.h,V,0,1,x.yanchor);var r=l.getCursor(ht,dt,x.xanchor,x.yanchor);f(it,r)},doneFn:function(e){f(it),e&&void 0!==ht&&void 0!==dt&&a.restyle(t,{"colorbar.x":ht,"colorbar.y":dt},b().index)}})}return ut}function b(){var r,n,i=e.substr(2);for(r=0;ru*f?i.RdBu:u>=0?i.Reds:i.Blues,l.colorscale=h,s.reversescale&&(h=a(h)),s.colorscale=h)}},{"../../lib":372,"./flip_scale":307,"./scales":314}],305:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":314}],306:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,c,u){var f=u.prefix,h=u.cLetter,d=f.slice(0,f.length-1),p=f?i.nestedProperty(t,d).get()||{}:t,g=f?i.nestedProperty(e,d).get()||{}:e,v=p[h+"min"],m=p[h+"max"],y=p.colorscale,b=n(v)&&n(m)&&m>v;c(f+h+"auto",!b),c(f+h+"min"),c(f+h+"max");var x;void 0!==y&&(x=!s(y)),c(f+"autocolorscale",x);var _=c(f+"colorscale"),w=c(f+"reversescale");if(w&&(g.colorscale=l(_)),"marker.line."!==f){var k;f&&(k=a(p));var A=c(f+"showscale",k);A&&o(p,g,r)}}},{"../../lib":372,"../colorbar/defaults":299,"../colorbar/has_colorbar":301,"./flip_scale":307,"./is_valid_scale":311, +"fast-isnumeric":95}],307:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=t.length,n=new Array(r),i=r-1,a=0;i>=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],308:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return e||(e=i),t?("string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e):e}},{"./default_scale":305,"./is_valid_scale_array":312,"./scales":314}],309:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(Array.isArray(o))for(var l=0;lh;h++)l=t[h],u[h]=e+l[0]*(r-e),f[h]=i(l[1]).toRgb();var d=n.scale.linear().domain(u).interpolate(n.interpolateObject).range(f);return function(t){if(a(t)){var n=o.constrain(t,e,r),l=d(n);return i(l).toRgbString()}return i(t).isValid()?t:s.defaultLine}}},{"../../lib":372,"../color":297,d3:87,"fast-isnumeric":95,tinycolor2:275}],314:[function(t,e,r){"use strict";e.exports={Greys:[[0,"rgb(0,0,0)"],[1,"rgb(255,255,255)"]],YlGnBu:[[0,"rgb(8,29,88)"],[.125,"rgb(37,52,148)"],[.25,"rgb(34,94,168)"],[.375,"rgb(29,145,192)"],[.5,"rgb(65,182,196)"],[.625,"rgb(127,205,187)"],[.75,"rgb(199,233,180)"],[.875,"rgb(237,248,217)"],[1,"rgb(255,255,217)"]],Greens:[[0,"rgb(0,68,27)"],[.125,"rgb(0,109,44)"],[.25,"rgb(35,139,69)"],[.375,"rgb(65,171,93)"],[.5,"rgb(116,196,118)"],[.625,"rgb(161,217,155)"],[.75,"rgb(199,233,192)"],[.875,"rgb(229,245,224)"],[1,"rgb(247,252,245)"]],YlOrRd:[[0,"rgb(128,0,38)"],[.125,"rgb(189,0,38)"],[.25,"rgb(227,26,28)"],[.375,"rgb(252,78,42)"],[.5,"rgb(253,141,60)"],[.625,"rgb(254,178,76)"],[.75,"rgb(254,217,118)"],[.875,"rgb(255,237,160)"],[1,"rgb(255,255,204)"]],Bluered:[[0,"rgb(0,0,255)"],[1,"rgb(255,0,0)"]],RdBu:[[0,"rgb(5,10,172)"],[.35,"rgb(106,137,247)"],[.5,"rgb(190,190,190)"],[.6,"rgb(220,170,132)"],[.7,"rgb(230,145,90)"],[1,"rgb(178,10,28)"]],Reds:[[0,"rgb(220,220,220)"],[.2,"rgb(245,195,157)"],[.4,"rgb(245,160,105)"],[1,"rgb(178,10,28)"]],Blues:[[0,"rgb(5,10,172)"],[.35,"rgb(40,60,190)"],[.5,"rgb(70,100,245)"],[.6,"rgb(90,120,245)"],[.7,"rgb(106,137,247)"],[1,"rgb(220,220,220)"]],Picnic:[[0,"rgb(0,0,255)"],[.1,"rgb(51,153,255)"],[.2,"rgb(102,204,255)"],[.3,"rgb(153,204,255)"],[.4,"rgb(204,204,255)"],[.5,"rgb(255,255,255)"],[.6,"rgb(255,204,255)"],[.7,"rgb(255,153,255)"],[.8,"rgb(255,102,204)"],[.9,"rgb(255,102,102)"],[1,"rgb(255,0,0)"]],Rainbow:[[0,"rgb(150,0,90)"],[.125,"rgb(0,0,200)"],[.25,"rgb(0,25,255)"],[.375,"rgb(0,152,255)"],[.5,"rgb(44,255,150)"],[.625,"rgb(151,255,0)"],[.75,"rgb(255,234,0)"],[.875,"rgb(255,111,0)"],[1,"rgb(255,0,0)"]],Portland:[[0,"rgb(12,51,131)"],[.25,"rgb(10,136,186)"],[.5,"rgb(242,211,56)"],[.75,"rgb(242,143,56)"],[1,"rgb(217,30,30)"]],Jet:[[0,"rgb(0,0,131)"],[.125,"rgb(0,60,170)"],[.375,"rgb(5,255,255)"],[.625,"rgb(255,255,0)"],[.875,"rgb(250,0,0)"],[1,"rgb(128,0,0)"]],Hot:[[0,"rgb(0,0,0)"],[.3,"rgb(230,0,0)"],[.6,"rgb(255,210,0)"],[1,"rgb(255,255,255)"]],Blackbody:[[0,"rgb(0,0,0)"],[.2,"rgb(230,0,0)"],[.4,"rgb(230,210,0)"],[.7,"rgb(255,255,255)"],[1,"rgb(160,200,255)"]],Earth:[[0,"rgb(0,0,130)"],[.1,"rgb(0,180,180)"],[.2,"rgb(40,210,40)"],[.4,"rgb(230,230,50)"],[.6,"rgb(120,70,20)"],[1,"rgb(255,255,255)"]],Electric:[[0,"rgb(0,0,0)"],[.15,"rgb(30,0,100)"],[.4,"rgb(120,0,100)"],[.6,"rgb(160,90,0)"],[.8,"rgb(230,200,0)"],[1,"rgb(255,250,220)"]],Viridis:[[0,"#440154"],[.06274509803921569,"#48186a"],[.12549019607843137,"#472d7b"],[.18823529411764706,"#424086"],[.25098039215686274,"#3b528b"],[.3137254901960784,"#33638d"],[.3764705882352941,"#2c728e"],[.4392156862745098,"#26828e"],[.5019607843137255,"#21918c"],[.5647058823529412,"#1fa088"],[.6274509803921569,"#28ae80"],[.6901960784313725,"#3fbc73"],[.7529411764705882,"#5ec962"],[.8156862745098039,"#84d44b"],[.8784313725490196,"#addc30"],[.9411764705882353,"#d8e219"],[1,"#fde725"]]}},{}],315:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i){var a=(t-r)/(n-r),o=a+e/(n-r),s=(a+o)/2;return"left"===i||"bottom"===i?a:"center"===i||"middle"===i?s:"right"===i||"top"===i?o:2/3-s>a?a:o>4/3-s?o:s}},{}],316:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":372}],317:[function(t,e,r){"use strict";function n(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function i(t){t._dragging=!1,t._replotPending&&a.plot(t)}var a=t("../../plotly"),o=t("../../lib"),s=t("../../plots/cartesian/constants"),l=e.exports={};l.align=t("./align"),l.getCursor=t("./cursor");var c=t("./unhover");l.unhover=c.wrapped,l.unhoverRaw=c.raw,l.init=function(t){function e(e){return p._dragged=!1,p._dragging=!0,c=e.clientX,u=e.clientY,d=e.target,f=(new Date).getTime(),f-p._mouseDownTimev&&(g=Math.max(g-1,1)),t.doneFn&&t.doneFn(p._dragged,g),!p._dragged){var r=document.createEvent("MouseEvents");r.initEvent("click",!0,!0),d.dispatchEvent(r)}return i(p),p._dragged=!1,o.pauseEvent(e)}var c,u,f,h,d,p=o.getPlotDiv(t.element)||{},g=1,v=s.DBLCLICKDELAY;p._mouseDownTime||(p._mouseDownTime=0),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":372,"../../plotly":390,"../../plots/cartesian/constants":398,"./align":315,"./cursor":316,"./unhover":318}],318:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=e.exports={};i.wrapped=function(t,e,r){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),i.raw(t,e,r)},i.raw=function(t,e){var r=t._fullLayout;e||(e={}),e.target&&n.triggerHandler(t,"plotly_beforehover",e)===!1||(r._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":366}],319:[function(t,e,r){"use strict";function n(t,e,r,n){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],c=Math.pow(a*a+o*o,x/2),u=Math.pow(s*s+l*l,x/2),f=(u*u*a-c*c*s)*n,h=(u*u*o-c*c*l)*n,d=3*u*(c+u),p=3*c*(c+u);return[[i.round(e[0]+(d&&f/d),2),i.round(e[1]+(d&&h/d),2)],[i.round(e[0]-(p&&f/p),2),i.round(e[1]-(p&&h/p),2)]]}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../plots/plots"),s=t("../color"),l=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../traces/scatter/subtypes"),d=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,r,n){e&&e.family&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},p.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},p.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},p.setRect=function(t,e,r,n,i){t.call(p.setPosition,e,r).call(p.setSize,n,i)},p.translatePoints=function(t,e,r){t.each(function(t){var n=t.xp||e.c2p(t.x),o=t.yp||r.c2p(t.y),s=i.select(this);a(n)&&a(o)?"text"===this.nodeName?s.attr("x",n).attr("y",o):s.attr("transform","translate("+n+","+o+")"):s.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:1>e?1:Math.round(e):r||0},p.lineGroupStyle=function(t,e,r,n){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=n||a.dash||"";i.select(this).call(s.stroke,r||a.color).call(p.dashLine,l,o)})},p.dashLine=function(t,e,r){var n=Math.max(r,3);"solid"===e?e="":"dot"===e?e=n+"px,"+n+"px":"dash"===e?e=3*n+"px,"+3*n+"px":"longdash"===e?e=5*n+"px,"+5*n+"px":"dashdot"===e?e=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===e&&(e=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var r=i.select(this);try{r.call(s.fill,e[0].trace.fillcolor)}catch(n){console.log(n,t),r.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var r=e.marker,n=r.line;if(o.traceIs(e,"symbols")){var a=d(e);t.attr("d",function(t){var n;n="various"===t.ms||"various"===r.size?3:h.isBubble(e)?a(t.ms):(r.size||6)/2,t.mrc=n;var i=p.symbolNumber(t.mx||r.symbol)||0,o=i%100;return t.om=i%200>=100,p.symbolFuncs[o](n)+(i>=200?m:"")}).style("opacity",function(t){return(t.mo+1||r.opacity+1)-1})}var l=(e._input||{}).marker||{},c=p.tryColorscale(r,l,""),u=p.tryColorscale(r,l,"line.");t.each(function(t){var e,a,o;t.so?(o=n.outlierwidth,a=n.outliercolor,e=r.outliercolor):(o=(t.mlw+1||n.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,a="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(n.color)?s.defaultLine:n.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(r.color)?s.defaultLine:r.color||"rgba(0,0,0,0)");var l=i.select(this);t.om?l.call(s.stroke,e).style({"stroke-width":(o||1)+"px",fill:"none"}):(l.style("stroke-width",o+"px").call(s.fill,e),o&&l.call(s.stroke,a))})}},p.tryColorscale=function(t,e,r){var n=c.nestedProperty(t,r+"color").get(),i=c.nestedProperty(t,r+"colorscale").get(),o=c.nestedProperty(t,r+"cauto").get(),s=c.nestedProperty(t,r+"cmin"),u=c.nestedProperty(t,r+"cmax"),f=s.get(),h=u.get();return i&&Array.isArray(n)?(!o&&a(f)&&a(h)||(f=1/0,h=-(1/0),n.forEach(function(t){a(t)&&(f>t&&(f=+t),t>h&&(h=+t))}),f>h&&(f=0,h=1),s.set(f),u.set(h),c.nestedProperty(e,r+"cmin").set(f),c.nestedProperty(e,r+"cmax").set(h)),l.makeScaleFunction(i,f,h)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},b=1.3;p.textPointStyle=function(t,e){t.each(function(t){var r=i.select(this),n=t.tx||e.text;if(!n||Array.isArray(n))return void r.remove();var o=t.tp||e.textposition,s=-1!==o.indexOf("top")?"top":-1!==o.indexOf("bottom")?"bottom":"middle",l=-1!==o.indexOf("left")?"end":-1!==o.indexOf("right")?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=a(c)&&c>0?c:0,r.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",l).text(n).call(u.convertToTspans);var h=i.select(this.parentNode),d=r.selectAll("tspan.line"),g=((d[0].length||1)-1)*b+1,v=y[l]*f,m=.75*c+y[s]*f+(y[s]-1)*g*c/2;h.attr("transform","translate("+v+","+m+")"),g>1&&d.attr({x:r.attr("x"),y:r.attr("y")})})};var x=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,i="M"+t[0],a=[];for(r=1;rr;r++)o.push(n(t[r-1],t[r],t[r+1],e));for(o.push(n(t[a-1],t[a],t[0],e)),r=1;a>=r;r++)i+="C"+o[r-1][1]+" "+o[r][0]+" "+t[r];return i+="C"+o[a][1]+" "+o[0][0]+" "+t[0]+"Z"};var _={hv:function(t,e){return"H"+i.round(e[0],2)+"V"+i.round(e[1],2)},vh:function(t,e){return"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},hvh:function(t,e){return"H"+i.round((t[0]+e[0])/2,2)+"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},vhv:function(t,e){return"V"+i.round((t[1]+e[1])/2,2)+"H"+i.round(e[0],2)+"V"+i.round(e[1],2)}},w=function(t,e){return"L"+i.round(e[0],2)+","+i.round(e[1],2)};p.steps=function(t){var e=_[t]||w;return function(t){for(var r="M"+i.round(t[0][0],2)+","+i.round(t[0][1],2),n=1;n=A&&(i.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(l),c.extendFlat({},l)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var r="#"+e,n=i.select("base");n.size()&&n.attr("href")&&(r=window.location.href+r),t.attr("clip-path","url("+r+")")}},{"../../constants/xmlns_namespaces":360,"../../lib":372,"../../lib/svg_text_utils":384,"../../plots/plots":441,"../../traces/scatter/make_bubble_size_func":553,"../../traces/scatter/subtypes":559,"../color":297,"../colorscale":310,"./symbol_defs":320,d3:87,"fast-isnumeric":95}],320:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+","+r+"H"+e+"L0,-"+i+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+",-"+r+"H"+e+"L0,"+i+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M"+r+",-"+e+"V"+e+"L-"+i+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+r+",-"+e+"V"+e+"L"+i+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(t*-.309,2),o=n.round(.809*t,2);return"M"+e+","+a+"L"+r+","+o+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(e*-.309,2),c=n.round(.118*e,2),u=n.round(.809*e,2),f=n.round(.382*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+c+"L"+o+","+u+"L0,"+f+"L-"+o+","+u+"L-"+a+","+c+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:87}],321:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],322:[function(t,e,r){"use strict";function n(t,e,r,n){var a=e["error_"+n]||{},l=a.visible&&-1!==["linear","log"].indexOf(r.type),c=[];if(l){for(var u=s(a),f=0;fs;s++)o[s]={x:r[s],y:i[s]};return o[0].trace=t,n.calc({calcdata:[o],_fullLayout:e}),o},n.plot=t("./plot"),n.style=t("./style"),n.hoverInfo=function(t,e,r){(e.error_y||{}).visible&&(r.yerr=t.yh-t.y,e.error_y.symmetric||(r.yerrneg=t.y-t.ys)),(e.error_x||{}).visible&&(r.xerr=t.xh-t.x,e.error_x.symmetric||(r.xerrneg=t.x-t.xs))}},{"./attributes":321,"./calc":322,"./defaults":324,"./plot":326,"./style":327}],326:[function(t,e,r){"use strict";function n(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};return void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0))),void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0))),n}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),s=t("../../traces/scatter/subtypes");e.exports=function(t,e){var r=e.x(),l=e.y();t.each(function(t){var e=t[0].trace,c=e.error_x||{},u=e.error_y||{},f=s.hasMarkers(e)&&e.marker.maxdisplayed>0;if(u.visible||c.visible){var h=i.select(this).selectAll("g.errorbar").data(o.identity);h.enter().append("g").classed("errorbar",!0),h.each(function(t){var e=i.select(this),o=n(t,r,l);if(!f||t.vis){var s;if(u.visible&&a(o.x)&&a(o.yh)&&a(o.ys)){var h=u.width;s="M"+(o.x-h)+","+o.yh+"h"+2*h+"m-"+h+",0V"+o.ys,o.noYS||(s+="m-"+h+",0h"+2*h),e.append("path").classed("yerror",!0).attr("d",s)}if(c.visible&&a(o.y)&&a(o.xh)&&a(o.xs)){var d=(c.copy_ystyle?u:c).width;s="M"+o.xh+","+(o.y-d)+"v"+2*d+"m0,-"+d+"H"+o.xs,o.noXS||(s+="m0,-"+d+"v"+2*d),e.append("path").classed("xerror",!0).attr("d",s)}}})}})}},{"../../lib":372,"../../traces/scatter/subtypes":559,d3:87,"fast-isnumeric":95}],327:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":297,d3:87}],328:[function(t,e,r){"use strict";r.isRightAnchor=function(t){return"right"===t.xanchor||"auto"===t.xanchor&&t.x>=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],329:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:a({},n,{}),traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":367,"../../plots/font_attributes":411,"../color/attributes":296}],330:[function(t,e,r){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],331:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/plots"),a=t("./attributes"),o=t("./helpers");e.exports=function(t,e,r){function s(t,e){return n.coerce(l,c,a,t,e)}for(var l=t.legend||{},c=e.legend={},u=0,f="normal",h=0;h1);p!==!1&&(s("bgcolor",e.paper_bgcolor),s("bordercolor"),s("borderwidth"),n.coerceFont(s,"font",e.font),s("traceorder",f),o.isGrouped(e.legend)&&s("tracegroupgap"),s("x"),s("xanchor"),s("y"),s("yanchor"),n.noneOrAll(l,c,["x","y"]))}},{"../../lib":372,"../../plots/plots":441,"./attributes":329,"./helpers":334}],332:[function(t,e,r){"use strict";function n(t,e,r,n,o){function c(t){l.util.convertToTspans(t,function(){e.firstRender&&(i(e,o),a(e))}),t.selectAll("tspan.line").attr({x:t.attr("x")})}var f=e._fullLayout,d=r[0].trace,p=u.traceIs(d,"pie"),g=d.index,v=p?r[0].label:d.name,m=s.select(t).selectAll("text.legendtext").data([0]);m.enter().append("text").classed("legendtext",!0),m.attr({x:40,y:0,"data-unformatted":v}).style("text-anchor","start").classed("user-select-none",!0).call(h.font,f.legend.font).text(v),e._context.editable&&!p?m.call(l.util.makeEditable).call(c).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(c),this.text()||(t=" "),l.restyle(e,"name",t,g)}):m.call(c)}function i(t,e){var r=t._fullLayout,n=r.legend,i=n.borderwidth;n.width=0,n.height=0,e.each(function(t){var e,r,a=t[0].trace,o=s.select(this),l=o.selectAll(".legendtoggle"),c=o.selectAll(".legendtext"),u=o.selectAll(".legendtext>tspan"),f=1.3*n.font.size,d=u[0].length||1,p=c.node()&&h.bBox(c.node()).width,g=o.select("g[class*=math-group]");if(!a.showlegend)return void o.remove();if(g.node()){var v=h.bBox(g.node());f=v.height,p=v.width,g.attr("transform","translate(0,"+f/4+")")}else e=f*(.3+(1-d)/2),c.attr("y",e),u.attr("y",e);r=Math.max(f*d,16)+3,o.attr("transform","translate("+i+","+(5+i+n.height+r/2)+")"),l.attr({x:0,y:-r/2,height:r}),n.height+=r,n.width=Math.max(n.width,p||0)}),n.width+=45+2*i,n.height+=10+2*i,m.isGrouped(n)&&(n.height+=(n._lgroupsLength-1)*n.tracegroupgap),e.selectAll(".legendtoggle").attr("width",(t._context.editable?0:n.width)+40),n.width=Math.ceil(n.width),n.height=Math.ceil(n.height)}function a(t){var e=t._fullLayout,r=e.legend,n="left";y.isRightAnchor(r)?n="right":y.isCenterAnchor(r)&&(n="center");var i="top";y.isBottomAnchor(r)?i="bottom":y.isMiddleAnchor(r)&&(i="middle"),u.autoMargin(t,"legend",{ +x:r.x,y:r.y,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:r.height*({top:1,middle:.5}[i]||0),t:r.height*({bottom:1,middle:.5}[i]||0)})}function o(t){var e=t._fullLayout,r=e.legend,n="left";y.isRightAnchor(r)?n="right":y.isCenterAnchor(r)&&(n="center"),u.autoMargin(t,"legend",{x:r.x,y:.5,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:0,t:0})}var s=t("d3"),l=t("../../plotly"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../dragelement"),h=t("../drawing"),d=t("../color"),p=t("./constants"),g=t("./get_legend_data"),v=t("./style"),m=t("./helpers"),y=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e),T.attr("transform","translate(0, "+e+")"),E.call(h.setRect,x.width,t,p.scrollBarWidth,p.scrollBarHeight),A.select("rect").attr({y:x.borderwidth-e})}var r=t._fullLayout,b="legend"+r._uid;if(r._infolayer&&t.calcdata){var x=r.legend,_=r.showlegend&&g(t.calcdata,x),w=r.hiddenlabels||[];if(!r.showlegend||!_.length)return r._infolayer.selectAll(".legend").remove(),r._topdefs.select("#"+b).remove(),void u.autoMargin(t,"legend");"undefined"==typeof t.firstRender?t.firstRender=!0:t.firstRender&&(t.firstRender=!1);var k=r._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({"class":"legend","pointer-events":"all"});var A=r._topdefs.selectAll("#"+b).data([0]);A.enter().append("clipPath").attr("id",b).append("rect");var M=k.selectAll("rect.bg").data([0]);M.enter().append("rect").attr({"class":"bg","shape-rendering":"crispEdges"}).call(d.stroke,x.bordercolor).call(d.fill,x.bgcolor).style("stroke-width",x.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var E=k.selectAll("rect.scrollbar").data([0]);E.enter().append("rect").attr({"class":"scrollbar",rx:20,ry:2,width:0,height:0}).call(d.fill,"#808BA4");var L=T.selectAll("g.groups").data(_);L.enter().append("g").attr("class","groups"),L.exit().remove(),m.isGrouped(x)&&L.attr("transform",function(t,e){return"translate(0,"+e*x.tracegroupgap+")"});var S=L.selectAll("g.traces").data(c.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(v).style("opacity",function(t){var e=t[0].trace;return u.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(e,r){n(this,t,e,r,S);var i=s.select(this).selectAll("rect").data([0]);i.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(d.fill,"rgba(0,0,0,0)"),i.on("click",function(){if(!t._dragged){var r,n,i=t._fullData,a=e[0].trace,o=a.legendgroup,s=[];if(u.traceIs(a,"pie")){var c=e[0].label,f=w.slice(),h=f.indexOf(c);-1===h?f.push(c):f.splice(h,1),l.relayout(t,"hiddenlabels",f)}else{if(""===o)s=[a.index];else for(var d=0;dz?o(t):a(t);var P=r._size,R=P.l+P.w*x.x,O=P.t+P.h*(1-x.y);y.isRightAnchor(x)?R-=x.width:y.isCenterAnchor(x)&&(R-=x.width/2),y.isBottomAnchor(x)?O-=x.height:y.isMiddleAnchor(x)&&(O-=x.height/2);var I=x.height,N=P.h;I>N?(O=P.t,I=N):(O>z&&(O=z-I),C>O&&(O=C),I=Math.min(z-O,x.height)),k.attr("transform","translate("+R+","+O+")"),M.attr({width:x.width-x.borderwidth,height:I-x.borderwidth,x:x.borderwidth/2,y:x.borderwidth/2});var j=T.attr("data-scroll")||0;if(T.attr("transform","translate(0, "+j+")"),A.select("rect").attr({width:x.width-2*x.borderwidth,height:I-2*x.borderwidth,x:x.borderwidth-j,y:x.borderwidth}),T.call(h.setClipUrl,b),x.height-I>0&&!t._context.staticPlot){M.attr({width:x.width-2*x.borderwidth+p.scrollBarWidth+p.scrollBarMargin}),A.select("rect").attr({width:x.width-2*x.borderwidth+p.scrollBarWidth+p.scrollBarMargin}),t.firstRender&&e(p.scrollBarMargin,0);var F=I-p.scrollBarHeight-2*p.scrollBarMargin,B=x.height-I,D=p.scrollBarMargin,U=0;e(D,U),k.on("wheel",null),k.on("wheel",function(){U=c.constrain(T.attr("data-scroll")-s.event.deltaY/F*B,-B,0),D=p.scrollBarMargin-U/B*F,e(D,U),s.event.preventDefault()}),E.on(".drag",null),T.on(".drag",null);var V=s.behavior.drag().on("drag",function(){D=c.constrain(s.event.y-p.scrollBarHeight/2,p.scrollBarMargin,p.scrollBarMargin+F),U=-(D-p.scrollBarMargin)/F*B,e(D,U)});E.call(V),T.call(V)}if(t._context.editable){var q,H,G,Y;k.classed("cursor-move",!0),f.init({element:k.node(),prepFn:function(){var t=c.getTranslate(k);G=t.x,Y=t.y},moveFn:function(t,e){var r=G+t,n=Y+e,i="translate("+r+", "+n+")";k.attr("transform",i),q=f.align(r,0,P.l,P.l+P.w,x.xanchor),H=f.align(n,0,P.t+P.h,P.t,x.yanchor)},doneFn:function(e){e&&void 0!==q&&void 0!==H&&l.relayout(t,{"legend.x":q,"legend.y":H})}})}}}},{"../../lib":372,"../../plotly":390,"../../plots/plots":441,"../color":297,"../dragelement":317,"../drawing":319,"./anchor_utils":328,"./constants":330,"./get_legend_data":333,"./helpers":334,"./style":336,d3:87}],333:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("./helpers");e.exports=function(t,e){function r(t,r){if(""!==t&&i.isGrouped(e))-1===l.indexOf(t)?(l.push(t),c=!0,s[t]=[[r]]):s[t].push([r]);else{var n="~~i"+f;l.push(n),s[n]=[[r]],f++}}var a,o,s={},l=[],c=!1,u={},f=0;for(a=0;aa;a++)m=s[l[a]],y[a]=i.isReversed(e)?m.reverse():m;else{for(y=[new Array(b)],a=0;b>a;a++)m=s[l[a]][0],y[0][i.isReversed(e)?b-a-1:a]=m;b=1}return e._lgroupsLength=b,y}},{"../../plots/plots":441,"./helpers":334}],334:[function(t,e,r){"use strict";var n=t("../../plots/plots");r.legendGetsTrace=function(t){return t.visible&&n.traceIs(t,"showLegend")},r.isGrouped=function(t){return-1!==(t.traceorder||"").indexOf("grouped")},r.isReversed=function(t){return-1!==(t.traceorder||"").indexOf("reversed")}},{"../../plots/plots":441}],335:[function(t,e,r){"use strict";var n=e.exports={};n.layoutAttributes=t("./attributes"),n.supplyLayoutDefaults=t("./defaults"),n.draw=t("./draw"),n.style=t("./style")},{"./attributes":329,"./defaults":331,"./draw":332,"./style":336}],336:[function(t,e,r){"use strict";function n(t){var e=t[0].trace,r=e.visible&&e.fill&&"none"!==e.fill,n=d.hasLines(e),i=l.select(this).select(".legendfill").selectAll("path").data(r?[t]:[]);i.enter().append("path").classed("js-fill",!0),i.exit().remove(),i.attr("d","M5,0h30v6h-30z").call(f.fillGroupStyle);var a=l.select(this).select(".legendlines").selectAll("path").data(n?[t]:[]);a.enter().append("path").classed("js-line",!0).attr("d","M5,0h30"),a.exit().remove(),a.call(f.lineGroupStyle)}function i(t){function e(t,e,r){var n=c.nestedProperty(o,t).get(),i=Array.isArray(n)&&e?e(n):n;if(r){if(ir[1])return r[1]}return i}function r(t){return t[0]}var n,i,a=t[0],o=a.trace,s=d.hasMarkers(o),u=d.hasText(o),h=d.hasLines(o);if(s||u||h){var p={},g={};s&&(p.mc=e("marker.color",r),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",r),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),h&&(g.line={width:e("line.width",r,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",r),p.ts=10,p.tc=e("textfont.color",r),p.tf=e("textfont.family",r)),n=[c.minExtend(a,p)],i=c.minExtend(o,g)}var v=l.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(s?n:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,i),s&&(n[0].mrc=3);var y=v.selectAll("g.pointtext").data(u?n:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,i)}function a(t){var e=t[0].trace,r=e.marker||{},n=r.line||{},i=l.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);i.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),i.exit().remove(),i.each(function(t){var e=(t.mlw+1||n.width+1)-1,i=l.select(this);i.style("stroke-width",e+"px").call(h.fill,t.mc||r.color),e&&i.call(h.stroke,t.mlc||n.color)})}function o(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);r.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.each(function(t){var r=(t.lw+1||e.line.width+1)-1,n=l.select(this);n.style("stroke-width",r+"px").call(h.fill,t.fc||e.fillcolor),r&&n.call(h.stroke,t.lc||e.line.color)})}function s(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);r.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.size()&&r.call(p,t[0],e)}var l=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),h=t("../color"),d=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=l.select(this),r=e.selectAll("g.legendfill").data([t]);r.enter().append("g").classed("legendfill",!0);var n=e.selectAll("g.legendlines").data([t]);n.enter().append("g").classed("legendlines",!0);var i=e.selectAll("g.legendsymbols").data([t]);i.enter().append("g").classed("legendsymbols",!0),i.style("opacity",t[0].trace.opacity),i.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(a).each(o).each(s).each(n).each(i)}},{"../../lib":372,"../../plots/plots":441,"../../traces/pie/style_one":538,"../../traces/scatter/subtypes":559,"../color":297,"../drawing":319,d3:87}],337:[function(t,e,r){"use strict";function n(t,e){var r=e.currentTarget,n=r.getAttribute("data-attr"),i=r.getAttribute("data-val")||!0,a=t._fullLayout,o={};if("zoom"===n){for(var s,l,u="in"===i?.5:2,h=(1+u)/2,d=(1-u)/2,p=c.Axes.list(t,null,!0),v=0;vy;y++){var b=s[y];h=m[b]={};for(var x=0;x1)return n(["resetViews","toggleHover"]),o(v,r);u&&(n(["zoom3d","pan3d","orbitRotation","tableRotation"]),n(["resetCameraDefault3d","resetCameraLastSave3d"]),n(["hoverClosest3d"])),h&&(n(["zoomInGeo","zoomOutGeo","resetGeo"]),n(["hoverClosestGeo"]));var m=i(s),y=[];return((c||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(c||g)&&a(l)&&(y.push("select2d"),y.push("lasso2d")),y.length&&n(y),!c&&!p||m||g||n(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&d?n(["toggleHover"]):p?n(["hoverClosestGl2d"]):c?n(["hoverClosestCartesian","hoverCompareCartesian"]):d&&n(["hoverClosestPie"]),o(v,r)}function i(t){for(var e=l.Axes.list({_fullLayout:t},null,!0),r=!0,n=0;n0);if(h){var d=i(e,r,s);l("x",d[0]),l("y",d[1]),a.noneOrAll(t,e,["x","y"]),l("xanchor"),l("yanchor"),a.coerceFont(l,"font",r.font),l("bgcolor"),l("bordercolor"),l("borderwidth")}}},{"../../lib":372,"./attributes":340,"./button_attributes":341,"./constants":342}],344:[function(t,e,r){"use strict";function n(t){for(var e=m.list(t,"x",!0),r=[],n=0;nr){var i=r;r=e,e=i}s.setAttributes(x,{"data-min":e,"data-max":r}),s.setAttributes(z,{x:e,width:r-e}),s.setAttributes(k,{width:e}),s.setAttributes(A,{x:r,width:h-r}),s.setAttributes(M,{transform:"translate("+(e-p-1)+")"}),s.setAttributes(L,{transform:"translate("+r+")"});var o=f.range[0],l=f.range[1],c=l-o,u=e/h*c+o,d=r/h*c+o;window.requestAnimationFrame?window.requestAnimationFrame(function(){n.relayout(t,"xaxis.range",[u,d])}):setTimeout(function(){n.relayout(t,"xaxis.range",[u,d])},16)}var c=t._fullLayout,u=c._infolayer.selectAll("g.range-slider"),f=c.xaxis.rangeslider,h=c._size.w,d=(c.height-c.margin.b-c.margin.t)*f.thickness,p=2,g=Math.floor(f.borderwidth/2),v=c.margin.l,m=c.height-d-c.margin.b,y=0,b=h,x=document.createElementNS(o,"g");s.setAttributes(x,{"class":"range-slider","data-min":y,"data-max":b,"pointer-events":"all",transform:"translate("+v+","+m+")"});var _=document.createElementNS(o,"rect"),w=f.borderwidth%2===0?f.borderwidth:f.borderwidth-1;s.setAttributes(_,{fill:f.bgcolor,stroke:f.bordercolor,"stroke-width":f.borderwidth,height:d+w,width:h+w,transform:"translate(-"+g+", -"+g+")","shape-rendering":"crispEdges"});var k=document.createElementNS(o,"rect");s.setAttributes(k,{x:0,width:y,height:d,fill:"rgba(0,0,0,0.4)"});var A=document.createElementNS(o,"rect");s.setAttributes(A,{x:b,width:h-b,height:d,fill:"rgba(0,0,0,0.4)"});var M=document.createElementNS(o,"g"),T=document.createElementNS(o,"rect"),E=document.createElementNS(o,"rect");s.setAttributes(M,{transform:"translate("+(y-p-1)+")"}),s.setAttributes(T,{width:10,height:d,x:-6,fill:"transparent",cursor:"col-resize"}),s.setAttributes(E,{width:p,height:d/2,y:d/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(M,[E,T]);var L=document.createElementNS(o,"g"),S=document.createElementNS(o,"rect"),C=document.createElementNS(o,"rect");s.setAttributes(L,{transform:"translate("+b+")"}),s.setAttributes(S,{width:10,height:d,x:-2,fill:"transparent",cursor:"col-resize"}),s.setAttributes(C,{width:p,height:d/2,y:d/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(L,[C,S]);var z=document.createElementNS(o,"rect"); +s.setAttributes(z,{x:y,width:b-y,height:d,cursor:"ew-resize",fill:"transparent"}),x.addEventListener("mousedown",function(t){function e(t){var e=+t.clientX-a;switch(i){case z:x.style.cursor="ew-resize",r(+l+e,+s+e);break;case T:x.style.cursor="col-resize",r(+s+e,+l);break;case S:x.style.cursor="col-resize",r(+s,+l+e);break;default:x.style.cursor="ew-resize",r(o,o+e)}}function n(){window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",n),x.style.cursor="auto"}var i=t.target,a=t.clientX,o=a-x.getBoundingClientRect().left,s=x.getAttribute("data-min"),l=x.getAttribute("data-max");window.addEventListener("mousemove",e),window.addEventListener("mouseup",n)}),f.range||(f.range=i.getAutoRange(c.xaxis));var P=l(t,h,d);s.appendChildren(x,[_,P,k,A,z,M,L]),e(c.xaxis.range[0],c.xaxis.range[1]),u.data([0]).enter().append(function(){return f.setRange=e,x})}},{"../../constants/xmlns_namespaces":360,"../../lib":372,"../../plotly":390,"../../plots/cartesian/axes":393,"./helpers":350,"./range_plot":352}],349:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(t,e){return n.coerce(s,l,i,t,e)}if(t[r].rangeslider){var s="object"==typeof t[r].rangeslider?t[r].rangeslider:{},l=e[r].rangeslider={};if(o("bgcolor"),o("bordercolor"),o("borderwidth"),o("thickness"),o("visible"),o("range"),l.range&&!e[r].autorange){var c=l.range,u=e[r].range;c[0]=Math.min(c[0],u[0]),c[1]=Math.max(c[1],u[1])}else e[r]._needsExpand=!0;l.visible&&a.forEach(function(t){var r=e[t]||{};r.fixedrange=!0,e[t]=r})}}},{"../../lib":372,"./attributes":347}],350:[function(t,e,r){"use strict";r.setAttributes=function(t,e){for(var r in e)t.setAttribute(r,e[r])},r.appendChildren=function(t,e){for(var r=0;rl;l++){var c=s[l],u={_fullLayout:e},f=x.coerceRef(t,n,u,c);if("path"!==o){var h=.25,d=.75;if("paper"!==f){var p=x.getFromId(u,f),g=a(p);h=g(p.range[0]+h*(p.range[1]-p.range[0])),d=g(p.range[0]+d*(p.range[1]-p.range[0]))}r(c+"0",h),r(c+"1",d)}}return"path"===o?r("path"):b.noneOrAll(t,n,["x0","x1","y0","y1"]),n}function i(t){return"category"===t.type?t.c2l:t.d2l}function a(t){return"category"===t.type?t.l2c:t.l2d}function o(t,e){t.layout.shapes=e,k.supplyLayoutDefaults(t.layout,t._fullLayout),k.drawAll(t)}function s(t){delete t.layout.shapes,t._fullLayout.shapes=[],k.drawAll(t)}function l(t,e,r){for(var n=0;ne;i--)h(t,i).selectAll('[data-index="'+(i-1)+'"]').attr("data-index",i),k.draw(t,i)}function f(t,e,r,o){function s(e){var r=e.append("path").attr(z).style("opacity",S.opacity).call(_.stroke,P).call(_.fill,S.fillcolor).call(w.dashLine,S.line.dash,S.line.width);C&&r.call(w.setClipUrl,"clip"+t._fullLayout._uid+C)}var l,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},p={};"string"==typeof r&&r?p[r]=o:b.isPlainObject(r)&&(p=r);var v=Object.keys(p);for(l=0;ll;l++){var k=y[l];if(void 0===p[k]&&void 0!==u[k]){var A,M=k.charAt(0),T=x.getFromId(t,x.coerceRef(f,{},t,M)),E=x.getFromId(t,x.coerceRef(u,{},t,M)),L=u[k];void 0!==p[M+"ref"]&&(T?(A=i(T)(L),L=(A-T.range[0])/(T.range[1]-T.range[0])):L=(L-E.domain[0])/(E.domain[1]-E.domain[0]),E?(A=E.range[0]+L*(E.range[1]-E.range[0]),L=a(E)(A)):L=T.domain[0]+L*(T.domain[1]-T.domain[0])),u[k]=L}}var S=n(u,t._fullLayout);t._fullLayout.shapes[e]=S;var C,z={"data-index":e,"fill-rule":"evenodd",d:g(t,S)},P=S.line.width?S.line.color:"rgba(0,0,0,0)";if("below"!==S.layer)C=(S.xref+S.yref).replace(/paper/g,""),s(t._fullLayout._shapeUpperLayer);else if("paper"===S.xref&&"paper"===S.yref)C="",s(t._fullLayout._shapeLowerLayer);else{var R,O=t._fullLayout._plots||{},I=Object.keys(O);for(l=0,c=I.length;c>l;l++)R=O[I[l]],C=I[l],d(t,S,R.id)&&s(R.shapelayer)}}}function h(t,e){var r=t._fullLayout.shapes[e],n=t._fullLayout._shapeUpperLayer;return r?"below"===r.layer&&(n="paper"===r.xref&&"paper"===r.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._subplotShapeLayer):console.log("getShapeLayer: undefined shape: index",e),n}function d(t,e,r){var n=y.Axes.getFromId(t,r,"x")._id,i=y.Axes.getFromId(t,r,"y")._id;return"below"===e.layer&&(n===e.xref||i===e.yref)}function p(t){return function(e){return t(e.replace("_"," "))}}function g(t,e){var r,n,a,o,s=e.type,l=x.getFromId(t,e.xref),c=x.getFromId(t,e.yref),u=t._fullLayout._size;if(l?(r=i(l),n=function(t){return l._offset+l.l2p(r(t,!0))}):n=function(t){return u.l+u.w*t},c?(a=i(c),o=function(t){return c._offset+c.l2p(a(t,!0))}):o=function(t){return u.t+u.h*(1-t)},"path"===s)return l&&"date"===l.type&&(n=p(n)),c&&"date"===c.type&&(o=p(o)),k.convertPath(e.path,n,o);var f=n(e.x0),h=n(e.x1),d=o(e.y0),g=o(e.y1);if("line"===s)return"M"+f+","+d+"L"+h+","+g;if("rect"===s)return"M"+f+","+d+"H"+h+"V"+g+"H"+f+"Z";var v=(f+h)/2,m=(d+g)/2,y=Math.abs(v-f),b=Math.abs(m-d),_="A"+y+","+b,w=v+y+","+m,A=v+","+(m-b);return"M"+w+_+" 0 1,1 "+A+_+" 0 0,1 "+w+"Z"}function v(t,e,r,n,i){var a="category"===t.type?Number:t.d2c;if(void 0!==e)return[a(e),a(r)];if(n){var o,s,l,c,u,f=1/0,h=-(1/0),d=n.match(A);for("date"===t.type&&(a=p(a)),o=0;ou&&(f=u),u>h&&(h=u)));return h>=f?[f,h]:void 0}}var m=t("fast-isnumeric"),y=t("../../plotly"),b=t("../../lib"),x=t("../../plots/cartesian/axes"),_=t("../color"),w=t("../drawing"),k=e.exports={};k.layoutAttributes=t("./attributes"),k.supplyLayoutDefaults=function(t,e){for(var r=t.shapes||[],i=e.shapes=[],a=0;as&&(t="X"),t});return n>s&&(l=l.replace(/[\s,]*X.*/,""),console.log("ignoring extra params in segment "+t)),i+l})},k.calcAutorange=function(t){var e,r,n,i,a,o=t._fullLayout,s=o.shapes;if(s.length&&t._fullData.length)for(e=0;eh?r=h:(u.left-=b.offsetLeft,u.right-=b.offsetLeft,u.top-=b.offsetTop,u.bottom-=b.offsetTop,b.selection.each(function(){var t=l.bBox(this);s.bBoxIntersect(u,t,c)&&(r=Math.max(r,o*(t[b.side]-u[a])+c))}),r=Math.min(h,r)),r>0||0>h){var d={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[b.side];e.attr("transform","translate("+d+")")}}}function p(){E=0,L=!0,S=z,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)})}var g=r.propContainer,v=r.propName,m=r.traceIndex,y=r.dfltName,b=r.avoid||{},x=r.attributes,_=r.transform,w=r.containerGroup,k=t._fullLayout,A=g.titlefont.family,M=g.titlefont.size,T=g.titlefont.color,E=1,L=!1,S=g.title.trim();""===S&&(E=0),S.match(/Click to enter .+ title/)&&(E=.2,L=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var z="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==m?a.restyle(t,v,e,m):a.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(x).selectAll("tspan.line").attr(x)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",L)}},{"../../lib":372,"../../lib/svg_text_utils":384,"../../plotly":390,"../../plots/plots":441,"../color":297,"../drawing":319,d3:87,"fast-isnumeric":95}],356:[function(t,e,r){"use strict";var n=e.exports={};n.projNames={equirectangular:"equirectangular",mercator:"mercator",orthographic:"orthographic","natural earth":"naturalEarth",kavrayskiy7:"kavrayskiy7",miller:"miller",robinson:"robinson",eckert4:"eckert4","azimuthal equal area":"azimuthalEqualArea","azimuthal equidistant":"azimuthalEquidistant","conic equal area":"conicEqualArea","conic conformal":"conicConformal","conic equidistant":"conicEquidistant",gnomonic:"gnomonic",stereographic:"stereographic",mollweide:"mollweide",hammer:"hammer","transverse mercator":"transverseMercator","albers usa":"albersUsa"},n.axesNames=["lonaxis","lataxis"],n.lonaxisSpan={orthographic:180,"azimuthal equal area":360,"azimuthal equidistant":360,"conic conformal":180,gnomonic:160,stereographic:180,"transverse mercator":180,"*":360},n.lataxisSpan={"conic conformal":150,stereographic:179.5,"*":180},n.scopeDefaults={world:{lonaxisRange:[-180,180],lataxisRange:[-90,90],projType:"equirectangular",projRotate:[0,0,0]},usa:{lonaxisRange:[-180,-50],lataxisRange:[15,80],projType:"albers usa"},europe:{lonaxisRange:[-30,60],lataxisRange:[30,80],projType:"conic conformal",projRotate:[15,0,0],projParallels:[0,60]},asia:{lonaxisRange:[22,160],lataxisRange:[-15,55],projType:"mercator",projRotate:[0,0,0]},africa:{lonaxisRange:[-30,60],lataxisRange:[-40,40],projType:"mercator",projRotate:[0,0,0]},"north america":{lonaxisRange:[-180,-45],lataxisRange:[5,85],projType:"conic conformal",projRotate:[-100,0,0],projParallels:[29.5,45.5]},"south america":{lonaxisRange:[-100,-30],lataxisRange:[-60,15],projType:"mercator",projRotate:[0,0,0]}},n.clipPad=.001,n.precision=.1,n.landColor="#F0DC82",n.waterColor="#3399FF",n.locationmodeToLayer={"ISO-3":"countries","USA-states":"subunits","country names":"countries"},n.sphereSVG={type:"Sphere"},n.fillLayers=["ocean","land","lakes"],n.lineLayers=["subunits","countries","coastlines","rivers","frame"],n.baseLayers=["ocean","land","lakes","subunits","countries","coastlines","rivers","lataxis","lonaxis","frame"],n.layerNameToAdjective={ocean:"ocean",land:"land",lakes:"lake",subunits:"subunit",countries:"country",coastlines:"coastline",rivers:"river",frame:"frame"},n.baseLayersOverChoropleth=["rivers","lakes"]},{}],357:[function(t,e,r){"use strict";e.exports={solid:[1],dot:[1,1],dash:[4,1],longdash:[8,1],dashdot:[4,1,1,1],longdashdot:[8,1,1,1]}},{}],358:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],359:[function(t,e,r){"use strict";e.exports={circle:"\u25cf","circle-open":"\u25cb",square:"\u25a0","square-open":"\u25a1",diamond:"\u25c6","diamond-open":"\u25c7",cross:"+",x:"\u274c"}},{}],360:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],361:[function(t,e,r){"use strict";var n=t("./plotly");r.version="1.10.1",r.plot=n.plot,r.newPlot=n.newPlot,r.restyle=n.restyle,r.relayout=n.relayout,r.redraw=n.redraw,r.extendTraces=n.extendTraces,r.prependTraces=n.prependTraces,r.addTraces=n.addTraces,r.deleteTraces=n.deleteTraces,r.moveTraces=n.moveTraces,r.purge=n.purge,r.setPlotConfig=t("./plot_api/set_plot_config"),r.register=n.register,r.Icons=t("../build/ploticon"),r.Plots=n.Plots,r.Fx=n.Fx,r.Snapshot=n.Snapshot,r.PlotSchema=n.PlotSchema,r.Queue=n.Queue,r.d3=t("d3")},{"../build/ploticon":2,"./plot_api/set_plot_config":389,"./plotly":390,d3:87}],362:[function(t,e,r){"use strict";"undefined"!=typeof MathJax?(r.MathJax=!0,MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:!0,displayAlign:"left",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]}}),MathJax.Hub.Configured()):r.MathJax=!1},{}],363:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){Array.isArray(t)&&(e[r]=t[n])}},{}],364:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("./nested_property"),o=t("../components/colorscale/get_scale"),s=(Object.keys(t("../components/colorscale/scales")),/^([2-9]|[1-9][0-9]+)$/);r.valObjects={data_array:{coerceFunction:function(t,e,r){Array.isArray(t)?e.set(t):void 0!==r&&e.set(r)}},enumerated:{coerceFunction:function(t,e,r,n){n.coerceNumber&&(t=+t),-1===n.values.indexOf(t)?e.set(r):e.set(t)}},"boolean":{coerceFunction:function(t,e,r){t===!0||t===!1?e.set(t):e.set(r)}},number:{coerceFunction:function(t,e,r,i){!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if(n.strict===!0&&"string"!=typeof t)return void e.set(r);var i=String(t);void 0===t||n.noBlank===!0&&!i?e.set(r):e.set(i)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r){var n=r.length;return"string"==typeof t&&t.substr(0,n)===r&&s.test(t.substr(n))?void e.set(t):void e.set(r)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"!=typeof t)return void e.set(r);if(-1!==n.extras.indexOf(t))return void e.set(t);for(var i=t.split("+"),a=0;a2)return!1;var l=o[0].split("-");if(l.length>3||3!==l.length&&o[1])return!1;if(4===l[0].length)r=Number(l[0]);else{if(2!==l[0].length)return!1;var c=(new Date).getFullYear();r=((Number(l[0])-c+70)%100+200)%100+c-70}return s(r)?1===l.length?new Date(r,0,1).getTime():(n=Number(l[1])-1,l[1].length>2||!(n>=0&&11>=n)?!1:2===l.length?new Date(r,n,1).getTime():(i=Number(l[2]),l[2].length>2||!(i>=1&&31>=i)?!1:(i=new Date(r,n,i).getTime(),o[1]?(l=o[1].split(":"),l.length>3?!1:(a=Number(l[0]),l[0].length>2||!(a>=0&&23>=a)?!1:(i+=36e5*a,1===l.length?i:(n=Number(l[1]),l[1].length>2||!(n>=0&&59>=n)?!1:(i+=6e4*n,2===l.length?i:(t=Number(l[2]),t>=0&&60>t?i+1e3*t:!1)))))):i))):!1},r.isDateTime=function(t){return r.dateTime2ms(t)!==!1},r.ms2DateTime=function(t,e){if("undefined"==typeof o)return void console.log("d3 is not defined");e||(e=0);var r=new Date(t),i=o.time.format("%Y-%m-%d")(r);return 7776e6>e?(i+=" "+n(r.getHours(),2),432e6>e&&(i+=":"+n(r.getMinutes(),2),108e5>e&&(i+=":"+n(r.getSeconds(),2),3e5>e&&(i+="."+n(r.getMilliseconds(),3)))),i.replace(/([:\s]00)*\.?[0]*$/,"")):i};var l={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},c={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},u=o.time.format.utc,f={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(u),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(u)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(u)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){c[t].forEach(function(e){f[t].D.push(u(e)),["H","I","D"].forEach(function(r){l[r].forEach(function(n){var i=f[t][r];i.push(u(e+"~"+n)),i.push(u(n+"~"+e))})})})});var h=/[a-z]*/g,d=function(t){return t.substr(0,3)},p=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,g=/[\s,\/\-\.\(\)]+/g,v=/~?([ap])~?m(~|$)/,m=function(t,e){return e+"m "},y=/\d\d\d\d/,b=/(^|~)[a-z]{3}/,x=/[ap]m/,_=/:/,w=/q([1-4])/,k=["31~mar","30~jun","30~sep","31~dec"],A=function(t,e){return k[e-1]},M=/ ?([+\-]\d\d:?\d\d|Z)$/;r.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(h,d).replace(p,"").replace(g,"~").replace(v,m).replace(w,A).trim().replace(M,"");var e,r,n=null,o=i(t),s=a(t);e=f[o][s],r=e.length;for(var l=0;r>l&&!(n=e[l].parse(t));l++);if(!(n instanceof Date))return!1;var c=n.getTimezoneOffset();return n.setTime(n.getTime()+60*c*1e3),n}},{d3:87,"fast-isnumeric":95}],366:[function(t,e,r){"use strict";var n=t("events").EventEmitter,i={init:function(t){if(t._ev instanceof n)return t;var e=new n;return t._ev=e,t.on=e.on.bind(e),t.once=e.once.bind(e),t.removeListener=e.removeListener.bind(e),t.removeAllListeners=e.removeAllListeners.bind(e),t.emit=function(r,n){"undefined"!=typeof jQuery&&jQuery(t).trigger(r,n),e.emit(r,n)},t},triggerHandler:function(t,e,r){var n,i;"undefined"!=typeof jQuery&&(n=jQuery(t).triggerHandler(e,r));var a=t._ev;if(!a)return n;var o=a._events[e];if(!o)return n;"function"==typeof o&&(o=[o]);for(var s=o.pop(),l=0;lp;p++){o=t[p];for(s in o)l=h[s],c=o[s],e&&c&&(i(c)||(u=a(c)))?(u?(u=!1,f=l&&a(l)?l:[]):f=l&&i(l)?l:{},h[s]=n([f,c],e,r)):("undefined"!=typeof c||r)&&(h[s]=c)}return h}var i=t("./is_plain_object.js"),a=Array.isArray;r.extendFlat=function(){return n(arguments,!1,!1)},r.extendDeep=function(){return n(arguments,!0,!1)},r.extendDeepAll=function(){return n(arguments,!0,!0)}},{"./is_plain_object.js":373}],368:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=0;ry;y++)f=s(p,y),d=l(e,y),m[y]=n(f,d);else m=n(p,e);return m}var s=t("tinycolor2"),l=t("fast-isnumeric"),c=t("../components/colorscale/make_scale_function"),u=t("../components/color/attributes").defaultLine,f=t("./str2rgbarray"),h=1;e.exports=o},{"../components/color/attributes":296,"../components/colorscale/make_scale_function":313,"./str2rgbarray":383,"fast-isnumeric":95,tinycolor2:275}],371:[function(t,e,r){"use strict";function n(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(e>r)break;t=t.slice(0,e)+l(t.slice(e+5,r))+t.slice(r+6)}return t}function i(t){return t.replace(/\/g,"\n")}function a(t){return t.replace(/\<.*\>/g,"")}function o(t){for(var e=0;(e=t.indexOf("&",e))>=0;){var r=t.indexOf(";",e);if(e>r)e+=1;else{var n=c[t.slice(e+1,r)];t=n?t.slice(0,e)+n+t.slice(r+1):t.slice(0,e)+t.slice(r+1)}}return t}function s(t){return""+o(a(n(i(t))))}var l=t("superscript-text"),c={mu:"\u03bc",amp:"&",lt:"<",gt:">"};e.exports=s},{"superscript-text":272}],372:[function(t,e,r){"use strict";var n=t("d3"),i=e.exports={};i.nestedProperty=t("./nested_property"),i.isPlainObject=t("./is_plain_object");var a=t("./coerce");i.valObjects=a.valObjects,i.coerce=a.coerce,i.coerce2=a.coerce2,i.coerceFont=a.coerceFont;var o=t("./dates");i.dateTime2ms=o.dateTime2ms,i.isDateTime=o.isDateTime,i.ms2DateTime=o.ms2DateTime,i.parseDate=o.parseDate;var s=t("./search");i.findBin=s.findBin,i.sorterAsc=s.sorterAsc,i.sorterDes=s.sorterDes,i.distinctVals=s.distinctVals,i.roundUp=s.roundUp;var l=t("./stats");i.aggNums=l.aggNums,i.len=l.len,i.mean=l.mean,i.variance=l.variance,i.stdev=l.stdev,i.interp=l.interp;var c=t("./matrix");i.init2dArray=c.init2dArray,i.transposeRagged=c.transposeRagged,i.dot=c.dot,i.translationMatrix=c.translationMatrix,i.rotationMatrix=c.rotationMatrix,i.rotationXYMatrix=c.rotationXYMatrix,i.apply2DTransform=c.apply2DTransform,i.apply2DTransform2=c.apply2DTransform2;var u=t("./extend");i.extendFlat=u.extendFlat,i.extendDeep=u.extendDeep,i.extendDeepAll=u.extendDeepAll,i.notifier=t("./notifier"),i.swapAttrs=function(t,e,r,n){r||(r="x"),n||(n="y");for(var a=0;ar?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},i.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},i.identity=function(t){return t},i.randstr=function f(t,e,r){if(r||(r=16),void 0===e&&(e=24),0>=e)return"0";var n,i,a,o=Math.log(Math.pow(2,e))/Math.log(r),s="";for(n=2;o===1/0;n*=2)o=Math.log(Math.pow(2,e/n))/Math.log(r)*n;var l=o-Math.floor(o);for(n=0;n-1||c!==1/0&&c>=Math.pow(2,e)?f(t,e,r):s},i.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={};return r.optionList=[],r._newoption=function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)},r["_"+e]=t,r},i.smooth=function(t,e){if(e=Math.round(e)||0,2>e)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,c=new Array(l),u=new Array(o);for(r=0;l>r;r++)c[r]=(1-Math.cos(Math.PI*(r+1)/e))/(2*e);for(r=0;o>r;r++){for(a=0,n=0;l>n;n++)i=r+n+1-e,-o>i?i-=s*Math.round(i/s):i>=s&&(i-=s*Math.floor(i/s)),0>i?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*c[n];u[r]=a}return u},i.promiseError=function(t){console.log(t,t.stack)},i.syncOrAsync=function(t,e,r){function n(){return i.markTime("async done "+o.name),i.syncOrAsync(t,e,r)}for(var a,o;t.length;){if(o=t.splice(0,1)[0],a=o(e),a&&a.then)return a.then(n).then(void 0,i.promiseError);i.markTime("sync done "+o.name)}return r&&r(e)},i.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},i.noneOrAll=function(t,e,r){if(t){var n,i,a=!1,o=!0;for(n=0;ni;i++)e[i][r]=t[i]},i.minExtend=function(t,e){var r={};"object"!=typeof e&&(e={});var n,a,o,s=3,l=Object.keys(t);for(n=0;nn;n++)r[n]=new Array(e);return r},r.transposeRagged=function(t){var e,r,n=0,i=t.length;for(e=0;i>e;e++)n=Math.max(n,t[e].length);var a=new Array(n);for(e=0;n>e;e++)for(a[e]=new Array(i),r=0;i>r;r++)a[e][r]=t[r][e];return a},r.dot=function(t,e){if(!t.length||!e.length||t.length!==e.length)return null;var n,i,a=t.length;if(t[0].length)for(n=new Array(a),i=0;a>i;i++)n[i]=r.dot(t[i],e);else if(e[0].length){var o=r.transposeRagged(e);for(n=new Array(o.length),i=0;ii;i++)n+=t[i]*e[i];return n},r.translationMatrix=function(t,e){return[[1,0,t],[0,1,e],[0,0,1]]},r.rotationMatrix=function(t){var e=t*Math.PI/180;return[[Math.cos(e),-Math.sin(e),0],[Math.sin(e),Math.cos(e),0],[0,0,1]]},r.rotationXYMatrix=function(t,e,n){return r.dot(r.dot(r.translationMatrix(e,n),r.rotationMatrix(t)),r.translationMatrix(-e,-n))},r.apply2DTransform=function(t){return function(){var e=arguments;3===e.length&&(e=e[0]);var n=1===arguments.length?e[0]:[e[0],e[1]];return r.dot(t,[n[0],n[1],1]).slice(0,2)}},r.apply2DTransform2=function(t){var e=r.apply2DTransform(t);return function(t){return e(t.slice(0,2)).concat(e(t.slice(2,4)))}}},{}],375:[function(t,e,r){"use strict";function n(t,e){return function(){var r,i,a,o,s,l=t;for(o=0;o=0;e--){if(n=t[e],o=!1,Array.isArray(n))for(r=n.length-1;r>=0;r--)c(n[r])?o?n[r]=void 0:n.pop():o=!0;else if("object"==typeof n&&null!==n)for(a=Object.keys(n),o=!1,r=a.length-1;r>=0;r--)c(n[a[r]])&&!i(n[a[r]],a[r])?delete n[a[r]]:o=!0;if(o)return}}function c(t){return void 0===t||null===t?!0:"object"!=typeof t?!1:Array.isArray(t)?!t.length:!Object.keys(t).length}function u(t,e,r){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:r,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,l=e.split(".");sr||r>a||o>n||n>s?!1:!e||!c(t)}function r(t,e){var r=t[0],l=t[1];if(i>r||r>a||o>l||l>s)return!1;var c,u,f,h,d,p=n.length,g=n[0][0],v=n[0][1],m=0;for(c=1;p>c;c++)if(u=g,f=v,g=n[c][0],v=n[c][1],h=Math.min(u,g),!(h>r||r>Math.max(u,g)||l>Math.max(f,v)))if(l=l&&r!==h&&m++}return m%2===1}var n=t.slice(),i=n[0][0],a=i,o=n[0][1],s=o;n.push(n[0]);for(var l=1;la;a++)if(o=[t[a][0]-l[0],t[a][1]-l[1]],s=n(o,c),0>s||s>u||Math.abs(n(o,h))>i)return!0;return!1};i.filter=function(t,e){function r(r){t.push(r);var s=n.length,l=i;n.splice(o+1);for(var c=l+1;c1){var s=t.pop();r(s)}return{addPt:r,raw:t,filtered:n}}},{"./matrix":374}],378:[function(t,e,r){"use strict";function n(t,e){for(var r,n=[],a=0;a=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;rt}function i(t,e){return e>=t}function a(t,e){return t>e}function o(t,e){return t>=e}var s=t("fast-isnumeric");r.findBin=function(t,e,r){if(s(e.start))return r?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var l,c,u=0,f=e.length,h=0;for(c=e[e.length-1]>=e[0]?r?n:i:r?o:a;f>u&&h++<100;)l=Math.floor((u+f)/2),c(e[l],t)?u=l+1:f=l;return h>90&&console.log("Long binary search..."),u-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;n>s;s++)e[s+1]>e[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,c=r?Math.ceil:Math.floor;a>i&&o++<100;)n=c((i+a)/2),e[n]<=t?i=n+s:a=n-l;return e[i]}},{"fast-isnumeric":95}],380:[function(t,e,r){"use strict";e.exports=function(t,e){(t.attr("class")||"").split(" ").forEach(function(e){0===e.indexOf("cursor-")&&t.classed(e,!1)}),e&&t.classed("cursor-"+e,!0)}},{}],381:[function(t,e,r){"use strict";var n=t("../components/color"),i=function(){};e.exports=function(t){for(var e in t)"function"==typeof t[e]&&(t[e]=i);t.destroy=function(){t.container.parentNode.removeChild(t.container)};var r=document.createElement("div");return r.textContent="Webgl is not supported by your browser - visit http://get.webgl.org for more info",r.style.cursor="pointer",r.style.fontSize="24px",r.style.color=n.defaults[0],t.container.appendChild(r),t.container.style.background="#FFFFFF",t.container.onclick=function(){window.open("http://get.webgl.org")},!1}},{"../components/color":297}],382:[function(t,e,r){"use strict";var n=t("fast-isnumeric");r.aggNums=function(t,e,i,a){var o,s;if(a||(a=i.length),n(e)||(e=!1),Array.isArray(i[0])){for(s=new Array(a),o=0;a>o;o++)s[o]=r.aggNums(t,e,i[o]);i=s}for(o=0;a>o;o++)n(e)?n(i[o])&&(e=t(+e,+i[o])):e=i[o];return e},r.len=function(t){return r.aggNums(function(t){return t+1},0,t)},r.mean=function(t,e){return e||(e=r.len(t)),r.aggNums(function(t,e){return t+e},0,t)/e},r.variance=function(t,e,i){return e||(e=r.len(t)),n(i)||(i=r.mean(t,e)),r.aggNums(function(t,e){return t+Math.pow(e-i,2)},0,t)/e},r.stdev=function(t,e,n){return Math.sqrt(r.variance(t,e,n))},r.interp=function(t,e){if(!n(e))throw"n should be a finite number";if(e=e*t.length-.5,0>e)return t[0];if(e>t.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"fast-isnumeric":95}],383:[function(t,e,r){"use strict";function n(t){return t=i(t),a.str2RgbaArray(t.toRgbString())}var i=t("tinycolor2"),a=t("arraytools");e.exports=n},{arraytools:27,tinycolor2:275}],384:[function(t,e,r){"use strict";function n(t,e){return t.node().getBoundingClientRect()[e]}function i(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function a(t,e,r){var n="math-output-"+l.Lib.randstr([],64),a=c.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(i(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,a.node()],function(){var e=c.select("body").select("#MathJax_SVG_glyphs");if(a.select(".MathJax_SVG").empty()||!a.select("svg").node())console.log("There was an error in the tex syntax.",t),r();else{var n=a.select("svg").node().getBoundingClientRect();r(a.select(".MathJax_SVG"),e,n)}a.remove()})}function o(t){for(var e=l.util.html_entity_decode(t),r=e.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),r=e&&e[2].toLowerCase(),n=h[r];if(void 0!==n){var i=e[1],a=e[3],o=a.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===r){if(i)return"";if("href"!==a.substr(0,4).toLowerCase())return"";var s=document.createElement("a");return s.href=a.substr(4).replace(/["'=]/g,""),-1===d.indexOf(s.protocol)?"":'"}if("br"===r)return"
";if(i)return"sup"===r?'':"sub"===r?'':"";var c=""}return l.util.xml_entity_encode(t).replace(/");i>0;i=r.indexOf("
",i+1))n.push(i);var a=0;n.forEach(function(t){for(var e=t+a,n=r.slice(0,e),i="",o=n.length-1;o>=0;o--){var s=n[o].match(/<(\/?).*>/i);if(s&&"
"!==n[o]){s[1]||(i=n[o]);break}}i&&(r.splice(e+1,0,i),r.splice(e,0,""),a+=2)});var o=r.join(""),s=o.split(/
/gi);return s.length>1&&(r=s.map(function(t,e){return''+t+""})),r.join("")}function s(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-c.top+"px",left:a()-c.left+"px","z-index":1e3}),this}}var l=t("../plotly"),c=t("d3"),u=t("../constants/xmlns_namespaces"),f=e.exports={};c.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),r=(new DOMParser).parseFromString(e,"application/xml"),n=r.documentElement.firstChild;n;)this.node().appendChild(this.node().ownerDocument.importNode(n,!0)),n=n.nextSibling;return r.querySelector("parsererror")?(console.log(r.querySelector("parsererror div").textContent),null):c.select(this.node().lastChild)},f.html_entity_decode=function(t){var e=c.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),r},f.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},f.convertToTspans=function(t,e){function r(){d.empty()||(p=u.attr("class")+"-math",d.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),h=t.appendSVG(s),h||t.text(i),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(u)}var i=t.text(),s=o(i),u=t,f=!u.attr("data-notex")&&s.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),h=i,d=c.select(u.node().parentNode);if(!d.empty()){var p=u.attr("class")?u.attr("class").split(" ")[0]:"text";p+="-math",d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=l.Lib.getPlotDiv(u.node());(v&&v._promises||[]).push(new Promise(function(t){u.style({visibility:"hidden"});var i={fontSize:parseInt(u.style("font-size"),10)};a(f[2],i,function(i,a,o){d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove();var s=i&&i.select("svg");if(!s||!s.node())return r(),void t();var l=d.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});l.node().appendChild(s.node()),a&&a.node()&&s.node().insertBefore(a.node().cloneNode(!0),s.node().firstChild),s.attr({"class":p,height:o.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=u.style("fill")||"black";s.select("g").attr({fill:c,stroke:c});var f=n(s,"width"),h=n(s,"height"),g=+u.attr("x")-f*{start:0,middle:.5,end:1}[u.attr("text-anchor")||"start"],v=parseInt(u.style("font-size"),10)||n(u,"height"),m=-v/4;"y"===p[0]?(l.attr({transform:"rotate("+[-90,+u.attr("x"),+u.attr("y")]+") translate("+[-f/2,m-h/2]+")"}),s.attr({x:+u.attr("x"),y:+u.attr("y")})):"l"===p[0]?s.attr({x:u.attr("x"),y:m-h/2}):"a"===p[0]?s.attr({x:0,y:m}):s.attr({x:g,y:+u.attr("y")+m-h/2}),e&&e.call(u,l),t(l)})}))}else r();return t}};var h={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},d=["http:","https:","mailto:"],p=new RegExp("]*)?/?>","g");f.plainText=function(t){return(t||"").replace(p," ")},f.makeEditable=function(t,e,r){function n(){a(),o.style({opacity:0});var t,e=h.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0})}function i(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}function a(){var t=c.select(l.Lib.getPlotDiv(o.node())),e=t.select(".svg-container"),n=e.append("div");n.classed("plugin-editable editable",!0).style({position:"absolute","font-family":o.style("font-family")||"Arial","font-size":o.style("font-size")||12,color:r.fill||o.style("fill")||"black",opacity:1,"background-color":r.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(o.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(r.text||o.attr("data-unformatted")).call(s(o,e,r)).on("blur",function(){o.text(this.textContent).style({opacity:1});var t,e=c.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0});var r=this.textContent;c.select(this).transition().duration(0).remove(),c.select(document).on("mouseup",null),u.edit.call(o,r)}).on("focus",function(){var t=this;c.select(document).on("mouseup",function(){return c.event.target===t?!1:void(document.activeElement===n.node()&&n.node().blur())})}).on("keyup",function(){27===c.event.which?(o.style({opacity:1}),c.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),u.cancel.call(o,this.textContent)):(u.input.call(o,this.textContent),c.select(this).call(s(o,e,r)))}).on("keydown",function(){13===c.event.which&&this.blur()}).call(i)}r||(r={});var o=this,u=c.dispatch("edit","input","cancel"),f=c.select(this.node()).style({"pointer-events":"all"}),h=e||f;return e&&f.style({"pointer-events":"none"}),r.immediate?n():h.on("click",n),c.rebind(this,u,"on")}},{"../constants/xmlns_namespaces":360,"../plotly":390,d3:87}],385:[function(t,e,r){"use strict";var n=e.exports={},i=t("../constants/geo_constants").locationmodeToLayer,a=t("topojson").feature;n.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},n.getTopojsonPath=function(t,e){return t+e+".json"},n.getTopojsonFeatures=function(t,e){var r=i[t.locationmode],n=e.objects[r];return a(e,n).features}},{"../constants/geo_constants":356,topojson:277}],386:[function(t,e,r){"use strict";function n(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function i(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function a(t,e){t._context||(t._context=R.extendFlat({},P.defaultConfig));var r=t._context;e&&(Object.keys(e).forEach(function(t){t in r&&("setBackground"===t&&"opaque"===e[t]?r[t]=i:r[t]=e[t])}),e.plot3dPixelRatio&&!r.plotGlPixelRatio&&(r.plotGlPixelRatio=r.plot3dPixelRatio)),r.staticPlot&&(r.editable=!1,r.autosizable=!1,r.scrollZoom=!1,r.doubleClick=!1,r.showTips=!1,r.showLink=!1,r.displayModeBar=!1)}function o(t,e,r){var n=S.select(t).selectAll(".plot-container").data([0]);n.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=n.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e),r&&(t.layout=r),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(w(t,{}),t._fullLayout.autosize=r.autosize=!0),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var a=t.framework.svg(),o=1,s=t._fullLayout.title;""!==s&&s||(o=0);var l="Click to enter title",c=function(){this.call(P.util.convertToTspans)},u=a.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":s}),s&&s!==l||(o=.2,u.attr({"data-unformatted":l}).text(l).style({opacity:o}).on("mouseover.opacity",function(){S.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){S.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),N.addLinks(t),Promise.resolve()}function s(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var n=P.Axes.list({_fullLayout:t});for(e=0;ee;e++){var o=t.annotations[e];o.ref&&("paper"===o.ref?(o.xref="paper",o.yref="paper"):"data"===o.ref&&(o.xref="x",o.yref="y"),delete o.ref),l(o,"xref"),l(o,"yref")}void 0===t.shapes||Array.isArray(t.shapes)||(console.log("shapes must be an array"),delete t.shapes);var s=(t.shapes||[]).length;for(e=0;s>e;e++){var c=t.shapes[e];l(c,"xref"),l(c,"yref")}var u=t.legend;u&&(u.x>3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var h=N.getSubplotIds(t,"gl3d");for(e=0;er;++r)b[r]=v[e]+m*y[2+4*r];d.camera={eye:{x:b[0],y:b[1],z:b[2]},center:{x:v[0],y:v[1],z:v[2]},up:{x:y[1],y:y[5],z:y[9]}},delete d.cameraposition}}return R.markTime("finished rest of cleanLayout, starting color"),F.clean(t),R.markTime("finished cleanLayout color.clean"),t}function l(t,e){var r=t[e],n=e.charAt(0);r&&"paper"!==r&&(t[e]=P.Axes.cleanId(r,n))}function c(t,e){for(var r=[],n=(t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid})),i=0;ia&&(s=R.randstr(n),-1!==r.indexOf(s));a++);o.uid=R.randstr(n),n.push(o.uid)}if(r.push(o.uid),"histogramy"===o.type&&"xbins"in o&&!("ybins"in o)&&(o.ybins=o.xbins,delete o.xbins),o.error_y&&"opacity"in o.error_y){var l=F.defaults,c=o.error_y.color||(N.traceIs(o,"bar")?F.defaultLine:l[i%l.length]);o.error_y.color=F.addOpacity(F.rgb(c),F.opacity(c)*o.error_y.opacity),delete o.error_y.opacity}if("bardir"in o&&("h"!==o.bardir||!N.traceIs(o,"bar")&&"histogram"!==o.type.substr(0,9)||(o.orientation="h",x(o)),delete o.bardir),"histogramy"===o.type&&x(o),"histogramx"!==o.type&&"histogramy"!==o.type||(o.type="histogram"),"scl"in o&&(o.colorscale=o.scl,delete o.scl),"reversescl"in o&&(o.reversescale=o.reversescl,delete o.reversescl),o.xaxis&&(o.xaxis=P.Axes.cleanId(o.xaxis,"x")),o.yaxis&&(o.yaxis=P.Axes.cleanId(o.yaxis,"y")),N.traceIs(o,"gl3d")&&o.scene&&(o.scene=N.subplotsRegistry.gl3d.cleanId(o.scene)),N.traceIs(o,"pie")||(Array.isArray(o.textposition)?o.textposition=o.textposition.map(u):o.textposition&&(o.textposition=u(o.textposition))),N.traceIs(o,"2dMap")&&("YIGnBu"===o.colorscale&&(o.colorscale="YlGnBu"),"YIOrRd"===o.colorscale&&(o.colorscale="YlOrRd")),N.traceIs(o,"markerColorscale")&&o.marker){var h=o.marker;"YIGnBu"===h.colorscale&&(h.colorscale="YlGnBu"),"YIOrRd"===h.colorscale&&(h.colorscale="YlOrRd")}if("surface"===o.type&&R.isPlainObject(o.contours)){var d=["x","y","z"];for(a=0;an?a.push(i+n):a.push(n);return a}function p(t,e,r){var n,i;for(n=0;n=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||0>i&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function g(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),p(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&p(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function v(t,e,r){var n,i;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),n=0;n=0&&l0){var s=_(t._boundingBoxMargins),l=s.left+s.right,c=s.bottom+s.top,u=a._container.node().getBoundingClientRect(),f=1-2*o.frameMargins;i=Math.round(f*(u.width-l)),n=Math.round(f*(u.height-c))}else r=window.getComputedStyle(t),n=parseFloat(r.height)||a.height,i=parseFloat(r.width)||a.width;return Math.abs(a.width-i)>1||Math.abs(a.height-n)>1?(a.height=t.layout.height=n,a.width=t.layout.width=i):"initial"!==a.autosize&&(delete e.autosize,a.autosize=t.layout.autosize=!0),N.sanitizeMargins(a),e}function k(t){var e=S.select(t),r=t._fullLayout;if(r._hasGL3D&&N.subplotsRegistry.gl3d.initAxes(t),r._container=e.selectAll(".plot-container").data([0]),r._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),r._paperdiv=r._container.selectAll(".svg-container").data([0]),r._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===r.autosize&&(w(t,{}),r.autosize=!0,t.layout.autosize=!0),r._glcontainer=r._paperdiv.selectAll(".gl-container").data([0]),r._glcontainer.enter().append("div").classed("gl-container",!0),r._geocontainer=r._paperdiv.selectAll(".geo-container").data([0]),r._geocontainer.enter().append("div").classed("geo-container",!0),r._paperdiv.selectAll(".main-svg").remove(),r._paper=r._paperdiv.insert("svg",":first-child").classed("main-svg",!0),r._toppaper=r._paperdiv.append("svg").classed("main-svg",!0),!r._uid){ +var n=[];S.selectAll("defs").each(function(){this.id&&n.push(this.id.split("-")[1])}),r._uid=R.randstr(n)}r._paperdiv.selectAll(".main-svg").attr(X.svgAttrs),r._defs=r._paper.append("defs").attr("id","defs-"+r._uid),r._topdefs=r._toppaper.append("defs").attr("id","topdefs-"+r._uid),r._draggers=r._paper.append("g").classed("draglayer",!0);var i=r._paper.append("g").classed("layer-below",!0);r._shapeLowerLayer=i.append("g").classed("shapelayer",!0);var a=P.Axes.getSubplots(t);a.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,a),r._hasCartesian&&M(t,a),r._ternarylayer=r._paper.append("g").classed("ternarylayer",!0),r._subplotShapeLayer=r._paper.selectAll(".shapelayer-subplot");var o=r._paper.append("g").classed("layer-above",!0);r._shapeUpperLayer=o.append("g").classed("shapelayer",!0),r._pielayer=r._paper.append("g").classed("pielayer",!0),r._glimages=r._paper.append("g").classed("glimages",!0),r._geoimages=r._paper.append("g").classed("geoimages",!0),r._infolayer=r._toppaper.append("g").classed("infolayer",!0),r._zoomlayer=r._toppaper.append("g").classed("zoomlayer",!0),r._hoverlayer=r._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var s=R.syncOrAsync([T,function(){return P.Axes.doTicks(t,"redraw")},j.init],t);return s&&s.then&&t._promises.push(s),s}function A(t,e){function r(e,r){return function(){return P.Axes.getFromId(t,e,r)}}for(var n,i,a=t._fullLayout._plots={},o=0;o0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),A=w===_;x?t.framework===k&&!b&&A||(t.framework=k,k(t)):A?b&&k(t):(t.framework=k,k(t)),b&&P.Axes.saveRangeInitial(t);var M=t._fullLayout,E=!t.calcdata||t.calcdata.length!==(t.data||[]).length;E&&h(t);for(var L=0;LG.range[0]?[1,2]:[2,1]);else{var X=G.range[0],W=G.range[1];"log"===O?(0>=X&&0>=W&&i(V+".autorange",!0),0>=X?X=W/1e6:0>=W&&(W=X/1e6),i(V+".range[0]",Math.log(X)/Math.LN10),i(V+".range[1]",Math.log(W)/Math.LN10)):(i(V+".range[0]",Math.pow(10,X)),i(V+".range[1]",Math.pow(10,W)))}else i(V+".autorange",!0)}if("reverse"===B)q.range?q.range.reverse():(i(V+".autorange",!0),q.range=[1,0]),H.autorange?_=!0:x=!0;else if("annotations"===z.parts[0]||"shapes"===z.parts[0]){var Z=z.parts[1],K=z.parts[0],Q=p[K]||[],$=P[R.titleCase(K)],J=Q[Z]||{};2===z.parts.length&&("add"===v[C]||R.isPlainObject(v[C])?E[C]="remove":"remove"===v[C]?-1===Z?(E[K]=Q,delete E[C]):E[C]=J:console.log("???",v)),!a(J,"x")&&!a(J,"y")||R.containsAny(C,["color","opacity","align","dash"])||(_=!0),$.draw(t,Z,z.parts.slice(2).join("."),v[C]),delete v[C]}else 0===z.parts[0].indexOf("scene")?x=!0:0===z.parts[0].indexOf("geo")?x=!0:0===z.parts[0].indexOf("ternary")?x=!0:!g._hasGL2D||-1===C.indexOf("axis")&&"plot_bgcolor"!==z.parts[0]?"hiddenlabels"===C?_=!0:-1!==z.parts[0].indexOf("legend")?m=!0:-1!==C.indexOf("title")?y=!0:-1!==z.parts[0].indexOf("bgcolor")?b=!0:z.parts.length>1&&R.containsAny(z.parts[1],["tick","exponent","grid","zeroline"])?y=!0:-1!==C.indexOf(".linewidth")&&-1!==C.indexOf("axis")?y=b=!0:z.parts.length>1&&-1!==z.parts[1].indexOf("line")?b=!0:z.parts.length>1&&"mirror"===z.parts[1]?y=b=!0:"margin.pad"===C?y=b=!0:"margin"===z.parts[0]||"autorange"===z.parts[1]||"rangemode"===z.parts[1]||"type"===z.parts[1]||"domain"===z.parts[1]||C.match(/^(bar|box|font)/)?_=!0:-1!==["hovermode","dragmode"].indexOf(C)?k=!0:-1===["hovermode","dragmode","height","width","autosize"].indexOf(C)&&(x=!0):x=!0,z.set(O)}I&&I.add(t,tt,[t,E],tt,[t,M]),v.autosize&&(v=w(t,v)),(v.height||v.width||v.autosize)&&(_=!0);var et=Object.keys(v),rt=[N.previousPromises];if(x||_)rt.push(function(){return t.layout=void 0,_&&(t.calcdata=void 0),P.plot(t,"",p)});else if(et.length&&(N.supplyDefaults(t),g=t._fullLayout,m&&rt.push(function(){return U.draw(t),N.previousPromises(t)}),b&&rt.push(T),y&&rt.push(function(){return P.Axes.doTicks(t,"redraw"),L(t),N.previousPromises(t)}),k)){var nt;for(Y(t),nt=N.getSubplotIds(g,"gl3d"),d=0;dc&&u>e&&(void 0===i[r]?a[f]=E.tickText(t,e):a[f]=s(t,e,String(i[r])),f++);return f=864e5?t._tickround="d":r>=36e5?t._tickround="H":r>=6e4?t._tickround="M":r>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(r/2)/Math.LN10);else{x(r)||(r=Number(r.substr(1))),t._tickround=2-Math.floor(Math.log(r)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var n=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(n)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((n-1)/3):t._tickexponent=n); +}else"M"===r.charAt(0)?t._tickround=2===r.length?"m":"y":t._tickround=null}function o(t,e){var r=t.match(V),n=new Date(e);if(r){var i=Math.min(+r[1]||6,6),a=String(e/1e3%1+2.0000005).substr(2,i).replace(/0+$/,"")||"0";return b.time.format(t.replace(V,a))(n)}return b.time.format(t)(n)}function s(t,e,r){var n=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}function l(t,e,r,n){var i,a=e.x,s=t._tickround,l=new Date(a),c="";r&&t.hoverformat?i=o(t.hoverformat,a):t.tickformat?i=o(t.tickformat,a):(n&&(x(s)?s+=2:s={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[s]),"y"===s?i=N(l):"m"===s?i=j(l):(a!==t._tmin||r||(c="
"+N(l)),"d"===s?i=F(l):"H"===s?i=B(l):(a!==t._tmin||r||(c="
"+F(l)+", "+N(l)),i=D(l),"M"!==s&&(i+=U(l),"S"!==s&&(i+=h(y(a/1e3,1),t,"none",r).substr(1)))))),e.text=i+c}function c(t,e,r,n,i){var a=t.dtick,o=e.x;if(!n||"string"==typeof a&&"L"===a.charAt(0)||(a="L3"),t.tickformat||"string"==typeof a&&"L"===a.charAt(0))e.text=h(Math.pow(10,o),t,i,n);else if(x(a)||"D"===a.charAt(0)&&y(o+.01,1)<.1)if(-1!==["e","E","power"].indexOf(t.exponentformat)){var s=Math.round(o);0===s?e.text=1:1===s?e.text="10":s>1?e.text="10"+s+"":e.text="10\u2212"+-s+"",e.fontSize*=1.25}else e.text=h(Math.pow(10,o),t,"","fakehover"),"D1"===a&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==a.charAt(0))throw"unrecognized dtick "+String(a);e.text=String(Math.round(Math.pow(10,y(o,1)))),e.fontSize*=.75}if("D1"===t.dtick){var l=String(e.text).charAt(0);"0"!==l&&"1"!==l||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(0>o?.5:.25)))}}function u(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r=""),e.text=String(r)}function f(t,e,r,n,i){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide"),e.text=h(e.x,t,i,n)}function h(t,e,r,n){var i=0>t,o=e._tickround,s=r||e.exponentformat||"B",l=e._tickexponent,c=e.tickformat;if(n){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:x(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};a(u),o=(Number(u._tickround)||0)+4,l=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return b.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-o)/2;if("none"===s&&(l=0),t=Math.abs(t),f>t)t="0",i=!1;else{if(t+=f,l&&(t*=Math.pow(10,-l),o+=l),0===o)t=String(Math.floor(t));else if(0>o){t=String(Math.round(t)),t=t.substr(0,t.length+o);for(var h=o;0>h;h++)t+="0"}else{t=String(t);var p=t.indexOf(".")+1;p&&(t=t.substr(0,p+o).replace(/\.?0+$/,""))}t=d(t,e._gd._fullLayout.separators)}if(l&&"hide"!==s){var g;g=0>l?"\u2212"+-l:"power"!==s?"+"+l:String(l),"e"===s||("SI"===s||"B"===s)&&(l>12||-15>l)?t+="e"+g:"E"===s?t+="E"+g:"power"===s?t+="×10"+g+"":"B"===s&&9===l?t+="B":"SI"!==s&&"B"!==s||(t+=q[l/3+5])}return i?"\u2212"+t:t}function d(t,e){var r=e.charAt(0),n=e.charAt(1),i=t.split("."),a=i[0],o=i.length>1?r+i[1]:"";if(n&&(i.length>1||a.length>4))for(;H.test(a);)a=a.replace(H,"$1"+n+"$2");return a+o}function p(t,e){var r,n,i=[];for(r=0;r1)for(n=1;n2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},E.getAutoRange=function(t){var e,r=[],n=t._min[0].val,i=t._max[0].val;for(e=1;e0&&u>0&&f/u>h&&(l=o,c=s,h=f/u);return n===i?r=d?[n+1,"normal"!==t.rangemode?0:n-1]:["normal"!==t.rangemode?0:n-1,n+1]:h&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode&&l.val>=0?l={val:0,pad:0}:"nonnegative"===t.rangemode&&(l.val-h*l.pad<0&&(l={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),h=(c.val-l.val)/(t._length-l.pad-c.pad)),r=[l.val-h*l.pad,c.val+h*c.pad],r[0]===r[1]&&(r=[r[0]-1,r[0]+1]),d&&r.reverse()),r},E.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=E.getAutoRange(t);var r=t._gd.layout[t._name];r||(t._gd.layout[t._name]=r={}),r!==t&&(r.range=t.range.slice(),r.autorange=t.autorange)}},E.saveRangeInitial=function(t,e){for(var r=E.list(t,"",!0),n=!1,i=0;ip&&(p=g/10),c=t.c2l(p),u=t.c2l(g),y&&(c=Math.min(0,c),u=Math.max(0,u)),n(c)){for(d=!0,o=0;o=h?d=!1:s.val>=c&&s.pad<=h&&(t._min.splice(o,1),o--);d&&t._min.push({val:c,pad:y&&0===c?0:h})}if(n(u)){for(d=!0,o=0;o=u&&s.pad>=f?d=!1:s.val<=u&&s.pad<=f&&(t._max.splice(o,1),o--);d&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),r||(r={}),t._m||t.setScale();var a,o,s,l,c,u,f,h,d,p,g,v=e.length,m=r.padded?.05*t._length:0,y=r.tozero&&("linear"===t.type||"-"===t.type),b=n((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),_=n((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),w=n(r.vpadplus||r.vpad),k=n(r.vpadminus||r.vpad);for(a=0;6>a;a++)i(a);for(a=v-1;a>5;a--)i(a)}},E.autoBin=function(t,e,r,n){function i(t){return(1+100*(t-d)/f.dtick)%100<2}var a=w.aggNums(Math.min,null,t),o=w.aggNums(Math.max,null,t);if("category"===e.type)return{start:a-.5,end:o+.5,size:1};var s;if(r)s=(o-a)/r;else{var l=w.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(l.minDiff)/Math.LN10)),u=c*w.roundUp(l.minDiff/c,[.9,1.9,4.9,9.9],!0);s=Math.max(u,2*w.stdev(t)/Math.pow(t.length,n?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[a,o]};E.autoTicks(f,s);var h,d=E.tickIncrement(E.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;yg&&(p>.3*b||i(a)||i(o))){var _=f.dtick/2;d+=a>d+_?_:-_}var k=1+Math.floor((o-d)/f.dtick);h=d+k*f.dtick}else for(h=d;o>=h;)h=E.tickIncrement(h,f.dtick);return{start:d,end:h,size:f.dtick}},E.calcTicks=function(t){if("array"===t.tickmode)return n(t);if("auto"===t.tickmode||!t.dtick){var e,r=t.nticks;r||("category"===t.type?(e=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/e):(e="y"===t._id.charAt(0)?40:80,r=w.constrain(t._length/e,4,9)+1)),E.autoTicks(t,Math.abs(t.range[1]-t.range[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),a(t),t._tmin=E.tickFirst(t);var i=t.range[1]=s:s>=l)&&(o.push(l),!(o.length>1e3));l=E.tickIncrement(l,t.dtick,i));t._tmax=o[o.length-1];for(var c=new Array(o.length),u=0;u157788e5?(e/=315576e5,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*i(e,r,C)):e>12096e5?(e/=26298e5,t.dtick="M"+i(e,1,z)):e>432e5?(t.dtick=i(e,864e5,R),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=i(e,36e5,z):e>3e4?t.dtick=i(e,6e4,P):e>500?t.dtick=i(e,1e3,P):(r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,C));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var n=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/n,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+i(e,r,C)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,C));if(0===t.dtick&&(t.dtick=1),!x(t.dtick)&&"string"!=typeof t.dtick){var a=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(a)}},E.tickIncrement=function(t,e,r){var n=r?-1:1;if(x(e))return t+n*e;var i=e.charAt(0),a=n*Number(e.substr(1));if("M"===i){var o=new Date(t);return o.setMonth(o.getMonth()+a)}if("L"===i)return Math.log(Math.pow(10,t)+a)/Math.LN10;if("D"===i){var s="D2"===e?I:O,l=t+.01*n,c=w.roundUp(y(l,1),s,r);return Math.floor(l)+Math.log(b.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},E.tickFirst=function(t){var e=t.range[1]n:n>c;)c=E.tickIncrement(c,i,e);return c}if("L"===u)return Math.log(r((Math.pow(10,n)-a)/f)*f+a)/Math.LN10;if("D"===u){var h="D2"===i?I:O,d=w.roundUp(y(n,1),h,e);return Math.floor(n)+Math.log(b.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(i)};var N=b.time.format("%Y"),j=b.time.format("%b %Y"),F=b.time.format("%b %-d"),B=b.time.format("%b %-d %Hh"),D=b.time.format("%H:%M"),U=b.time.format(":%S"),V=/%(\d?)f/g;E.tickText=function(t,e,r){function n(n){var i;return void 0===n?!0:r?"none"===n:(i={first:t._tmin,last:t._tmax}[n],"all"!==n&&e!==i)}var i,a,o=s(t,e),h="array"===t.tickmode,d=r||h;if(h&&Array.isArray(t.ticktext)){var p=Math.abs(t.range[1]-t.range[0])/1e4;for(a=0;a1&&er&&(M=90),i(u,M)}c._lastangle=M}return o(e),e+" done"}function l(){c._boundingBox=r.node().getBoundingClientRect()}var u=r.selectAll("g."+C).data(y,S);if(!c.showticklabels||!x(n))return u.remove(),void o(e);var f,h,p,m,_;"x"===v?(_="bottom"===D?1:-1,f=function(t){return t.dx+I*_},m=n+(O+R)*_,h=function(t){return t.dy+m+t.fontSize*("bottom"===D?1:-.5)},p=function(t){return x(t)&&0!==t&&180!==t?0>t*_?"end":"start":"middle"}):(_="right"===D?1:-1,h=function(t){return t.dy+t.fontSize/2-I*_},f=function(t){return t.dx+n+(O+R+(90===Math.abs(c.tickangle)?t.fontSize/2:0))*_},p=function(t){return x(t)&&90===Math.abs(t)?"middle":"right"===D?"start":"end"});var A=0,M=0,E=[];u.enter().append("g").classed(C,1).append("text").attr("text-anchor","middle").each(function(e){var r=b.select(this),n=t._promises.length;r.call(T.setPosition,f(e),h(e)).call(T.font,e.font,e.fontSize,e.fontColor).text(e.text).call(k.convertToTspans),n=t._promises[n],n?E.push(t._promises.pop().then(function(){i(r,c.tickangle)})):i(r,c.tickangle)}),u.exit().remove(),u.each(function(t){A=Math.max(A,t.fontSize)}),i(u,c._lastangle||c.tickangle);var L=w.syncOrAsync([a,s,l]);return L&&L.then&&t._promises.push(L),L}function o(e){if(!r){var n,i,a,o,s=L.getFromId(t,e),l=b.select(t).selectAll("g."+e+"tick"),c={selection:l,side:s.side},f=e.charAt(0),h=t._fullLayout._size,d=1.5,p=s.titlefont.size;if(l.size()){var g=b.select(l.node().parentNode).attr("transform").match(/translate\(([-\.\d]+),([-\.\d]+)\)/);g&&(c.offsetLeft=+g[1],c.offsetTop=+g[2])}"x"===f?(i="free"===s.anchor?{_offset:h.t+(1-(s.position||0))*h.h,_length:0}:L.getFromId(t,s.anchor),a=s._offset+s._length/2,o=i._offset+("top"===s.side?-10-p*(d+(s.showticklabels?1:0)):i._length+10+p*(d+(s.showticklabels?1.5:.5))),s.rangeslider&&s.rangeslider.visible&&s._boundingBox&&(o+=(u.height-u.margin.b-u.margin.t)*s.rangeslider.thickness+s._boundingBox.height),c.side||(c.side="bottom")):(i="free"===s.anchor?{_offset:h.l+(s.position||0)*h.w,_length:0}:L.getFromId(t,s.anchor),o=s._offset+s._length/2,a=i._offset+("right"===s.side?i._length+10+p*(d+(s.showticklabels?1:.5)):-10-p*(d+(s.showticklabels?.5:0))),n={rotate:"-90",offset:0},c.side||(c.side="left")),A.draw(t,e+"title",{propContainer:s,propName:s._name+".title",dfltName:f.toUpperCase()+" axis",avoid:c,transform:n,attributes:{x:a,y:o,"text-anchor":"middle"}})}}function s(t,e){return t.visible!==!0||t.xaxis+t.yaxis!==e?!1:_.Plots.traceIs(t,"bar")&&t.orientation==={x:"h",y:"v"}[v]?!0:t.fill&&t.fill.charAt(t.fill.length-1)===v}function l(e,r,i){var a=e.gridlayer,o=e.zerolinelayer,l=e["hidegrid"+v]?[]:V,u=c._gridpath||"M0,0"+("x"===v?"v":"h")+r._length,f=a.selectAll("path."+z).data(c.showgrid===!1?[]:l,S);if(f.enter().append("path").classed(z,1).classed("crisp",1).attr("d",u).each(function(t){c.zeroline&&("linear"===c.type||"-"===c.type)&&Math.abs(t.x)g;g++){var y=c.mirrors[o._id+h[g]];"ticks"!==y&&"labels"!==y||(f[g]=!0)}return void 0!==n[2]&&(f[2]=!0),f.forEach(function(t,e){var r=n[e],i=U[e];t&&x(r)&&(d+=p(r+R*i,i*c.ticklen))}),i(r,d),l(e,o,t),a(r,n[3])}}).filter(function(t){return t&&t.then});return H.length?Promise.all(H):0},E.swap=function(t,e){for(var r=p(t,e),n=0;n2*n}function u(t){for(var e,r=Math.max(1,(t.length-1)/1e3),n=0,i=0,a=0;a2*n}var f=t("fast-isnumeric"),h=t("tinycolor2").mix,d=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),b=t("./tick_label_defaults"),x=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),A=t("./axis_ids");e.exports=function(t,e,r,i){function a(r,n){return d.coerce2(t,e,v,r,n)}var o=i.letter,s=i.font||{},l="Click to enter "+(i.title||o.toUpperCase()+" axis")+" title";i.name&&(e._name=i.name,e._id=A.name2id(i.name));var c=r("type");"-"===c&&(n(e,i.data),"-"===e.type?e.type="linear":c=t.type=e.type),e._initialCategories="category"===c?w(o,t.categoryorder,t.categoryarray,i.data):[],_(e);var u=r("color"),p=u===t.color?u:s.color;r("title",l),d.coerceFont(r,"titlefont",{family:s.family,size:Math.round(1.2*s.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),M=r("autorange",!k);M&&r("rangemode");var T=r("range",[-1,"x"===o?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),d.noneOrAll(t.range,e.range,[0,1]),r("fixedrange"),m(t,e,r,c),b(t,e,r,c,i),y(t,e,r,i),x(t,e,r);var E=a("linecolor",u),L=a("linewidth"),S=r("showline",!!E||!!L);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&r("mirror");var C=a("gridcolor",h(u,i.bgColor,g).toRgbString()),z=a("gridwidth"),P=r("showgrid",i.showGrid||!!C||!!z);P||(delete e.gridcolor,delete e.gridwidth);var R=a("zerolinecolor",u),O=a("zerolinewidth"),I=r("zeroline",i.showGrid||!!R||!!O);return I||(delete e.zerolinecolor,delete e.zerolinewidth),e}},{"../../components/color/attributes":296,"../../lib":372,"../plots":441,"./axis_ids":395,"./category_order_defaults":396,"./clean_datum":397,"./layout_attributes":402,"./ordered_categories":404,"./set_convert":407,"./tick_label_defaults":408,"./tick_mark_defaults":409,"./tick_value_defaults":410,"fast-isnumeric":95,tinycolor2:275}],395:[function(t,e,r){"use strict";function n(t,e,r){function n(t,r){for(var n=Object.keys(t),i=/^[xyz]axis[0-9]*/,a=[],o=0;o0;-1===i.indexOf(t.categoryorder)&&a?r("categoryorder","array"):"array"!==t.categoryorder||a?r("categoryorder"):(t.categoryorder="trace",r("categoryorder"))}}},{"./layout_attributes":402}],397:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return i.ms2DateTime(t);if("string"!=typeof t&&!n(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){console.log(e,t)}return t}},{"../../lib":372,"fast-isnumeric":95}],398:[function(t,e,r){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:100,BENDPX:1.5}},{}],399:[function(t,e,r){"use strict";function n(t,e){var r,n=t.range[e],i=Math.abs(n-t.range[1-e]);return"date"===t.type?c.ms2DateTime(n,i):"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,o.format("."+r+"g")(Math.pow(10,n))):(r=Math.floor(Math.log(Math.abs(n))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,o.format("."+String(r)+"g")(n))}function i(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function a(t){o.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var o=t("d3"),s=t("tinycolor2"),l=t("../../plotly"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../components/color"),h=t("../../components/drawing"),d=t("../../lib/setcursor"),p=t("../../components/dragelement"),g=t("./axes"),v=t("./select"),m=t("./constants"),y=!0;e.exports=function(t,e,r,o,b,x,_,w){function k(t,e){for(var r=0;r.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+ht+", "+dt+")").attr("d",ot+"Z"),ut=ft.append("path").attr("class","zoombox-corners").style({fill:f.background,stroke:f.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+ht+", "+dt+")").attr("d","M0,0Z"),T();for(var a=0;ai?(lt="",it.r=it.l,it.t=it.b,ut.attr("d","M0,0Z")):(it.t=0,it.b=V,lt="x",ut.attr("d","M"+(it.l-.5)+","+(nt-H-.5)+"h-3v"+(2*H+1)+"h3ZM"+(it.r+.5)+","+(nt-H-.5)+"h3v"+(2*H+1)+"h-3Z")):!Z||i.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),ut.transition().style("opacity",1).duration(200),st=!0)}function L(t,e,r){var n,i,a;for(n=0;nzoom back out","long"),y=!1)))}function C(e,r){var i=1===(_+w).length;if(e)I();else if(2!==r||i){if(1===r&&i){var a=_?D[0]:B[0],o="s"===_||"w"===w?0:1,s=a._name+".range["+o+"]",c=n(a,o),f="left",h="middle";if(a.fixedrange)return;_?(h="n"===_?"top":"bottom","right"===a.side&&(f="right")):"e"===w&&(f="right"),J.call(u.makeEditable,null,{immediate:!0,background:j.paper_bgcolor,text:String(c),fill:a.tickfont?a.tickfont.color:"#444",horizontalAlign:f,verticalAlign:h}).on("edit",function(e){var r="category"===a.type?a.c2l(e):a.d2l(e);void 0!==r&&l.relayout(t,s,r)})}}else O()}function z(e){function r(t,e,r){if(!t.fixedrange){A(t.range);var n=t.range,i=n[0]+(n[1]-n[0])*e;t.range=[i+(n[0]-i)*r,i+(n[1]-i)*r]}}if(t._context.scrollZoom||j._enablescrollzoom){var n=t.querySelector(".plotly");if(!(n.scrollHeight-n.clientHeight>10||n.scrollWidth-n.clientWidth>10)){clearTimeout(gt);var i=-e.deltaY;if(isFinite(i)||(i=e.wheelDelta/10),!isFinite(i))return void console.log("did not find wheel motion attributes",e);var a,o=Math.exp(-Math.min(Math.max(i,-20),20)/100),s=mt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-s.left)/s.width,u=pt[0]+pt[2]*l,f=(s.bottom-e.clientY)/s.height,h=pt[1]+pt[3]*(1-f);if(w){for(a=0;a=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function i(t,e,r){for(var i=1-e,a=0,o=0;o0;n--)r.push(e);return r}function i(t,e){for(var r=[],n=0;nj||j>B.width||0>F||F>B.height)return _.unhoverRaw(t,e)}else j="xpx"in e?e.xpx:p[0]._length/2,F="ypx"in e?e.ypx:v[0]._length/2;if(x="xval"in e?n(d,e.xval):i(p,j),A="yval"in e?n(d,e.yval):i(v,F),!g(x[0])||!g(A[0]))return console.log("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var D=1/0;for(T=0;T1||-1!==L.hoverinfo.indexOf("name")?L.name:void 0,index:!1,distance:Math.min(D,k.MAXDIST),color:b.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},O=I.length,"array"===C){var U=e[T];"pointNumber"in U?(R.index=U.pointNumber,C="closest"):(C="","xval"in U&&(z=U.xval,C="x"),"yval"in U&&(P=U.yval,C=C?"closest":"y"))}else z=x[S],P=A[S];if(L._module&&L._module.hoverPoints){var V=L._module.hoverPoints(R,z,P,C);if(V)for(var q,H=0;HO&&(I.splice(0,O),D=I[0].distance)}if(0===I.length)return _.unhoverRaw(t,e);var G="y"===y&&N.length>1;I.sort(function(t,e){return t.distance-e.distance});var Y=b.combine(a.plot_bgcolor||b.background,a.paper_bgcolor),X={hovermode:y,rotateLabels:G,bgColor:Y,container:a._hoverlayer,outerContainer:a._paperdiv},W=c(I,X);u(I,G?"xa":"ya"),f(W,G);var Z=t._hoverdata,K=[];for(M=0;M128?"#000":b.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,r=u.textContent||"",r.length>15&&(r=r.substr(0,12)+"...")}void 0!==t.extraText&&(n+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(n+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(n+="y: "+t.yLabel+"
"),n+=(n?"z: ":"")+t.zLabel):M&&t[i+"Label"]===g?n=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(n=t.yLabel):n=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(n+=(n?"
":"")+t.text),""===n&&(""===r&&e.remove(),n=r);var f=e.select("text.nums").style("fill",c).call(x.setPosition,0,0).text(n).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(x.setPosition,0,0);var h=e.select("text.name"),v=0;r&&r!==n?(h.style("fill",l).text(r).call(x.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),h.selectAll("tspan.line").call(x.setPosition,0,0),v=h.node().getBoundingClientRect().width+2*P):(h.remove(),e.select("rect").remove()),e.select("path").style({fill:l,stroke:c});var m,k,E=f.node().getBoundingClientRect(),L=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),R=Math.abs(t.y1-t.y0),O=E.width+z+P+v;t.ty0=_-E.top,t.bx=E.width+2*P,t.by=E.height+2*P,t.anchor="start",t.txwidth=E.width,t.tx2width=v,t.offset=0,a?(t.pos=L,m=A>=S+R/2+O,k=S-R/2-O>=0,"top"!==t.idealAlign&&m||!k?m?(S+=R/2,t.anchor="start"):t.anchor="middle":(S-=R/2,t.anchor="end")):(t.pos=S,m=w>=L+C/2+O,k=L-C/2-O>=0,"left"!==t.idealAlign&&m||!k?m?(L+=C/2,t.anchor="start"):t.anchor="middle":(L-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&h.attr("text-anchor",t.anchor),e.attr("transform","translate("+L+","+S+")"+(a?"rotate("+T+")":""))}),S}function u(t,e){function r(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(.01>a)){if(-.01>i){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos>e.pmax-1&&(l.del=!0,c--);for(o=0;o=c);o++)if(l=t[o],l.pos=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos+l.dp+l.size>e.pmax&&(l.del=!0,c--)}}}for(var n,i,a,o,s,l,c,u=0,f=t.map(function(t,r){var n=t[e];return[{i:r,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===n._id.charAt(0)?L:1)/2,pmin:n._offset,pmax:n._offset+n._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(s=d.length-1;s>=0;s--)d[s].dp+=i;for(h.push.apply(h,d),f.splice(o+1,1),c=0,s=h.length-1;s>=0;s--)c+=h[s].dp;for(a=c/h.length,s=h.length-1;s>=0;s--)h[s].dp-=a;n=!1}else o++}f.forEach(r)}for(o=f.length-1;o>=0;o--){var v=f[o];for(s=v.length-1;s>=0;s--){var m=v[s],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var r=d.select(this);if(t.del)return void r.remove();var n="end"===t.anchor?-1:1,i=r.select("text.nums"),a={start:1,end:-1,middle:0}[t.anchor],o=a*(z+P),s=o+a*(t.txwidth+P),l=0,c=t.offset;"middle"===t.anchor&&(o-=t.tx2width/2,s-=t.tx2width/2),e&&(c*=-C,l=t.offset*S),r.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(n*z+l)+","+(z+c)+"v"+(t.by/2-z)+"h"+n*t.bx+"v-"+t.by+"H"+(n*z+l)+"V"+(c-z)+"Z"),i.call(x.setPosition,o+l,c+t.ty0-t.by/2+P).selectAll("tspan.line").attr({x:i.attr("x"),y:i.attr("y")}),t.tx2width&&(r.select("text.name, text.name tspan.line").call(x.setPosition,s+a*P+l,c+t.ty0-t.by/2+P),r.select("rect").call(x.setRect,s+(a-1)*t.tx2width/2+l,c-t.by/2-1,t.tx2width,t.by+2))})}function h(t,e,r){if(!e.target)return!1;if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}var d=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),b=t("../../components/color"),x=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),A=t("./dragbox"),M=e.exports={};M.unhover=_.unhover,M.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},M.supplyLayoutDefaults=function(t,e,r){function n(r,n){return v.coerce(t,e,M.layoutAttributes,r,n)}n("dragmode");var i;if(e._hasCartesian){var a=e._isHoriz=M.isHoriz(r);i=a?"y":"x"}else i="closest";n("hovermode",i)},M.isHoriz=function(t){for(var e=!0,r=0;rt._lastHoverTime+k.HOVERMINTIME?(o(t,e,r),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){o(t,e,r),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},M.getDistanceFunction=function(t,e,r,n){return"closest"===t?n||a(e,r):"x"===t?e:r},M.getClosest=function(t,e,r){if(r.index!==!1)r.index>=0&&r.indext*e||0===t?k.MAXDIST*(.6-.3/Math.max(3,Math.abs(t-e))):1/0}},{"../../components/color":297,"../../components/dragelement":317,"../../components/drawing":319,"../../lib":372,"../../lib/events":366,"../../lib/svg_text_utils":384,"./axes":393,"./constants":398,"./dragbox":399,d3:87,"fast-isnumeric":95,tinycolor2:275}],401:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../plots"),a=t("./constants");r.name="cartesian",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex=a.idRegex,r.attrRegex=a.attrRegex,r.attributes=t("./attributes"),r.plot=function(t){function e(t,e){for(var r=[],n=0;nf[1]-.01&&(e.domain=[0,1]),i.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":372,"fast-isnumeric":95}],406:[function(t,e,r){"use strict";function n(t){return t._id}var i=t("../../lib/polygon"),a=t("../../components/color"),o=t("./axes"),s=t("./constants"),l=i.filter,c=i.tester,u=s.MINSELECT;e.exports=function(t,e,r,i,f){function h(t){var e="y"===t._id.charAt(0)?1:0;return function(r){return t.p2d(r[e])}}function d(t,e){return t-e}var p,g=i.gd._fullLayout._zoomlayer,v=i.element.getBoundingClientRect(),m=i.plotinfo.x()._offset,y=i.plotinfo.y()._offset,b=e-v.left,x=r-v.top,_=b,w=x,k="M"+b+","+x,A=i.xaxes[0]._length,M=i.yaxes[0]._length,T=i.xaxes.map(n),E=i.yaxes.map(n),L=i.xaxes.concat(i.yaxes);"lasso"===f&&(p=l([[b,x]],s.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",k+"Z");var C,z,P,R,O,I=g.append("path").attr("class","zoombox-corners").style({fill:a.background,stroke:a.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),N=[],j=i.gd,F=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(0>=e&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-3*u*Math.abs(n-i))}return o.BADNUM}function r(t){return Math.pow(10,t)}function c(t){return i(t)?Number(t):o.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?r:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,r=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var n=l.getFromId(t._gd,t.overlaying);t.domain=n.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;2>e;e++)i(t.range[e])||(t.range[e]=i(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=r.t+(1-t.domain[1])*r.h,t._length=r.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=r.l+t.domain[0]*r.w,t._length=r.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]), +t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw a.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return i(e)?n.round(t._b+t._m*e,2):o.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,r){return t.l2p(t.c2l(e,r))},t.p2c=function(e){return t.l2c(t.p2l(e))},-1!==["linear","log","-"].indexOf(t.type))t.c2d=c,t.d2c=function(t){return t=s(t),i(t)?Number(t):o.BADNUM},t.d2l=function(e,r){return"log"===t.type?t.c2l(t.d2c(e),r):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return i(t)?a.ms2DateTime(t):o.BADNUM},t.d2c=function(t){return i(t)?Number(t):a.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(a.dateTime2ms);!i(t.range[0])&&i(f[0])&&(t.range[0]=f[0]),!i(t.range[1])&&i(f[1])&&(t.range[1]=f[1])}catch(h){console.log(h,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&-1===t._categories.indexOf(e)&&t._categories.push(e);var r=t._categories.indexOf(e);return-1===r?o.BADNUM:r},t.d2l=t.d2c);t.makeCalcdata=function(e,r){var n,i,a;if(r in e)for(n=e[r],i=new Array(n.length),a=0;an?"0":"1.0"}var r=this.framework,n=r.select("g.choroplethlayer"),i=r.select("g.scattergeolayer"),a=this.projection,o=this.path,s=this.clipAngle;r.selectAll("path.basepath").attr("d",o),r.selectAll("path.graticulepath").attr("d",o),n.selectAll("path.choroplethlocation").attr("d",o),n.selectAll("path.basepath").attr("d",o),i.selectAll("path.js-line").attr("d",o),null!==s?(i.selectAll("path.point").style("opacity",e).attr("transform",t),i.selectAll("text").style("opacity",e).attr("transform",t)):(i.selectAll("path.point").attr("transform",t),i.selectAll("text").attr("transform",t))}},{"../../components/color":297,"../../components/drawing":319,"../../constants/geo_constants":356,"../../constants/xmlns_namespaces":360,"../../lib/filter_visible":368,"../../lib/topojson_utils":385,"../../plots/cartesian/axes":393,"./projections":419,"./set_scale":420,"./zoom":421,"./zoom_reset":422,d3:87,topojson:277}],413:[function(t,e,r){"use strict";var n=t("./geo"),i=t("../../plots/plots");r.name="geo",r.attr="geo",r.idRoot="geo",r.idRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"geo");void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var o=0;o=n}function a(t,e){for(var r=e[0],n=e[1],i=!1,a=0,o=t.length,s=o-1;o>a;s=a++){var l=t[a],c=l[0],u=l[1],f=t[s],h=f[0],d=f[1];u>n^d>n&&(h-c)*(n-u)/(d-u)+c>r&&(i=!i)}return i}function o(t){return t>1?L:-1>t?-L:Math.asin(t)}function s(t,e){var r=(2+L)*Math.sin(e);e/=2;for(var n=0,i=1/0;10>n&&Math.abs(i)>M;n++){var a=Math.cos(e);e-=i=(e+Math.sin(e)*(a+2)-r)/(2*a*(1+a))}return[2/Math.sqrt(E*(4+E))*t*(1+Math.cos(e)),2*Math.sqrt(E/(4+E))*Math.sin(e)]}function l(t,e){function r(r,n){var i=R(r/e,n);return i[0]*=t,i}return arguments.length<2&&(e=t),1===e?R:e===1/0?u:(r.invert=function(r,n){var i=R.invert(r/t,n);return i[0]*=e,i},r)}function c(){var t=2,e=P(l),r=e(t);return r.coefficient=function(r){return arguments.length?e(t=+r):t},r}function u(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function f(t,e){return[3*t/(2*E)*Math.sqrt(E*E/3-e*e),e]}function h(t,e){return[t,1.25*Math.log(Math.tan(E/4+.4*e))]}function d(t){return function(e){var r,n=t*Math.sin(e),i=30;do e-=r=(e+Math.sin(e)-n)/(1+Math.cos(e));while(Math.abs(r)>M&&--i>0);return e/2}}function p(t,e,r){function n(r,n){return[t*r*Math.cos(n=i(n)),e*Math.sin(n)]}var i=d(r);return n.invert=function(n,i){var a=o(i/e);return[n/(t*Math.cos(a)),o((2*a+Math.sin(2*a))/r)]},n}function g(t,e){var r=e*e,n=r*r;return[t*(.8707-.131979*r+n*(-.013791+n*(.003971*r-.001529*n))),e*(1.007226+r*(.015085+n*(-.044475+.028874*r-.005916*n)))]}function v(t,e){var r,n=Math.min(18,36*Math.abs(e)/E),i=Math.floor(n),a=n-i,o=(r=I[i])[0],s=r[1],l=(r=I[++i])[0],c=r[1],u=(r=I[Math.min(19,++i)])[0],f=r[1];return[t*(l+a*(u-o)/2+a*a*(u-2*l+o)/2),(e>0?L:-L)*(c+a*(f-s)/2+a*a*(f-2*c+s)/2)]}function m(t,e){return[t*Math.cos(e),e]}i.geo.project=function(t,r){var n=r.stream;if(!n)throw new Error("not yet supported");return(t&&y.hasOwnProperty(t.type)?y[t.type]:e)(t,n)};var y={Feature:t,FeatureCollection:function(e,r){return{type:"FeatureCollection",features:e.features.map(function(e){return t(e,r)})}}},b=[],x=[],_={point:function(t,e){b.push([t,e])},result:function(){var t=b.length?b.length<2?{type:"Point",coordinates:b[0]}:{type:"MultiPoint",coordinates:b}:null;return b=[],t}},w={lineStart:r,point:function(t,e){b.push([t,e])},lineEnd:function(){b.length&&(x.push(b),b=[])},result:function(){var t=x.length?x.length<2?{type:"LineString",coordinates:x[0]}:{type:"MultiLineString",coordinates:x}:null;return x=[],t}},k={polygonStart:r,lineStart:r,point:function(t,e){b.push([t,e])},lineEnd:function(){var t=b.length;if(t){do b.push(b[0].slice());while(++t<4);x.push(b),b=[]}},polygonEnd:r,result:function(){if(!x.length)return null;var t=[],e=[];return x.forEach(function(r){n(r)?t.push([r]):e.push(r)}),e.forEach(function(e){var r=e[0];t.some(function(t){return a(t[0],r)?(t.push(e),!0):void 0})||t.push([e])}),x=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},A={Point:_,MultiPoint:_,LineString:w,MultiLineString:w,Polygon:k,MultiPolygon:k,Sphere:k},M=1e-6,T=M*M,E=Math.PI,L=E/2,S=(Math.sqrt(E),E/180),C=180/E,z=i.geo.projection,P=i.geo.projectionMutator;i.geo.interrupt=function(t){function e(e,r){for(var n=0>r?-1:1,i=l[+(0>r)],a=0,o=i.length-1;o>a&&e>i[a][2][0];++a);var s=t(e-i[a][1][0],r);return s[0]+=t(i[a][1][0],n*r>n*i[a][0][1]?i[a][0][1]:r)[0],s}function r(){s=l.map(function(e){return e.map(function(e){var r,n=t(e[0][0],e[0][1])[0],i=t(e[2][0],e[2][1])[0],a=t(e[1][0],e[0][1])[1],o=t(e[1][0],e[1][1])[1];return a>o&&(r=a,a=o,o=r),[[n,a],[i,o]]})})}function n(){for(var t=1e-6,e=[],r=0,n=l[0].length;n>r;++r){var o=l[0][r],s=180*o[0][0]/E,c=180*o[0][1]/E,u=180*o[1][1]/E,f=180*o[2][0]/E,h=180*o[2][1]/E;e.push(a([[s+t,c+t],[s+t,u-t],[f-t,u-t],[f-t,h+t]],30))}for(var r=l[1].length-1;r>=0;--r){var o=l[1][r],s=180*o[0][0]/E,c=180*o[0][1]/E,u=180*o[1][1]/E,f=180*o[2][0]/E,h=180*o[2][1]/E;e.push(a([[f-t,h-t],[f-t,u+t],[s+t,u+t],[s+t,c-t]],30))}return{type:"Polygon",coordinates:[i.merge(e)]}}function a(t,e){for(var r,n,i,a=-1,o=t.length,s=t[0],l=[];++ac;++c)l.push([s[0]+c*n,s[1]+c*i]);s=r}return l.push(r),l}function o(t,e){return Math.abs(t[0]-e[0])n)],a=l[+(0>n)],c=0,u=i.length;u>c;++c){var f=i[c];if(f[0][0]<=r&&rM&&--i>0);return[t/(.8707+(a=n*n)*(-.131979+a*(-.013791+a*a*a*(.003971-.001529*a)))),n]},(i.geo.naturalEarth=function(){return z(g)}).raw=g;var I=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];I.forEach(function(t){t[1]*=1.0144}),v.invert=function(t,e){var r=e/L,n=90*r,i=Math.min(18,Math.abs(n/5)),a=Math.max(0,Math.floor(i));do{var o=I[a][1],s=I[a+1][1],l=I[Math.min(19,a+2)][1],c=l-o,u=l-2*s+o,f=2*(Math.abs(r)-s)/c,h=u/c,d=f*(1-h*f*(1-2*h*f));if(d>=0||1===a){n=(e>=0?5:-5)*(d+i);var p,g=50;do i=Math.min(18,Math.abs(n)/5),a=Math.floor(i),d=i-a,o=I[a][1],s=I[a+1][1],l=I[Math.min(19,a+2)][1],n-=(p=(e>=0?L:-L)*(s+d*(l-o)/2+d*d*(l-2*s+o)/2)-e)*C;while(Math.abs(p)>T&&--g>0);break}}while(--a>=0);var v=I[a][0],m=I[a+1][0],y=I[Math.min(19,a+2)][0];return[t/(m+d*(y-v)/2+d*d*(y-2*m+v)/2),n*S]},(i.geo.robinson=function(){return z(v)}).raw=v,m.invert=function(t,e){return[t/Math.cos(e),e]},(i.geo.sinusoidal=function(){return z(m)}).raw=m}var i=t("d3");e.exports=n},{d3:87}],420:[function(t,e,r){"use strict";function n(t,e){var r=t.projection,n=t.lonaxis,o=t.lataxis,l=t.domain,c=t.framewidth||0,u=e.w*(l.x[1]-l.x[0]),f=e.h*(l.y[1]-l.y[0]),h=n.range[0]+s,d=n.range[1]-s,p=o.range[0]+s,g=o.range[1]-s,v=n._fullRange[0]+s,m=n._fullRange[1]-s,y=o._fullRange[0]+s,b=o._fullRange[1]-s;r._translate0=[e.l+u/2,e.t+f/2];var x=d-h,_=g-p,w=[h+x/2,p+_/2],k=r._rotate;r._center=[w[0]+k[0],w[1]+k[1]];var A=function(e){function n(t){return Math.min(_*u/(t[1][0]-t[0][0]),_*f/(t[1][1]-t[0][1]))}var o,s,l,x,_=e.scale(),w=r._translate0,k=i(h,p,d,g),A=i(v,y,m,b);l=a(e,k),o=n(l),x=a(e,A),r._fullScale=n(x),e.scale(o),l=a(e,k),s=[w[0]-l[0][0]+c,w[1]-l[0][1]+c],r._translate=s,e.translate(s),l=a(e,k),t._isAlbersUsa||e.clipExtent(l),o=r.scale*o,r._scale=o,t._width=Math.round(l[1][0])+c,t._height=Math.round(l[1][1])+c,t._marginX=(u-Math.round(l[1][0]))/2,t._marginY=(f-Math.round(l[1][1]))/2};return A}function i(t,e,r,n){var i=(r-t)/4;return{type:"Polygon",coordinates:[[[t,e],[t,n],[t+i,n],[t+2*i,n],[t+3*i,n],[r,n],[r,e],[r-i,e],[r-2*i,e],[r-3*i,e],[t,e]]]}}function a(t,e){return o.geo.path().projection(t).bounds(e)}var o=t("d3"),s=t("../../constants/geo_constants").clipPad;e.exports=n},{"../../constants/geo_constants":356,d3:87}],421:[function(t,e,r){"use strict";function n(t,e){var r;return(r=e._isScoped?a:e._clipAngle?s:o)(t,e.projection)}function i(t,e){var r=e._fullScale;return _.behavior.zoom().translate(t.translate()).scale(t.scale()).scaleExtent([.5*r,100*r])}function a(t,e){function r(){_.select(this).style(A)}function n(){o.scale(_.event.scale).translate(_.event.translate),t.render()}function a(){_.select(this).style(M)}var o=t.projection,s=i(o,e);return s.on("zoomstart",r).on("zoom",n).on("zoomend",a),s}function o(t,e){function r(t){return v.invert(t)}function n(t){var e=v(r(t));return Math.abs(e[0]-t[0])>y||Math.abs(e[1]-t[1])>y}function a(){_.select(this).style(A),l=_.mouse(this),c=v.rotate(),u=v.translate(),f=c,h=r(l)}function o(){return d=_.mouse(this),n(l)?(m.scale(v.scale()),void m.translate(v.translate())):(v.scale(_.event.scale),v.translate([u[0],_.event.translate[1]]),h?r(d)&&(g=r(d),p=[f[0]+(g[0]-h[0]),c[1],c[2]],v.rotate(p),f=p):(l=d,h=r(l)),void t.render())}function s(){_.select(this).style(M)}var l,c,u,f,h,d,p,g,v=t.projection,m=i(v,e),y=2;return m.on("zoomstart",a).on("zoom",o).on("zoomend",s),m}function s(t,e){function r(t){m++||t({type:"zoomstart"})}function n(t){t({type:"zoom"})}function a(t){--m||t({type:"zoomend"})}var o,s=t.projection,d={r:s.rotate(),k:s.scale()},p=i(s,e),g=x(p,"zoomstart","zoom","zoomend"),m=0,y=p.on;return p.on("zoomstart",function(){_.select(this).style(A);var t=_.mouse(this),e=s.rotate(),i=e,a=s.translate(),m=c(e);o=l(s,t),y.call(p,"zoom",function(){var r=_.mouse(this);if(s.scale(d.k=_.event.scale),o){if(l(s,r)){s.rotate(e).translate(a);var c=l(s,r),p=f(o,c),y=v(u(m,p)),b=d.r=h(y,o,i);isFinite(b[0])&&isFinite(b[1])&&isFinite(b[2])||(b=i),s.rotate(b),i=b}}else t=r,o=l(s,t);n(g.of(this,arguments))}),r(g.of(this,arguments))}).on("zoomend",function(){_.select(this).style(M),y.call(p,"zoom",null),a(g.of(this,arguments))}).on("zoom.redraw",function(){t.render()}),_.rebind(p,g,"on")}function l(t,e){var r=t.invert(e);return r&&isFinite(r[0])&&isFinite(r[1])&&m(r)}function c(t){var e=.5*t[0]*w,r=.5*t[1]*w,n=.5*t[2]*w,i=Math.sin(e),a=Math.cos(e),o=Math.sin(r),s=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return[a*s*c+i*o*l,i*s*c-a*o*l,a*o*c+i*s*l,a*s*l-i*o*c]}function u(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=e[0],s=e[1],l=e[2],c=e[3];return[r*o-n*s-i*l-a*c,r*s+n*o+i*c-a*l,r*l-n*c+i*o+a*s,r*c+n*l-i*s+a*o]}function f(t,e){if(t&&e){var r=b(t,e),n=Math.sqrt(y(r,r)),i=.5*Math.acos(Math.max(-1,Math.min(1,y(t,e)))),a=Math.sin(i)/n;return n&&[Math.cos(i),r[2]*a,-r[1]*a,r[0]*a]}}function h(t,e,r){var n=g(e,2,t[0]);n=g(n,1,t[1]),n=g(n,0,t[2]-r[2]);var i,a,o=e[0],s=e[1],l=e[2],c=n[0],u=n[1],f=n[2],h=Math.atan2(s,o)*k,p=Math.sqrt(o*o+s*s);Math.abs(u)>p?(a=(u>0?90:-90)-h,i=0):(a=Math.asin(u/p)*k-h,i=Math.sqrt(p*p-u*u));var v=180-a-2*h,m=(Math.atan2(f,c)-Math.atan2(l,i))*k,y=(Math.atan2(f,c)-Math.atan2(l,-i))*k,b=d(r[0],r[1],a,m),x=d(r[0],r[1],v,y);return x>=b?[a,m,r[2]]:[v,y,r[2]]}function d(t,e,r,n){var i=p(r-t),a=p(n-e);return Math.sqrt(i*i+a*a)}function p(t){return(t%360+540)%360-180}function g(t,e,r){var n=r*w,i=t.slice(),a=0===e?1:0,o=2===e?1:2,s=Math.cos(n),l=Math.sin(n);return i[a]=t[a]*s-t[o]*l,i[o]=t[o]*s+t[a]*l,i}function v(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*k,Math.asin(Math.max(-1,Math.min(1,2*(t[0]*t[2]-t[3]*t[1]))))*k,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*k]}function m(t){var e=t[0]*w,r=t[1]*w,n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function y(t,e){for(var r=0,n=0,i=t.length;i>n;++n)r+=t[n]*e[n];return r}function b(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function x(t){for(var e=0,r=arguments.length,n=[];++ed;++d){for(e=c[d],r=t[this.scene[e]._name],n=/Click to enter .+ title/.test(r.title)?"":r.title,p=0;2>=p;p+=2)this.labelEnable[d+p]=!1,this.labels[d+p]=o(n),this.labelColor[d+p]=s(r.titlefont.color),this.labelFont[d+p]=r.titlefont.family,this.labelSize[d+p]=r.titlefont.size,this.labelPad[d+p]=this.getLabelPad(e,r),this.tickEnable[d+p]=!1,this.tickColor[d+p]=s((r.tickfont||{}).color), +this.tickAngle[d+p]="auto"===r.tickangle?0:Math.PI*-r.tickangle/180,this.tickPad[d+p]=this.getTickPad(r),this.tickMarkLength[d+p]=0,this.tickMarkWidth[d+p]=r.tickwidth||0,this.tickMarkColor[d+p]=s(r.tickcolor),this.borderLineEnable[d+p]=!1,this.borderLineColor[d+p]=s(r.linecolor),this.borderLineWidth[d+p]=r.linewidth||0;u=this.hasSharedAxis(r),a=this.hasAxisInDfltPos(e,r)&&!u,l=this.hasAxisInAltrPos(e,r)&&!u,i=r.mirror||!1,f=u?-1!==String(i).indexOf("all"):!!i,h=u?"allticks"===i:-1!==String(i).indexOf("ticks"),a?this.labelEnable[d]=!0:l&&(this.labelEnable[d+2]=!0),a?this.tickEnable[d]=r.showticklabels:l&&(this.tickEnable[d+2]=r.showticklabels),(a||f)&&(this.borderLineEnable[d]=r.showline),(l||f)&&(this.borderLineEnable[d+2]=r.showline),(a||h)&&(this.tickMarkLength[d]=this.getTickMarkLength(r)),(l||h)&&(this.tickMarkLength[d+2]=this.getTickMarkLength(r)),this.gridLineEnable[d]=r.showgrid,this.gridLineColor[d]=s(r.gridcolor),this.gridLineWidth[d]=r.gridwidth,this.zeroLineEnable[d]=r.zeroline,this.zeroLineColor[d]=s(r.zerolinecolor),this.zeroLineWidth[d]=r.zerolinewidth}},l.hasSharedAxis=function(t){var e=this.scene,r=a.Plots.getSubplotIds(e.fullLayout,"gl2d"),n=a.Axes.findSubplotsWithAxis(r,t);return 0!==n.indexOf(e.id)},l.hasAxisInDfltPos=function(t,e){var r=e.side;return"xaxis"===t?"bottom"===r:"yaxis"===t?"left"===r:void 0},l.hasAxisInAltrPos=function(t,e){var r=e.side;return"xaxis"===t?"top"===r:"yaxis"===t?"right"===r:void 0},l.getLabelPad=function(t,e){var r=1.5,n=e.titlefont.size,i=e.showticklabels;return"xaxis"===t?"top"===e.side?-10+n*(r+(i?1:0)):-10+n*(r+(i?.5:0)):"yaxis"===t?"right"===e.side?10+n*(r+(i?1:.5)):10+n*(r+(i?.5:0)):void 0},l.getTickPad=function(t){return"outside"===t.ticks?10+t.ticklen:15},l.getTickMarkLength=function(t){if(!t.ticks)return 0;var e=t.ticklen;return"inside"===t.ticks?-e:e},e.exports=i},{"../../lib/html2unicode":371,"../../lib/str2rgbarray":383,"../../plotly":390}],425:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("./scene2d"),a=n.Plots;r.name="gl2d",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex={x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},r.attrRegex={x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},r.attributes=t("../cartesian/attributes"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,n=a.getSubplotIds(e,"gl2d"),o=0;or;++r){var n=t[r],i=e[r];if(n.length!==i.length)return!0;for(var a=0;ao;++o,--s)for(var l=0;r>l;++l)for(var c=0;4>c;++c){var u=i[4*(r*o+l)+c];i[4*(r*o+l)+c]=i[4*(r*s+l)+c],i[4*(r*s+l)+c]=u}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticPlot&&this.container.removeChild(a),p},m.computeTickMarks=function(){this.xaxis._length=this.glplot.viewBox[2]-this.glplot.viewBox[0],this.yaxis._length=this.glplot.viewBox[3]-this.glplot.viewBox[1];for(var t=[s.calcTicks(this.xaxis),s.calcTicks(this.yaxis)],e=0;2>e;++e)for(var r=0;rk;++k)w[k]=Math.min(w[k],a.bounds[k]),w[k+2]=Math.max(w[k+2],a.bounds[k+2])}var A;for(n=0;2>n;++n)w[n]>w[n+2]&&(w[n]=-1,w[n+2]=1),A=this[v[n]],A._length=y.viewBox[n+2]-y.viewBox[n],s.doAutoRange(A);y.ticks=this.computeTickMarks();var M=this.xaxis.range,T=this.yaxis.range;y.dataBox=[M[0],T[0],M[1],T[1]],y.merge(r),o.update(y),this.glplot.draw()},m.draw=function(){if(!this.stopped){requestAnimationFrame(this.redraw);var t=this.glplot,e=this.camera,r=e.mouseListener,n=this.fullLayout;this.cameraChanged();var i=r.x*t.pixelRatio,a=this.canvas.height-t.pixelRatio*r.y;if(e.boxEnabled&&"zoom"===n.dragmode)this.selectBox.enabled=!0,this.selectBox.selectBox=[Math.min(e.boxStart[0],e.boxEnd[0]),Math.min(e.boxStart[1],e.boxEnd[1]),Math.max(e.boxStart[0],e.boxEnd[0]),Math.max(e.boxStart[1],e.boxEnd[1])],t.setDirty();else{this.selectBox.enabled=!1;var o=n._size,s=this.xaxis.domain,c=this.yaxis.domain,u=t.pick(i/t.pixelRatio+o.l+s[0]*o.w,a/t.pixelRatio-(o.t+(1-c[1])*o.h));if(u&&n.hovermode){var f=u.object._trace.handlePick(u);if(f&&(!this.lastPickResult||this.lastPickResult.trace!==f.trace||this.lastPickResult.dataCoord[0]!==f.dataCoord[0]||this.lastPickResult.dataCoord[1]!==f.dataCoord[1])){var h=this.lastPickResult=f;this.spikes.update({center:u.dataCoord}),h.screenCoord=[((t.viewBox[2]-t.viewBox[0])*(u.dataCoord[0]-t.dataBox[0])/(t.dataBox[2]-t.dataBox[0])+t.viewBox[0])/t.pixelRatio,(this.canvas.height-(t.viewBox[3]-t.viewBox[1])*(u.dataCoord[1]-t.dataBox[1])/(t.dataBox[3]-t.dataBox[1])-t.viewBox[1])/t.pixelRatio];var d=h.hoverinfo;if("all"!==d){var p=d.split("+");-1===p.indexOf("x")&&(h.traceCoord[0]=void 0),-1===p.indexOf("y")&&(h.traceCoord[1]=void 0),-1===p.indexOf("z")&&(h.traceCoord[2]=void 0),-1===p.indexOf("text")&&(h.textLabel=void 0),-1===p.indexOf("name")&&(h.name=void 0)}l.loneHover({x:h.screenCoord[0],y:h.screenCoord[1],xLabel:this.hoverFormatter("xaxis",h.traceCoord[0]),yLabel:this.hoverFormatter("yaxis",h.traceCoord[1]),zLabel:h.traceCoord[2],text:h.textLabel,name:h.name,color:h.color},{container:this.svgContainer}),this.lastPickResult={dataCoord:u.dataCoord}}}else!u&&this.lastPickResult&&(this.spikes.update({}),this.lastPickResult=null,l.loneUnhover(this.svgContainer))}t.draw()}},m.hoverFormatter=function(t,e){if(void 0!==e){var r=this[t];return s.tickText(r,r.c2l(e),"hover").text}}},{"../../lib/html2unicode":371,"../../lib/show_no_webgl_msg":381,"../../plots/cartesian/axes":393,"../../plots/cartesian/graph_interact":400,"./camera":423,"./convert":424,"gl-plot2d":149,"gl-select-box":164,"gl-spikes2d":173}],427:[function(t,e,r){"use strict";function n(t,e){t=t||document.body,e=e||{};var r=[.01,1/0];"distanceLimits"in e&&(r[0]=e.distanceLimits[0],r[1]=e.distanceLimits[1]),"zoomMin"in e&&(r[0]=e.zoomMin),"zoomMax"in e&&(r[1]=e.zoomMax);var n=a({center:e.center||[0,0,0],up:e.up||[0,1,0],eye:e.eye||[0,0,10],mode:e.mode||"orbit",distanceLimits:r}),l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0,u=t.clientWidth,f=t.clientHeight,h={keyBindingMode:"rotate",view:n,element:t,delay:e.delay||16,rotateSpeed:e.rotateSpeed||1,zoomSpeed:e.zoomSpeed||1,translateSpeed:e.translateSpeed||1,flipX:!!e.flipX,flipY:!!e.flipY,modes:n.modes,tick:function(){var e=i(),r=this.delay,a=e-2*r;n.idle(e-r),n.recalcMatrix(a),n.flush(e-(100+2*r));for(var o=!0,s=n.computedMatrix,h=0;16>h;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){var e=n.computedUp.slice(),r=n.computedEye.slice(),a=n.computedCenter.slice();if(n.setMode(t),"turntable"===t){var o=i();n._active.lookAt(o,r,a,e),n._active.lookAt(o+500,r,a,[0,0,1]),n._active.flush(o)}return n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s="rotate"===h.keyBindingMode,l="pan"===h.keyBindingMode,u="zoom"===h.keyBindingMode,f=!!o.control,g=!!o.alt,v=!!o.shift,m=!!(1&e),y=!!(2&e),b=!!(4&e),x=1/t.clientHeight,_=x*(r-d),w=x*(a-p),k=h.flipX?1:-1,A=h.flipY?1:-1,M=i(),T=Math.PI*h.rotateSpeed;if((s&&m&&!f&&!g&&!v||m&&!f&&!g&&v)&&n.rotate(M,k*T*_,-A*T*w,0),(l&&m&&!f&&!g&&!v||y||m&&f&&!g&&!v)&&n.pan(M,-h.translateSpeed*_*c,h.translateSpeed*w*c,0),u&&m&&!f&&!g&&!v||b||m&&!f&&g&&!v){var E=-h.zoomSpeed*w/window.innerHeight*(M-n.lastT())*100;n.pan(M,0,0,c*(Math.exp(E)-1))}return d=r,p=a,!0}),s(t,function(t,e){var r=h.flipX?1:-1,a=h.flipY?1:-1,o=i();if(Math.abs(t)>Math.abs(e))n.rotate(o,0,0,-t*r*Math.PI*h.rotateSpeed/window.innerWidth);else{var s=-h.zoomSpeed*a*e/window.innerHeight*(o-n.lastT())/100;n.pan(o,0,0,c*(Math.exp(s)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":21,"mouse-change":211,"mouse-wheel":213,"right-now":247}],428:[function(t,e,r){"use strict";var n=t("./scene"),i=t("../plots"),a=["xaxis","yaxis","zaxis"];r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"gl3d");e._paperdiv.style({width:e.width+"px",height:e.height+"px"}),t._context.setBackground(t,e.paper_bgcolor);for(var o=0;ol;++l){var c=a[l],u=s[c];u._gd=t}}},{"../plots":441,"./layout/attributes":429,"./layout/defaults":433,"./layout/layout_attributes":434,"./scene":438,"./set_convert":439}],429:[function(t,e,r){"use strict";e.exports={scene:{valType:"subplotid",dflt:"scene"}}},{}],430:[function(t,e,r){"use strict";var n=t("../../../components/color"),i=t("../../cartesian/layout_attributes"),a=t("../../../lib/extend").extendFlat;e.exports={showspikes:{valType:"boolean",dflt:!0},spikesides:{valType:"boolean",dflt:!0},spikethickness:{valType:"number",min:0,dflt:2},spikecolor:{valType:"color",dflt:n.defaultLine},showbackground:{valType:"boolean",dflt:!1},backgroundcolor:{valType:"color",dflt:"rgba(204, 204, 204, 0.5)"},showaxeslabels:{valType:"boolean",dflt:!0},color:i.color,categoryorder:i.categoryorder,categoryarray:i.categoryarray,title:i.title,titlefont:i.titlefont,type:i.type,autorange:i.autorange,rangemode:i.rangemode,range:i.range,fixedrange:i.fixedrange,tickmode:i.tickmode,nticks:i.nticks,tick0:i.tick0,dtick:i.dtick,tickvals:i.tickvals,ticktext:i.ticktext,ticks:i.ticks,mirror:i.mirror,ticklen:i.ticklen,tickwidth:i.tickwidth,tickcolor:i.tickcolor,showticklabels:i.showticklabels,tickfont:i.tickfont,tickangle:i.tickangle,tickprefix:i.tickprefix,showtickprefix:i.showtickprefix,ticksuffix:i.ticksuffix,showticksuffix:i.showticksuffix,showexponent:i.showexponent,exponentformat:i.exponentformat,tickformat:i.tickformat,hoverformat:i.hoverformat,showline:i.showline,linecolor:i.linecolor,linewidth:i.linewidth,showgrid:i.showgrid,gridcolor:a({},i.gridcolor,{dflt:"rgb(204, 204, 204)"}),gridwidth:i.gridwidth,zeroline:i.zeroline,zerolinecolor:i.zerolinecolor,zerolinewidth:i.zerolinewidth}},{"../../../components/color":297,"../../../lib/extend":367,"../../cartesian/layout_attributes":402}],431:[function(t,e,r){"use strict";var n=t("tinycolor2").mix,i=t("../../../lib"),a=t("./axis_attributes"),o=t("../../cartesian/axis_defaults"),s=["xaxis","yaxis","zaxis"],l=function(){},c=13600/187;e.exports=function(t,e,r){function u(t,e){return i.coerce(f,h,a,t,e)}for(var f,h,d=0;dr;++r){var n=t[c[r]];e.labels[r]=o(n.title),"titlefont"in n&&(n.titlefont.color&&(e.labelColor[r]=s(n.titlefont.color)),n.titlefont.family&&(e.labelFont[r]=n.titlefont.family),n.titlefont.size&&(e.labelSize[r]=n.titlefont.size)),"showline"in n&&(e.lineEnable[r]=n.showline),"linecolor"in n&&(e.lineColor[r]=s(n.linecolor)),"linewidth"in n&&(e.lineWidth[r]=n.linewidth),"showgrid"in n&&(e.gridEnable[r]=n.showgrid),"gridcolor"in n&&(e.gridColor[r]=s(n.gridcolor)),"gridwidth"in n&&(e.gridWidth[r]=n.gridwidth),"log"===n.type?e.zeroEnable[r]=!1:"zeroline"in n&&(e.zeroEnable[r]=n.zeroline),"zerolinecolor"in n&&(e.zeroLineColor[r]=s(n.zerolinecolor)),"zerolinewidth"in n&&(e.zeroLineWidth[r]=n.zerolinewidth),"ticks"in n&&n.ticks?e.lineTickEnable[r]=!0:e.lineTickEnable[r]=!1,"ticklen"in n&&(e.lineTickLength[r]=e._defaultLineTickLength[r]=n.ticklen),"tickcolor"in n&&(e.lineTickColor[r]=s(n.tickcolor)),"tickwidth"in n&&(e.lineTickWidth[r]=n.tickwidth),"tickangle"in n&&(e.tickAngle[r]="auto"===n.tickangle?0:Math.PI*-n.tickangle/180),"showticklabels"in n&&(e.tickEnable[r]=n.showticklabels),"tickfont"in n&&(n.tickfont.color&&(e.tickColor[r]=s(n.tickfont.color)),n.tickfont.family&&(e.tickFont[r]=n.tickfont.family),n.tickfont.size&&(e.tickSize[r]=n.tickfont.size)),"mirror"in n?-1!==["ticks","all","allticks"].indexOf(n.mirror)?(e.lineTickMirror[r]=!0,e.lineMirror[r]=!0):n.mirror===!0?(e.lineTickMirror[r]=!1,e.lineMirror[r]=!0):(e.lineTickMirror[r]=!1,e.lineMirror[r]=!1):e.lineMirror[r]=!1,"showbackground"in n&&n.showbackground!==!1?(e.backgroundEnable[r]=!0,e.backgroundColor[r]=s(n.backgroundcolor)):e.backgroundEnable[r]=!1}},e.exports=i},{"../../../lib/html2unicode":371,"../../../lib/str2rgbarray":383,arraytools:27}],433:[function(t,e,r){"use strict";function n(t,e,r,n){for(var a=r("bgcolor"),l=i.combine(a,n.paper_bgcolor),c=Object.keys(o.camera),u=0;ue;++e){var r=t[o[e]];this.enabled[e]=r.showspikes,this.colors[e]=a(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness}},e.exports=i},{"../../../lib/str2rgbarray":383}],436:[function(t,e,r){"use strict";function n(t){for(var e=new Array(3),r=0;3>r;++r){for(var n=t[r],i=new Array(n.length),a=0;au;++u){var f=i[s[u]];if(f._length=(r[u].hi-r[u].lo)*r[u].pixelsPerDataUnit/t.dataScale[u],Math.abs(f._length)===1/0)c[u]=[];else{f.range[0]=r[u].lo/t.dataScale[u],f.range[1]=r[u].hi/t.dataScale[u],f._m=1/(t.dataScale[u]*r[u].pixelsPerDataUnit),f.range[0]===f.range[1]&&(f.range[0]-=1,f.range[1]+=1);var h=f.tickmode;if("auto"===f.tickmode){f.tickmode="linear";var d=f.nticks||a.Lib.constrain(f._length/40,4,9);a.Axes.autoTicks(f,Math.abs(f.range[1]-f.range[0])/d)}for(var p=a.Axes.calcTicks(f),g=0;gu;++u){l[u]=.5*(t.glplot.bounds[0][u]+t.glplot.bounds[1][u]);for(var g=0;2>g;++g)e.bounds[g][u]=t.glplot.bounds[g][u]}t.contourLevels=n(c)}e.exports=i;var a=t("../../../plotly"),o=t("../../../lib/html2unicode"),s=["xaxis","yaxis","zaxis"],l=[0,0,0]},{"../../../lib/html2unicode":371,"../../../plotly":390}],437:[function(t,e,r){"use strict";function n(t,e){var r,n,i=[0,0,0,0];for(r=0;4>r;++r)for(n=0;4>n;++n)i[n]+=t[4*r+n]*e[r];return i}function i(t,e){var r=n(t.projection,n(t.view,n(t.model,[e[0],e[1],e[2],1])));return r}e.exports=i},{}],438:[function(t,e,r){"use strict";function n(t){function e(e,r){if("string"==typeof r)return r;var n=t.fullSceneLayout[e];return d.tickText(n,n.c2l(r),"hover").text}var r=t.svgContainer,n=t.container.getBoundingClientRect(),i=n.width,a=n.height;r.setAttributeNS(null,"viewBox","0 0 "+i+" "+a),r.setAttributeNS(null,"width",i),r.setAttributeNS(null,"height",a),w(t),t.glplot.axes.update(t.axesOptions);for(var o=Object.keys(t.traces),s=null,l=t.glplot.selection,c=0;ca;++a){var u=l[A[a]];b(u)}t?Array.isArray(t)||(t=[t]):t=[];for(var f=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],a=0;ao;++o)f[0][o]>f[1][o]?d[o]=1:f[1][o]===f[0][o]?d[o]=1:d[o]=1/(f[1][o]-f[0][o]);this.dataScale=d;for(var a=0;aa;++a){var u=l[A[a]],_=u.type;if(_ in x?(x[_].acc*=d[a],x[_].count+=1):x[_]={acc:d[a],count:1},u.autorange){for(m[0][a]=1/0,m[1][a]=-(1/0),o=0;om[1][a])m[0][a]=-1,m[1][a]=1;else{var k=m[1][a]-m[0][a];m[0][a]-=k/32,m[1][a]+=k/32}}else{var M=l[A[a]].range;m[0][a]=M[0],m[1][a]=M[1]}m[0][a]===m[1][a]&&(m[0][a]-=1,m[1][a]+=1),y[a]=m[1][a]-m[0][a],this.glplot.bounds[0][a]=m[0][a]*d[a],this.glplot.bounds[1][a]=m[1][a]*d[a]}for(var T=[1,1,1],a=0;3>a;++a){var u=l[A[a]],_=u.type,E=x[_];T[a]=Math.pow(E.acc,1/E.count)/d[a]}var L,S=4;if("auto"===l.aspectmode)L=Math.max.apply(null,T)/Math.min.apply(null,T)<=S?T:[1,1,1];else if("cube"===l.aspectmode)L=[1,1,1];else if("data"===l.aspectmode)L=T;else{if("manual"!==l.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var C=l.aspectratio;L=[C.x,C.y,C.z]}l.aspectratio.x=c.aspectratio.x=L[0],l.aspectratio.y=c.aspectratio.y=L[1],l.aspectratio.z=c.aspectratio.z=L[2],this.glplot.aspect=L;var z=l.domain||null,P=e._size||null;if(z&&P){var R=this.container.style;R.position="absolute",R.left=P.l+z.x[0]*P.w+"px",R.top=P.t+(1-z.y[1])*P.h+"px",R.width=P.w*(z.x[1]-z.x[0])+"px",R.height=P.h*(z.y[1]-z.y[0])+"px"}this.glplot.redraw()}},k.destroy=function(){this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null},k.setCameraToDefault=function(){this.setCamera({eye:{x:1.25,y:1.25,z:1.25},center:{x:0,y:0,z:0},up:{x:0,y:0,z:1}})},k.getCamera=function(){this.glplot.camera.view.recalcMatrix(this.camera.view.lastT()); +var t=this.glplot.camera.up,e=this.glplot.camera.center,r=this.glplot.camera.eye;return{up:{x:t[0],y:t[1],z:t[2]},center:{x:e[0],y:e[1],z:e[2]},eye:{x:r[0],y:r[1],z:r[2]}}},k.setCamera=function(t){function e(t){return[[t.eye.x,t.eye.y,t.eye.z],[t.center.x,t.center.y,t.center.z],[t.up.x,t.up.y,t.up.z]]}var r={};r[this.id]=t,this.glplot.camera.lookAt.apply(this,e(t)),this.graphDiv.emit("plotly_relayout",r)},k.saveCamera=function(t){function e(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return t[i[r]][a[n]]===e[i[r]][a[n]]}var r=this.getCamera(),n=f.nestedProperty(t,this.id+".camera"),i=n.get(),a=!1;if(void 0===i)a=!0;else for(var o=0;3>o;o++)for(var s=0;3>s;s++)if(!e(r,i,o,s)){a=!0;break}return a&&n.set(r),a},k.updateFx=function(t,e){var r=this.camera;r&&("orbit"===t?(r.mode="orbit",r.keyBindingMode="rotate"):"turntable"===t?(r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate"):r.keyBindingMode=t),this.fullSceneLayout.hovermode=e},k.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(l),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,n=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var i=new Uint8Array(r*n*4);e.readPixels(0,0,r,n,e.RGBA,e.UNSIGNED_BYTE,i);for(var a=0,o=n-1;o>a;++a,--o)for(var s=0;r>s;++s)for(var c=0;4>c;++c){var u=i[4*(r*a+s)+c];i[4*(r*a+s)+c]=i[4*(r*o+s)+c],i[4*(r*o+s)+c]=u}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticMode&&this.container.removeChild(l),p},e.exports=a},{"../../lib":372,"../../lib/show_no_webgl_msg":381,"../../lib/str2rgbarray":383,"../../plots/cartesian/axes":393,"../../plots/cartesian/graph_interact":400,"../../plots/plots":441,"./camera":427,"./layout/convert":432,"./layout/spikes":435,"./layout/tick_marks":436,"./project":437,"./set_convert":439,"gl-plot3d":151}],439:[function(t,e,r){"use strict";var n=t("../cartesian/axes"),i=function(){};e.exports=function(t){n.setConvert(t),t.setScale=i}},{"../cartesian/axes":393}],440:[function(t,e,r){"use strict";var n=t("../plotly"),i=t("./font_attributes"),a=t("../components/color/attributes"),o=n.Lib.extendFlat;e.exports={font:{family:o({},i.family,{dflt:'"Open Sans", verdana, arial, sans-serif'}),size:o({},i.size,{dflt:12}),color:o({},i.color,{dflt:a.defaultLine})},title:{valType:"string",dflt:"Click to enter Plot title"},titlefont:o({},i,{}),autosize:{valType:"enumerated",values:[!0,!1,"initial"]},width:{valType:"number",min:10,dflt:700},height:{valType:"number",min:10,dflt:450},margin:{l:{valType:"number",min:0,dflt:80},r:{valType:"number",min:0,dflt:80},t:{valType:"number",min:0,dflt:100},b:{valType:"number",min:0,dflt:80},pad:{valType:"number",min:0,dflt:0},autoexpand:{valType:"boolean",dflt:!0}},paper_bgcolor:{valType:"color",dflt:a.background},plot_bgcolor:{valType:"color",dflt:a.background},separators:{valType:"string",dflt:".,"},hidesources:{valType:"boolean",dflt:!1},smith:{valType:"enumerated",values:[!1],dflt:!1},showlegend:{valType:"boolean"},_hasCartesian:{valType:"boolean",dflt:!1},_hasGL3D:{valType:"boolean",dflt:!1},_hasGeo:{valType:"boolean",dflt:!1},_hasPie:{valType:"boolean",dflt:!1},_hasGL2D:{valType:"boolean",dflt:!1},_hasTernary:{valType:"boolean",dflt:!1},_composedModules:{"*":"Fx"},_nestedModules:{xaxis:"Axes",yaxis:"Axes",scene:"gl3d",geo:"geo",legend:"Legend",annotations:"Annotations",shapes:"Shapes",ternary:"ternary"}}},{"../components/color/attributes":296,"../plotly":390,"./font_attributes":411}],441:[function(t,e,r){"use strict";function n(t){return"object"==typeof t&&(t=t.type),t}function i(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#","class":"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){d.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}function a(t,e){for(var r,n=Object.keys(e),i=0;i=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var o=r.select(".js-link-to-tool"),s=r.select(".js-link-spacer"),c=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&i(t,o),s.text(o.text()&&c.text()?" - ":"")},d.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",r=l.select(t).append("div").attr("id","hiddenform").style("display","none"),n=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),i=n.append("input").attr({type:"text",name:"data"});return i.node().value=d.graphJson(t,!1,"keepdata"),n.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1},d.supplyDefaults=function(t){var e,r,n,i,o,s=t._fullLayout||{},l=t._fullLayout={},c=t.layout||{},f=t._fullData||[],h=t._fullData=[],p=t.data||[],g=t._modules=[];for(d.supplyLayoutGlobalDefaults(c,l),l._dataLength=p.length,d.supplyDataDefaults(p,h,l,g),e=0;ea&&(e=(r-1)/(i.l+i.r),i.l=Math.floor(e*i.l),i.r=Math.floor(e*i.r)),0>o&&(e=(n-1)/(i.t+i.b),i.t=Math.floor(e*i.t),i.b=Math.floor(e*i.b))}},d.autoMargin=function(t,e,r){var n=t._fullLayout;if(n._pushmargin||(n._pushmargin={}),n.margin.autoexpand!==!1){if(r){var i=void 0===r.pad?12:r.pad;r.l+r.r>.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0),n._pushmargin[e]={l:{val:r.x,size:r.l+i},r:{val:r.x,size:r.r+i},b:{val:r.y,size:r.b+i},t:{val:r.y,size:r.t+i}}}else delete n._pushmargin[e];t._replotting||d.doAutoMargin(t)}},d.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var r=e._size,n=JSON.stringify(r),i=Math.max(e.margin.l||0,0),a=Math.max(e.margin.r||0,0),o=Math.max(e.margin.t||0,0),s=Math.max(e.margin.b||0,0),l=e._pushmargin;return e.margin.autoexpand!==!1&&(l.base={l:{val:0,size:i},r:{val:1,size:a},t:{val:1,size:o},b:{val:0,size:s}},Object.keys(l).forEach(function(t){var r=l[t].l||{},n=l[t].b||{},u=r.val,f=r.size,h=n.val,d=n.size;Object.keys(l).forEach(function(t){if(c(f)&&l[t].r){var r=l[t].r.val,n=l[t].r.size;if(r>u){var p=(f*r+(n-e.width)*u)/(r-u),g=(n*(1-u)+(f-e.width)*(1-r))/(r-u);p>=0&&g>=0&&p+g>i+a&&(i=p,a=g)}}if(c(d)&&l[t].t){var v=l[t].t.val,m=l[t].t.size;if(v>h){var y=(d*v+(m-e.height)*h)/(v-h),b=(m*(1-h)+(d-e.height)*(1-v))/(v-h);y>=0&&b>=0&&y+b>s+o&&(s=y,o=b)}}})})),r.l=Math.round(i),r.r=Math.round(a),r.t=Math.round(o),r.b=Math.round(s),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,t._replotting||"{}"===n||n===JSON.stringify(e._size)?void 0:u.plot(t)},d.graphJson=function(t,e,r,n,i){function a(t){if("function"==typeof t)return null;if(f.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0&&!f.isPlainObject(t.stream))continue}else if("keepall"!==r&&(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0))continue;i[e]=a(t[e])}return i}return Array.isArray(t)?t.map(a):t&&t.getTime?f.ms2DateTime(t):t}(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&d.supplyDefaults(t);var o=i?t._fullData:t.data,s=i?t._fullLayout:t.layout,l={data:(o||[]).map(function(t){var r=a(t);return e&&delete r.fit,r})};return e||(l.layout=a(s)),t.framework&&t.framework.isPolar&&(l=t.framework.getConfig()),"object"===n?l:JSON.stringify(l)}},{"../components/color":297,"../lib":372,"../plotly":390,"./attributes":391,"./font_attributes":411,"./layout_attributes":440,d3:87,"fast-isnumeric":95}],442:[function(t,e,r){"use strict";var n=t("../../traces/scatter/attributes"),i=n.marker;e.exports={r:n.r,t:n.t,marker:{color:i.color,size:i.size,symbol:i.symbol,opacity:i.opacity}}},{"../../traces/scatter/attributes":540}],443:[function(t,e,r){"use strict";function n(t,e){var r={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return a({},e,r)}var i=t("../cartesian/layout_attributes"),a=t("../../lib/extend").extendFlat,o=a({},i.domain,{});e.exports={radialaxis:n("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:o,orientation:{valType:"number"}}),angularaxis:n("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:o}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":367,"../cartesian/layout_attributes":402}],444:[function(t,e,r){var n=t("../../plotly"),i=t("d3"),a=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},o=n.Lib.extendDeepAll;a.Axis=function(){function t(t){r=t||r;var c=l.data,f=l.layout;return("string"==typeof r||r.nodeName)&&(r=i.select(r)),r.datum(c).each(function(t,r){function l(t,e){return s(t)%360+f.orientation}var c=t.slice();u={data:a.util.cloneJson(c),layout:a.util.cloneJson(f)};var h=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[h],h=(h+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:i.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var d=c.filter(function(t,e){var r=t.visible;return"undefined"==typeof r||r===!0}),p=!1,g=d.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=i.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var r=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,n){t.yStack=[r],m.push(r),r=a.util.sumArrays(t.r,r)}),t.values});d=i.merge(y)}d.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var b=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;b=Math.max(10,b);var x,_=[f.margin.left+b,f.margin.top+b];if(p){var w=i.max(a.util.sumArrays(a.util.arrayLast(d).r[0],a.util.arrayLast(m)));x=[0,w]}else x=i.extent(a.util.flattenArray(d.map(function(t,e){return t.r})));f.radialAxis.domain!=a.DATAEXTENT&&(x[0]=0),n=i.scale.linear().domain(f.radialAxis.domain!=a.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:x).range([0,b]),u.layout.radialAxis.domain=n.domain();var k,A=a.util.flattenArray(d.map(function(t,e){return t.t})),M="string"==typeof A[0];M&&(A=a.util.deduplicate(A),k=A.slice(),A=i.range(A.length),d=d.map(function(t,e){var r=t;return t.t=[A],p&&(r.yStack=t.yStack),r}));var T=d.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===d.length,E=null===f.needsEndSpacing?M||!T:f.needsEndSpacing,L=f.angularAxis.domain&&f.angularAxis.domain!=a.DATAEXTENT&&!M&&f.angularAxis.domain[0]>=0,S=L?f.angularAxis.domain:i.extent(A),C=Math.abs(A[1]-A[0]);T&&!M&&(C=0);var z=S.slice();E&&M&&(z[1]+=C);var P=f.angularAxis.ticksCount||4;P>8&&(P=P/(P/8)+P%8),f.angularAxis.ticksStep&&(P=(z[1]-z[0])/P);var R=f.angularAxis.ticksStep||(z[1]-z[0])/(P*(f.minorTicks+1));k&&(R=Math.max(Math.round(R),1)),z[2]||(z[2]=R);var O=i.range.apply(this,z);if(O=O.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=i.scale.linear().domain(z.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=s.domain(),u.layout.angularAxis.endPadding=E?C:0,e=i.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var I="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",N=(new DOMParser).parseFromString(I,"application/xml"),j=this.appendChild(this.ownerDocument.importNode(N.documentElement,!0));e=i.select(j)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var F,B=e.select(".chart-group"),D={fill:"none",stroke:f.tickColor},U={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){F=e.select(".legend-group").attr({transform:"translate("+[b,f.margin.top]+")"}).style({display:"block"});var V=d.map(function(t,e){var r=a.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});a.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:o({},a.Legend.defaultConfig().legendConfig,{container:F,elements:V,reverseOrder:f.legend.reverseOrder})})();var q=F.node().getBBox();b=Math.min(f.width-q.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,b=Math.max(10,b),_=[f.margin.left+b,f.margin.top+b],n.range([0,b]),u.layout.radialAxis.domain=n.domain(),F.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else F=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),B.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(f.width-(f.margin.left+f.margin.right+2*b+(q?q.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*b))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),e.select(".outer-group").attr("transform","translate("+H+")"),f.title){var G=e.select("g.title-group text").style(U).text(f.title),Y=G.node().getBBox();G.attr({x:_[0]-Y.width/2,y:_[1]-b-20})}var X=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var W=X.selectAll("circle.grid-circle").data(n.ticks(5));W.enter().append("circle").attr({"class":"grid-circle"}).style(D),W.attr("r",n),W.exit().remove()}X.select("circle.outside-circle").attr({r:b}).style(D);var Z=e.select("circle.background-circle").attr({r:b}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var K=i.svg.axis().scale(n).ticks(5).tickSize(5);X.call(K).attr({transform:"rotate("+f.radialAxis.orientation+")"}),X.selectAll(".domain").style(D),X.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(U).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,U["font-size"]]+")":"translate("+[0,U["font-size"]]+")"}}),X.selectAll("g>line").style({stroke:"black"})}var Q=e.select(".angular.axis-group").selectAll("g.angular-tick").data(O),$=Q.enter().append("g").classed("angular-tick",!0);Q.attr({transform:function(t,e){return"rotate("+l(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),Q.exit().remove(),$.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(D),$.selectAll(".minor").style({stroke:f.minorTickColor}),Q.select("line.grid-line").attr({x1:f.tickLength?b-f.tickLength:0,x2:b}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),$.append("text").classed("axis-text",!0).style(U);var J=Q.select("text.axis-text").attr({x:b+f.labelOffset,dy:".35em",transform:function(t,e){var r=l(t,e),n=b+f.labelOffset,i=f.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?270>r&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(180>=r&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(U);f.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=i.max(B.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));F.attr({transform:"translate("+[b+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,rt=e.select("g.geometry-group").selectAll("g.geometry").data(d);if(rt.enter().append("g").attr({"class":function(t,e){return"geometry geometry"+e}}),rt.exit().remove(),d[0]||et){var nt=[];d.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=s,r.container=rt.filter(function(t,r){return r==e}),r.geometry=t.geometry,r.orientation=f.orientation,r.direction=f.direction,r.index=e,nt.push({data:t,geometryConfig:r})});var it=i.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(nt),at=[];it.forEach(function(t,e){"unstacked"===t.key?at=at.concat(t.values.map(function(t,e){return[t]})):at.push(t.values)}),at.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return o(a[r].defaultConfig(),t)});a[r]().config(n)()})}var ot,st,lt=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=a.tooltipPanel().config({container:ct,fontSize:8})(),ft=a.tooltipPanel().config({container:ct,fontSize:8})(),ht=a.tooltipPanel().config({container:ct,hasTick:!0})();if(!M){var dt=lt.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});B.on("mousemove.angular-guide",function(t,e){var r=a.util.getMousePos(Z).angle;dt.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-f.orientation)%360;ot=s.invert(n);var i=a.util.convertToCartesian(b+12,r+180);ut.text(a.util.round(ot)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){lt.select("line").style({opacity:0})})}var pt=lt.select("circle").style({stroke:"grey",fill:"none"});B.on("mousemove.radial-guide",function(t,e){var r=a.util.getMousePos(Z).radius;pt.attr({r:r}).style({opacity:.5}),st=n.invert(a.util.getMousePos(Z).radius);var i=a.util.convertToCartesian(r,f.radialAxis.orientation);ft.text(a.util.round(st)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),ht.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,r){var n=i.select(this),o=n.style("fill"),s="black",l=n.style("opacity")||1;if(n.attr({"data-opacity":l}),"none"!=o){n.attr({"data-fill":o}),s=i.hsl(o).darker().toString(),n.style({fill:s,opacity:1});var c={t:a.util.round(t[0]),r:a.util.round(t[1])};M&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),h=e.node().getBoundingClientRect(),d=[f.left+f.width/2-H[0]-h.left,f.top+f.height/2-H[1]-h.top];ht.config({color:s}).text(u),ht.move(d)}else o=n.style("stroke"),n.attr({"data-stroke":o}),s=i.hsl(o).darker().toString(),n.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0!=i.event.which?!1:void(i.select(this).attr("data-fill")&&ht.show())}).on("mouseout.tooltip",function(t,e){ht.hide();var r=i.select(this),n=r.attr("data-fill");n?r.style({fill:n,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})}),h}var e,r,n,s,l={data:[],layout:{}},c={},u={},f=i.dispatch("hover"),h={};return h.render=function(e){return t(e),this},h.config=function(t){if(!arguments.length)return l;var e=a.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),o(l.data[e],a.Axis.defaultConfig().data[0]),o(l.data[e],t)}),o(l.layout,a.Axis.defaultConfig().layout),o(l.layout,e.layout),this},h.getLiveConfig=function(){return u},h.getinputConfig=function(){return c},h.radialScale=function(t){return n},h.angularScale=function(t){return s},h.svg=function(){return e},i.rebind(h,f,"on"),h},a.Axis.defaultConfig=function(t,e){var r={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:i.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return r},a.util={},a.DATAEXTENT="dataExtent",a.AREA="AreaChart",a.LINE="LinePlot",a.DOT="DotPlot",a.BAR="BarChart",a.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},a.util._extend=function(t,e){for(var r in t)e[r]=t[r]},a.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},a.util.dataFromEquation2=function(t,e){var r=e||6,n=i.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180,i=t(n);return[e,i]});return n},a.util.dataFromEquation=function(t,e,r){var n=e||6,a=[],o=[];i.range(0,360+n,n).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},a.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return i.range(e).map(function(t,e){return r[e]||r[0]})},a.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=a.util.ensureArray(t[e],r)}),t},a.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},a.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},a.util.sumArrays=function(t,e){return i.zip(t,e).map(function(t,e){return i.sum(t)})},a.util.arrayLast=function(t){return t[t.length-1]},a.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},a.util.flattenArray=function(t){for(var e=[];!a.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},a.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},a.util.convertToCartesian=function(t,e){var r=e*Math.PI/180,n=t*Math.cos(r),i=t*Math.sin(r);return[n,i]},a.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},a.util.getMousePos=function(t){var e=i.mouse(t.node()),r=e[0],n=e[1],a={};return a.x=r,a.y=n,a.pos=e,a.angle=180*(Math.atan2(n,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+n*n),a},a.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;a>i;i++)e=t[i],e in r?(r[e]++,n[e]=r[e]):r[e]=1;return n},a.util.duplicates=function(t){return Object.keys(a.util.duplicatesCount(t))},a.util.translator=function(t,e,r,n){if(n){var i=r.slice();r=e,e=i}var a=e.reduce(function(t,e){return"undefined"!=typeof t?t[e]:void 0},t);"undefined"!=typeof a&&(e.reduce(function(t,r,n){return"undefined"!=typeof t?(n===e.length-1&&delete t[r], +t[r]):void 0},t),r.reduce(function(t,e,n){return"undefined"==typeof t[e]&&(t[e]={}),n===r.length-1&&(t[e]=a),t[e]},t))},a.PolyChart=function(){function t(){var t=r[0].geometryConfig,e=t.container;"string"==typeof e&&(e=i.select(e)),e.datum(r).each(function(e,r){function n(e,r){var n=t.radialScale(e[1]),i=(t.angularScale(e[0])+t.orientation)*Math.PI/180;return{r:n,t:i}}function a(t){var e=t.r*Math.cos(t.t),r=t.r*Math.sin(t.t);return{x:e,y:r}}var o=!!e[0].data.yStack,l=e.map(function(t,e){return o?i.zip(t.data.t[0],t.data.r[0],t.data.yStack[0]):i.zip(t.data.t[0],t.data.r[0])}),c=t.angularScale,u=t.radialScale.domain()[0],f={};f.bar=function(r,n,a){var o=e[a].data,s=t.radialScale(r[1])-t.radialScale(0),l=t.radialScale(r[2]||0),u=o.barWidth;i.select(this).attr({"class":"mark bar",d:"M"+[[s+l,-u/2],[s+l,u/2],[l,u/2],[l,-u/2]].join("L")+"Z",transform:function(e,r){return"rotate("+(t.orientation+c(e[0]))+")"}})},f.dot=function(t,r,o){var s=t[2]?[t[0],t[1]+t[2]]:t,l=i.svg.symbol().size(e[o].data.dotSize).type(e[o].data.dotType)(t,r);i.select(this).attr({"class":"mark dot",d:l,transform:function(t,e){var r=a(n(s));return"translate("+[r.x,r.y]+")"}})};var h=i.svg.line.radial().interpolate(e[0].data.lineInterpolation).radius(function(e){return t.radialScale(e[1])}).angle(function(e){return t.angularScale(e[0])*Math.PI/180});f.line=function(r,n,a){var o=r[2]?l[a].map(function(t,e){return[t[0],t[1]+t[2]]}):l[a];if(i.select(this).each(f.dot).style({opacity:function(t,r){return+e[a].data.dotVisible},fill:v.stroke(r,n,a)}).attr({"class":"mark dot"}),!(n>0)){var s=i.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({"class":"line",d:h(o),transform:function(e,r){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(r,n,a)},"fill-opacity":0,stroke:function(t,e){return v.stroke(r,n,a)},"stroke-width":function(t,e){return v["stroke-width"](r,n,a)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](r,n,a)},opacity:function(t,e){return v.opacity(r,n,a)},display:function(t,e){return v.display(r,n,a)}})}};var d=t.angularScale.range(),p=Math.abs(d[1]-d[0])/l[0].length*Math.PI/180,g=i.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,r,n){i.select(this).attr({"class":"mark arc",d:g,transform:function(e,r){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var v={fill:function(t,r,n){return e[n].data.color},stroke:function(t,r,n){return e[n].data.strokeColor},"stroke-width":function(t,r,n){return e[n].data.strokeSize+"px"},"stroke-dasharray":function(t,r,n){return s[e[n].data.strokeDash]},opacity:function(t,r,n){return e[n].data.opacity},display:function(t,r,n){return"undefined"==typeof e[n].data.visible||e[n].data.visible?"block":"none"}},m=i.select(this).selectAll("g.layer").data(l);m.enter().append("g").attr({"class":"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({"class":"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,r=[a.PolyChart.defaultConfig()],n=i.dispatch("hover"),s={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){r[e]||(r[e]={}),o(r[e],a.PolyChart.defaultConfig()),o(r[e],t)}),this):r},t.getColorScale=function(){return e},i.rebind(t,n,"on"),t},a.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:i.scale.category20()}};return t},a.BarChart=function(){return a.PolyChart()},a.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},a.AreaChart=function(){return a.PolyChart()},a.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},a.DotPlot=function(){return a.PolyChart()},a.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},a.LinePlot=function(){return a.PolyChart()},a.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},a.Legend=function(){function t(){var r=e.legendConfig,n=e.data.map(function(t,e){return[].concat(t).map(function(t,n){var i=o({},r.elements[e]);return i.name=t,i.color=[].concat(r.elements[e].color)[n],i})}),a=i.merge(n);a=a.filter(function(t,e){return r.elements[e]&&(r.elements[e].visibleInLegend||"undefined"==typeof r.elements[e].visibleInLegend)}),r.reverseOrder&&(a=a.reverse());var s=r.container;("string"==typeof s||s.nodeName)&&(s=i.select(s));var l=a.map(function(t,e){return t.color}),c=r.fontSize,u=null==r.isContinuous?"number"==typeof a[0]:r.isContinuous,f=u?r.height:c*a.length,h=s.classed("legend-group",!0),d=h.selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=i.range(a.length),v=i.scale[u?"linear":"ordinal"]().domain(g).range(l),m=i.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var r=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=i.svg.symbolTypes.indexOf(t)?i.svg.symbol().type(t).size(r)():i.svg.symbol().type("square").size(r)()};if(u){var b=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);b.enter().append("stop"),b.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:r.height,width:r.colorBandWidth,fill:"url(#grad1)"})}else{var x=d.select(".legend-marks").selectAll("path.legend-mark").data(a);x.enter().append("path").classed("legend-mark",!0),x.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var r=t.symbol;return y(r,c)},fill:function(t,e){return v(e)}}),x.exit().remove()}var _=i.svg.axis().scale(m).orient("right"),w=d.select("g.legend-axis").attr({transform:"translate("+[u?r.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?r.textColor:"none"}),w.selectAll("text").style({fill:r.textColor,"font-size":r.fontSize}).text(function(t,e){return a[e].name}),t}var e=a.Legend.defaultConfig(),r=i.dispatch("hover");return t.config=function(t){return arguments.length?(o(e,t),this):e},i.rebind(t,r,"on"),t},a.Legend.defaultConfig=function(t,e){var r={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return r},a.tooltipPanel=function(){var t,e,r,n={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+a.tooltipPanel.uid++,l=10,c=function(){t=n.container.selectAll("g."+s).data([0]);var i=t.enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=i.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=i.append("text").attr({dx:n.padding+l,dy:.3*+n.fontSize}),c};return c.text=function(a){var o=i.hsl(n.color).l,s=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":n.fontSize+"px"}).text(f);var h=n.padding,d=e.node().getBBox(),p={fill:n.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[n.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),c},c.move=function(e){return t?(t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c):void 0},c.hide=function(){return t?(t.style({display:"none"}),c):void 0},c.show=function(){return t?(t.style({display:"block"}),c):void 0},c.config=function(t){return o(n,t),c},c},a.tooltipPanel.uid=1,a.adapter={},a.adapter.plotly=function(){var t={};return t.convert=function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=o({},t),i=[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]];return i.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",n.dotVisible===!0?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var n=a.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var i=n.indexOf(t.geometry);-1!=i&&(r.data[e].groupId=i)})}if(t.layout){var s=o({},t.layout),l=[[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]];if(l.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};i.entries(s.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),s.margin=f}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r},t}},{"../../plotly":390,"./micropolar_manager":445,d3:87}],445:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("d3"),a=t("./undo_manager"),o=e.exports={},s=n.Lib.extendDeepAll;o.framework=function(t){function e(e,a){return a&&(f=a),i.select(i.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),r=r?s(r,e):e,c||(c=n.micropolar.Axis()),u=n.micropolar.adapter.plotly().convert(r),c.config(u).render(f),t.data=r.data,t.layout=r.layout,o.fillLayout(t),r}var r,l,c,u,f,h=new a;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return r},e.getLiveConfig=function(){return n.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=n.micropolar.util.cloneJson(r);!function(e,r){h.add({undo:function(){r&&t(r)},redo:function(){t(e)}})}(e,l),l=n.micropolar.util.cloneJson(e)},e.undo=function(){h.undo()},e.redo=function(){h.redo()},e},o.fillLayout=function(t){var e=i.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:n.Color.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../plotly":390,"./undo_manager":446,d3:87}],446:[function(t,e,r){"use strict";e.exports=function(){function t(t,e){return t?(i=!0,t[e](),i=!1,this):this}var e,r=[],n=-1,i=!1;return{add:function(t){return i?this:(r.splice(n+1,r.length-n),r.push(t),n=r.length-1,this)},setCallback:function(t){e=t},undo:function(){var i=r[n];return i?(t(i,"undo"),n-=1,e&&e(i.undo),this):this},redo:function(){var i=r[n+1];return i?(t(i,"redo"),n+=1,e&&e(i.redo),this):this},clear:function(){r=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return ng;g++){var v=d[g];s=t[v]?t[v]:t[v]={},e[v]=l={},o("domain."+h,[g/p,(g+1)/p]),o("domain."+{x:"y",y:"x"}[h]),a.id=v,f(s,l,o,a)}}},{"../lib":372,"./plots":441}],448:[function(t,e,r){"use strict";var n=t("./ternary"),i=t("../../plots/plots");r.name="ternary",r.attr="subplot",r.idRoot="ternary",r.idRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"ternary"),o=0;o=o&&(d.min=0,p.min=0,g.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}var i=t("../../../components/color"),a=t("../../subplot_defaults"),o=t("./layout_attributes"),s=t("./axis_defaults"),l=["aaxis","baxis","caxis"];e.exports=function(t,e,r){e._hasTernary&&a(t,e,r,{type:"ternary",attributes:o,handleDefaults:n,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../../components/color":297,"../../subplot_defaults":447,"./axis_defaults":451,"./layout_attributes":453}],453:[function(t,e,r){"use strict";var n=t("../../../components/color/attributes"),i=t("./axis_attributes");e.exports={domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},bgcolor:{valType:"color",dflt:n.background},sum:{valType:"number",dflt:1,min:0},aaxis:i,baxis:i,caxis:i}},{"../../../components/color/attributes":296,"./axis_attributes":450}],454:[function(t,e,r){"use strict";function n(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework()}function i(t){a.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var a=t("d3"),o=t("tinycolor2"),s=t("../../plotly"),l=t("../../lib"),c=t("../../components/color"),u=t("../../components/drawing"),f=t("../cartesian/set_convert"),h=t("../../lib/extend").extendFlat,d=t("../cartesian/axes"),p=t("../../lib/filter_visible"),g=t("../../components/dragelement"),v=t("../../components/titles"),m=t("../cartesian/select"),y=t("../cartesian/constants"),b=t("../cartesian/graph_interact");e.exports=n;var x=n.prototype;x.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={}},x.plot=function(t,e){var r,n=this,i=e[n.id],a=e._size;l.getPlotDiv(n.plotContainer.node())!==n.graphDiv&&(n.init(n.graphDiv._fullLayout),n.makeFramework()),n.adjustLayout(i,a);var o=n.traceHash,s={};for(r=0;r_*y?(a=y,i=a*_):(i=m,a=i/_),o=g*i/m,s=v*a/y,r=e.l+e.w*d-i/2,n=e.t+e.h*(1-p)-a/2,l.x0=r,l.y0=n,l.w=i,l.h=a,l.sum=b,l.xaxis={type:"linear",range:[x+2*k-b,b-x-2*w],domain:[d-o/2,d+o/2],_id:"x",_gd:l.graphDiv},f(l.xaxis),l.xaxis.setScale(),l.yaxis={type:"linear",range:[x,b-w-k],domain:[p-s/2,p+s/2],_id:"y",_gd:l.graphDiv},f(l.yaxis),l.yaxis.setScale();var A=l.yaxis.domain[0],M=l.aaxis=h({},t.aaxis,{range:[x,b-w-k],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[A,A+s*_],_axislayer:l.layers.aaxis,_gridlayer:l.layers.agrid,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l"+a+",-"+i/2});f(M);var T=l.baxis=h({},t.baxis,{range:[b-x-k,w],side:"bottom",_counterangle:30,domain:l.xaxis.domain,_axislayer:l.layers.baxis,_gridlayer:l.layers.bgrid,_counteraxis:l.aaxis,_pos:0,_gd:l.graphDiv,_id:"x",_length:i,_gridpath:"M0,0l-"+i/2+",-"+a});f(T),M._counteraxis=T;var E=l.caxis=h({},t.caxis,{range:[b-x-w,k],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[A,A+s*_],_axislayer:l.layers.caxis,_gridlayer:l.layers.cgrid,_counteraxis:l.baxis,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l-"+a+","+i/2});f(E);var L="M"+r+","+(n+a)+"h"+i+"l-"+i/2+",-"+a+"Z";l.clipDef.select("path").attr("d",L),l.layers.plotbg.select("path").attr("d",L);var S="translate("+r+","+n+")";l.plotContainer.selectAll(".scatterlayer,.maplayer,.zoom").attr("transform",S);var C="translate("+r+","+(n+a)+")";l.layers.baxis.attr("transform",C),l.layers.bgrid.attr("transform",C);var z="translate("+(r+i/2)+","+n+")rotate(30)";l.layers.aaxis.attr("transform",z),l.layers.agrid.attr("transform",z);var P="translate("+(r+i/2)+","+n+")rotate(-30)";l.layers.caxis.attr("transform",P),l.layers.cgrid.attr("transform",P),l.drawAxes(!0),l.plotContainer.selectAll(".crisp").classed("crisp",!1);var R=l.layers.axlines;R.select(".aline").attr("d",M.showline?"M"+r+","+(n+a)+"l"+i/2+",-"+a:"M0,0").call(c.stroke,M.linecolor||"#000").style("stroke-width",(M.linewidth||0)+"px"),R.select(".bline").attr("d",T.showline?"M"+r+","+(n+a)+"h"+i:"M0,0").call(c.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),R.select(".cline").attr("d",E.showline?"M"+(r+i/2)+","+n+"l"+i/2+","+a:"M0,0").call(c.stroke,E.linecolor||"#000").style("stroke-width",(E.linewidth||0)+"px")},x.drawAxes=function(t){var e=this,r=e.graphDiv,n=e.id.substr(7)+"title",i=e.aaxis,a=e.baxis,o=e.caxis;if(d.doTicks(r,i,!0),d.doTicks(r,a,!0),d.doTicks(r,o,!0),t){var s=Math.max(i.showticklabels?i.tickfont.size/2:0,(o.showticklabels?.75*o.tickfont.size:0)+("outside"===o.ticks?.87*o.ticklen:0));v.draw(r,"a"+n,{propContainer:i,propName:e.id+".aaxis.title",dfltName:"Component A",attributes:{x:e.x0+e.w/2,y:e.y0-i.titlefont.size/3-s,"text-anchor":"middle"}});var l=(a.showticklabels?a.tickfont.size:0)+("outside"===a.ticks?a.ticklen:0)+3;v.draw(r,"b"+n,{propContainer:a,propName:e.id+".baxis.title",dfltName:"Component B",attributes:{x:e.x0-l,y:e.y0+e.h+.83*a.titlefont.size+l,"text-anchor":"middle"}}),v.draw(r,"c"+n,{propContainer:o,propName:e.id+".caxis.title",dfltName:"Component C",attributes:{x:e.x0+e.w+l,y:e.y0+e.h+.83*o.titlefont.size+l,"text-anchor":"middle"}})}};var w=y.MINZOOM/2+.87,k="m-0.87,.5h"+w+"v3h-"+(w+5.2)+"l"+(w/2+2.6)+",-"+(.87*w+4.5)+"l2.6,1.5l-"+w/2+","+.87*w+"Z",A="m0.87,.5h-"+w+"v3h"+(w+5.2)+"l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-2.6,1.5l"+w/2+","+.87*w+"Z",M="m0,1l"+w/2+","+.87*w+"l2.6,-1.5l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-"+(w/2+2.6)+","+(.87*w+4.5)+"l2.6,1.5l"+w/2+",-"+.87*w+"Z",T="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",E=!0;x.initInteractions=function(){function t(t,e,r){var n=j.getBoundingClientRect();x=e-n.left,w=r-n.top,L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L,S=N.aaxis.range[1]-L.a,z=o(N.graphDiv._fullLayout[N.id].bgcolor).getLuminance(),P="M0,"+N.h+"L"+N.w/2+", 0L"+N.w+","+N.h+"Z",R=!1,O=B.append("path").attr("class","zoombox").style({fill:z>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",P),I=B.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),p()}function e(t,e){return 1-e/N.h}function r(t,e){return 1-(t+(N.h-e)/Math.sqrt(3))/N.w}function n(t,e){return(t-(N.h-e)/Math.sqrt(3))/N.w}function a(t,i){var a=x+t,o=w+i,s=Math.max(0,Math.min(1,e(x,w),e(a,o))),l=Math.max(0,Math.min(1,r(x,w),r(a,o))),c=Math.max(0,Math.min(1,n(x,w),n(a,o))),u=(s/2+c)*N.w,f=(1-s/2-l)*N.w,h=(u+f)/2,d=f-u,p=(1-s)*N.h,g=p-d/_;d.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),I.transition().style("opacity",1).duration(200),R=!0)}function u(t,e){if(C===L)return 2===e&&v(),i(F);i(F);var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r),E&&F.data&&F._context.showTips&&(l.notifier("Double-click to
zoom back out","long"),E=!1)}function f(){L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L}function h(t,e){var r=t/N.xaxis._m,n=e/N.yaxis._m;C={a:L.a-n,b:L.b+(r+n)/2,c:L.c-(r-n)/2};var i=[C.a,C.b,C.c].sort(),a={a:i.indexOf(C.a),b:i.indexOf(C.b),c:i.indexOf(C.c)};i[0]<0&&(i[1]+i[0]/2<0?(i[2]+=i[0]+i[1],i[0]=i[1]=0):(i[2]+=i[0]/2,i[1]+=i[0]/2,i[0]=0),C={a:i[a.a],b:i[a.b],c:i[a.c]},e=(L.a-C.a)*N.yaxis._m,t=(L.c-C.c-L.b+C.b)*N.xaxis._m);var o="translate("+(N.x0+t)+","+(N.y0+e)+")";N.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",o),N.aaxis.range=[C.a,N.sum-C.b-C.c],N.baxis.range=[N.sum-C.a-C.c,C.b],N.caxis.range=[N.sum-C.a-C.b,C.c],N.drawAxes(!1),N.plotContainer.selectAll(".crisp").classed("crisp",!1)}function d(t,e){if(t){var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r)}else 2===e&&v()}function p(){N.plotContainer.selectAll(".select-outline").remove()}function v(){var t={};t[N.id+".aaxis.min"]=0,t[N.id+".baxis.min"]=0,t[N.id+".caxis.min"]=0,F.emit("plotly_doubleclick",null),s.relayout(F,t)}var x,w,L,S,C,z,P,R,O,I,N=this,j=N.layers.plotbg.select("path").node(),F=N.graphDiv,B=N.layers.zoom,D={element:j,gd:F,plotinfo:{plot:B},doubleclick:v,subplot:N.id,prepFn:function(e,r,n){D.xaxes=[N.xaxis],D.yaxes=[N.yaxis];var i=F._fullLayout.dragmode;e.shiftKey&&(i="pan"===i?"zoom":"pan"),"lasso"===i?D.minDrag=1:D.minDrag=void 0,"zoom"===i?(D.moveFn=a,D.doneFn=u,t(e,r,n)):"pan"===i?(D.moveFn=h,D.doneFn=d,f(),p()):"select"!==i&&"lasso"!==i||m(e,r,n,D,i)}};g.init(D),j.onmousemove=function(t){b.hover(F,t,N.id),F._fullLayout._lasthover=j,F._fullLayout._hoversubplot=N.id},j.onmouseout=function(t){F._dragging||g.unhover(F,t)},j.onclick=function(t){b.click(F,t)},F._fullLayout._plots||(F._fullLayout._plots={}),F._fullLayout._plots[N.id]={overlays:[],xaxis:N.xaxis,yaxis:N.yaxis,x:function(){return N.xaxis},y:function(){return N.yaxis}}}},{"../../components/color":297,"../../components/dragelement":317,"../../components/drawing":319,"../../components/titles":355,"../../lib":372,"../../lib/extend":367,"../../lib/filter_visible":368,"../../plotly":390,"../cartesian/axes":393,"../cartesian/constants":398,"../cartesian/graph_interact":400,"../cartesian/select":406,"../cartesian/set_convert":407,d3:87,tinycolor2:275}],455:[function(t,e,r){"use strict";function n(t){var e;switch(t){case"themes__thumb":e={autosize:!0,width:150,height:150,title:"",showlegend:!1,margin:{l:5,r:5,t:5,b:5,pad:0},annotations:[]};break;case"thumbnail":e={title:"",hidesources:!0,showlegend:!1,borderwidth:0,bordercolor:"",margin:{l:1,r:1,t:1,b:1,pad:0},annotations:[]};break;default:e={}}return e}function i(t){var e=["xaxis","yaxis","zaxis"];return e.indexOf(t.slice(0,5))>-1}var a=t("../plotly"),o=a.Lib.extendFlat,s=a.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var r,l=t.data,c=t.layout,u=s([],l),f=s({},c,n(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var h=Object.keys(f);for(r=0;rl;l++)n(r[l])&&n(s[l])&&d.push({p:r[l],s:s[l],b:0});return a(e,"marker")&&o(e,e.marker.color,"marker","c"),a(e,"marker.line")&&o(e,e.marker.line.color,"marker.line","c"),d}},{"../../components/colorscale/calc":304,"../../components/colorscale/has_colorscale":309,"../../plots/cartesian/axes":393,"fast-isnumeric":95}],463:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("../scatter/xy_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=a(t,e,u);return f?(u("orientation",e.x&&!e.y?"h":"v"),u("text"),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),void s(t,e,i.defaultLine,{axis:"x",inherit:"y"})):void(e.visible=!1)}},{"../../components/color":297,"../../components/errorbars/defaults":324,"../../lib":372,"../bar/style_defaults":471,"../scatter/xy_defaults":561,"./attributes":461}],464:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../components/errorbars"),a=t("../../components/color");e.exports=function(t,e,r,o){var s,l=t.cd,c=l[0].trace,u=l[0].t,f=t.xa,h=t.ya,d="closest"===o?u.barwidth/2:u.dbar*(1-f._gd._fullLayout.bargap)/2;s="closest"!==o?function(t){return t.p}:"h"===c.orientation?function(t){return t.y}:function(t){return t.x};var p,g;"h"===c.orientation?(p=function(t){return n.inbox(t.b-e,t.x-e)+(t.x-e)/(t.x-t.b)},g=function(t){var e=s(t)-r;return n.inbox(e-d,e+d)}):(g=function(t){return n.inbox(t.b-r,t.y-r)+(t.y-r)/(t.y-t.b)},p=function(t){var r=s(t)-e;return n.inbox(r-d,r+d)});var v=n.getDistanceFunction(o,p,g);if(n.getClosest(l,v,t),t.index!==!1){var m=l[t.index],y=m.mcc||c.marker.color,b=m.mlcc||c.marker.line.color,x=m.mlw||c.marker.line.width;return a.opacity(y)?t.color=y:a.opacity(b)&&x&&(t.color=b),"h"===c.orientation?(t.x0=t.x1=f.c2p(m.x,!0),t.xLabelVal=m.s,t.y0=h.c2p(s(m)-d,!0),t.y1=h.c2p(s(m)+d,!0),t.yLabelVal=m.p):(t.y0=t.y1=h.c2p(m.y,!0),t.yLabelVal=m.s,t.x0=f.c2p(s(m)-d,!0),t.x1=f.c2p(s(m)+d,!0),t.xLabelVal=m.p),m.tx&&(t.text=m.tx),i.hoverInfo(m,c,t),[t]}}},{"../../components/color":297,"../../components/errorbars":325,"../../plots/cartesian/graph_interact":400}],465:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("./layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.calc=t("./calc"),n.setPositions=t("./set_positions"),n.colorbar=t("../scatter/colorbar"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.moduleType="trace",n.name="bar",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","oriented","markerColorscale","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":401,"../scatter/colorbar":543,"./arrays_to_calcdata":460,"./attributes":461,"./calc":462,"./defaults":463,"./hover":464,"./layout_attributes":466,"./layout_defaults":467,"./plot":468,"./set_positions":469,"./style":470}],466:[function(t,e,r){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","group","overlay"],dflt:"group"},barnorm:{valType:"enumerated",values:["","fraction","percent"],dflt:""},bargap:{valType:"number",min:0,max:1},bargroupgap:{valType:"number",min:0,max:1,dflt:0}}},{}],467:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./layout_attributes");e.exports=function(t,e,r){function s(r,n){return a.coerce(t,e,o,r,n)}for(var l=!1,c=!1,u=!1,f={},h=0;h=2?a(t):t>e?Math.ceil(t):Math.floor(t)}var h,d,p,g;if("h"===s.orientation?(p=u.c2p(r.poffset+e.p,!0),g=u.c2p(r.poffset+e.p+r.barwidth,!0),h=c.c2p(e.b,!0),d=c.c2p(e.s+e.b,!0)):(h=c.c2p(r.poffset+e.p,!0),d=c.c2p(r.poffset+e.p+r.barwidth,!0),g=u.c2p(e.s+e.b,!0),p=u.c2p(e.b,!0)),!(i(h)&&i(d)&&i(p)&&i(g)&&h!==d&&p!==g))return void n.select(this).remove();var v=(e.mlw+1||s.marker.line.width+1||(e.trace?e.trace.marker.line.width:0)+1)-1,m=n.round(v/2%1,2);if(!t._context.staticPlot){var y=o.opacity(e.mc||s.marker.color),b=1>y||v>.01?a:l;h=b(h,d),d=b(d,h),p=b(p,g),g=b(g,p)}n.select(this).attr("d","M"+h+","+p+"V"+g+"H"+d+"V"+p+"Z")})}),h.call(s.plot,e)}},{"../../components/color":297,"../../components/errorbars":325,"../../lib":372,"./arrays_to_calcdata":460,d3:87,"fast-isnumeric":95}],469:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axes"),o=t("../../lib");e.exports=function(t,e){var r,s,l=t._fullLayout,c=e.x(),u=e.y();["v","h"].forEach(function(f){function h(e){function r(t){t[p]=t.p+h}var n=[];e.forEach(function(e){t.calcdata[e].forEach(function(t){n.push(t.p)})});var i=o.distinctVals(n),s=i.vals,c=i.minDiff,u=!1,f=[];"group"===l.barmode&&e.forEach(function(e){u||(t.calcdata[e].forEach(function(t){u||f.forEach(function(e){Math.abs(t.p-e)x&&(L=!0,A=x),x>k+z&&(L=!0,k=x))}a.expand(m,[A,k],{tozero:!0,padded:L})}else{var P=function(t){return t[g]=t.s,t.s};for(r=0;r1||0===s.bargap&&0===s.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),e.selectAll("g.points").each(function(t){var e=t[0].trace,r=e.marker,o=r.line,s=(e._input||{}).marker||{},l=a.tryColorscale(r,s,""),c=a.tryColorscale(r,s,"line.");n.select(this).selectAll("path").each(function(t){var e,a,s=(t.mlw+1||o.width+1)-1,u=n.select(this);e="mc"in t?t.mcc=l(t.mc):Array.isArray(r.color)?i.defaultLine:r.color,u.style("stroke-width",s+"px").call(i.fill,e),s&&(a="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(o.color)?i.defaultLine:o.color,u.call(i.stroke,a))})}),e.call(o.style)}},{"../../components/color":297,"../../components/drawing":319,"../../components/errorbars":325,d3:87}],471:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s){r("marker.color",o),i(t,"marker")&&a(t,e,s,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),i(t,"marker.line")&&a(t,e,s,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width")}},{"../../components/color":297,"../../components/colorscale/defaults":306,"../../components/colorscale/has_colorscale":309}],472:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/color/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=o.line;e.exports={y:{valType:"data_array"},x:{valType:"data_array"},x0:{valType:"any"},y0:{valType:"any"},whiskerwidth:{valType:"number",min:0,max:1,dflt:.5},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1},jitter:{valType:"number",min:0,max:1},pointpos:{valType:"number",min:-2,max:2},orientation:{valType:"enumerated",values:["v","h"]},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)"},symbol:a({},o.symbol,{arrayOk:!1}),opacity:a({},o.opacity,{arrayOk:!1,dflt:1}),size:a({},o.size,{arrayOk:!1}),color:a({},o.color,{arrayOk:!1}),line:{color:a({},s.color,{arrayOk:!1,dflt:i.defaultLine}),width:a({},s.width,{arrayOk:!1,dflt:0}),outliercolor:{valType:"color"},outlierwidth:{valType:"number",min:0,dflt:1}}},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2}},fillcolor:n.fillcolor}},{"../../components/color/attributes":296,"../../lib/extend":367,"../scatter/attributes":540}],473:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../../plots/cartesian/axes");e.exports=function(t,e){function r(t,e,r,a,o){var s;return r in e?p=a.makeCalcdata(e,r):(s=r+"0"in e?e[r+"0"]:"name"in e&&("category"===a.type||n(e.name)&&-1!==["linear","log"].indexOf(a.type)||i.isDateTime(e.name)&&"date"===a.type)?e.name:t.numboxes,s=a.d2c(s),p=o.map(function(){return s})),p}function o(t,e,r,a,o){var s,l,c,u,f=a.length,h=e.length,d=[],p=[];for(s=0;f>s;++s)l=a[s],t[s]={pos:l},p[s]=l-o,d[s]=[];for(p.push(a[f-1]+o),s=0;h>s;++s)u=e[s],n(u)&&(c=i.findBin(r[s],p),c>=0&&h>c&&d[c].push(u));return d}function s(t,e){var r,n,a,o;for(o=0;o1,m=r.dPos*(1-h.boxgap)*(1-h.boxgroupgap)/(v?t.numboxes:1),y=v?2*r.dPos*(-.5+(r.boxnum+.5)/t.numboxes)*(1-h.boxgap):0,b=m*g.whiskerwidth;return g.visible!==!0||r.emptybox?void a.select(this).remove():("h"===g.orientation?(l=p,f=d):(l=d,f=p),r.bPos=y,r.bdPos=m,n(),a.select(this).selectAll("path.box").data(o.identity).enter().append("path").attr("class","box").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=l.c2p(t.pos+y-b,!0),s=l.c2p(t.pos+y+b,!0),c=f.c2p(t.q1,!0),u=f.c2p(t.q3,!0),h=o.constrain(f.c2p(t.med,!0),Math.min(c,u)+1,Math.max(c,u)-1),d=f.c2p(g.boxpoints===!1?t.min:t.lf,!0),p=f.c2p(g.boxpoints===!1?t.max:t.uf,!0);"h"===g.orientation?a.select(this).attr("d","M"+h+","+r+"V"+n+"M"+c+","+r+"V"+n+"H"+u+"V"+r+"ZM"+c+","+e+"H"+d+"M"+u+","+e+"H"+p+(0===g.whiskerwidth?"":"M"+d+","+i+"V"+s+"M"+p+","+i+"V"+s)):a.select(this).attr("d","M"+r+","+h+"H"+n+"M"+r+","+c+"H"+n+"V"+u+"H"+r+"ZM"+e+","+c+"V"+d+"M"+e+","+u+"V"+p+(0===g.whiskerwidth?"":"M"+i+","+d+"H"+s+"M"+i+","+p+"H"+s))}),g.boxpoints&&a.select(this).selectAll("g.points").data(function(t){return t.forEach(function(t){t.t=r,t.trace=g}),t}).enter().append("g").attr("class","points").selectAll("path").data(function(t){var e,r,n,a,s,l,f,h="all"===g.boxpoints?t.val:t.val.filter(function(e){return et.uf}),d=(t.q3-t.q1)*u,p=[],v=0;if(g.jitter){for(e=0;et.lo&&(n.so=!0),n})}).enter().append("path").call(s.translatePoints,d,p),void(g.boxmean&&a.select(this).selectAll("path.mean").data(o.identity).enter().append("path").attr("class","mean").style("fill","none").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=f.c2p(t.mean,!0),o=f.c2p(t.mean-t.sd,!0),s=f.c2p(t.mean+t.sd,!0);"h"===g.orientation?a.select(this).attr("d","M"+i+","+r+"V"+n+("sd"!==g.boxmean?"":"m0,0L"+o+","+e+"L"+i+","+r+"L"+s+","+e+"Z")):a.select(this).attr("d","M"+r+","+i+"H"+n+("sd"!==g.boxmean?"":"m0,0L"+e+","+o+"L"+r+","+i+"L"+e+","+s+"Z"))})))})}},{"../../components/drawing":319,"../../lib":372,d3:87}],480:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib");e.exports=function(t,e){var r,o,s,l,c=t._fullLayout,u=e.x(),f=e.y(),h=["v","h"];for(o=0;ol&&(e.z=u.slice(0,l)),s("locationmode"),s("text"),s("marker.line.color"),s("marker.line.width"),i(t,e,o,s,{prefix:"",cLetter:"z"}),void s("hoverinfo",1===o._dataLength?"location+z+text":void 0)):void(e.visible=!1)}},{"../../components/colorscale/defaults":306,"../../lib":372,"./attributes":482}],485:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../heatmap/colorbar"),n.calc=t("./calc"),n.plot=t("./plot").plot,n.moduleType="trace",n.name="choropleth",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","noOpacity"],n.meta={},e.exports=n},{"../../plots/geo":413,"../heatmap/colorbar":499,"./attributes":482,"./calc":483,"./defaults":484,"./plot":486}],486:[function(t,e,r){"use strict";function n(t,e){function r(e){var r=t.mockAxis;return o.tickText(r,r.c2l(e),"hover").text}var n=e.hoverinfo;if("none"===n)return function(t){delete t.nameLabel,delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("name"),s=-1!==i.indexOf("location"),l=-1!==i.indexOf("z"),c=-1!==i.indexOf("text"),u=!a&&s;return function(t){var n=[];u?t.nameLabel=t.id:(a&&(t.nameLabel=e.name),s&&n.push(t.id)),l&&n.push(r(t.z)),c&&n.push(t.tx),t.textLabel=n.join("
")}}function i(t){return function(e,r){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:r,location:e.id,z:e.z}]}}}var a=t("d3"),o=t("../../plots/cartesian/axes"),s=t("../../plots/cartesian/graph_interact"),l=t("../../components/color"),c=t("../../components/drawing"),u=t("../../components/colorscale/get_scale"),f=t("../../components/colorscale/make_scale_function"),h=t("../../lib/topojson_utils").getTopojsonFeatures,d=t("../../lib/geo_location_utils").locationToFeature,p=t("../../lib/array_to_calc_item"),g=t("../../constants/geo_constants"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){for(var r,n=[],i=t.locations,a=i.length,o=h(t,e),s=(t.marker||{}).line||{},l=0;a>l;l++)r=d(t.locationmode,i[l],o),void 0!==r&&(r.z=t.z[l],void 0!==t.text&&(r.tx=t.text[l]),p(s.color,r,"mlc",l),p(s.width,r,"mlw",l),n.push(r));return n.length>0&&(n[0].trace=t),n},m.plot=function(t,e,r){var o,l=t.framework,c=l.select("g.choroplethlayer"),u=l.select("g.baselayer"),f=l.select("g.baselayeroverchoropleth"),h=g.baseLayersOverChoropleth,d=c.selectAll("g.trace.choropleth").data(e,function(t){return t.uid});d.enter().append("g").attr("class","trace choropleth"),d.exit().remove(),d.each(function(e){function r(e,r){if(t.showHover){var n=t.projection(e.properties.ct);c(e),s.loneHover({x:n[0],y:n[1],name:e.nameLabel,text:e.textLabel},{container:t.hoverContainer.node()}),f=u(e,r),t.graphDiv.emit("plotly_hover",f)}}function o(e,r){t.graphDiv.emit("plotly_click",u(e,r))}var l=m.calcGeoJSON(e,t.topojson),c=n(t,e),u=i(e),f=null,h=a.select(this).selectAll("path.choroplethlocation").data(l);h.enter().append("path").classed("choroplethlocation",!0).on("mouseover",r).on("click",o).on("mouseout",function(){s.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",f)}).on("mousedown",function(){s.loneUnhover(t.hoverContainer)}).on("mouseup",r),h.exit().remove()}),f.selectAll("*").remove();for(var p=0;pr;r++)e=f[r],d[r]=e[0]*(t.zmax-t.zmin)+t.zmin,p[r]=e[1];var g=n.extent([t.zmin,t.zmax,a.start,a.start+l*(c-1)]),v=g[t.zminr;r++)e=f[r],d[r]=(e[0]*(c+u-1)-u/2)*l+o,p[r]=e[1];var y=n.scale.linear().interpolate(n.interpolateRgb).domain(d).range(p);return y}},{"../../components/colorscale/get_scale":308,d3:87}],494:[function(t,e,r){"use strict";function n(t,e,r){_.markTime("in Contour.plot");var n=r[0].trace,a=r[0].x,s=r[0].y,c=n.contours,u=n.uid,f=e.x(),h=e.y(),v=t._fullLayout,b="contour"+u,x=i(c,e,r[0]);if(n.visible!==!0)return v._paper.selectAll("."+b+",.hm"+u).remove(),void v._infolayer.selectAll(".cb"+u).remove();"heatmap"===c.coloring?(n.zauto&&n.autocontour===!1&&(n._input.zmin=n.zmin=c.start-c.size/2,n._input.zmax=n.zmax=n.zmin+x.length*c.size),k(t,e,[r])):v._paper.selectAll(".hm"+u).remove(),o(x),l(x);var w=f.c2p(a[0],!0),A=f.c2p(a[a.length-1],!0),M=h.c2p(s[0],!0),T=h.c2p(s[s.length-1],!0),E=[[w,T],[A,T],[A,M],[w,M]],L=d(e,r,b);p(L,E,c),g(L,x,E,c),m(L,x,c),y(L,e,r[0],E),_.markTime("done Contour.plot")}function i(t,e,r){for(var n=t.size||1,i=[],a=t.start;at?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);if(5===r||10===r){var n=(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4;return t>n?5===r?713:1114:5===r?104:208}return 15===r?0:r}function o(t){var e,r,n,i,o,s,l,c,u,f=t[0].z,h=f.length,d=f[0].length,p=2===h||2===d;for(r=0;h-1>r;r++)for(i=[],0===r&&(i=i.concat(A)),r===h-2&&(i=i.concat(M)),e=0;d-1>e;e++)for(n=i.slice(),0===e&&(n=n.concat(T)),e===d-2&&(n=n.concat(E)),o=e+","+r,s=[[f[r][e],f[r][e+1]],[f[r+1][e],f[r+1][e+1]]],u=0;ui;i++){if(s>20?(s=S[s][(l[0]||l[1])<0?0:1],t.crossings[o]=C[s]):delete t.crossings[o],l=L[s],!l){console.log("found bad marching index",s,e,t.level);break}if(d.push(h(t,e,l)),e[0]+=l[0],e[1]+=l[1],u(d[d.length-1],d[d.length-2])&&d.pop(),o=e.join(","),o===a&&l.join(",")===p||r&&(l[0]&&(e[0]<0||e[0]>v-2)||l[1]&&(e[1]<0||e[1]>g-2)))break;s=t.crossings[o]}1e4===i&&console.log("Infinite loop in contour?");var m,y,b,x,_,w,k,A=u(d[0],d[d.length-1]),M=0,T=.2*t.smoothing,E=[],z=0;for(i=1;i=z;i--)if(m=E[i],P>m){for(b=0,y=i-1;y>=z&&m+E[y]b&&m+E[b]e;)e++,r=Object.keys(i.crossings)[0].split(",").map(Number),s(i,r);1e4===e&&console.log("Infinite loop in contour?")}}function c(t,e,r){var n=0,i=0;return t>20&&e?208===t||1114===t?n=0===r[0]?1:-1:i=0===r[1]?1:-1:-1!==A.indexOf(t)?i=1:-1!==T.indexOf(t)?n=1:-1!==M.indexOf(t)?i=-1:n=-1,[n,i]}function u(t,e){return Math.abs(t[0]-e[0])<.01&&Math.abs(t[1]-e[1])<.01}function f(t,e){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function h(t,e,r){var n=e[0]+Math.max(r[0],0),i=e[1]+Math.max(r[1],0),a=t.z[i][n],o=t.xaxis,s=t.yaxis;if(r[1]){var l=(t.level-a)/(t.z[i][n+1]-a);return[o.c2p((1-l)*t.x[n]+l*t.x[n+1],!0),s.c2p(t.y[i],!0)]}var c=(t.level-a)/(t.z[i+1][n]-a);return[o.c2p(t.x[n],!0),s.c2p((1-c)*t.y[i]+c*t.y[i+1],!0)]}function d(t,e,r){var n=t.plot.select(".maplayer").selectAll("g.contour."+r).data(e);return n.enter().append("g").classed("contour",!0).classed(r,!0),n.exit().remove(),n}function p(t,e,r){var n=t.selectAll("g.contourbg").data([0]);n.enter().append("g").classed("contourbg",!0);var i=n.selectAll("path").data("fill"===r.coloring?[0]:[]);i.enter().append("path"),i.exit().remove(),i.attr("d","M"+e.join("L")+"Z").style("stroke","none")}function g(t,e,r,n){var i=t.selectAll("g.contourfill").data([0]);i.enter().append("g").classed("contourfill",!0);var a=i.selectAll("path").data("fill"===n.coloring?e:[]);a.enter().append("path"),a.exit().remove(),a.each(function(t){var e=v(t,r);e?x.select(this).attr("d",e).style("stroke","none"):x.select(this).remove()})}function v(t,e){function r(t){return Math.abs(t[1]-e[0][1])<.01}function n(t){return Math.abs(t[1]-e[2][1])<.01}function i(t){return Math.abs(t[0]-e[0][0])<.01}function a(t){return Math.abs(t[0]-e[2][0])<.01}for(var o,s,l,c,u,f,h=t.edgepaths.length||t.z[0][0]l;l++){if(!o){console.log("missing end?",d,t);break}for(r(o)&&!a(o)?s=e[1]:i(o)?s=e[0]:n(o)?s=e[3]:a(o)&&(s=e[2]),u=0;u=0&&(s=v,c=u):Math.abs(o[1]-s[1])<.01?Math.abs(o[1]-v[1])<.01&&(v[0]-o[0])*(s[0]-v[0])>=0&&(s=v,c=u):console.log("endpt to newendpt is not vert. or horz.",o,s,v)}if(o=s,c>=0)break;h+="L"+s}if(c===t.edgepaths.length){console.log("unclosed perimeter path");break}d=c,g=-1===p.indexOf(d),g&&(d=p[0],h+="Z")}for(d=0;de;e++)s.push(1);for(e=0;a>e;e++)i.push(s.slice());for(e=0;eo;o++)for(n=i(l,o),u[o]=new Array(n),s=0;n>s;s++)u[o][s]=e(a(l,o,s));return u}function i(t,e,r,n,i,a){var o,s,l,c=[],u=h.traceIs(t,"contour"),f=h.traceIs(t,"histogram"),d=h.traceIs(t,"gl2d");if(Array.isArray(e)&&!f&&"category"!==a.type){e=e.map(a.d2c);var p=e.length;if(!(i>=p))return u?e.slice(0,i):e.slice(0,i+1);if(u||d)c=e.slice(0,i);else if(1===i)c=[e[0]-.5,e[0]+.5];else{for(c=[1.5*e[0]-.5*e[1]],l=1;p>l;l++)c.push(.5*(e[l-1]+e[l]));c.push(1.5*e[p-1]-.5*e[p-2])}if(i>p){var g=c[c.length-1],v=g-c[c.length-2];for(l=p;i>l;l++)g+=v,c.push(g)}}else for(s=n||1,o=void 0===r?0:f||"category"===a.type?r:a.d2c(r),l=u||d?0:-.5;i>l;l++)c.push(o+s*l);return c}function a(t){return.5-.25*Math.min(1,.5*t)}function o(t,e,r){var n,i,o=1;if(Array.isArray(r))for(n=0;nn&&o>y;n++)o=l(t,e,a(o));return o>y&&console.log("interp2d didn't converge quickly",o),t}function s(t){var e,r,n,i,a,o,s,l,c=[],u={},f=[],h=t[0],d=[],p=[0,0,0],g=m(t);for(r=0;rn;n++)void 0===d[n]&&(o=(void 0!==d[n-1]?1:0)+(void 0!==d[n+1]?1:0)+(void 0!==e[n]?1:0)+(void 0!==h[n]?1:0),o?(0===r&&o++,0===n&&o++,r===t.length-1&&o++,n===d.length-1&&o++,4>o&&(u[[r,n]]=[r,n,o]),c.push([r,n,o])):f.push([r,n]));for(;f.length;){for(s={},l=!1,a=f.length-1;a>=0;a--)i=f[a],r=i[0],n=i[1],o=((u[[r-1,n]]||p)[2]+(u[[r+1,n]]||p)[2]+(u[[r,n-1]]||p)[2]+(u[[r,n+1]]||p)[2])/20,o&&(s[i]=[r,n,o],f.splice(a,1),l=!0);if(!l)throw"findEmpties iterated with no new neighbors";for(i in s)u[i]=s[i],c.push(s[i])}return c.sort(function(t,e){return e[2]-t[2]})}function l(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g,v=0;for(o=0;os;s++)l=b[s],c=t[i+l[0]],c&&(u=c[a+l[1]],void 0!==u&&(0===h?p=g=u:(p=Math.min(p,u),g=Math.max(g,u)),f++,h+=u));if(0===f)throw"iterateInterp2d order is wrong: no defined neighbors";t[i][a]=h/f,void 0===d?4>f&&(v=1):(t[i][a]=(1+r)*t[i][a]-r*d,g>p&&(v=Math.max(v,Math.abs(t[i][a]-d)/(g-p))))}return v}var c=t("fast-isnumeric"),u=t("../../lib"),f=t("../../plots/cartesian/axes"),h=t("../../plots/plots"),d=t("../histogram2d/calc"),p=t("../../components/colorscale/calc"),g=t("./has_columns"),v=t("./convert_column_xyz"),m=t("./max_row_length");e.exports=function(t,e){function r(t){E=e._input.zsmooth=e.zsmooth=!1,u.notifier("cannot fast-zsmooth: "+t)}u.markTime("start convert x&y");var a,l,c,y,b,x,_,w,k=f.getFromId(t,e.xaxis||"x"),A=f.getFromId(t,e.yaxis||"y"),M=h.traceIs(e,"contour"),T=h.traceIs(e,"histogram"),E=M?"best":e.zsmooth;if(k._minDtick=0,A._minDtick=0,u.markTime("done convert x&y"),T){var L=d(t,e);a=L.x,l=L.x0,c=L.dx,y=L.y,b=L.y0,x=L.dy,_=L.z}else g(e)&&v(e,k,A),a=e.x?k.makeCalcdata(e,"x"):[],y=e.y?A.makeCalcdata(e,"y"):[],l=e.x0||0,c=e.dx||1,b=e.y0||0,x=e.dy||1,_=n(e),(M||e.connectgaps)&&(e._emptypoints=s(_),e._interpz=o(_,e._emptypoints,e._interpz));if("fast"===E)if("log"===k.type||"log"===A.type)r("log axis found");else if(!T){if(a.length){var S=(a[a.length-1]-a[0])/(a.length-1),C=Math.abs(S/100);for(w=0;wC){r("x scale is not linear");break}}if(y.length&&"fast"===E){var z=(y[y.length-1]-y[0])/(y.length-1),P=Math.abs(z/100);for(w=0;wP){r("y scale is not linear");break}}}var R=m(_),O="scaled"===e.xtype?"":e.x,I=i(e,O,l,c,R,k),N="scaled"===e.ytype?"":e.y,j=i(e,N,b,x,_.length,A);f.expand(k,I),f.expand(A,j);var F={x:I,y:j,z:_};if(p(e,_,"","z"),M&&e.contours&&"heatmap"===e.contours.coloring){var B="contour"===e.type?"heatmap":"histogram2d";F.xfill=i(B,O,l,c,R,k),F.yfill=i(B,N,b,x,_.length,A)}return[F]};var y=.01,b=[[-1,0],[1,0],[0,-1],[0,1]]},{"../../components/colorscale/calc":304,"../../lib":372,"../../plots/cartesian/axes":393,"../../plots/plots":441,"../histogram2d/calc":518,"./convert_column_xyz":500,"./has_columns":502,"./max_row_length":505,"fast-isnumeric":95}],499:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c="cb"+r.uid,u=s(r.colorscale),f=r.zmin,h=r.zmax;if(i(f)||(f=a.aggNums(Math.min,null,r.z)),i(h)||(h=a.aggNums(Math.max,null,r.z)),t._fullLayout._infolayer.selectAll("."+c).remove(),!r.showscale)return void o.autoMargin(t,c);var d=e[0].t.cb=l(t,c);d.fillcolor(n.scale.linear().domain(u.map(function(t){return f+t[0]*(h-f)})).range(u.map(function(t){return t[1]}))).filllevels({start:f,end:h,size:(h-f)/254}).options(r.colorbar)(),a.markTime("done colorbar")}},{"../../components/colorbar/draw":300,"../../components/colorscale/get_scale":308,"../../lib":372,"../../plots/plots":441,d3:87,"fast-isnumeric":95}],500:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a=t.x.slice(),o=t.y.slice(),s=t.z,l=t.text,c=Math.min(a.length,o.length,s.length),u=void 0!==l&&!Array.isArray(l[0]);for(ci;i++)a[i]=e.d2c(a[i]),o[i]=r.d2c(o[i]);var f,h,d,p=n.distinctVals(a),g=p.vals,v=n.distinctVals(o),m=v.vals,y=n.init2dArray(m.length,g.length);for(u&&(d=n.init2dArray(m.length,g.length)),i=0;c>i;i++)f=n.findBin(a[i]+p.minDiff/2,g),h=n.findBin(o[i]+v.minDiff/2,m),y[h][f]=s[i],u&&(d[h][f]=l[i]);t.x=g,t.y=m,t.z=y,u&&(t.text=d)}},{"../../lib":372}],501:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./has_columns"),a=t("./xyz_defaults"),o=t("../../components/colorscale/defaults"),s=t("./attributes");e.exports=function(t,e,r,l){function c(r,i){return n.coerce(t,e,s,r,i)}var u=a(t,e,c);return u?(c("text"),c("zsmooth"),c("connectgaps",i(e)&&e.zsmooth!==!1),void o(t,e,l,c,{prefix:"",cLetter:"z"})):void(e.visible=!1)}},{"../../components/colorscale/defaults":306,"../../lib":372,"./attributes":497,"./has_columns":502,"./xyz_defaults":508}],502:[function(t,e,r){"use strict";e.exports=function(t){return!Array.isArray(t.z[0])}},{}],503:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../lib");e.exports=function(t,e,r,a,o){if(!(t.distancec||c>=m[0].length||0>u||u>m.length)return}else{if(n.inbox(e-g[0],e-g[g.length-1])>n.MAXDIST||n.inbox(r-v[0],r-v[v.length-1])>n.MAXDIST)return;if(o){var w;for(b=[2*g[0]-g[1]],w=1;w0;)_=v.c2p(C[M]),M--;for(x>_&&(w=_,_=x,x=w,N=!0),M=0;void 0===k&&M0;)A=m.c2p(z[M]),M--;if(k>A&&(w=k,k=A,A=w,j=!0),P&&(C=r[0].xfill,z=r[0].yfill),"fast"!==R){var F="best"===R?0:.5;x=Math.max(-F*v._length,x),_=Math.min((1+F)*v._length,_),k=Math.max(-F*m._length,k),A=Math.min((1+F)*m._length,A)}var B=Math.round(_-x),D=Math.round(A-k);if(!(0>=B||0>=D)){var U,V;"fast"===R?(U=I,V=O):(U=B,V=D);var q=document.createElement("canvas");q.width=U,q.height=V;var H,G,Y=q.getContext("2d"),X=i.scale.linear().domain(S.map(function(t){return t[0]})).range(S.map(function(t){var e=a(t[1]).toRgb();return[e.r,e.g,e.b,e.a]})).clamp(!0);"fast"===R?(H=N?function(t){return I-1-t}:o.identity,G=j?function(t){return O-1-t}:o.identity):(H=function(t){return o.constrain(Math.round(v.c2p(C[t])-x),0,B)},G=function(t){return o.constrain(Math.round(m.c2p(z[t])-k),0,D)});var W,Z,K,Q,$,J,tt=G(0),et=[tt,tt],rt=N?0:1,nt=j?0:1,it=0,at=0,ot=0,st=0;if(o.markTime("done init png"),R){var lt=0,ct=new Uint8Array(B*D*4);if("best"===R){var ut,ft,ht,dt=new Array(C.length),pt=new Array(z.length),gt=new Array(B);for(M=0;MM;M++)gt[M]=n(M,dt);for(Z=0;D>Z;Z++)for(ut=n(Z,pt),ft=T[ut.bin0],ht=T[ut.bin1],M=0;B>M;M++,lt+=4)J=d(ft,ht,gt[M],ut),h(ct,lt,J)}else for(Z=0;O>Z;Z++)for($=T[Z],et=G(Z),M=0;I>M;M++)J=f($[M],1),lt=4*(et*B+H(M)),h(ct,lt,J);var vt=Y.createImageData(B,D);vt.data.set(ct),Y.putImageData(vt,0,0)}else for(Z=0;O>Z;Z++)if($=T[Z],et.reverse(),et[nt]=G(Z+1),et[0]!==et[1]&&void 0!==et[0]&&void 0!==et[1])for(K=H(0),W=[K,K],M=0;I>M;M++)W.reverse(),W[rt]=H(M+1),W[0]!==W[1]&&void 0!==W[0]&&void 0!==W[1]&&(Q=$[M],J=f(Q,(W[1]-W[0])*(et[1]-et[0])),Y.fillStyle="rgba("+J.join(",")+")",Y.fillRect(W[0],et[0],W[1]-W[0],et[1]-et[0]));o.markTime("done filling png"),at=Math.round(at/it),ot=Math.round(ot/it),st=Math.round(st/it);var mt=a("rgb("+at+","+ot+","+st+")");t._hmpixcount=(t._hmpixcount||0)+it,t._hmlumcount=(t._hmlumcount||0)+it*mt.getLuminance();var yt=e.plot.select(".imagelayer").selectAll("g.hm."+b).data([0]);yt.enter().append("g").classed("hm",!0).classed(b,!0),yt.exit().remove();var bt=yt.selectAll("image").data(r);bt.enter().append("svg:image"),bt.exit().remove(),bt.attr({xmlns:c.svg,"xlink:href":q.toDataURL("image/png"),height:D,width:B,x:x,y:k,preserveAspectRatio:"none"}),o.markTime("done showing png")}}var i=t("d3"),a=t("tinycolor2"),o=t("../../lib"),s=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),c=t("../../constants/xmlns_namespaces"),u=t("./max_row_length");e.exports=function(t,e,r){for(var i=0;i0&&(n=!0);for(var s=0;si;i++)e[i]?(t[i]/=e[i],n+=t[i]):t[i]=null;return n}},{}],511:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){return r("histnorm"),n.forEach(function(t){var e=r(t+"bins.start"),n=r(t+"bins.end"),i=r("autobin"+t,!(e&&n));r(i?"nbins"+t:t+"bins.size")}),e}},{}],512:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports={count:function(t,e,r){return r[t]++,1},sum:function(t,e,r,i){var a=i[e];return n(a)?(a=Number(a),r[t]+=a,a):0},avg:function(t,e,r,i,a){var o=i[e];return n(o)&&(o=Number(o),r[t]+=o,a[t]++),0},min:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]>a)return r[t]=a,a-r[t]}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]r&&c.length<5e3;)g=a.tickIncrement(r,b.size),c.push((r+g)/2),u.push(S),x&&_.push(r),E&&w.push(1/(g-r)),P&&k.push(0),r=g;var R=u.length;for(r=0;r=0&&R>m&&(A+=C(m,r,u,y,k));P&&(A=l(u,k)),z&&z(u,A,w);var O=Math.min(c.length,u.length),I=[],N=0,j=O-1;for(r=0;O>r;r++)if(u[r]){N=r;break}for(r=O-1;r>N;r--)if(u[r]){j=r;break}for(r=N;j>=r;r++)n(c[r])&&n(u[r])&&I.push({p:c[r],s:u[r],b:0});return I}}},{"../../lib":372,"../../plots/cartesian/axes":393,"./average":510,"./bin_functions":512,"./norm_functions":516,"fast-isnumeric":95}],514:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("./bin_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=u("x"),h=u("y");u("text");var d=u("orientation",h&&!f?"h":"v"),p=e["v"===d?"x":"y"];if(!p||!p.length)return void(e.visible=!1);var g=e["h"===d?"x":"y"];g&&u("histfunc");var v="h"===d?["y"]:["x"];a(t,e,u,v),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),s(t,e,i.defaultLine,{axis:"x",inherit:"y"})}},{"../../components/color":297,"../../components/errorbars/defaults":324,"../../lib":372,"../bar/style_defaults":471,"./attributes":509,"./bin_defaults":511}],515:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("../bar/layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("../bar/layout_defaults"),n.calc=t("./calc"),n.setPositions=t("../bar/set_positions"),n.plot=t("../bar/plot"),n.style=t("../bar/style"),n.colorbar=t("../scatter/colorbar"),n.hoverPoints=t("../bar/hover"),n.moduleType="trace",n.name="histogram",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","histogram","oriented","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":401,"../bar/hover":464,"../bar/layout_attributes":466,"../bar/layout_defaults":467,"../bar/plot":468,"../bar/set_positions":469,"../bar/style":470,"../scatter/colorbar":543,"./attributes":509,"./calc":513,"./defaults":514}],516:[function(t,e,r){"use strict";e.exports={percent:function(t,e){for(var r=t.length,n=100/e,i=0;r>i;i++)t[i]*=n},probability:function(t,e){for(var r=t.length,n=0;r>n;n++)t[n]/=e},density:function(t,e,r,n){var i=t.length;n=n||1;for(var a=0;i>a;a++)t[a]*=r[a]*n},"probability density":function(t,e,r,n){var i=t.length;n&&(e/=n);for(var a=0;i>a;a++)t[a]*=r[a]/e}}},{}],517:[function(t,e,r){"use strict";var n=t("../histogram/attributes"),i=t("../heatmap/attributes");e.exports={x:n.x,y:n.y,z:{valType:"data_array"},marker:{color:{valType:"data_array"}},histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zauto:i.zauto,zmin:i.zmin,zmax:i.zmax,colorscale:i.colorscale,autocolorscale:i.autocolorscale,reversescale:i.reversescale,showscale:i.showscale,zsmooth:i.zsmooth,_nestedModules:{colorbar:"Colorbar"}}},{"../heatmap/attributes":497,"../histogram/attributes":509}],518:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("../histogram/bin_functions"),o=t("../histogram/norm_functions"),s=t("../histogram/average");e.exports=function(t,e){var r,l,c,u,f,h,d=i.getFromId(t,e.xaxis||"x"),p=e.x?d.makeCalcdata(e,"x"):[],g=i.getFromId(t,e.yaxis||"y"),v=e.y?g.makeCalcdata(e,"y"):[],m=Math.min(p.length,v.length); +p.length>m&&p.splice(m,p.length-m),v.length>m&&v.splice(m,v.length-m),n.markTime("done convert data"),!e.autobinx&&"xbins"in e||(e.xbins=i.autoBin(p,d,e.nbinsx,"2d"),"histogram2dcontour"===e.type&&(e.xbins.start-=e.xbins.size,e.xbins.end+=e.xbins.size),e._input.xbins=e.xbins),!e.autobiny&&"ybins"in e||(e.ybins=i.autoBin(v,g,e.nbinsy,"2d"),"histogram2dcontour"===e.type&&(e.ybins.start-=e.ybins.size,e.ybins.end+=e.ybins.size),e._input.ybins=e.ybins),n.markTime("done autoBin"),f=[];var y,b,x=[],_=[],w="string"==typeof e.xbins.size?[]:e.xbins,k="string"==typeof e.xbins.size?[]:e.ybins,A=0,M=[],T=e.histnorm,E=e.histfunc,L=-1!==T.indexOf("density"),S="max"===E||"min"===E,C=S?null:0,z=a.count,P=o[T],R=!1,O=[],I=[],N="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";N&&"count"!==E&&(R="avg"===E,z=a[E]);var j=e.xbins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6;for(h=j.start;F>h;h=i.tickIncrement(h,j.size))x.push(C),Array.isArray(w)&&w.push(h),R&&_.push(0);Array.isArray(w)&&w.push(h);var B=x.length;for(r=e.xbins.start,l=(h-r)/B,r+=l/2,j=e.ybins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6,h=j.start;F>h;h=i.tickIncrement(h,j.size))f.push(x.concat()),Array.isArray(k)&&k.push(h),R&&M.push(_.concat());Array.isArray(k)&&k.push(h);var D=f.length;for(c=e.ybins.start,u=(h-c)/D,c+=u/2,L&&(O=x.map(function(t,e){return Array.isArray(w)?1/(w[e+1]-w[e]):1/l}),I=f.map(function(t,e){return Array.isArray(k)?1/(k[e+1]-k[e]):1/u})),n.markTime("done making bins"),h=0;m>h;h++)y=n.findBin(p[h],w),b=n.findBin(v[h],k),y>=0&&B>y&&b>=0&&D>b&&(A+=z(y,h,f[b],N,M[b]));if(R)for(b=0;D>b;b++)A+=s(f[b],M[b]);if(P)for(b=0;D>b;b++)P(f[b],A,O,I[b]);return n.markTime("done binning"),{x:p,x0:r,dx:l,y:v,y0:c,dy:u,z:f}}},{"../../lib":372,"../../plots/cartesian/axes":393,"../histogram/average":510,"../histogram/bin_functions":512,"../histogram/norm_functions":516}],519:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./sample_defaults"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r){function s(r,i){return n.coerce(t,e,o,r,i)}i(t,e,s),s("zsmooth"),a(t,e,r,s,{prefix:"",cLetter:"z"})}},{"../../components/colorscale/defaults":306,"../../lib":372,"./attributes":517,"./sample_defaults":521}],520:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../heatmap/calc"),n.plot=t("../heatmap/plot"),n.colorbar=t("../heatmap/colorbar"),n.style=t("../heatmap/style"),n.hoverPoints=t("../heatmap/hover"),n.moduleType="trace",n.name="histogram2d",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":401,"../heatmap/calc":498,"../heatmap/colorbar":499,"../heatmap/hover":503,"../heatmap/plot":506,"../heatmap/style":507,"./attributes":517,"./defaults":519}],521:[function(t,e,r){"use strict";var n=t("../histogram/bin_defaults");e.exports=function(t,e,r){var i=r("x"),a=r("y");if(!(i&&i.length&&a&&a.length))return void(e.visible=!1);var o=r("z")||r("marker.color");o&&r("histfunc");var s=["x","y"];n(t,e,r,s)}},{"../histogram/bin_defaults":511}],522:[function(t,e,r){"use strict";var n=t("../histogram2d/attributes"),i=t("../contour/attributes");e.exports={x:n.x,y:n.y,z:n.z,marker:n.marker,histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zauto:i.zauto,zmin:i.zmin,zmax:i.zmax,colorscale:i.colorscale,autocolorscale:i.autocolorscale,reversescale:i.reversescale,showscale:i.showscale,autocontour:i.autocontour,ncontours:i.ncontours,contours:i.contours,line:i.line,_nestedModules:{colorbar:"Colorbar"}}},{"../contour/attributes":487,"../histogram2d/attributes":517}],523:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../histogram2d/sample_defaults"),a=t("../contour/style_defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,i){return n.coerce(t,e,o,r,i)}i(t,e,l);var c=n.coerce2(t,e,o,"contours.start"),u=n.coerce2(t,e,o,"contours.end"),f=l("autocontour",!(c&&u));l(f?"ncontours":"contours.size"),a(t,e,l,s)}},{"../../lib":372,"../contour/style_defaults":496,"../histogram2d/sample_defaults":521,"./attributes":522}],524:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../contour/calc"),n.plot=t("../contour/plot"),n.style=t("../contour/style"),n.colorbar=t("../contour/colorbar"),n.hoverPoints=t("../contour/hover"),n.moduleType="trace",n.name="histogram2dcontour",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","contour","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":401,"../contour/calc":488,"../contour/colorbar":489,"../contour/hover":491,"../contour/plot":494,"../contour/style":495,"./attributes":522,"./defaults":523}],525:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../surface/attributes"),a=t("../../lib/extend").extendFlat;e.exports={x:{valType:"data_array"},y:{valType:"data_array"},z:{valType:"data_array"},i:{valType:"data_array"},j:{valType:"data_array"},k:{valType:"data_array"},delaunayaxis:{valType:"enumerated",values:["x","y","z"],dflt:"z"},alphahull:{valType:"number",dflt:-1},intensity:{valType:"data_array"},color:{valType:"color"},vertexcolor:{valType:"data_array"},facecolor:{valType:"data_array"},opacity:a({},i.opacity),flatshading:{valType:"boolean",dflt:!1},contour:{show:a({},i.contours.x.show,{}),color:a({},i.contours.x.color),width:a({},i.contours.x.width)},colorscale:n.colorscale,reversescale:n.reversescale,showscale:n.showscale,lighting:a({},i.lighting),_nestedModules:{colorbar:"Colorbar"}}},{"../../components/colorscale/attributes":303,"../../lib/extend":367,"../surface/attributes":585}],526:[function(t,e,r){"use strict";function n(t,e,r){this.scene=t,this.uid=r,this.mesh=e,this.name="",this.color="#fff",this.data=null,this.showContour=!1}function i(t){return t.map(function(t){var e=t[0],r=c(t[1]),n=r.toRgb();return{index:e,rgb:[n.r,n.g,n.b,1]}})}function a(t){return t.map(d)}function o(t,e,r){for(var n=new Array(t.length),i=0;i0)s=f(t.alphahull,l);else{var c=["x","y","z"].indexOf(t.delaunayaxis);s=u(l.map(function(t){return[t[(c+1)%3],t[(c+2)%3]]}))}var p={positions:l,cells:s,ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,opacity:t.opacity,contourEnable:t.contour.show,contourColor:d(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",p.vertexIntensity=t.intensity,p.colormap=i(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolors[0],p.vertexColors=a(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],p.cellColors=a(t.facecolor)):(this.color=t.color,p.meshColor=d(t.color)),this.mesh.update(p)},p.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=s},{"../../lib/str2rgbarray":383,"alpha-shape":26,"convex-hull":77,"delaunay-triangulate":88,"gl-mesh3d":142,tinycolor2:275}],527:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/colorbar/defaults"),a=t("./attributes");e.exports=function(t,e,r,o){function s(r,i){return n.coerce(t,e,a,r,i)}function l(t){var e=t.map(function(t){var e=s(t);return e&&Array.isArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var c=l(["x","y","z"]),u=l(["i","j","k"]);return c?(u&&u.forEach(function(t){for(var e=0;el||(c=p[r],void 0!==c&&""!==c||(c=r),c=String(c),void 0===y[c]&&(y[c]=!0,u=a(e.marker.colors[r]),u.isValid()?(u=o.addOpacity(u,u.getAlpha()),m[c]||(m[c]=u)):m[c]?u=m[c]:(u=!1,b=!0),f=-1!==_.indexOf(c),f||(x+=l),g.push({v:l,label:c,color:u,i:r,hidden:f}))));if(e.sort&&g.sort(function(t,e){return e.v-t.v}),b)for(r=0;r")}return g};var l},{"../../components/color":297,"./helpers":532,"fast-isnumeric":95,tinycolor2:275}],531:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(r,a){return n.coerce(t,e,i,r,a)}var s=n.coerceFont,l=o("values");if(!Array.isArray(l)||!l.length)return void(e.visible=!1);var c=o("labels");Array.isArray(c)||(o("label0"),o("dlabel"));var u=o("marker.line.width");u&&o("marker.line.color");var f=o("marker.colors");Array.isArray(f)||(e.marker.colors=[]),o("scalegroup");var h=o("text"),d=o("textinfo",Array.isArray(h)?"text+percent":"percent");if(o("hoverinfo",1===a._dataLength?"label+text+value+percent":void 0),d&&"none"!==d){var p=o("textposition"),g=Array.isArray(p)||"auto"===p,v=g||"inside"===p,m=g||"outside"===p;if(v||m){var y=s(o,"textfont",a.font);v&&s(o,"insidetextfont",y),m&&s(o,"outsidetextfont",y)}}o("domain.x"),o("domain.y"),o("hole"),o("sort"),o("direction"),o("rotation"),o("pull")}},{"../../lib":372,"./attributes":529}],532:[function(t,e,r){"use strict";r.formatPiePercent=function(t){var e=(100*t).toPrecision(3);return-1!==e.indexOf(".")?e.replace(/[.]?0+$/,"")+"%":e+"%"},r.formatPieValue=function(t){var e=t.toPrecision(10);return-1!==e.indexOf(".")?e.replace(/[.]?0+$/,""):e}},{}],533:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.layoutAttributes=t("./layout_attributes"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.styleOne=t("./style_one"),n.moduleType="trace",n.name="pie",n.basePlotModule=t("../../plots/cartesian"),n.categories=["pie","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":401,"./attributes":529,"./calc":530,"./defaults":531,"./layout_attributes":534,"./layout_defaults":535,"./plot":536,"./style":537,"./style_one":538}],534:[function(t,e,r){"use strict";e.exports={hiddenlabels:{valType:"data_array"}}},{}],535:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e){function r(r,a){return n.coerce(t,e,i,r,a)}r("hiddenlabels")}},{"../../lib":372,"./layout_attributes":534}],536:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,o=Math.PI*Math.min(e.v/r.vTotal,.5),s=1-r.trace.hole,l=i(e,r),c={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(c.scale>=1)return c;var u=a+1/(2*Math.tan(o)),f=r.r*Math.min(1/(Math.sqrt(u*u+.5)+u),s/(Math.sqrt(a*a+s/2)+a)),h={scale:2*f/t.height,rCenter:Math.cos(f/r.r)-f*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},d=1/a,p=d+1/(2*Math.tan(o)),g=r.r*Math.min(1/(Math.sqrt(p*p+.5)+p),s/(Math.sqrt(d*d+s/2)+d)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},m=v.scale>h.scale?v:h;return c.scale<1&&m.scale>c.scale?m:c}function i(t,e){if(t.v===e.vTotal&&!e.trace.hole)return 1;var r=Math.PI*Math.min(t.v/e.vTotal,.5);return Math.min(1/(1+1/Math.sin(r)),(1-e.trace.hole)/2)}function a(t,e){var r=e.pxmid[0],n=e.pxmid[1],i=t.width/2,a=t.height/2;return 0>r&&(i*=-1),0>n&&(a*=-1),{scale:1,rCenter:1,rotate:0,x:i+Math.abs(a)*(i>0?1:-1)/2,y:a/(1+r*r/(n*n)),outside:!0}}function o(t,e){function r(t,e){return t.pxmid[1]-e.pxmid[1]}function n(t,e){return e.pxmid[1]-t.pxmid[1]}function i(t,r){r||(r={});var n,i,a,s,h,d,g=r.labelExtraY+(o?r.yLabelMax:r.yLabelMin),v=o?t.yLabelMin:t.yLabelMax,m=o?t.yLabelMax:t.yLabelMin,y=t.cyFinal+c(t.px0[1],t.px1[1]),b=g-v;if(b*f>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(i=0;i=e.pull[a.i]||((t.pxmid[1]-a.pxmid[1])*f>0?(s=a.cyFinal+c(a.px0[1],a.px1[1]),b=s-v-t.labelExtraY,b*f>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-y)*f>0&&(n=3*u*Math.abs(i-p.indexOf(t)),h=a.cxFinal+l(a.px0[0],a.px1[0]),d=h+n-(t.cxFinal+t.pxmid[0])-t.labelExtraX,d*u>0&&(t.labelExtraX+=d)))}var a,o,s,l,c,u,f,h,d,p,g,v,m;for(o=0;2>o;o++)for(s=o?r:n,c=o?Math.max:Math.min,f=o?1:-1,a=0;2>a;a++){for(l=a?Math.max:Math.min,u=a?1:-1,h=t[o][a],h.sort(s),d=t[1-o][a],p=d.concat(h),v=[],g=0;gu&&(u=s.pull[a]);o.r=Math.min(r/c(s.tilt,Math.sin(l),s.depth),n/c(s.tilt,Math.cos(l),s.depth))/(2+2*u),o.cx=e.l+e.w*(s.domain.x[1]+s.domain.x[0])/2,o.cy=e.t+e.h*(2-s.domain.y[1]-s.domain.y[0])/2,s.scalegroup&&-1===d.indexOf(s.scalegroup)&&d.push(s.scalegroup)}for(a=0;af.vTotal/2?1:0)}function c(t,e,r){if(!t)return 1;var n=Math.sin(t*Math.PI/180);return Math.max(.01,r*n*Math.abs(e)+2*Math.sqrt(1-n*n*e*e))}var u=t("d3"),f=t("../../plots/cartesian/graph_interact"),h=t("../../components/color"),d=t("../../components/drawing"),p=t("../../lib/svg_text_utils"),g=t("./helpers");e.exports=function(t,e){var r=t._fullLayout;s(e,r._size);var c=r._pielayer.selectAll("g.trace").data(e);c.enter().append("g").attr({"stroke-linejoin":"round","class":"trace"}),c.exit().remove(),c.order(),c.each(function(e){var s=u.select(this),c=e[0],v=c.trace,m=0,y=(v.depth||0)*c.r*Math.sin(m)/2,b=v.tiltaxis||0,x=b*Math.PI/180,_=[y*Math.sin(x),y*Math.cos(x)],w=c.r*Math.cos(m),k=s.selectAll("g.part").data(v.tilt?["top","sides"]:["top"]);k.enter().append("g").attr("class",function(t){return t+" part"}),k.exit().remove(),k.order(),l(e),s.selectAll(".top").each(function(){var s=u.select(this).selectAll("g.slice").data(e);s.enter().append("g").classed("slice",!0),s.exit().remove();var l=[[[],[]],[[],[]]],m=!1;s.each(function(o){function s(e){var r=t._fullLayout,n=t._fullData[v.index],a=n.hoverinfo;if("all"===a&&(a="label+text+value+percent+name"),!t._dragging&&r.hovermode!==!1&&"none"!==a&&a){var s=i(o,c),l=k+o.pxmid[0]*(1-s),u=A+o.pxmid[1]*(1-s),h=[];-1!==a.indexOf("label")&&h.push(o.label),n.text&&n.text[o.i]&&-1!==a.indexOf("text")&&h.push(n.text[o.i]),-1!==a.indexOf("value")&&h.push(g.formatPieValue(o.v)),-1!==a.indexOf("percent")&&h.push(g.formatPiePercent(o.v/c.vTotal)),f.loneHover({x0:l-s*c.r,x1:l+s*c.r,y:u,text:h.join("
"),name:-1!==a.indexOf("name")?n.name:void 0,color:o.color,idealAlign:o.pxmid[0]<0?"left":"right"},{container:r._hoverlayer.node(),outerContainer:r._paper.node()}),f.hover(t,e,"pie"),E=!0}}function h(e){t.emit("plotly_unhover",{points:[e]}),E&&(f.loneUnhover(r._hoverlayer.node()),E=!1)}function y(){t._hoverdata=[o],t._hoverdata.trace=e.trace,f.click(t,{target:!0})}function x(t,e,r,n){return"a"+n*c.r+","+n*w+" "+b+" "+o.largeArc+(r?" 1 ":" 0 ")+n*(e[0]-t[0])+","+n*(e[1]-t[1])}if(o.hidden)return void u.select(this).selectAll("path,g").remove();l[o.pxmid[1]<0?0:1][o.pxmid[0]<0?0:1].push(o);var k=c.cx+_[0],A=c.cy+_[1],M=u.select(this),T=M.selectAll("path.surface").data([o]),E=!1;if(T.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),M.select("path.textline").remove(),M.on("mouseover",s).on("mouseout",h).on("click",y),v.pull){var L=+(Array.isArray(v.pull)?v.pull[o.i]:v.pull)||0;L>0&&(k+=L*o.pxmid[0],A+=L*o.pxmid[1])}o.cxFinal=k,o.cyFinal=A;var S=v.hole;if(o.v===c.vTotal){var C="M"+(k+o.px0[0])+","+(A+o.px0[1])+x(o.px0,o.pxmid,!0,1)+x(o.pxmid,o.px0,!0,1)+"Z";S?T.attr("d","M"+(k+S*o.px0[0])+","+(A+S*o.px0[1])+x(o.px0,o.pxmid,!1,S)+x(o.pxmid,o.px0,!1,S)+"Z"+C):T.attr("d",C)}else{var z=x(o.px0,o.px1,!0,1);if(S){var P=1-S;T.attr("d","M"+(k+S*o.px1[0])+","+(A+S*o.px1[1])+x(o.px1,o.px0,!1,S)+"l"+P*o.px0[0]+","+P*o.px0[1]+z+"Z")}else T.attr("d","M"+k+","+A+"l"+o.px0[0]+","+o.px0[1]+z+"Z")}var R=Array.isArray(v.textposition)?v.textposition[o.i]:v.textposition,O=M.selectAll("g.slicetext").data(o.text&&"none"!==R?[0]:[]);O.enter().append("g").classed("slicetext",!0),O.exit().remove(),O.each(function(){var t=u.select(this).selectAll("text").data([0]);t.enter().append("text").attr("data-notex",1),t.exit().remove(),t.text(o.text).attr({"class":"slicetext",transform:"","data-bb":"","text-anchor":"middle",x:0,y:0}).call(d.font,"outside"===R?v.outsidetextfont:v.insidetextfont).call(p.convertToTspans),t.selectAll("tspan.line").attr({x:0,y:0});var e,r=d.bBox(t.node());"outside"===R?e=a(r,o):(e=n(r,o,c),"auto"===R&&e.scale<1&&(t.call(d.font,v.outsidetextfont),v.outsidetextfont.family===v.insidetextfont.family&&v.outsidetextfont.size===v.insidetextfont.size||(t.attr({"data-bb":""}),r=d.bBox(t.node())),e=a(r,o)));var i=k+o.pxmid[0]*e.rCenter+(e.x||0),s=A+o.pxmid[1]*e.rCenter+(e.y||0);e.outside&&(o.yLabelMin=s-r.height/2,o.yLabelMid=s,o.yLabelMax=s+r.height/2,o.labelExtraX=0,o.labelExtraY=0,m=!0),t.attr("transform","translate("+i+","+s+")"+(e.scale<1?"scale("+e.scale+")":"")+(e.rotate?"rotate("+e.rotate+")":"")+"translate("+-(r.left+r.right)/2+","+-(r.top+r.bottom)/2+")")})}),m&&o(l,v),s.each(function(t){if(t.labelExtraX||t.labelExtraY){var e=u.select(this),r=e.select("g.slicetext text");r.attr("transform","translate("+t.labelExtraX+","+t.labelExtraY+")"+r.attr("transform"));var n=t.cxFinal+t.pxmid[0],i=t.cyFinal+t.pxmid[1],a="M"+n+","+i,o=(t.yLabelMax-t.yLabelMin)*(t.pxmid[0]<0?-1:1)/4;if(t.labelExtraX){var s=t.labelExtraX*t.pxmid[1]/t.pxmid[0],l=t.yLabelMid+t.labelExtraY-(t.cyFinal+t.pxmid[1]);a+=Math.abs(s)>Math.abs(l)?"l"+l*t.pxmid[0]/t.pxmid[1]+","+l+"H"+(n+t.labelExtraX+o):"l"+t.labelExtraX+","+s+"v"+(l-s)+"h"+o}else a+="V"+(t.yLabelMid+t.labelExtraY)+"h"+o;e.append("path").classed("textline",!0).call(h.stroke,v.outsidetextfont.color).attr({"stroke-width":Math.min(2,v.outsidetextfont.size/8),d:a,fill:"none"})}})})}),setTimeout(function(){c.selectAll("tspan").each(function(){var t=u.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":297,"../../components/drawing":319,"../../lib/svg_text_utils":384,"../../plots/cartesian/graph_interact":400,"./helpers":532,d3:87}],537:[function(t,e,r){"use strict";var n=t("d3"),i=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0],r=e.trace,a=n.select(this);a.style({opacity:r.opacity}),a.selectAll(".top path.surface").each(function(t){n.select(this).call(i,t,r)})})}},{"./style_one":538,d3:87}],538:[function(t,e,r){"use strict";var n=t("../../components/color");e.exports=function(t,e,r){var i=r.marker.line.color;Array.isArray(i)&&(i=i[e.i]||n.defaultLine);var a=r.marker.line.width||0;Array.isArray(a)&&(a=a[e.i]||0),t.style({"stroke-width":a,fill:e.color}).call(n.stroke,i)}},{"../../components/color":297}],539:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t){var e=t[0].trace,r=e.marker;if(n.mergeArray(e.text,t,"tx"),n.mergeArray(e.textposition,t,"tp"),e.textfont&&(n.mergeArray(e.textfont.size,t,"ts"),n.mergeArray(e.textfont.color,t,"tc"),n.mergeArray(e.textfont.family,t,"tf")),r&&r.line){var i=r.line;n.mergeArray(r.opacity,t,"mo"),n.mergeArray(r.symbol,t,"mx"),n.mergeArray(r.color,t,"mc"),n.mergeArray(i.color,t,"mlc"),n.mergeArray(i.width,t,"mlw")}}},{"../../lib":372}],540:[function(t,e,r){"use strict";var n=t("../../components/drawing");t("./constants");e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number",min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:{symbol:{valType:"enumerated",values:n.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},color:{valType:"color",arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number",dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},colorscale:{valType:"colorscale"},cauto:{valType:"boolean",dflt:!0},cmax:{valType:"number",dflt:null},cmin:{valType:"number",dflt:null},autocolorscale:{valType:"boolean",dflt:!0},reversescale:{valType:"boolean",dflt:!1},showscale:{valType:"boolean",dflt:!1},line:{color:{valType:"color",arrayOk:!0},width:{valType:"number",min:0,arrayOk:!0},colorscale:{valType:"colorscale"},cauto:{valType:"boolean",dflt:!0},cmax:{valType:"number",dflt:null},cmin:{valType:"number",dflt:null},autocolorscale:{valType:"boolean",dflt:!0},reversescale:{valType:"boolean",dflt:!1}}},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:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/drawing":319,"./constants":544}],541:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./subtypes"),s=t("./marker_colorscale_calc");e.exports=function(t,e){var r=i.getFromId(t,e.xaxis||"x"),l=i.getFromId(t,e.yaxis||"y");a.markTime("in Scatter.calc");var c=r.makeCalcdata(e,"x");a.markTime("finished convert x");var u=l.makeCalcdata(e,"y");a.markTime("finished convert y");var f,h,d,p=Math.min(c.length,u.length);r._minDtick=0,l._minDtick=0,c.length>p&&c.splice(p,c.length-p),u.length>p&&u.splice(p,u.length-p);var g={padded:!0},v={padded:!0};if(o.hasMarkers(e)){if(f=e.marker,h=f.size,Array.isArray(h)){var m={type:"linear"};i.setConvert(m),h=m.makeCalcdata(e.marker,"size"),h.length>p&&h.splice(p,h.length-p)}var y,b=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/b),3)}:function(t){return Math.max((t||0)/b,3)},g.ppad=v.ppad=Array.isArray(h)?h.map(y):y(h)}s(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||c[0]===c[p-1]&&u[0]===u[p-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(o.hasMarkers(e)||o.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||c[0]===c[p-1]&&u[0]===u[p-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(v.padded=!1):v.tozero=!0,a.markTime("ready for Axes.expand"),i.expand(r,c,g),a.markTime("done expand x"),i.expand(l,u,v),a.markTime("done expand y");var x=new Array(p);for(d=0;p>d;d++)x[d]=n(c[d])&&n(u[d])?{x:c[d],y:u[d]}:{x:!1,y:!1};return void 0!==typeof h&&a.mergeArray(h,x,"ms"),t.firstscatter=!1,x}},{"../../lib":372,"../../plots/cartesian/axes":393,"./marker_colorscale_calc":554,"./subtypes":559,"fast-isnumeric":95}],542:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i,a;for(e=0;e=0;i--)if(a=t[i],"scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}},{}],543:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c=r.marker,u="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void o.autoMargin(t,u);var f=s(c.colorscale),h=c.color,d=c.cmin,p=c.cmax;i(d)||(d=a.aggNums(Math.min,null,h)),i(p)||(p=a.aggNums(Math.max,null,h));var g=e[0].t.cb=l(t,u);g.fillcolor(n.scale.linear().domain(f.map(function(t){return d+t[0]*(p-d)})).range(f.map(function(t){return t[1]}))).filllevels({start:d,end:p,size:(p-d)/254}).options(c.colorbar)(),a.markTime("done colorbar")}},{"../../components/colorbar/draw":300,"../../components/colorscale/get_scale":308,"../../lib":372,"../../plots/plots":441,d3:87,"fast-isnumeric":95}],544:[function(t,e,r){"use strict";e.exports={PTS_LINESONLY:20}},{}],545:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("./constants"),o=t("./subtypes"),s=t("./xy_defaults"),l=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),h=t("./fillcolor_defaults"),d=t("../../components/errorbars/defaults");e.exports=function(t,e,r,p){function g(r,a){return n.coerce(t,e,i,r,a)}var v=s(t,e,g),m=vi(f))break;l=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,c=f,d=!1):m>y&&(m=y,u=f,d=!0)}if(d?(C[z++]=c,l!==u&&(C[z++]=u)):(u!==s&&(C[z++]=u),l!==c&&(C[z++]=c)),C[z++]=l,o>=t.length||!f)break;C[z++]=f,s=f}}else C[z++]=c}E.push(C.slice(0,z))}return E}},{"../../plots/cartesian/axes":393}],552:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=r("line.shape");"spline"===n&&r("line.smoothing")}},{}],553:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t){var e=t.marker,r=e.sizeref||1,i=e.sizemin||0,a="area"===e.sizemode?function(t){return Math.sqrt(t/r)}:function(t){return t/r};return function(t){var e=a(t/2);return n(e)&&e>0?Math.max(e,i):0}}},{"fast-isnumeric":95}],554:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("./subtypes");e.exports=function(t){if(a.hasMarkers(t)){var e=t.marker;n(t,"marker")&&i(t,e.color,"marker","c"),n(t,"marker.line")&&i(t,e.line.color,"marker.line","c")}}},{"../../components/colorscale/calc":304,"../../components/colorscale/has_colorscale":309,"./subtypes":559}],555:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l){var c,u=o.isBubble(t),f=(t.line||{}).color;f&&(r=f),l("marker.symbol"),l("marker.opacity",u?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),c=f&&e.marker.color!==f?f:u?n.background:n.defaultLine,l("marker.line.color",c),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",u?1:0),u&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode"))}},{"../../components/color":297,"../../components/colorscale/defaults":306,"../../components/colorscale/has_colorscale":309,"./subtypes":559}],556:[function(t,e,r){"use strict";function n(t,e,r){var n=e.x(),a=e.y(),o=i.extent(n.range.map(n.l2c)),s=i.extent(a.range.map(a.l2c));r.forEach(function(t,e){var n=t[0].trace;if(l.hasMarkers(n)){var i=n.marker.maxdisplayed;if(0!==i){var a=t.filter(function(t){return t.x>=o[0]&&t.x<=o[1]&&t.y>=s[0]&&t.y<=s[1]}),c=Math.ceil(a.length/i),u=0;r.forEach(function(t,r){var n=t[0].trace;l.hasMarkers(n)&&n.marker.maxdisplayed>0&&e>r&&u++});var f=Math.round(u*c/3+Math.floor(u/3)*c/7.1);t.forEach(function(t){delete t.vis}),a.forEach(function(t,e){0===Math.round((e+f)%c)&&(t.vis=!0)})}}})}var i=t("d3"),a=t("../../lib"),o=t("../../components/drawing"),s=t("../../components/errorbars"),l=t("./subtypes"),c=t("./arrays_to_calcdata"),u=t("./line_points");e.exports=function(t,e,r){function f(t){return t.filter(function(t){return t.vis})}n(t,e,r);var h=e.x(),d=e.y(),p=e.plot.select(".scatterlayer").selectAll("g.trace.scatter").data(r);p.enter().append("g").attr("class","trace scatter").style("stroke-miterlimit",2),p.call(s.plot,e);var g,v,m,y,b="";p.each(function(t){var e=t[0].trace,r=e.line,n=i.select(this);if(e.visible===!0&&(v=e.fill.charAt(e.fill.length-1),"x"!==v&&"y"!==v&&(v=""),t[0].node3=n,c(t),l.hasLines(e)||"none"!==e.fill)){var a,s,f,p,x,_="",w="";g="tozero"===e.fill.substr(0,6)||"toself"===e.fill||"to"===e.fill.substr(0,2)&&!b?n.append("path").classed("js-fill",!0):null,y&&(m=y.datum(t)),y=n.append("path").classed("js-fill",!0),-1!==["hv","vh","hvh","vhv"].indexOf(r.shape)?(f=o.steps(r.shape),p=o.steps(r.shape.split("").reverse().join(""))):f=p="spline"===r.shape?function(t){var e=t[t.length-1];return t[0][0]===e[0]&&t[0][1]===e[1]?o.smoothclosed(t.slice(1),r.smoothing):o.smoothopen(t,r.smoothing)}:function(t){return"M"+t.join("L")},x=function(t){return p(t.reverse())};var k=u(t,{xaxis:h,yaxis:d,connectGaps:e.connectgaps,baseTolerance:Math.max(r.width||1,3)/4,linear:"linear"===r.shape});if(k.length){for(var A=k[0][0],M=k[k.length-1],T=M[M.length-1],E=0;E1&&n.append("path").classed("js-line",!0).attr("d",a)}g?A&&T&&(v?("y"===v?A[1]=T[1]=d.c2p(0,!0):"x"===v&&(A[0]=T[0]=h.c2p(0,!0)),g.attr("d",_+"L"+T+"L"+A+"Z")):g.attr("d",_+"Z")):"tonext"===e.fill.substr(0,6)&&_&&b&&("tonext"===e.fill?m.attr("d",_+"Z"+b+"Z"):m.attr("d",_+"L"+b.substr(1)+"Z")),b=w}}}),p.selectAll("path:not([d])").remove(),p.append("g").attr("class","points").each(function(t){var e=t[0].trace,r=i.select(this),n=l.hasMarkers(e),s=l.hasText(e);!n&&!s||e.visible!==!0?r.remove():(n&&r.selectAll("path.point").data(e.marker.maxdisplayed?f:a.identity).enter().append("path").classed("point",!0).call(o.translatePoints,h,d),s&&r.selectAll("g").data(e.marker.maxdisplayed?f:a.identity).enter().append("g").append("text").call(o.translatePoints,h,d))})}},{"../../components/drawing":319,"../../components/errorbars":325,"../../lib":372,"./arrays_to_calcdata":539,"./line_points":551,"./subtypes":559,d3:87}],557:[function(t,e,r){"use strict";var n=t("./subtypes"),i=.2;e.exports=function(t,e){var r,a,o,s,l=t.cd,c=t.xaxis,u=t.yaxis,f=[],h=l[0].trace,d=h.index,p=h.marker;if(n.hasMarkers(h)||n.hasText(h)){var g=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(r=0;rs;s++){for(var l=[[0,0,0],[0,0,0]],c=0;3>c;c++)if(r[c])for(var u=0;2>u;u++)l[u][c]=r[c][s][u];o[s]=l}return o}var o=t("../../components/errorbars/compute_error");e.exports=a},{"../../components/errorbars/compute_error":323}],565:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.linePlot=null,this.scatterPlot=null,this.errorBars=null,this.textMarkers=null,this.delaunayMesh=null,this.color=null,this.mode="",this.dataPoints=[],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.textLabels=null,this.data=null}function i(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],s=[];for(n=0;ni;i++){var a=t[i];a&&a.copy_zstyle!==!1&&(a=t[2]),a&&(e[i]=a.width/2,r[i]=b(a.color),n=a.thickness)}return{capSize:e,color:r,lineWidth:n}}function o(t){var e=[0,0];return Array.isArray(t)?[0,-1]:(t.indexOf("bottom")>=0&&(e[1]+=1),t.indexOf("top")>=0&&(e[1]-=1),t.indexOf("left")>=0&&(e[0]-=1),t.indexOf("right")>=0&&(e[0]+=1),e)}function s(t,e){return e(4*t)}function l(t){return k[t]}function c(t,e,r,n,i){var a=null;if(Array.isArray(t)){a=[];for(var o=0;e>o;o++)void 0===t[o]?a[o]=n:a[o]=r(t[o],i)}else a=r(t,y.identity);return a}function u(t,e){var r,n,i,u,f,h,d=[],p=t.fullSceneLayout,g=t.dataScale,v=p.xaxis,m=p.yaxis,w=p.zaxis,k=e.marker,M=e.line,T=e.x||[],E=e.y||[],L=e.z||[],S=T.length;for(n=0;S>n;n++)i=v.d2l(T[n])*g[0],u=m.d2l(E[n])*g[1],f=w.d2l(L[n])*g[2],d[n]=[i,u,f];if(Array.isArray(e.text))h=e.text;else if(void 0!==e.text)for(h=new Array(S),n=0;S>n;n++)h[n]=e.text;if(r={position:d,mode:e.mode,text:h},"line"in e&&(r.lineColor=b(M.color),r.lineWidth=M.width,r.lineDashes=M.dash),"marker"in e){var C=_(e);r.scatterColor=x(k,1,S),r.scatterSize=c(k.size,S,s,20,C),r.scatterMarker=c(k.symbol,S,l,"\u25cf"),r.scatterLineWidth=k.line.width,r.scatterLineColor=x(k.line,1,S),r.scatterAngle=0}"textposition"in e&&(r.textOffset=o(e.textposition),r.textColor=x(e.textfont,1,S),r.textSize=c(e.textfont.size,S,y.identity,12),r.textFont=e.textfont.family,r.textAngle=0);var z=["x","y","z"];for(r.project=[!1,!1,!1],r.projectScale=[1,1,1],r.projectOpacity=[1,1,1],n=0;3>n;++n){var P=e.projection[z[n]];(r.project[n]=P.show)&&(r.projectOpacity[n]=P.opacity,r.projectScale[n]=P.scale)}r.errorBounds=A(e,g);var R=a([e.error_x,e.error_y,e.error_z]);return r.errorColor=R.color,r.errorLineWidth=R.lineWidth,r.errorCapSize=R.capSize,r.delaunayAxis=e.surfaceaxis,r.delaunayColor=b(e.surfacecolor),r}function f(t){if(Array.isArray(t)){var e=t[0];return Array.isArray(e)&&(t=e),"rgb("+t.slice(0,3).map(function(t){return Math.round(255*t)})+")"}return null}function h(t,e){var r=new n(t,e.uid);return r.update(e),r}var d=t("gl-line3d"),p=t("gl-scatter3d"),g=t("gl-error3d"),v=t("gl-mesh3d"),m=t("delaunay-triangulate"),y=t("../../lib"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/make_bubble_size_func"),w=t("../../constants/gl3d_dashes"),k=t("../../constants/gl_markers"),A=t("./calc_errors"),M=n.prototype;M.handlePick=function(t){if(t.object&&(t.object===this.linePlot||t.object===this.delaunayMesh||t.object===this.textMarkers||t.object===this.scatterPlot)){t.object.highlight&&t.object.highlight(null),this.scatterPlot&&(t.object=this.scatterPlot,this.scatterPlot.highlight(t.data)),this.textLabels&&void 0!==this.textLabels[t.data.index]?t.textLabel=this.textLabels[t.data.index]:t.textLabel="";var e=t.data.index;return t.traceCoordinate=[this.data.x[e],this.data.y[e],this.data.z[e]],!0}},M.update=function(t){var e,r,n,a,o=this.scene.glplot.gl,s=w.solid;this.data=t;var l=u(this.scene,t);"mode"in l&&(this.mode=l.mode),"lineDashes"in l&&l.lineDashes in w&&(s=w[l.lineDashes]),this.color=f(l.scatterColor)||f(l.lineColor),this.dataPoints=l.position,e={gl:o,position:l.position,color:l.lineColor,lineWidth:l.lineWidth||1,dashes:s[0],dashScale:s[1],opacity:t.opacity,connectGaps:t.connectgaps},-1!==this.mode.indexOf("lines")?this.linePlot?this.linePlot.update(e):(this.linePlot=d(e),this.scene.glplot.add(this.linePlot)):this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose(),this.linePlot=null);var c=t.opacity;if(t.marker&&t.marker.opacity&&(c*=t.marker.opacity),r={gl:o,position:l.position,color:l.scatterColor,size:l.scatterSize,glyph:l.scatterMarker,opacity:c,orthographic:!0,lineWidth:l.scatterLineWidth,lineColor:l.scatterLineColor,project:l.project,projectScale:l.projectScale,projectOpacity:l.projectOpacity},-1!==this.mode.indexOf("markers")?this.scatterPlot?this.scatterPlot.update(r):(this.scatterPlot=p(r),this.scatterPlot.highlightScale=1,this.scene.glplot.add(this.scatterPlot)):this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose(),this.scatterPlot=null),a={gl:o,position:l.position,glyph:l.text,color:l.textColor,size:l.textSize,angle:l.textAngle,alignment:l.textOffset,font:l.textFont,orthographic:!0,lineWidth:0,project:!1,opacity:t.opacity},this.textLabels=l.text,-1!==this.mode.indexOf("text")?this.textMarkers?this.textMarkers.update(a):(this.textMarkers=p(a),this.textMarkers.highlightScale=1,this.scene.glplot.add(this.textMarkers)):this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose(),this.textMarkers=null),n={gl:o,position:l.position,color:l.errorColor,error:l.errorBounds,lineWidth:l.errorLineWidth,capSize:l.errorCapSize,opacity:t.opacity},this.errorBars?l.errorBounds?this.errorBars.update(n):(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose(),this.errorBars=null):l.errorBounds&&(this.errorBars=g(n),this.scene.glplot.add(this.errorBars)),l.delaunayAxis>=0){var h=i(l.position,l.delaunayColor,l.delaunayAxis);h.opacity=t.opacity,this.delaunayMesh?this.delaunayMesh.update(h):(h.gl=o,this.delaunayMesh=v(h),this.scene.glplot.add(this.delaunayMesh))}else this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose(),this.delaunayMesh=null)},M.dispose=function(){this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose()),this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose()),this.errorBars&&(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose()),this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose()),this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose())},e.exports=h},{"../../constants/gl3d_dashes":358,"../../constants/gl_markers":359,"../../lib":372,"../../lib/gl_format_color":370,"../../lib/str2rgbarray":383,"../scatter/make_bubble_size_func":553,"./calc_errors":564,"delaunay-triangulate":88,"gl-error3d":112,"gl-line3d":119,"gl-mesh3d":142,"gl-scatter3d":162}],566:[function(t,e,r){"use strict";function n(t,e,r){var n=0,i=r("x"),a=r("y"),o=r("z");return i&&a&&o&&(n=Math.min(i.length,a.length,o.length),n=0&&h("surfacecolor",p||g);for(var v=["x","y","z"],m=0;3>m;++m){var y="projection."+v[m];h(y+".show")&&(h(y+".opacity"),h(y+".scale"))}c(t,e,r,{axis:"z"}),c(t,e,r,{axis:"y",inherit:"z"}),c(t,e,r,{axis:"x",inherit:"z"})}},{"../../components/errorbars/defaults":324,"../../lib":372,"../scatter/line_defaults":550,"../scatter/marker_defaults":555,"../scatter/subtypes":559,"../scatter/text_defaults":560,"./attributes":562}],567:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../constants/gl_markers":359,"../../plots/gl3d":428,"../scatter/colorbar":543,"./attributes":562,"./calc":563,"./convert":565,"./defaults":566}],568:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=n.line,l=o.line;e.exports={lon:{valType:"data_array"},lat:{valType:"data_array"},locations:{valType:"data_array"},locationmode:{valType:"enumerated",values:["ISO-3","USA-states","country names"],dflt:"ISO-3"},mode:a({},n.mode,{dflt:"markers"}),text:a({},n.text,{}),line:{color:s.color,width:s.width,dash:s.dash},marker:{symbol:o.symbol,opacity:o.opacity,size:o.size,sizeref:o.sizeref,sizemin:o.sizemin,sizemode:o.sizemode,color:o.color,colorscale:o.colorscale,cauto:o.cauto,cmax:o.cmax,cmin:o.cmin,autocolorscale:o.autocolorscale,reversescale:o.reversescale,showscale:o.showscale,line:{color:l.color,width:l.width,colorscale:l.colorscale,cauto:l.cauto,cmax:l.cmax,cmin:l.cmin,autocolorscale:l.autocolorscale,reversescale:l.reversescale}},textfont:n.textfont,textposition:n.textposition,hoverinfo:a({},i.hoverinfo,{flags:["lon","lat","location","text","name"]}),_nestedModules:{"marker.colorbar":"Colorbar"}}},{"../../lib/extend":367,"../../plots/attributes":391,"../scatter/attributes":540}],569:[function(t,e,r){"use strict";var n=t("../scatter/marker_colorscale_calc");e.exports=function(t,e){var r=[{x:!1,y:!1,trace:e,t:{}}];return n(e),r}},{"../scatter/marker_colorscale_calc":554}],570:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=0,o=r("locations");return o?(r("locationmode"),a=o.length):(n=r("lon")||[],i=r("lat")||[],a=Math.min(n.length,i.length),an;n++)r[n]=[t.lon[n],t.lat[n]];return{type:"LineString",coordinates:r,trace:t}}function a(t,e){function r(e){var r=t.mockAxis;return c.tickText(r,r.c2l(e),"hover").text+"\xb0"}var n=e.hoverinfo;if("none"===n)return function(t){delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("location")&&Array.isArray(e.locations),o=-1!==i.indexOf("lon"),s=-1!==i.indexOf("lat"),l=-1!==i.indexOf("text");return function(t){var n=[];a?n.push(t.location):o&&s?n.push("("+r(t.lon)+", "+r(t.lat)+")"):o?n.push("lon: "+r(t.lon)):s&&n.push("lat: "+r(t.lat)),l&&n.push(t.tx||e.text),t.textLabel=n.join("
")}}function o(t){var e=Array.isArray(t.locations);return function(r,n){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:n,lon:r.lon,lat:r.lat,location:e?r.location:null}]}}}var s=t("d3"),l=t("../../plots/cartesian/graph_interact"),c=t("../../plots/cartesian/axes"),u=t("../../lib/topojson_utils").getTopojsonFeatures,f=t("../../lib/geo_location_utils").locationToFeature,h=t("../../lib/array_to_calc_item"),d=t("../../components/color"),p=t("../../components/drawing"),g=t("../scatter/subtypes"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){var r,i,a,o,s=[],l=Array.isArray(t.locations);l?(o=t.locations,r=o.length,i=u(t,e),a=function(t,e){var r=f(t.locationmode,o[e],i);return void 0!==r?r.properties.ct:void 0}):(r=t.lon.length,a=function(t,e){return[t.lon[e],t.lat[e]]});for(var c=0;r>c;c++){var h=a(t,c);if(h){var d={lon:h[0],lat:h[1],location:l?t.locations[c]:null};n(t,d,c),s.push(d)}}return s.length>0&&(s[0].trace=t),s},m.plot=function(t,e){var r=t.framework.select(".scattergeolayer").selectAll("g.trace.scattergeo").data(e,function(t){return t.uid});r.enter().append("g").attr("class","trace scattergeo"),r.exit().remove(),r.selectAll("*").remove(),r.each(function(t){var e=s.select(this);g.hasLines(t)&&e.selectAll("path.js-line").data([i(t)]).enter().append("path").classed("js-line",!0)}),r.each(function(e){function r(r,n){if(t.showHover){var i=t.projection([r.lon,r.lat]);h(r),l.loneHover({x:i[0],y:i[1],name:v?e.name:void 0,text:r.textLabel,color:r.mc||(e.marker||{}).color},{container:t.hoverContainer.node()}),y=d(r,n),t.graphDiv.emit("plotly_hover",y)}}function n(e,r){t.graphDiv.emit("plotly_click",d(e,r))}var i=s.select(this),c=g.hasMarkers(e),u=g.hasText(e);if(c||u){var f=m.calcGeoJSON(e,t.topojson),h=a(t,e),d=o(e),p=e.hoverinfo,v="all"===p||-1!==p.indexOf("name"),y=null;c&&i.selectAll("path.point").data(f).enter().append("path").classed("point",!0).on("mouseover",r).on("click",n).on("mouseout",function(){l.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",y)}).on("mousedown",function(){l.loneUnhover(t.hoverContainer)}).on("mouseup",r),u&&i.selectAll("g").data(f).enter().append("g").append("text")}}),m.style(t)},m.style=function(t){var e=t.framework.selectAll("g.trace.scattergeo");e.style("opacity",function(t){return t.opacity}),e.each(function(t){s.select(this).selectAll("path.point").call(p.pointStyle,t),s.select(this).selectAll("text").call(p.textPointStyle,t)}),e.selectAll("path.js-line").style("fill","none").each(function(t){var e=t.trace,r=e.line||{};s.select(this).call(d.stroke,r.color).call(p.dashLine,r.dash||"",r.width||0)})}},{"../../components/color":297,"../../components/drawing":319,"../../lib/array_to_calc_item":363,"../../lib/geo_location_utils":369,"../../lib/topojson_utils":385,"../../plots/cartesian/axes":393,"../../plots/cartesian/graph_interact":400,"../scatter/subtypes":559,"./attributes":568,d3:87}],573:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../constants/gl2d_dashes"),a=t("../../constants/gl_markers"),o=t("../../lib/extend").extendFlat,s=n.line,l=n.marker,c=l.line;e.exports={x:n.x,x0:n.x0,dx:n.dx,y:n.y,y0:n.y0,dy:n.dy,text:o({},n.text,{}),mode:{valType:"flaglist",flags:["lines","markers"],extras:["none"]},line:{color:s.color,width:s.width,dash:{valType:"enumerated",values:Object.keys(i),dflt:"solid"}},marker:{color:l.color,symbol:{valType:"enumerated",values:Object.keys(a),dflt:"circle",arrayOk:!0},size:l.size,sizeref:l.sizeref,sizemin:l.sizemin,sizemode:l.sizemode,opacity:l.opacity,colorscale:l.colorscale,cauto:l.cauto,cmax:l.cmax,cmin:l.cmin,autocolorscale:l.autocolorscale,reversescale:l.reversescale,showscale:l.showscale,line:{color:c.color,width:c.width,colorscale:c.colorscale,cauto:c.cauto,cmax:c.cmax,cmin:c.cmin,autocolorscale:c.autocolorscale,reversescale:c.reversescale}},fill:o({},n.fill,{values:["none","tozeroy","tozerox"]}),fillcolor:n.fillcolor,_nestedModules:{error_x:"ErrorBars",error_y:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../constants/gl2d_dashes":357,"../../constants/gl_markers":359,"../../lib/extend":367,"../scatter/attributes":540}],574:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.xData=[],this.yData=[],this.textLabels=[],this.color="rgb(0, 0, 0)",this.name="",this.hoverinfo="all",this.idToIndex=[],this.bounds=[0,0,0,0],this.hasLines=!1,this.lineOptions={positions:new Float32Array,color:[0,0,0,1],width:1,fill:[!1,!1,!1,!1],fillColor:[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],dashes:[1]},this.line=d(t.glplot,this.lineOptions),this.line._trace=this,this.hasErrorX=!1,this.errorXOptions={positions:new Float32Array,errors:new Float32Array,lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorX=p(t.glplot,this.errorXOptions),this.errorX._trace=this,this.hasErrorY=!1,this.errorYOptions={positions:new Float32Array,errors:new Float32Array,lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorY=p(t.glplot,this.errorYOptions),this.errorY._trace=this,this.hasMarkers=!1,this.scatterOptions={positions:new Float32Array,sizes:[],colors:[],glyphs:[],borderWidths:[],borderColors:[],size:12,color:[0,0,0,1],borderSize:1,borderColor:[0,0,0,1]},this.scatter=f(t.glplot,this.scatterOptions),this.scatter._trace=this,this.fancyScatter=h(t.glplot,this.scatterOptions),this.fancyScatter._trace=this}function i(t,e,r){return Array.isArray(e)||(e=[e]),a(t,e,r)}function a(t,e,r){for(var n=new Array(r),i=e[0],a=0;r>a;++a)n[a]=t(a>=e.length?i:e[a]);return n}function o(t,e,r){return l(S(t,r),L(e,r),r)}function s(t,e,r,n){var i=x(t,e,n);return i=Array.isArray(i[0])?i:a(v.identity,[i],n),l(i,L(r,n),n)}function l(t,e,r){for(var n=new Array(4*r),i=0;r>i;++i){for(var a=0;3>a;++a)n[4*i+a]=t[i][a];n[4*i+3]=t[i][3]*e[i]}return n}function c(t,e){if(void 0===Float32Array.slice){for(var r=new Float32Array(e),n=0;e>n;n++)r[n]=t[n];return r}return t.slice(0,e)}function u(t,e){var r=new n(t,e.uid);return r.update(e),r}var f=t("gl-scatter2d"),h=t("gl-scatter2d-fancy"),d=t("gl-line2d"),p=t("gl-error2d"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../plots/cartesian/axes"),y=t("../../components/errorbars"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/subtypes"),w=t("../scatter/make_bubble_size_func"),k=t("../scatter/get_trace_color"),A=t("../../constants/gl_markers"),M=t("../../constants/gl2d_dashes"),T=["xaxis","yaxis"],E=n.prototype;E.handlePick=function(t){var e=this.idToIndex[t.pointId];return{trace:this,dataCoord:t.dataCoord,traceCoord:[this.xData[e],this.yData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:Array.isArray(this.color)?this.color[e]:this.color,name:this.name,hoverinfo:this.hoverinfo}},E.isFancy=function(t){if("linear"!==this.scene.xaxis.type)return!0;if("linear"!==this.scene.yaxis.type)return!0;if(!t.x||!t.y)return!0;var e=t.marker||{};if(Array.isArray(e.symbol)||"circle"!==e.symbol||Array.isArray(e.size)||Array.isArray(e.line.width)||Array.isArray(e.opacity))return!0;var r=e.color;if(Array.isArray(r))return!0;var n=Array.isArray(e.line.color);return Array.isArray(n)?!0:this.hasErrorX?!0:!!this.hasErrorY};var L=i.bind(null,function(t){return+t}),S=i.bind(null,b),C=i.bind(null,function(t){return A[t]||"\u25cf"});E.update=function(t){t.visible!==!0?(this.hasLines=!1,this.hasErrorX=!1,this.hasErrorY=!1,this.hasMarkers=!1):(this.hasLines=_.hasLines(t),this.hasErrorX=t.error_x.visible===!0,this.hasErrorY=t.error_y.visible===!0,this.hasMarkers=_.hasMarkers(t)),this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.isFancy(t)?this.updateFancy(t):this.updateFast(t),this.color=k(t,{})},E.updateFast=function(t){for(var e,r,n=this.xData=t.x,i=this.yData=t.y,a=n.length,o=new Array(a),s=new Float32Array(2*a),l=this.bounds,u=0,f=0,h=0;a>h;++h)e=n[h],r=i[h],g(e)&&g(r)&&(o[u++]=h,s[f++]=e,s[f++]=r,l[0]=Math.min(l[0],e),l[1]=Math.min(l[1],r),l[2]=Math.max(l[2],e),l[3]=Math.max(l[3],r));s=c(s,f),this.idToIndex=o,this.updateLines(t,s),this.updateError("X",t),this.updateError("Y",t);var d;if(this.hasMarkers){this.scatterOptions.positions=s;var p=b(t.marker.color),v=b(t.marker.line.color),m=t.opacity*t.marker.opacity;p[3]*=m,this.scatterOptions.color=p, +v[3]*=m,this.scatterOptions.borderColor=v,d=t.marker.size,this.scatterOptions.size=d,this.scatterOptions.borderSize=t.marker.line.width,this.scatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions),this.expandAxesFast(l,d)},E.updateFancy=function(t){var e,r,n,a,o,l,u,f,h=this.scene,d=h.xaxis,p=h.yaxis,g=this.bounds,v=this.xData=d.makeCalcdata(t,"x"),m=this.yData=p.makeCalcdata(t,"y"),b=y.calcFromTrace(t,h.fullLayout),x=v.length,_=new Array(x),k=new Float32Array(2*x),A=new Float32Array(4*x),M=new Float32Array(4*x),T=0,E=0,S=0,z=0,P="log"===d.type?function(t){return d.d2l(t)}:function(t){return t},R="log"===p.type?function(t){return p.d2l(t)}:function(t){return t};for(e=0;x>e;++e)n=P(v[e]),a=R(m[e]),isNaN(n)||isNaN(a)||(_[T++]=e,k[E++]=n,k[E++]=a,o=A[S++]=n-b[e].xs||0,l=A[S++]=b[e].xh-n||0,A[S++]=0,A[S++]=0,M[z++]=0,M[z++]=0,u=M[z++]=a-b[e].ys||0,f=M[z++]=b[e].yh-a||0,g[0]=Math.min(g[0],n-o),g[1]=Math.min(g[1],a-u),g[2]=Math.max(g[2],n+l),g[3]=Math.max(g[3],a+f));k=c(k,E),this.idToIndex=_,this.updateLines(t,k),this.updateError("X",t,k,A),this.updateError("Y",t,k,M);var O;if(this.hasMarkers){this.scatterOptions.positions=k,this.scatterOptions.sizes=new Array(T),this.scatterOptions.glyphs=new Array(T),this.scatterOptions.borderWidths=new Array(T),this.scatterOptions.colors=new Array(4*T),this.scatterOptions.borderColors=new Array(4*T);var I,N=w(t),j=t.marker,F=j.opacity,B=t.opacity,D=s(j,F,B,x),U=C(j.symbol,x),V=L(j.line.width,x),q=s(j.line,F,B,x);for(O=i(N,j.size,x),e=0;T>e;++e)for(I=_[e],this.scatterOptions.sizes[e]=4*O[I],this.scatterOptions.glyphs[e]=U[I],this.scatterOptions.borderWidths[e]=.5*V[I],r=0;4>r;++r)this.scatterOptions.colors[4*e+r]=D[4*I+r],this.scatterOptions.borderColors[4*e+r]=q[4*I+r];this.fancyScatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions),this.expandAxesFancy(v,m,O)},E.updateLines=function(t,e){if(this.hasLines){this.lineOptions.positions=e;var r=b(t.line.color);this.hasMarkers&&(r[3]*=t.marker.opacity);for(var n=Math.round(.5*this.lineOptions.width),i=(M[t.line.dash]||[1]).slice(),a=0;ao;o++)r=this.scene[T[o]],n=r._min,n||(n=[]),n.push({val:t[o],pad:a}),i=r._max,i||(i=[]),i.push({val:t[o+2],pad:a})},E.expandAxesFancy=function(t,e,r){var n=this.scene,i={padded:!0,ppad:r};m.expand(n.xaxis,t,i),m.expand(n.yaxis,e,i)},E.dispose=function(){this.line.dispose(),this.errorX.dispose(),this.errorY.dispose(),this.scatter.dispose(),this.fancyScatter.dispose()},e.exports=u},{"../../components/errorbars":325,"../../constants/gl2d_dashes":357,"../../constants/gl_markers":359,"../../lib":372,"../../lib/gl_format_color":370,"../../lib/str2rgbarray":383,"../../plots/cartesian/axes":393,"../scatter/get_trace_color":547,"../scatter/make_bubble_size_func":553,"../scatter/subtypes":559,"fast-isnumeric":95,"gl-error2d":110,"gl-line2d":117,"gl-scatter2d":159,"gl-scatter2d-fancy":154}],575:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/xy_defaults"),s=t("../scatter/marker_defaults"),l=t("../scatter/line_defaults"),c=t("../scatter/fillcolor_defaults"),u=t("../../components/errorbars/defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p=o(t,e,d);return p?(d("text"),d("mode",pr;r++)y=e.a[r],b=e.b[r],x=e.c[r],n(y)&&n(b)&&n(x)?(y=+y,b=+b,x=+x,_=v/(y+b+x),1!==_&&(y*=_,b*=_,x*=_),k=y,w=x-b,M[r]={x:w,y:k,a:y,b:b,c:x}):M[r]={x:!1,y:!1};var T,E;if(o.hasMarkers(e)&&(T=e.marker,E=T.size,Array.isArray(E))){var L={type:"linear"};i.setConvert(L),E=L.makeCalcdata(e.marker,"size"),E.length>A&&E.splice(A,E.length-A)}return s(e),void 0!==typeof E&&a.mergeArray(E,M,"ms"),M}},{"../../lib":372,"../../plots/cartesian/axes":393,"../scatter/marker_colorscale_calc":554,"../scatter/subtypes":559,"fast-isnumeric":95}],579:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/marker_defaults"),s=t("../scatter/line_defaults"),l=t("../scatter/line_shape_defaults"),c=t("../scatter/text_defaults"),u=t("../scatter/fillcolor_defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p,g=d("a"),v=d("b"),m=d("c");if(g?(p=g.length,v?(p=Math.min(p,v.length),m&&(p=Math.min(p,m.length))):p=m?Math.min(p,m.length):0):v&&m&&(p=Math.min(v.length,m.length)),!p)return void(e.visible=!1);g&&p"),s}}},{"../../plots/cartesian/axes":393,"../scatter/hover":548}],581:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../plots/ternary":448,"../scatter/colorbar":543,"./attributes":577,"./calc":578,"./defaults":579,"./hover":580,"./plot":582,"./select":583,"./style":584}],582:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e){for(var r={x:function(){return t.xaxis},y:function(){return t.yaxis},plot:t.plotContainer},i=new Array(e.length),a=t.graphDiv.calcdata,o=0;oe){for(var r=g/e,n=[0|Math.floor(t[0].shape[0]*r+1),0|Math.floor(t[0].shape[1]*r+1)],i=n[0]*n[1],o=0;or;++r)this.showContour[r]&&(e=!0,t[r]=this.scene.contourLevels[r]);e&&this.surface.update({levels:t})},v.update=function(t){var e,r=this.scene,n=r.fullSceneLayout,a=this.surface,s=t.opacity,l=i(t.colorscale,s),u=t.z,h=t.x,d=t.y,g=n.xaxis,v=n.yaxis,m=n.zaxis,y=r.dataScale,b=u[0].length,x=u.length,_=[c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x])],w=_[0],k=_[1],A=r.contourLevels;this.data=t,f(_[2],function(t,e){return m.d2l(u[e][t])*y[2]}),Array.isArray(h[0])?f(w,function(t,e){return g.d2l(h[e][t])*y[0]}):f(w,function(t){return g.d2l(h[t])*y[0]}),Array.isArray(d[0])?f(k,function(t,e){return v.d2l(d[e][t])*y[1]}):f(k,function(t,e){return v.d2l(d[e])*y[1]});var M={colormap:l,levels:[[],[],[]],showContour:[!0,!0,!0],showSurface:!t.hidesurface,contourProject:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],contourWidth:[1,1,1],contourColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],contourTint:[1,1,1],dynamicColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],dynamicWidth:[1,1,1],dynamicTint:[1,1,1],opacity:1};if(M.intensityBounds=[t.cmin,t.cmax],t.surfacecolor){var T=c(new Float32Array(b*x),[b,x]);f(T,function(e,r){return t.surfacecolor[r][e]}),_.push(T)}else M.intensityBounds[0]*=y[2],M.intensityBounds[1]*=y[2];this.dataScale=o(_),t.surfacecolor&&(M.intensity=_.pop()),"opacity"in t&&t.opacity<1&&(M.opacity=.25*t.opacity);var E=[!0,!0,!0],L=["x","y","z"];for(e=0;3>e;++e){var S=t.contours[L[e]];E[e]=S.highlight,M.showContour[e]=S.show||S.highlight,M.showContour[e]&&(M.contourProject[e]=[S.project.x,S.project.y,S.project.z],S.show?(this.showContour[e]=!0,M.levels[e]=A[e],a.highlightColor[e]=M.contourColor[e]=p(S.color),S.usecolormap?a.highlightTint[e]=M.contourTint[e]=0:a.highlightTint[e]=M.contourTint[e]=1,M.contourWidth[e]=S.width):this.showContour[e]=!1,S.highlight&&(M.dynamicColor[e]=p(S.highlightcolor),M.dynamicWidth[e]=S.highlightwidth))}M.coords=_,a.update(M),a.visible=t.visible,a.enableDynamic=E,a.snapToData=!0,"lighting"in t&&(a.ambientLight=t.lighting.ambient,a.diffuseLight=t.lighting.diffuse,a.specularLight=t.lighting.specular,a.roughness=t.lighting.roughness,a.fresnel=t.lighting.fresnel),s&&1>s&&(a.supportsTransparency=!0)},v.dispose=function(){this.scene.glplot.remove(this.surface),this.surface.dispose()},e.exports=s},{"../../lib/str2rgbarray":383,"gl-surface3d":177,ndarray:225,"ndarray-fill":215,"ndarray-homography":217,"ndarray-ops":219,tinycolor2:275}],589:[function(t,e,r){"use strict";function n(t,e,r){e in t&&!(r in t)&&(t[r]=t[e])}var i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}var c,u,f=l("z");if(!f)return void(e.visible=!1);var h=f[0].length,d=f.length;if(l("x"),l("y"),!Array.isArray(e.x))for(e.x=[],c=0;h>c;++c)e.x[c]=c;if(l("text"),!Array.isArray(e.y))for(e.y=[],c=0;d>c;++c)e.y[c]=c;l("lighting.ambient"),l("lighting.diffuse"),l("lighting.specular"),l("lighting.roughness"),l("lighting.fresnel"),l("hidesurface"),l("opacity");var p=l("surfacecolor");l("colorscale");var g=["x","y","z"];for(c=0;3>c;++c){var v="contours."+g[c],m=l(v+".show"),y=l(v+".highlight");if(m||y)for(u=0;3>u;++u)l(v+".project."+g[u]);m&&(l(v+".color"),l(v+".width"),l(v+".usecolormap")),y&&(l(v+".highlightcolor"),l(v+".highlightwidth"))}p||(n(t,"zmin","cmin"),n(t,"zmax","cmax"),n(t,"zauto","cauto")),a(t,e,s,l,{prefix:"",cLetter:"c"})}},{"../../components/colorscale/defaults":306,"../../lib":372,"./attributes":585}],590:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("./colorbar"),n.calc=t("./calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="surface",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","noOpacity"],n.meta={},e.exports=n},{"../../plots/gl3d":428,"./attributes":585,"./calc":586,"./colorbar":587,"./convert":588,"./defaults":589}],591:[function(t,e,r){"use strict";function n(t,e){function r(e,r){var i=o.nestedProperty(t,e).get(),a=o.nestedProperty(n,e).get();a.push(i[r])}var n=o.extendDeep({},t),s=e.transform,l=s.filtersrc,c=i(s),u=t[l].length,f=a(t);f.forEach(function(t){o.nestedProperty(n,t).set([])});for(var h=0;u>h;h++){var d=t[l][h];if(c(d))for(var p=0;pt};case">":return function(t){return t>e}}}function a(t,e){e=e||"";var r=[];return Object.keys(t).forEach(function(n){var i=t[n];"_"!==n.charAt(0)&&("transforms"===n?i.forEach(function(t,i){r=r.concat(a(t,e+n+"["+i+"]."))}):o.isPlainObject(i)?r=r.concat(a(i,e+n+".")):Array.isArray(i)&&r.push(e+n))}),r}var o=t("../../../../src/lib");r.moduleType="transform",r.name="filter",r.attributes={operation:{valType:"enumerated",values:["=","<",">"],dflt:"="},value:{valType:"number",dflt:0},filtersrc:{valType:"enumerated",values:["x","y"],dflt:"x"}},r.supplyDefaults=function(t,e,n){function i(e,n){return o.coerce(t,a,r.attributes,e,n)}var a={};return i("operation"),i("value"),i("filtersrc"),a},r.transform=function(t,e){var r=t.map(function(t){return n(t,e)});return r}},{"../../../../src/lib":372}],592:[function(t,e,r){"use strict";function n(t,e){for(var r=e.transform,n=r.groups,a=n.filter(function(t,e,r){return r.indexOf(t)===e}),o=new Array(a.length),s=Math.min(t.x.length,t.y.length,n.length),l=0;lf;f++)n[f]===c&&(u.x.push(t.x[f]),u.y.push(t.y[f]));u.name=c,u.marker.color=r.groupColors[c]}return o}var i=t("../../../../src/lib");r.moduleType="transform",r.name="groupby",r.attributes={active:{valType:"boolean",dflt:!0},groups:{valType:"data_array",dflt:[]},groupColors:{valType:"any",dflt:{}}},r.supplyDefaults=function(t,e,n){function a(e,n){return i.coerce(t,o,r.attributes,e,n)}var o={},s=a("active");return s?(a("groups"),a("groupColors"),o):o},r.transform=function(t,e){var r=[];return t.forEach(function(t){r=r.concat(n(t,e))}),r}},{"../../../../src/lib":372}]},{},[12])(12)}); \ No newline at end of file diff --git a/man/add_chull.Rd b/man/add_chull.Rd new file mode 100644 index 0000000000..2aed49d33c --- /dev/null +++ b/man/add_chull.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add.R +\name{add_chull} +\alias{add_chull} +\usage{ +add_chull(p, ...) +} +\examples{ + +x <- rnorm(10) +plot_ly(x = ~x) \%>\% + add_chull() +} + diff --git a/man/add_polygons.Rd b/man/add_polygons.Rd new file mode 100644 index 0000000000..44cbb77c9a --- /dev/null +++ b/man/add_polygons.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add.R +\name{add_polygons} +\alias{add_polygons} +\usage{ +add_polygons(p, ...) +} +\examples{ + +library(dplyr) +data(canada.cities, package = "maps") +canada.cities \%>\% + group_by(name) \%>\% + plot_ly(x = ~long, y = ~lat) \%>\% + add_points() +} + diff --git a/man/group2NA.Rd b/man/group2NA.Rd index 19e37adbb4..52ed2ef3b7 100644 --- a/man/group2NA.Rd +++ b/man/group2NA.Rd @@ -1,9 +1,12 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/dplyr.R +% Please edit documentation in R/dplyr.R, R/plotly_data.R \name{group2NA} \alias{group2NA} \title{Insert missing values to create trace groupings} \usage{ +group2NA(data, groupNames = "group", nested = NULL, + retrace.first = inherits(data, "GeomPolygon")) + group2NA(data, groupNames = "group", nested = NULL, retrace.first = inherits(data, "GeomPolygon")) } @@ -15,10 +18,25 @@ group2NA(data, groupNames = "group", nested = NULL, \item{nested}{other variables that group should be nested (i.e., ordered) within.} +\item{retrace.first}{should the first row of each group be appended to the +last row? This is useful for enclosing polygons with lines.} + +\item{data}{a data frame.} + +\item{groupNames}{name(s) of the grouping variable(s) as a character vector} + +\item{nested}{other variables that group should be nested +(i.e., ordered) within.} + \item{retrace.first}{should the first row of each group be appended to the last row? This is useful for enclosing polygons with lines.} } \description{ +If a group of traces share the same non-positional characteristics (i.e., +color, fill, etc), it is more efficient to draw them as a single trace +with missing values that separate the groups (instead of multiple traces). +This is a helper function for inserting missing values into a data set + If a group of traces share the same non-positional characteristics (i.e., color, fill, etc), it is more efficient to draw them as a single trace with missing values that separate the groups (instead of multiple traces). @@ -28,5 +46,8 @@ This is a helper function for inserting missing values into a data set elong <- tidyr::gather(economics, variable, value, -date) plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) +elong <- tidyr::gather(economics, variable, value, -date) +plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) + } diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index da2c63ffea..a550c2eb92 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -5,8 +5,7 @@ \title{Initiate a plotly visualization} \usage{ plot_ly(data = data.frame(), ..., type = NULL, color, colors, symbol, - symbols, size, width = NULL, height = NULL, inherit = FALSE, - source = "A") + symbols, size, width = NULL, height = NULL, source = "A") } \arguments{ \item{data}{A data frame (optional).} @@ -33,8 +32,6 @@ or a color interpolation function like \code{colorRamp()}.} \item{height}{Height in pixels (optional, defaults to automatic sizing).} -\item{inherit}{logical. Should future traces inherit properties from this initial trace?} - \item{source}{Only relevant for \link{event_data}.} } \description{ diff --git a/man/plotly-data.Rd b/man/plotly-data.Rd index a55ae3a7a0..18dae2a24d 100644 --- a/man/plotly-data.Rd +++ b/man/plotly-data.Rd @@ -18,7 +18,7 @@ \usage{ groups.plotly(x) -group_by_.plotly(.data, ..., .dots, add = FALSE) +\method{group_by_}{plotly}(.data, ..., .dots, add = FALSE) ungroup.plotly(x) @@ -26,13 +26,13 @@ summarise_.plotly(.data, ..., .dots) mutate_.plotly(.data, ..., .dots) -arrange_.plotly(.data, ..., .dots) +\method{arrange_}{plotly}(.data, ..., .dots) select_.plotly(.data, ..., .dots) filter_.plotly(.data, ..., .dots) -distinct_.plotly(.data, ..., .dots) +\method{distinct_}{plotly}(.data, ..., .dots) slice_.plotly(.data, ..., .dots) diff --git a/man/plotly_data.Rd b/man/plotly_data.Rd new file mode 100644 index 0000000000..cd415daaa8 --- /dev/null +++ b/man/plotly_data.Rd @@ -0,0 +1,69 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plotly_data.R +\name{plotly_data} +\alias{arrange_.plotly} +\alias{distinct_.plotly} +\alias{filter_.plotly} +\alias{group_by_.plotly} +\alias{groups.plotly} +\alias{mutate_.plotly} +\alias{plotly_data} +\alias{rename_.plotly} +\alias{select_.plotly} +\alias{slice_.plotly} +\alias{summarise_.plotly} +\alias{transmute_.plotly} +\alias{ungroup.plotly} +\title{View and manipulate data associated with a plotly graph} +\usage{ +plotly_data(p, id = p$x$cur_data) + +groups.plotly(x) + +\method{group_by_}{plotly}(.data, ..., .dots, add = FALSE) + +ungroup.plotly(x) + +summarise_.plotly(.data, ..., .dots) + +mutate_.plotly(.data, ..., .dots) + +\method{arrange_}{plotly}(.data, ..., .dots) + +select_.plotly(.data, ..., .dots) + +filter_.plotly(.data, ..., .dots) + +\method{distinct_}{plotly}(.data, ..., .dots) + +slice_.plotly(.data, ..., .dots) + +rename_.plotly(.data, ..., .dots) + +transmute_.plotly(.data, ..., .dots) +} +\description{ +\code{plotly_data()} returns the data associated with +a plotly visualization. This data can be manipulated via +the dplyr and tidyr verbs listed below: +} +\examples{ + +# loading dplyr is super important! +library(dplyr) + +mtcars \%>\% + plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") \%>\% + filter(cyl == 4) \%>\% + add_points(x = ~wt, y = ~mpg, name = "filtered points", + marker = list(color = "red")) + +library(tidyr) +economics \%>\% + gather(variable, value, -date) \%>\% + group_by(variable) \%>\% + plot_ly(x = ~date, y = ~value) + +} +\keyword{internal} + diff --git a/man/plotly_spec.Rd b/man/plotly_spec.Rd index 45172be8ab..62ebcf0a6a 100644 --- a/man/plotly_spec.Rd +++ b/man/plotly_spec.Rd @@ -4,14 +4,14 @@ \alias{plotly_spec} \title{Obtain JSON sent to plotly.js} \usage{ -plotly_spec(p = plot_ly(), as = c("plain", "json"), ...) +plotly_spec(p = plot_ly(), as = c("json", "plain"), pretty = TRUE) } \arguments{ \item{p}{a plotly or ggplot object.} \item{as}{in what format should the spec be printed?} -\item{...}{arguments passed onto \code{jsonlite::toJSON}} +\item{pretty}{adds indentation whitespace to JSON output.} } \description{ This function returns the JSON sent to plotly.js which can be useful for From bb839791551caa25909a9c7a5b52d6356af01c5c Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 1 Jun 2016 13:23:30 +1000 Subject: [PATCH 09/73] error checking for trace attributes --- NAMESPACE | 1 + NEWS | 2 +- R/helpers.R | 12 ++++++++++++ R/plotly.R | 10 +++++++--- R/plotly_build.R | 4 +++- R/sysdata.rda | Bin 202 -> 6381 bytes R/utils.R | 17 +++++++++++++++-- inst/plotlyjs.R | 38 ++++++++++++++++++++++++++++++++------ man/add_polygons.Rd | 11 +++++++---- man/add_trace.Rd | 7 +++++++ man/explain_attrs.Rd | 21 +++++++++++++++++++++ man/plot_ly.Rd | 2 +- man/plotly_empty.Rd | 2 +- man/plotly_spec.Rd | 7 +++++-- 14 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 man/explain_attrs.Rd diff --git a/NAMESPACE b/NAMESPACE index c0001103cf..0855354b5d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -63,6 +63,7 @@ export(as.widget) export(config) export(embed_notebook) export(event_data) +export(explain_attrs) export(export) export(filter_.plotly) export(geom2trace) diff --git a/NEWS b/NEWS index 7a04124a35..b414ff3434 100644 --- a/NEWS +++ b/NEWS @@ -12,7 +12,7 @@ Traces created via `add_trace()` (or, more generally, by any `add_*()` function) NEW FEATURES & IMPROVEMENTS: -* Error checking for trace types and their attributes. +* Error checking for trace types and their attributes. Also added a `show_attributes()` function to obtain information about trace attributes. * New `add_points()`/`add_lines()`/`add_text()` functions provide a shorthand for common plots. * New `toWebGL()` function for easy conversion from SVG to WebGL. * New `export()` function makes it easy to save plots as png/jpeg/pdf (fixes #311). diff --git a/R/helpers.R b/R/helpers.R index 4cdb343b94..bd38322611 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -23,6 +23,18 @@ plotly_spec <- function(p = plot_ly(), attr = NULL, as = c("json", "plain"), pre spec } +#' Show information about attribute(s) of a given trace type +#' +#' @export +#' @param type a trace type +#' @param attrs attributes for the race type +#' @examples +#' +#' explain_attrs() +explain_attrs <- function(type = "scatter", attrs = c("x", "y")) { + jsonlite::toJSON(verify_attrs(type, attrs), pretty = TRUE) +} + #' Convert trace types to WebGL #' diff --git a/R/plotly.R b/R/plotly.R index 164e3a1c34..af01211cf1 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -58,21 +58,25 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, width = NULL, height = NULL, source = "A") { # "native" plotly arguments argz <- list(...) - # old arguments to this function that are no longer supported + # warn about old arguments that are no longer supported for (i in c("filename", "fileopt", "world_readable")) { if (is.null(argz[[i]])) next warning("Ignoring ", i, ". Use plotly_POST() if you want to post figures to plotly.") + argz[[i]] <- NULL } if (!is.null(argz[["group"]])) { warning("The group argument has been deprecated. Use group_by() instead.") + argz[["group"]] <- NULL } if (!is.null(argz[["inherit"]])) { warning("The inherit argument has been deprecated.") + argz[["inherit"]] <- NULL } - # if type is NULL, return the default trace type with a message - # if type is invalid, throw an error + # verify trace type and it's attributes argz$type <- verify_type(type) + attrs <- verify_attrs(argz$type, names(argz)) + # tack on "special" arguments argz$color <- verify_arg(color) argz$symbol <- verify_arg(symbol) diff --git a/R/plotly_build.R b/R/plotly_build.R index a31adeabc6..3e9164b62d 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -46,7 +46,7 @@ plotly_build.plotly <- function(p) { # get rid of the data -> layout mapping and merge all the layouts # into a single layout (more recent layouts will override older ones) p$x$layoutAttrs <- NULL - p$x$layout <- modifyList(p$x$layout %||% list(), Reduce(modifyList, layouts)) + p$x$layout <- modifyList(p$x$layout %||% list(), Reduce(modifyList, layouts) %||% list()) dats <- Map(function(x, y) { @@ -82,6 +82,8 @@ plotly_build.plotly <- function(p) { # traces can't have names p$x$data <- setNames(p$x$data, NULL) + + p } diff --git a/R/sysdata.rda b/R/sysdata.rda index a1dff32fa34ac6eeb4bb75f341261e17c582ebe5..5cc5e1bd9eee04290cda22b984b68078659b63d8 100644 GIT binary patch literal 6381 zcmW-lcQ_mB7ss`|y}d@;du!8iTf{D6)$VPt9nvC+m_=g5s$C)64irI&gv4rXiE)Lb zwp%-9jZnLk+M|e(qCfq8&U2n~&hvf$dEdXz_kCdFuA%f79AF7Au&}E=2g#58amLB? zkF)yc>Ca*N0mpsC`+wfQ{~y4Jh>Y1`A(4d}wyL_~S+C+q{1Q{!(!tzAsHR1Dl}lPdpqsx5~lMbpeo_V343z zl)v|nw>i!@uBA$`6rqFw3a4W$<~p!c#WJfLIdtBg6QQmt*jJZ2>`7Y%F#^K&G(8yO zHWe5h1rgOVBsHo};U#S&Gu~>XjH2zk6i?5nK7Z@Fa?_O68hd1X{(EykVWH%qB=383qgdwDaPLv`AADT}UicID+!o1Yt^zh( zhUdeB2>w1k$~InD=IaZ44GZ$qT))S)_a~A?O}wORi*2p+Z2w95Txk6$F+9;|?)-c{ z^y~6eiT5MD@O2C|2;+#e9ghrIx~cT?FVt2whd?e{Wq zDUld8@G2-v@*qv0))%aR_XsYvu7}E5SNf;T>NRQsh8wk(G{#lc?@wQ-J&qgr=HLsX zjBtI^M~4$^^sWcue>l1=Zi}tAy6s0+_OVZ+LUX^PA@kp&Fl8BHUk9R9wkcS^lbe6o z*-ejWp2jpiT|1urFke1lzGc9l94^VbNY~y>7J{d(S*m_Ec{=OPbawmBd)5^?LMutHy$|l30UKgR> zcIPIAo+FU*4H#0%zK=!F?Lt;bJdf*rw)zR#AP0AKUMlcZ2DmErRtXBx;<}z-i=u#@ zfur#Ddr$2E3+;X?eKwC>IrI2bQ;0mK08?ciAj7+~3uQ)CjRy8wM#@!*dW&uZj(%TY zWUP>tFYpu6qp6eO3sdSv!gcdcl?8n9bgC&=x8lFhuan-ckL#$SRQdO^c3u<NPhuuk7_X#>Rh4iK@GBHiHw?9)+N<#wTIX4gszMG zU6G-gj4CWZ&sE*l^_^wY*iB`aTY3z7#8%I7qLy1U=WaxxjA_>9BnZGUK;&udhiM6#ihTf^riQ8J*gwGItwfuW@uL>=f9sjkFXy>~BxRYYe ziiE2zE)Du;`ar&1{e^VNR?{_j?9KReGqVWYP_Oo20za_m;jYA0$C_N5LTP_vz}zls zl%E8A=*dK_>=?R+4K~e8><9;1xi`e`HY$~_Ge1rY4SP+x7Je6nRI3*jjssM123Ajc zY0s75JW!(^&)dbwGO5wWNNRPNI8(9Ade|!-HBMG7gv9;VreWCa8z zwcA&8w$gW9U6iz#yEZyu8+7L&C4zN_vRp6md3s(HLb(;1p)yCX%i8kRxE`=D(nsoU z52YO~Fu(;n4low)IQO#y~v){LF+rJqaeMNX{z8|`!3v)C^j8NN;i!(%$zd=ft z{p2AHL!&8g+w?D~r+NLPwC6eI5(A|@F=h_5mWvCv>$8!nHgM5IzeZ?}X-UAM?<(sa zjO%Ma#=^og|1nLZdghLIw!PC(259!OIfyt>3eEkBv_|YP`eHjEU&?qZzr0UE%!h~V zFPB1h>E??b%H`@o?8B^T#s?hkVxB}KMBCKjAT3R1BO@(WQ@gCpjpElXYG0GpP@N$c zpKV-=7mViZW|$u5lZ_4-d{{ny$9~0IC+XuUB}!JZ$AbOi_YLc%FSVyUN-RAm{NypL zi}KdVA6htAGeeTY+h7Giz+UH8X(9ocjFpdvCKn`QNxcSef&@ObNG17-miLl_~TkipHzw4F4Ap0p!b+n0yKhOJP+!euatZs)-^@XWK9B5Y)Gl2fI>i}DiF~{Mc8y#SsKU2 z2`d5J@v_y$LX1}*Ag)rvcm16$rJv*K+#{o`x%OH>d>_CsEF|tcO5pIMf&PBY`tMPdPAcqT&_oEHQG6V)ASV3vE2*kGJ)N`u$*-jABFG=zT z52}I5h!q{n%nAQ2w^>y^&e*kdA}|_6RFn*7;F=H&oTLh?A7}YNTT;5ee7s~_qd$P; zZ|*^T2Fm7b3CJ+FEZrt$^X5-esUhYo<64sbKgAGG)^Oeb#Z6Myu;eQSjz5_9yBTk? z_Rs#gy16AUfcJ$nqK)yjeoUVnXgB)I(C5VO@Kz-msA<|5J`N*RpSo;2p6Wzk=OeGh zpK!?=VY-`NT)WeHTj~lL4#<6GQ6Q23HzC==!W5i;1Ww&9SWQ29h8MscO^KMroj9W$ z9S4kMS%n>G$o3Q-S93X_<HyrrQ;4 z+Kt5>!a5pReS%Zk?mC3AMIm}|`*M5$i+@UCA!P{_Z-vorZ~0DNIn6qGx$O1G)LCtKbqA@v+ zk=Q{er~k;mI%!j0g2W(ibnRVhVnlq40IpL;4x&Cc69_y>>fw#S#z7AHl%_=Y#A-vj zmRD~FSSNs{04xhmz#a#P(IfrS`p`4TtEdJ@wmo^%D%4sy7Hp;!p=9IqPFbR#PV3kQgq((}zrVKzCf zP|ZHboGt@5t23+UQ1I(b@u7p%*0}}JXT@Z8+8T-;fK{<8MB;l;RYQ8U{3yBJz(q{Jz@(S_;TyW*IdiYG)ljw=Z~yV2NO~>(0KC66pq{l0&kp5Y&*T`RxTkw?i8H<=Dn zTLktCG@sPbOYa~YCLp5<4f#stC+5udXf}zL1kGd#Q@^PN4$3>0d}w_Z0L}BXs0*sD z=~{H*&POR=23p?9yq{m zXi3A2LdQQ{KO=GHd5gr(< z^`tzmojq6JabZeNQ$b>C4j#~>ro~(ys^=Ph#1?zaE>03(yWv?wSceK27&svqskx&9 z3JPl-g%pWs7jB`OL-?r#t$O}!sReNFL|=(BQ=gMA7c8~<9ZQ`xPVIy>&_ zUX+Oj^7?;{JLYmM!#geSM%!oBSK-0ftz$`?F&)^d1c&2s!d7jeF4H;z(|X2rjg`CL z?1+HOkwra?>IrYPEShMfX^!oDjo{dz&m4O;K|7M)&K!4pfxCE-b8YWLSC1Y>t#~0j zb7vKLf!xG;0-JjrYtZ(ut?YXARyS@^Bek18{2;Svh;g84F9<_;#d~tT3_2JtGvs_- zvf3_U&T02k)`gn+$_^r=XfW3i?Ws1P{jT2N=0_Ob_yncugSl`vIjS}V(I*S zW?_?`%?f!5Ttrf!h4t;>3{|6}c{Z>Da^d4qgL-`Gsf;0P!IXbEw!lxx1|&

F-+| zJDzNA5?WM$+fjeC#{y0u$bX(~(-+JepFc7A7OsQJ8I#xvkxT(scAEcqICWxJ%u0ix zA33CiukJx#`eIZn#zE88GsNfE^wJvG?+ax|;~#4~Vm~6DYFH3K1wgy|bPWotsJP;j zjpW$XshBTUB0g*+(QYI!H>z(M2Kwp3S=LL>Ojets;swqOaTqc%DQL^Osj;)zF-v<# zDHfC?Kpw2P1Y;y&)_omTxA!h;uLiTN5N@q)%$ftMmr~@T3mtiuFQ^rw$_t~`pQzYf zdKKMa^7x()EcK)&hD60vtoP7!Q!@4gsg+j;obi;}Shl5p*xFQ}2G`C92Rmu)DjTrL zP^hW?ioEnX<#Vskw?j%_)eh8eN`g9mWR{;Gp{qO#1!n=hAGuTfGZH$WZBV$X>%rwo zP<3_X+de=6q~%k4EutD|t>mQf?m)NcecvWLNOor3{8Ob>o9@C8rCz=ikN`)uOgte% zFEF)j@zhYubtfBWhfGP_vQ)4N7OL=E;WqdZGsL`|QS$bymgpdLVw>J$JIqg4mX1P3 zTTNSX`LsWy_|FE5Iay2+HDa2^g|Vcd&` z4<8+SS_xL&M&EBFv!CA;ysdYuslqxG2zVR9iRKEy_b!w_{ko#$O(EaWJ~KOnVx;6m1>dXp$b0W&!NOnk zIKR84XwKxkTs3Aglcegy`LzzIj&fmn3wiCQl40|E6=|5k;1sIDo#GlI>Jp;_I+HL@ zzf5Gq&FoNq>7qTt)}vKYBd&Qi5Q2-1M>GLa<%-G>qGcdOg`+LyAjxmx?)6dM2E(Zy z=2A%_m!#J7ZSkKhC43Ue*Wa;Z6EEl^HFaaPJTo>AWs~cCmaQ~rQDKlnp;8gadwv)1 zd1x3%zaEBa;XdMhc8Vs*M?Wr=-HmxbZVT9U@6i{*@eeW3;-4c~W;KAZu!B2W`|XE) z{+K9FhAlfT>K_` z?Bdosz7>W!{e>-v32xm<{eDaQ>ZG1D4)8|fy;nucr2Lu-I>*E6_)fc`(%;tjfI0&d z&k=b}Bp?z0)Ly)f*~4pLb2p(Q??&9%miNaRpy(tu`?Pn^u1uCVvS#fwKW8)iys-%7 ztwsc%ZKeR+wuT8TAa(QqlVq$~aq!dCr9YSI6ufa8Y=ZNMr+AN0uw+cVTFAq^%Q;v_ zO{(6_8rQI;rl;ivYvrtv8Reoa@@}iOrS(znF>cs2ZeAhKKd(u*nEjnr$DDgC;3uCCtkw|H(@6CJmeu(#|xIhDn7NfAX(wiO+bpev6f zkiYUz96j6&KAFTnvq;%wXCb$+0{nA4BVnU&p6r_PzN2#>{(0WE{G(EPcGD|r=5g@`8Szn)K+vgj!g=~81 zbzt&Kl0d>t#q)6?Q@f=0la)VVj&KN>ed<*cD2j@IJVdZ0o5=kjhV0=9ASi1XM-?Su zVpj^t*0G8MNo`R*gBC>q(H!KZ8H6-9Ip+o7NhlPW*e)!}%}9}B5zF|yk}1N3hPAai E@H}}{r2qf` diff --git a/R/utils.R b/R/utils.R index deac0953fe..4013b24e71 100644 --- a/R/utils.R +++ b/R/utils.R @@ -46,14 +46,14 @@ verify_plot <- function(p) { # TODO: add an argument to verify trace properties are valid (https://github.com/ropensci/plotly/issues/540) verify_type <- function(type = NULL) { if (is.null(type)) { - message("No trace type specified. Guessing you want a scatter trace") + message("No trace type specified. Guessing you want a 'scatter' trace") type <- "scatter" } if (!is.character(type) || length(type) != 1) { stop("The trace type must be a character vector of length 1.\n", call. = FALSE) } - if (!type %in% traces) { + if (!type %in% names(traces)) { stop("Trace type must be one of the following: \n", "'", paste(traces, collapse = "', '"), "'", call. = FALSE) @@ -61,6 +61,19 @@ verify_type <- function(type = NULL) { type } +verify_attrs <- function(type = NULL, attributes = NULL) { + type <- verify_type(type) + attrs <- traces[[type]]$attributes + idx <- attributes %in% names(attrs) + if (any(!idx)) { + stop( + "The '", type, "' trace type doesn't have attribute(s) named: '", + paste(attributes[!idx], collapse = "', '"), "'", call. = FALSE + ) + } + attrs[attributes] +} + # is a given trace type 3d? is3d <- function(type = NULL) { type <- type %||% "scatter" diff --git a/inst/plotlyjs.R b/inst/plotlyjs.R index 7837c8aafa..81519885af 100644 --- a/inst/plotlyjs.R +++ b/inst/plotlyjs.R @@ -4,12 +4,6 @@ zip <- content(x)$zipball_url tmp <- tempfile(fileext = ".zip") download.file(zip, tmp) unzip(tmp) -# save trace types (mostly for error checking on the R side) -traces <- basename(Sys.glob("plotly-plotly.js*/src/traces/*")) -devtools::use_data(traces, overwrite = TRUE, internal = TRUE) -# TODO: figure out the _required_ properties of each trace type, store them -# as internal R data, and use them to provide error checking - # update the plotly.js bundle p <- Sys.glob("plotly-plotly.js*/dist/plotly.min.js") file.copy(p, "inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js", overwrite = T) @@ -18,3 +12,35 @@ file.copy(l, "inst/htmlwidgets/lib/plotlyjs/LICENSE", overwrite = T) unlink("plotly-plotly.js*", recursive = T) message("Manually update plotly.yaml with this version") basename(zip) + + + +#' Update plotly's internal traces information +#' +#' Note this script requires RSelenium and phantomjs and shouldn't be +#' run other than package maintainers +#' +#' +#' @param path a path pointing to the source of plotly's R package + +update_attributes <- function(path = ".") { + if (!is.na(Sys.getenv("RSTUDIO", NA))) { + stop("This function must be called outside of RStudio") + } + devtools::load_all(path) + pjs <- RSelenium::phantom() + on.exit(pjs$stop(), add = TRUE) + remDr <- RSelenium::remoteDriver(browserName = "phantomjs") + Sys.sleep(5) + remDr$open(silent = TRUE) + htmlwidgets::saveWidget(plotly::plot_ly(), "index.html") + remDr$navigate(file.path(getwd(), "index.html")) + traces <- remDr$executeScript("return Plotly.PlotSchema.get().traces") + devtools::use_data(traces, overwrite = TRUE, internal = TRUE) +} + + +update_attributes() + + + diff --git a/man/add_polygons.Rd b/man/add_polygons.Rd index 44cbb77c9a..11c2df88be 100644 --- a/man/add_polygons.Rd +++ b/man/add_polygons.Rd @@ -9,9 +9,12 @@ add_polygons(p, ...) library(dplyr) data(canada.cities, package = "maps") -canada.cities \%>\% - group_by(name) \%>\% - plot_ly(x = ~long, y = ~lat) \%>\% - add_points() + +ggplot2::map_data("world", "canada") \%>\% + group_by(group) \%>\% + plot_ly(x = ~long, y = ~lat, hoverinfo = "none") \%>\% + add_points(text = ~paste(name, "
", pop), hoverinfo = "text", + data = canada.cities) \%>\% + layout(showlegend = FALSE) } diff --git a/man/add_trace.Rd b/man/add_trace.Rd index 65a3f9d234..cfca903b13 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -30,6 +30,13 @@ provided, arguments are evaluated using the data frame in \code{\link{plot_ly}() } \description{ Add a trace to a plotly visualization +} +\examples{ + +p <- plot_ly(economics, x = ~date, y = ~uempmed) +# add a loess smoother +p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) + } \author{ Carson Sievert diff --git a/man/explain_attrs.Rd b/man/explain_attrs.Rd new file mode 100644 index 0000000000..af8bd62185 --- /dev/null +++ b/man/explain_attrs.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helpers.R +\name{explain_attrs} +\alias{explain_attrs} +\title{Show information about attribute(s) of a given trace type} +\usage{ +explain_attrs(type = "scatter", attrs = c("x", "y")) +} +\arguments{ +\item{type}{a trace type} + +\item{attrs}{attributes for the race type} +} +\description{ +Show information about attribute(s) of a given trace type +} +\examples{ + +explain_attrs() +} + diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index a550c2eb92..903f77d8cb 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -45,7 +45,7 @@ Reference section (see below). \dontrun{ data(economics, package = "ggplot2") # basic time-series plot -p <- plot_ly(economics, x = ~date, y = ~uempmed, inherit = TRUE) +p <- plot_ly(economics, x = ~date, y = ~uempmed) # add a loess smoother p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) # add a title diff --git a/man/plotly_empty.Rd b/man/plotly_empty.Rd index 0177e2994f..481a37677d 100644 --- a/man/plotly_empty.Rd +++ b/man/plotly_empty.Rd @@ -4,7 +4,7 @@ \alias{plotly_empty} \title{Create a complete empty plotly graph.} \usage{ -plotly_empty() +plotly_empty(...) } \description{ Useful when used with \link{subplot} diff --git a/man/plotly_spec.Rd b/man/plotly_spec.Rd index 62ebcf0a6a..944f46ba7b 100644 --- a/man/plotly_spec.Rd +++ b/man/plotly_spec.Rd @@ -4,11 +4,14 @@ \alias{plotly_spec} \title{Obtain JSON sent to plotly.js} \usage{ -plotly_spec(p = plot_ly(), as = c("json", "plain"), pretty = TRUE) +plotly_spec(p = plot_ly(), attr = NULL, as = c("json", "plain"), + pretty = TRUE) } \arguments{ \item{p}{a plotly or ggplot object.} +\item{attr}{focus on a particular attribute in the spec.} + \item{as}{in what format should the spec be printed?} \item{pretty}{adds indentation whitespace to JSON output.} @@ -19,6 +22,6 @@ debugging. } \examples{ -plotly_spec(plot_ly(), as = "json", pretty = TRUE) +plotly_spec(plot_ly(), "data") } From 7300e8d1a9b23afc60c41cea9a06db83a0c69d29 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 10 Jun 2016 08:41:37 +1200 Subject: [PATCH 10/73] unlink file when updating plotlyjs attrs --- R/add.R | 2 +- inst/plotlyjs.R | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/R/add.R b/R/add.R index 18924ab073..4da85a6e24 100644 --- a/R/add.R +++ b/R/add.R @@ -105,7 +105,7 @@ add_polygons <- function(p, ...) { #' @export add_ribbons <- function(p, ...) { - # TODO: Should mode='markers+lines'? If so, retrace first points? + # TODO: add ymin, ymax arguments? add_polygons(...) } diff --git a/inst/plotlyjs.R b/inst/plotlyjs.R index 81519885af..6f9d4adb45 100644 --- a/inst/plotlyjs.R +++ b/inst/plotlyjs.R @@ -30,6 +30,7 @@ update_attributes <- function(path = ".") { devtools::load_all(path) pjs <- RSelenium::phantom() on.exit(pjs$stop(), add = TRUE) + on.exit(unlink("index.html"), add = TRUE) remDr <- RSelenium::remoteDriver(browserName = "phantomjs") Sys.sleep(5) remDr$open(silent = TRUE) From 5a4b314fd784a497535fddda96540ef9f9c087ac Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 10 Jun 2016 11:29:19 +1200 Subject: [PATCH 11/73] fix NEWS version --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 0ec2413f7e..a8a365947b 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -3.6.4 -- 31 May 2016 +3.6.5 -- 10 June 2016 IMPROVEMENT: From b546d10f72fa6e369b483b71616f3e3380a5b303 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 10 Jun 2016 12:08:47 +1200 Subject: [PATCH 12/73] if trace type is missing in add_*(), inherit from first trace --- R/add.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/add.R b/R/add.R index 38e17b69f6..f692def213 100644 --- a/R/add.R +++ b/R/add.R @@ -47,7 +47,7 @@ add_trace <- function(p, ..., # "native" plotly arguments argz <- list(...) - argz$type <- verify_type(argz$type) + argz$type <- verify_type(argz$type %||% p$x$attrs[[1]]$type) if (!is.null(argz[["group"]])) { warning("The group argument has been deprecated. Use group_by() instead.") From 03da3d4b05328de3a28985a138bfad563bca942d Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 10 Jun 2016 18:14:18 +1200 Subject: [PATCH 13/73] use viridisLite; start thinking about 'transforms' --- DESCRIPTION | 4 ++-- R/plotly_build.R | 33 +++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d9d4cac287..0504faa5f0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: plotly Title: Create Interactive Web Graphics via 'plotly.js' -Version: 3.6.5 +Version: 4.0.0 Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"), email = "cpsievert1@gmail.com"), person("Chris", "Parmer", role = c("aut", "cph"), @@ -27,7 +27,7 @@ Imports: jsonlite, magrittr, digest, - viridis, + viridisLite, base64enc, htmlwidgets, tidyr, diff --git a/R/plotly_build.R b/R/plotly_build.R index 3e9164b62d..a61f620f18 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -56,8 +56,9 @@ plotly_build.plotly <- function(p) { grps <- dplyr::groups(d) # insert missing values to differentiate groups if (length(grps) > 0) { - d <- group2NA(d, as.character(grps)) + d <- group2NA(d, groupNames = as.character(grps)) } + # perform the evaluation for (var in names(fl)) { x[[var]] <- lazyeval::f_eval(fl[[var]], d) varname <- sub("^~", "", deparse2(fl[[var]])) @@ -70,10 +71,28 @@ plotly_build.plotly <- function(p) { } } } + + # create an index for splitting the trace into multiple traces + #discreteVars <- compact(list(if (is.discrete(x$color)) x$color, x$symbol)) + #if (length(discreteVars) > 0) { + # idx <- do.call("interaction", discreteVars) + # lvls <- levels(idx) + # + #} + + + # "transforms" for special arguments + # TODO: let plotly.js handle this logic? + # browser() + + + x[lengths(x) > 0] }, p$x$attrs, names(p$x$attrs)) + # it's possible that somethings, like figures (pulled from a plotly server), + # already have "built" data p$x$data <- c(p$x$data, dats) # get rid of data -> vis mapping stuff @@ -82,8 +101,6 @@ plotly_build.plotly <- function(p) { # traces can't have names p$x$data <- setNames(p$x$data, NULL) - - p } @@ -91,8 +108,8 @@ plotly_build.plotly <- function(p) { colorize <- function(dat, title = "") { cols <- dat[["color"]] %||% dat[["z"]] if (is.numeric(cols)) { - # by default, use viridis::viridis(10) -> http://rud.is/b/2015/07/20/using-the-new-viridis-colormap-in-r-thanks-to-simon-garnier/ - colors <- dat[["colors"]] %||% viridis::viridis(10) + # http://rud.is/b/2015/07/20/using-the-new-viridis-colormap-in-r-thanks-to-simon-garnier/ + colors <- dat[["colors"]] %||% viridisLite::viridis(10) cols <- as.vector(cols) rng <- range(cols, na.rm = TRUE) x <- seq(min(rng), max(rng), length.out = 10) @@ -117,7 +134,7 @@ colorize <- function(dat, title = "") { } else { # discrete color scale lvls <- unique(cols) N <- length(lvls) - default <- if (is.ordered(cols)) viridis::viridis(N) + default <- if (is.ordered(cols)) viridisLite::viridis(N) else RColorBrewer::brewer.pal(N, "Set2") colors <- dat[["colors"]] %||% default colz <- scales::col_factor(colors, levels = lvls, na.color = "transparent")(lvls) @@ -131,7 +148,7 @@ colorize <- function(dat, title = "") { symbolize <- function(dat) { # symbols really only make sense when markers are in the mode, right? - dat$mode <- dat$mode %||% "markers" + dat$mode <- grepl("markers", dat$mode %||% "markers") dat <- traceify(dat, "symbol") dat <- lapply(dat, function(x) { x$symbol <- NULL; x }) N <- length(dat) @@ -144,7 +161,7 @@ symbolize <- function(dat) { # break up a single trace into multiple traces according to values stored # a particular key name -traceify <- function(dat, nm = "group") { +traceify <- function(dat, nm = "color") { x <- dat[[nm]] if (is.null(x)) { return(list(dat)) From 94a87971aa3ed90b795ad838bde20c01cf59e2f1 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Sat, 11 Jun 2016 08:26:22 +1200 Subject: [PATCH 14/73] update intro vignette --- vignettes/intro.Rmd | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/vignettes/intro.Rmd b/vignettes/intro.Rmd index 15a3c20134..2dbee86595 100644 --- a/vignettes/intro.Rmd +++ b/vignettes/intro.Rmd @@ -89,15 +89,15 @@ The __plotly__ function arguments used thus far are documented in [the figure re If a ordinal variable (aka a non-ordered factor variable) is assigned to color, then a qualitative color palette is used by default. ```{r} -plot_ly(iris, x = Petal.Length, y = Petal.Width, - color = Species, mode = "markers") +plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width, + color = ~Species, mode = "markers") ``` If you want to change the default palette, it's recommended that you provide a qualitative pallette name (e.g., "Set1" or "Accent") to the colors argument. ```{r} -plot_ly(iris, x = Petal.Length, y = Petal.Width, - color = Species, colors = "Set1", mode = "markers") +plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width, + color = ~Species, colors = "Set1", mode = "markers") ``` In this case, the palette consists of 9 colors and the default behavior is to pick colors that are furthest apart ("#E41A1C", "#FF7F00", and "#999999"). @@ -111,8 +111,8 @@ If you'd like more control over the mapping, you can provide a vector of colors ```{r} cols <- RColorBrewer::brewer.pal(nlevels(iris$Species), "Set1") -plot_ly(iris, x = Petal.Length, y = Petal.Width, - color = Species, colors = cols, mode = "markers") +plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width, + color = ~Species, colors = cols, mode = "markers") ``` #### Sequential color mappings @@ -120,22 +120,22 @@ plot_ly(iris, x = Petal.Length, y = Petal.Width, If either a numeric or an ordered factor is mapped to color, `plot_ly()` applies a sequential color scale by default. ```{r} -plot_ly(iris, x = Petal.Length, y = Petal.Width, - color = as.ordered(Species), mode = "markers") +plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width, + color = ~as.ordered(Species), mode = "markers") ``` In the case of continuous numeric variables, `plot_ly()` performs a linear mapping between the data and an interpolated color pallette. ```{r} -plot_ly(iris, x = Petal.Length, y = Petal.Width, - color = Sepal.Length, mode = "markers") +plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width, + color = ~Sepal.Length, mode = "markers") ``` The colors argument takes arbitrary color codes of arbitrary length. Here is how we could use it to replicate the default mapping in ggplot2. ```{r} -plot_ly(iris, x = Petal.Length, y = Petal.Width, - color = Sepal.Length, colors = c("#132B43", "#56B1F7"), +plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width, + color = ~Sepal.Length, colors = c("#132B43", "#56B1F7"), mode = "markers") ``` @@ -144,8 +144,8 @@ plot_ly(iris, x = Petal.Length, y = Petal.Width, To obtain a diverging color mapping, just provide a diverging palette to the colors argument. ```{r} -plot_ly(iris, x = Petal.Length, y = Petal.Width, - color = Sepal.Length, colors = "PuOr", mode = "markers") +plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width, + color = ~Sepal.Length, colors = "PuOr", mode = "markers") ``` ### The symbol argument @@ -153,13 +153,13 @@ plot_ly(iris, x = Petal.Length, y = Petal.Width, To encode values using symbols, use the symbol argument. ```{r} -plot_ly(iris, x = Petal.Length, y = Petal.Width, - symbol = Species, mode = "markers") +plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width, + symbol = ~Species, mode = "markers") ``` To change the default symbols used, use the symbols argument. All the valid symbol types are listed [here](https://plot.ly/r/reference/#marker). ```{r} -plot_ly(iris, x = Petal.Length, y = Petal.Width, mode = "markers", - symbol = Species, symbols = c("cross", "square", "triangle-down")) +plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width, mode = "markers", + symbol = ~Species, symbols = c("cross", "square", "triangle-down")) ``` From 627ead9d85eab44caac5fb2cd2e844d8d46e3052 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 15 Jun 2016 11:35:23 -0500 Subject: [PATCH 15/73] aesthetic mappings should be plot (not trace) specific; add linetype/linetypes mapping; use entire plot schema for better validation --- NAMESPACE | 6 +- NEWS | 7 +- R/add.R | 89 +++-- R/debug.R | 43 +++ R/dev.R | 39 ++ R/export.R | 2 +- R/helpers.R | 54 --- R/plotly.R | 58 +-- R/plotly_build.R | 334 +++++++++++++----- R/sysdata.rda | Bin 6381 -> 9730 bytes R/utils.R | 91 ++++- .../lib/plotlyjs/plotly-latest.min.js | 78 ++-- inst/plotlyjs.R | 8 +- man/add_chull.Rd | 14 - man/add_lines.Rd | 12 + man/add_points.Rd | 12 + man/add_polygons.Rd | 4 + man/add_ribbons.Rd | 12 + man/add_text.Rd | 12 + man/add_trace.Rd | 2 +- man/explain_attrs.Rd | 2 +- man/plot_ly.Rd | 14 +- man/plotly_empty.Rd | 2 +- man/plotly_json.Rd | 25 ++ man/plotly_spec.Rd | 13 +- man/schema.Rd | 22 ++ man/toWebGL.Rd | 2 +- 27 files changed, 661 insertions(+), 296 deletions(-) create mode 100644 R/debug.R create mode 100644 R/dev.R delete mode 100644 man/add_chull.Rd create mode 100644 man/add_lines.Rd create mode 100644 man/add_points.Rd create mode 100644 man/add_ribbons.Rd create mode 100644 man/add_text.Rd create mode 100644 man/plotly_json.Rd create mode 100644 man/schema.Rd diff --git a/NAMESPACE b/NAMESPACE index 0855354b5d..0e294e6bea 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -48,17 +48,13 @@ S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) S3method(to_basic,default) export("%>%") -export(add_annotation) -export(add_chull) export(add_data) export(add_lines) export(add_points) export(add_polygons) export(add_ribbons) -export(add_shape) export(add_text) export(add_trace) -export(add_transform) export(as.widget) export(config) export(embed_notebook) @@ -83,9 +79,11 @@ export(plotly_POST) export(plotly_build) export(plotly_data) export(plotly_empty) +export(plotly_json) export(plotly_spec) export(rename_.plotly) export(renderPlotly) +export(schema) export(select_.plotly) export(signup) export(slice_.plotly) diff --git a/NEWS b/NEWS index 3e40c123d8..252cb8a5e1 100644 --- a/NEWS +++ b/NEWS @@ -12,13 +12,17 @@ Traces created via `add_trace()` (or, more generally, by any `add_*()` function) NEW FEATURES & IMPROVEMENTS: -* Error checking for trace types and their attributes. Also added a `show_attributes()` function to obtain information about trace attributes. +* Error checking for trace types and their attributes. Also added a `explain_attrs()` function to obtain information about trace attributes. * New `add_points()`/`add_lines()`/`add_text()` functions provide a shorthand for common plots. * New `toWebGL()` function for easy conversion from SVG to WebGL. * New `export()` function makes it easy to save plots as png/jpeg/pdf (fixes #311). * `layout()` is now a generic function and uses method dispatch to avoid conflicts with `graphics:layout()` (fixes #464). * Added a `plotly_spec()` function for inspecting the data sent to plotly.js (as an R list or JSON). +OTHER CHANGES: + +* Upgraded to plotly.js v1.13.0 -- https://github.com/plotly/plotly.js/releases/tag/v1.13.0 + 3.6.5 -- 10 June 2016 IMPROVEMENT: @@ -36,7 +40,6 @@ embed_notebook() will no longer use a '.embed' extension in the iframe src attri CHANGES: Provided a better way of reexporting magrittr::`%>%`. See #597. ->>>>>>> master 3.6.2 -- 24 May 2016 diff --git a/R/add.R b/R/add.R index f692def213..cb0f230440 100644 --- a/R/add.R +++ b/R/add.R @@ -8,7 +8,10 @@ #' NULL %>% plot_ly() %>% add_data(economics) %>% add_trace(x = ~date, y = ~pce) add_data <- function(p, data = NULL) { if (is.null(data)) return(p) - p <- verify_plot(p) + if (!is.plotly(p)) { + stop("Don't know how to add traces to an object of class: ", + class(p), call. = FALSE) + } id <- new_id() p$x$visdat[[id]] <- function() data p$x$cur_data <- id @@ -42,8 +45,8 @@ add_data <- function(p, data = NULL) { #' p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) #' add_trace <- function(p, ..., - color, colors = NULL, symbol, symbols = NULL, - size, data = NULL) { + color, colors = NULL, symbol, symbols = NULL, size, + linetype, linetypes = NULL, data = NULL) { # "native" plotly arguments argz <- list(...) @@ -73,21 +76,29 @@ add_trace <- function(p, ..., p } +#' Add points to a plotly vis +#' #' @export add_points <- function(p, ...) { add_trace(p, type = "scatter", mode = "markers", ...) } +#' Add lines to a plotly vis +#' #' @export add_lines <- function(p, ...) { add_trace(p, type = "scatter", mode = "lines", ...) } +#' Add text to a plotly vis +#' #' @export add_text <- function(p, ...) { add_trace(p, type = "scatter", mode = "text", ...) } +#' Add polygons to a plotly vis +#' #' @export #' @examples #' @@ -105,6 +116,10 @@ add_polygons <- function(p, ...) { add_trace(p, type = "scatter", mode = "lines", fill = "toself", ...) } +#' Add ribbons to a plotly vis +#' +#' Ribbons are a special case of polygons. +#' #' @export add_ribbons <- function(p, ...) { # TODO: add ymin, ymax arguments? @@ -112,38 +127,40 @@ add_ribbons <- function(p, ...) { } -#' @export -#' @examples -#' -#' x <- rnorm(10) -#' plot_ly(x = ~x) %>% -#' add_chull() -add_chull <- function(p, ...) { - stop("not yet implemented") - ch <- chull(x, y = NULL) - # TODO: Should mode='markers+lines'? If so, retrace first points? - add_polygons(...) -} - - -# ------------------------------------------------------------------------ -# Non-trace addition -# ------------------------------------------------------------------------ - -#' @export -add_transform <- function(p, ...) { - stop("not yet implemented") -} - - -#' @export -add_shape <- function(p, ...) { - stop("not yet implemented") -} - -#' @export -add_annotation <- function(p, ...) { - stop("not yet implemented") -} +# #' +# #' +# #' @export +# #' @examples +# #' +# #' x <- rnorm(10) +# #' plot_ly(x = ~x) %>% +# #' add_chull() +# add_chull <- function(p, ...) { +# stop("not yet implemented") +# ch <- chull(x, y = NULL) +# # TODO: Should mode='markers+lines'? If so, retrace first points? +# add_polygons(...) +# } + + +## ------------------------------------------------------------------------ +## Non-trace addition +## ------------------------------------------------------------------------ +# +##' @export +#add_transform <- function(p, ...) { +# stop("not yet implemented") +#} +# +# +##' @export +#add_shape <- function(p, ...) { +# stop("not yet implemented") +#} +# +##' @export +#add_annotation <- function(p, ...) { +# stop("not yet implemented") +#} diff --git a/R/debug.R b/R/debug.R new file mode 100644 index 0000000000..89f81eba9c --- /dev/null +++ b/R/debug.R @@ -0,0 +1,43 @@ +#' Obtain JSON sent to plotly.js +#' +#' This function returns the JSON sent to plotly.js which can be useful for +#' debugging. +#' +#' @param p a plotly or ggplot object. +#' @param ... other options passed onto \code{listviewer::jsonedit} +#' @export +#' @examples +#' +#' plotly_spec(plot_ly()) + +plotly_spec <- function(p = plot_ly(), ...) { + if (system.file(package = "listviewer") == "") { + stop("This function requires the listviewer package:\n", + "install.packages('listviewer')", call. = FALSE) + } + listviewer::jsonedit(to_JSON(plotly_build(p)$x), mode = "form", ...) +} + + +#' Display plot schema +#' +#' @export +#' @examples +#' +#' schema() + +schema <- function() { + listviewer::jsonedit(Schema, mode = "form") +} + +#' Show information about attribute(s) of a given trace type +#' +#' @export +#' @param type a trace type +#' @param attrs attributes for the race type +#' @examples +#' +#' explain_attrs() +explain_attrs <- function(type = "scatter", attrs = c("x", "y")) { + jsonlite::toJSON(verify_attrs(type, attrs), pretty = TRUE) +} diff --git a/R/dev.R b/R/dev.R new file mode 100644 index 0000000000..0ed55ca5f8 --- /dev/null +++ b/R/dev.R @@ -0,0 +1,39 @@ +#' Inspect JSON sent to plotly.js +#' +#' This function is useful for obtaining/viewing/debugging JSON +#' sent to plotly.js. +#' +#' @param p a plotly or ggplot object. +#' @param jsonedit use \code{listviewer::jsonedit} to view the JSON? +#' @param ... other options passed onto \code{listviewer::jsonedit} +#' @export +#' @examples +#' +#' plotly_json(plot_ly()) +#' plotly_json(plot_ly(), F) + +plotly_json <- function(p = plot_ly(), jsonedit = interactive(), ...) { + plotlyJSON <- to_JSON(plotly_build(p)$x, pretty = TRUE) + if (jsonedit) { + if (system.file(package = "listviewer") == "") { + stop("This function requires the listviewer package:\n", + "install.packages('listviewer')", call. = FALSE) + } + listviewer::jsonedit(plotlyJSON, mode = "form", ...) + } else { + plotlyJSON + } +} + +#' Display plotly's plot schema +#' +#' The schema contains valid attributes names, their value type, +#' default values (if any), and min/max values (if applicable). +#' +#' @export +#' @examples +#' schema() + +schema <- function() { + listviewer::jsonedit(Schema, mode = "form") +} diff --git a/R/export.R b/R/export.R index 7bafcc6c3a..300976d71b 100644 --- a/R/export.R +++ b/R/export.R @@ -17,7 +17,7 @@ export <- function(p, file = "plotly.png", ...) { } f <- basename(tempfile('plotly', '.', '.html')) on.exit(unlink(f), add = TRUE) - html <- htmlwidgets::saveWidget(plotly_build(p), f) + html <- htmlwidgets::saveWidget(p, f) webshot::webshot(f, file, ...) } diff --git a/R/helpers.R b/R/helpers.R index bd38322611..5850d53d60 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -1,45 +1,5 @@ -#' Obtain JSON sent to plotly.js -#' -#' This function returns the JSON sent to plotly.js which can be useful for -#' debugging. -#' -#' @param p a plotly or ggplot object. -#' @param attr focus on a particular attribute in the spec. -#' @param as in what format should the spec be printed? -#' @param pretty adds indentation whitespace to JSON output. -#' @export -#' @examples -#' -#' plotly_spec(plot_ly(), "data") - -plotly_spec <- function(p = plot_ly(), attr = NULL, as = c("json", "plain"), pretty = TRUE) { - spec <- plotly_build(p)$x - if (!is.null(attr)) { - spec <- spec[[attr]] - } - if (identical("json", match.arg(as))) { - return(to_JSON(spec, pretty = pretty)) - } - spec -} - -#' Show information about attribute(s) of a given trace type -#' -#' @export -#' @param type a trace type -#' @param attrs attributes for the race type -#' @examples -#' -#' explain_attrs() -explain_attrs <- function(type = "scatter", attrs = c("x", "y")) { - jsonlite::toJSON(verify_attrs(type, attrs), pretty = TRUE) -} - - #' Convert trace types to WebGL #' -#' This function will also build -#' #' @param p a plotly or ggplot object. #' @param warn should a warning be produced if the trace type doesn't have #' a WebGL equivalent? @@ -66,17 +26,3 @@ toWebGL <- function(p, warn = TRUE) { p } - -#' Create a complete empty plotly graph. -#' -#' Useful when used with \link{subplot} -#' -#' @export -plotly_empty <- function(...) { - eaxis <- list( - showticklabels = FALSE, - showgrid = FALSE, - zeroline = FALSE - ) - layout(plot_ly(...), xaxis = eaxis, yaxis = eaxis) -} diff --git a/R/plotly.R b/R/plotly.R index 5db6ea602e..2335182aef 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -14,8 +14,9 @@ #' or a vector of colors to interpolate in hexadecimal "#RRGGBB" format, #' or a color interpolation function like \code{colorRamp()}. #' @param symbol Either a variable name or a (discrete) vector to use for symbol encoding. -#' @param symbols A character vector of symbol types. Possible values: -#' 'dot', 'cross', 'diamond', 'square', 'triangle-down', 'triangle-left', 'triangle-right', 'triangle-up' +#' @param symbols A character vector of symbol types. For possible values, see \link{schema}. +#' @param linetype Either a variable name or a (discrete) vector to use for linetype encoding. +#' @param linetypes A character vector of line types. For possible values, see \link{schema}. #' @param size A variable name or numeric vector to encode the size of markers. #' @param width Width in pixels (optional, defaults to automatic sizing). #' @param height Height in pixels (optional, defaults to automatic sizing). @@ -38,6 +39,7 @@ #' #' # using the color argument #' plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, mode = "markers") +#' # smooth gradient between 5 colors #' plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, #' colors = terrain.colors(5), mode = "markers") #' @@ -47,6 +49,8 @@ #' } #' plot_ly(economics, x = ~unemploy / pop, color = ~decade(date), type = "box") #' +#' plot_ly(economics, x = ~date, y = ~unemploy / pop, linetype = ~decade(date)) +#' #' # sometimes, a data frame isn't fit for the use case... #' # for 3D surface plots, a numeric matrix is more natural #' plot_ly(z = volcano, type = "surface") @@ -55,35 +59,34 @@ #' plot_ly <- function(data = data.frame(), ..., type = NULL, color, colors = NULL, symbol, symbols = NULL, size, + linetype, linetypes = NULL, width = NULL, height = NULL, source = "A") { # "native" plotly arguments - argz <- list(...) + attrs <- list(...) # warn about old arguments that are no longer supported for (i in c("filename", "fileopt", "world_readable")) { - if (is.null(argz[[i]])) next + if (is.null(attrs[[i]])) next warning("Ignoring ", i, ". Use plotly_POST() if you want to post figures to plotly.") - argz[[i]] <- NULL + attrs[[i]] <- NULL } - if (!is.null(argz[["group"]])) { + if (!is.null(attrs[["group"]])) { warning("The group argument has been deprecated. Use group_by() instead.") - argz[["group"]] <- NULL + attrs[["group"]] <- NULL } - if (!is.null(argz[["inherit"]])) { + if (!is.null(attrs[["inherit"]])) { warning("The inherit argument has been deprecated.") - argz[["inherit"]] <- NULL + attrs[["inherit"]] <- NULL } - # verify trace type and it's attributes - argz$type <- verify_type(type) - attrs <- verify_attrs(argz$type, names(argz)) - # tack on "special" arguments - argz$color <- verify_arg(color) - argz$symbol <- verify_arg(symbol) - argz$size <- verify_arg(size) - # TODO: do we really need to verify these? - argz$colors <- colors - argz$symbols <- symbols + attrs$color <- verify_arg(color) + attrs$symbol <- verify_arg(symbol) + attrs$linetype <- verify_arg(linetype) + attrs$size <- verify_arg(size) + + attrs$colors <- colors + attrs$symbols <- symbols + attrs$linetypes <- linetypes # id for tracking attribute mappings and finding the most current data id <- new_id() @@ -92,7 +95,7 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, p <- list( visdat = setNames(list(function() plotlyVisDat), id), cur_data = id, - attrs = setNames(list(argz), id), + attrs = setNames(list(attrs), id), # we always deal with a _list_ of traces and _list_ of layouts # since they can each have different data layout = list( @@ -107,3 +110,18 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, as.widget(p) } + + +#' Create a complete empty plotly graph. +#' +#' Useful when used with \link{subplot} +#' +#' @export +plotly_empty <- function(...) { + eaxis <- list( + showticklabels = FALSE, + showgrid = FALSE, + zeroline = FALSE + ) + layout(plot_ly(...), xaxis = eaxis, yaxis = eaxis) +} diff --git a/R/plotly_build.R b/R/plotly_build.R index a61f620f18..18cedcaa1d 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -42,7 +42,7 @@ plotly_build.plotly <- function(p) { x[lengths(x) > 0] }, p$x$layoutAttrs, names(p$x$layoutAttrs)) - + # get rid of the data -> layout mapping and merge all the layouts # into a single layout (more recent layouts will override older ones) p$x$layoutAttrs <- NULL @@ -72,114 +72,274 @@ plotly_build.plotly <- function(p) { } } - # create an index for splitting the trace into multiple traces - #discreteVars <- compact(list(if (is.discrete(x$color)) x$color, x$symbol)) - #if (length(discreteVars) > 0) { - # idx <- do.call("interaction", discreteVars) - # lvls <- levels(idx) - # - #} - - - # "transforms" for special arguments - # TODO: let plotly.js handle this logic? - # browser() - - + x$type <- verify_type(x$type) x[lengths(x) > 0] - + }, p$x$attrs, names(p$x$attrs)) - # it's possible that somethings, like figures (pulled from a plotly server), + # "transforms" (i.e., apply scaling to) for special arguments + # TODO: should non-formula object names populate titles? + colorTitle <- unlist(lapply(p$x$attrs, "[[", "color"))[[1]] + dats <- mapColor(dats, title = sub("^~", "", deparse2(colorTitle))) + dats <- mapSymbol(dats) + dats <- mapLinetype(dats) + + # traceify by the interaction of discrete variables + traces <- list() + for (i in seq_along(dats)) { + d <- dats[[i]] + params <- list( + if (is.discrete(d[["color"]])) d[["color"]], + d[["symbol"]], + d[["linetype"]] + ) + params <- compact(params) %||% list(NULL) + idx <- do.call("interaction", params) + dats[[i]][["color"]] <- NULL + dats[[i]][["symbol"]] <- NULL + traces <- c(traces, traceify(dats[[i]], idx)) + } + + # it's possible that some things (like figures pulled from a plotly server) # already have "built" data - p$x$data <- c(p$x$data, dats) + p$x$data <- c(p$x$data, traces) # get rid of data -> vis mapping stuff p$x[c("visdat", "cur_data", "attrs")] <- NULL + if (has_legend(p) && has_colorbar(p)) { + # shrink the colorbar + idx <- which(vapply(p$x$data, function(x) inherits(x, "plotly_colorbar"), logical(1))) + p$x$data[[idx]]$marker$colorbar <- modifyList( + p$x$data[[idx]]$marker$colorbar %||% list(), + list(len = 1/2, lenmode = "fraction", y = 1, yanchor = "top") + ) + p$x$layout$legend <- modifyList( + p$x$layout$legend %||% list(), + list(y = 1/2, yanchor = "top") + ) + } + # traces can't have names p$x$data <- setNames(p$x$data, NULL) - p + # verify plot attributes are legal according to the plotly.js spec + # (and box attributes data_array attributes where appropriate) + verify_plot(p) } -# returns a _list of traces_. -colorize <- function(dat, title = "") { - cols <- dat[["color"]] %||% dat[["z"]] - if (is.numeric(cols)) { - # http://rud.is/b/2015/07/20/using-the-new-viridis-colormap-in-r-thanks-to-simon-garnier/ - colors <- dat[["colors"]] %||% viridisLite::viridis(10) - cols <- as.vector(cols) - rng <- range(cols, na.rm = TRUE) - x <- seq(min(rng), max(rng), length.out = 10) - colz <- scales::col_numeric(colors, rng, na.color = "transparent")(x) - df <- if (length(cols) > 1) data.frame(scales::rescale(x), colz) - else data.frame(c(0, 1), rep(colz, 2)) - col_list <- list( - colorbar = list(title = as.character(title)), - colorscale = setNames(df, NULL) +# appends a new (empty) trace to generate (plot-wide) colorbar/colorscale +mapColor <- function(traces, title = "", na.color = "transparent") { + color <- lapply(traces, "[[", "color") + nColors <- lengths(color) + # if no "top-level" color is present, return traces untouched + if (all(nColors == 0)) { + return(traces) + } + # color/colorscale/colorbar attribute placement depends on trace type and marker mode + types <- vapply(traces, function(tr) tr$type, character(1)) + modes <- vapply(traces, function(tr) { + tr$mode %||% if (any(lengths(tr) > 20)) "lines" else "markers+lines" + }, character(1)) + hasMarker <- has_marker(types, modes) + hasLine <- has_line(types, modes) + hasText <- has_text(types, modes) + hasZ <- !grepl("scatter", types) & + any(vapply(traces, function(tr) !is.null(tr$z), logical(1))) + + isNumeric <- vapply(color, is.numeric, logical(1)) + colors <- lapply(traces, "[[", "colors") + + if (any(isNumeric)) { + palette <- compact(colors[isNumeric]) %||% viridisLite::viridis(10) + if (is.list(palette) && length(palette) > 1) { + stop("Multiple numeric color palettes specified (via the colors argument).\n", + "When using the color/colors arguments, only one palette is allowed.", + call. = FALSE) + } + # TODO: use ggstat::frange() when it's on CRAN? + allColor <- unlist(color[isNumeric]) + rng <- range(allColor, na.rm = TRUE) + colScale <- scales::col_numeric(palette, rng, na.color = na.color) + # generate the colorscale to be shared across traces + vals <- if (diff(rng) > 0) as.numeric(quantile(allColor)) else c(0, 1) + colorScale <- matrix(c(scales::rescale(vals), colScale(vals)), ncol = 2) + colorObj <- list( + colorbar = list(title = as.character(title), ticklen = 2), + cmin = rng[1], + cmax = rng[2], + colorscale = colorScale, + showscale = FALSE ) - # scatter-like traces can have both line and marker objects - if (grepl("scatter", dat[["type"]] %||% "scatter")) { - col_list$color <- cols - dat[["marker"]] <- modifyList(col_list, dat[["marker"]] %||% list()) - #mode <- dat[["mode"]] %||% "markers+lines" - # can't have a colorscale for both markers and lines??? - #dat[["line"]] <- modifyList(col_list, dat[["line"]] %||% list()) - } else { - dat <- c(dat, col_list) + for (i in which(isNumeric)) { + colorObj$color <- color[[i]] + if (hasLine[[i]]) { + traces[[i]]$line <- modifyList(traces[[i]]$line %||% list(), colorObj) + } + if (hasMarker[[i]]) { + traces[[i]]$marker <- modifyList(traces[[i]]$marker %||% list(), colorObj) + } + if (hasZ[[i]]) { + traces[[i]] <- modifyList(traces[[i]] %||% list(), colorObj) + } + if (hasText[[i]]) { + warning("Numeric color variables cannot (yet) be mapped to text.\n", + "Feel free to make a feature request \n", + "https://github.com/plotly/plotly.js", call. = FALSE) + } } - dat <- list(dat) - } else { # discrete color scale - lvls <- unique(cols) + # add an "empty" trace with the colorbar + colorObj$color <- rng + colorObj$showscale <- TRUE + colorBarTrace <- list( + x = range(unlist(lapply(traces, "[[", "x")), na.rm = TRUE), + y = range(unlist(lapply(traces, "[[", "y")), na.rm = TRUE), + type = "scatter", + mode = "markers", + opacity = 0, + hoverinfo = "none", + showlegend = FALSE, + marker = colorObj + ) + traces[[length(traces) + 1]] <- structure(colorBarTrace, class = "plotly_colorbar") + } + + if (any(!isNumeric)) { + allColor <- unlist(color[!isNumeric]) + lvls <- unique(allColor) N <- length(lvls) - default <- if (is.ordered(cols)) viridisLite::viridis(N) - else RColorBrewer::brewer.pal(N, "Set2") - colors <- dat[["colors"]] %||% default - colz <- scales::col_factor(colors, levels = lvls, na.color = "transparent")(lvls) - dat <- traceify(dat, "color") - dat <- Map(function(x, y) { x[["marker"]] <- c(x[["marker"]], list(color = y)); x }, - dat, colz) - } - dat <- lapply(dat, function(x) { x$color <- NULL; x$colors <- NULL; x }) - dat + palette <- compact(colors[!isNumeric]) %||% + if (is.ordered(allColor)) viridisLite::viridis(N) else RColorBrewer::brewer.pal(N, "Set2") + if (is.list(palette) && length(palette) > 1) { + stop("Multiple numeric color palettes specified (via the colors argument).\n", + "When using the color/colors arguments, only one palette is allowed.", + call. = FALSE) + } + colScale <- scales::col_factor(palette, levels = lvls, na.color = na.color) + for (i in which(!isNumeric)) { + if (hasLine[[i]]) { + traces[[i]]$line$color <- colScale(color[[i]]) + } + if (hasMarker[[i]]) { + traces[[i]]$marker$color <- colScale(color[[i]]) + } + if (hasText[[i]]) { + traces[[i]]$textfont$color <- colScale(color[[i]]) + } + + } + } + + traces } -symbolize <- function(dat) { - # symbols really only make sense when markers are in the mode, right? - dat$mode <- grepl("markers", dat$mode %||% "markers") - dat <- traceify(dat, "symbol") - dat <- lapply(dat, function(x) { x$symbol <- NULL; x }) - N <- length(dat) - if (N > 8) warning("Plotly supports 8 different symbols, but you have ", N, " levels!") - symbols <- c('dot', 'cross', 'diamond', 'square', 'triangle-down', 'triangle-left', 'triangle-right', 'triangle-up') - sym <- dat[[1]][["symbols"]][seq_len(N)] %||% symbols[seq_len(N)] - dat <- Map(function(x, y) { x$marker$symbol <- y; x }, dat, sym) - dat +mapSymbol <- function(traces) { + symbolList <- lapply(traces, "[[", "symbol") + nSymbols <- lengths(symbolList) + # if no "top-level" symbol is present, return traces untouched + if (all(nSymbols == 0)) { + return(traces) + } + symbol <- unlist(compact(symbolList)) + if (!is.null(symbol) && !is.discrete(symbol)) { + warning("Coercing the symbol variable to a factor since\n", + "symbols only make sense for discrete variables", call. = FALSE) + symbol <- as.factor(symbol) + } + N <- length(unique(symbol)) + if (N > 8) { + warning("You've mapped a variable with ", N, " different levels to symbol.\n", + "It's very difficult to perceive more than 8 different symbols\n", + "in a single plot.") + } + # symbol values are duplicated (there is a valid numeric and character string for each symbol) + validSymbols <- as.character(Schema$traces$scatter$attributes$marker$symbol$values) + symbols <- unique(unlist(lapply(traces, "[[", "symbols"))) %||% + grep("[0-9]", validSymbols, invert = TRUE, value = TRUE) + illegalSymbols <- setdiff(symbols, validSymbols) + if (length(illegalSymbols)) { + stop("The following are not valid symbol codes:\n", + paste(illegalSymbols, collapse = ", "), + "Valid symbols include:\n'", + paste(validSymbols, collapse = "', '"), + call. = FALSE) + } + palette <- setNames(symbols[seq_len(N)], unique(symbol)) + for (i in which(nSymbols > 0)) { + traces[[i]]$marker$symbol <- as.character(palette[symbolList[[i]]]) + # ensure the mode is set so that the symbol is relevant + if (!grepl("markers", traces[[i]]$mode %||% "")) { + message("Adding markers to mode; otherwise symbol would have no effect.") + traces[[i]]$mode <- paste0(traces[[i]]$mode, "+markers") + } + } + traces } + + +mapLinetype <- function(traces) { + linetypeList <- lapply(traces, "[[", "linetype") + nLinetypes <- lengths(linetypeList) + # if no "top-level" linetype is present, return traces untouched + if (all(nLinetypes == 0)) { + return(traces) + } + linetype <- unlist(compact(linetypeList)) + if (!is.null(linetype) && !is.discrete(linetype)) { + warning("Coercing the linetype variable to a factor since\n", + "linetype only make sense for discrete variables", call. = FALSE) + linetype <- as.factor(linetype) + } + N <- length(unique(linetype)) + validLinetypes <- as.character( + Schema$traces$scatter$attributes$line$dash$values + ) + if (N > length(validLinetypes)) { + warning("linetype has ", N, " levels.\n", "plotly.js only has ", + length(validLinetypes), " different line types", call. = TRUE) + } + linetypes <- unique(unlist(lapply(traces, "[[", "linetypes"))) %||% validLinetypes + illegalLinetypes <- setdiff(linetypes, validLinetypes) + if (length(illegalLinetypes)) { + stop("The following are not valid symbol codes:\n'", + paste(illegalLinetypes, collapse = "', '"), + "Valid linetypes include:\n'", + paste(validLinetypes, collapse = "', '"), + call. = FALSE) + } + palette <- setNames(linetypes[seq_len(N)], unique(linetype)) + for (i in which(nLinetypes > 0)) { + traces[[i]][["line"]][["dash"]] <- as.character(palette[linetypeList[[i]]]) + # ensure the mode is set so that the linetype is relevant + if (!grepl("lines", traces[[i]]$mode %||% "")) { + message("Adding lines to mode; otherwise linetype would have no effect.") + traces[[i]]$mode <- paste0(traces[[i]]$mode, "+lines") + } + + } + traces +} + + # break up a single trace into multiple traces according to values stored # a particular key name -traceify <- function(dat, nm = "color") { - x <- dat[[nm]] - if (is.null(x)) { - return(list(dat)) - } else { - # the order of lvls determines the order in which traces are drawn - # for ordered factors at least, it makes sense to draw the highest level first - # since that _should_ be the darkest color in a sequential pallette - lvls <- if (is.factor(x)) rev(levels(x)) else unique(x) - n <- length(x) - # recursively search for a non-list of appropriate length (if it is, subset it) - recurse <- function(z, n, idx) { - if (is.list(z)) lapply(z, recurse, n, idx) else if (length(z) == n) z[idx] else z - } - new_dat <- list() - for (j in seq_along(lvls)) { - new_dat[[j]] <- lapply(dat, function(y) recurse(y, n, x %in% lvls[j])) - new_dat[[j]]$name <- lvls[j] - } - return(new_dat) +traceify <- function(dat, x = NULL) { + if (length(x) == 0) return(list(dat)) + # the order of lvls determines the order in which traces are drawn + # for ordered factors at least, it makes sense to draw the highest level first + # since that _should_ be the darkest color in a sequential pallette + lvls <- if (is.factor(x)) rev(levels(x)) else unique(x) + n <- length(x) + # recursively search for a non-list of appropriate length (if it is, subset it) + recurse <- function(z, n, idx) { + if (is.list(z)) lapply(z, recurse, n, idx) else if (length(z) == n) uniq(z[idx]) else z + } + new_dat <- list() + for (j in seq_along(lvls)) { + new_dat[[j]] <- lapply(dat, function(y) recurse(y, n, x %in% lvls[j])) + new_dat[[j]]$name <- lvls[j] } + return(new_dat) } diff --git a/R/sysdata.rda b/R/sysdata.rda index 5cc5e1bd9eee04290cda22b984b68078659b63d8..111c4cdd0984d0c49f4d5deb856257abbfb86ddf 100644 GIT binary patch literal 9730 zcmV+dCjHq$T4*^jL0KkKS@Tr&(gD(q|NsC0|NsC0|Ns9l|9}7g|Nde^NU%U4LSV@z zNB}}QM8V)XT=H>n@1(5{cIDT-y60L@003y(J{3r z#%jQ;-ci%RO1s(J)2`bzor9`3ZCKt;hj8g_ajgR;5cjj!r32RX4EJ-O33E1y%mjhZ z;oZtKrYTFdc^;0QgRQYZ?>D>GJ8nD-5mF|Co*{(LF*Fg8iHVXjdYXEMn2$9HiR9Gv z7>`hCfS#ku7@7?LGyobg1X2XhK{Pam2pVZJO{CG9iTY1e)5(%%DAAA}pfu5=KzfEi zXld#+27mwr8e%lU444x}35ljA0Wg{{2*4&L6Gngy7(sv`kTlaFk*19d5TZ#Yl+83# z^-b!UdOazo8iAt;p^2tI00003K=m3lG#NAi00004)gnSnrcFI2l-?;HsXV8Y)5$&R zk&t?ZfY1#905kvq00007r~otor6fTB5CpKe>{Ao_lZlBYrlgWd z#L+v`Q~DDVq{QNCYGQCt^h{D|G@@B5ke5oOQt3pvkeCTUDw0Vg3H^yw`)PEtRVbH9 zq|>P;p88QFpJ6DT!e*GI(*%-HD4Nrp997ROBy~84l#|H8LL9u1UIoQDvKKon-7L!f=zWorLYD3W)DrwqjC!3ZruW5NTeT6~?iC{`*nv=>`;HBi_GgnDY{z|0 z{Nseos5L;AXlaS{&5ZH`1kF9F8i*^-nVI}QwSc+NJ5YCd*+ViVpGGEPja0@dh)N6) zhT)L7A{aP{ju9qWu*x2aFFIv{mSJXRia1=9I7(Sq8C#^UF|>uL4;^yq`^lIfH-|%o zOWWYtKu}&pg2wc@iv&ZtTz)U%{vOeKdX??+NxFlps~U_kks=caLX;Ar0RSXQ7D`|V zgPBM)IG7FtzZ=v2Zyr8T4+wk?HNQ*hwLMYS9y!rhO&Gh{H6j>5$iRr0Ay#lOTo95W zNm5+$NNEOSux+bL7Aa&(KqzJbD}ZB|dU~mcagt$?F-s7^02GRQWCZnnTm*4UrikCz zEK#LzyHYgMQfa23=3|+Fm|=;A6*E{aWlYv#g+yixg625HV4psJ50}sOp!0zR=eWt? zQ?r8hI?2s#OhAJOGYl3{r5IWYDgG|K2Z3}b;nbv&5k``jMHL5ih*b?l6jJv?l7xW- zLJ0#vQgKW%E(?cBmX}9C=78Xw1(iD?mqVJ9Fr>f}C`1f1RFnZQCvJ>WB^{9is%6%eC`dpMvxFjK z?=IXZDpN>p1oXlt-Q2_t=5`B_X`CS@ z6qrI9-Wu(;7G=#h8x7%VY*d#cgHaI2R~Kk7u451eBXhVF!Rk+Nbz{A(hy%5_CvU-$ zB|IJ#sT7YURE`k-lvL|lqHfHQdVJwli^4o7W-CCu9;|J z1s{y3>6yYrpzR>|0;GRWDI7nCOS8vcyvQ%1Ew7$wMf<{_0^Il%t_6Y zV>=Ek%s8!C-4Vk-bE72nZbAS))C}oyRe&;}I1p4%N-rQ-1NU(Lzo}yKMvz}~FR-6v zK%9lm%sf~DhQS$`V+^6~&|L*pEQFNaZdaz0y7q4?3wG=nMc5E9)hNj_2$K*zh?;7g zmBda)ZtMgUrkjdr3CTdJ2irzE$L@FYPUK%M)Dj?+B};=suaJZz3Z+4yBoPQ03P}R6 zKF`xE&H9pLy-ujpab)#XoJQ$&+GW#nX}%rot=MvEx7v;sX0wM6a)S%_&N$kiGv#;+ z6WS?mt5mGRAWTBhaDoIOn1yKd3v}JSjITNS9?D%%qXr-rET4ZD@YymsMX0z7@x_DK z*QOgumDHNW%_jnxe)?yT!>dAN@Y}aHX@@4XK)R0%A~1H|bKCgSnf-7Qz`SoPG+!1S zGo_lrqXt=%3}uvN49c&Rl_*YF0$+;zjxe5`Stdp;ug{B7ZZ6(D_g~%IqOv$W4qjb3 z^QXB;9&1t1Ds7GwhyfoFHE;jClH2SC_|6f+pu#E@ZR zl0d>p#2q&mWKN*U9YD#019^-u78jMFYKB>(fsCORN*lQBE=IB;xh9%q;MrkL0iJ~4 zCc@fSFiY$oDU1PG3kF3UTxGcf%*e=c5oMVvv7OZ7PGf*5RN97-vJ)a2G87=o ze4Gn*^tjw@9V>BZ+m3C%JeQZrc%?yVK&g64AVfq*WjV^L-0jxNa}QA89;&t{B8O4n z`{HJ}0k?rQig-g6GLcbfJ0L4DM~U&IIL{yt zpdj2^yuVXh3u)5v=+^JX;p90!rh57`;J@8TyXW9>8K-CyQJ}nBP-x1&my>;REAeok z9iTS>1jQ~WfGf*@P@B6}hu+JAItoX9sLP2^&>V)7`|ESGshbBD*@% zY|up|kPfZ(sBzGV3mAkNLAFX&m^A5|>6mY$>{ZWg+@#g zP%{wEG>1r5^`b(Mo&AL!^bKW_NeiYtlQ5)?dAF%Xwhgs@Ad>P!YuEWv9fayMTx zM%!owGP=sfqG^>Wqkch?3&vqX-qcJB~3*237!_9 z;@!-IpqM5sX$eFO3=7U+UZG&ah*gB^qz=DT*D zyrKAev=;Y4m+u=?d{mVb^{63Cks_D6tcCvdl-=tz0M!*z{&wxv2wwa|r_qH;6P=JE zV+sQHrF5jhtvO7_Zzk&9h}=lTfTe<*Ok^T-tV9h0NLU5}7-E5$0vQG%3{}FD5HQRD z#FR;Z!qW_3Qb`gC5|R)zF~Y%mz)>-TWRis`0N_4pLY|0}g~m{DTvHrSs*z5#bxl%8 zTr&}6-U-&O1HfcTb_8e=g_r_Rg+e7#kWkaCcoB{WPT+1Ch)K~_>|IGihKZza6>AEK zE_jI&`;l1`Dqjv(rgLg-tq^M@jA+Akykv`Oc{E(|xBWU_X@mv12VE0KZVAo6MM&_N z;YkZDC^{gNshG+XIC3;3pb{0?z~rf`8k!(NU<{hz;E^U#aKlBm6Dt%ntfXOxwS=X% znHt|F%F03UPl|NSiaMhbxhxizDj9+;EGAAeVq!wFvPlUF!bu4U zD+z%lAqj$DxUGqZrb1##l2DkENg&A}Ncocg~z zy=MI<4r%lk^G%9f8B+ABO`Ad#YEUv=;wnN4#j$j%$UdmNvq_gY-gdbkB&rrn2cotm z-jgp1hChVK)4!xdL<9$R<`GNCf)SLx38!KXT~)M?bsTwjUu?8D3&MS71@kb>U9||& zi8StII?11YUel*Gu;!l5-quHhFuP_Ki0gepW6f`FT3)rLb0)10O+w=?Sf-s&R_Xfq zyei|GJ9fZwBiE|iu@q&&GIYmmdSY$i>i&?pyn^{fzQH+?1(U#@C>tizvV4>9&J&Vx zPu)$EqGafwROL3DXH4_WPp)EovlAvz$&)4o?3prlOqnud2%Ob34oImM1;{aOcH5i$vWnzT*=!q zWW`;b1pX$(r;S49TfHIEw!#`16}}q;RnaPEGXo0I82Zu`6g@Xk3@VV&`4!EiX1NZ}zmg zKV94+O*ilIP$dto1#2e) zJo{AY>~q>}R^A^wqkZ$cJ2A}<^>8KnODQedO-;0zl~ZXv^x91%+DwG(r6jPI3b$)7 za|)9%MAFG(_iua2<@0@ad32XhDKSJM6Sd@YMT|^8cXt?*MIa{y$;W)8Wm6R91&X`= z%)(ey9UO4XQ4Fcc!1$H^71`G<3VZ=?f4hkBzk9F+R19BCf&Z4%?%=D@3ewCMSX=RB zCvxL`z?6thp=ewjl0=La0GcIXH&A`_v)}x0=F$DH_Lj-;re!&&a$P<$da312sbo{~ zeFgURAR**4)p}q{0_o}sUtZh5?rO)69Mqv+3V=kJxX6V8l*SxwdTET9voK%4slmlI zDYCpV8vhgN^tz(m&VE^mlM^N;OqeFoaod6*W__N)*`k#qh43r(5LG~riF6hJ4cRBu zRGC*t`;+r(5D}cP9RcSBAn|HIYF6rl<@nu*ZJpL_tsqwJ~ zZ1104v(HS(oe@J>U1(F`R$?9RQ~vh*H_X9|!;9HGhRz$bo$&H)-&MU>zlCC-W5Iu1 zo>Fz5^bm?hKSq`qwQVx4v z2Lx)rdwLh9;9Q`tZi63pTw)-r<^eo@4lw#LX6_5(du;IZEM2eWtw>qL^;MZiIdswv z;(Rck5xOQl}(T;!Qt zCFCSCP@My=a~7P{W-@SO;3>QUPcLW?;{=817NQj)HSd{D*KePkZl`J1Xh@mFM{dHK zfW_a?c8gU#^!ADnuI4`#@>d7Dmh50F@&T6}WtoTte( zH6@aWDN#rxo?*=!p>icKsa^=MwKs67*`>!Ut##b3mA?go=;^376}@m( zRH;K`#6oYVSS(ON%3zRe5yKScdEq3~)RUvYKyf!%cu5LKS(8+>om4ATLlq`Sz@(J1 zz*cl~#X9*-EM?N#cpFn}M$fw~PID$qnK;f9Q=HsQ(;~@}CMG6Kn3*zm%}q__rwOUT zZqX#1P9`T4h$D$4pBLc#H#`3O;p%C_`Z(6sH0-OKdvYBq2bVW?yzG_FkxUdj(x?}g z$BBYT;ATPd5dp#+<;j4`ksEH!W7WoESyd+H7iJslM@D?J(H#fx#wt0~^kOGm$u3Gv z?E8E>c)hc;I$b@}XKGBku&$4adui>Ooyxl)u1dw%4GUBcm~kV$G9Q_$;C8WE)z2)^ z-miN~(C8+^Wge=xQ=JNQR~yHVH;y`J)1dozJWzL%l8~~5N<$103L`=yOd>fVo%j@b z9zjf8e7FgA-qX(gG-eES4_89ot~l1!6#T)YZFuqda*b=vJQU%u!<)lsY?v_MEIE|E zkV4x?1(pPo)qx5`@p%9&3?T^uBtW2s@Y7UIX}1u|0+})iTUsRt10!g-y_Sad+yZ1O zWtP$nEhJqp0!+}+nv_orDELIpDGHigIYC_BK0!|zO^!?v)GyDZHgtP`?)d+8dUU*u z4$EWq&m#K2F22tAtp{iYWt3u=rcw8&uL~n{U-swV6_h7)J!O=4SCa1Z zr-^M(ZBBJwJd=4X{)00@x7_(-=3!HewiR2_+uNX=Rb=aBSiPz96W+dO!WnY)Jnu%| z3J;z?LZ186@?uY~nir8w$P^<6Fl3m@mQ{>lo_#%g9|`52Dd$Q6ac~A2NjwSYC!I1$ zCMoAhq|#|Q`n#RQIDNei>+&uF?&@2(KBw7EK2HHYmNex$XECZgu_qzSsp<3n=ga!% zuP5$)hur!fLSFaUnfjy?J)95B$twxFcVCG?U<4V683*Nj=B^Lh#ImdvHz|M{QZQQv zn!)wM@k@P^gY<>+&WRsRMXI>9aATW!2PEj9d6V)s9M(NA+Ro=xZi}x68wr%?E^G5k zx3!Y5$@u?EsW+8A86sJVWXYGypz`jYxOP=1Y&@TREmczBc+GyMy74TOM34;s&i1I% zRLF^B0e6|Slqrgm3UV%%^@c;prg9K_3c;cSBg2@Q4Sh^=&fMExduwVo0ybO7SHQ z!s>*9PJTfI3nEXYS@s33YYW;oCLXXHSLc+IvW2G&EU+jUKVK6 zn=8HDMAYo5B`#2e?qfweD)z{On8i2o_k|=(=^@Bj z^53(d2=jKs0l2S0<4Ym~F&Xfjs>#7JZBTE%_E;ke5r!fJE@-%zC?gX?hHOwRhG@Qa zn(Q%DlZX@poVB7>R(d4gbINqSx$i`<5Cb&DSWAflNmvpUg!258&v{f6&F0HJoMHsd zE&%W2*U&KC3F&Dq%WouRBTbAdZL7#`srZS|qHOD!3uMfOFs7seO64ovPg`=EQ`t|Y zkZ7%pDVS8O4uv7i#*U5gwIfa2qZNg-@1%S^zCl;dJYOB-PM?#@;_^<{c49}Nsb~*y z793Epb@9BM;+h7Qi!m~rh=wr%8S9+{(17Sgi8(SY*IZdnI9V&75EaO%w+o~(#TGLz z&KRS`z3wdeWM@pxZ4Y7UdcW=Nq;X5`-4)Gt$X`hKeR`Xz>z;}DC*_;InMY7-#^*G( z@BNv6&*7uKafjJjq8xH7+ekfOpzG@*jw^mpamF!UVDtPc_BUd#`w-4rCbC<=*GhD; zROBk`Da_x1aMjTcZ7x%bYU7sl^u=TGxtcD@LAA2wRe9oiCx0(|O0{Y(#Y453WHSRS z$Y8d$qMa~hhOjk?J1z@raq{=UUnSs4>%Q|YE|;<74!mz@mhE+5m!pTX(yP;PakW;v z)n1Z=d<-16XQ^;+7j!NW3bfMDYbe5cS+TUWLlr*qzb*Jh(3wt9JU%@9Mwo~wxxxUV zNQEUGle6KyMSjj8dZ(&&&(}IGnDrw%PfngL!uir;t%stz@-GK(l~w5C>D6w@=2MLy z0-p=_?+e=KTwae)4)r@J!GLA>_ES=*a+r+>a%ok!nXSZSVrZ2jNLNeX2DquMCpS`Q zQP_we%xGEw!Ak)$zzj*#4bml?g9QyVu^k8lAvQtTAfSXLnUM$#g~gojM&kLC+wM&+ zfWJ4VQ=w;3SHGh0_YE=dh}GT|Oj1kTPT|OA+|o!epeY?MlvI6K9USX8}jT2sbTJ-ZCin`_MeN`5cpb^g2}6@C2iT7 zq?gdy!J=&qz^)9RPRZo_S;5sN>qQx+b<8x?speixp0bIxS-%&sI^gMf z?+fAJa$V)w3Vy~}F;Vi1X{nXd)X|LAwW&rGgzK`nAmBgrrrZ|VYAl*DJQ$giKWZ<) zonES+32UnEqgwLhJ{_3I?7-EQHET4~`Ll|+oZQ>1iIm0^oSB#gjYCZ_SEA#X)2n!n!*wn-<0uh-6yj@dw`%qHg(u(^XL>O;YZaE< z2y*d5+NWP)u|%^b&V9pbvI3w1C|*e9O=$}792u$J(J9g|-5eo8bO4sD@t+qmcDPN3 z_ko9v;5joRQQ1wWs$hd7#1r<-uS)&>#RNtLH) z=cCJ8nsX%<bdGZMOLCGuh=`dCW|F*TDpK1BT!^+^&$ zo}F~21|dkfE-u8V!Gai%xevdIAA10=EN^tbW#q0a|@~VD`#qaj;dwt&jIWc$F zWIqh2-9F+6+dg@dCXhKbyAk*8vfOPq7v7~S*;R^JNrHm`yCUB^qO8q=zfRlz1C))f zO6MEX@AKq?q;kn=2Hx%H)r{(JQ);oIYon`vqT*yYP1vqQ)0}oA9_DRFLC|P*fgqt^ z#-h$;fPgB)s7yV-Q!YeZpCjdw0~t6m9aE}g$&)5bpQrXWbS*PYEeh=g3x-a8;)>56PV7wW);GQpQ_o z#PRoLZ0JWe9}XAM7r{(VXVKS&XURTE#5(ZGW6530cVEBax_5q}@W9h4Yt5u@g7V~B zcxv)%i}sD4G`Zh}UXpYi`Ug&%HW$(^YMy03I-h(zbvGBOZZ0DA*G1bFMZ1PDtfPvb zLYSs0(5F;f6VdH?yYtRjD`oGmUmO+YF`0~Egf1o|dv$zCb|q}!mCl!yk-F)&>X$*1 zzJ_eM!{ege=4tp5c_)zUI{MkwGoh=>TAe1m9t<6>)b;juQ&i~ee!g*b^dpS;r{S4D zVr2b^lX<+}Z#{F_KH2uot*x!Epj_8|dyAszx-N@rYiny~RNiFXWZq=;sq)jdk?6__ z{#UnUJbm8ZXuRL^98U!eqs{$3G zKq9Mpqgyj0JeOIscV4i8pcd&vR_rqfeNlP9piZ^8xGGG*C+rpgzL%25ZFCfYzeD1%~or zOSA2JU9U!~LgoS!9+esps>t{kMA2Tf@T4bH`9~*kA0-^srp}tCU5o}c{L0Otwu)_5 zQXC$*cqs6_6P+M>QVywa2RX19smxF}O%TwIkXSg9WhRjD@i%4}Rj5XW3Kb?mHp^DV zrdeKE+VP$+~fvA*|Q9X3}Q_W5aQ%b3}n`wNNlct)9beSpZCNgHHca`8)=e6OOl6n&m{-7b> z@E!BQ8E9RlM5>gM%3LRl%pyy!m-qOqB?B(XQA#OrmQ#L|Qt2$Eq`^vwf|iox6uK~d z=#KC`@Q^5_!bta^)JkblBuZ&9E>dDA6aH7h9aaDKDvZcE&QnA-#XrH~KgnM7h@Y&W QPyfZ-kxmpOJk>pPfWBie*#H0l literal 6381 zcmW-lcQ_mB7ss`|y}d@;du!8iTf{D6)$VPt9nvC+m_=g5s$C)64irI&gv4rXiE)Lb zwp%-9jZnLk+M|e(qCfq8&U2n~&hvf$dEdXz_kCdFuA%f79AF7Au&}E=2g#58amLB? zkF)yc>Ca*N0mpsC`+wfQ{~y4Jh>Y1`A(4d}wyL_~S+C+q{1Q{!(!tzAsHR1Dl}lPdpqsx5~lMbpeo_V343z zl)v|nw>i!@uBA$`6rqFw3a4W$<~p!c#WJfLIdtBg6QQmt*jJZ2>`7Y%F#^K&G(8yO zHWe5h1rgOVBsHo};U#S&Gu~>XjH2zk6i?5nK7Z@Fa?_O68hd1X{(EykVWH%qB=383qgdwDaPLv`AADT}UicID+!o1Yt^zh( zhUdeB2>w1k$~InD=IaZ44GZ$qT))S)_a~A?O}wORi*2p+Z2w95Txk6$F+9;|?)-c{ z^y~6eiT5MD@O2C|2;+#e9ghrIx~cT?FVt2whd?e{Wq zDUld8@G2-v@*qv0))%aR_XsYvu7}E5SNf;T>NRQsh8wk(G{#lc?@wQ-J&qgr=HLsX zjBtI^M~4$^^sWcue>l1=Zi}tAy6s0+_OVZ+LUX^PA@kp&Fl8BHUk9R9wkcS^lbe6o z*-ejWp2jpiT|1urFke1lzGc9l94^VbNY~y>7J{d(S*m_Ec{=OPbawmBd)5^?LMutHy$|l30UKgR> zcIPIAo+FU*4H#0%zK=!F?Lt;bJdf*rw)zR#AP0AKUMlcZ2DmErRtXBx;<}z-i=u#@ zfur#Ddr$2E3+;X?eKwC>IrI2bQ;0mK08?ciAj7+~3uQ)CjRy8wM#@!*dW&uZj(%TY zWUP>tFYpu6qp6eO3sdSv!gcdcl?8n9bgC&=x8lFhuan-ckL#$SRQdO^c3u<NPhuuk7_X#>Rh4iK@GBHiHw?9)+N<#wTIX4gszMG zU6G-gj4CWZ&sE*l^_^wY*iB`aTY3z7#8%I7qLy1U=WaxxjA_>9BnZGUK;&udhiM6#ihTf^riQ8J*gwGItwfuW@uL>=f9sjkFXy>~BxRYYe ziiE2zE)Du;`ar&1{e^VNR?{_j?9KReGqVWYP_Oo20za_m;jYA0$C_N5LTP_vz}zls zl%E8A=*dK_>=?R+4K~e8><9;1xi`e`HY$~_Ge1rY4SP+x7Je6nRI3*jjssM123Ajc zY0s75JW!(^&)dbwGO5wWNNRPNI8(9Ade|!-HBMG7gv9;VreWCa8z zwcA&8w$gW9U6iz#yEZyu8+7L&C4zN_vRp6md3s(HLb(;1p)yCX%i8kRxE`=D(nsoU z52YO~Fu(;n4low)IQO#y~v){LF+rJqaeMNX{z8|`!3v)C^j8NN;i!(%$zd=ft z{p2AHL!&8g+w?D~r+NLPwC6eI5(A|@F=h_5mWvCv>$8!nHgM5IzeZ?}X-UAM?<(sa zjO%Ma#=^og|1nLZdghLIw!PC(259!OIfyt>3eEkBv_|YP`eHjEU&?qZzr0UE%!h~V zFPB1h>E??b%H`@o?8B^T#s?hkVxB}KMBCKjAT3R1BO@(WQ@gCpjpElXYG0GpP@N$c zpKV-=7mViZW|$u5lZ_4-d{{ny$9~0IC+XuUB}!JZ$AbOi_YLc%FSVyUN-RAm{NypL zi}KdVA6htAGeeTY+h7Giz+UH8X(9ocjFpdvCKn`QNxcSef&@ObNG17-miLl_~TkipHzw4F4Ap0p!b+n0yKhOJP+!euatZs)-^@XWK9B5Y)Gl2fI>i}DiF~{Mc8y#SsKU2 z2`d5J@v_y$LX1}*Ag)rvcm16$rJv*K+#{o`x%OH>d>_CsEF|tcO5pIMf&PBY`tMPdPAcqT&_oEHQG6V)ASV3vE2*kGJ)N`u$*-jABFG=zT z52}I5h!q{n%nAQ2w^>y^&e*kdA}|_6RFn*7;F=H&oTLh?A7}YNTT;5ee7s~_qd$P; zZ|*^T2Fm7b3CJ+FEZrt$^X5-esUhYo<64sbKgAGG)^Oeb#Z6Myu;eQSjz5_9yBTk? z_Rs#gy16AUfcJ$nqK)yjeoUVnXgB)I(C5VO@Kz-msA<|5J`N*RpSo;2p6Wzk=OeGh zpK!?=VY-`NT)WeHTj~lL4#<6GQ6Q23HzC==!W5i;1Ww&9SWQ29h8MscO^KMroj9W$ z9S4kMS%n>G$o3Q-S93X_<HyrrQ;4 z+Kt5>!a5pReS%Zk?mC3AMIm}|`*M5$i+@UCA!P{_Z-vorZ~0DNIn6qGx$O1G)LCtKbqA@v+ zk=Q{er~k;mI%!j0g2W(ibnRVhVnlq40IpL;4x&Cc69_y>>fw#S#z7AHl%_=Y#A-vj zmRD~FSSNs{04xhmz#a#P(IfrS`p`4TtEdJ@wmo^%D%4sy7Hp;!p=9IqPFbR#PV3kQgq((}zrVKzCf zP|ZHboGt@5t23+UQ1I(b@u7p%*0}}JXT@Z8+8T-;fK{<8MB;l;RYQ8U{3yBJz(q{Jz@(S_;TyW*IdiYG)ljw=Z~yV2NO~>(0KC66pq{l0&kp5Y&*T`RxTkw?i8H<=Dn zTLktCG@sPbOYa~YCLp5<4f#stC+5udXf}zL1kGd#Q@^PN4$3>0d}w_Z0L}BXs0*sD z=~{H*&POR=23p?9yq{m zXi3A2LdQQ{KO=GHd5gr(< z^`tzmojq6JabZeNQ$b>C4j#~>ro~(ys^=Ph#1?zaE>03(yWv?wSceK27&svqskx&9 z3JPl-g%pWs7jB`OL-?r#t$O}!sReNFL|=(BQ=gMA7c8~<9ZQ`xPVIy>&_ zUX+Oj^7?;{JLYmM!#geSM%!oBSK-0ftz$`?F&)^d1c&2s!d7jeF4H;z(|X2rjg`CL z?1+HOkwra?>IrYPEShMfX^!oDjo{dz&m4O;K|7M)&K!4pfxCE-b8YWLSC1Y>t#~0j zb7vKLf!xG;0-JjrYtZ(ut?YXARyS@^Bek18{2;Svh;g84F9<_;#d~tT3_2JtGvs_- zvf3_U&T02k)`gn+$_^r=XfW3i?Ws1P{jT2N=0_Ob_yncugSl`vIjS}V(I*S zW?_?`%?f!5Ttrf!h4t;>3{|6}c{Z>Da^d4qgL-`Gsf;0P!IXbEw!lxx1|&

F-+| zJDzNA5?WM$+fjeC#{y0u$bX(~(-+JepFc7A7OsQJ8I#xvkxT(scAEcqICWxJ%u0ix zA33CiukJx#`eIZn#zE88GsNfE^wJvG?+ax|;~#4~Vm~6DYFH3K1wgy|bPWotsJP;j zjpW$XshBTUB0g*+(QYI!H>z(M2Kwp3S=LL>Ojets;swqOaTqc%DQL^Osj;)zF-v<# zDHfC?Kpw2P1Y;y&)_omTxA!h;uLiTN5N@q)%$ftMmr~@T3mtiuFQ^rw$_t~`pQzYf zdKKMa^7x()EcK)&hD60vtoP7!Q!@4gsg+j;obi;}Shl5p*xFQ}2G`C92Rmu)DjTrL zP^hW?ioEnX<#Vskw?j%_)eh8eN`g9mWR{;Gp{qO#1!n=hAGuTfGZH$WZBV$X>%rwo zP<3_X+de=6q~%k4EutD|t>mQf?m)NcecvWLNOor3{8Ob>o9@C8rCz=ikN`)uOgte% zFEF)j@zhYubtfBWhfGP_vQ)4N7OL=E;WqdZGsL`|QS$bymgpdLVw>J$JIqg4mX1P3 zTTNSX`LsWy_|FE5Iay2+HDa2^g|Vcd&` z4<8+SS_xL&M&EBFv!CA;ysdYuslqxG2zVR9iRKEy_b!w_{ko#$O(EaWJ~KOnVx;6m1>dXp$b0W&!NOnk zIKR84XwKxkTs3Aglcegy`LzzIj&fmn3wiCQl40|E6=|5k;1sIDo#GlI>Jp;_I+HL@ zzf5Gq&FoNq>7qTt)}vKYBd&Qi5Q2-1M>GLa<%-G>qGcdOg`+LyAjxmx?)6dM2E(Zy z=2A%_m!#J7ZSkKhC43Ue*Wa;Z6EEl^HFaaPJTo>AWs~cCmaQ~rQDKlnp;8gadwv)1 zd1x3%zaEBa;XdMhc8Vs*M?Wr=-HmxbZVT9U@6i{*@eeW3;-4c~W;KAZu!B2W`|XE) z{+K9FhAlfT>K_` z?Bdosz7>W!{e>-v32xm<{eDaQ>ZG1D4)8|fy;nucr2Lu-I>*E6_)fc`(%;tjfI0&d z&k=b}Bp?z0)Ly)f*~4pLb2p(Q??&9%miNaRpy(tu`?Pn^u1uCVvS#fwKW8)iys-%7 ztwsc%ZKeR+wuT8TAa(QqlVq$~aq!dCr9YSI6ufa8Y=ZNMr+AN0uw+cVTFAq^%Q;v_ zO{(6_8rQI;rl;ivYvrtv8Reoa@@}iOrS(znF>cs2ZeAhKKd(u*nEjnr$DDgC;3uCCtkw|H(@6CJmeu(#|xIhDn7NfAX(wiO+bpev6f zkiYUz96j6&KAFTnvq;%wXCb$+0{nA4BVnU&p6r_Ph;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){return n.setMode(t),n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s=1/t.clientHeight,l=s*(r-d),u=s*(a-p),f=h.flipX?1:-1,g=h.flipY?1:-1,v=Math.PI*h.rotateSpeed,m=i();if(1&e)o.shift?n.rotate(m,0,0,-l*v):n.rotate(m,f*v*l,-g*v*u,0);else if(2&e)n.pan(m,-h.translateSpeed*l*c,h.translateSpeed*u*c,0);else if(4&e){var y=h.zoomSpeed*u/window.innerHeight*(m-n.lastT())*50;n.pan(m,0,0,c*(Math.exp(y)-1))}d=r,p=a}),s(t,function(t,e,r){var a=h.flipX?1:-1,o=h.flipY?1:-1,s=i();if(Math.abs(t)>Math.abs(e))n.rotate(s,0,0,-t*a*Math.PI*h.rotateSpeed/window.innerWidth);else{var l=h.zoomSpeed*o*e/window.innerHeight*(s-n.lastT())/100;n.pan(s,0,0,c*(Math.exp(l)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":21,"mouse-change":211,"mouse-wheel":213,"right-now":247}],21:[function(t,e,r){"use strict";function n(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map(function(e){return t[e]}),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.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}function i(t){t=t||{};var e=t.eye||[0,0,1],r=t.center||[0,0,0],i=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],c=t.mode||"turntable",u=a(),f=o(),h=s();return u.setDistanceLimits(l[0],l[1]),u.lookAt(0,e,r,i),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,i),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,i),new n({turntable:u,orbit:f,matrix:h},c)}e.exports=i;var a=t("turntable-camera-controller"),o=t("orbit-camera-controller"),s=t("matrix-camera-controller"),l=n.prototype,c=[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]];c.forEach(function(t){for(var e=t[0],r=[],n=0;ne)){var r=this._active,n=this._controllerList[e],i=Math.max(r.lastT(),n.lastT());r.recalcMatrix(i),n.setMatrix(i,r.computedMatrix),this._active=n,this._mode=t,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}}},l.getMode=function(){return this._mode}},{"matrix-camera-controller":209,"orbit-camera-controller":229,"turntable-camera-controller":279}],22:[function(t,e,r){"use strict";function n(t){var e=s.get(t);if(!e||!t.isBuffer(e._triangleBuffer.buffer)){var r=a(t,new Float32Array([-1,-1,-1,4,4,-1]));e=o(t,[{buffer:r,type:t.FLOAT,size:2}]),e._triangleBuffer=r,s.set(t,e)}e.bind(),t.drawArrays(t.TRIANGLES,0,3),e.unbind()}var i="undefined"==typeof WeakMap?t("weak-map"):WeakMap,a=t("gl-buffer"),o=t("gl-vao"),s=new i;e.exports=n},{"gl-buffer":107,"gl-vao":182,"weak-map":287}],23:[function(t,e,r){function n(t,e,r){e="number"==typeof e?e:1,r=r||": ";var n=t.split(/\r?\n/),a=String(n.length+e-1).length;return n.map(function(t,n){var o=n+e,s=String(o).length,l=i(o,a-s);return l+r+t}).join("\n")}var i=t("pad-left");e.exports=n},{"pad-left":230}],24:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(e+1),n=0;n=i;++i){for(var o=new Array(e),s=0;e>s;++s)o[s]=Math.pow(i+1-n,s);r[i]=o}var l=a.apply(void 0,r);if(l)return!0}return!1}function i(t){var e=t.length;if(0===e)return[];if(1===e)return[0];for(var r=t[0].length,i=[t[0]],a=[0],o=1;e>o;++o)if(i.push(t[o]),n(i,r)){if(a.push(o),a.length===r+1)return a}else i.pop();return a}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":253}],25:[function(t,e,r){"use strict";function n(t,e){return i(e).filter(function(r){for(var n=new Array(r.length),i=0;ia;a++)i.push(t+a*n);return i}function r(){for(var t=[].slice.call(arguments),e=t.map(function(t){return t.length}),r=Math.min.apply(null,e),n=[],i=0;r>i;i++){n[i]=[];for(var a=0;aa;a++)i.push([t[a],e[a],r[a]]);return i}function i(t){function e(t){for(var n=0;n>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3])),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}function c(t,e){var r,n;if("string"!=typeof t)return t;if(r=[],"#"===t[0]?(t=t.substr(1),3===t.length&&(t+=t),n=parseInt(t,16),r[0]=n>>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3]),n[4]?r[3]=parseFloat(n[4]):r[3]=1),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}var u={},f=/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,.*)?\)$/,h=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,?\s*(.*)?\)$/;return u.isPlainObject=t,u.linspace=e,u.zip3=n,u.sum=i,u.zip=r,u.isEqual=s,u.copy2D=a,u.copy1D=o,u.str2RgbArray=l,u.str2RgbaArray=c,u};e.exports=n()},{}],28:[function(t,e,r){e.exports=function(t){return atob(t)}},{}],29:[function(t,e,r){"use strict";function n(t){for(var e=0,r=0;ro;++o){for(var s=new Array(r+1),l=0;r>=l;++l)s[l]=t[l][o];i[o]=s}i[r]=new Array(r+1);for(var o=0;r>=o;++o)i[r][o]=1;for(var c=new Array(r+1),o=0;r>o;++o)c[o]=e[o];c[r]=1;var u=a(i,c),f=n(u[r+1]);0===f&&(f=1);for(var h=new Array(r+1),o=0;r>=o;++o)h[o]=n(u[o])/f;return h}e.exports=i;var a=t("robust-linear-solve")},{"robust-linear-solve":252}],30:[function(t,e,r){"use strict";function n(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;r>e;++e)l[e]=t[e],c[t.charCodeAt(e)]=e;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63}function i(t){var e,r,n,i,a,o,s=t.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===t[s-2]?2:"="===t[s-1]?1:0,o=new u(3*s/4-a),n=a>0?s-4:s;var l=0;for(e=0,r=0;n>e;e+=4,r+=3)i=c[t.charCodeAt(e)]<<18|c[t.charCodeAt(e+1)]<<12|c[t.charCodeAt(e+2)]<<6|c[t.charCodeAt(e+3)],o[l++]=i>>16&255,o[l++]=i>>8&255,o[l++]=255&i;return 2===a?(i=c[t.charCodeAt(e)]<<2|c[t.charCodeAt(e+1)]>>4,o[l++]=255&i):1===a&&(i=c[t.charCodeAt(e)]<<10|c[t.charCodeAt(e+1)]<<4|c[t.charCodeAt(e+2)]>>2,o[l++]=i>>8&255,o[l++]=255&i),o}function a(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function o(t,e,r){for(var n,i=[],o=e;r>o;o+=3)n=(t[o]<<16)+(t[o+1]<<8)+t[o+2],i.push(a(n));return i.join("")}function s(t){for(var e,r=t.length,n=r%3,i="",a=[],s=16383,c=0,u=r-n;u>c;c+=s)a.push(o(t,c,c+s>u?u:c+s));return 1===n?(e=t[r-1],i+=l[e>>2],i+=l[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=l[e>>10],i+=l[e>>4&63],i+=l[e<<2&63],i+="="),a.push(i),a.join("")}r.toByteArray=i,r.fromByteArray=s;var l=[],c=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],31:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]).add(e[0].mul(t[1])),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":41}],32:[function(t,e,r){"use strict";function n(t,e){return t[0].mul(e[1]).cmp(e[0].mul(t[1]))}e.exports=n},{}],33:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]),t[1].mul(e[0]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":41}],34:[function(t,e,r){"use strict";function n(t,e){if(i(t))return e?c(t,n(e)):[t[0].clone(),t[1].clone()];var r,u,f=0;if(a(t))r=t.clone();else if("string"==typeof t)r=s(t);else{if(0===t)return[o(0),o(1)];if(t===Math.floor(t))r=o(t);else{for(;t!==Math.floor(t);)t*=Math.pow(2,256),f-=256;r=o(t)}}if(i(e))r.mul(e[1]),u=e[0].clone();else if(a(e))u=e.clone();else if("string"==typeof e)u=s(e);else if(e)if(e===Math.floor(e))u=o(e);else{for(;e!==Math.floor(e);)e*=Math.pow(2,256),f+=256;u=o(e)}else u=o(1);return f>0?r=r.shln(f):0>f&&(u=u.shln(-f)),l(r,u)}var i=t("./is-rat"),a=t("./lib/is-bn"),o=t("./lib/num-to-bn"),s=t("./lib/str-to-bn"),l=t("./lib/rationalize"),c=t("./div");e.exports=n},{"./div":33,"./is-rat":35,"./lib/is-bn":39,"./lib/num-to-bn":40,"./lib/rationalize":41,"./lib/str-to-bn":42}],35:[function(t,e,r){"use strict";function n(t){return Array.isArray(t)&&2===t.length&&i(t[0])&&i(t[1])}var i=t("./lib/is-bn");e.exports=n},{"./lib/is-bn":39}],36:[function(t,e,r){"use strict";function n(t){return t.cmp(new i(0))}var i=t("bn.js");e.exports=n},{"bn.js":49}],37:[function(t,e,r){"use strict";function n(t){var e=t.length,r=t.words,n=0;if(1===e)n=r[0];else if(2===e)n=r[0]+67108864*r[1];else for(var n=0,i=0;e>i;i++){var a=r[i];n+=a*Math.pow(67108864,i)}return t.sign?-n:n}e.exports=n},{}],38:[function(t,e,r){"use strict";function n(t){var e=a(i.lo(t));if(32>e)return e;var r=a(i.hi(t));return r>20?52:r+32}var i=t("double-bits"),a=t("bit-twiddle").countTrailingZeros;e.exports=n},{"bit-twiddle":48,"double-bits":89}],39:[function(t,e,r){"use strict";function n(t){return t&&"object"==typeof t&&Boolean(t.words)}t("bn.js");e.exports=n},{"bn.js":49}],40:[function(t,e,r){"use strict";function n(t){var e=a.exponent(t);return 52>e?new i(t):new i(t*Math.pow(2,52-e)).shln(e-52)}var i=t("bn.js"),a=t("double-bits");e.exports=n},{"bn.js":49,"double-bits":89}],41:[function(t,e,r){"use strict";function n(t,e){var r=a(t),n=a(e);if(0===r)return[i(0),i(1)];if(0===n)return[i(0),i(0)];0>n&&(t=t.neg(),e=e.neg());var o=t.gcd(e);return o.cmpn(1)?[t.div(o),e.div(o)]:[t,e]}var i=t("./num-to-bn"),a=t("./bn-sign");e.exports=n},{"./bn-sign":36,"./num-to-bn":40}],42:[function(t,e,r){"use strict";function n(t){return new i(t)}var i=t("bn.js");e.exports=n},{"bn.js":49}],43:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[0]),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":41}],44:[function(t,e,r){"use strict";function n(t){return i(t[0])*i(t[1])}var i=t("./lib/bn-sign");e.exports=n},{"./lib/bn-sign":36}],45:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":41}],46:[function(t,e,r){"use strict";function n(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var n=e.divmod(r),o=n.div,s=i(o),l=n.mod;if(0===l.cmpn(0))return s;if(s){var c=a(s)+4,u=i(l.shln(c).divRound(r));return 0>s&&(u=-u),s+u*Math.pow(2,-c)}var f=r.bitLength()-l.bitLength()+53,u=i(l.shln(f).divRound(r));return 1023>f?u*Math.pow(2,-f):(u*=Math.pow(2,-1023),u*Math.pow(2,1023-f))}var i=t("./lib/bn-to-num"),a=t("./lib/ctz");e.exports=n},{"./lib/bn-to-num":37,"./lib/ctz":38}],47:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],48:[function(t,e,r){"use strict";"use restrict";function n(t){var e=32;return t&=-t,t&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}var i=32;r.INT_BITS=i,r.INT_MAX=2147483647,r.INT_MIN=-1<0)-(0>t)},r.abs=function(t){var e=t>>i-1;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(e>t)},r.max=function(t,e){return t^(t^e)&-(e>t)},r.isPow2=function(t){return!(t&t-1||!t)},r.log2=function(t){var e,r;return e=(t>65535)<<4,t>>>=e,r=(t>255)<<3,t>>>=r,e|=r,r=(t>15)<<2,t>>>=r,e|=r,r=(t>3)<<1,t>>>=r,e|=r,e|t>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return t-=t>>>1&1431655765,t=(858993459&t)+(t>>>2&858993459),16843009*(t+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,t&=15,27030>>>t&1};var a=new Array(256);!function(t){for(var e=0;256>e;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|a[t>>>16&255]<<8|a[t>>>24&255]},r.interleave2=function(t,e){return t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},r.deinterleave2=function(t,e){return t=t>>>e&1431655765,t=858993459&(t|t>>>1),t=252645135&(t|t>>>2),t=16711935&(t|t>>>4),t=65535&(t|t>>>16),t<<16>>16},r.interleave3=function(t,e,r){return t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t|=e<<1,r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),t|r<<2},r.deinterleave3=function(t,e){return t=t>>>e&1227133513,t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),t=1023&(t|t>>>16),t<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],49:[function(t,e,r){!function(t,e){"use strict";function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){return null!==t&&"object"==typeof t&&Array.isArray(t.words)?t:(this.sign=!1,this.words=null,this.length=0,this.red=null,"le"!==e&&"be"!==e||(r=e, -e=10),void(null!==t&&this._init(t||0,e||10,r||"be")))}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),a=e;i>a;a++){var o=t.charCodeAt(a)-48;n<<=4,n|=o>=49&&54>=o?o-49+10:o>=17&&22>=o?o-17+10:15&o}return n}function o(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;a>o;o++){var s=t.charCodeAt(o)-48;i*=n,i+=s>=49?s-49+10:s>=17?s-17+10:s}return i}function s(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).ishln(this.n).isub(this.p),this.tmp=this._tmp()}function l(){s.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function c(){s.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function u(){s.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function f(){s.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function h(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function d(t){h.call(this,t),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).ishln(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.sign=!0,this.minv=this.minv.mod(this.r)}"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26,i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&36>=e),t=t.toString().replace(/\s+/g,"");var i=0;"-"===t[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.sign=!0),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initNumber=function(t,e,n){0>t&&(this.sign=!0,t=-t),67108864>t?(this.words=[67108863&t],this.length=1):4503599627370496>t?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(9007199254740992>t),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3){var s=t[i]|t[i-1]<<8|t[i-2]<<16;this.words[o]|=s<>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}else if("le"===n)for(var i=0,o=0;i>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}return this.strip()},i.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6){var o=a(t,r,r+6);this.words[i]|=o<>>26-n&4194303,n+=24,n>=26&&(n-=26,i++)}if(r+6!==e){var o=a(t,e,r+6);this.words[i]|=o<>>26-n&4194303}this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;67108863>=i;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,s=a%n,l=Math.min(a,a-s)+r,c=0,u=r;l>u;u+=n)c=o(t,u,u+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){for(var f=1,c=o(t,u,t.length,e),u=0;s>u;u++)f*=e;this.imuln(f),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},i.prototype.inspect=function(){return(this.red?""};var p=["","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"],g=[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],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(t,e){if(t=t||10,16===t||"hex"===t){for(var n="",i=0,e=0|e||1,a=0,o=0;o>>24-i&16777215,n=0!==a||o!==this.length-1?p[6-l.length]+l+n:l+n,i+=2,i>=26&&(i-=26,o--)}for(0!==a&&(n=a.toString(16)+n);n.length%e!==0;)n="0"+n;return this.sign&&(n="-"+n),n}if(t===(0|t)&&t>=2&&36>=t){var c=g[t],u=v[t],n="",f=this.clone();for(f.sign=!1;0!==f.cmpn(0);){var h=f.modn(u).toString(t);f=f.idivn(u),n=0!==f.cmpn(0)?p[c-h.length]+h+n:h+n}return 0===this.cmpn(0)&&(n="0"+n),this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(t){this.strip();var e=new Array(this.byteLength());e[0]=0;var r=this.clone();if("le"!==t)for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[e.length-n-1]=i}else for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[n]=i}return e},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0===(8191&e)&&(r+=13,e>>>=13),0===(127&e)&&(r+=7,e>>>=7),0===(15&e)&&(r+=4,e>>>=4),0===(3&e)&&(r+=2,e>>>=2),0===(1&e)&&r++,r},i.prototype.bitLength=function(){var t=0,e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.iand=function(t){this.sign=this.sign&&t.sign;var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.ixor=function(t){this.sign=this.sign||t.sign;var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);for(var n=t/26|0,i=t%26;this.length<=n;)this.words[this.length++]=0;return e?this.words[n]=this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26}for(;0!==i&&a>>26}if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(t.sign){t.sign=!1;var e=this.iadd(t);return t.sign=!0,e._normSign()}if(this.sign)return this.sign=!1,this.iadd(t),this.sign=!0,this._normSign();var r=this.cmp(t);if(0===r)return this.sign=!1,this.length=1,this.words[0]=0,this;var n,i;r>0?(n=this,i=t):(n=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e}for(;0!==a&&o>26,this.words[o]=67108863&e}if(0===a&&o>>26,a=67108863&r,o=Math.min(n,t.length-1),s=Math.max(0,n-this.length+1);o>=s;s++){var l=n-s,c=0|this.words[l],u=0|t.words[s],f=c*u,h=67108863&f;i=i+(f/67108864|0)|0,h=h+a|0,a=67108863&h,i=i+(h>>>26)|0}e.words[n]=a,r=i}return 0!==r?e.words[n]=r:e.length--,e.strip()},i.prototype._bigMulTo=function(t,e){e.sign=t.sign!==this.sign,e.length=this.length+t.length;for(var r=0,n=0,i=0;i=l;l++){var c=i-l,u=0|this.words[c],f=0|t.words[l],h=u*f,d=67108863&h;a=a+(h/67108864|0)|0,d=d+o|0,o=67108863&d,a=a+(d>>>26)|0,n+=a>>>26,a&=67108863}e.words[i]=o,r=a,a=n}return 0!==r?e.words[i]=r:e.length--,e.strip()},i.prototype.mulTo=function(t,e){var r;return r=this.length+t.length<63?this._smallMulTo(t,e):this._bigMulTo(t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.imul=function(t){if(0===this.cmpn(0)||0===t.cmpn(0))return this.words[0]=0,this.length=1,this;var e=this.length,r=t.length;this.sign=t.sign!==this.sign,this.length=this.length+t.length,this.words[this.length-1]=0;for(var n=this.length-2;n>=0;n--){for(var i=0,a=0,o=Math.min(n,r-1),s=Math.max(0,n-e+1);o>=s;s++){var l=n-s,c=this.words[l],u=t.words[s],f=c*u,h=67108863&f;i+=f/67108864|0,h+=a,a=67108863&h,i+=h>>>26}this.words[n]=a,this.words[n+1]+=i,i=0}for(var i=0,l=1;l>>26}return this.strip()},i.prototype.imuln=function(t){r("number"==typeof t);for(var e=0,n=0;n>=26,e+=i/67108864|0,e+=a>>>26,this.words[n]=67108863&a}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.ishln=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=67108863>>>26-e<<26-e;if(0!==e){for(var a=0,o=0;o>>26-e}a&&(this.words[o]=a,this.length++)}if(0!==n){for(var o=this.length-1;o>=0;o--)this.words[o+n]=this.words[o];for(var o=0;n>o;o++)this.words[o]=0;this.length+=n}return this.strip()},i.prototype.ishrn=function(t,e,n){r("number"==typeof t&&t>=0);var i;i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<c;c++)l.words[c]=this.words[c];l.length=o}if(0===o);else if(this.length>o){this.length-=o;for(var c=0;c=0&&(0!==u||c>=i);c--){var f=this.words[c];this.words[c]=u<<26-a|f>>>a,u=f&s}return l&&0!==u&&(l.words[l.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<t?this.isubn(-t):this.sign?1===this.length&&this.words[0]=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),0>t)return this.iaddn(-t);if(this.sign)return this.sign=!1,this.iaddn(t),this.sign=!0,this;this.words[0]-=t;for(var e=0;e>26)-(c/67108864|0),this.words[i+n]=67108863&l}for(;i>26,this.words[i+n]=67108863&l}if(0===s)return this.strip();r(-1===s),s=0;for(var i=0;i>26,this.words[i]=67108863&l}return this.sign=!0,this.strip()},i.prototype._wordDiv=function(t,e){var r=this.length-t.length,n=this.clone(),a=t,o=a.words[a.length-1],s=this._countBits(o);r=26-s,0!==r&&(a=a.shln(r),n.ishln(r),o=a.words[a.length-1]);var l,c=n.length-a.length;if("mod"!==e){l=new i(null),l.length=c+1,l.words=new Array(l.length);for(var u=0;u=0;h--){var d=67108864*n.words[a.length+h]+n.words[a.length+h-1];for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(a,d,h);n.sign;)d--,n.sign=!1,n._ishlnsubmul(a,1,h),0!==n.cmpn(0)&&(n.sign=!n.sign);l&&(l.words[h]=d)}return l&&l.strip(),n.strip(),"div"!==e&&0!==r&&n.ishrn(r),{div:l?l:null,mod:n}},i.prototype.divmod=function(t,e){if(r(0!==t.cmpn(0)),this.sign&&!t.sign){var n,a,o=this.neg().divmod(t,e);return"mod"!==e&&(n=o.div.neg()),"div"!==e&&(a=0===o.mod.cmpn(0)?o.mod:t.sub(o.mod)),{div:n,mod:a}}if(!this.sign&&t.sign){var n,o=this.divmod(t.neg(),e);return"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}}return this.sign&&t.sign?this.neg().divmod(t.neg(),e):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e)},i.prototype.div=function(t){return this.divmod(t,"div").div},i.prototype.mod=function(t){return this.divmod(t,"mod").mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(0===e.mod.cmpn(0))return e.div;var r=e.div.sign?e.mod.isub(t):e.mod,n=t.shrn(1),i=t.andln(1),a=r.cmp(n);return 0>a||1===i&&0===a?e.div:e.div.sign?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(67108863>=t);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+this.words[i])%t;return n},i.prototype.idivn=function(t){r(67108863>=t);for(var e=0,n=this.length-1;n>=0;n--){var i=this.words[n]+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=new i(0),l=new i(1),c=0;e.isEven()&&n.isEven();)e.ishrn(1),n.ishrn(1),++c;for(var u=n.clone(),f=e.clone();0!==e.cmpn(0);){for(;e.isEven();)e.ishrn(1),a.isEven()&&o.isEven()?(a.ishrn(1),o.ishrn(1)):(a.iadd(u).ishrn(1),o.isub(f).ishrn(1));for(;n.isEven();)n.ishrn(1),s.isEven()&&l.isEven()?(s.ishrn(1),l.ishrn(1)):(s.iadd(u).ishrn(1),l.isub(f).ishrn(1));e.cmp(n)>=0?(e.isub(n),a.isub(s),o.isub(l)):(n.isub(e),s.isub(a),l.isub(o))}return{a:s,b:l,gcd:n.ishln(c)}},i.prototype._invmp=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(;e.isEven();)e.ishrn(1),a.isEven()?a.ishrn(1):a.iadd(s).ishrn(1);for(;n.isEven();)n.ishrn(1),o.isEven()?o.ishrn(1):o.iadd(s).ishrn(1);e.cmp(n)>=0?(e.isub(n),a.isub(o)):(n.isub(e),o.isub(a))}return 0===e.cmpn(1)?a:o},i.prototype.gcd=function(t){if(0===this.cmpn(0))return t.clone();if(0===t.cmpn(0))return this.clone();var e=this.clone(),r=t.clone();e.sign=!1,r.sign=!1;for(var n=0;e.isEven()&&r.isEven();n++)e.ishrn(1),r.ishrn(1);for(;;){for(;e.isEven();)e.ishrn(1);for(;r.isEven();)r.ishrn(1);var i=e.cmp(r);if(0>i){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.ishln(n)},i.prototype.invm=function(t){return this.egcd(t).a.mod(t)},i.prototype.isEven=function(){return 0===(1&this.words[0])},i.prototype.isOdd=function(){return 1===(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<a;a++)this.words[a]=0;return this.words[n]|=i,this.length=n+1,this}for(var o=i,a=n;0!==o&&a>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.cmpn=function(t){var e=0>t;if(e&&(t=-t),this.sign&&!e)return-1;if(!this.sign&&e)return 1;t&=67108863,this.strip();var r;if(this.length>1)r=1;else{var n=this.words[0];r=n===t?0:t>n?-1:1}return this.sign&&(r=-r),r},i.prototype.cmp=function(t){if(this.sign&&!t.sign)return-1;if(!this.sign&&t.sign)return 1;var e=this.ucmp(t);return this.sign?-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length=0;r--){var n=this.words[r],i=t.words[r];if(n!==i){i>n?e=-1:n>i&&(e=1);break}}return e},i.red=function(t){return new h(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};s.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},s.prototype.ireduce=function(t){var e,r=t;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),e=r.bitLength();while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},s.prototype.split=function(t,e){t.ishrn(this.n,0,e)},s.prototype.imulK=function(t){return t.imul(this.k)},n(l,s),l.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;n>i;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var a=t.words[9];e.words[e.length++]=a&r;for(var i=10;i>>22,a=o}t.words[i-10]=a>>>22,t.length-=9},l.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e,r=0,n=0;n>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function y(t){if(m[t])return m[t];var y;if("k256"===t)y=new l;else if("p224"===t)y=new c;else if("p192"===t)y=new u;else{if("p25519"!==t)throw new Error("Unknown prime "+t);y=new f}return m[t]=y,y},h.prototype._verify1=function(t){r(!t.sign,"red works only with positives"),r(t.red,"red works only with red numbers")},h.prototype._verify2=function(t,e){r(!t.sign&&!e.sign,"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},h.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.mod(this.m)._forceRed(this)},h.prototype.neg=function(t){var e=t.clone();return e.sign=!e.sign,e.iadd(this.m)._forceRed(this)},h.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},h.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},h.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},h.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},h.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.shln(e))},h.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},h.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},h.prototype.isqr=function(t){return this.imul(t,t)},h.prototype.sqr=function(t){return this.mul(t,t)},h.prototype.sqrt=function(t){if(0===t.cmpn(0))return t.clone();var e=this.m.andln(3);if(r(e%2===1),3===e){var n=this.m.add(new i(1)).ishrn(2),a=this.pow(t,n);return a}for(var o=this.m.subn(1),s=0;0!==o.cmpn(0)&&0===o.andln(1);)s++,o.ishrn(1);r(0!==o.cmpn(0));var l=new i(1).toRed(this),c=l.redNeg(),u=this.m.subn(1).ishrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,o),a=this.pow(t,o.addn(1).ishrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(l);){for(var g=d,v=0;0!==g.cmp(l);v++)g=g.redSqr();r(p>v);var m=this.pow(h,new i(1).ishln(p-v-1));a=a.redMul(m),h=m.redSqr(),d=d.redMul(h),p=v}return a},h.prototype.invm=function(t){var e=t._invmp(this.m);return e.sign?(e.sign=!1,this.imod(e).redNeg()):this.imod(e)},h.prototype.pow=function(t,e){var r=[];if(0===e.cmpn(0))return new i(1);for(var n=e.clone();0!==n.cmpn(0);)r.push(n.andln(1)),n.ishrn(1);for(var a=t,o=0;o=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},d.prototype.mul=function(t,e){if(0===t.cmpn(0)||0===e.cmpn(0))return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).ishrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},d.prototype.invm=function(t){var e=this.imod(t._invmp(this.m).mul(this.r2));return e._forceRed(this)}}("undefined"==typeof e||e,this)},{}],50:[function(t,e,r){"use strict";function n(t){var e,r,n,i=t.length,a=0;for(e=0;i>e;++e)a+=t[e].length;var o=new Array(a),s=0;for(e=0;i>e;++e){var l=t[e],c=l.length;for(r=0;c>r;++r){var u=o[s++]=new Array(c-1),f=0;for(n=0;c>n;++n)n!==r&&(u[f++]=l[n]);if(1&r){var h=u[1];u[1]=u[0],u[0]=h}}}return o}e.exports=n},{}],51:[function(t,e,r){"use strict";function n(t,e){for(var r=0;t>r;++r)if(!(e[r]<=e[r+t]))return!0;return!1}function i(t,e,r,i){for(var a=0,o=0,s=0,l=t.length;l>s;++s){var c=t[s];if(!n(e,c)){for(var u=0;2*e>u;++u)r[a++]=c[u];i[o++]=s}}return o}function a(t,e,r,n){var a=t.length,o=e.length;if(!(0>=a||0>=o)){var s=t[0].length>>>1;if(!(0>=s)){var l,c=f.mallocDouble(2*s*a),u=f.mallocInt32(a);if(a=i(t,s,c,u),a>0){if(1===s&&n)h.init(a),l=h.sweepComplete(s,r,0,a,c,u,0,a,c,u);else{var p=f.mallocDouble(2*s*o),g=f.mallocInt32(o);o=i(e,s,p,g),o>0&&(h.init(a+o),l=1===s?h.sweepBipartite(s,r,0,a,c,u,0,o,p,g):d(s,r,n,a,c,u,o,p,g),f.free(p),f.free(g))}f.free(c),f.free(u)}return l}}}function o(t,e){u.push([t,e])}function s(t){return u=[],a(t,t,o,!0),u}function l(t,e){return u=[],a(t,e,o,!1),u}function c(t,e,r){switch(arguments.length){case 1:return s(t);case 2:return"function"==typeof e?a(t,t,e,!0):l(t,e);case 3:return a(t,e,r,!1);default:throw new Error("box-intersect: Invalid arguments")}}e.exports=c;var u,f=t("typedarray-pool"),h=t("./lib/sweep"),d=t("./lib/intersect")},{"./lib/intersect":53,"./lib/sweep":57,"typedarray-pool":282}],52:[function(t,e,r){"use strict";function n(t,e,r){var n="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),i=["function ",n,"(",w.join(),"){","var ",c,"=2*",a,";"],l="for(var i="+u+","+p+"="+c+"*"+u+";i<"+f+";++i,"+p+"+="+c+"){var x0="+h+"["+o+"+"+p+"],x1="+h+"["+o+"+"+p+"+"+a+"],xi="+d+"[i];",k="for(var j="+g+","+b+"="+c+"*"+g+";j<"+v+";++j,"+b+"+="+c+"){var y0="+m+"["+o+"+"+b+"],"+(r?"y1="+m+"["+o+"+"+b+"+"+a+"],":"")+"yi="+y+"[j];";return t?i.push(l,_,":",k):i.push(k,_,":",l),r?i.push("if(y1"+v+"-"+g+"){"),t?(e(!0,!1),o.push("}else{"),e(!1,!1)):(o.push("if("+l+"){"),e(!0,!0),o.push("}else{"),e(!0,!1),o.push("}}else{if("+l+"){"),e(!1,!0),o.push("}else{"),e(!1,!1),o.push("}")),o.push("}}return "+r);var s=i.join("")+o.join(""),c=new Function(s);return c()}var a="d",o="ax",s="vv",l="fp",c="es",u="rs",f="re",h="rb",d="ri",p="rp",g="bs",v="be",m="bb",y="bi",b="bp",x="rv",_="Q",w=[a,o,s,u,f,h,d,g,v,m,y];r.partial=i(!1),r.full=i(!0)},{}],53:[function(t,e,r){"use strict";function n(t,e){var r=8*c.log2(e+1)*(t+1)|0,n=c.nextPow2(M*r);L.lengthS&&(l.free(S),S=l.mallocDouble(i))}function i(t,e,r,n,i,a,o,s,l){var c=M*t;L[c]=e,L[c+1]=r,L[c+2]=n,L[c+3]=i,L[c+4]=a,L[c+5]=o;var u=T*t;S[u]=s,S[u+1]=l}function a(t,e,r,n,i,a,o,s,l,c,u){var f=2*t,h=l*f,d=c[h+e];t:for(var p=i,g=i*f;a>p;++p,g+=f){var v=o[g+e],m=o[g+e+t];if(!(v>d||d>m||n&&d===v)){for(var y=s[p],b=e+1;t>b;++b){var v=o[g+b],m=o[g+b+t],x=c[h+b],_=c[h+b+t];if(x>m||v>_)continue t}var w;if(w=n?r(u,y):r(y,u),void 0!==w)return w}}}function o(t,e,r,n,i,a,o,s,l,c){var u=2*t,f=s*u,h=l[f+e];t:for(var d=n,p=n*u;i>d;++d,p+=u){var g=o[d];if(g!==c){var v=a[p+e],m=a[p+e+t];if(!(v>h||h>m)){for(var y=e+1;t>y;++y){var v=a[p+y],m=a[p+y+t],b=l[f+y],x=l[f+y+t];if(b>m||v>x)continue t}var _=r(g,c);if(void 0!==_)return _}}}}function s(t,e,r,s,l,c,u,g,E){n(t,s+u);var C,z=0,P=2*t;for(i(z++,0,0,s,0,u,r?16:0,-(1/0),1/0),r||i(z++,0,0,u,0,s,1,-(1/0),1/0);z>0;){z-=1;var R=z*M,O=L[R],I=L[R+1],N=L[R+2],j=L[R+3],F=L[R+4],B=L[R+5],D=z*T,U=S[D],V=S[D+1],q=1&B,H=!!(16&B),G=l,Y=c,X=g,W=E;if(q&&(G=g,Y=E,X=l,W=c),!(2&B&&(N=_(t,O,I,N,G,Y,V),I>=N)||4&B&&(I=w(t,O,I,N,G,Y,U),I>=N))){var Z=N-I,K=F-j;if(H){if(y>t*Z*(Z+K)){if(C=d.scanComplete(t,O,e,I,N,G,Y,j,F,X,W),void 0!==C)return C;continue}}else{if(t*Math.min(Z,K)t*Z*K){if(C=d.scanBipartite(t,O,e,q,I,N,G,Y,j,F,X,W),void 0!==C)return C;continue}}var Q=b(t,O,I,N,G,Y,U,V);if(Q>I)if(v>t*(Q-I)){if(C=h(t,O+1,e,I,Q,G,Y,j,F,X,W),void 0!==C)return C}else if(O===t-2){if(C=q?d.sweepBipartite(t,e,j,F,X,W,I,Q,G,Y):d.sweepBipartite(t,e,I,Q,G,Y,j,F,X,W),void 0!==C)return C}else i(z++,O+1,I,Q,j,F,q,-(1/0),1/0),i(z++,O+1,j,F,I,Q,1^q,-(1/0),1/0);if(N>Q){var $=p(t,O,j,F,X,W),J=X[P*$+O],tt=x(t,O,$,F,X,W,J);if(F>tt&&i(z++,O,Q,N,tt,F,(4|q)+(H?16:0),J,V),$>j&&i(z++,O,Q,N,j,$,(2|q)+(H?16:0),U,J),$+1===tt){if(C=H?o(t,O,e,Q,N,G,Y,$,X,W[$]):a(t,O,e,q,Q,N,G,Y,$,X,W[$]),void 0!==C)return C}else if(tt>$){var et;if(H){if(et=k(t,O,Q,N,G,Y,J),et>Q){var rt=x(t,O,Q,et,G,Y,J);if(O===t-2){if(rt>Q&&(C=d.sweepComplete(t,e,Q,rt,G,Y,$,tt,X,W),void 0!==C))return C;if(et>rt&&(C=d.sweepBipartite(t,e,rt,et,G,Y,$,tt,X,W),void 0!==C))return C}else rt>Q&&i(z++,O+1,Q,rt,$,tt,16,-(1/0),1/0),et>rt&&(i(z++,O+1,rt,et,$,tt,0,-(1/0),1/0),i(z++,O+1,$,tt,rt,et,1,-(1/0),1/0))}}else et=q?A(t,O,Q,N,G,Y,J):k(t,O,Q,N,G,Y,J),et>Q&&(O===t-2?C=q?d.sweepBipartite(t,e,$,tt,X,W,Q,et,G,Y):d.sweepBipartite(t,e,Q,et,G,Y,$,tt,X,W):(i(z++,O+1,Q,et,$,tt,q,-(1/0),1/0),i(z++,O+1,$,tt,Q,et,1^q,-(1/0),1/0)))}}}}}e.exports=s;var l=t("typedarray-pool"),c=t("bit-twiddle"),u=t("./brute"),f=u.partial,h=u.full,d=t("./sweep"),p=t("./median"),g=t("./partition"),v=128,m=1<<22,y=1<<22,b=g("!(lo>=p0)&&!(p1>=hi)",["p0","p1"]),x=g("lo===p0",["p0"]),_=g("lol;++l,s+=o)for(var c=i[s],u=l,f=o*(l-1);u>r&&i[f+e]>c;--u,f-=o){for(var h=f,d=f+o,p=0;o>p;++p,++h,++d){var g=i[h];i[h]=i[d],i[d]=g}var v=a[u];a[u]=a[u-1],a[u-1]=v}}function i(t,e,r,i,a,l){if(r+1>=i)return r;for(var c=r,u=i,f=i+r>>>1,h=2*t,d=f,p=a[h*f+e];u>c;){if(s>u-c){n(t,e,c,u,a,l),p=a[h*f+e];break}var g=u-c,v=Math.random()*g+c|0,m=a[h*v+e],y=Math.random()*g+c|0,b=a[h*y+e],x=Math.random()*g+c|0,_=a[h*x+e];b>=m?_>=b?(d=y,p=b):m>=_?(d=v,p=m):(d=x,p=_):b>=_?(d=y,p=b):_>=m?(d=v,p=m):(d=x,p=_);for(var w=h*(u-1),k=h*d,A=0;h>A;++A,++w,++k){var M=a[w];a[w]=a[k],a[k]=M}var T=l[u-1];l[u-1]=l[d],l[d]=T,d=o(t,e,c,u-1,a,l,p);for(var w=h*(u-1),k=h*d,A=0;h>A;++A,++w,++k){var M=a[w];a[w]=a[k],a[k]=M}var T=l[u-1];if(l[u-1]=l[d],l[d]=T,d>f){for(u=d-1;u>c&&a[h*(u-1)+e]===p;)u-=1;u+=1}else{if(!(f>d))break;for(c=d+1;u>c&&a[h*c+e]===p;)c+=1}}return o(t,e,r,f,a,l,a[h*f+e])}e.exports=i;var a=t("./partition"),o=a("lo=0&&n.push("lo=e[k+n]"),t.indexOf("hi")>=0&&n.push("hi=e[k+o]"),r.push(i.replace("_",n.join()).replace("$",t)),Function.apply(void 0,r)}e.exports=n;var i="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 _;if($)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"},{}],56:[function(t,e,r){"use strict";function n(t,e){4*h>=e?i(0,e-1,t):f(0,e-1,t)}function i(t,e,r){for(var n=2*(t+1),i=t+1;e>=i;++i){for(var a=r[n++],o=r[n++],s=i,l=n-2;s-- >t;){var c=r[l-2],u=r[l-1];if(a>c)break;if(c===a&&o>u)break;r[l]=c,r[l+1]=u,l-=2}r[l]=a,r[l+1]=o}}function a(t,e,r){t*=2,e*=2;var n=r[t],i=r[t+1];r[t]=r[e],r[t+1]=r[e+1],r[e]=n,r[e+1]=i}function o(t,e,r){t*=2,e*=2,r[t]=r[e],r[t+1]=r[e+1]}function s(t,e,r,n){t*=2,e*=2,r*=2;var i=n[t],a=n[t+1];n[t]=n[e],n[t+1]=n[e+1],n[e]=n[r],n[e+1]=n[r+1],n[r]=i,n[r+1]=a}function l(t,e,r,n,i){t*=2,e*=2,i[t]=i[e],i[e]=r,i[t+1]=i[e+1],i[e+1]=n}function c(t,e,r){t*=2,e*=2;var n=r[t],i=r[e];return i>n?!1:n===i?r[t+1]>r[e+1]:!0}function u(t,e,r,n){t*=2;var i=n[t];return e>i?!0:i===e?n[t+1]>1,v=g-n,m=g+n,y=d,b=v,x=g,_=m,w=p,k=t+1,A=e-1,M=0;c(y,b,r)&&(M=y,y=b,b=M),c(_,w,r)&&(M=_,_=w,w=M),c(y,x,r)&&(M=y,y=x,x=M),c(b,x,r)&&(M=b,b=x,x=M),c(y,_,r)&&(M=y,y=_,_=M),c(x,_,r)&&(M=x,x=_,_=M),c(b,w,r)&&(M=b,b=w,w=M),c(b,x,r)&&(M=b,b=x,x=M),c(_,w,r)&&(M=_,_=w,w=M);for(var T=r[2*b],E=r[2*b+1],L=r[2*_],S=r[2*_+1],C=2*y,z=2*x,P=2*w,R=2*d,O=2*g,I=2*p,N=0;2>N;++N){var j=r[C+N],F=r[z+N],B=r[P+N];r[R+N]=j,r[O+N]=F,r[I+N]=B}o(v,t,r),o(m,e,r);for(var D=k;A>=D;++D)if(u(D,T,E,r))D!==k&&a(D,k,r),++k;else if(!u(D,L,S,r))for(;;){if(u(A,L,S,r)){u(A,T,E,r)?(s(D,k,A,r),++k,--A):(a(D,A,r),--A);break}if(--A=k-2-t?i(t,k-2,r):f(t,k-2,r),h>=e-(A+2)?i(A+2,e,r):f(A+2,e,r),h>=A-k?i(k,A,r):f(k,A,r)}e.exports=n;var h=32},{}],57:[function(t,e,r){"use strict";function n(t){var e=f.nextPow2(t);g.lengthk;++k){var A=s[k],M=b*k;_[p++]=o[M+x],_[p++]=-(A+1),_[p++]=o[M+w],_[p++]=A}for(var k=l;c>k;++k){var A=f[k]+d,T=b*k;_[p++]=u[T+x],_[p++]=-A,_[p++]=u[T+w],_[p++]=A}var E=p>>>1;h(_,E);for(var L=0,S=0,k=0;E>k;++k){var C=0|_[2*k+1];if(C>=d)C=C-d|0,i(m,y,S--,C);else if(C>=0)i(g,v,L--,C);else if(-d>=C){C=-C-d|0;for(var z=0;L>z;++z){var P=e(g[z],C);if(void 0!==P)return P}a(m,y,S++,C)}else{C=-C-1|0;for(var z=0;S>z;++z){var P=e(C,m[z]);if(void 0!==P)return P}a(g,v,L++,C)}}}function s(t,e,r,n,o,s,l,c,u,f){for(var d=0,p=2*t,w=t-1,k=p-1,A=r;n>A;++A){var M=s[A]+1<<1,T=p*A;_[d++]=o[T+w],_[d++]=-M,_[d++]=o[T+k],_[d++]=M}for(var A=l;c>A;++A){var M=f[A]+1<<1,E=p*A;_[d++]=u[E+w],_[d++]=1|-M,_[d++]=u[E+k],_[d++]=1|M}var L=d>>>1;h(_,L);for(var S=0,C=0,z=0,A=0;L>A;++A){var P=0|_[2*A+1],R=1&P;if(L-1>A&&P>>1===_[2*A+3]>>1&&(R=2,A+=1),0>P){for(var O=-(P>>1)-1,I=0;z>I;++I){var N=e(b[I],O);if(void 0!==N)return N}if(0!==R)for(var I=0;S>I;++I){var N=e(g[I],O);if(void 0!==N)return N}if(1!==R)for(var I=0;C>I;++I){var N=e(m[I],O);if(void 0!==N)return N}0===R?a(g,v,S++,O):1===R?a(m,y,C++,O):2===R&&a(b,x,z++,O)}else{var O=(P>>1)-1;0===R?i(g,v,S--,O):1===R?i(m,y,C--,O):2===R&&i(b,x,z--,O)}}}function l(t,e,r,n,o,s,l,c,u,f,p,m){var y=0,b=2*t,x=e,w=e+t,k=1,A=1;n?A=d:k=d;for(var M=o;s>M;++M){var T=M+k,E=b*M;_[y++]=l[E+x],_[y++]=-T,_[y++]=l[E+w],_[y++]=T}for(var M=u;f>M;++M){var T=M+A,L=b*M;_[y++]=p[L+x],_[y++]=-T}var S=y>>>1;h(_,S);for(var C=0,M=0;S>M;++M){var z=0|_[2*M+1];if(0>z){var T=-z,P=!1;if(T>=d?(P=!n,T-=d):(P=!!n,T-=1),P)a(g,v,C++,T);else{var R=m[T],O=b*T,I=p[O+e+1],N=p[O+e+1+t];t:for(var j=0;C>j;++j){var F=g[j],B=b*F;if(!(ND;++D)if(p[O+D+t]y;++y){var b=y+d,x=p*y;_[f++]=a[x+v],_[f++]=-b,_[f++]=a[x+m],_[f++]=b}for(var y=s;l>y;++y){var b=y+1,w=p*y;_[f++]=c[w+v],_[f++]=-b}var k=f>>>1;h(_,k);for(var A=0,y=0;k>y;++y){var M=0|_[2*y+1];if(0>M){var b=-M;if(b>=d)g[A++]=b-d;else{b-=1;var T=u[b],E=p*b,L=c[E+e+1],S=c[E+e+1+t];t:for(var C=0;A>C;++C){var z=g[C],P=o[z];if(P===T)break;var R=p*z;if(!(SO;++O)if(c[E+O+t]=0;--C)if(g[C]===b){for(var O=C+1;A>O;++O)g[O-1]=g[O];break}--A}}}e.exports={init:n,sweepBipartite:o,sweepComplete:s,scanBipartite:l,scanComplete:c};var u=t("typedarray-pool"),f=t("bit-twiddle"),h=t("./sort"),d=1<<28,p=1024,g=u.mallocInt32(p),v=u.mallocInt32(p),m=u.mallocInt32(p),y=u.mallocInt32(p),b=u.mallocInt32(p),x=u.mallocInt32(p),_=u.mallocDouble(8*p)},{"./sort":56,"bit-twiddle":48,"typedarray-pool":282}],58:[function(t,e,r){(function(e){"use strict";function n(){try{var t=new Uint8Array(1);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function i(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(i()=e?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}function u(t,e){if(l(e),t=a(t,0>e?0:0|g(e)),!o.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;r++)t[r]=0;return t}function f(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!o.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|m(e,r);return t=a(t,n),t.write(e,r),t}function h(t,e){var r=0|g(e.length);t=a(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function d(t,e,r,n){if(e.byteLength,0>r||e.byteLength=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function v(t){return+t!=t&&(t=0),o.alloc(+t)}function m(t,e){if(o.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return X(t).length;default:if(n)return H(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if((void 0===e||0>e)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),0>=r)return"";if(r>>>=0,e>>>=0,e>=r)return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,r);case"utf8":case"utf-8":return L(this,e,r);case"ascii":return C(this,e,r);case"binary":return z(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function x(t,e,r,n){function i(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}var a=1,o=t.length,s=e.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,o/=2,s/=2,r/=2}for(var l=-1,c=0;o>r+c;c++)if(i(t,r+c)===i(e,-1===l?0:c-l)){if(-1===l&&(l=c),c-l+1===s)return(r+l)*a}else-1!==l&&(c-=c-l),l=-1;return-1}function _(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=e.length;if(a%2!==0)throw new Error("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;n>o;o++){var s=parseInt(e.substr(2*o,2),16);if(isNaN(s))return o;t[r+o]=s}return o}function w(t,e,r,n){return W(H(e,t.length-r),t,r,n)}function k(t,e,r,n){return W(G(e),t,r,n)}function A(t,e,r,n){return k(t,e,r,n)}function M(t,e,r,n){return W(X(e),t,r,n)}function T(t,e,r,n){return W(Y(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?K.fromByteArray(t):K.fromByteArray(t.slice(e,r))}function L(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;r>i;){var a=t[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(r>=i+s){var l,c,u,f;switch(s){case 1:128>a&&(o=a);break;case 2:l=t[i+1],128===(192&l)&&(f=(31&a)<<6|63&l,f>127&&(o=f));break;case 3:l=t[i+1],c=t[i+2],128===(192&l)&&128===(192&c)&&(f=(15&a)<<12|(63&l)<<6|63&c,f>2047&&(55296>f||f>57343)&&(o=f));break;case 4:l=t[i+1],c=t[i+2],u=t[i+3],128===(192&l)&&128===(192&c)&&128===(192&u)&&(f=(15&a)<<18|(63&l)<<12|(63&c)<<6|63&u,f>65535&&1114112>f&&(o=f))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return S(n)}function S(t){var e=t.length;if(J>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=J));return r}function C(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function z(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function P(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",a=e;r>a;a++)i+=q(t[a]);return i}function R(t,e,r){for(var n=t.slice(e,r),i="",a=0;at)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,r,n,i,a){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||a>e)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function N(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,a=Math.min(t.length-r,2);a>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function j(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,a=Math.min(t.length-r,4);a>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function F(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("Index out of range")}function B(t,e,r,n,i){return i||F(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),Q.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,i){return i||F(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),Q.write(t,e,r,n,52,8),r+8}function U(t){if(t=V(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function V(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function q(t){return 16>t?"0"+t.toString(16):t.toString(16)}function H(t,e){e=e||1/0;for(var r,n=t.length,i=null,a=[],o=0;n>o;o++){if(r=t.charCodeAt(o),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,128>r){if((e-=1)<0)break;a.push(r)}else if(2048>r){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function G(t){for(var e=[],r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function X(t){return K.toByteArray(U(t))}function W(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}function Z(t){return t!==t}var K=t("base64-js"),Q=t("ieee754"),$=t("isarray");r.Buffer=o,r.SlowBuffer=v,r.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),r.kMaxLength=i(),o.poolSize=8192,o._augment=function(t){return t.__proto__=o.prototype,t},o.from=function(t,e,r){return s(null,t,e,r)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(t,e,r){return c(null,t,e,r)},o.allocUnsafe=function(t){return u(null,t)},o.allocUnsafeSlow=function(t){return u(null,t)},o.isBuffer=function(t){return!(null==t||!t._isBuffer)},o.compare=function(t,e){if(!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,a=Math.min(r,n);a>i;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return n>r?-1:r>n?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!$(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);var r;if(void 0===e)for(e=0,r=0;re;e+=2)b(this,e,e+1);return this},o.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;t>e;e+=4)b(this,e,e+3),b(this,e+1,e+2);return this},o.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?L(this,0,t):y.apply(this,arguments)},o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:0===o.compare(this,t)},o.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},o.prototype.compare=function(t,e,r,n,i){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),0>e||r>t.length||0>n||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var a=i-n,s=r-e,l=Math.min(a,s),c=this.slice(n,i),u=t.slice(e,r),f=0;l>f;++f)if(c[f]!==u[f]){a=c[f],s=u[f];break}return s>a?-1:a>s?1:0},o.prototype.indexOf=function(t,e,r){if("string"==typeof e?(r=e,e=0):e>2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t&&(t=o.from(t,r)),o.isBuffer(t))return 0===t.length?-1:x(this,t,e,r);if("number"==typeof t)return o.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):x(this,[t],e,r);throw new TypeError("val must be string, number or Buffer")},o.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},o.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return w(this,t,e,r);case"ascii":return k(this,t,e,r);case"binary":return A(this,t,e,r);case"base64":return M(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var J=4096;o.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var n;if(o.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=o.prototype;else{var i=e-t;n=new o(i,void 0);for(var a=0;i>a;a++)n[a]=this[a+t]}return n},o.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||O(t,e,this.length);for(var n=this[t],i=1,a=0;++a0&&(i*=256);)n+=this[t+--e]*i;return n},o.prototype.readUInt8=function(t,e){return e||O(t,1,this.length),this[t]},o.prototype.readUInt16LE=function(t,e){return e||O(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUInt16BE=function(t,e){return e||O(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUInt32LE=function(t,e){return e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUInt32BE=function(t,e){return e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||O(t,e,this.length);for(var n=this[t],i=1,a=0;++a=i&&(n-=Math.pow(2,8*e)),n},o.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||O(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a},o.prototype.readInt8=function(t,e){return e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt16BE=function(t,e){e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt32LE=function(t,e){return e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,e){return e||O(t,4,this.length),Q.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return e||O(t,4,this.length),Q.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return e||O(t,8,this.length),Q.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return e||O(t,8,this.length),Q.read(this,t,!1,52,8)},o.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e=0|e,r=0|r,!n){var i=Math.pow(2,8*r)-1;I(this,t,e,r,i,0)}var a=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+a]=t/o&255;return e+r},o.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,1,255,0),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},o.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},o.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},o.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):j(this,t,e,!0),e+4},o.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},o.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var a=0,o=1,s=0;for(this[e]=255&t;++at&&0===s&&0!==this[e+a-1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+r},o.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)0>t&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+r},o.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,1,127,-128),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},o.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},o.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):j(this,t,e,!0),e+4},o.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||I(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},o.prototype.writeFloatLE=function(t,e,r){return B(this,t,e,!0,r)},o.prototype.writeFloatBE=function(t,e,r){return B(this,t,e,!1,r)},o.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},o.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},o.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-er&&n>e)for(i=a-1;i>=0;i--)t[i+e]=this[i+r];else if(1e3>a||!o.TYPED_ARRAY_SUPPORT)for(i=0;a>i;i++)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+a),e);return a},o.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);256>i&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t=255&t);if(0>e||this.length=r)return this;e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var a;if("number"==typeof t)for(a=e;r>a;a++)this[a]=t;else{var s=o.isBuffer(t)?t:H(new o(t,n).toString()),l=s.length;for(a=0;r-e>a;a++)this[a+e]=s[a%l]}return this};var tt=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":30,ieee754:198,isarray:59}],59:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],60:[function(t,e,r){"use strict";function n(t){return[Math.min(t[0],t[1]),Math.max(t[0],t[1])]}function i(t,e){return t[0]-e[0]||t[1]-e[1]}function a(t){return t.map(n).sort(i)}function o(t,e,r){return e in t?t[e]:r}function s(t,e,r){Array.isArray(e)?(r=r||{},e=e||[]):(r=e||{},e=[]);var n=!!o(r,"delaunay",!0),i=!!o(r,"interior",!0),s=!!o(r,"exterior",!0),h=!!o(r,"infinity",!1);if(!i&&!s||0===t.length)return[];var d=l(t,e);if(n||i!==s||h){for(var p=c(t.length,a(e)),g=0;gs)){if(n>i){var l=n;n=i,i=l,l=o,o=s,s=l}e.isConstraint(n,i)||a(t[n],t[i],t[o],t[s])<0&&r.push(n,i)}}function i(t,e){for(var r=[],i=t.length,o=e.stars,s=0;i>s;++s)for(var l=o[s],c=1;cu||e.isConstraint(s,u))){for(var f=l[c-1],h=-1,d=1;dh||a(t[s],t[u],t[f],t[h])<0&&r.push(s,u)}}for(;r.length>0;){for(var u=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],p=1;pf||0>h||a(t[s],t[u],t[f],t[h])>=0||(e.flip(s,u),n(t,e,r,f,s,h),n(t,e,r,s,h,f),n(t,e,r,h,u,f),n(t,e,r,u,f,h))}}var a=t("robust-in-sphere")[4];t("binary-search-bounds");e.exports=i},{"binary-search-bounds":65,"robust-in-sphere":251}],62:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function i(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}function a(t,e){for(var r=t.cells(),a=r.length,o=0;a>o;++o){var s=r[o],l=s[0],c=s[1],u=s[2];u>c?l>c&&(s[0]=c,s[1]=u,s[2]=l):l>u&&(s[0]=u,s[1]=l,s[2]=c)}r.sort(i);for(var f=new Array(a),o=0;oo;++o)for(var s=r[o],y=0;3>y;++y){var l=s[y],c=s[(y+1)%3],b=p[3*o+y]=m.locate(c,l,t.opposite(c,l)),x=g[3*o+y]=t.isConstraint(l,c);0>b&&(x?d.push(o):(h.push(o),f[o]=1),e&&v.push([c,l,-1]))}return m}function o(t,e,r){for(var n=0,i=0;i0||l.length>0;){for(;s.length>0;){var d=s.pop();if(c[d]!==-i){c[d]=i;for(var p=(u[d],0);3>p;++p){var g=h[3*d+p];g>=0&&0===c[g]&&(f[3*d+p]?l.push(g):(s.push(g),c[g]=i))}}}var v=l;l=s,s=v,l.length=0,i=-i}var m=o(u,c,e);return r?m.concat(n.boundary):m}var l=t("binary-search-bounds");e.exports=s;var c=n.prototype;c.locate=function(){var t=[0,0,0];return function(e,r,n){var a=e,o=r,s=n;return n>r?e>r&&(a=r,o=n,s=e):e>n&&(a=n,o=e,s=r),0>a?-1:(t[0]=a,t[1]=o,t[2]=s,l.eq(this.cells,t,i))}}()},{"binary-search-bounds":65}],63:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.a=t,this.b=e,this.idx=r,this.lowerIds=n,this.upperIds=i}function i(t,e,r,n){this.a=t,this.b=e,this.type=r,this.idx=n}function a(t,e){var r=t.a[0]-e.a[0]||t.a[1]-e.a[1]||t.type-e.type;return r?r:t.type!==p&&(r=d(t.a,t.b,e.b))?r:t.idx-e.idx}function o(t,e){return d(t.a,t.b,e)}function s(t,e,r,n,i){for(var a=h.lt(e,n,o),s=h.gt(e,n,o),l=a;s>l;++l){for(var c=e[l],u=c.lowerIds,f=u.length;f>1&&d(r[u[f-2]],r[u[f-1]],n)>0;)t.push([u[f-1],u[f-2],i]),f-=1;u.length=f,u.push(i);for(var p=c.upperIds,f=p.length;f>1&&d(r[p[f-2]],r[p[f-1]],n)<0;)t.push([p[f-2],p[f-1],i]),f-=1;p.length=f,p.push(i)}}function l(t,e){var r;return(r=t.a[0]f;++f)l.push(new i(t[f],null,p,f));for(var f=0;o>f;++f){var h=e[f],d=t[h[0]],m=t[h[1]];d[0]m[0]&&l.push(new i(m,d,v,f),new i(d,m,g,f))}l.sort(a);for(var y=l[0].a[0]-(1+Math.abs(l[0].a[0]))*Math.pow(2,-52),b=[new n([y,1],[y,0],-1,[],[],[],[])],x=[],f=0,_=l.length;_>f;++f){var w=l[f],k=w.type;k===p?s(x,b,t,w.a,w.idx):k===v?c(b,t,w):u(b,t,w)}return x}var h=t("binary-search-bounds"),d=t("robust-orientation")[3],p=0,g=1,v=2;e.exports=f},{"binary-search-bounds":65,"robust-orientation":253}],64:[function(t,e,r){"use strict";function n(t,e){this.stars=t,this.edges=e}function i(t,e,r){for(var n=1,i=t.length;i>n;n+=2)if(t[n-1]===e&&t[n]===r)return t[n-1]=t[i-2],t[n]=t[i-1],void(t.length=i-2)}function a(t,e){for(var r=new Array(t),i=0;t>i;++i)r[i]=[];return new n(r,e)}var o=t("binary-search-bounds");e.exports=a;var s=n.prototype;s.isConstraint=function(){function t(t,e){return t[0]-e[0]||t[1]-e[1]}var e=[0,0];return function(r,n){return e[0]=Math.min(r,n),e[1]=Math.max(r,n),o.eq(this.edges,e,t)>=0}}(),s.removeTriangle=function(t,e,r){var n=this.stars;i(n[t],e,r),i(n[e],r,t),i(n[r],t,e)},s.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},s.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;i>n;n+=2)if(r[n]===t)return r[n-1];return-1},s.flip=function(t,e){var r=this.opposite(t,e),n=this.opposite(e,t);this.removeTriangle(t,e,r),this.removeTriangle(e,t,n),this.addTriangle(t,n,r),this.addTriangle(e,r,n)},s.edges=function(){for(var t=this.stars,e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0,o=i.length;o>a;a+=2)e.push([i[a],i[a+1]]);return e},s.cells=function(){for(var t=this.stars,e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0,o=i.length;o>a;a+=2){var s=i[a],l=i[a+1];r>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],66:[function(t,e,r){"use strict";function n(t){for(var e=1,r=1;rn;++n)if(t[r]i;++i)r+=t[i]*e[i];return r}function i(t){var e=t.length;if(0===e)return[];var r=(t[0].length,o([t.length+1,t.length+1],1)),i=o([t.length+1],1);r[e][e]=0;for(var a=0;e>a;++a){for(var l=0;a>=l;++l)r[l][a]=r[a][l]=2*n(t[a],t[l]);i[a]=n(t[a],t[a])}for(var c=s(r,i),u=0,f=c[e+1],a=0;aa;++a){for(var f=c[a],d=0,l=0;ls;++s)r[s]+=t[a][s]*n[a];return r}var o=t("dup"),s=t("robust-linear-solve");a.barycenetric=i,e.exports=a},{dup:90,"robust-linear-solve":252}],68:[function(t,e,r){function n(t){for(var e=i(t),r=0,n=0;nr?[e,w(e,1/0)]:r>0?[w(e,-(1/0)),e]:[e,e]}function i(t,e){for(var r=new Array(e.length),n=0;n=t.length)return o[e-t.length];var r=t[e];return[y(r[0]),y(r[1])]}for(var o=[],s=0;s=0;--s){var g=n[s],c=g[0],v=e[c],m=v[0],x=v[1],w=t[m],A=t[x];if((w[0]-A[0]||w[1]-A[1])<0){var M=m;m=x,x=M}v[0]=m;var T,E=v[1]=g[1];for(i&&(T=v[2]);s>0&&n[s-1][0]===c;){var g=n[--s],L=g[1];i?e.push([E,L,T]):e.push([E,L]),E=L}i?e.push([E,x,T]):e.push([E,x])}return o}function c(t,e,r){for(var i=t.length+e.length,a=new g(i),o=r,s=0;ss;++s){var p=a.find(s);p===s?(d[s]=f,t[f++]=t[s]):(h=!1,d[s]=-1)}if(t.length=f,h)return null;for(var s=0;i>s;++s)d[s]<0&&(d[s]=d[a.find(s)]);return d}function u(t,e){return t[0]-e[0]||t[1]-e[1]}function f(t,e){var r=t[0]-e[0]||t[1]-e[1];return r?r:t[2]e[2]?1:0}function h(t,e,r){if(0!==t.length){if(e)for(var n=0;n0||d.length>0}function p(t,e,r){var n,i=!1;if(r){n=e;for(var a=new Array(e.length),o=0;on;++n)e=t[n],e=e.toString(16),r+=("00"+e).substr(e.length);return r}function i(t){return"rgba("+t.join(",")+")"}var a=t("arraytools"),o=t("clone"),s=t("./colorScales");e.exports=function(t){var e,r,l,c,u,f,h,d,p,g,v,m,y,b=[],x=[],_=[],w=[];if(a.isPlainObject(t)||(t={}),p=t.nshades||72,d=t.format||"hex",h=t.colormap,h||(h="jet"),"string"==typeof h){if(h=h.toLowerCase(),!s[h])throw Error(h+" not a supported colorscale");f=o(s[h])}else{if(!Array.isArray(h))throw Error("unsupported colormap option",h);f=o(h)}if(f.length>p)throw new Error(h+" map requires nshades to be at least size "+f.length);for(v=Array.isArray(t.alpha)?2!==t.alpha.length?[1,1]:o(t.alpha):"number"==typeof t.alpha?[t.alpha,t.alpha]:[1,1],e=f.map(function(t){return Math.round(t.index*p)}),v[0]<0&&(v[0]=0),v[1]<0&&(v[0]=0),v[0]>1&&(v[0]=1),v[1]>1&&(v[0]=1),y=0;y=0&&r[3]<=1||(r[3]=v[0]+(v[1]-v[0])*m);for(y=0;y=0}function i(t,e,r,i){var s=a(e,r,i);if(0===s){var l=o(a(t,e,r)),c=o(a(t,e,i));if(l===c){if(0===l){var u=n(t,e,r),f=n(t,e,i);return u===f?0:u?1:-1}return 0}return 0===c?l>0?-1:n(t,e,i)?-1:1:0===l?c>0?1:n(t,e,r)?1:-1:o(c-l)}var h=a(t,e,r);if(h>0)return s>0&&a(t,e,i)>0?1:-1;if(0>h)return s>0||a(t,e,i)>0?1:-1;var d=a(t,e,i);return d>0?1:n(t,e,r)?1:-1}e.exports=i;var a=t("robust-orientation"),o=t("signum"),s=t("two-sum"),l=t("robust-product"),c=t("robust-sum")},{"robust-orientation":253,"robust-product":254,"robust-sum":258,signum:259,"two-sum":281}],75:[function(t,e,r){function n(t,e){return t-e}function i(t,e){var r=t.length,i=t.length-e.length;if(i)return i;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:return t[0]+t[1]-e[0]-e[1]||a(t[0],t[1])-a(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(i=o+t[2]-(s+e[2]))return i;var l=a(t[0],t[1]),c=a(e[0],e[1]);return a(l,t[2])-a(c,e[2])||a(l+t[2],o)-a(c+e[2],s);case 4:var u=t[0],f=t[1],h=t[2],d=t[3],p=e[0],g=e[1],v=e[2],m=e[3];return u+f+h+d-(p+g+v+m)||a(u,f,h,d)-a(p,g,v,m,p)||a(u+f,u+h,u+d,f+h,f+d,h+d)-a(p+g,p+v,p+m,g+v,g+m,v+m)||a(u+f+h,u+f+d,u+h+d,f+h+d)-a(p+g+v,p+g+m,p+v+m,g+v+m);default:for(var y=t.slice().sort(n),b=e.slice().sort(n),x=0;r>x;++x)if(i=y[x]-b[x])return i;return 0}}e.exports=i;var a=Math.min},{}],76:[function(t,e,r){"use strict";function n(t,e){return i(t,e)||a(t)-a(e)}var i=t("compare-cell"),a=t("cell-orientation");e.exports=n},{"cell-orientation":66,"compare-cell":75}],77:[function(t,e,r){"use strict";function n(t){var e=t.length;if(0===e)return[];if(1===e)return[[0]];var r=t[0].length;return 0===r?[]:1===r?i(t):2===r?a(t):o(t,r)}var i=t("./lib/ch1d"),a=t("./lib/ch2d"),o=t("./lib/chnd");e.exports=n},{"./lib/ch1d":78,"./lib/ch2d":79,"./lib/chnd":80}],78:[function(t,e,r){"use strict";function n(t){for(var e=0,r=0,n=1;nt[r][0]&&(r=n);return r>e?[[e],[r]]:e>r?[[r],[e]]:[[e]]}e.exports=n},{}],79:[function(t,e,r){"use strict";function n(t){var e=i(t),r=e.length;if(2>=r)return[];for(var n=new Array(r),a=e[r-1],o=0;r>o;++o){var s=e[o];n[o]=[a,s],a=s}return n}e.exports=n;var i=t("monotone-convex-hull-2d")},{"monotone-convex-hull-2d":210}],80:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),i=0;ii;++i)e.indexOf(i)<0&&(n[a++]=t[i]);return n}function i(t,e){for(var r=t.length,n=e.length,i=0;r>i;++i)for(var a=t[i],o=0;os)a[o]=e[s];else{s-=n;for(var l=0;n>l;++l)s>=e[l]&&(s+=1);a[o]=s}}return t}function a(t,e){try{return o(t,!0)}catch(r){var a=s(t);if(a.length<=e)return[];var l=n(t,a),c=o(l,!0);return i(c,a)}}e.exports=a;var o=t("incremental-convex-hull"),s=t("affine-hull")},{"affine-hull":24,"incremental-convex-hull":199}],81:[function(t,e,r){e.exports={AFG:"afghan",ALA:"\\b\\wland",ALB:"albania",DZA:"algeria",ASM:"^(?=.*americ).*samoa",AND:"andorra",AGO:"angola",AIA:"anguill?a",ATA:"antarctica",ATG:"antigua",ARG:"argentin",ARM:"armenia",ABW:"^(?!.*bonaire).*\\baruba",AUS:"australia",AUT:"^(?!.*hungary).*austria|\\baustri.*\\bemp",AZE:"azerbaijan",BHS:"bahamas",BHR:"bahrain",BGD:"bangladesh|^(?=.*east).*paki?stan",BRB:"barbados",BLR:"belarus|byelo",BEL:"^(?!.*luxem).*belgium",BLZ:"belize|^(?=.*british).*honduras",BEN:"benin|dahome",BMU:"bermuda",BTN:"bhutan",BOL:"bolivia",BES:"^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands",BIH:"herzegovina|bosnia",BWA:"botswana|bechuana",BVT:"bouvet",BRA:"brazil",IOT:"british.?indian.?ocean",BRN:"brunei",BGR:"bulgaria",BFA:"burkina|\\bfaso|upper.?volta",BDI:"burundi",KHM:"cambodia|kampuchea|khmer",CMR:"cameroon",CAN:"canada",CPV:"verde",CYM:"cayman",CAF:"\\bcentral.african.republic",TCD:"\\bchad",CHL:"\\bchile",CHN:"^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai).*china",CXR:"christmas",CCK:"\\bcocos|keeling",COL:"colombia",COM:"comoro",COD:"\\bdem.*congo|congo.*\\bdem|congo.*\\bdr|\\bdr.*congo|belgian.?congo|congo.?free.?state|kinshasa|zaire|l.opoldville|drc|droc|rdc",COG:"^(?!.*\\bdem)(?!.*\\bdr)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l.opoldville)(?!.*free).*\\bcongo",COK:"\\bcook",CRI:"costa.?rica",CIV:"ivoire|ivory",HRV:"croatia",CUB:"\\bcuba",CUW:"^(?!.*bonaire).*\\bcura(c|\xe7)ao",CYP:"cyprus",CZE:"^(?=.*rep).*czech|czechia|bohemia",CSK:"czechoslovakia",DNK:"denmark",DJI:"djibouti",DMA:"dominica(?!n)",DOM:"dominican.rep",ECU:"ecuador",EGY:"egypt",SLV:"el.?salvador",GNQ:"guine.*eq|eq.*guine|^(?=.*span).*guinea",ERI:"eritrea",EST:"estonia",ETH:"ethiopia|abyssinia",FLK:"falkland|malvinas",FRO:"faroe|faeroe",FJI:"fiji",FIN:"finland",FRA:"^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul",GUF:"^(?=.*french).*guiana",PYF:"french.?polynesia|tahiti",ATF:"french.?southern",GAB:"gabon",GMB:"gambia",GEO:"^(?!.*south).*georgia",DDR:"german.?democratic.?republic|democratic.?republic.*germany|east.germany",DEU:"^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german",GHA:"ghana|gold.?coast",GIB:"gibraltar",GRC:"greece|hellenic|hellas",GRL:"greenland",GRD:"grenada",GLP:"guadeloupe",GUM:"\\bguam",GTM:"guatemala",GGY:"guernsey",GIN:"^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea",GNB:"bissau|^(?=.*portu).*guinea",GUY:"guyana|british.?guiana",HTI:"haiti",HMD:"heard.*mcdonald",VAT:"holy.?see|vatican|papal.?st",HND:"^(?!.*brit).*honduras",HKG:"hong.?kong",HUN:"^(?!.*austr).*hungary",ISL:"iceland",IND:"india(?!.*ocea)",IDN:"indonesia",IRN:"\\biran|persia",IRQ:"\\biraq|mesopotamia",IRL:"ireland",IMN:"^(?=.*isle).*\\bman",ISR:"israel",ITA:"italy",JAM:"jamaica",JPN:"japan",JEY:"jersey",JOR:"jordan",KAZ:"kazak",KEN:"kenya|british.?east.?africa|east.?africa.?prot",KIR:"kiribati",PRK:"^(?=.*democrat).*\\bkorea|^(?=.*people).*\\bkorea|^(?=.*north).*\\bkorea|dprk",KOR:"^(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea",KWT:"kuwait",KGZ:"kyrgyz|kirghiz",LAO:"\\blaos?\\b",LVA:"latvia",LBN:"lebanon",LSO:"lesotho|basuto",LBR:"liberia",LBY:"libya",LIE:"liechtenstein",LTU:"lithuania",LUX:"^(?!.*belg).*luxem",MAC:"maca(o|u)",MKD:"macedonia|fyrom",MDG:"madagascar|malagasy",MWI:"malawi|nyasa",MYS:"malaysia",MDV:"maldive",MLI:"\\bmali\\b",MLT:"\\bmalta",MHL:"marshall",MTQ:"martinique",MRT:"mauritania",MUS:"mauritius",MYT:"\\bmayotte",MEX:"\\bmexic",FSM:"micronesia",MDA:"moldov|b(a|e)ssarabia",MCO:"monaco",MNG:"mongolia",MNE:"^(?!.*serbia).*montenegro",MSR:"montserrat",MAR:"morocco|\\bmaroc",MOZ:"mozambique",MMR:"myanmar|burma",NAM:"namibia",NRU:"nauru",NPL:"nepal",NLD:"^(?!.*\\bant)(?!.*\\bcarib).*netherlands",ANT:"^(?=.*\\bant).*(nether|dutch)",NCL:"new.?caledonia",NZL:"new.?zealand",NIC:"nicaragua",NER:"\\bniger(?!ia)",NGA:"nigeria",NIU:"niue",NFK:"norfolk",MNP:"mariana",NOR:"norway",OMN:"\\boman|trucial",PAK:"^(?!.*east).*paki?stan",PLW:"palau",PSE:"palestin|\\bgaza|west.?bank",PAN:"panama",PNG:"papua|new.?guinea",PRY:"paraguay",PER:"peru",PHL:"philippines",PCN:"pitcairn",POL:"poland",PRT:"portugal",PRI:"puerto.?rico",QAT:"qatar",REU:"r(e|\xe9)union",ROU:"r(o|u|ou)mania",RUS:"\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics",RWA:"rwanda",BLM:"barth(e|\xe9)lemy",SHN:"helena",KNA:"kitts|\\bnevis",LCA:"\\blucia",MAF:"^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)",SPM:"miquelon",VCT:"vincent",WSM:"^(?!.*amer).*samoa",SMR:"san.?marino",STP:"\\bs(a|\xe3)o.?tom(e|\xe9)",SAU:"\\bsa\\w*.?arabia",SEN:"senegal",SRB:"^(?!.*monte).*serbia",SYC:"seychell",SLE:"sierra",SGP:"singapore",SXM:"^(?!.*martin)(?!.*saba).*maarten",SVK:"^(?!.*cze).*slovak",SVN:"slovenia",SLB:"solomon",SOM:"somali",ZAF:"\\bs\\w*.?africa",SGS:"south.?georgia|sandwich",SSD:"\\bs\\w*.?sudan",ESP:"spain",LKA:"sri.?lanka|ceylon",SDN:"^(?!.*\\bs(?!u)).*sudan",SUR:"surinam|dutch.?guiana",SJM:"svalbard",SWZ:"swaziland",SWE:"sweden",CHE:"switz|swiss",SYR:"syria",TWN:"taiwan|taipei|formosa",TJK:"tajik",TZA:"tanzania",THA:"thailand|\\bsiam",TLS:"^(?=.*leste).*timor|^(?=.*east).*timor",TGO:"togo",TKL:"tokelau",TON:"tonga",TTO:"trinidad|tobago",TUN:"tunisia",TUR:"turkey",TKM:"turkmen",TCA:"turks",TUV:"tuvalu",UGA:"uganda",UKR:"ukrain",ARE:"emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em",GBR:"united.?kingdom|britain|^u\\.?k\\.?$",USA:"united.?states|\\bu\\.?s\\.?a\\.?\\b|\\bu\\.?s\\.?\\b(?!.*islands)",UMI:"minor.?outlying.?is",URY:"uruguay",UZB:"uzbek",VUT:"vanuatu|new.?hebrides",VEN:"venezuela",VNM:"^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam",VGB:"^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin",VIR:"^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin",WLF:"futuna|wallis",ESH:"western.sahara",YEM:"^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen",YMD:"^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen",YUG:"yugoslavia",ZMB:"zambia|northern.?rhodesia",EAZ:"zanzibar",ZWE:"zimbabwe|^(?!.*northern).*rhodesia"}},{}],82:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=6*i*i-6*i,s=3*i*i-4*i+1,l=-6*i*i+6*i,c=3*i*i-2*i;if(t.length){a||(a=new Array(t.length));for(var u=t.length-1;u>=0;--u)a[u]=o*t[u]+s*e[u]+l*r[u]+c*n[u];return a}return o*t+s*e+l*r[u]+c*n}function i(t,e,r,n,i,a){var o=i-1,s=i*i,l=o*o,c=(1+2*i)*l,u=i*l,f=s*(3-2*i),h=s*o;if(t.length){a||(a=new Array(t.length));for(var d=t.length-1;d>=0;--d)a[d]=c*t[d]+u*e[d]+f*r[d]+h*n[d];return a}return c*t+u*e+f*r+h*n}e.exports=i,e.exports.derivative=n},{}],83:[function(t,e,r){"use strict";function n(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function i(t){var e=new n;e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===o){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(i),ir.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,a(e)}var a=t("./lib/thunk.js");e.exports=i},{"./lib/thunk.js":85}],84:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],c=[],u=0,f=0;for(n=0;a>n;++n)c.push(["i",n,"=0"].join(""));for(i=0;o>i;++i)for(n=0;a>n;++n)f=u,u=t[n],0===n?c.push(["d",i,"s",n,"=t",i,"p",u].join("")):c.push(["d",i,"s",n,"=(t",i,"p",u,"-s",f,"*t",i,"p",f,")"].join(""));for(l.push("var "+c.join(",")),n=a-1;n>=0;--n)u=t[n],l.push(["for(i",n,"=0;i",n,"n;++n){for(f=u,u=t[n],i=0;o>i;++i)l.push(["p",i,"+=d",i,"s",n].join(""));s&&(n>0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",u,"]"].join(""))),l.push("}")}return l.join("\n")}function i(t,e,r,i){for(var a=e.length,o=r.arrayArgs.length,s=r.blockSize,l=r.indexArgs.length>0,c=[],u=0;o>u;++u)c.push(["var offset",u,"=p",u].join(""));for(var u=t;a>u;++u)c.push(["for(var j"+u+"=SS[",e[u],"]|0;j",u,">0;){"].join("")),c.push(["if(j",u,"<",s,"){"].join("")),c.push(["s",e[u],"=j",u].join("")),c.push(["j",u,"=0"].join("")),c.push(["}else{s",e[u],"=",s].join("")),c.push(["j",u,"-=",s,"}"].join("")),l&&c.push(["index[",e[u],"]=j",u].join(""));for(var u=0;o>u;++u){for(var f=["offset"+u],h=t;a>h;++h)f.push(["j",h,"*t",u,"p",e[h]].join(""));c.push(["p",u,"=(",f.join("+"),")"].join(""))}c.push(n(e,r,i));for(var u=t;a>u;++u)c.push("}");return c.join("\n")}function a(t){for(var e=0,r=t[0].length;r>e;){for(var n=1;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}function l(t,e){for(var r=e[1].length-Math.abs(t.arrayBlockIndices[0])|0,l=new Array(t.arrayArgs.length),u=new Array(t.arrayArgs.length),f=0;fy;++y)_.push(["s",y,"=SS[",y,"]"].join(""));for(var f=0;fy;++y)_.push(["t",f,"p",y,"=t",f,"[",p[f]+y,"]"].join(""));for(var y=0;y0&&_.push("shape=SS.slice(0)"),t.indexArgs.length>0){for(var w=new Array(r),f=0;r>f;++f)w[f]="0";_.push(["index=[",w.join(","),"]"].join(""))}for(var f=0;f3&&x.push(o(t.pre,t,u));var T=o(t.body,t,u),E=a(v);r>E?x.push(i(E,v[0],t,T)):x.push(n(v[0],t,T)),t.post.body.length>3&&x.push(o(t.post,t,u)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+x.join("\n")+"\n----------");var L=[t.funcName||"unnamed","_cwise_loop_",l[0].join("s"),"m",E,s(u)].join(""),S=new Function(["function ",L,"(",b.join(","),"){",x.join("\n"),"} return ",L].join(""));return S()}var c=t("uniq");e.exports=l},{uniq:284}],85:[function(t,e,r){"use strict";function n(t){var e=["'use strict'","var CACHED={}"],r=[],n=t.funcName+"_cwise_thunk";e.push(["return function ",n,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],c=[],u=0;u0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[u]))),c.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[u])+"]"))}t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),e.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}"));for(var u=0;ut?-1:t>e?1:t>=e?0:NaN}function a(t){return null===t?NaN:+t}function o(t){return!isNaN(t)}function s(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}function l(t){return t.length}function c(t){for(var e=1;t*e%1;)e*=10;return e}function u(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function f(){this._=Object.create(null)}function h(t){return(t+="")===ko||t[0]===Ao?Ao+t:t}function d(t){return(t+="")[0]===Ao?t.slice(1):t}function p(t){return h(t)in this._}function g(t){return(t=h(t))in this._&&delete this._[t]}function v(){var t=[];for(var e in this._)t.push(d(e)); -return t}function m(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function b(){this._=Object.create(null)}function x(t){return t}function _(t,e,r){return function(){var n=r.apply(e,arguments);return n===e?t:n}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var r=0,n=Mo.length;n>r;++r){var i=Mo[r]+e;if(i in t)return i}}function k(){}function A(){}function M(t){function e(){for(var e,n=r,i=-1,a=n.length;++ir;r++)for(var i,a=t[r],o=0,s=a.length;s>o;o++)(i=a[o])&&e(i,o,r);return t}function Y(t){return Eo(t,Oo),t}function X(t){var e,r;return function(n,i,a){var o,s=t[a].update,l=s.length;for(a!=r&&(r=a,e=0),i>=e&&(e=i+1);!(o=s[e])&&++e0&&(t=t.slice(0,s));var c=Io.get(t);return c&&(t=c,l=K),s?e?i:n:e?k:a}function Z(t,e){return function(r){var n=co.event;co.event=r,e[0]=this.__data__;try{t.apply(this,e)}finally{co.event=n}}}function K(t,e){var r=Z(t,e);return function(t){var e=this,n=t.relatedTarget;n&&(n===e||8&n.compareDocumentPosition(e))||r.call(e,t)}}function Q(t){var r=".dragsuppress-"+ ++jo,i="click"+r,a=co.select(n(t)).on("touchmove"+r,T).on("dragstart"+r,T).on("selectstart"+r,T);if(null==No&&(No="onselectstart"in t?!1:w(t.style,"userSelect")),No){var o=e(t).style,s=o[No];o[No]="none"}return function(t){if(a.on(r,null),No&&(o[No]=s),t){var e=function(){a.on(i,null)};a.on(i,function(){T(),e()},!0),setTimeout(e,0)}}}function $(t,e){e.changedTouches&&(e=e.changedTouches[0]);var r=t.ownerSVGElement||t;if(r.createSVGPoint){var i=r.createSVGPoint();if(0>Fo){var a=n(t);if(a.scrollX||a.scrollY){r=co.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();Fo=!(o.f||o.e),r.remove()}}return Fo?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}function J(){return co.event.changedTouches[0].identifier}function tt(t){return t>0?1:0>t?-1:0}function et(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function rt(t){return t>1?0:-1>t?Uo:Math.acos(t)}function nt(t){return t>1?Ho:-1>t?-Ho:Math.asin(t)}function it(t){return((t=Math.exp(t))-1/t)/2}function at(t){return((t=Math.exp(t))+1/t)/2}function ot(t){return((t=Math.exp(2*t))-1)/(t+1)}function st(t){return(t=Math.sin(t/2))*t}function lt(){}function ct(t,e,r){return this instanceof ct?(this.h=+t,this.s=+e,void(this.l=+r)):arguments.length<2?t instanceof ct?new ct(t.h,t.s,t.l):kt(""+t,At,ct):new ct(t,e,r)}function ut(t,e,r){function n(t){return t>360?t-=360:0>t&&(t+=360),60>t?a+(o-a)*t/60:180>t?o:240>t?a+(o-a)*(240-t)/60:a}function i(t){return Math.round(255*n(t))}var a,o;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:0>e?0:e>1?1:e,r=0>r?0:r>1?1:r,o=.5>=r?r*(1+e):r+e-r*e,a=2*r-o,new bt(i(t+120),i(t),i(t-120))}function ft(t,e,r){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+r)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof dt?gt(t.l,t.a,t.b):gt((t=Mt((t=co.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,r)}function ht(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new dt(r,Math.cos(t*=Go)*e,Math.sin(t)*e)}function dt(t,e,r){return this instanceof dt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof dt?new dt(t.l,t.a,t.b):t instanceof ft?ht(t.h,t.c,t.l):Mt((t=bt(t)).r,t.g,t.b):new dt(t,e,r)}function pt(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return i=vt(i)*rs,n=vt(n)*ns,a=vt(a)*is,new bt(yt(3.2404542*i-1.5371385*n-.4985314*a),yt(-.969266*i+1.8760108*n+.041556*a),yt(.0556434*i-.2040259*n+1.0572252*a))}function gt(t,e,r){return t>0?new ft(Math.atan2(r,e)*Yo,Math.sqrt(e*e+r*r),t):new ft(NaN,NaN,t)}function vt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function mt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function bt(t,e,r){return this instanceof bt?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof bt?new bt(t.r,t.g,t.b):kt(""+t,bt,ut):new bt(t,e,r)}function xt(t){return new bt(t>>16,t>>8&255,255&t)}function _t(t){return xt(t)+""}function wt(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function kt(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(Et(i[0]),Et(i[1]),Et(i[2]))}return(a=ss.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o=o>>4|o,s=240&a,s=s>>4|s,l=15&a,l=l<<4|l):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function At(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=.5>l?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(r>e?6:0):e==o?(r-t)/s+2:(t-e)/s+4,n*=60):(n=NaN,i=l>0&&1>l?0:n),new ct(n,i,l)}function Mt(t,e,r){t=Tt(t),e=Tt(e),r=Tt(r);var n=mt((.4124564*t+.3575761*e+.1804375*r)/rs),i=mt((.2126729*t+.7151522*e+.072175*r)/ns),a=mt((.0193339*t+.119192*e+.9503041*r)/is);return dt(116*i-16,500*(n-i),200*(i-a))}function Tt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Et(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function Lt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,r,n){return 2===arguments.length&&"function"==typeof r&&(n=r,r=null),Ct(e,r,t,n)}}function Ct(t,e,r,n){function i(){var t,e=l.status;if(!e&&Pt(l)||e>=200&&300>e||304===e){try{t=r.call(a,l)}catch(n){return void o.error.call(a,n)}o.load.call(a,t)}else o.error.call(a,l)}var a={},o=co.dispatch("beforesend","progress","load","error"),s={},l=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(t)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(t){var e=co.event;co.event=t;try{o.progress.call(a,l)}finally{co.event=e}},a.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",a)},a.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",a):e},a.responseType=function(t){return arguments.length?(c=t,a):c},a.response=function(t){return r=t,a},["get","post"].forEach(function(t){a[t]=function(){return a.send.apply(a,[t].concat(fo(arguments)))}}),a.send=function(r,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),l.open(r,t,!0),null==e||"accept"in s||(s.accept=e+",*/*"),l.setRequestHeader)for(var u in s)l.setRequestHeader(u,s[u]);return null!=e&&l.overrideMimeType&&l.overrideMimeType(e),null!=c&&(l.responseType=c),null!=i&&a.on("error",i).on("load",function(t){i(null,t)}),o.beforesend.call(a,l),l.send(null==n?null:n),a},a.abort=function(){return l.abort(),a},co.rebind(a,o,"on"),null==n?a:a.get(zt(n))}function zt(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}function Pt(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Rt(t,e,r){var n=arguments.length;2>n&&(e=0),3>n&&(r=Date.now());var i=r+e,a={c:t,t:i,n:null};return cs?cs.n=a:ls=a,cs=a,us||(fs=clearTimeout(fs),us=1,hs(Ot)),a}function Ot(){var t=It(),e=Nt()-t;e>24?(isFinite(e)&&(clearTimeout(fs),fs=setTimeout(Ot,e)),us=0):(us=1,hs(Ot))}function It(){for(var t=Date.now(),e=ls;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Nt(){for(var t,e=ls,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}}function Bt(t){var e=t.decimal,r=t.thousands,n=t.grouping,i=t.currency,a=n&&r?function(t,e){for(var i=t.length,a=[],o=0,s=n[0],l=0;i>0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>e));)s=n[o=(o+1)%n.length];return a.reverse().join(r)}:x;return function(t){var r=ps.exec(t),n=r[1]||" ",o=r[2]||">",s=r[3]||"-",l=r[4]||"",c=r[5],u=+r[6],f=r[7],h=r[8],d=r[9],p=1,g="",v="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(c||"0"===n&&"="===o)&&(c=n="0",o="="),d){case"n":f=!0,d="g";break;case"%":p=100,v="%",d="f";break;case"p":p=100,v="%",d="r";break;case"b":case"o":case"x":case"X":"#"===l&&(g="0"+d.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,d="r"}"$"===l&&(g=i[0],v=i[1]),"r"!=d||h||(d="g"),null!=h&&("g"==d?h=Math.max(1,Math.min(21,h)):"e"!=d&&"f"!=d||(h=Math.max(0,Math.min(20,h)))),d=gs.get(d)||Dt;var b=c&&f;return function(t){var r=v;if(m&&t%1)return"";var i=0>t||0===t&&0>1/t?(t=-t,"-"):"-"===s?"":s;if(0>p){var l=co.formatPrefix(t,h);t=l.scale(t),r=l.symbol+v}else t*=p;t=d(t,h);var x,_,w=t.lastIndexOf(".");if(0>w){var k=y?t.lastIndexOf("e"):-1;0>k?(x=t,_=""):(x=t.substring(0,k),_=t.substring(k))}else x=t.substring(0,w),_=e+t.substring(w+1);!c&&f&&(x=a(x,1/0));var A=g.length+x.length+_.length+(b?0:i.length),M=u>A?new Array(A=u-A+1).join(n):"";return b&&(x=a(M+x,M.length?u-_.length:1/0)),i+=g,t=x+_,("<"===o?i+t+M:">"===o?M+i+t:"^"===o?M.substring(0,A>>=1)+i+t+M.substring(A):i+(b?t:M+t))+r}}}function Dt(t){return t+""}function Ut(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Vt(t,e,r){function n(e){var r=t(e),n=a(r,1);return n-e>e-r?r:n}function i(r){return e(r=t(new ms(r-1)),1),r}function a(t,r){return e(t=new ms(+t),r),t}function o(t,n,a){var o=i(t),s=[];if(a>1)for(;n>o;)r(o)%a||s.push(new Date(+o)),e(o,1);else for(;n>o;)s.push(new Date(+o)),e(o,1);return s}function s(t,e,r){try{ms=Ut;var n=new Ut;return n._=t,o(n,e,r)}finally{ms=Date}}t.floor=t,t.round=n,t.ceil=i,t.offset=a,t.range=o;var l=t.utc=qt(t);return l.floor=l,l.round=qt(n),l.ceil=qt(i),l.offset=qt(a),l.range=s,t}function qt(t){return function(e,r){try{ms=Ut;var n=new Ut;return n._=e,t(n,r)._}finally{ms=Date}}}function Ht(t){function e(t){function e(e){for(var r,i,a,o=[],s=-1,l=0;++ss;){if(n>=c)return-1;if(i=e.charCodeAt(s++),37===i){if(o=e.charAt(s++),a=S[o in bs?e.charAt(s++):o],!a||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}function n(t,e,r){w.lastIndex=0;var n=w.exec(e.slice(r));return n?(t.w=k.get(n[0].toLowerCase()),r+n[0].length):-1}function i(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.w=_.get(n[0].toLowerCase()),r+n[0].length):-1}function a(t,e,r){T.lastIndex=0;var n=T.exec(e.slice(r));return n?(t.m=E.get(n[0].toLowerCase()),r+n[0].length):-1}function o(t,e,r){A.lastIndex=0;var n=A.exec(e.slice(r));return n?(t.m=M.get(n[0].toLowerCase()),r+n[0].length):-1}function s(t,e,n){return r(t,L.c.toString(),e,n)}function l(t,e,n){return r(t,L.x.toString(),e,n)}function c(t,e,n){return r(t,L.X.toString(),e,n)}function u(t,e,r){var n=b.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)}var f=t.dateTime,h=t.date,d=t.time,p=t.periods,g=t.days,v=t.shortDays,m=t.months,y=t.shortMonths;e.utc=function(t){function r(t){try{ms=Ut;var e=new ms;return e._=t,n(e)}finally{ms=Date}}var n=e(t);return r.parse=function(t){try{ms=Ut;var e=n.parse(t);return e&&e._}finally{ms=Date}},r.toString=n.toString,r},e.multi=e.utc.multi=ue;var b=co.map(),x=Yt(g),_=Xt(g),w=Yt(v),k=Xt(v),A=Yt(m),M=Xt(m),T=Yt(y),E=Xt(y);p.forEach(function(t,e){b.set(t.toLowerCase(),e)});var L={a:function(t){return v[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return m[t.getMonth()]},c:e(f),d:function(t,e){return Gt(t.getDate(),e,2)},e:function(t,e){return Gt(t.getDate(),e,2)},H:function(t,e){return Gt(t.getHours(),e,2)},I:function(t,e){return Gt(t.getHours()%12||12,e,2)},j:function(t,e){return Gt(1+vs.dayOfYear(t),e,3)},L:function(t,e){return Gt(t.getMilliseconds(),e,3)},m:function(t,e){return Gt(t.getMonth()+1,e,2)},M:function(t,e){return Gt(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Gt(t.getSeconds(),e,2)},U:function(t,e){return Gt(vs.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Gt(vs.mondayOfYear(t),e,2)},x:e(h),X:e(d),y:function(t,e){return Gt(t.getFullYear()%100,e,2)},Y:function(t,e){return Gt(t.getFullYear()%1e4,e,4)},Z:le,"%":function(){return"%"}},S={a:n,A:i,b:a,B:o,c:s,d:re,e:re,H:ie,I:ie,j:ne,L:se,m:ee,M:ae,p:u,S:oe,U:Zt,w:Wt,W:Kt,x:l,X:c,y:$t,Y:Qt,Z:Jt,"%":ce};return e}function Gt(t,e,r){var n=0>t?"-":"",i=(n?-t:t)+"",a=i.length;return n+(r>a?new Array(r-a+1).join(e)+i:i)}function Yt(t){return new RegExp("^(?:"+t.map(co.requote).join("|")+")","i")}function Xt(t){for(var e=new f,r=-1,n=t.length;++r68?1900:2e3)}function ee(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function re(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function ne(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function ie(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function ae(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function oe(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function se(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function le(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=wo(e)/60|0,i=wo(e)%60;return r+Gt(n,"0",2)+Gt(i,"0",2)}function ce(t,e,r){_s.lastIndex=0;var n=_s.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function ue(t){for(var e=t.length,r=-1;++r=0?1:-1,s=o*r,l=Math.cos(e),c=Math.sin(e),u=a*c,f=i*l+u*Math.cos(s),h=u*o*Math.sin(s);Es.add(Math.atan2(h,f)),n=t,i=l,a=c}var e,r,n,i,a;Ls.point=function(o,s){Ls.point=t,n=(e=o)*Go,i=Math.cos(s=(r=s)*Go/2+Uo/4),a=Math.sin(s)},Ls.lineEnd=function(){t(e,r)}}function me(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function be(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function xe(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ke(t){return[Math.atan2(t[1],t[0]),nt(t[2])]}function Ae(t,e){return wo(t[0]-e[0])s;++s)i.point((r=t[s])[0],r[1]);return void i.lineEnd()}var l=new Oe(r,t,null,!0),c=new Oe(r,null,l,!1);l.o=c,a.push(l),o.push(c),l=new Oe(n,t,null,!1),c=new Oe(n,null,l,!0),l.o=c,a.push(l),o.push(c)}}),o.sort(e),Re(a),Re(o),a.length){for(var s=0,l=r,c=o.length;c>s;++s)o[s].e=l=!l;for(var u,f,h=a[0];;){for(var d=h,p=!0;d.v;)if((d=d.n)===h)return;u=d.z,i.lineStart();do{if(d.v=d.o.v=!0,d.e){if(p)for(var s=0,c=u.length;c>s;++s)i.point((f=u[s])[0],f[1]);else n(d.x,d.n.x,1,i);d=d.n}else{if(p){u=d.p.z;for(var s=u.length-1;s>=0;--s)i.point((f=u[s])[0],f[1])}else n(d.x,d.p.x,-1,i);d=d.p}d=d.o,u=d.z,p=!p}while(!d.v);i.lineEnd()}}}function Re(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n0){for(_||(a.polygonStart(),_=!0),a.lineStart();++o1&&2&e&&r.push(r.pop().concat(r.shift())),d.push(r.filter(Ne))}var d,p,g,v=e(a),m=i.invert(n[0],n[1]),y={point:o,lineStart:l,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=f,y.lineEnd=h,d=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=l,y.lineEnd=c,d=co.merge(d);var t=Ve(m,p);d.length?(_||(a.polygonStart(),_=!0),Pe(d,Fe,t,r,a)):t&&(_||(a.polygonStart(),_=!0),a.lineStart(),r(null,null,1,a),a.lineEnd()),_&&(a.polygonEnd(),_=!1),d=p=null},sphere:function(){a.polygonStart(),a.lineStart(),r(null,null,1,a),a.lineEnd(),a.polygonEnd()}},b=je(),x=e(b),_=!1;return y}}function Ne(t){return t.length>1}function je(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:k,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Fe(t,e){return((t=t.x)[0]<0?t[1]-Ho-Bo:Ho-t[1])-((e=e.x)[0]<0?e[1]-Ho-Bo:Ho-e[1])}function Be(t){var e,r=NaN,n=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?Uo:-Uo,l=wo(a-r);wo(l-Uo)0?Ho:-Ho),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=Uo&&(wo(r-i)Bo?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}function Ue(t,e,r,n){var i;if(null==t)i=r*Ho,n.point(-Uo,i),n.point(0,i),n.point(Uo,i),n.point(Uo,0),n.point(Uo,-i),n.point(0,-i),n.point(-Uo,-i),n.point(-Uo,0),n.point(-Uo,i);else if(wo(t[0]-e[0])>Bo){var a=t[0]s;++s){var c=e[s],u=c.length;if(u)for(var f=c[0],h=f[0],d=f[1]/2+Uo/4,p=Math.sin(d),g=Math.cos(d),v=1;;){v===u&&(v=0),t=c[v];var m=t[0],y=t[1]/2+Uo/4,b=Math.sin(y),x=Math.cos(y),_=m-h,w=_>=0?1:-1,k=w*_,A=k>Uo,M=p*b;if(Es.add(Math.atan2(M*w*Math.sin(k),g*x+M*Math.cos(k))),a+=A?_+w*Vo:_,A^h>=r^m>=r){var T=be(me(f),me(t));we(T);var E=be(i,T);we(E);var L=(A^_>=0?-1:1)*nt(E[2]);(n>L||n===L&&(T[0]||T[1]))&&(o+=A^_>=0?1:-1)}if(!v++)break;h=m,p=b,g=x,f=t}}return(-Bo>a||Bo>a&&-Bo>Es)^1&o}function qe(t){function e(t,e){return Math.cos(t)*Math.cos(e)>a}function r(t){var r,a,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(f,h){var d,p=[f,h],g=e(f,h),v=o?g?0:i(f,h):g?i(f+(0>f?Uo:-Uo),h):0;if(!r&&(c=l=g)&&t.lineStart(),g!==l&&(d=n(r,p),(Ae(r,d)||Ae(p,d))&&(p[0]+=Bo,p[1]+=Bo,g=e(p[0],p[1]))),g!==l)u=0,g?(t.lineStart(),d=n(p,r),t.point(d[0],d[1])):(d=n(r,p),t.point(d[0],d[1]),t.lineEnd()),r=d;else if(s&&r&&o^g){var m;v&a||!(m=n(p,r,!0))||(u=0,o?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||r&&Ae(r,p)||t.point(p[0],p[1]),r=p,l=g,a=v},lineEnd:function(){l&&t.lineEnd(),r=null},clean:function(){return u|(c&&l)<<1}}}function n(t,e,r){var n=me(t),i=me(e),o=[1,0,0],s=be(n,i),l=ye(s,s),c=s[0],u=l-c*c;if(!u)return!r&&t;var f=a*l/u,h=-a*c/u,d=be(o,s),p=_e(o,f),g=_e(s,h);xe(p,g);var v=d,m=ye(p,v),y=ye(v,v),b=m*m-y*(ye(p,p)-1);if(!(0>b)){var x=Math.sqrt(b),_=_e(v,(-m-x)/y);if(xe(_,p),_=ke(_),!r)return _;var w,k=t[0],A=e[0],M=t[1],T=e[1];k>A&&(w=k,k=A,A=w);var E=A-k,L=wo(E-Uo)E;if(!L&&M>T&&(w=M,M=T,T=w),S?L?M+T>0^_[1]<(wo(_[0]-k)Uo^(k<=_[0]&&_[0]<=A)){var C=_e(v,(-m+x)/y);return xe(C,p),[_,ke(C)]}}}function i(e,r){var n=o?t:Uo-t,i=0;return-n>e?i|=1:e>n&&(i|=2),-n>r?i|=4:r>n&&(i|=8),i}var a=Math.cos(t),o=a>0,s=wo(a)>Bo,l=vr(t,6*Go);return Ie(e,r,l,o?[0,-t]:[-Uo,t-Uo])}function He(t,e,r,n){return function(i){var a,o=i.a,s=i.b,l=o.x,c=o.y,u=s.x,f=s.y,h=0,d=1,p=u-l,g=f-c;if(a=t-l,p||!(a>0)){if(a/=p,0>p){if(h>a)return;d>a&&(d=a)}else if(p>0){if(a>d)return;a>h&&(h=a)}if(a=r-l,p||!(0>a)){if(a/=p,0>p){if(a>d)return;a>h&&(h=a)}else if(p>0){if(h>a)return;d>a&&(d=a)}if(a=e-c,g||!(a>0)){if(a/=g,0>g){if(h>a)return;d>a&&(d=a)}else if(g>0){if(a>d)return;a>h&&(h=a)}if(a=n-c,g||!(0>a)){if(a/=g,0>g){if(a>d)return;a>h&&(h=a)}else if(g>0){if(h>a)return;d>a&&(d=a)}return h>0&&(i.a={x:l+h*p,y:c+h*g}),1>d&&(i.b={x:l+d*p,y:c+d*g}),i}}}}}}function Ge(t,e,r,n){function i(n,i){return wo(n[0]-t)0?0:3:wo(n[0]-r)0?2:1:wo(n[1]-e)0?1:0:i>0?3:2}function a(t,e){return o(t.x,e.x)}function o(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}return function(s){function l(t){for(var e=0,r=v.length,n=t[1],i=0;r>i;++i)for(var a,o=1,s=v[i],l=s.length,c=s[0];l>o;++o)a=s[o],c[1]<=n?a[1]>n&&et(c,a,t)>0&&++e:a[1]<=n&&et(c,a,t)<0&&--e,c=a;return 0!==e}function c(a,s,l,c){var u=0,f=0;if(null==a||(u=i(a,l))!==(f=i(s,l))||o(a,s)<0^l>0){do c.point(0===u||3===u?t:r,u>1?n:e);while((u=(u+l+4)%4)!==f)}else c.point(s[0],s[1])}function u(i,a){return i>=t&&r>=i&&a>=e&&n>=a}function f(t,e){u(t,e)&&s.point(t,e)}function h(){S.point=p,v&&v.push(m=[]),A=!0,k=!1,_=w=NaN}function d(){g&&(p(y,b),x&&k&&E.rejoin(),g.push(E.buffer())),S.point=f,k&&s.lineEnd()}function p(t,e){t=Math.max(-Vs,Math.min(Vs,t)),e=Math.max(-Vs,Math.min(Vs,e));var r=u(t,e);if(v&&m.push([t,e]),A)y=t,b=e,x=r,A=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&k)s.point(t,e);else{var n={a:{x:_,y:w},b:{x:t,y:e}};L(n)?(k||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),M=!1):r&&(s.lineStart(),s.point(t,e),M=!1)}_=t,w=e,k=r}var g,v,m,y,b,x,_,w,k,A,M,T=s,E=je(),L=He(t,e,r,n),S={point:f,lineStart:h,lineEnd:d,polygonStart:function(){s=E,g=[],v=[],M=!0},polygonEnd:function(){s=T,g=co.merge(g);var e=l([t,n]),r=M&&e,i=g.length;(r||i)&&(s.polygonStart(),r&&(s.lineStart(),c(null,null,1,s),s.lineEnd()),i&&Pe(g,a,e,c,s),s.polygonEnd()),g=v=m=null}};return S}}function Ye(t){var e=0,r=Uo/3,n=lr(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*Uo/180,r=t[1]*Uo/180):[e/Uo*180,r/Uo*180]},i}function Xe(t,e){function r(t,e){var r=Math.sqrt(a-2*i*Math.sin(e))/i;return[r*Math.sin(t*=i),o-r*Math.cos(t)]}var n=Math.sin(t),i=(n+Math.sin(e))/2,a=1+n*(2*i-n),o=Math.sqrt(a)/i;return r.invert=function(t,e){var r=o-e;return[Math.atan2(t,r)/i,nt((a-(t*t+r*r)*i*i)/(2*i))]},r}function We(){function t(t,e){Hs+=i*t-n*e,n=t,i=e}var e,r,n,i;Zs.point=function(a,o){Zs.point=t,e=n=a,r=i=o},Zs.lineEnd=function(){t(e,r)}}function Ze(t,e){Gs>t&&(Gs=t),t>Xs&&(Xs=t),Ys>e&&(Ys=e),e>Ws&&(Ws=e)}function Ke(){function t(t,e){o.push("M",t,",",e,a)}function e(t,e){o.push("M",t,",",e),s.point=r}function r(t,e){o.push("L",t,",",e)}function n(){s.point=t}function i(){o.push("Z")}var a=Qe(4.5),o=[],s={point:t,lineStart:function(){s.point=e},lineEnd:n,polygonStart:function(){s.lineEnd=i},polygonEnd:function(){s.lineEnd=n,s.point=t},pointRadius:function(t){return a=Qe(t),s},result:function(){if(o.length){var t=o.join("");return o=[],t}}};return s}function Qe(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function $e(t,e){zs+=t,Ps+=e,++Rs}function Je(){function t(t,n){var i=t-e,a=n-r,o=Math.sqrt(i*i+a*a);Os+=o*(e+t)/2,Is+=o*(r+n)/2,Ns+=o,$e(e=t,r=n)}var e,r;Qs.point=function(n,i){Qs.point=t,$e(e=n,r=i)}}function tr(){Qs.point=$e}function er(){function t(t,e){var r=t-n,a=e-i,o=Math.sqrt(r*r+a*a);Os+=o*(n+t)/2,Is+=o*(i+e)/2,Ns+=o,o=i*t-n*e,js+=o*(n+t),Fs+=o*(i+e),Bs+=3*o,$e(n=t,i=e)}var e,r,n,i;Qs.point=function(a,o){Qs.point=t,$e(e=n=a,r=i=o)},Qs.lineEnd=function(){t(e,r)}}function rr(t){function e(e,r){t.moveTo(e+o,r),t.arc(e,r,o,0,Vo)}function r(e,r){t.moveTo(e,r),s.point=n}function n(e,r){t.lineTo(e,r)}function i(){s.point=e}function a(){t.closePath()}var o=4.5,s={point:e,lineStart:function(){s.point=r},lineEnd:i,polygonStart:function(){s.lineEnd=a},polygonEnd:function(){s.lineEnd=i,s.point=e},pointRadius:function(t){return o=t,s},result:k};return s}function nr(t){function e(t){return(s?n:r)(t)}function r(e){return or(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})}function n(e){function r(r,n){r=t(r,n),e.point(r[0],r[1])}function n(){b=NaN,A.point=a,e.lineStart()}function a(r,n){var a=me([r,n]),o=t(r,n);i(b,x,y,_,w,k,b=o[0],x=o[1],y=r,_=a[0],w=a[1],k=a[2],s,e),e.point(b,x)}function o(){A.point=r,e.lineEnd()}function l(){n(),A.point=c,A.lineEnd=u}function c(t,e){a(f=t,h=e),d=b,p=x,g=_,v=w,m=k,A.point=a}function u(){i(b,x,y,_,w,k,d,p,f,g,v,m,s,e),A.lineEnd=o,o()}var f,h,d,p,g,v,m,y,b,x,_,w,k,A={point:r,lineStart:n,lineEnd:o,polygonStart:function(){e.polygonStart(),A.lineStart=l},polygonEnd:function(){e.polygonEnd(),A.lineStart=n}};return A}function i(e,r,n,s,l,c,u,f,h,d,p,g,v,m){var y=u-e,b=f-r,x=y*y+b*b;if(x>4*a&&v--){var _=s+d,w=l+p,k=c+g,A=Math.sqrt(_*_+w*w+k*k),M=Math.asin(k/=A),T=wo(wo(k)-1)a||wo((y*C+b*z)/x-.5)>.3||o>s*d+l*p+c*g)&&(i(e,r,n,s,l,c,L,S,T,_/=A,w/=A,k,v,m),m.point(L,S),i(L,S,T,_,w,k,u,f,h,d,p,g,v,m))}}var a=.5,o=Math.cos(30*Go),s=16;return e.precision=function(t){return arguments.length?(s=(a=t*t)>0&&16,e):Math.sqrt(a)},e}function ir(t){var e=nr(function(e,r){return t([e*Yo,r*Yo])});return function(t){return cr(e(t))}}function ar(t){this.stream=t}function or(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart(); -},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sr(t){return lr(function(){return t})()}function lr(t){function e(t){return t=s(t[0]*Go,t[1]*Go),[t[0]*h+l,c-t[1]*h]}function r(t){return t=s.invert((t[0]-l)/h,(c-t[1])/h),t&&[t[0]*Yo,t[1]*Yo]}function n(){s=Ce(o=hr(m,y,b),a);var t=a(g,v);return l=d-t[0]*h,c=p+t[1]*h,i()}function i(){return u&&(u.valid=!1,u=null),e}var a,o,s,l,c,u,f=nr(function(t,e){return t=a(t,e),[t[0]*h+l,c-t[1]*h]}),h=150,d=480,p=250,g=0,v=0,m=0,y=0,b=0,_=Us,w=x,k=null,A=null;return e.stream=function(t){return u&&(u.valid=!1),u=cr(_(o,f(w(t)))),u.valid=!0,u},e.clipAngle=function(t){return arguments.length?(_=null==t?(k=t,Us):qe((k=+t)*Go),i()):k},e.clipExtent=function(t){return arguments.length?(A=t,w=t?Ge(t[0][0],t[0][1],t[1][0],t[1][1]):x,i()):A},e.scale=function(t){return arguments.length?(h=+t,n()):h},e.translate=function(t){return arguments.length?(d=+t[0],p=+t[1],n()):[d,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Go,v=t[1]%360*Go,n()):[g*Yo,v*Yo]},e.rotate=function(t){return arguments.length?(m=t[0]%360*Go,y=t[1]%360*Go,b=t.length>2?t[2]%360*Go:0,n()):[m*Yo,y*Yo,b*Yo]},co.rebind(e,f,"precision"),function(){return a=t.apply(this,arguments),e.invert=a.invert&&r,n()}}function cr(t){return or(t,function(e,r){t.point(e*Go,r*Go)})}function ur(t,e){return[t,e]}function fr(t,e){return[t>Uo?t-Vo:-Uo>t?t+Vo:t,e]}function hr(t,e,r){return t?e||r?Ce(pr(t),gr(e,r)):pr(t):e||r?gr(e,r):fr}function dr(t){return function(e,r){return e+=t,[e>Uo?e-Vo:-Uo>e?e+Vo:e,r]}}function pr(t){var e=dr(t);return e.invert=dr(-t),e}function gr(t,e){function r(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*n+s*i;return[Math.atan2(l*a-u*o,s*n-c*i),nt(u*a+l*o)]}var n=Math.cos(t),i=Math.sin(t),a=Math.cos(e),o=Math.sin(e);return r.invert=function(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*a-l*o;return[Math.atan2(l*a+c*o,s*n+u*i),nt(u*n-s*i)]},r}function vr(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=mr(r,i),a=mr(r,a),(o>0?a>i:i>a)&&(i+=o*Vo)):(i=t+o*Vo,a=t-.5*l);for(var c,u=i;o>0?u>a:a>u;u-=l)s.point((c=ke([r,-n*Math.cos(u),-n*Math.sin(u)]))[0],c[1])}}function mr(t,e){var r=me(e);r[0]-=t,we(r);var n=rt(-r[1]);return((-r[2]<0?-n:n)+2*Math.PI-Bo)%(2*Math.PI)}function yr(t,e,r){var n=co.range(t,e-Bo,r).concat(e);return function(t){return n.map(function(e){return[t,e]})}}function br(t,e,r){var n=co.range(t,e-Bo,r).concat(e);return function(t){return n.map(function(e){return[e,t]})}}function xr(t){return t.source}function _r(t){return t.target}function wr(t,e,r,n){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(n),s=Math.sin(n),l=i*Math.cos(t),c=i*Math.sin(t),u=o*Math.cos(r),f=o*Math.sin(r),h=2*Math.asin(Math.sqrt(st(n-e)+i*o*st(r-t))),d=1/Math.sin(h),p=h?function(t){var e=Math.sin(t*=h)*d,r=Math.sin(h-t)*d,n=r*l+e*u,i=r*c+e*f,o=r*a+e*s;return[Math.atan2(i,n)*Yo,Math.atan2(o,Math.sqrt(n*n+i*i))*Yo]}:function(){return[t*Yo,e*Yo]};return p.distance=h,p}function kr(){function t(t,i){var a=Math.sin(i*=Go),o=Math.cos(i),s=wo((t*=Go)-e),l=Math.cos(s);$s+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=n*a-r*o*l)*s),r*a+n*o*l),e=t,r=a,n=o}var e,r,n;Js.point=function(i,a){e=i*Go,r=Math.sin(a*=Go),n=Math.cos(a),Js.point=t},Js.lineEnd=function(){Js.point=Js.lineEnd=k}}function Ar(t,e){function r(e,r){var n=Math.cos(e),i=Math.cos(r),a=t(n*i);return[a*i*Math.sin(e),a*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),i=e(n),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,n*o),Math.asin(n&&r*a/n)]},r}function Mr(t,e){function r(t,e){o>0?-Ho+Bo>e&&(e=-Ho+Bo):e>Ho-Bo&&(e=Ho-Bo);var r=o/Math.pow(i(e),a);return[r*Math.sin(a*t),o-r*Math.cos(a*t)]}var n=Math.cos(t),i=function(t){return Math.tan(Uo/4+t/2)},a=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(i(e)/i(t)),o=n*Math.pow(i(t),a)/a;return a?(r.invert=function(t,e){var r=o-e,n=tt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(o/n,1/a))-Ho]},r):Er}function Tr(t,e){function r(t,e){var r=a-e;return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}var n=Math.cos(t),i=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),a=n/i+t;return wo(i)i;i++){for(;n>1&&et(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function Rr(t,e){return t[0]-e[0]||t[1]-e[1]}function Or(t,e,r){return(r[0]-e[0])*(t[1]-e[1])<(r[1]-e[1])*(t[0]-e[0])}function Ir(t,e,r,n){var i=t[0],a=r[0],o=e[0]-i,s=n[0]-a,l=t[1],c=r[1],u=e[1]-l,f=n[1]-c,h=(s*(l-c)-f*(i-a))/(f*o-s*u);return[i+h*o,l+h*u]}function Nr(t){var e=t[0],r=t[t.length-1];return!(e[0]-r[0]||e[1]-r[1])}function jr(){an(this),this.edge=this.site=this.circle=null}function Fr(t){var e=fl.pop()||new jr;return e.site=t,e}function Br(t){Zr(t),ll.remove(t),fl.push(t),an(t)}function Dr(t){var e=t.circle,r=e.x,n=e.cy,i={x:r,y:n},a=t.P,o=t.N,s=[t];Br(t);for(var l=a;l.circle&&wo(r-l.circle.x)u;++u)c=s[u],l=s[u-1],en(c.edge,l.site,c.site,i);l=s[0],c=s[f-1],c.edge=Jr(l.site,c.site,null,i),Wr(l),Wr(c)}function Ur(t){for(var e,r,n,i,a=t.x,o=t.y,s=ll._;s;)if(n=Vr(s,o)-a,n>Bo)s=s.L;else{if(i=a-qr(s,o),!(i>Bo)){n>-Bo?(e=s.P,r=s):i>-Bo?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=Fr(t);if(ll.insert(e,l),e||r){if(e===r)return Zr(e),r=Fr(e.site),ll.insert(l,r),l.edge=r.edge=Jr(e.site,l.site),Wr(e),void Wr(r);if(!r)return void(l.edge=Jr(e.site,l.site));Zr(e),Zr(r);var c=e.site,u=c.x,f=c.y,h=t.x-u,d=t.y-f,p=r.site,g=p.x-u,v=p.y-f,m=2*(h*v-d*g),y=h*h+d*d,b=g*g+v*v,x={x:(v*y-d*b)/m+u,y:(h*b-g*y)/m+f};en(r.edge,c,p,x),l.edge=Jr(c,t,null,x),r.edge=Jr(t,p,null,x),Wr(e),Wr(r)}}function Vr(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-(1/0);r=o.site;var s=r.x,l=r.y,c=l-e;if(!c)return s;var u=s-n,f=1/a-1/c,h=u/c;return f?(-h+Math.sqrt(h*h-2*f*(u*u/(-2*c)-l+c/2+i-a/2)))/f+n:(n+s)/2}function qr(t,e){var r=t.N;if(r)return Vr(r,e);var n=t.site;return n.y===e?n.x:1/0}function Hr(t){this.site=t,this.edges=[]}function Gr(t){for(var e,r,n,i,a,o,s,l,c,u,f=t[0][0],h=t[1][0],d=t[0][1],p=t[1][1],g=sl,v=g.length;v--;)if(a=g[v],a&&a.prepare())for(s=a.edges,l=s.length,o=0;l>o;)u=s[o].end(),n=u.x,i=u.y,c=s[++o%l].start(),e=c.x,r=c.y,(wo(n-e)>Bo||wo(i-r)>Bo)&&(s.splice(o,0,new rn(tn(a.site,u,wo(n-f)Bo?{x:f,y:wo(e-f)Bo?{x:wo(r-p)Bo?{x:h,y:wo(e-h)Bo?{x:wo(r-d)=-Do)){var d=l*l+c*c,p=u*u+f*f,g=(f*d-c*p)/h,v=(l*p-u*d)/h,f=v+s,m=hl.pop()||new Xr;m.arc=t,m.site=i,m.x=g+o,m.y=f+Math.sqrt(g*g+v*v),m.cy=f,t.circle=m;for(var y=null,b=ul._;b;)if(m.yv||v>=s)return;if(h>p){if(a){if(a.y>=c)return}else a={x:v,y:l};r={x:v,y:c}}else{if(a){if(a.yn||n>1)if(h>p){if(a){if(a.y>=c)return}else a={x:(l-i)/n,y:l};r={x:(c-i)/n,y:c}}else{if(a){if(a.yd){if(a){if(a.x>=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xa||f>o||n>h||i>d)){if(p=t.point){var p,g=e-t.x,v=r-t.y,m=g*g+v*v;if(l>m){var y=Math.sqrt(l=m);n=e-y,i=r-y,a=e+y,o=r+y,s=p}}for(var b=t.nodes,x=.5*(u+h),_=.5*(f+d),w=e>=x,k=r>=_,A=k<<1|w,M=A+4;M>A;++A)if(t=b[3&A])switch(3&A){case 0:c(t,u,f,x,_);break;case 1:c(t,x,f,h,_);break;case 2:c(t,u,_,x,d);break;case 3:c(t,x,_,h,d)}}}(t,n,i,a,o),s}function mn(t,e){t=co.rgb(t),e=co.rgb(e);var r=t.r,n=t.g,i=t.b,a=e.r-r,o=e.g-n,s=e.b-i;return function(t){return"#"+wt(Math.round(r+a*t))+wt(Math.round(n+o*t))+wt(Math.round(i+s*t))}}function yn(t,e){var r,n={},i={};for(r in t)r in e?n[r]=_n(t[r],e[r]):i[r]=t[r];for(r in e)r in t||(i[r]=e[r]);return function(t){for(r in n)i[r]=n[r](t);return i}}function bn(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function xn(t,e){var r,n,i,a=pl.lastIndex=gl.lastIndex=0,o=-1,s=[],l=[];for(t+="",e+="";(r=pl.exec(t))&&(n=gl.exec(e));)(i=n.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:bn(r,n)})),a=gl.lastIndex;return an;++n)s[(r=l[n]).i]=r.x(t);return s.join("")})}function _n(t,e){for(var r,n=co.interpolators.length;--n>=0&&!(r=co.interpolators[n](t,e)););return r}function wn(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;s>r;++r)n.push(_n(t[r],e[r]));for(;a>r;++r)i[r]=t[r];for(;o>r;++r)i[r]=e[r];return function(t){for(r=0;s>r;++r)i[r]=n[r](t);return i}}function kn(t){return function(e){return 0>=e?0:e>=1?1:t(e)}}function An(t){return function(e){return 1-t(1-e)}}function Mn(t){return function(e){return.5*(.5>e?t(2*e):2-t(2-2*e))}}function Tn(t){return t*t}function En(t){return t*t*t}function Ln(t){if(0>=t)return 0;if(t>=1)return 1;var e=t*t,r=e*t;return 4*(.5>t?r:3*(t-e)+r-.75)}function Sn(t){return function(e){return Math.pow(e,t)}}function Cn(t){return 1-Math.cos(t*Ho)}function zn(t){return Math.pow(2,10*(t-1))}function Pn(t){return 1-Math.sqrt(1-t*t)}function Rn(t,e){var r;return arguments.length<2&&(e=.45),arguments.length?r=e/Vo*Math.asin(1/t):(t=1,r=e/4),function(n){return 1+t*Math.pow(2,-10*n)*Math.sin((n-r)*Vo/e)}}function On(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function In(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Nn(t,e){t=co.hcl(t),e=co.hcl(e);var r=t.h,n=t.c,i=t.l,a=e.h-r,o=e.c-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.c:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ht(r+a*t,n+o*t,i+s*t)+""}}function jn(t,e){t=co.hsl(t),e=co.hsl(e);var r=t.h,n=t.s,i=t.l,a=e.h-r,o=e.s-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.s:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ut(r+a*t,n+o*t,i+s*t)+""}}function Fn(t,e){t=co.lab(t),e=co.lab(e);var r=t.l,n=t.a,i=t.b,a=e.l-r,o=e.a-n,s=e.b-i;return function(t){return pt(r+a*t,n+o*t,i+s*t)+""}}function Bn(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function Dn(t){var e=[t.a,t.b],r=[t.c,t.d],n=Vn(e),i=Un(e,r),a=Vn(qn(r,e,-i))||0;e[0]*r[1]180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(Hn(r)+"rotate(",null,")")-2,x:bn(t,e)})):e&&r.push(Hn(r)+"rotate("+e+")")}function Xn(t,e,r,n){t!==e?n.push({i:r.push(Hn(r)+"skewX(",null,")")-2,x:bn(t,e)}):e&&r.push(Hn(r)+"skewX("+e+")")}function Wn(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(Hn(r)+"scale(",null,",",null,")");n.push({i:i-4,x:bn(t[0],e[0])},{i:i-2,x:bn(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(Hn(r)+"scale("+e+")")}function Zn(t,e){var r=[],n=[];return t=co.transform(t),e=co.transform(e),Gn(t.translate,e.translate,r,n),Yn(t.rotate,e.rotate,r,n),Xn(t.skew,e.skew,r,n),Wn(t.scale,e.scale,r,n),t=e=null,function(t){for(var e,i=-1,a=n.length;++i=0;)r.push(i[n])}function li(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++or;++r)(e=t[r][1])>i&&(n=r,i=e);return n}function bi(t){return t.reduce(xi,0)}function xi(t,e){return t+e[1]}function _i(t,e){return wi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wi(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function ki(t){return[co.min(t),co.max(t)]}function Ai(t,e){return t.value-e.value}function Mi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ti(t,e){t._pack_next=e,e._pack_prev=t}function Ei(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function Li(t){function e(t){u=Math.min(t.x-t.r,u),f=Math.max(t.x+t.r,f),h=Math.min(t.y-t.r,h),d=Math.max(t.y+t.r,d)}if((r=t.children)&&(c=r.length)){var r,n,i,a,o,s,l,c,u=1/0,f=-(1/0),h=1/0,d=-(1/0);if(r.forEach(Si),n=r[0],n.x=-n.r,n.y=0,e(n),c>1&&(i=r[1],i.x=i.r,i.y=0,e(i),c>2))for(a=r[2],Pi(n,i,a),e(a),Mi(n,a),n._pack_prev=a,Mi(a,i),i=n._pack_next,o=3;c>o;o++){Pi(n,i,a=r[o]);var p=0,g=1,v=1;for(s=i._pack_next;s!==i;s=s._pack_next,g++)if(Ei(s,a)){p=1;break}if(1==p)for(l=n._pack_prev;l!==s._pack_prev&&!Ei(l,a);l=l._pack_prev,v++);p?(v>g||g==v&&i.ro;o++)a=r[o],a.x-=m,a.y-=y,b=Math.max(b,a.r+Math.sqrt(a.x*a.x+a.y*a.y));t.r=b,r.forEach(Ci)}}function Si(t){t._pack_next=t._pack_prev=t}function Ci(t){delete t._pack_next,delete t._pack_prev}function zi(t,e,r,n){var i=t.children;if(t.x=e+=n*t.x,t.y=r+=n*t.y,t.r*=n,i)for(var a=-1,o=i.length;++a=0;)e=i[a],e.z+=r,e.m+=r,r+=e.s+(n+=e.c)}function Fi(t,e,r){return t.a.parent===e.parent?t.a:r}function Bi(t){return 1+co.max(t,function(t){return t.y})}function Di(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ui(t){var e=t.children;return e&&e.length?Ui(e[0]):t}function Vi(t){var e,r=t.children;return r&&(e=r.length)?Vi(r[e-1]):t}function qi(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Hi(t,e){var r=t.x+e[3],n=t.y+e[0],i=t.dx-e[1]-e[3],a=t.dy-e[0]-e[2];return 0>i&&(r+=i/2,i=0),0>a&&(n+=a/2,a=0),{x:r,y:n,dx:i,dy:a}}function Gi(t){var e=t[0],r=t[t.length-1];return r>e?[e,r]:[r,e]}function Yi(t){return t.rangeExtent?t.rangeExtent():Gi(t.range())}function Xi(t,e,r,n){var i=r(t[0],t[1]),a=n(e[0],e[1]);return function(t){return a(i(t))}}function Wi(t,e){var r,n=0,i=t.length-1,a=t[n],o=t[i];return a>o&&(r=n,n=i,i=r,r=a,a=o,o=r),t[n]=e.floor(a),t[i]=e.ceil(o),t}function Zi(t){return t?{floor:function(e){return Math.floor(e/t)*t},ceil:function(e){return Math.ceil(e/t)*t}}:Tl}function Ki(t,e,r,n){var i=[],a=[],o=0,s=Math.min(t.length,e.length)-1;for(t[s]2?Ki:Xi,l=n?Qn:Kn;return o=i(t,e,l,r),s=i(e,t,l,_n),a}function a(t){return o(t)}var o,s;return a.invert=function(t){return s(t)},a.domain=function(e){return arguments.length?(t=e.map(Number),i()):t},a.range=function(t){return arguments.length?(e=t,i()):e},a.rangeRound=function(t){return a.range(t).interpolate(Bn)},a.clamp=function(t){return arguments.length?(n=t,i()):n},a.interpolate=function(t){return arguments.length?(r=t,i()):r},a.ticks=function(e){return ea(t,e)},a.tickFormat=function(e,r){return ra(t,e,r)},a.nice=function(e){return Ji(t,e),i()},a.copy=function(){return Qi(t,e,r,n)},i()}function $i(t,e){return co.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ji(t,e){return Wi(t,Zi(ta(t,e)[2])),Wi(t,Zi(ta(t,e)[2])),t}function ta(t,e){null==e&&(e=10);var r=Gi(t),n=r[1]-r[0],i=Math.pow(10,Math.floor(Math.log(n/e)/Math.LN10)),a=e/n*i;return.15>=a?i*=10:.35>=a?i*=5:.75>=a&&(i*=2),r[0]=Math.ceil(r[0]/i)*i,r[1]=Math.floor(r[1]/i)*i+.5*i,r[2]=i,r}function ea(t,e){return co.range.apply(co,ta(t,e))}function ra(t,e,r){var n=ta(t,e);if(r){var i=ps.exec(r);if(i.shift(),"s"===i[8]){var a=co.formatPrefix(Math.max(wo(n[0]),wo(n[1])));return i[7]||(i[7]="."+na(a.scale(n[2]))),i[8]="f",r=co.format(i.join("")),function(t){return r(a.scale(t))+a.symbol}}i[7]||(i[7]="."+ia(i[8],n)),r=i.join("")}else r=",."+na(n[2])+"f";return co.format(r)}function na(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ia(t,e){var r=na(e[2]);return t in El?Math.abs(r-na(Math.max(wo(e[0]),wo(e[1]))))+ +("e"!==t):r-2*("%"===t)}function aa(t,e,r,n){function i(t){return(r?Math.log(0>t?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function a(t){return r?Math.pow(e,t):-Math.pow(e,-t)}function o(e){return t(i(e))}return o.invert=function(e){return a(t.invert(e))},o.domain=function(e){return arguments.length?(r=e[0]>=0,t.domain((n=e.map(Number)).map(i)),o):n},o.base=function(r){return arguments.length?(e=+r,t.domain(n.map(i)),o):e},o.nice=function(){var e=Wi(n.map(i),r?Math:Sl);return t.domain(e),n=e.map(a),o},o.ticks=function(){var t=Gi(n),o=[],s=t[0],l=t[1],c=Math.floor(i(s)),u=Math.ceil(i(l)),f=e%1?2:e;if(isFinite(u-c)){if(r){for(;u>c;c++)for(var h=1;f>h;h++)o.push(a(c)*h);o.push(a(c))}else for(o.push(a(c));c++0;h--)o.push(a(c)*h);for(c=0;o[c]l;u--);o=o.slice(c,u)}return o},o.tickFormat=function(t,r){if(!arguments.length)return Ll;arguments.length<2?r=Ll:"function"!=typeof r&&(r=co.format(r));var n=Math.max(1,e*t/o.ticks().length);return function(t){var o=t/a(Math.round(i(t)));return e-.5>o*e&&(o*=e),n>=o?r(t):""}},o.copy=function(){return aa(t.copy(),e,r,n)},$i(o,t)}function oa(t,e,r){function n(e){return t(i(e))}var i=sa(e),a=sa(1/e);return n.invert=function(e){return a(t.invert(e))},n.domain=function(e){return arguments.length?(t.domain((r=e.map(Number)).map(i)),n):r},n.ticks=function(t){return ea(r,t)},n.tickFormat=function(t,e){return ra(r,t,e)},n.nice=function(t){return n.domain(Ji(r,t))},n.exponent=function(o){return arguments.length?(i=sa(e=o),a=sa(1/e),t.domain(r.map(i)),n):e},n.copy=function(){return oa(t.copy(),e,r)},$i(n,t)}function sa(t){return function(e){return 0>e?-Math.pow(-e,t):Math.pow(e,t)}}function la(t,e){function r(r){return a[((i.get(r)||("range"===e.t?i.set(r,t.push(r)):NaN))-1)%a.length]}function n(e,r){return co.range(t.length).map(function(t){return e+r*t})}var i,a,o;return r.domain=function(n){if(!arguments.length)return t;t=[],i=new f;for(var a,o=-1,s=n.length;++or?[NaN,NaN]:[r>0?s[r-1]:t[0],re?NaN:e/a+t,[e,e+1/a]},n.copy=function(){return ua(t,e,r)},i()}function fa(t,e){function r(r){return r>=r?e[co.bisect(t,r)]:void 0}return r.domain=function(e){return arguments.length?(t=e,r):t},r.range=function(t){return arguments.length?(e=t,r):e},r.invertExtent=function(r){return r=e.indexOf(r),[t[r-1],t[r]]},r.copy=function(){return fa(t,e)},r}function ha(t){function e(t){return+t}return e.invert=e,e.domain=e.range=function(r){return arguments.length?(t=r.map(e),e):t},e.ticks=function(e){return ea(t,e)},e.tickFormat=function(e,r){return ra(t,e,r)},e.copy=function(){return ha(t)},e}function da(){return 0}function pa(t){return t.innerRadius}function ga(t){return t.outerRadius}function va(t){return t.startAngle}function ma(t){return t.endAngle}function ya(t){return t&&t.padAngle}function ba(t,e,r,n){return(t-r)*e-(e-n)*t>0?0:1}function xa(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,c=-s*a,u=t[0]+l,f=t[1]+c,h=e[0]+l,d=e[1]+c,p=(u+h)/2,g=(f+d)/2,v=h-u,m=d-f,y=v*v+m*m,b=r-n,x=u*d-h*f,_=(0>m?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*m-v*_)/y,k=(-x*v-m*_)/y,A=(x*m+v*_)/y,M=(-x*v+m*_)/y,T=w-p,E=k-g,L=A-p,S=M-g;return T*T+E*E>L*L+S*S&&(w=A,k=M),[[w-l,k-c],[w*r/b,k*r/b]]}function _a(t){function e(e){function o(){c.push("M",a(t(u),s))}for(var l,c=[],u=[],f=-1,h=e.length,d=Lt(r),p=Lt(n);++f1?t.join("L"):t+"Z"}function ka(t){return t.join("L")+"Z"}function Aa(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1&&i.push("H",n[0]),i.join("")}function Ma(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var c=2;c9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));for(s=-1;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}function Ua(t){return t.length<3?wa(t):t[0]+Ca(t,Da(t))}function Va(t){for(var e,r,n,i=-1,a=t.length;++i=e?o(t-e):void(c.c=o)}function o(r){var i=p.active,a=p[i];a&&(a.timer.c=null,a.timer.t=NaN,--p.count,delete p[i],a.event&&a.event.interrupt.call(t,t.__data__,a.index));for(var o in p)if(n>+o){var f=p[o];f.timer.c=null,f.timer.t=NaN,--p.count,delete p[o]}c.c=s,Rt(function(){return c.c&&s(r||1)&&(c.c=null,c.t=NaN),1},0,l),p.active=n,g.event&&g.event.start.call(t,t.__data__,e),d=[],g.tween.forEach(function(r,n){(n=n.call(t,t.__data__,e))&&d.push(n)}),h=g.ease,u=g.duration}function s(i){for(var a=i/u,o=h(a),s=d.length;s>0;)d[--s].call(t,o);return a>=1?(g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[n]:delete t[r],1):void 0}var l,c,u,h,d,p=t[r]||(t[r]={active:0,count:0}),g=p[n];g||(l=i.time,c=Rt(a,0,l),g=p[n]={tween:new f,time:l,timer:c,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++p.count)}function ro(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate("+(isFinite(n)?n:r(t))+",0)"})}function no(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate(0,"+(isFinite(n)?n:r(t))+")"})}function io(t){return t.toISOString()}function ao(t,e,r){function n(e){return t(e)}function i(t,r){var n=t[1]-t[0],i=n/r,a=co.bisect(tc,i);return a==tc.length?[e.year,ta(t.map(function(t){return t/31536e6}),r)[2]]:a?e[i/tc[a-1]1?{floor:function(e){for(;r(e=t.floor(e));)e=oo(e-1);return e},ceil:function(e){for(;r(e=t.ceil(e));)e=oo(+e+1);return e}}:t))},n.ticks=function(t,e){var r=Gi(n.domain()),a=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return a&&(t=a[0],e=a[1]),t.range(r[0],oo(+r[1]+1),1>e?1:e)},n.tickFormat=function(){return r},n.copy=function(){return ao(t.copy(),e,r)},$i(n,t)}function oo(t){return new Date(t)}function so(t){return JSON.parse(t.responseText)}function lo(t){var e=ho.createRange();return e.selectNode(ho.body),e.createContextualFragment(t.responseText)}var co={version:"3.5.17"},uo=[].slice,fo=function(t){return uo.call(t)},ho=this.document;if(ho)try{fo(ho.documentElement.childNodes)[0].nodeType}catch(po){fo=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),ho)try{ho.createElement("DIV").style.setProperty("opacity",0,"")}catch(go){var vo=this.Element.prototype,mo=vo.setAttribute,yo=vo.setAttributeNS,bo=this.CSSStyleDeclaration.prototype,xo=bo.setProperty;vo.setAttribute=function(t,e){mo.call(this,t,e+"")},vo.setAttributeNS=function(t,e,r){yo.call(this,t,e,r+"")},bo.setProperty=function(t,e,r){xo.call(this,t,e+"",r)}}co.ascending=i,co.descending=function(t,e){return t>e?-1:e>t?1:e>=t?0:NaN},co.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},co.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},co.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}else{for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}return[r,i]},co.sum=function(t,e){var r,n=0,i=t.length,a=-1;if(1===arguments.length)for(;++a1?l/(u-1):void 0},co.deviation=function(){var t=co.variance.apply(this,arguments);return t?Math.sqrt(t):t};var _o=s(i);co.bisectLeft=_o.left,co.bisect=co.bisectRight=_o.right,co.bisector=function(t){return s(1===t.length?function(e,r){return i(t(e),r)}:t)},co.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,2>a&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},co.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},co.pairs=function(t){for(var e,r=0,n=t.length-1,i=t[0],a=new Array(0>n?0:n);n>r;)a[r]=[e=i,i=t[++r]];return a},co.transpose=function(t){if(!(i=t.length))return[];for(var e=-1,r=co.min(t,l),n=new Array(r);++e=0;)for(n=t[i],e=n.length;--e>=0;)r[--o]=n[e];return r};var wo=Math.abs;co.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r===1/0)throw new Error("infinite range");var n,i=[],a=c(wo(r)),o=-1;if(t*=a,e*=a,r*=a,0>r)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=a.length)return n?n.call(i,o):r?o.sort(r):o;for(var l,c,u,h,d=-1,p=o.length,g=a[s++],v=new f;++d=a.length)return t;var n=[],i=o[r++];return t.forEach(function(t,i){n.push({key:t,values:e(i,r)})}),i?n.sort(function(t,e){return i(t.key,e.key)}):n}var r,n,i={},a=[],o=[];return i.map=function(e,r){return t(r,e,0)},i.entries=function(r){return e(t(co.map,r,0),0)},i.key=function(t){return a.push(t),i},i.sortKeys=function(t){return o[a.length-1]=t,i},i.sortValues=function(t){return r=t,i},i.rollup=function(t){return n=t,i},i},co.set=function(t){var e=new b;if(t)for(var r=0,n=t.length;n>r;++r)e.add(t[r]);return e},u(b,{has:p,add:function(t){return this._[h(t+="")]=!0,t},remove:g,values:v,size:m,empty:y,forEach:function(t){for(var e in this._)t.call(this,d(e))}}),co.behavior={},co.rebind=function(t,e){for(var r,n=1,i=arguments.length;++n=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},co.event=null,co.requote=function(t){return t.replace(To,"\\$&")};var To=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Eo={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]},Lo=function(t,e){return e.querySelector(t)},So=function(t,e){return e.querySelectorAll(t)},Co=function(t,e){var r=t.matches||t[w(t,"matchesSelector")];return(Co=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(Lo=function(t,e){return Sizzle(t,e)[0]||null},So=Sizzle,Co=Sizzle.matchesSelector),co.selection=function(){return co.select(ho.documentElement)};var zo=co.selection.prototype=[];zo.select=function(t){var e,r,n,i,a=[];t=C(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Ro.hasOwnProperty(r)?{space:Ro[r],local:t}:t}},zo.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node();return t=co.ns.qualify(t),t.local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}for(e in t)this.each(P(e,t[e]));return this}return this.each(P(t,e))},zo.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=I(t)).length,i=-1;if(e=r.classList){for(;++ii){if("string"!=typeof t){2>i&&(e="");for(r in t)this.each(F(r,t[r],e));return this}if(2>i){var a=this.node();return n(a).getComputedStyle(a,null).getPropertyValue(t)}r=""}return this.each(F(t,e,r))},zo.property=function(t,e){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(e in t)this.each(B(e,t[e]));return this}return this.each(B(t,e))},zo.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},zo.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},zo.append=function(t){return t=D(t),this.select(function(){return this.appendChild(t.apply(this,arguments))})},zo.insert=function(t,e){return t=D(t),e=C(e),this.select(function(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)})},zo.remove=function(){return this.each(U)},zo.data=function(t,e){function r(t,r){var n,i,a,o=t.length,u=r.length,h=Math.min(o,u),d=new Array(u),p=new Array(u),g=new Array(o);if(e){var v,m=new f,y=new Array(o);for(n=-1;++nn;++n)p[n]=V(r[n]);for(;o>n;++n)g[n]=t[n]}p.update=d,p.parentNode=d.parentNode=g.parentNode=t.parentNode,s.push(p),l.push(d),c.push(g)}var n,i,a=-1,o=this.length;if(!arguments.length){for(t=new Array(o=(n=this[0]).length);++aa;a++){i.push(e=[]),e.parentNode=(r=this[a]).parentNode;for(var s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return S(i)},zo.order=function(){for(var t=-1,e=this.length;++t=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},zo.sort=function(t){t=H.apply(this,arguments);for(var e=-1,r=this.length;++et;t++)for(var r=this[t],n=0,i=r.length;i>n;n++){var a=r[n];if(a)return a}return null},zo.size=function(){var t=0;return G(this,function(){++t}),t};var Oo=[];co.selection.enter=Y,co.selection.enter.prototype=Oo,Oo.append=zo.append,Oo.empty=zo.empty,Oo.node=zo.node,Oo.call=zo.call,Oo.size=zo.size,Oo.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++sn){if("string"!=typeof t){2>n&&(e=!1);for(r in t)this.each(W(r,t[r],e));return this}if(2>n)return(n=this.node()["__on"+t])&&n._;r=!1}return this.each(W(t,e,r))};var Io=co.map({mouseenter:"mouseover",mouseleave:"mouseout"});ho&&Io.forEach(function(t){"on"+t in ho&&Io.remove(t)});var No,jo=0;co.mouse=function(t){return $(t,E())};var Fo=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;co.touch=function(t,e,r){if(arguments.length<3&&(r=e,e=E().changedTouches),e)for(var n,i=0,a=e.length;a>i;++i)if((n=e[i]).identifier===r)return $(t,n)},co.behavior.drag=function(){function t(){this.on("mousedown.drag",a).on("touchstart.drag",o)}function e(t,e,n,a,o){return function(){function s(){var t,r,n=e(h,g);n&&(t=n[0]-b[0],r=n[1]-b[1],p|=t|r,b=n,d({type:"drag",x:n[0]+c[0],y:n[1]+c[1],dx:t,dy:r}))}function l(){e(h,g)&&(m.on(a+v,null).on(o+v,null),y(p),d({type:"dragend"}))}var c,u=this,f=co.event.target.correspondingElement||co.event.target,h=u.parentNode,d=r.of(u,arguments),p=0,g=t(),v=".drag"+(null==g?"":"-"+g),m=co.select(n(f)).on(a+v,s).on(o+v,l),y=Q(f),b=e(h,g);i?(c=i.apply(u,arguments),c=[c.x-b[0],c.y-b[1]]):c=[0,0],d({type:"dragstart"})}}var r=L(t,"drag","dragstart","dragend"),i=null,a=e(k,co.mouse,n,"mousemove","mouseup"),o=e(J,co.touch,x,"touchmove","touchend");return t.origin=function(e){return arguments.length?(i=e,t):i},co.rebind(t,r,"on")},co.touches=function(t,e){return arguments.length<2&&(e=E().touches),e?fo(e).map(function(e){var r=$(t,e);return r.identifier=e.identifier,r}):[]};var Bo=1e-6,Do=Bo*Bo,Uo=Math.PI,Vo=2*Uo,qo=Vo-Bo,Ho=Uo/2,Go=Uo/180,Yo=180/Uo,Xo=Math.SQRT2,Wo=2,Zo=4;co.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],c=e[2],u=s-i,f=l-a,h=u*u+f*f;if(Do>h)n=Math.log(c/o)/Xo,r=function(t){return[i+t*u,a+t*f,o*Math.exp(Xo*t*n)]};else{var d=Math.sqrt(h),p=(c*c-o*o+Zo*h)/(2*o*Wo*d),g=(c*c-o*o-Zo*h)/(2*c*Wo*d),v=Math.log(Math.sqrt(p*p+1)-p),m=Math.log(Math.sqrt(g*g+1)-g);n=(m-v)/Xo,r=function(t){var e=t*n,r=at(v),s=o/(Wo*d)*(r*ot(Xo*e+v)-it(v));return[i+s*u,a+s*f,o*r/at(Xo*e+v)]}}return r.duration=1e3*n,r},co.behavior.zoom=function(){function t(t){t.on(z,f).on(Qo+".zoom",d).on("dblclick.zoom",p).on(O,h)}function e(t){return[(t[0]-A.x)/A.k,(t[1]-A.y)/A.k]}function r(t){return[t[0]*A.k+A.x,t[1]*A.k+A.y]}function i(t){A.k=Math.max(E[0],Math.min(E[1],t))}function a(t,e){e=r(e),A.x+=t[0]-e[0],A.y+=t[1]-e[1]}function o(e,r,n,o){e.__chart__={x:A.x,y:A.y,k:A.k},i(Math.pow(2,o)),a(v=r,n),e=co.select(e),S>0&&(e=e.transition().duration(S)),e.call(t.event)}function s(){_&&_.domain(x.range().map(function(t){return(t-A.x)/A.k}).map(x.invert)),k&&k.domain(w.range().map(function(t){return(t-A.y)/A.k}).map(w.invert))}function l(t){C++||t({type:"zoomstart"})}function c(t){s(),t({type:"zoom",scale:A.k,translate:[A.x,A.y]})}function u(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){s=1,a(co.mouse(i),h),c(o)}function r(){f.on(P,null).on(R,null),d(s),u(o)}var i=this,o=I.of(i,arguments),s=0,f=co.select(n(i)).on(P,t).on(R,r),h=e(co.mouse(i)),d=Q(i);Hl.call(i),l(o)}function h(){function t(){var t=co.touches(p);return d=A.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function r(){var e=co.event.target;co.select(e).on(x,n).on(_,s),w.push(e);for(var r=co.event.changedTouches,i=0,a=r.length;a>i;++i)v[r[i].identifier]=null;var l=t(),c=Date.now();if(1===l.length){if(500>c-b){var u=l[0];o(p,u,v[u.identifier],Math.floor(Math.log(A.k)/Math.LN2)+1),T()}b=c}else if(l.length>1){var u=l[0],f=l[1],h=u[0]-f[0],d=u[1]-f[1];m=h*h+d*d}}function n(){var t,e,r,n,o=co.touches(p);Hl.call(p);for(var s=0,l=o.length;l>s;++s,n=null)if(r=o[s],n=v[r.identifier]){if(e)break;t=r,e=n}if(n){var u=(u=r[0]-t[0])*u+(u=r[1]-t[1])*u,f=m&&Math.sqrt(u/m);t=[(t[0]+r[0])/2,(t[1]+r[1])/2],e=[(e[0]+n[0])/2,(e[1]+n[1])/2],i(f*d)}b=null,a(t,e),c(g)}function s(){if(co.event.touches.length){for(var e=co.event.changedTouches,r=0,n=e.length;n>r;++r)delete v[e[r].identifier];for(var i in v)return void t()}co.selectAll(w).on(y,null),k.on(z,f).on(O,h),M(),u(g)}var d,p=this,g=I.of(p,arguments),v={},m=0,y=".zoom-"+co.event.changedTouches[0].identifier,x="touchmove"+y,_="touchend"+y,w=[],k=co.select(p),M=Q(p);r(),l(g),k.on(z,null).on(O,r)}function d(){var t=I.of(this,arguments);y?clearTimeout(y):(Hl.call(this),g=e(v=m||co.mouse(this)),l(t)),y=setTimeout(function(){y=null,u(t)},50),T(),i(Math.pow(2,.002*Ko())*A.k),a(v,g),c(t)}function p(){var t=co.mouse(this),r=Math.log(A.k)/Math.LN2;o(this,t,e(t),co.event.shiftKey?Math.ceil(r)-1:Math.floor(r)+1)}var g,v,m,y,b,x,_,w,k,A={x:0,y:0,k:1},M=[960,500],E=$o,S=250,C=0,z="mousedown.zoom",P="mousemove.zoom",R="mouseup.zoom",O="touchstart.zoom",I=L(t,"zoomstart","zoom","zoomend");return Qo||(Qo="onwheel"in ho?(Ko=function(){return-co.event.deltaY*(co.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ho?(Ko=function(){return co.event.wheelDelta},"mousewheel"):(Ko=function(){return-co.event.detail},"MozMousePixelScroll")),t.event=function(t){t.each(function(){var t=I.of(this,arguments),e=A;Vl?co.select(this).transition().each("start.zoom",function(){A=this.__chart__||{x:0,y:0,k:1},l(t)}).tween("zoom:zoom",function(){var r=M[0],n=M[1],i=v?v[0]:r/2,a=v?v[1]:n/2,o=co.interpolateZoom([(i-A.x)/A.k,(a-A.y)/A.k,r/A.k],[(i-e.x)/e.k,(a-e.y)/e.k,r/e.k]);return function(e){var n=o(e),s=r/n[2];this.__chart__=A={x:i-n[0]*s,y:a-n[1]*s,k:s},c(t)}}).each("interrupt.zoom",function(){u(t)}).each("end.zoom",function(){u(t)}):(this.__chart__=A,l(t),c(t),u(t))})},t.translate=function(e){return arguments.length?(A={x:+e[0],y:+e[1],k:A.k},s(),t):[A.x,A.y]},t.scale=function(e){return arguments.length?(A={x:A.x,y:A.y,k:null},i(+e),s(),t):A.k},t.scaleExtent=function(e){return arguments.length?(E=null==e?$o:[+e[0],+e[1]],t):E},t.center=function(e){return arguments.length?(m=e&&[+e[0],+e[1]],t):m},t.size=function(e){return arguments.length?(M=e&&[+e[0],+e[1]],t):M},t.duration=function(e){return arguments.length?(S=+e,t):S},t.x=function(e){return arguments.length?(_=e,x=e.copy(),A={x:0,y:0,k:1},t):_},t.y=function(e){return arguments.length?(k=e,w=e.copy(),A={x:0,y:0,k:1},t):k},co.rebind(t,I,"on")};var Ko,Qo,$o=[0,1/0];co.color=lt,lt.prototype.toString=function(){return this.rgb()+""},co.hsl=ct;var Jo=ct.prototype=new lt;Jo.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,this.l/t)},Jo.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,t*this.l)},Jo.rgb=function(){return ut(this.h,this.s,this.l)},co.hcl=ft;var ts=ft.prototype=new lt;ts.brighter=function(t){return new ft(this.h,this.c,Math.min(100,this.l+es*(arguments.length?t:1)))},ts.darker=function(t){return new ft(this.h,this.c,Math.max(0,this.l-es*(arguments.length?t:1)))},ts.rgb=function(){return ht(this.h,this.c,this.l).rgb()},co.lab=dt;var es=18,rs=.95047,ns=1,is=1.08883,as=dt.prototype=new lt;as.brighter=function(t){return new dt(Math.min(100,this.l+es*(arguments.length?t:1)),this.a,this.b)},as.darker=function(t){return new dt(Math.max(0,this.l-es*(arguments.length?t:1)),this.a,this.b)},as.rgb=function(){return pt(this.l,this.a,this.b)},co.rgb=bt;var os=bt.prototype=new lt;os.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&i>e&&(e=i),r&&i>r&&(r=i),n&&i>n&&(n=i),new bt(Math.min(255,e/t),Math.min(255,r/t),Math.min(255,n/t))):new bt(i,i,i)},os.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new bt(t*this.r,t*this.g,t*this.b)},os.hsl=function(){return At(this.r,this.g,this.b)},os.toString=function(){return"#"+wt(this.r)+wt(this.g)+wt(this.b)};var ss=co.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ss.forEach(function(t,e){ss.set(t,xt(e))}),co.functor=Lt,co.xhr=St(x),co.dsv=function(t,e){function r(t,r,a){arguments.length<3&&(a=r,r=null);var o=Ct(t,e,null==r?n:i(r),a);return o.row=function(t){return arguments.length?o.response(null==(r=t)?n:i(t)):r},o}function n(t){return r.parse(t.responseText)}function i(t){return function(e){return r.parse(e.responseText,t)}}function a(e){return e.map(o).join(t)}function o(t){return s.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var s=new RegExp('["'+t+"\n]"),l=t.charCodeAt(0);return r.parse=function(t,e){var n;return r.parseRows(t,function(t,r){if(n)return n(t,r-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");n=e?function(t,r){return e(i(t),r)}:i})},r.parseRows=function(t,e){function r(){if(u>=c)return o;if(i)return i=!1,a;var e=u;if(34===t.charCodeAt(e)){for(var r=e;r++u;){var n=t.charCodeAt(u++),s=1;if(10===n)i=!0;else if(13===n)i=!0,10===t.charCodeAt(u)&&(++u,++s);else if(n!==l)continue;return t.slice(e,u-s)}return t.slice(e)}for(var n,i,a={},o={},s=[],c=t.length,u=0,f=0;(n=r())!==o;){for(var h=[];n!==a&&n!==o;)h.push(n),n=r();e&&null==(h=e(h,f++))||s.push(h)}return s},r.format=function(e){if(Array.isArray(e[0]))return r.formatRows(e);var n=new b,i=[];return e.forEach(function(t){for(var e in t)n.has(e)||i.push(n.add(e))}),[i.map(o).join(t)].concat(e.map(function(e){return i.map(function(t){return o(e[t])}).join(t)})).join("\n")},r.formatRows=function(t){return t.map(a).join("\n")},r},co.csv=co.dsv(",","text/csv"),co.tsv=co.dsv(" ","text/tab-separated-values");var ls,cs,us,fs,hs=this[w(this,"requestAnimationFrame")]||function(t){setTimeout(t,17)};co.timer=function(){Rt.apply(this,arguments)},co.timer.flush=function(){It(),Nt()},co.round=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)};var ds=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Ft);co.formatPrefix=function(t,e){var r=0;return(t=+t)&&(0>t&&(t*=-1),e&&(t=co.round(t,jt(t,e))),r=1+Math.floor(1e-12+Math.log(t)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),ds[8+r/3]};var ps=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,gs=co.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=co.round(t,jt(t,e))).toFixed(Math.max(0,Math.min(20,jt(t*(1+1e-15),e))))}}),vs=co.time={},ms=Date;Ut.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ys.setUTCDate.apply(this._,arguments)},setDay:function(){ys.setUTCDay.apply(this._,arguments)},setFullYear:function(){ys.setUTCFullYear.apply(this._,arguments)},setHours:function(){ys.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ys.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ys.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ys.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ys.setUTCSeconds.apply(this._,arguments)},setTime:function(){ys.setTime.apply(this._,arguments)}};var ys=Date.prototype;vs.year=Vt(function(t){return t=vs.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),vs.years=vs.year.range,vs.years.utc=vs.year.utc.range,vs.day=Vt(function(t){var e=new ms(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),vs.days=vs.day.range,vs.days.utc=vs.day.utc.range,vs.dayOfYear=function(t){var e=vs.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var r=vs[t]=Vt(function(t){return(t=vs.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)-(r!==e)});vs[t+"s"]=r.range,vs[t+"s"].utc=r.utc.range,vs[t+"OfYear"]=function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)}}),vs.week=vs.sunday,vs.weeks=vs.sunday.range,vs.weeks.utc=vs.sunday.utc.range,vs.weekOfYear=vs.sundayOfYear;var bs={"-":"",_:" ",0:"0"},xs=/^\s*\d+/,_s=/^%/;co.locale=function(t){return{numberFormat:Bt(t),timeFormat:Ht(t)}};var ws=co.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});co.format=ws.numberFormat,co.geo={},fe.prototype={s:0,t:0,add:function(t){he(t,this.t,ks),he(ks.s,this.s,this),this.s?this.t+=ks.t:this.s=ks.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ks=new fe;co.geo.stream=function(t,e){t&&As.hasOwnProperty(t.type)?As[t.type](t,e):de(t,e)};var As={Feature:function(t,e){de(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++nt?4*Uo+t:t,Ls.lineStart=Ls.lineEnd=Ls.point=k}};co.geo.bounds=function(){function t(t,e){b.push(x=[u=t,h=t]),f>e&&(f=e),e>d&&(d=e)}function e(e,r){var n=me([e*Go,r*Go]);if(m){var i=be(m,n),a=[i[1],-i[0],0],o=be(a,i);we(o),o=ke(o);var l=e-p,c=l>0?1:-1,g=o[0]*Yo*c,v=wo(l)>180;if(v^(g>c*p&&c*e>g)){var y=o[1]*Yo;y>d&&(d=y)}else if(g=(g+360)%360-180,v^(g>c*p&&c*e>g)){var y=-o[1]*Yo;f>y&&(f=y)}else f>r&&(f=r),r>d&&(d=r);v?p>e?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e):h>=u?(u>e&&(u=e),e>h&&(h=e)):e>p?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e)}else t(e,r);m=n,p=e}function r(){_.point=e}function n(){x[0]=u,x[1]=h,_.point=t,m=null}function i(t,r){if(m){var n=t-p;y+=wo(n)>180?n+(n>0?360:-360):n}else g=t,v=r;Ls.point(t,r),e(t,r)}function a(){Ls.lineStart()}function o(){i(g,v),Ls.lineEnd(),wo(y)>Bo&&(u=-(h=180)),x[0]=u,x[1]=h,m=null}function s(t,e){return(e-=t)<0?e+360:e}function l(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tEs?(u=-(h=180),f=-(d=90)):y>Bo?d=90:-Bo>y&&(f=-90),x[0]=u,x[1]=h}};return function(t){d=h=-(u=f=1/0),b=[],co.geo.stream(t,_);var e=b.length;if(e){b.sort(l);for(var r,n=1,i=b[0],a=[i];e>n;++n)r=b[n],c(r[0],i)||c(r[1],i)?(s(i[0],r[1])>s(i[0],i[1])&&(i[1]=r[1]),s(r[0],i[1])>s(i[0],i[1])&&(i[0]=r[0])):a.push(i=r);for(var o,r,p=-(1/0),e=a.length-1,n=0,i=a[e];e>=n;i=r,++n)r=a[n],(o=s(i[1],r[0]))>p&&(p=o,u=r[0],h=i[1])}return b=x=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[h,d]]}}(),co.geo.centroid=function(t){Ss=Cs=zs=Ps=Rs=Os=Is=Ns=js=Fs=Bs=0,co.geo.stream(t,Ds);var e=js,r=Fs,n=Bs,i=e*e+r*r+n*n;return Do>i&&(e=Os,r=Is,n=Ns,Bo>Cs&&(e=zs,r=Ps,n=Rs),i=e*e+r*r+n*n,Do>i)?[NaN,NaN]:[Math.atan2(r,e)*Yo,nt(n/Math.sqrt(i))*Yo]};var Ss,Cs,zs,Ps,Rs,Os,Is,Ns,js,Fs,Bs,Ds={sphere:k,point:Me,lineStart:Ee,lineEnd:Le,polygonStart:function(){Ds.lineStart=Se},polygonEnd:function(){Ds.lineStart=Ee}},Us=Ie(ze,Be,Ue,[-Uo,-Uo/2]),Vs=1e9;co.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),i=a(t),i.valid=!0,i},extent:function(s){return arguments.length?(a=Ge(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(co.geo.conicEqualArea=function(){return Ye(Xe)}).raw=Xe,co.geo.albers=function(){return co.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},co.geo.albersUsa=function(){function t(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}var e,r,n,i,a=co.geo.albers(),o=co.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=co.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};return t.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&.234>i&&n>=-.425&&-.214>n?o:i>=.166&&.234>i&&n>=-.214&&-.115>n?s:a).invert(t)},t.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},t.precision=function(e){return arguments.length?(a.precision(e),o.precision(e),s.precision(e),t):a.precision()},t.scale=function(e){return arguments.length?(a.scale(e),o.scale(.35*e),s.scale(e),t.translate(a.translate())):a.scale()},t.translate=function(e){if(!arguments.length)return a.translate();var c=a.scale(),u=+e[0],f=+e[1];return r=a.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(l).point,n=o.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+Bo,f+.12*c+Bo],[u-.214*c-Bo,f+.234*c-Bo]]).stream(l).point,i=s.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+Bo,f+.166*c+Bo],[u-.115*c-Bo,f+.234*c-Bo]]).stream(l).point,t},t.scale(1070)};var qs,Hs,Gs,Ys,Xs,Ws,Zs={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Hs=0,Zs.lineStart=We},polygonEnd:function(){Zs.lineStart=Zs.lineEnd=Zs.point=k,qs+=wo(Hs/2)}},Ks={point:Ze,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},Qs={point:$e,lineStart:Je,lineEnd:tr,polygonStart:function(){Qs.lineStart=er},polygonEnd:function(){Qs.point=$e,Qs.lineStart=Je,Qs.lineEnd=tr}};co.geo.path=function(){function t(t){return t&&("function"==typeof s&&a.pointRadius(+s.apply(this,arguments)),o&&o.valid||(o=i(a)),co.geo.stream(t,o)),a.result()}function e(){return o=null,t}var r,n,i,a,o,s=4.5;return t.area=function(t){return qs=0,co.geo.stream(t,i(Zs)),qs},t.centroid=function(t){return zs=Ps=Rs=Os=Is=Ns=js=Fs=Bs=0,co.geo.stream(t,i(Qs)),Bs?[js/Bs,Fs/Bs]:Ns?[Os/Ns,Is/Ns]:Rs?[zs/Rs,Ps/Rs]:[NaN,NaN]},t.bounds=function(t){return Xs=Ws=-(Gs=Ys=1/0),co.geo.stream(t,i(Ks)),[[Gs,Ys],[Xs,Ws]]},t.projection=function(t){return arguments.length?(i=(r=t)?t.stream||ir(t):x,e()):r},t.context=function(t){return arguments.length?(a=null==(n=t)?new Ke:new rr(t),"function"!=typeof s&&a.pointRadius(s),e()):n},t.pointRadius=function(e){return arguments.length?(s="function"==typeof e?e:(a.pointRadius(+e),+e),t):s},t.projection(co.geo.albersUsa()).context(null)},co.geo.transform=function(t){return{stream:function(e){var r=new ar(e);for(var n in t)r[n]=t[n];return r}}},ar.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},co.geo.projection=sr,co.geo.projectionMutator=lr,(co.geo.equirectangular=function(){return sr(ur)}).raw=ur.invert=ur,co.geo.rotation=function(t){function e(e){return e=t(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e}return t=hr(t[0]%360*Go,t[1]*Go,t.length>2?t[2]*Go:0),e.invert=function(e){return e=t.invert(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e},e},fr.invert=ur,co.geo.circle=function(){function t(){var t="function"==typeof n?n.apply(this,arguments):n,e=hr(-t[0]*Go,-t[1]*Go,0).invert,i=[];return r(null,null,1,{point:function(t,r){i.push(t=e(t,r)),t[0]*=Yo,t[1]*=Yo}}),{type:"Polygon",coordinates:[i]}}var e,r,n=[0,0],i=6;return t.origin=function(e){return arguments.length?(n=e,t):n},t.angle=function(n){return arguments.length?(r=vr((e=+n)*Go,i*Go),t):e},t.precision=function(n){return arguments.length?(r=vr(e*Go,(i=+n)*Go),t):i},t.angle(90)},co.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Go,i=t[1]*Go,a=e[1]*Go,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),c=Math.cos(i),u=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-l*f*s)*r),l*u+c*f*s)},co.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return co.range(Math.ceil(a/v)*v,i,v).map(h).concat(co.range(Math.ceil(c/m)*m,l,m).map(d)).concat(co.range(Math.ceil(n/p)*p,r,p).filter(function(t){return wo(t%v)>Bo}).map(u)).concat(co.range(Math.ceil(s/g)*g,o,g).filter(function(t){return wo(t%m)>Bo}).map(f))}var r,n,i,a,o,s,l,c,u,f,h,d,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[h(a).concat(d(l).slice(1),h(i).reverse().slice(1),d(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(a=+e[0][0],i=+e[1][0],c=+e[0][1],l=+e[1][1],a>i&&(e=a,a=i,i=e),c>l&&(e=c,c=l,l=e),t.precision(y)):[[a,c],[i,l]]},t.minorExtent=function(e){return arguments.length?(n=+e[0][0],r=+e[1][0],s=+e[0][1],o=+e[1][1],n>r&&(e=n,n=r,r=e),s>o&&(e=s,s=o,o=e),t.precision(y)):[[n,s],[r,o]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=yr(s,o,90),f=br(n,r,y),h=yr(c,l,90),d=br(a,i,y),t):y},t.majorExtent([[-180,-90+Bo],[180,90-Bo]]).minorExtent([[-180,-80-Bo],[180,80+Bo]])},co.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}var e,r,n=xr,i=_r;return t.distance=function(){return co.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},t.source=function(r){return arguments.length?(n=r,e="function"==typeof r?null:r,t):n},t.target=function(e){return arguments.length?(i=e,r="function"==typeof e?null:e,t):i},t.precision=function(){return arguments.length?t:0},t},co.geo.interpolate=function(t,e){return wr(t[0]*Go,t[1]*Go,e[0]*Go,e[1]*Go)},co.geo.length=function(t){return $s=0,co.geo.stream(t,Js),$s};var $s,Js={sphere:k,point:k,lineStart:kr,lineEnd:k,polygonStart:k,polygonEnd:k},tl=Ar(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(co.geo.azimuthalEqualArea=function(){return sr(tl)}).raw=tl;var el=Ar(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},x);(co.geo.azimuthalEquidistant=function(){return sr(el)}).raw=el,(co.geo.conicConformal=function(){return Ye(Mr)}).raw=Mr,(co.geo.conicEquidistant=function(){return Ye(Tr)}).raw=Tr;var rl=Ar(function(t){return 1/t},Math.atan);(co.geo.gnomonic=function(){return sr(rl)}).raw=rl,Er.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Ho]},(co.geo.mercator=function(){return Lr(Er)}).raw=Er;var nl=Ar(function(){return 1},Math.asin);(co.geo.orthographic=function(){return sr(nl)}).raw=nl;var il=Ar(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(co.geo.stereographic=function(){return sr(il)}).raw=il,Sr.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ho]},(co.geo.transverseMercator=function(){var t=Lr(Sr),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):(t=r(),[t[0],t[1],t[2]-90])},r([0,0,90])}).raw=Sr,co.geom={},co.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,i=Lt(r),a=Lt(n),o=t.length,s=[],l=[];for(e=0;o>e;e++)s.push([+i.call(this,t[e],e),+a.call(this,t[e],e),e]);for(s.sort(Rr),e=0;o>e;e++)l.push([s[e][0],-s[e][1]]);var c=Pr(s),u=Pr(l),f=u[0]===c[0],h=u[u.length-1]===c[c.length-1],d=[];for(e=c.length-1;e>=0;--e)d.push(t[s[c[e]][2]]);for(e=+f;e=n&&c.x<=a&&c.y>=i&&c.y<=o?[[n,o],[a,o],[a,i],[n,i]]:[];u.point=t[s]}),e}function r(t){return t.map(function(t,e){return{x:Math.round(a(t,e)/Bo)*Bo,y:Math.round(o(t,e)/Bo)*Bo,i:e}})}var n=Cr,i=zr,a=n,o=i,s=dl;return t?e(t):(e.links=function(t){return cn(r(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cn(r(t)).cells.forEach(function(r,n){for(var i,a,o=r.site,s=r.edges.sort(Yr),l=-1,c=s.length,u=s[c-1].edge,f=u.l===o?u.r:u.l;++l=c,h=n>=u,d=h<<1|f;t.leaf=!1,t=t.nodes[d]||(t.nodes[d]=pn()),f?i=c:s=c,h?o=u:l=u,a(t,e,r,n,i,o,s,l)}var u,f,h,d,p,g,v,m,y,b=Lt(s),x=Lt(l);if(null!=e)g=e,v=r,m=n,y=i;else if(m=y=-(g=v=1/0),f=[],h=[],p=t.length,o)for(d=0;p>d;++d)u=t[d],u.xm&&(m=u.x),u.y>y&&(y=u.y),f.push(u.x),h.push(u.y);else for(d=0;p>d;++d){var _=+b(u=t[d],d),w=+x(u,d);g>_&&(g=_),v>w&&(v=w),_>m&&(m=_),w>y&&(y=w),f.push(_),h.push(w)}var k=m-g,A=y-v;k>A?y=v+k:m=g+A;var M=pn();if(M.add=function(t){a(M,t,+b(t,++d),+x(t,d),g,v,m,y)},M.visit=function(t){gn(t,M,g,v,m,y)},M.find=function(t){return vn(M,t[0],t[1],g,v,m,y)},d=-1,null==e){for(;++d=0?t.slice(0,e):t,n=e>=0?t.slice(e+1):"in";return r=ml.get(r)||vl,n=yl.get(n)||x,kn(n(r.apply(null,uo.call(arguments,1))))},co.interpolateHcl=Nn,co.interpolateHsl=jn,co.interpolateLab=Fn,co.interpolateRound=Bn,co.transform=function(t){var e=ho.createElementNS(co.ns.prefix.svg,"g");return(co.transform=function(t){if(null!=t){e.setAttribute("transform",t);var r=e.transform.baseVal.consolidate()}return new Dn(r?r.matrix:bl)})(t)},Dn.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var bl={a:1,b:0,c:0,d:1,e:0,f:0};co.interpolateTransform=Zn,co.layout={},co.layout.bundle=function(){return function(t){for(var e=[],r=-1,n=t.length;++rs*s/m){if(g>l){var c=e.charge/l;t.px-=a*c,t.py-=o*c}return!0}if(e.point&&l&&g>l){var c=e.pointCharge/l;t.px-=a*c,t.py-=o*c}}return!e.charge}}function e(t){t.px=co.event.x,t.py=co.event.y,l.resume()}var r,n,i,a,o,s,l={},c=co.dispatch("start","tick","end"),u=[1,1],f=.9,h=xl,d=_l,p=-30,g=wl,v=.1,m=.64,y=[],b=[];return l.tick=function(){if((i*=.99)<.005)return r=null,c.end({type:"end",alpha:i=0}),!0;var e,n,l,h,d,g,m,x,_,w=y.length,k=b.length;for(n=0;k>n;++n)l=b[n],h=l.source,d=l.target,x=d.x-h.x,_=d.y-h.y,(g=x*x+_*_)&&(g=i*o[n]*((g=Math.sqrt(g))-a[n])/g,x*=g,_*=g,d.x-=x*(m=h.weight+d.weight?h.weight/(h.weight+d.weight):.5),d.y-=_*m,h.x+=x*(m=1-m),h.y+=_*m);if((m=i*v)&&(x=u[0]/2,_=u[1]/2,n=-1,m))for(;++n0?i=t:(r.c=null,r.t=NaN,r=null,c.end({type:"end",alpha:i=0})):t>0&&(c.start({type:"start",alpha:i=t}),r=Rt(l.tick)),l):i},l.start=function(){function t(t,n){if(!r){for(r=new Array(i),l=0;i>l;++l)r[l]=[];for(l=0;c>l;++l){var a=b[l];r[a.source.index].push(a.target),r[a.target.index].push(a.source)}}for(var o,s=r[e],l=-1,u=s.length;++le;++e)(n=y[e]).index=e,n.weight=0;for(e=0;c>e;++e)n=b[e],"number"==typeof n.source&&(n.source=y[n.source]),"number"==typeof n.target&&(n.target=y[n.target]),++n.source.weight,++n.target.weight;for(e=0;i>e;++e)n=y[e],isNaN(n.x)&&(n.x=t("x",f)),isNaN(n.y)&&(n.y=t("y",g)),isNaN(n.px)&&(n.px=n.x),isNaN(n.py)&&(n.py=n.y);if(a=[],"function"==typeof h)for(e=0;c>e;++e)a[e]=+h.call(this,b[e],e);else for(e=0;c>e;++e)a[e]=h;if(o=[],"function"==typeof d)for(e=0;c>e;++e)o[e]=+d.call(this,b[e],e);else for(e=0;c>e;++e)o[e]=d;if(s=[],"function"==typeof p)for(e=0;i>e;++e)s[e]=+p.call(this,y[e],e);else for(e=0;i>e;++e)s[e]=p;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return n||(n=co.behavior.drag().origin(x).on("dragstart.force",ei).on("drag.force",e).on("dragend.force",ri)),arguments.length?void this.on("mouseover.force",ni).on("mouseout.force",ii).call(n):n},co.rebind(l,c,"on")};var xl=20,_l=1,wl=1/0;co.layout.hierarchy=function(){function t(i){var a,o=[i],s=[];for(i.depth=0;null!=(a=o.pop());)if(s.push(a),(c=r.call(t,a,a.depth))&&(l=c.length)){for(var l,c,u;--l>=0;)o.push(u=c[l]),u.parent=a,u.depth=a.depth+1;n&&(a.value=0),a.children=c}else n&&(a.value=+n.call(t,a,a.depth)||0),delete a.children;return li(i,function(t){var r,i;e&&(r=t.children)&&r.sort(e),n&&(i=t.parent)&&(i.value+=t.value)}),s}var e=fi,r=ci,n=ui;return t.sort=function(r){return arguments.length?(e=r,t):e},t.children=function(e){return arguments.length?(r=e,t):r},t.value=function(e){return arguments.length?(n=e,t):n},t.revalue=function(e){return n&&(si(e,function(t){t.children&&(t.value=0)}),li(e,function(e){var r;e.children||(e.value=+n.call(t,e,e.depth)||0),(r=e.parent)&&(r.value+=e.value)})),e},t},co.layout.partition=function(){function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,c=-1;for(n=e.value?n/e.value:0;++cf?-1:1),p=co.sum(c),g=p?(f-l*d)/p:0,v=co.range(l),m=[];return null!=r&&v.sort(r===kl?function(t,e){return c[e]-c[t]}:function(t,e){return r(o[t],o[e])}),v.forEach(function(t){m[t]={data:o[t],value:s=c[t],startAngle:u,endAngle:u+=s*g+d,padAngle:h}}),m}var e=Number,r=kl,n=0,i=Vo,a=0;return t.value=function(r){return arguments.length?(e=r,t):e},t.sort=function(e){return arguments.length?(r=e,t):r},t.startAngle=function(e){return arguments.length?(n=e,t):n},t.endAngle=function(e){return arguments.length?(i=e,t):i},t.padAngle=function(e){return arguments.length?(a=e,t):a},t};var kl={};co.layout.stack=function(){function t(s,l){if(!(h=s.length))return s;var c=s.map(function(r,n){return e.call(t,r,n)}),u=c.map(function(e){return e.map(function(e,r){return[a.call(t,e,r),o.call(t,e,r)]})}),f=r.call(t,u,l);c=co.permute(c,f),u=co.permute(u,f);var h,d,p,g,v=n.call(t,u,l),m=c[0].length;for(p=0;m>p;++p)for(i.call(t,c[0][p],g=v[p],u[0][p][1]),d=1;h>d;++d)i.call(t,c[d][p],g+=u[d-1][p][1],u[d][p][1]);return s}var e=x,r=vi,n=mi,i=gi,a=di,o=pi;return t.values=function(r){return arguments.length?(e=r,t):e},t.order=function(e){return arguments.length?(r="function"==typeof e?e:Al.get(e)||vi,t):r},t.offset=function(e){return arguments.length?(n="function"==typeof e?e:Ml.get(e)||mi,t):n},t.x=function(e){return arguments.length?(a=e,t):a},t.y=function(e){return arguments.length?(o=e,t):o},t.out=function(e){return arguments.length?(i=e,t):i},t};var Al=co.map({"inside-out":function(t){var e,r,n=t.length,i=t.map(yi),a=t.map(bi),o=co.range(n).sort(function(t,e){return i[t]-i[e]}),s=0,l=0,c=[],u=[];for(e=0;n>e;++e)r=o[e],l>s?(s+=a[r],c.push(r)):(l+=a[r],u.push(r));return u.reverse().concat(c)},reverse:function(t){return co.range(t.length).reverse()},"default":vi}),Ml=co.map({silhouette:function(t){var e,r,n,i=t.length,a=t[0].length,o=[],s=0,l=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];n>s&&(s=n),o.push(n)}for(r=0;a>r;++r)l[r]=(s-o[r])/2;return l},wiggle:function(t){var e,r,n,i,a,o,s,l,c,u=t.length,f=t[0],h=f.length,d=[];for(d[0]=l=c=0,r=1;h>r;++r){for(e=0,i=0;u>e;++e)i+=t[e][r][1];for(e=0,a=0,s=f[r][0]-f[r-1][0];u>e;++e){for(n=0,o=(t[e][r][1]-t[e][r-1][1])/(2*s);e>n;++n)o+=(t[n][r][1]-t[n][r-1][1])/s;a+=o*t[e][r][1]}d[r]=l-=i?a/i*s:0,c>l&&(c=l)}for(r=0;h>r;++r)d[r]-=c;return d},expand:function(t){var e,r,n,i=t.length,a=t[0].length,o=1/i,s=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];if(n)for(e=0;i>e;e++)t[e][r][1]/=n;else for(e=0;i>e;e++)t[e][r][1]=o}for(r=0;a>r;++r)s[r]=0;return s},zero:mi});co.layout.histogram=function(){function t(t,a){for(var o,s,l=[],c=t.map(r,this),u=n.call(this,c,a),f=i.call(this,u,c,a),a=-1,h=c.length,d=f.length-1,p=e?1:1/h;++a0)for(a=-1;++a=u[0]&&s<=u[1]&&(o=l[co.bisect(f,s,1,d)-1],o.y+=p,o.push(t[a]));return l}var e=!0,r=Number,n=ki,i=_i;return t.value=function(e){return arguments.length?(r=e,t):r},t.range=function(e){return arguments.length?(n=Lt(e),t):n},t.bins=function(e){return arguments.length?(i="number"==typeof e?function(t){return wi(t,e)}:Lt(e),t):i},t.frequency=function(r){return arguments.length?(e=!!r,t):e},t},co.layout.pack=function(){function t(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],c=i[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,li(s,function(t){t.r=+u(t.value)}),li(s,Li),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/c))/2;li(s,function(t){t.r+=f}),li(s,Li),li(s,function(t){t.r-=f})}return zi(s,l/2,c/2,e?1:1/Math.max(2*s.r/l,2*s.r/c)),o}var e,r=co.layout.hierarchy().sort(Ai),n=0,i=[1,1];return t.size=function(e){return arguments.length?(i=e,t):i},t.radius=function(r){return arguments.length?(e=null==r||"function"==typeof r?r:+r,t):e},t.padding=function(e){return arguments.length?(n=+e,t):n},oi(t,r)},co.layout.tree=function(){function t(t,i){var u=o.call(this,t,i),f=u[0],h=e(f);if(li(h,r),h.parent.m=-h.z,si(h,n),c)si(f,a);else{var d=f,p=f,g=f;si(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=s(d,p)/2-d.x,m=l[0]/(p.x+s(p,d)/2+v),y=l[1]/(g.depth||1);si(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return u}function e(t){for(var e,r={A:null,children:[t]},n=[r];null!=(e=n.pop());)for(var i,a=e.children,o=0,s=a.length;s>o;++o)n.push((a[o]=i={_:a[o],parent:e,children:(i=a[o].children)&&i.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=i);return r.children[0]}function r(t){var e=t.children,r=t.parent.children,n=t.i?r[t.i-1]:null;if(e.length){ji(t);var a=(e[0].z+e[e.length-1].z)/2;n?(t.z=n.z+s(t._,n._),t.m=t.z-a):t.z=a}else n&&(t.z=n.z+s(t._,n._));t.parent.A=i(t,n,t.parent.A||r[0])}function n(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function i(t,e,r){if(e){for(var n,i=t,a=t,o=e,l=i.parent.children[0],c=i.m,u=a.m,f=o.m,h=l.m;o=Ii(o),i=Oi(i),o&&i;)l=Oi(l),a=Ii(a),a.a=t,n=o.z+f-i.z-c+s(o._,i._),n>0&&(Ni(Fi(o,t,r),t,n),c+=n,u+=n),f+=o.m,c+=i.m,h+=l.m,u+=a.m;o&&!Ii(a)&&(a.t=o,a.m+=f-u),i&&!Oi(l)&&(l.t=i,l.m+=c-h,r=t)}return r}function a(t){t.x*=l[0],t.y=t.depth*l[1]}var o=co.layout.hierarchy().sort(null).value(null),s=Ri,l=[1,1],c=null;return t.separation=function(e){return arguments.length?(s=e,t):s},t.size=function(e){return arguments.length?(c=null==(l=e)?a:null,t):c?null:l},t.nodeSize=function(e){return arguments.length?(c=null==(l=e)?null:a,t):c?l:null},oi(t,o)},co.layout.cluster=function(){function t(t,a){var o,s=e.call(this,t,a),l=s[0],c=0;li(l,function(t){var e=t.children;e&&e.length?(t.x=Di(e),t.y=Bi(e)):(t.x=o?c+=r(t,o):0,t.y=0,o=t)});var u=Ui(l),f=Vi(l),h=u.x-r(u,f)/2,d=f.x+r(f,u)/2;return li(l,i?function(t){t.x=(t.x-l.x)*n[0],t.y=(l.y-t.y)*n[1]}:function(t){t.x=(t.x-h)/(d-h)*n[0],t.y=(1-(l.y?t.y/l.y:1))*n[1]}),s}var e=co.layout.hierarchy().sort(null).value(null),r=Ri,n=[1,1],i=!1;return t.separation=function(e){return arguments.length?(r=e,t):r},t.size=function(e){return arguments.length?(i=null==(n=e),t):i?null:n},t.nodeSize=function(e){return arguments.length?(i=null!=(n=e),t):i?n:null},oi(t,e)},co.layout.treemap=function(){function t(t,e){for(var r,n,i=-1,a=t.length;++ie?0:e),r.area=isNaN(n)||0>=n?0:n}function e(r){var a=r.children;if(a&&a.length){var o,s,l,c=f(r),u=[],h=a.slice(),p=1/0,g="slice"===d?c.dx:"dice"===d?c.dy:"slice-dice"===d?1&r.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(t(h,c.dx*c.dy/r.value),u.area=0;(l=h.length)>0;)u.push(o=h[l-1]),u.area+=o.area,"squarify"!==d||(s=n(u,g))<=p?(h.pop(),p=s):(u.area-=u.pop().area,i(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(i(u,g,c,!0),u.length=u.area=0),a.forEach(e)}}function r(e){var n=e.children;if(n&&n.length){var a,o=f(e),s=n.slice(),l=[];for(t(s,o.dx*o.dy/e.value),l.area=0;a=s.pop();)l.push(a),l.area+=a.area,null!=a.z&&(i(l,a.z?o.dx:o.dy,o,!s.length),l.length=l.area=0);n.forEach(r)}}function n(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++or&&(a=r),r>i&&(i=r));return n*=n,e*=e,n?Math.max(e*i*p/n,n/(e*a*p)):1/0}function i(t,e,r,n){var i,a=-1,o=t.length,s=r.x,c=r.y,u=e?l(t.area/e):0;if(e==r.dx){for((n||u>r.dy)&&(u=r.dy);++ar.dx)&&(u=r.dx);++ar&&(e=1),1>r&&(t=0),function(){var r,n,i;do r=2*Math.random()-1,n=2*Math.random()-1,i=r*r+n*n;while(!i||i>1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=co.random.normal.apply(co,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=co.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,r=0;t>r;r++)e+=Math.random();return e}}},co.scale={};var Tl={floor:x,ceil:x};co.scale.linear=function(){return Qi([0,1],[0,1],_n,!1)};var El={s:1,g:1,p:1,r:1,e:1};co.scale.log=function(){return aa(co.scale.linear().domain([0,1]),10,!0,[1,10])};var Ll=co.format(".0e"),Sl={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};co.scale.pow=function(){return oa(co.scale.linear(),1,[0,1])},co.scale.sqrt=function(){return co.scale.pow().exponent(.5)},co.scale.ordinal=function(){return la([],{t:"range",a:[[]]})},co.scale.category10=function(){return co.scale.ordinal().range(Cl)},co.scale.category20=function(){return co.scale.ordinal().range(zl)},co.scale.category20b=function(){return co.scale.ordinal().range(Pl)},co.scale.category20c=function(){return co.scale.ordinal().range(Rl)};var Cl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(_t),zl=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(_t),Pl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(_t),Rl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(_t);co.scale.quantile=function(){return ca([],[])},co.scale.quantize=function(){return ua(0,1,[0,1])},co.scale.threshold=function(){return fa([.5],[0,1])},co.scale.identity=function(){return ha([0,1])},co.svg={},co.svg.arc=function(){function t(){var t=Math.max(0,+r.apply(this,arguments)),c=Math.max(0,+n.apply(this,arguments)),u=o.apply(this,arguments)-Ho,f=s.apply(this,arguments)-Ho,h=Math.abs(f-u),d=u>f?0:1;if(t>c&&(p=c,c=t,t=p),h>=qo)return e(c,d)+(t?e(t,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,k,A,M,T=0,E=0,L=[];if((m=(+l.apply(this,arguments)||0)/2)&&(v=a===Ol?Math.sqrt(t*t+c*c):+a.apply(this,arguments),d||(E*=-1),c&&(E=nt(v/c*Math.sin(m))),t&&(T=nt(v/t*Math.sin(m)))),c){y=c*Math.cos(u+E),b=c*Math.sin(u+E),x=c*Math.cos(f-E),_=c*Math.sin(f-E);var S=Math.abs(f-u-2*E)<=Uo?0:1;if(E&&ba(y,b,x,_)===d^S){var C=(u+f)/2;y=c*Math.cos(C),b=c*Math.sin(C),x=_=null}}else y=b=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),A=t*Math.cos(u+T),M=t*Math.sin(u+T);var z=Math.abs(u-f+2*T)<=Uo?0:1;if(T&&ba(w,k,A,M)===1-d^z){var P=(u+f)/2;w=t*Math.cos(P),k=t*Math.sin(P),A=M=null}}else w=k=0;if(h>Bo&&(p=Math.min(Math.abs(c-t)/2,+i.apply(this,arguments)))>.001){g=c>t^d?0:1;var R=p,O=p;if(Uo>h){var I=null==A?[w,k]:null==x?[y,b]:Ir([y,b],[A,M],[x,_],[w,k]),N=y-I[0],j=b-I[1],F=x-I[0],B=_-I[1],D=1/Math.sin(Math.acos((N*F+j*B)/(Math.sqrt(N*N+j*j)*Math.sqrt(F*F+B*B)))/2),U=Math.sqrt(I[0]*I[0]+I[1]*I[1]);O=Math.min(p,(t-U)/(D-1)),R=Math.min(p,(c-U)/(D+1))}if(null!=x){var V=xa(null==A?[w,k]:[A,M],[y,b],c,R,d),q=xa([x,_],[w,k],c,R,d);p===R?L.push("M",V[0],"A",R,",",R," 0 0,",g," ",V[1],"A",c,",",c," 0 ",1-d^ba(V[1][0],V[1][1],q[1][0],q[1][1]),",",d," ",q[1],"A",R,",",R," 0 0,",g," ",q[0]):L.push("M",V[0],"A",R,",",R," 0 1,",g," ",q[0])}else L.push("M",y,",",b);if(null!=A){var H=xa([y,b],[A,M],t,-O,d),G=xa([w,k],null==x?[y,b]:[x,_],t,-O,d);p===O?L.push("L",G[0],"A",O,",",O," 0 0,",g," ",G[1],"A",t,",",t," 0 ",d^ba(G[1][0],G[1][1],H[1][0],H[1][1]),",",1-d," ",H[1],"A",O,",",O," 0 0,",g," ",H[0]):L.push("L",G[0],"A",O,",",O," 0 0,",g," ",H[0])}else L.push("L",w,",",k)}else L.push("M",y,",",b),null!=x&&L.push("A",c,",",c," 0 ",S,",",d," ",x,",",_),L.push("L",w,",",k),null!=A&&L.push("A",t,",",t," 0 ",z,",",1-d," ",A,",",M);return L.push("Z"),L.join("")}function e(t,e){return"M0,"+t+"A"+t+","+t+" 0 1,"+e+" 0,"+-t+"A"+t+","+t+" 0 1,"+e+" 0,"+t}var r=pa,n=ga,i=da,a=Ol,o=va,s=ma,l=ya;return t.innerRadius=function(e){return arguments.length?(r=Lt(e),t):r},t.outerRadius=function(e){return arguments.length?(n=Lt(e),t):n},t.cornerRadius=function(e){return arguments.length?(i=Lt(e),t):i},t.padRadius=function(e){return arguments.length?(a=e==Ol?Ol:Lt(e),t):a},t.startAngle=function(e){return arguments.length?(o=Lt(e),t):o},t.endAngle=function(e){return arguments.length?(s=Lt(e),t):s},t.padAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.centroid=function(){var t=(+r.apply(this,arguments)+ +n.apply(this,arguments))/2,e=(+o.apply(this,arguments)+ +s.apply(this,arguments))/2-Ho;return[Math.cos(e)*t,Math.sin(e)*t]},t};var Ol="auto";co.svg.line=function(){return _a(x)};var Il=co.map({linear:wa,"linear-closed":ka,step:Aa,"step-before":Ma,"step-after":Ta,basis:Pa,"basis-open":Ra,"basis-closed":Oa,bundle:Ia,cardinal:Sa,"cardinal-open":Ea,"cardinal-closed":La,monotone:Ua});Il.forEach(function(t,e){e.key=t,e.closed=/-closed$/.test(t)});var Nl=[0,2/3,1/3,0],jl=[0,1/3,2/3,0],Fl=[0,1/6,2/3,1/6];co.svg.line.radial=function(){var t=_a(Va);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},Ma.reverse=Ta,Ta.reverse=Ma,co.svg.area=function(){return qa(x)},co.svg.area.radial=function(){var t=qa(Va);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},co.svg.chord=function(){function t(t,s){var l=e(this,a,t,s),c=e(this,o,t,s);return"M"+l.p0+n(l.r,l.p1,l.a1-l.a0)+(r(l,c)?i(l.r,l.p1,l.r,l.p0):i(l.r,l.p1,c.r,c.p0)+n(c.r,c.p1,c.a1-c.a0)+i(c.r,c.p1,l.r,l.p0))+"Z"}function e(t,e,r,n){var i=e.call(t,r,n),a=s.call(t,i,n),o=l.call(t,i,n)-Ho,u=c.call(t,i,n)-Ho;return{r:a,a0:o,a1:u,p0:[a*Math.cos(o),a*Math.sin(o)],p1:[a*Math.cos(u),a*Math.sin(u)]}}function r(t,e){return t.a0==e.a0&&t.a1==e.a1}function n(t,e,r){return"A"+t+","+t+" 0 "+ +(r>Uo)+",1 "+e}function i(t,e,r,n){return"Q 0,0 "+n}var a=xr,o=_r,s=Ha,l=va,c=ma;return t.radius=function(e){return arguments.length?(s=Lt(e),t):s},t.source=function(e){return arguments.length?(a=Lt(e),t):a},t.target=function(e){return arguments.length?(o=Lt(e),t):o},t.startAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.endAngle=function(e){return arguments.length?(c=Lt(e),t):c},t},co.svg.diagonal=function(){function t(t,i){var a=e.call(this,t,i),o=r.call(this,t,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return l=l.map(n),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var e=xr,r=_r,n=Ga;return t.source=function(r){return arguments.length?(e=Lt(r),t):e},t.target=function(e){return arguments.length?(r=Lt(e),t):r},t.projection=function(e){return arguments.length?(n=e,t):n},t},co.svg.diagonal.radial=function(){var t=co.svg.diagonal(),e=Ga,r=t.projection;return t.projection=function(t){return arguments.length?r(Ya(e=t)):e},t},co.svg.symbol=function(){function t(t,n){return(Bl.get(e.call(this,t,n))||Za)(r.call(this,t,n))}var e=Wa,r=Xa;return t.type=function(r){return arguments.length?(e=Lt(r),t):e},t.size=function(e){return arguments.length?(r=Lt(e),t):r},t};var Bl=co.map({circle:Za,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Ul)),r=e*Ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/Dl),r=e*Dl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/Dl),r=e*Dl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});co.svg.symbolTypes=Bl.keys();var Dl=Math.sqrt(3),Ul=Math.tan(30*Go);zo.transition=function(t){for(var e,r,n=Vl||++Yl,i=to(t),a=[],o=ql||{time:Date.now(),ease:Ln,delay:0,duration:250},s=-1,l=this.length;++sa;a++){i.push(e=[]);for(var r=this[a],s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return Qa(i,this.namespace,this.id)},Gl.tween=function(t,e){var r=this.id,n=this.namespace;return arguments.length<2?this.node()[n][r].tween.get(t):G(this,null==e?function(e){e[n][r].tween.remove(t)}:function(i){i[n][r].tween.set(t,e)})},Gl.attr=function(t,e){function r(){this.removeAttribute(s)}function n(){this.removeAttributeNS(s.space,s.local)}function i(t){return null==t?r:(t+="",function(){var e,r=this.getAttribute(s);return r!==t&&(e=o(r,t),function(t){this.setAttribute(s,e(t))})})}function a(t){return null==t?n:(t+="",function(){var e,r=this.getAttributeNS(s.space,s.local);return r!==t&&(e=o(r,t),function(t){this.setAttributeNS(s.space,s.local,e(t))})})}if(arguments.length<2){for(e in t)this.attr(e,t[e]);return this}var o="transform"==t?Zn:_n,s=co.ns.qualify(t);return $a(this,"attr."+t,e,s.local?a:i)},Gl.attrTween=function(t,e){function r(t,r){var n=e.call(this,t,r,this.getAttribute(i));return n&&function(t){this.setAttribute(i,n(t))}}function n(t,r){var n=e.call(this,t,r,this.getAttributeNS(i.space,i.local));return n&&function(t){this.setAttributeNS(i.space,i.local,n(t))}}var i=co.ns.qualify(t);return this.tween("attr."+t,i.local?n:r)},Gl.style=function(t,e,r){function i(){this.style.removeProperty(t)}function a(e){return null==e?i:(e+="",function(){var i,a=n(this).getComputedStyle(this,null).getPropertyValue(t);return a!==e&&(i=_n(a,e),function(e){this.style.setProperty(t,i(e),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof t){2>o&&(e="");for(r in t)this.style(r,t[r],e);return this}r=""}return $a(this,"style."+t,e,a)},Gl.styleTween=function(t,e,r){function i(i,a){var o=e.call(this,i,a,n(this).getComputedStyle(this,null).getPropertyValue(t));return o&&function(e){this.style.setProperty(t,o(e),r)}}return arguments.length<3&&(r=""),this.tween("style."+t,i)},Gl.text=function(t){return $a(this,"text",t,Ja)},Gl.remove=function(){var t=this.namespace;return this.each("end.transition",function(){var e;this[t].count<2&&(e=this.parentNode)&&e.removeChild(this)})},Gl.ease=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].ease:("function"!=typeof t&&(t=co.ease.apply(co,arguments)),G(this,function(n){n[r][e].ease=t}))},Gl.delay=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].delay:G(this,"function"==typeof t?function(n,i,a){n[r][e].delay=+t.call(n,n.__data__,i,a)}:(t=+t,function(n){n[r][e].delay=t}))},Gl.duration=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].duration:G(this,"function"==typeof t?function(n,i,a){n[r][e].duration=Math.max(1,t.call(n,n.__data__,i,a))}:(t=Math.max(1,t),function(n){n[r][e].duration=t}))},Gl.each=function(t,e){var r=this.id,n=this.namespace;if(arguments.length<2){var i=ql,a=Vl;try{Vl=r,G(this,function(e,i,a){ql=e[n][r],t.call(e,e.__data__,i,a)})}finally{ql=i,Vl=a}}else G(this,function(i){var a=i[n][r];(a.event||(a.event=co.dispatch("start","end","interrupt"))).on(t,e)});return this},Gl.transition=function(){for(var t,e,r,n,i=this.id,a=++Yl,o=this.namespace,s=[],l=0,c=this.length;c>l;l++){s.push(t=[]);for(var e=this[l],u=0,f=e.length;f>u;u++)(r=e[u])&&(n=r[o][i],eo(r,u,o,a,{time:n.time,ease:n.ease,delay:n.delay+n.duration,duration:n.duration})),t.push(r)}return Qa(s,o,a)},co.svg.axis=function(){function t(t){t.each(function(){var t,c=co.select(this),u=this.__chart__||r,f=this.__chart__=r.copy(),h=null==l?f.ticks?f.ticks.apply(f,s):f.domain():l,d=null==e?f.tickFormat?f.tickFormat.apply(f,s):x:e,p=c.selectAll(".tick").data(h,f),g=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Bo),v=co.transition(p.exit()).style("opacity",Bo).remove(),m=co.transition(p.order()).style("opacity",1),y=Math.max(i,0)+o,b=Yi(f),_=c.selectAll(".domain").data([0]),w=(_.enter().append("path").attr("class","domain"),co.transition(_));g.append("line"),g.append("text");var k,A,M,T,E=g.select("line"),L=m.select("line"),S=p.select("text").text(d),C=g.select("text"),z=m.select("text"),P="top"===n||"left"===n?-1:1;if("bottom"===n||"top"===n?(t=ro,k="x",M="y",A="x2",T="y2",S.attr("dy",0>P?"0em":".71em").style("text-anchor","middle"),w.attr("d","M"+b[0]+","+P*a+"V0H"+b[1]+"V"+P*a)):(t=no,k="y",M="x",A="y2",T="x2",S.attr("dy",".32em").style("text-anchor",0>P?"end":"start"),w.attr("d","M"+P*a+","+b[0]+"H0V"+b[1]+"H"+P*a)),E.attr(T,P*i),C.attr(M,P*y),L.attr(A,0).attr(T,P*i),z.attr(k,0).attr(M,P*y),f.rangeBand){var R=f,O=R.rangeBand()/2;u=f=function(t){return R(t)+O}}else u.rangeBand?u=f:v.call(t,f,u);g.call(t,u,f),m.call(t,f,f)})}var e,r=co.scale.linear(),n=Xl,i=6,a=6,o=3,s=[10],l=null;return t.scale=function(e){return arguments.length?(r=e,t):r},t.orient=function(e){return arguments.length?(n=e in Wl?e+"":Xl,t):n},t.ticks=function(){return arguments.length?(s=fo(arguments),t):s},t.tickValues=function(e){return arguments.length?(l=e,t):l},t.tickFormat=function(r){return arguments.length?(e=r,t):e},t.tickSize=function(e){var r=arguments.length;return r?(i=+e,a=+arguments[r-1],t):i},t.innerTickSize=function(e){return arguments.length?(i=+e,t):i},t.outerTickSize=function(e){return arguments.length?(a=+e,t):a},t.tickPadding=function(e){return arguments.length?(o=+e,t):o},t.tickSubdivide=function(){return arguments.length&&t},t};var Xl="bottom",Wl={top:1,right:1,bottom:1,left:1};co.svg.brush=function(){function t(n){n.each(function(){var n=co.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",a).on("touchstart.brush",a),o=n.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),n.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var s=n.selectAll(".resize").data(g,x);s.exit().remove(),s.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return Zl[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),s.style("display",t.empty()?"none":null);var l,f=co.transition(n),h=co.transition(o);c&&(l=Yi(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(f)),u&&(l=Yi(u),h.attr("y",l[0]).attr("height",l[1]-l[0]),i(f)),e(f)})}function e(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+f[+/e$/.test(t)]+","+h[+/^s/.test(t)]+")"})}function r(t){t.select(".extent").attr("x",f[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function i(t){t.select(".extent").attr("y",h[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function a(){function a(){32==co.event.keyCode&&(S||(b=null,z[0]-=f[1],z[1]-=h[1],S=2),T())}function g(){32==co.event.keyCode&&2==S&&(z[0]+=f[1],z[1]+=h[1],S=0,T())}function v(){var t=co.mouse(_),n=!1;x&&(t[0]+=x[0],t[1]+=x[1]),S||(co.event.altKey?(b||(b=[(f[0]+f[1])/2,(h[0]+h[1])/2]),z[0]=f[+(t[0]u?(i=n,n=u):i=u),g[0]!=n||g[1]!=i?(r?s=null:o=null,g[0]=n,g[1]=i,!0):void 0}function y(){v(),A.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),co.select("body").style("cursor",null),P.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),k({type:"brushend"})}var b,x,_=this,w=co.select(co.event.target),k=l.of(_,arguments),A=co.select(_),M=w.datum(),E=!/^(n|s)$/.test(M)&&c,L=!/^(e|w)$/.test(M)&&u,S=w.classed("extent"),C=Q(_),z=co.mouse(_),P=co.select(n(_)).on("keydown.brush",a).on("keyup.brush",g);if(co.event.changedTouches?P.on("touchmove.brush",v).on("touchend.brush",y):P.on("mousemove.brush",v).on("mouseup.brush",y),A.interrupt().selectAll("*").interrupt(),S)z[0]=f[0]-z[0],z[1]=h[0]-z[1];else if(M){var R=+/w$/.test(M),O=+/^n/.test(M);x=[f[1-R]-z[0],h[1-O]-z[1]],z[0]=f[R],z[1]=h[O]}else co.event.altKey&&(b=z.slice());A.style("pointer-events","none").selectAll(".resize").style("display",null),co.select("body").style("cursor",w.style("cursor")),k({type:"brushstart"}),v()}var o,s,l=L(t,"brushstart","brush","brushend"),c=null,u=null,f=[0,0],h=[0,0],d=!0,p=!0,g=Kl[0];return t.event=function(t){t.each(function(){var t=l.of(this,arguments),e={x:f,y:h,i:o,j:s},r=this.__chart__||e;this.__chart__=e,Vl?co.select(this).transition().each("start.brush",function(){o=r.i,s=r.j,f=r.x,h=r.y,t({type:"brushstart"})}).tween("brush:brush",function(){var r=wn(f,e.x),n=wn(h,e.y);return o=s=null,function(i){f=e.x=r(i),h=e.y=n(i),t({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=e.i,s=e.j,t({type:"brush",mode:"resize"}),t({type:"brushend"})}):(t({type:"brushstart"}),t({type:"brush",mode:"resize"}),t({type:"brushend"}))})},t.x=function(e){return arguments.length?(c=e,g=Kl[!c<<1|!u],t):c},t.y=function(e){return arguments.length?(u=e,g=Kl[!c<<1|!u],t):u},t.clamp=function(e){return arguments.length?(c&&u?(d=!!e[0],p=!!e[1]):c?d=!!e:u&&(p=!!e),t):c&&u?[d,p]:c?d:u?p:null},t.extent=function(e){var r,n,i,a,l;return arguments.length?(c&&(r=e[0],n=e[1],u&&(r=r[0],n=n[0]),o=[r,n],c.invert&&(r=c(r),n=c(n)),r>n&&(l=r,r=n,n=l),r==f[0]&&n==f[1]||(f=[r,n])),u&&(i=e[0],a=e[1],c&&(i=i[1],a=a[1]),s=[i,a],u.invert&&(i=u(i),a=u(a)),i>a&&(l=i,i=a,a=l),i==h[0]&&a==h[1]||(h=[i,a])),t):(c&&(o?(r=o[0],n=o[1]):(r=f[0],n=f[1],c.invert&&(r=c.invert(r),n=c.invert(n)),r>n&&(l=r,r=n,n=l))),u&&(s?(i=s[0],a=s[1]):(i=h[0],a=h[1],u.invert&&(i=u.invert(i),a=u.invert(a)),i>a&&(l=i,i=a,a=l))),c&&u?[[r,i],[n,a]]:c?[r,n]:u&&[i,a])},t.clear=function(){return t.empty()||(f=[0,0],h=[0,0],o=s=null),t},t.empty=function(){return!!c&&f[0]==f[1]||!!u&&h[0]==h[1]},co.rebind(t,l,"on")};var Zl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Kl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Ql=vs.format=ws.timeFormat,$l=Ql.utc,Jl=$l("%Y-%m-%dT%H:%M:%S.%LZ");Ql.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?io:Jl,io.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},io.toString=Jl.toString,vs.second=Vt(function(t){return new ms(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),vs.seconds=vs.second.range,vs.seconds.utc=vs.second.utc.range,vs.minute=Vt(function(t){return new ms(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),vs.minutes=vs.minute.range,vs.minutes.utc=vs.minute.utc.range,vs.hour=Vt(function(t){var e=t.getTimezoneOffset()/60;return new ms(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),vs.hours=vs.hour.range,vs.hours.utc=vs.hour.utc.range,vs.month=Vt(function(t){return t=vs.day(t),t.setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),vs.months=vs.month.range,vs.months.utc=vs.month.utc.range;var tc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],ec=[[vs.second,1],[vs.second,5],[vs.second,15],[vs.second,30],[vs.minute,1],[vs.minute,5],[vs.minute,15],[vs.minute,30],[vs.hour,1],[vs.hour,3],[vs.hour,6],[vs.hour,12],[vs.day,1],[vs.day,2],[vs.week,1],[vs.month,1],[vs.month,3],[vs.year,1]],rc=Ql.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",ze]]),nc={range:function(t,e,r){return co.range(Math.ceil(t/r)*r,+e,r).map(oo)},floor:x,ceil:x};ec.year=vs.year,vs.scale=function(){return ao(co.scale.linear(),ec,rc)};var ic=ec.map(function(t){return[t[0].utc,t[1]]}),ac=$l.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",ze]]);ic.year=vs.year.utc,vs.scale.utc=function(){return ao(co.scale.linear(),ic,ac)},co.text=St(function(t){return t.responseText}),co.json=function(t,e){return Ct(t,"application/json",so,e)},co.html=function(t,e){return Ct(t,"text/html",lo,e)},co.xml=St(function(t){return t.responseXML}),"function"==typeof t&&t.amd?(this.d3=co,t(co)):"object"==typeof r&&r.exports?r.exports=co:this.d3=co}()},{}],88:[function(t,e,r){"use strict";function n(t,e){this.point=t,this.index=e}function i(t,e){for(var r=t.point,n=e.point,i=r.length,a=0;i>a;++a){var o=n[a]-r[a];if(o)return o}return 0}function a(t,e,r){if(1===t)return r?[[-1,0]]:[];var n=e.map(function(t,e){return[t[0],e]});n.sort(function(t,e){return t[0]-e[0]});for(var i=new Array(t-1),a=1;t>a;++a){var o=n[a-1],s=n[a];i[a-1]=[o[1],s[1]]}return r&&i.push([-1,i[0][1]],[i[t-1][1],-1]),i}function o(t,e){var r=t.length;if(0===r)return[];var o=t[0].length;if(1>o)return[];if(1===o)return a(r,t,e);for(var c=new Array(r),u=1,f=0;r>f;++f){for(var h=t[f],d=new Array(o+1),p=0,g=0;o>g;++g){var v=h[g];d[g]=v,p+=v*v}d[o]=p,c[f]=new n(d,f),u=Math.max(p,u)}l(c,i),r=c.length;for(var m=new Array(r+o+1),y=new Array(r+o+1),b=(o+1)*(o+1)*u,x=new Array(o+1),f=0;o>=f;++f)x[f]=0;x[o]=b,m[0]=x.slice(),y[0]=-1;for(var f=0;o>=f;++f){var d=x.slice();d[f]=1,m[f+1]=d,y[f+1]=-1}for(var f=0;r>f;++f){var _=c[f];m[f+o+1]=_.point,y[f+o+1]=_.index}var w=s(m,!1);if(w=e?w.filter(function(t){for(var e=0,r=0;o>=r;++r){var n=y[t[r]];if(0>n&&++e>=2)return!1;t[r]=n}return!0}):w.filter(function(t){for(var e=0;o>=e;++e){var r=y[t[e]];if(0>r)return!1;t[e]=r}return!0}),1&o)for(var f=0;f>>31},e.exports.exponent=function(t){var r=e.exports.hi(t);return(r<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){var r=e.exports.hi(t);return!(2146435072&r)}}).call(this,t("buffer").Buffer)},{buffer:58}],90:[function(t,e,r){"use strict";function n(t,e,r){var i=0|t[r];if(0>=i)return[];var a,o=new Array(i);if(r===t.length-1)for(a=0;i>a;++a)o[a]=e;else for(a=0;i>a;++a)o[a]=n(t,e,r+1);return o}function i(t,e){var r,n;for(r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return i(0|t,e);break;case"object":if("number"==typeof t.length)return n(t,e,0)}return[]}e.exports=a},{}],91:[function(t,e,r){"use strict";function n(t,e){var r=t.length;if("number"!=typeof e){e=0;for(var n=0;r>n;++n){var a=t[n];e=Math.max(e,a[0],a[1])}e=(0|e)+1}e=0|e;for(var o=new Array(e),n=0;e>n;++n)o[n]=[];for(var n=0;r>n;++n){var a=t[n];o[a[0]].push(a[1]),o[a[1]].push(a[0])}for(var s=0;e>s;++s)i(o[s],function(t,e){return t-e});return o}e.exports=n;var i=t("uniq")},{uniq:284}],92:[function(e,r,n){(function(n,i){(function(){"use strict";function a(t){return"function"==typeof t||"object"==typeof t&&null!==t}function o(t){return"function"==typeof t}function s(t){Z=t}function l(t){J=t}function c(){return function(){n.nextTick(p)}}function u(){return function(){W(p)}}function f(){var t=0,e=new rt(p),r=document.createTextNode("");return e.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}function h(){var t=new MessageChannel;return t.port1.onmessage=p,function(){t.port2.postMessage(0)}}function d(){return function(){setTimeout(p,1)}}function p(){for(var t=0;$>t;t+=2){var e=at[t],r=at[t+1];e(r),at[t]=void 0,at[t+1]=void 0}$=0}function g(){try{var t=e,r=t("vertx");return W=r.runOnLoop||r.runOnContext,u()}catch(n){return d()}}function v(t,e){var r=this,n=new this.constructor(y);void 0===n[lt]&&j(n);var i=r._state;if(i){var a=arguments[i-1];J(function(){O(i,n,a,r._result)})}else C(r,n,t,e);return n}function m(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var r=new e(y);return T(r,t),r}function y(){}function b(){return new TypeError("You cannot resolve a promise with itself")}function x(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return ht.error=e,ht}}function w(t,e,r,n){try{t.call(e,r,n)}catch(i){return i}}function k(t,e,r){J(function(t){var n=!1,i=w(r,e,function(r){n||(n=!0,e!==r?T(t,r):L(t,r))},function(e){n||(n=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&i&&(n=!0,S(t,i))},t)}function A(t,e){e._state===ut?L(t,e._result):e._state===ft?S(t,e._result):C(e,void 0,function(e){T(t,e)},function(e){S(t,e)})}function M(t,e,r){e.constructor===t.constructor&&r===ot&&constructor.resolve===st?A(t,e):r===ht?S(t,ht.error):void 0===r?L(t,e):o(r)?k(t,e,r):L(t,e)}function T(t,e){t===e?S(t,b()):a(e)?M(t,e,_(e)):L(t,e)}function E(t){t._onerror&&t._onerror(t._result),z(t)}function L(t,e){t._state===ct&&(t._result=e,t._state=ut,0!==t._subscribers.length&&J(z,t))}function S(t,e){t._state===ct&&(t._state=ft,t._result=e,J(E,t))}function C(t,e,r,n){var i=t._subscribers,a=i.length;t._onerror=null,i[a]=e,i[a+ut]=r,i[a+ft]=n,0===a&&t._state&&J(z,t)}function z(t){var e=t._subscribers,r=t._state;if(0!==e.length){for(var n,i,a=t._result,o=0;oa;a++)e.resolve(t[a]).then(r,n)}:function(t,e){e(new TypeError("You must pass an array to race."))})}function D(t){var e=this,r=new e(y);return S(r,t),r}function U(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function V(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function q(t){this[lt]=N(),this._result=this._state=void 0,this._subscribers=[],y!==t&&("function"!=typeof t&&U(),this instanceof q?I(this,t):V())}function H(t,e){this._instanceConstructor=t,this.promise=new t(y),this.promise[lt]||j(this.promise),Q(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?L(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&L(this.promise,this._result))):S(this.promise,G())}function G(){return new Error("Array Methods must be provided an Array")}function Y(){var t;if("undefined"!=typeof i)t=i;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var r=t.Promise;r&&"[object Promise]"===Object.prototype.toString.call(r.resolve())&&!r.cast||(t.Promise=yt)}var X;X=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var W,Z,K,Q=X,$=0,J=function(t,e){at[$]=t,at[$+1]=e,$+=2,2===$&&(Z?Z(p):K())},tt="undefined"!=typeof window?window:void 0,et=tt||{},rt=et.MutationObserver||et.WebKitMutationObserver,nt="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),it="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,at=new Array(1e3);K=nt?c():rt?f():it?h():void 0===tt&&"function"==typeof e?g():d();var ot=v,st=m,lt=Math.random().toString(36).substring(16),ct=void 0,ut=1,ft=2,ht=new P,dt=new P,pt=0,gt=F,vt=B,mt=D,yt=q;q.all=gt,q.race=vt,q.resolve=st,q.reject=mt,q._setScheduler=s,q._setAsap=l,q._asap=J,q.prototype={constructor:q,then:ot,"catch":function(t){return this.then(null,t)}};var bt=H;H.prototype._enumerate=function(){for(var t=this.length,e=this._input,r=0;this._state===ct&&t>r;r++)this._eachEntry(e[r],r)},H.prototype._eachEntry=function(t,e){var r=this._instanceConstructor,n=r.resolve;if(n===st){var i=_(t);if(i===ot&&t._state!==ct)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(r===yt){var a=new r(y);M(a,t,i),this._willSettleAt(a,e)}else this._willSettleAt(new r(function(e){e(t)}),e)}else this._willSettleAt(n(t),e)},H.prototype._settledAt=function(t,e,r){var n=this.promise;n._state===ct&&(this._remaining--,t===ft?S(n,r):this._result[e]=r),0===this._remaining&&L(n,this._result)},H.prototype._willSettleAt=function(t,e){ -var r=this;C(t,void 0,function(t){r._settledAt(ut,e,t)},function(t){r._settledAt(ft,e,t)})};var xt=Y,_t={Promise:yt,polyfill:xt};"function"==typeof t&&t.amd?t(function(){return _t}):"undefined"!=typeof r&&r.exports?r.exports=_t:"undefined"!=typeof this&&(this.ES6Promise=_t),xt()}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:239}],93:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function a(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!a(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,l,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,l=0;n>l;l++)c[l].apply(this,a);return!0},n.prototype.addListener=function(t,e){var r;if(!i(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(r=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,a,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],a=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(s=a;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],94:[function(t,e,r){"use strict";function n(t,e,r){var n=e||0,i=r||1;return[[t[12]+t[0],t[13]+t[1],t[14]+t[2],t[15]+t[3]],[t[12]-t[0],t[13]-t[1],t[14]-t[2],t[15]-t[3]],[t[12]+t[4],t[13]+t[5],t[14]+t[6],t[15]+t[7]],[t[12]-t[4],t[13]-t[5],t[14]-t[6],t[15]-t[7]],[n*t[12]+t[8],n*t[13]+t[9],n*t[14]+t[10],n*t[15]+t[11]],[i*t[12]-t[8],i*t[13]-t[9],i*t[14]-t[10],i*t[15]-t[11]]]}e.exports=n},{}],95:[function(t,e,r){"use strict";function n(t){for(var e,r=t.length,n=0;r>n;n++)if(e=t.charCodeAt(n),(9>e||e>13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(8192>e||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var r=t;if(t=+t,0===t&&n(r))return!1}else if("number"!==e)return!1;return 1>t-t}},{}],96:[function(t,e,r){"use strict";function n(t,e,r){return Math.min(e,Math.max(t,r))}function i(t,e,r){this.dimension=t.length,this.bounds=[new Array(this.dimension),new Array(this.dimension)];for(var n=0;nr;++r)e[r]=0;return e}function o(t,e,r){switch(arguments.length){case 0:return new i([0],[0],0);case 1:if("number"==typeof t){var n=a(t);return new i(n,n,0)}return new i(t,a(t.length),0);case 2:if("number"==typeof e){var n=a(t.length);return new i(t,n,+e)}r=0;case 3:if(t.length!==e.length)throw new Error("state and velocity lengths must match");return new i(t,e,r)}}e.exports=o;var s=t("cubic-hermite"),l=t("binary-search-bounds"),c=i.prototype;c.flush=function(t){var e=l.gt(this._time,t)-1;0>=e||(this._time.splice(0,e),this._state.splice(0,e*this.dimension),this._velocity.splice(0,e*this.dimension))},c.curve=function(t){var e=this._time,r=e.length,i=l.le(e,t),a=this._scratch[0],o=this._state,c=this._velocity,u=this.dimension,f=this.bounds;if(0>i)for(var h=u-1,d=0;u>d;++d,--h)a[d]=o[h];else if(i>=r-1)for(var h=o.length-1,p=t-e[r-1],d=0;u>d;++d,--h)a[d]=o[h]+p*c[h];else{for(var h=u*(i+1)-1,g=e[i],v=e[i+1],m=v-g||1,y=this._scratch[1],b=this._scratch[2],x=this._scratch[3],_=this._scratch[4],w=!0,d=0;u>d;++d,--h)y[d]=o[h],x[d]=c[h]*m,b[d]=o[h+u],_[d]=c[h+u]*m,w=w&&y[d]===b[d]&&x[d]===_[d]&&0===x[d];if(w)for(var d=0;u>d;++d)a[d]=y[d];else s(y,x,b,_,(t-g)/m,a)}for(var k=f[0],A=f[1],d=0;u>d;++d)a[d]=n(k[d],A[d],a[d]);return a},c.dcurve=function(t){var e=this._time,r=e.length,n=l.le(e,t),i=this._scratch[0],a=this._state,o=this._velocity,c=this.dimension;if(n>=r-1)for(var u=a.length-1,f=(t-e[r-1],0);c>f;++f,--u)i[f]=o[u];else{for(var u=c*(n+1)-1,h=e[n],d=e[n+1],p=d-h||1,g=this._scratch[1],v=this._scratch[2],m=this._scratch[3],y=this._scratch[4],b=!0,f=0;c>f;++f,--u)g[f]=a[u],m[f]=o[u]*p,v[f]=a[u+c],y[f]=o[u+c]*p,b=b&&g[f]===v[f]&&m[f]===y[f]&&0===m[f];if(b)for(var f=0;c>f;++f)i[f]=0;else{s.derivative(g,m,v,y,(t-h)/p,i);for(var f=0;c>f;++f)i[f]/=p}}return i},c.lastT=function(){var t=this._time;return t[t.length-1]},c.stable=function(){for(var t=this._velocity,e=t.length,r=this.dimension-1;r>=0;--r)if(t[--e])return!1;return!0},c.jump=function(t){var e=this.lastT(),r=this.dimension;if(!(e>t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1];this._time.push(e,t);for(var u=0;2>u;++u)for(var f=0;r>f;++f)i.push(i[o++]),a.push(0);this._time.push(t);for(var f=r;f>0;--f)i.push(n(l[f-1],c[f-1],arguments[f])),a.push(0)}},c.push=function(t){var e=this.lastT(),r=this.dimension;if(!(e>t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=t-e,l=this.bounds,c=l[0],u=l[1],f=s>1e-6?1/s:0;this._time.push(t);for(var h=r;h>0;--h){var d=n(c[h-1],u[h-1],arguments[h]);i.push(d),a.push((d-i[o++])*f)}}},c.set=function(t){var e=this.dimension;if(!(t0;--l)r.push(n(o[l-1],s[l-1],arguments[l])),i.push(0)}},c.move=function(t){var e=this.lastT(),r=this.dimension;if(!(e>=t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1],u=t-e,f=u>1e-6?1/u:0;this._time.push(t);for(var h=r;h>0;--h){var d=arguments[h];i.push(n(l[h-1],c[h-1],i[o++]+d)),a.push(d*f)}}},c.idle=function(t){var e=this.lastT();if(!(e>t)){var r=this.dimension,i=this._state,a=this._velocity,o=i.length-r,s=this.bounds,l=s[0],c=s[1],u=t-e;this._time.push(t);for(var f=r-1;f>=0;--f)i.push(n(l[f],c[f],i[o]+u*a[o])),a.push(0),o+=1}}},{"binary-search-bounds":47,"cubic-hermite":82}],97:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function i(t){return new n(t._color,t.key,t.value,t.left,t.right,t._count)}function a(t,e){return new n(t,e.key,e.value,e.left,e.right,e._count)}function o(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function s(t,e){this._compare=t,this.root=e}function l(t,e){if(e.left){var r=l(t,e.left);if(r)return r}var r=t(e.key,e.value);return r?r:e.right?l(t,e.right):void 0}function c(t,e,r,n){var i=e(t,n.key);if(0>=i){if(n.left){var a=c(t,e,r,n.left);if(a)return a}var a=r(n.key,n.value);if(a)return a}return n.right?c(t,e,r,n.right):void 0}function u(t,e,r,n,i){var a,o=r(t,i.key),s=r(e,i.key);if(0>=o){if(i.left&&(a=u(t,e,r,n,i.left)))return a;if(s>0&&(a=n(i.key,i.value)))return a}return s>0&&i.right?u(t,e,r,n,i.right):void 0}function f(t,e){this.tree=t,this._stack=e}function h(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function d(t){for(var e,r,n,s,l=t.length-1;l>=0;--l){if(e=t[l],0===l)return void(e._color=m);if(r=t[l-1],r.left===e){if(n=r.right,n.right&&n.right._color===v){if(n=r.right=i(n),s=n.right=i(n.right),r.right=n.left,n.left=r,n.right=s,n._color=r._color,e._color=m,r._color=m,s._color=m,o(r),o(n),l>1){var c=t[l-2];c.left===r?c.left=n:c.right=n}return void(t[l-1]=n)}if(n.left&&n.left._color===v){if(n=r.right=i(n),s=n.left=i(n.left),r.right=s.left,n.left=s.right,s.left=r,s.right=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var c=t[l-2];c.left===r?c.left=s:c.right=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.right=a(v,n));r.right=a(v,n);continue}if(n=i(n),r.right=n.left,n.left=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var c=t[l-2];c.left===r?c.left=n:c.right=n}t[l-1]=n,t[l]=r,l+11){var c=t[l-2];c.right===r?c.right=n:c.left=n}return void(t[l-1]=n)}if(n.right&&n.right._color===v){if(n=r.left=i(n),s=n.right=i(n.right),r.left=s.right,n.right=s.left,s.right=r,s.left=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var c=t[l-2];c.right===r?c.right=s:c.left=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.left=a(v,n));r.left=a(v,n);continue}if(n=i(n),r.left=n.right,n.right=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var c=t[l-2];c.right===r?c.right=n:c.left=n}t[l-1]=n,t[l]=r,l+1t?-1:t>e?1:0}function g(t){return new s(t||p,null)}e.exports=g;var v=0,m=1,y=s.prototype;Object.defineProperty(y,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(y,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(y,"length",{get:function(){return this.root?this.root._count:0}}),y.insert=function(t,e){for(var r=this._compare,i=this.root,l=[],c=[];i;){var u=r(t,i.key);l.push(i),c.push(u),i=0>=u?i.left:i.right}l.push(new n(v,t,e,null,null,1));for(var f=l.length-2;f>=0;--f){var i=l[f];c[f]<=0?l[f]=new n(i._color,i.key,i.value,l[f+1],i.right,i._count+1):l[f]=new n(i._color,i.key,i.value,i.left,l[f+1],i._count+1)}for(var f=l.length-1;f>1;--f){var h=l[f-1],i=l[f];if(h._color===m||i._color===m)break;var d=l[f-2];if(d.left===h)if(h.left===i){var p=d.right;if(!p||p._color!==v){if(d._color=v,d.left=h.right,h._color=m,h.right=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.left===d?g.left=h:g.right=h}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else{var p=d.right;if(!p||p._color!==v){if(h.right=i.left,d._color=v,d.left=i.right,i._color=m,i.left=h,i.right=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.left===d?g.left=i:g.right=i}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else if(h.right===i){var p=d.left;if(!p||p._color!==v){if(d._color=v,d.right=h.left,h._color=m,h.left=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.right===d?g.right=h:g.left=h}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}else{var p=d.left;if(!p||p._color!==v){if(h.left=i.right,d._color=v,d.right=i.left,i._color=m,i.right=h,i.left=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.right===d?g.right=i:g.left=i}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}}return l[0]._color=m,new s(r,l[0])},y.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return l(t,this.root);case 2:return c(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return u(e,r,this._compare,t,this.root)}},Object.defineProperty(y,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(y,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),y.at=function(t){if(0>t)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},y.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>=a&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>a&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new f(this,n);r=0>=i?r.left:r.right}return new f(this,[])},y.remove=function(t){var e=this.find(t);return e?e.remove():this},y.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=0>=n?r.left:r.right}};var b=f.prototype;Object.defineProperty(b,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(b,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),b.clone=function(){return new f(this.tree,this._stack.slice())},b.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new n(r._color,r.key,r.value,r.left,r.right,r._count);for(var i=t.length-2;i>=0;--i){var r=t[i];r.left===t[i+1]?e[i]=new n(r._color,r.key,r.value,e[i+1],r.right,r._count):e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count)}if(r=e[e.length-1],r.left&&r.right){var a=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var o=e[a-1];e.push(new n(r._color,o.key,o.value,r.left,r.right,r._count)),e[a-1].key=r.key,e[a-1].value=r.value;for(var i=e.length-2;i>=a;--i)r=e[i],e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count);e[a-1].left=e[a]}if(r=e[e.length-1],r._color===v){var l=e[e.length-2];l.left===r?l.left=null:l.right===r&&(l.right=null),e.pop();for(var i=0;i0?this._stack[this._stack.length-1].key:void 0},enumerable:!0}),Object.defineProperty(b,"value",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1].value:void 0},enumerable:!0}),Object.defineProperty(b,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),b.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),b.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),i=e[e.length-1];r[r.length-1]=new n(i._color,i.key,t,i.left,i.right,i._count);for(var a=e.length-2;a>=0;--a)i=e[a],i.left===e[a+1]?r[a]=new n(i._color,i.key,i.value,r[a+1],i.right,i._count):r[a]=new n(i._color,i.key,i.value,i.left,r[a+1],i._count);return new s(this.tree._compare,r[0])},b.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],98:[function(t,e,r){function n(t){if(0>t)return Number("0/0");for(var e=s[0],r=s.length-1;r>0;--r)e+=s[r]/(t+r);var n=t+o+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}var i=7,a=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],o=607/128,s=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];e.exports=function l(t){if(.5>t)return Math.PI/(Math.sin(Math.PI*t)*l(1-t));if(t>100)return Math.exp(n(t));t-=1;for(var e=a[0],r=1;i+2>r;r++)e+=a[r]/(t+r);var o=t+i+.5;return Math.sqrt(2*Math.PI)*Math.pow(o,t+.5)*Math.exp(-o)*e},e.exports.log=n},{}],99:[function(t,e,r){"use strict";function n(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function i(t){this.gl=t,this.pixelRatio=1,this.bounds=[[-10,-10,-10],[10,10,10]],this.ticks=[[],[],[]],this.autoTicks=!0,this.tickSpacing=[1,1,1],this.tickEnable=[!0,!0,!0],this.tickFont=["sans-serif","sans-serif","sans-serif"],this.tickSize=[12,12,12],this.tickAngle=[0,0,0],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=[!0,!0,!0],this.labelFont="sans-serif",this.labelSize=[20,20,20],this.labelAngle=[0,0,0],this.labelColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.labelPad=[10,10,10],this.lineEnable=[!0,!0,!0],this.lineMirror=[!1,!1,!1],this.lineWidth=[1,1,1],this.lineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.lineTickEnable=[!0,!0,!0],this.lineTickMirror=[!1,!1,!1],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=[!0,!0,!0],this.gridWidth=[1,1,1],this.gridColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.zeroEnable=[!0,!0,!0],this.zeroLineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.zeroLineWidth=[2,2,2],this.backgroundEnable=[!1,!1,!1],this.backgroundColor=[[.8,.8,.8,.5],[.8,.8,.8,.5],[.8,.8,.8,.5]],this._firstInit=!0,this._text=null,this._lines=null,this._background=u(t)}function a(){this.primalOffset=[0,0,0],this.primalMinor=[0,0,0],this.mirrorOffset=[0,0,0],this.mirrorMinor=[0,0,0]}function o(t,e,r,n,i){for(var a=t.primalOffset,o=t.primalMinor,s=t.mirrorOffset,l=t.mirrorMinor,c=n[e],u=0;3>u;++u)if(e!==u){var f=a,h=s,d=o,p=l;c&1<0?(d[u]=-1,p[u]=0):(d[u]=0,p[u]=1)}}function s(t,e){var r=new i(t);return r.update(e),r}e.exports=s;var l=t("./lib/text.js"),c=t("./lib/lines.js"),u=t("./lib/background.js"),f=t("./lib/cube.js"),h=t("./lib/ticks.js"),d=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),p=i.prototype;p.update=function(t){function e(e,r,n){if(n in t){var i,a=t[n],o=this[n];(e?Array.isArray(a)&&Array.isArray(a[0]):Array.isArray(a))?this[n]=i=[r(a[0]),r(a[1]),r(a[2])]:this[n]=i=[r(a),r(a),r(a)];for(var s=0;3>s;++s)if(i[s]!==o[s])return!0}return!1}t=t||{};var r,n=e.bind(this,!1,Number),i=e.bind(this,!1,Boolean),a=e.bind(this,!1,String),o=e.bind(this,!0,function(t){if(Array.isArray(t)){if(3===t.length)return[+t[0],+t[1],+t[2],1];if(4===t.length)return[+t[0],+t[1],+t[2],+t[3]]}return[0,0,0,1]}),s=!1,u=!1;if("bounds"in t)for(var f=t.bounds,d=0;2>d;++d)for(var p=0;3>p;++p)f[d][p]!==this.bounds[d][p]&&(u=!0),this.bounds[d][p]=f[d][p];if("ticks"in t){r=t.ticks,s=!0,this.autoTicks=!1;for(var d=0;3>d;++d)this.tickSpacing[d]=0}else n("tickSpacing")&&(this.autoTicks=!0,u=!0);if(this._firstInit&&("ticks"in t||"tickSpacing"in t||(this.autoTicks=!0),u=!0,s=!0,this._firstInit=!1),u&&this.autoTicks&&(r=h.create(this.bounds,this.tickSpacing),s=!0),s){for(var d=0;3>d;++d)r[d].sort(function(t,e){return t.x-e.x});h.equal(r,this.ticks)?s=!1:this.ticks=r}i("tickEnable"),a("tickFont")&&(s=!0),n("tickSize"),n("tickAngle"),n("tickPad"),o("tickColor");var g=a("labels");a("labelFont")&&(g=!0),i("labelEnable"),n("labelSize"),n("labelPad"),o("labelColor"),i("lineEnable"),i("lineMirror"),n("lineWidth"),o("lineColor"),i("lineTickEnable"),i("lineTickMirror"),n("lineTickLength"),n("lineTickWidth"),o("lineTickColor"),i("gridEnable"),n("gridWidth"),o("gridColor"),i("zeroEnable"),o("zeroLineColor"),n("zeroLineWidth"),i("backgroundEnable"),o("backgroundColor"),this._text?this._text&&(g||s)&&this._text.update(this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont):this._text=l(this.gl,this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont),this._lines&&s&&(this._lines.dispose(),this._lines=null),this._lines||(this._lines=c(this.gl,this.bounds,this.ticks))};var g=[new a,new a,new a],v=[0,0,0],m={model:d,view:d,projection:d};p.isOpaque=function(){return!0},p.isTransparent=function(){return!1},p.drawTransparent=function(t){};var y=[0,0,0],b=[0,0,0],x=[0,0,0];p.draw=function(t){t=t||m;for(var e=this.gl,r=t.model||d,i=t.view||d,a=t.projection||d,s=this.bounds,l=f(r,i,a,s),c=l.cubeEdges,u=l.axis,h=i[12],p=i[13],_=i[14],w=i[15],k=this.pixelRatio*(a[3]*h+a[7]*p+a[11]*_+a[15]*w)/e.drawingBufferHeight,A=0;3>A;++A)this.lastCubeProps.cubeEdges[A]=c[A],this.lastCubeProps.axis[A]=u[A];for(var M=g,A=0;3>A;++A)o(g[A],A,this.bounds,c,u);for(var e=this.gl,T=v,A=0;3>A;++A)this.backgroundEnable[A]?T[A]=u[A]:T[A]=0;this._background.draw(r,i,a,s,T,this.backgroundColor),this._lines.bind(r,i,a,this);for(var A=0;3>A;++A){var E=[0,0,0];u[A]>0?E[A]=s[1][A]:E[A]=s[0][A];for(var L=0;2>L;++L){var S=(A+1+L)%3,C=(A+1+(1^L))%3;this.gridEnable[S]&&this._lines.drawGrid(S,C,this.bounds,E,this.gridColor[S],this.gridWidth[S]*this.pixelRatio)}for(var L=0;2>L;++L){var S=(A+1+L)%3,C=(A+1+(1^L))%3;this.zeroEnable[C]&&s[0][C]<=0&&s[1][C]>=0&&this._lines.drawZero(S,C,this.bounds,E,this.zeroLineColor[C],this.zeroLineWidth[C]*this.pixelRatio)}}for(var A=0;3>A;++A){this.lineEnable[A]&&this._lines.drawAxisLine(A,this.bounds,M[A].primalOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio),this.lineMirror[A]&&this._lines.drawAxisLine(A,this.bounds,M[A].mirrorOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio);for(var z=n(y,M[A].primalMinor),P=n(b,M[A].mirrorMinor),R=this.lineTickLength,L=0;3>L;++L){var O=k/r[5*L];z[L]*=R[L]*O,P[L]*=R[L]*O}this.lineTickEnable[A]&&this._lines.drawAxisTicks(A,M[A].primalOffset,z,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio),this.lineTickMirror[A]&&this._lines.drawAxisTicks(A,M[A].mirrorOffset,P,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio)}this._text.bind(r,i,a,this.pixelRatio);for(var A=0;3>A;++A){for(var I=M[A].primalMinor,N=n(x,M[A].primalOffset),L=0;3>L;++L)this.lineTickEnable[A]&&(N[L]+=k*I[L]*Math.max(this.lineTickLength[L],0)/r[5*L]);if(this.tickEnable[A]){for(var L=0;3>L;++L)N[L]+=k*I[L]*this.tickPad[L]/r[5*L];this._text.drawTicks(A,this.tickSize[A],this.tickAngle[A],N,this.tickColor[A])}if(this.labelEnable[A]){for(var L=0;3>L;++L)N[L]+=k*I[L]*this.labelPad[L]/r[5*L];N[A]+=.5*(s[0][A]+s[1][A]),this._text.drawLabel(A,this.labelSize[A],this.labelAngle[A],N,this.labelColor[A])}}},p.dispose=function(){this._text.dispose(),this._lines.dispose(),this._background.dispose(),this._lines=null,this._text=null,this._background=null,this.gl=null}},{"./lib/background.js":100,"./lib/cube.js":101,"./lib/lines.js":102,"./lib/text.js":104,"./lib/ticks.js":105}],100:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n}function i(t){for(var e=[],r=[],i=0,l=0;3>l;++l)for(var c=(l+1)%3,u=(l+2)%3,f=[0,0,0],h=[0,0,0],d=-1;1>=d;d+=2){r.push(i,i+2,i+1,i+1,i+2,i+3),f[l]=d,h[l]=d;for(var p=-1;1>=p;p+=2){f[c]=p;for(var g=-1;1>=g;g+=2)f[u]=g,e.push(f[0],f[1],f[2],h[0],h[1],h[2]),i+=1}var v=c;c=u,u=v}var m=a(t,new Float32Array(e)),y=a(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),b=o(t,[{buffer:m,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:m,type:t.FLOAT,size:3,offset:12,stride:24}],y),x=s(t);return x.attributes.position.location=0,x.attributes.normal.location=1,new n(t,m,b,x)}e.exports=i;var a=t("gl-buffer"),o=t("gl-vao"),s=t("./shaders").bg,l=n.prototype;l.draw=function(t,e,r,n,i,a){for(var o=!1,s=0;3>s;++s)o=o||i[s];if(o){var l=this.gl;l.enable(l.POLYGON_OFFSET_FILL),l.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:t,view:e,projection:r,bounds:n,enable:i,colors:a},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),l.disable(l.POLYGON_OFFSET_FILL)}},l.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders":103,"gl-buffer":107,"gl-vao":182}],101:[function(t,e,r){"use strict";function n(t,e,r){for(var n=0;4>n;++n){t[n]=r[12+n];for(var i=0;3>i;++i)t[n]+=e[i]*r[4*i+n]}}function i(t){for(var e=0;eg;++g){d[2]=a[g][2];for(var b=0;2>b;++b){d[1]=a[b][1];for(var x=0;2>x;++x)d[0]=a[x][0],n(f[l],d,u),l+=1}}for(var _=-1,g=0;8>g;++g){for(var w=f[g][3],k=0;3>k;++k)h[g][k]=f[g][k]/w;0>w&&(0>_?_=g:h[g][2]_){_=0;for(var A=0;3>A;++A){for(var M=(A+2)%3,T=(A+1)%3,E=-1,L=-1,S=0;2>S;++S){var C=S<E||0>L)L>E&&(_|=1<S;++S){var C=S<E&&(_|=1<g;++g)g!==_&&g!==O&&(0>I?I=g:h[I][1]>h[g][1]&&(I=g));for(var N=-1,g=0;3>g;++g){var j=I^1<N&&(N=j);var T=h[j];T[0]g;++g){var j=I^1<F&&(F=j);var T=h[j];T[0]>h[F][0]&&(F=j)}}var B=v;B[0]=B[1]=B[2]=0,B[o.log2(N^I)]=I&N,B[o.log2(I^F)]=I&F;var D=7^F;D===_||D===O?(D=7^N,B[o.log2(F^D)]=D&F):B[o.log2(N^D)]=D&N;for(var U=m,V=_,A=0;3>A;++A)V&1<t;++t)f[t]=[1,1,1,1],h[t]=[1,1,1]}();var g=[[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]],v=[1,1,1],m=[0,0,0],y={cubeEdges:v,axis:m}},{"bit-twiddle":48,"gl-mat4/invert":128,"gl-mat4/multiply":130,"robust-orientation":253,"split-polygon":270}],102:[function(t,e,r){"use strict";function n(t){return t[0]=t[1]=t[2]=0,t}function i(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function a(t,e,r,n,i,a,o,s){this.gl=t,this.vertBuffer=e,this.vao=r,this.shader=n,this.tickCount=i,this.tickOffset=a,this.gridCount=o,this.gridOffset=s}function o(t,e,r){var n=[],i=[0,0,0],o=[0,0,0],u=[0,0,0],f=[0,0,0];n.push(0,0,1,0,1,1,0,0,-1,0,0,-1,0,1,1,0,1,-1);for(var h=0;3>h;++h){for(var d=n.length/3|0,p=0;ph;++h)for(var p=u[h],g=2;g>=0;--g){var v=c[p[g]];s.push(l*v[0],-l*v[1],t)}}for(var s=(this.gl,[]),l=[0,0,0],c=[0,0,0],u=[0,0,0],d=[0,0,0],p=0;3>p;++p){u[p]=s.length/h|0,o(.5*(t[0][p]+t[1][p]),e[p],r),d[p]=(s.length/h|0)-u[p],l[p]=s.length/h|0;for(var g=0;g=0&&(i=r.length-n-1);var a=Math.pow(10,i),o=Math.round(t*e*a),s=o+"";if(s.indexOf("e")>=0)return s;var l=o/a,c=o%a;0>o?(l=0|-Math.ceil(l),c=0|-c):(l=0|Math.floor(l),c=0|c);var u=""+l;if(0>o&&(u="-"+u),i){for(var f=""+c;f.lengthi;++i){for(var a=[],o=(.5*(t[0][i]+t[1][i]),0);o*e[i]<=t[1][i];++o)a.push({x:o*e[i],text:n(e[i],o)});for(var o=-1;o*e[i]>=t[0][i];--o)a.push({x:o*e[i],text:n(e[i],o)});r.push(a)}return r}function a(t,e){for(var r=0;3>r;++r){if(t[r].length!==e[r].length)return!1;for(var n=0;na;++a){for(var o=p,s=g,l=0;3>l;++l)s[l]=o[l]=r[l];s[3]=o[3]=1,s[a]+=1,f(s,s,e),s[3]<0&&(t[a]=1/0),o[a]-=1,f(o,o,e),o[3]<0&&(t[a]=1/0);var c=(o[0]/o[3]-s[0]/s[3])*n,u=(o[1]/o[3]-s[1]/s[3])*i;t[a]=.25*Math.sqrt(c*c+u*u)}return t}function a(t,e,r,n,a){var f=e.model||h,p=e.view||h,g=e.projection||h,y=t.bounds,a=a||l(f,p,g,y),b=a.axis;a.edges;c(d,p,f),c(d,g,d);for(var x=v,_=0;3>_;++_)x[_].lo=1/0,x[_].hi=-(1/0),x[_].pixelsPerDataUnit=1/0;var w=o(u(d,d));u(d,d);for(var k=0;3>k;++k){var A=(k+1)%3,M=(k+2)%3,T=m;t:for(var _=0;2>_;++_){var E=[];if(b[k]<0!=!!_){T[k]=y[_][k];for(var L=0;2>L;++L){T[A]=y[L^_][A];for(var S=0;2>S;++S)T[M]=y[S^L^_][M],E.push(T.slice())}for(var L=0;LS;++S)x[S].lo=Math.min(x[S].lo,M[S]),x[S].hi=Math.max(x[S].hi,M[S]),S!==k&&(x[S].pixelsPerDataUnit=Math.min(x[S].pixelsPerDataUnit,Math.abs(C[S])))}}}return x}e.exports=a;var o=t("extract-frustum-planes"),s=t("split-polygon"),l=t("./lib/cube.js"),c=t("gl-mat4/multiply"),u=t("gl-mat4/transpose"),f=t("gl-vec4/transformMat4"),h=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),d=new Float32Array(16),p=[0,0,0,1],g=[0,0,0,1],v=[new n(1/0,-(1/0),1/0),new n(1/0,-(1/0),1/0),new n(1/0,-(1/0),1/0)],m=[0,0,0]},{"./lib/cube.js":101,"extract-frustum-planes":94,"gl-mat4/multiply":130,"gl-mat4/transpose":138,"gl-vec4/transformMat4":188,"split-polygon":270}],107:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.gl=t,this.type=e,this.handle=r,this.length=n,this.usage=i}function i(t,e,r,n,i,a){var o=i.length*i.BYTES_PER_ELEMENT;if(0>a)return t.bufferData(e,i,n),o;if(o+a>r)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function a(t,e){for(var r=l.malloc(t.length,e),n=t.length,i=0;n>i;++i)r[i]=t[i];return r}function o(t,e){for(var r=1,n=e.length-1;n>=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}function s(t,e,r,i){if(r=r||t.ARRAY_BUFFER,i=i||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.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(i!==t.DYNAMIC_DRAW&&i!==t.STATIC_DRAW&&i!==t.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 a=t.createBuffer(),o=new n(t,r,a,0,i);return o.update(e),o}var l=t("typedarray-pool"),c=t("ndarray-ops"),u=t("ndarray"),f=["uint8","uint8_clamped","uint16","uint32","int8","int16","int32","float32"],h=n.prototype;h.bind=function(){this.gl.bindBuffer(this.type,this.handle)},h.unbind=function(){this.gl.bindBuffer(this.type,null)},h.dispose=function(){this.gl.deleteBuffer(this.handle)},h.update=function(t,e){if("number"!=typeof e&&(e=-1),this.bind(),"object"==typeof t&&"undefined"!=typeof t.shape){var r=t.dtype;if(f.indexOf(r)<0&&(r="float32"),this.type===this.gl.ELEMENT_ARRAY_BUFFER){var n=gl.getExtension("OES_element_index_uint");r=n&&"uint16"!==r?"uint32":"uint16"}if(r===t.dtype&&o(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=i(this.gl,this.type,this.length,this.usage,t.data,e):this.length=i(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=l.malloc(t.size,r),h=u(s,t.shape);c.assign(h,t),0>e?this.length=i(this.gl,this.type,this.length,this.usage,s,e):this.length=i(this.gl,this.type,this.length,this.usage,s.subarray(0,t.size),e),l.free(s)}}else if(Array.isArray(t)){var d;d=this.type===this.gl.ELEMENT_ARRAY_BUFFER?a(t,"uint16"):a(t,"float32"),0>e?this.length=i(this.gl,this.type,this.length,this.usage,d,e):this.length=i(this.gl,this.type,this.length,this.usage,d.subarray(0,t.length),e),l.free(d)}else if("object"==typeof t&&"number"==typeof t.length)this.length=i(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");t=0|t,0>=t&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=s},{ndarray:225,"ndarray-ops":219,"typedarray-pool":282}],108:[function(t,e,r){e.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",34e3:"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"}},{}],109:[function(t,e,r){var n=t("./1.0/numbers");e.exports=function(t){return n[t]}},{"./1.0/numbers":108}],110:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.shader=e,this.buffer=r,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.color=[0,0,0,1]}function i(t,e){var r=a(t.gl,l.vertex,l.fragment),i=o(t.gl),s=new n(t,r,i);return s.update(e),t.addObject(s),s}var a=t("gl-shader"),o=t("gl-buffer"),s=t("typedarray-pool"),l=t("./lib/shaders");e.exports=i;var c=[[1,0,0,1,0,0],[1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,1,0,0],[1,0,0,1,0,0],[1,0,-1,0,0,1],[1,0,-1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,1],[1,0,-1,0,0,1],[-1,0,-1,0,0,1],[-1,0,-1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,1],[-1,0,-1,0,0,1],[0,1,1,0,0,0],[0,1,-1,0,0,0],[0,-1,-1,0,0,0],[0,-1,-1,0,0,0],[0,1,1,0,0,0],[0,-1,1,0,0,0],[0,1,0,-1,1,0],[0,1,0,-1,-1,0],[0,1,0,1,-1,0],[0,1,0,1,1,0],[0,1,0,-1,1,0],[0,1,0,1,-1,0],[0,-1,0,-1,1,0],[0,-1,0,-1,-1,0],[0,-1,0,1,-1,0],[0,-1,0,1,1,0],[0,-1,0,-1,1,0],[0,-1,0,1,-1,0]],u=n.prototype;u.draw=function(){var t=[1,0,0,0,1,0,0,0,1],e=[1,1];return function(){var r=this.plot,n=this.shader,i=this.buffer,a=this.bounds,o=this.numPoints;if(o){var s=r.gl,l=r.dataBox,u=r.viewBox,f=r.pixelRatio,h=a[2]-a[0],d=a[3]-a[1],p=l[2]-l[0],g=l[3]-l[1];t[0]=2*h/p,t[4]=2*d/g,t[6]=2*(a[0]-l[0])/p-1,t[7]=2*(a[1]-l[1])/g-1;var v=u[2]-u[0],m=u[3]-u[1];e[0]=2*f/v,e[1]=2*f/m,i.bind(),n.bind(),n.uniforms.viewTransform=t,n.uniforms.pixelScale=e,n.uniforms.color=this.color,n.attributes.position.pointer(s.FLOAT,!1,16,0),n.attributes.pixelOffset.pointer(s.FLOAT,!1,16,8),s.drawArrays(s.TRIANGLES,0,o*c.length)}}}(),u.drawPick=function(t){return t},u.pick=function(t,e){return null},u.update=function(t){t=t||{};var e,r,n,i=t.positions||[],a=t.errors||[],o=1;"lineWidth"in t&&(o=+t.lineWidth);var l=5;"capSize"in t&&(l=+t.capSize),this.color=(t.color||[0,0,0,1]).slice();var u=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=this.numPoints=i.length>>1;for(e=0;f>e;++e)r=i[2*e],n=i[2*e+1],u[0]=Math.min(r,u[0]),u[1]=Math.min(n,u[1]),u[2]=Math.max(r,u[2]),u[3]=Math.max(n,u[3]);u[2]===u[0]&&(u[2]+=1),u[3]===u[1]&&(u[3]+=1);var h=1/(u[2]-u[0]),d=1/(u[3]-u[1]),p=u[0],g=u[1],v=s.mallocFloat32(f*c.length*4),m=0;for(e=0;f>e;++e){r=i[2*e],n=i[2*e+1];for(var y=a[4*e],b=a[4*e+1],x=a[4*e+2],_=a[4*e+3],w=0;wA?A*=y:A>0&&(A*=b),0>M?M*=x:M>0&&(M*=_),v[m++]=h*(r-p+A),v[m++]=d*(n-g+M),v[m++]=o*k[2]+(l+o)*k[4],v[m++]=o*k[3]+(l+o)*k[5]}}this.buffer.update(v),s.free(v)},u.dispose=function(){this.plot.removeObject(this),this.shader.dispose(),this.buffer.dispose()}},{"./lib/shaders":111,"gl-buffer":107,"gl-shader":166,"typedarray-pool":282}],111:[function(t,e,r){e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 pixelOffset;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvoid main() {\n vec3 scrPosition = viewTransform * vec3(position, 1);\n gl_Position = vec4(\n scrPosition.xy + scrPosition.z * pixelScale * pixelOffset,\n 0,\n scrPosition.z);\n}\n",fragment:"precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"}},{}],112:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.shader=n,this.buffer=e,this.vao=r,this.pixelRatio=1,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.lineWidth=[1,1,1],this.capSize=[10,10,10],this.lineCount=[0,0,0],this.lineOffset=[0,0,0],this.opacity=1}function i(t,e){for(var r=0;3>r;++r)t[0][r]=Math.min(t[0][r],e[r]),t[1][r]=Math.max(t[1][r],e[r])}function a(t,e,r,n){for(var i=h[n],a=0;a=1},f.isTransparent=function(){return this.opacity<1},f.drawTransparent=f.draw=function(t){var e=this.gl,r=this.shader.uniforms;this.shader.bind();var n=r.view=t.view||u,i=r.projection=t.projection||u;r.model=t.model||u,r.clipBounds=this.clipBounds,r.opacity=this.opacity;var a=n[12],o=n[13],s=n[14],l=n[15],c=this.pixelRatio*(i[3]*a+i[7]*o+i[11]*s+i[15]*l)/e.drawingBufferHeight;this.vao.bind();for(var f=0;3>f;++f)e.lineWidth(this.lineWidth[f]),r.capSize=this.capSize[f]*c,e.drawArrays(e.LINES,this.lineOffset[f],this.lineCount[f]);this.vao.unbind()};var h=function(){for(var t=new Array(3),e=0;3>e;++e){for(var r=[],n=1;2>=n;++n)for(var i=-1;1>=i;i+=2){var a=(n+e)%3,o=[0,0,0];o[a]=i,r.push(o)}t[e]=r}return t}();f.update=function(t){t=t||{},"lineWidth"in t&&(this.lineWidth=t.lineWidth,Array.isArray(this.lineWidth)||(this.lineWidth=[this.lineWidth,this.lineWidth,this.lineWidth])),"capSize"in t&&(this.capSize=t.capSize,Array.isArray(this.capSize)||(this.capSize=[this.capSize,this.capSize,this.capSize])),"opacity"in t&&(this.opacity=t.opacity);var e=t.color||[[0,0,0],[0,0,0],[0,0,0]],r=t.position,n=t.error;if(Array.isArray(e[0])||(e=[e,e,e]),r&&n){var o=[],s=r.length,l=0;this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.lineCount=[0,0,0];for(var c=0;3>c;++c){this.lineOffset[c]=l;t:for(var u=0;s>u;++u){for(var f=r[u],h=0;3>h;++h)if(isNaN(f[h])||!isFinite(f[h]))continue t;var d=n[u],p=e[c];if(Array.isArray(p[0])&&(p=e[u]),3===p.length&&(p=[p[0],p[1],p[2],1]),!isNaN(d[0][c])&&!isNaN(d[1][c])){if(d[0][c]<0){var g=f.slice();g[c]+=d[0][c],o.push(f[0],f[1],f[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,g),l+=2+a(o,g,p,c)}if(d[1][c]>0){var g=f.slice();g[c]+=d[1][c],o.push(f[0],f[1],f[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,g),l+=2+a(o,g,p,c)}}}this.lineCount[c]=l-this.lineOffset[c]}this.buffer.update(o)}},f.dispose=function(){this.shader.dispose(),this.buffer.dispose(),this.vao.dispose()}},{"./shaders/index":113,"gl-buffer":107,"gl-vao":182}],113:[function(t,e,r){"use strict";var n=t("gl-shader"),i="precision mediump 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}",a="precision mediump float;\n#define GLSLIFY 1\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(fragPosition, clipBounds[0])) || any(greaterThan(fragPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = opacity * fragColor;\n}";e.exports=function(t){return n(t,i,a,null,[{name:"position",type:"vec3"},{name:"offset",type:"vec3"},{name:"color",type:"vec4"}])}},{"gl-shader":166}],114:[function(t,e,r){"use strict";function n(t){var e=t.getParameter(t.FRAMEBUFFER_BINDING),r=t.getParameter(t.RENDERBUFFER_BINDING),n=t.getParameter(t.TEXTURE_BINDING_2D);return[e,r,n]}function i(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function a(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);y=new Array(r+1);for(var n=0;r>=n;++n){for(var i=new Array(r),a=0;n>a;++a)i[a]=t.COLOR_ATTACHMENT0+a;for(var a=n;r>a;++a)i[a]=t.NONE;y[n]=i}}function o(t){switch(t){case p:throw new Error("gl-fbo: Framebuffer unsupported");case g:throw new Error("gl-fbo: Framebuffer incomplete attachment");case v:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case m:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function s(t,e,r,n,i,a){if(!n)return null;var o=d(t,e,r,i,n);return o.magFilter=t.NEAREST,o.minFilter=t.NEAREST,o.mipSamples=1,o.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,a,t.TEXTURE_2D,o.handle,0),o}function l(t,e,r,n,i){var a=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,a),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,a),a}function c(t){var e=n(t.gl),r=t.gl,a=t.handle=r.createFramebuffer(),c=t._shape[0],u=t._shape[1],f=t.color.length,h=t._ext,d=t._useStencil,p=t._useDepth,g=t._colorType;r.bindFramebuffer(r.FRAMEBUFFER,a);for(var v=0;f>v;++v)t.color[v]=s(r,c,u,g,r.RGBA,r.COLOR_ATTACHMENT0+v);0===f?(t._color_rb=l(r,c,u,r.RGBA4,r.COLOR_ATTACHMENT0),h&&h.drawBuffersWEBGL(y[0])):f>1&&h.drawBuffersWEBGL(y[f]);var m=r.getExtension("WEBGL_depth_texture");m?d?t.depth=s(r,c,u,m.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p&&(t.depth=s(r,c,u,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):p&&d?t._depth_rb=l(r,c,u,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p?t._depth_rb=l(r,c,u,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(t._depth_rb=l(r,c,u,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null);for(var v=0;vl;++l)this.color[l]=null;this._color_rb=null,this.depth=null,this._depth_rb=null,this._colorType=n,this._useDepth=a,this._useStencil=o;var u=this,f=[0|e,0|r];Object.defineProperties(f,{0:{get:function(){return u._shape[0]},set:function(t){return u.width=t}},1:{get:function(){return u._shape[1]},set:function(t){return u.height=t}}}),this._shapeVector=f,c(this)}function f(t,e,r){if(t._destroyed)throw new Error("gl-fbo: Can't resize destroyed FBO");if(t._shape[0]!==e||t._shape[1]!==r){var a=t.gl,s=a.getParameter(a.MAX_RENDERBUFFER_SIZE);if(0>e||e>s||0>r||r>s)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var l=n(a),c=0;ce||e>o||0>r||r>o)throw new Error("gl-fbo: Parameters are too large for FBO");n=n||{};var s=1;if("color"in n){if(s=Math.max(0|n.color,0),0>s)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(s>1){if(!i)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(s>t.getParameter(i.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+s+" draw buffers")}}var l=t.UNSIGNED_BYTE,c=t.getExtension("OES_texture_float");if(n.float&&s>0){if(!c)throw new Error("gl-fbo: Context does not support floating point textures");l=t.FLOAT}else n.preferFloat&&s>0&&c&&(l=t.FLOAT);var f=!0;"depth"in n&&(f=!!n.depth);var h=!1;return"stencil"in n&&(h=!!n.stencil),new u(t,e,r,l,s,f,h,i)}var d=t("gl-texture2d");e.exports=h;var p,g,v,m,y=null,b=u.prototype;Object.defineProperties(b,{shape:{get:function(){return this._destroyed?[0,0]:this._shapeVector},set:function(t){if(Array.isArray(t)||(t=[0|t,0|t]),2!==t.length)throw new Error("gl-fbo: Shape vector must be length 2");var e=0|t[0],r=0|t[1];return f(this,e,r),[e,r]},enumerable:!1},width:{get:function(){return this._destroyed?0:this._shape[0]},set:function(t){return t=0|t,f(this,t,this._shape[1]),t},enumerable:!1},height:{get:function(){return this._destroyed?0:this._shape[1]},set:function(t){return t=0|t,f(this,this._shape[0],t),t},enumerable:!1}}),b.bind=function(){if(!this._destroyed){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,this.handle),t.viewport(0,0,this._shape[0],this._shape[1])}},b.dispose=function(){if(!this._destroyed){this._destroyed=!0;var t=this.gl;t.deleteFramebuffer(this.handle),this.handle=null,this.depth&&(this.depth.dispose(),this.depth=null),this._depth_rb&&(t.deleteRenderbuffer(this._depth_rb),this._depth_rb=null);for(var e=0;e2&&!this.usingDashes){var C=this.mitreShader;C.bind();var z=C.uniforms;z.matrix=t,z.color=s,z.screenShape=e,z.radius=l*p,C.attributes.p.pointer(f.FLOAT,!1,48,0),f.drawArrays(f.POINTS,0,u/3|0)}}}}(),h.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0],r=[0,0,0,0];return function(n){var i=this.plot,a=this.pickShader,o=this.lineBuffer,s=this.pickBuffer,l=this.width,c=this.numPoints,u=this.bounds,f=this.vertCount,h=i.gl,d=i.viewBox,p=i.dataBox,g=i.pickPixelRatio,v=u[2]-u[0],m=u[3]-u[1],y=p[2]-p[0],b=p[3]-p[1],x=d[2]-d[0],_=d[3]-d[1];if(this.pickOffset=n,!f)return n+c;t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(u[0]-p[0])/y-1,t[7]=2*(u[1]-p[1])/b-1,e[0]=x,e[1]=_,r[0]=255&n,r[1]=n>>>8&255,r[2]=n>>>16&255,r[3]=n>>>24,a.bind();var w=a.uniforms;w.matrix=t,w.width=l*g,w.pickOffset=r,w.screenShape=e;var k=a.attributes;return o.bind(),k.a.pointer(h.FLOAT,!1,16,0),k.d.pointer(h.FLOAT,!1,16,8),s.bind(),k.pick0.pointer(h.UNSIGNED_BYTE,!1,8,0),k.pick1.pointer(h.UNSIGNED_BYTE,!1,8,4),h.drawArrays(h.TRIANGLES,0,f),n+c}}(),h.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.data;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},h.update=function(t){t=t||{};var e=this.plot.gl;!!t.connectGaps;this.color=(t.color||[0,0,1,1]).slice(),this.width=+(t.width||1),this.fill=(t.fill||[!1,!1,!1,!1]).slice(),this.fillColor=i(t.fillColor||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]);for(var r=t.dashes||[1],n=0,a=0;a1,this.dashPattern=l(e,c(o,[n,1,4],[1,0,0])),this.dashPattern.minFilter=e.NEAREST,this.dashPattern.magFilter=e.NEAREST,this.dashLength=n,u.free(o);var d=t.positions;this.data=d;var p=this.bounds;p[0]=p[1]=1/0,p[2]=p[3]=-(1/0);var g=this.numPoints=d.length>>>1;if(0!==g){for(var a=0;g>a;++a){var v=d[2*a],m=d[2*a+1];isNaN(v)||isNaN(m)||(p[0]=Math.min(p[0],v),p[1]=Math.min(p[1],m),p[2]=Math.max(p[2],v),p[3]=Math.max(p[3],m))}p[0]===p[2]&&(p[2]+=1),p[3]===p[1]&&(p[3]+=1);for(var y=u.mallocFloat32(24*(g-1)),b=u.mallocUint32(12*(g-1)),x=y.length,_=b.length,s=g,w=0;s>1;){var k=--s,v=d[2*s],m=d[2*s+1],A=k-1,M=d[2*A],T=d[2*A+1];if(!(isNaN(v)||isNaN(m)||isNaN(M)||isNaN(T))){w+=1,v=(v-p[0])/(p[2]-p[0]),m=(m-p[1])/(p[3]-p[1]),M=(M-p[0])/(p[2]-p[0]),T=(T-p[1])/(p[3]-p[1]);var E=M-v,L=T-m,S=k|1<<24,C=k-1,z=k,P=k-1|1<<24;y[--x]=-L,y[--x]=-E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=-L,y[--x]=-E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=L,y[--x]=E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=-L,y[--x]=-E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C}}this.vertCount=6*w,this.lineBuffer.update(y.subarray(x)),this.pickBuffer.update(b.subarray(_)),u.free(y),u.free(b)}},h.dispose=function(){this.plot.removeObject(this),this.lineBuffer.dispose(),this.pickBuffer.dispose(),this.lineShader.dispose(),this.mitreShader.dispose(),this.fillShader.dispose(),this.pickShader.dispose(),this.dashPattern.dispose()}},{"./lib/shaders":116,"gl-buffer":107,"gl-shader":166,"gl-texture2d":178,ndarray:225,"typedarray-pool":282}],118:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, nextPosition;\nattribute float arcLength, lineWidth;\nattribute vec4 color;\n\nuniform vec2 screenShape;\nuniform float pixelRatio;\nuniform mat4 model, view, projection;\n\nvarying vec4 fragColor;\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\n\nvoid main() {\n vec4 projected = projection * view * model * vec4(position, 1.0);\n vec4 tangentClip = projection * view * model * vec4(nextPosition - position, 0.0);\n vec2 tangent = normalize(screenShape * tangentClip.xy);\n vec2 offset = 0.5 * pixelRatio * lineWidth * vec2(tangent.y, -tangent.x) / screenShape;\n\n gl_Position = vec4(projected.xy + projected.w * offset, projected.zw);\n\n worldPosition = position;\n pixelArcLength = arcLength;\n fragColor = color;\n}\n",a="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\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",o="precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1_0(highp float v) {\n highp 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 highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp 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 highp 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\n\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId/255.0, encode_float_1_0(pixelArcLength).xyz);\n}",s=[{name:"position",type:"vec3"},{name:"nextPosition",type:"vec3"},{name:"arcLength",type:"float"},{name:"lineWidth",type:"float"},{name:"color",type:"vec4"}];r.createShader=function(t){return n(t,i,a,null,s)},r.createPickShader=function(t){return n(t,i,o,null,s)}},{"gl-shader":166}],119:[function(t,e,r){"use strict";function n(t,e){for(var r=0,n=0;3>n;++n){var i=t[n]-e[n];r+=i*i}return Math.sqrt(r)}function i(t){for(var e=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],r=0;3>r;++r)e[0][r]=Math.max(t[0][r],e[0][r]),e[1][r]=Math.min(t[1][r],e[1][r]);return e}function a(t,e,r,n){this.arcLength=t,this.position=e,this.index=r,this.dataCoordinate=n}function o(t,e,r,n,i,a){this.gl=t,this.shader=e,this.pickShader=r,this.buffer=n,this.vao=i,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.points=[],this.arcLength=[],this.vertexCount=0,this.bounds=[[0,0,0],[0,0,0]],this.pickId=0,this.lineWidth=1,this.texture=a,this.dashScale=1,this.opacity=1,this.dirty=!0,this.pixelRatio=1}function s(t){var e=t.gl||t.scene&&t.scene.gl,r=g(e);r.attributes.position.location=0,r.attributes.nextPosition.location=1,r.attributes.arcLength.location=2,r.attributes.lineWidth.location=3,r.attributes.color.location=4;var n=v(e);n.attributes.position.location=0,n.attributes.nextPosition.location=1,n.attributes.arcLength.location=2,n.attributes.lineWidth.location=3,n.attributes.color.location=4;for(var i=l(e),a=c(e,[{buffer:i,size:3,offset:0,stride:48},{buffer:i,size:3,offset:12,stride:48},{buffer:i,size:1,offset:24,stride:48},{buffer:i,size:1,offset:28,stride:48},{buffer:i,size:4,offset:32,stride:48}]),s=d(new Array(1024),[256,1,4]),f=0;1024>f;++f)s.data[f]=255;var h=u(e,s);h.wrap=e.REPEAT;var p=new o(e,r,n,i,a,h);return p.update(t),p}e.exports=s;var l=t("gl-buffer"),c=t("gl-vao"),u=t("gl-texture2d"),f=t("glsl-read-float"),h=t("binary-search-bounds"),d=t("ndarray"),p=t("./lib/shaders"),g=p.createShader,v=p.createPickShader,m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],y=o.prototype;y.isTransparent=function(){return this.opacity<1},y.isOpaque=function(){return this.opacity>=1},y.pickSlots=1,y.setPickBase=function(t){this.pickId=t},y.drawTransparent=y.draw=function(t){var e=this.gl,r=this.shader,n=this.vao;r.bind(),r.uniforms={model:t.model||m,view:t.view||m,projection:t.projection||m,clipBounds:i(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},y.drawPick=function(t){var e=this.gl,r=this.pickShader,n=this.vao;r.bind(),r.uniforms={model:t.model||m,view:t.view||m,projection:t.projection||m,pickId:this.pickId,clipBounds:i(this.clipBounds),screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},y.update=function(t){var e,r;this.dirty=!0;var i=!!t.connectGaps;"dashScale"in t&&(this.dashScale=t.dashScale),"opacity"in t&&(this.opacity=+t.opacity);var a=t.position||t.positions;if(a){var o=t.color||t.colors||[0,0,0,1],s=t.lineWidth||1,l=[],c=[],u=[],f=0,p=0,g=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],v=!1;t:for(e=1;er;++r){if(isNaN(m[r])||isNaN(y[r])||!isFinite(m[r])||!isFinite(y[r])){if(!i&&l.length>0){for(var b=0;24>b;++b)l.push(l[l.length-12]);p+=2,v=!0}continue t}g[0][r]=Math.min(g[0][r],m[r],y[r]),g[1][r]=Math.max(g[1][r],m[r],y[r])}var x,_;Array.isArray(o[0])?(x=o[e-1],_=o[e]):x=_=o,3===x.length&&(x=[x[0],x[1],x[2],1]),3===_.length&&(_=[_[0],_[1],_[2],1]);var w;w=Array.isArray(s)?s[e-1]:s;var k=f;if(f+=n(m,y),v){for(r=0;2>r;++r)l.push(m[0],m[1],m[2],y[0],y[1],y[2],k,w,x[0],x[1],x[2],x[3]);p+=2,v=!1}l.push(m[0],m[1],m[2],y[0],y[1],y[2],k,w,x[0],x[1],x[2],x[3],m[0],m[1],m[2],y[0],y[1],y[2],k,-w,x[0],x[1],x[2],x[3],y[0],y[1],y[2],m[0],m[1],m[2],f,-w,_[0],_[1],_[2],_[3],y[0],y[1],y[2],m[0],m[1],m[2],f,w,_[0],_[1],_[2],_[3]),p+=4}if(this.buffer.update(l),c.push(f),u.push(a[a.length-1].slice()),this.bounds=g,this.vertexCount=p,this.points=u,this.arcLength=c,"dashes"in t){var A=t.dashes,M=A.slice();for(M.unshift(0),e=1;ee;++e){for(r=0;4>r;++r)T.set(e,0,r,0);1&h.le(M,M[M.length-1]*e/255)?T.set(e,0,0,0):T.set(e,0,0,255)}this.texture.setPixels(T)}}},y.dispose=function(){this.shader.dispose(),this.vao.dispose(),this.buffer.dispose()},y.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=f(t.value[0],t.value[1],t.value[2],0),r=h.le(this.arcLength,e);if(0>r)return null;if(r===this.arcLength.length-1)return new a(this.arcLength[this.arcLength.length-1],this.points[this.points.length-1].slice(),r);for(var n=this.points[r],i=this.points[Math.min(r+1,this.points.length-1)],o=(e-this.arcLength[r])/(this.arcLength[r+1]-this.arcLength[r]),s=1-o,l=[0,0,0],c=0;3>c;++c)l[c]=s*n[c]+o*i[c];var u=Math.min(.5>o?r:r+1,this.points.length-1);return new a(e,l,u,this.points[u])}},{"./lib/shaders":118,"binary-search-bounds":47,"gl-buffer":107,"gl-texture2d":178,"gl-vao":182,"glsl-read-float":189,ndarray:225}],120:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r*a-i*n;return o?(o=1/o,t[0]=a*o,t[1]=-n*o,t[2]=-i*o,t[3]=r*o,t):null}e.exports=n},{}],121:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=u*o-s*c,h=-u*a+s*l,d=c*a-o*l,p=r*f+n*h+i*d;return p?(p=1/p,t[0]=f*p,t[1]=(-u*n+i*c)*p,t[2]=(s*n-i*o)*p,t[3]=h*p,t[4]=(u*r-i*l)*p,t[5]=(-s*r+i*a)*p,t[6]=d*p,t[7]=(-c*r+n*l)*p,t[8]=(o*r-n*a)*p,t):null}e.exports=n},{}],122:[function(t,e,r){function n(t){var e=new Float32Array(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}e.exports=n},{}],123:[function(t,e,r){function n(){var t=new Float32Array(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],124:[function(t,e,r){function n(t){var e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],c=t[8],u=t[9],f=t[10],h=t[11],d=t[12],p=t[13],g=t[14],v=t[15],m=e*o-r*a,y=e*s-n*a,b=e*l-i*a,x=r*s-n*o,_=r*l-i*o,w=n*l-i*s,k=c*p-u*d,A=c*g-f*d,M=c*v-h*d,T=u*g-f*p,E=u*v-h*p,L=f*v-h*g;return m*L-y*E+b*T+x*M-_*A+w*k}e.exports=n},{}],125:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r+r,s=n+n,l=i+i,c=r*o,u=n*o,f=n*s,h=i*o,d=i*s,p=i*l,g=a*o,v=a*s,m=a*l;return t[0]=1-f-p,t[1]=u+m,t[2]=h-v,t[3]=0,t[4]=u-m,t[5]=1-c-p,t[6]=d+g,t[7]=0,t[8]=h+v,t[9]=d-g,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],126:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=n+n,l=i+i,c=a+a,u=n*s,f=n*l,h=n*c,d=i*l,p=i*c,g=a*c,v=o*s,m=o*l,y=o*c;return t[0]=1-(d+g),t[1]=f+y,t[2]=h-m,t[3]=0,t[4]=f-y,t[5]=1-(u+g),t[6]=p+v,t[7]=0,t[8]=h+m,t[9]=p-v,t[10]=1-(u+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}e.exports=n},{}],127:[function(t,e,r){function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],128:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],g=e[13],v=e[14],m=e[15],y=r*s-n*o,b=r*l-i*o,x=r*c-a*o,_=n*l-i*s,w=n*c-a*s,k=i*c-a*l,A=u*g-f*p,M=u*v-h*p,T=u*m-d*p,E=f*v-h*g,L=f*m-d*g,S=h*m-d*v,C=y*S-b*L+x*E+_*T-w*M+k*A;return C?(C=1/C,t[0]=(s*S-l*L+c*E)*C,t[1]=(i*L-n*S-a*E)*C,t[2]=(g*k-v*w+m*_)*C,t[3]=(h*w-f*k-d*_)*C,t[4]=(l*T-o*S-c*M)*C,t[5]=(r*S-i*T+a*M)*C,t[6]=(v*x-p*k-m*b)*C,t[7]=(u*k-h*x+d*b)*C,t[8]=(o*L-s*T+c*A)*C,t[9]=(n*T-r*L-a*A)*C,t[10]=(p*w-g*x+m*y)*C,t[11]=(f*x-u*w-d*y)*C,t[12]=(s*M-o*E-l*A)*C,t[13]=(r*E-n*M+i*A)*C,t[14]=(g*b-p*_-v*y)*C,t[15]=(u*_-f*b+h*y)*C,t):null}e.exports=n},{}],129:[function(t,e,r){function n(t,e,r,n){var a,o,s,l,c,u,f,h,d,p,g=e[0],v=e[1],m=e[2],y=n[0],b=n[1],x=n[2],_=r[0],w=r[1],k=r[2];return Math.abs(g-_)<1e-6&&Math.abs(v-w)<1e-6&&Math.abs(m-k)<1e-6?i(t):(f=g-_,h=v-w,d=m-k,p=1/Math.sqrt(f*f+h*h+d*d),f*=p,h*=p,d*=p,a=b*d-x*h,o=x*f-y*d,s=y*h-b*f,p=Math.sqrt(a*a+o*o+s*s),p?(p=1/p,a*=p,o*=p,s*=p):(a=0,o=0,s=0),l=h*s-d*o,c=d*a-f*s,u=f*o-h*a,p=Math.sqrt(l*l+c*c+u*u),p?(p=1/p,l*=p,c*=p,u*=p):(l=0,c=0,u=0),t[0]=a,t[1]=l,t[2]=f,t[3]=0,t[4]=o,t[5]=c,t[6]=h,t[7]=0,t[8]=s,t[9]=u,t[10]=d,t[11]=0,t[12]=-(a*g+o*v+s*m),t[13]=-(l*g+c*v+u*m),t[14]=-(f*g+h*v+d*m),t[15]=1,t)}var i=t("./identity");e.exports=n},{"./identity":127}],130:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],g=e[12],v=e[13],m=e[14],y=e[15],b=r[0],x=r[1],_=r[2],w=r[3];return t[0]=b*n+x*s+_*f+w*g,t[1]=b*i+x*l+_*h+w*v,t[2]=b*a+x*c+_*d+w*m,t[3]=b*o+x*u+_*p+w*y,b=r[4],x=r[5],_=r[6],w=r[7],t[4]=b*n+x*s+_*f+w*g,t[5]=b*i+x*l+_*h+w*v,t[6]=b*a+x*c+_*d+w*m,t[7]=b*o+x*u+_*p+w*y,b=r[8],x=r[9],_=r[10],w=r[11],t[8]=b*n+x*s+_*f+w*g,t[9]=b*i+x*l+_*h+w*v,t[10]=b*a+x*c+_*d+w*m,t[11]=b*o+x*u+_*p+w*y,b=r[12],x=r[13],_=r[14],w=r[15],t[12]=b*n+x*s+_*f+w*g,t[13]=b*i+x*l+_*h+w*v,t[14]=b*a+x*c+_*d+w*m,t[15]=b*o+x*u+_*p+w*y,t}e.exports=n},{}],131:[function(t,e,r){function n(t,e,r,n,i){var a=1/Math.tan(e/2),o=1/(n-i);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+n)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*n*o,t[15]=0,t}e.exports=n},{}],132:[function(t,e,r){function n(t,e,r,n){var i,a,o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w,k,A,M,T,E,L=n[0],S=n[1],C=n[2],z=Math.sqrt(L*L+S*S+C*C);return Math.abs(z)<1e-6?null:(z=1/z,L*=z,S*=z,C*=z,i=Math.sin(r),a=Math.cos(r),o=1-a,s=e[0],l=e[1],c=e[2],u=e[3],f=e[4],h=e[5],d=e[6],p=e[7],g=e[8],v=e[9],m=e[10],y=e[11],b=L*L*o+a,x=S*L*o+C*i,_=C*L*o-S*i,w=L*S*o-C*i,k=S*S*o+a,A=C*S*o+L*i,M=L*C*o+S*i,T=S*C*o-L*i,E=C*C*o+a,t[0]=s*b+f*x+g*_,t[1]=l*b+h*x+v*_,t[2]=c*b+d*x+m*_,t[3]=u*b+p*x+y*_,t[4]=s*w+f*k+g*A,t[5]=l*w+h*k+v*A,t[6]=c*w+d*k+m*A,t[7]=u*w+p*k+y*A,t[8]=s*M+f*T+g*E,t[9]=l*M+h*T+v*E,t[10]=c*M+d*T+m*E,t[11]=u*M+p*T+y*E,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}e.exports=n},{}],133:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+c*n,t[5]=o*i+u*n,t[6]=s*i+f*n,t[7]=l*i+h*n,t[8]=c*i-a*n,t[9]=u*i-o*n,t[10]=f*i-s*n,t[11]=h*i-l*n,t}e.exports=n},{}],134:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i-c*n,t[1]=o*i-u*n,t[2]=s*i-f*n,t[3]=l*i-h*n,t[8]=a*n+c*i,t[9]=o*n+u*i,t[10]=s*n+f*i,t[11]=l*n+h*i,t}e.exports=n},{}],135:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[4],u=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+c*n,t[1]=o*i+u*n,t[2]=s*i+f*n,t[3]=l*i+h*n,t[4]=c*i-a*n,t[5]=u*i-o*n,t[6]=f*i-s*n,t[7]=h*i-l*n,t}e.exports=n},{}],136:[function(t,e,r){function n(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}e.exports=n},{}],137:[function(t,e,r){function n(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g=r[0],v=r[1],m=r[2];return e===t?(t[12]=e[0]*g+e[4]*v+e[8]*m+e[12],t[13]=e[1]*g+e[5]*v+e[9]*m+e[13],t[14]=e[2]*g+e[6]*v+e[10]*m+e[14],t[15]=e[3]*g+e[7]*v+e[11]*m+e[15]):(n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],t[0]=n,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=c,t[7]=u,t[8]=f,t[9]=h,t[10]=d,t[11]=p,t[12]=n*g+s*v+f*m+e[12],t[13]=i*g+l*v+h*m+e[13],t[14]=a*g+c*v+d*m+e[14],t[15]=o*g+u*v+p*m+e[15]),t}e.exports=n},{}],138:[function(t,e,r){function n(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],a=e[6],o=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=a,t[11]=e[14],t[12]=i,t[13]=o,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}e.exports=n},{}],139:[function(t,e,r){"use strict";function n(t,e){switch(e.length){case 0:break;case 1:t[0]=1/e[0];break;case 4:i(t,e);break;case 9:a(t,e);break;case 16:o(t,e);break;default:throw new Error("currently supports matrices up to 4x4")}return t}e.exports=n;var i=t("gl-mat2/invert"),a=t("gl-mat3/invert"),o=t("gl-mat4/invert")},{"gl-mat2/invert":120,"gl-mat3/invert":121,"gl-mat4/invert":128}],140:[function(t,e,r){"use strict";function n(t,e){for(var r=[0,0,0,0],n=0;4>n;++n)for(var i=0;4>i;++i)r[i]+=t[4*n+i]*e[n];return r}function i(t,e,r,i,a){for(var o=n(i,n(r,n(e,[t[0],t[1],t[2],1]))),s=0;3>s;++s)o[s]/=o[3];return[.5*a[0]*(1+o[0]),.5*a[1]*(1-o[1])]}function a(t,e){if(2===t.length){for(var r=0,n=0,i=0;2>i;++i)r+=Math.pow(e[i]-t[0][i],2),n+=Math.pow(e[i]-t[1][i],2);return r=Math.sqrt(r),n=Math.sqrt(n),1e-6>r+n?[1,0]:[n/(r+n),r/(n+r)]}if(3===t.length){var a=[0,0];return c(t[0],t[1],t[2],e,a),l(t,a)}return[]}function o(t,e){for(var r=[0,0,0],n=0;no;++o)r[o]+=a*i[o];return r}function s(t,e,r,n,s,l){if(1===t.length)return[0,t[0].slice()];for(var c=new Array(t.length),u=0;up;++p)d+=Math.pow(c[u][p]-e[p],2);h>d&&(h=d,f=u)}for(var g=a(c,e),v=0,u=0;3>u;++u){if(g[u]<-.001||g[u]>1.0001)return null;v+=g[u]}return Math.abs(v-1)>.001?null:[f,o(t,g),g]}var l=t("barycentric"),c=t("polytope-closest-point/lib/closest_point_2d.js");e.exports=s},{barycentric:29,"polytope-closest-point/lib/closest_point_2d.js":238}],141:[function(t,e,r){var n="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\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\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}",i="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(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\n\n\nfloat cookTorranceSpecular_1_1(\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_2_0(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\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\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(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\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 = cookTorranceSpecular_1_1(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}",a="precision mediump 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}",o="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}",s="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(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}",l="precision mediump 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}",c="precision mediump 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}",u="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if(any(lessThan(f_position, clipBounds[0])) || \n any(greaterThan(f_position, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId, f_id.xyz);\n}",f="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(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}",h="precision mediump 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}",d="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n"; -r.meshShader={vertex:n,fragment:i,attributes:[{name:"position",type:"vec3"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.wireShader={vertex:a,fragment:o,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.pointShader={vertex:s,fragment:l,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]},r.pickShader={vertex:c,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]},r.pointPickShader={vertex:f,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]},r.contourShader={vertex:h,fragment:d,attributes:[{name:"position",type:"vec3"}]}},{}],142:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w,k,A,M,T){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleColors=u,this.triangleNormals=h,this.triangleUVs=f,this.triangleIds=c,this.triangleVAO=d,this.triangleCount=0,this.lineWidth=1,this.edgePositions=p,this.edgeColors=v,this.edgeUVs=m,this.edgeIds=g,this.edgeVAO=y,this.edgeCount=0,this.pointPositions=b,this.pointColors=_,this.pointUVs=w,this.pointSizes=k,this.pointIds=x,this.pointVAO=A,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=M,this.contourVAO=T,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!0,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this._model=I,this._view=I,this._projection=I,this._resolution=[1,1]}function i(t){for(var e=A({colormap:t,nshades:256,format:"rgba"}),r=new Uint8Array(1024),n=0;256>n;++n){for(var i=e[n],a=0;3>a;++a)r[4*n+a]=i[a];r[4*n+3]=255*i[3]}return k(r,[256,256,4],[4,0,1])}function a(t,e,r){for(var n=new Array(e),i=0;e>i;++i)n[i]=0;for(var a=t.length,i=0;a>i;++i)for(var o=t[i],s=0;sn;++n)r[n]=t[n][2];return r}function s(t){var e=v(t,S);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.normal.location=4,e}function l(t){var e=v(t,C);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e}function c(t){var e=v(t,z);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.pointSize.location=4,e}function u(t){var e=v(t,P);return e.attributes.position.location=0,e.attributes.id.location=1,e}function f(t){var e=v(t,R);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.pointSize.location=4,e}function h(t){var e=v(t,O);return e.attributes.position.location=0,e}function d(t){var e=t.gl,r=s(e),i=l(e),a=c(e),o=u(e),d=f(e),p=h(e),g=b(e,k(new Uint8Array([255,255,255,255]),[1,1,4]));g.generateMipmap(),g.minFilter=e.LINEAR_MIPMAP_LINEAR,g.magFilter=e.LINEAR;var v=m(e),x=m(e),_=m(e),w=m(e),A=m(e),M=y(e,[{buffer:v,type:e.FLOAT,size:3},{buffer:A,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:x,type:e.FLOAT,size:4},{buffer:_,type:e.FLOAT,size:2},{buffer:w,type:e.FLOAT,size:3}]),T=m(e),E=m(e),L=m(e),S=m(e),C=y(e,[{buffer:T,type:e.FLOAT,size:3},{buffer:S,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:E,type:e.FLOAT,size:4},{buffer:L,type:e.FLOAT,size:2}]),z=m(e),P=m(e),R=m(e),O=m(e),I=m(e),N=y(e,[{buffer:z,type:e.FLOAT,size:3},{buffer:I,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:P,type:e.FLOAT,size:4},{buffer:R,type:e.FLOAT,size:2},{buffer:O,type:e.FLOAT,size:1}]),j=m(e),F=y(e,[{buffer:j,type:e.FLOAT,size:3}]),B=new n(e,g,r,i,a,o,d,p,v,A,x,_,w,M,T,S,E,L,C,z,I,P,R,O,N,j,F);return B.update(t),B}var p=1e-6,g=1e-6,v=t("gl-shader"),m=t("gl-buffer"),y=t("gl-vao"),b=t("gl-texture2d"),x=t("normals"),_=t("gl-mat4/multiply"),w=t("gl-mat4/invert"),k=t("ndarray"),A=t("colormap"),M=t("simplicial-complex-contour"),T=t("typedarray-pool"),E=t("./lib/shaders"),L=t("./lib/closest-point"),S=E.meshShader,C=E.wireShader,z=E.pointShader,P=E.pickShader,R=E.pointPickShader,O=E.contourShader,I=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],N=n.prototype;N.isOpaque=function(){return this.opacity>=1},N.isTransparent=function(){return this.opacity<1},N.pickSlots=1,N.setPickBase=function(t){this.pickId=t},N.highlight=function(t){if(!t||!this.contourEnable)return void(this.contourCount=0);for(var e=M(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=T.mallocFloat32(6*a),s=0,l=0;a>l;++l)for(var c=r[l],u=0;2>u;++u){var f=c[0];2===c.length&&(f=c[u]);for(var h=n[f][0],d=n[f][1],p=i[f],g=1-p,v=this.positions[h],m=this.positions[d],y=0;3>y;++y)o[s++]=p*v[y]+g*m[y]}this.contourCount=s/3|0,this.contourPositions.update(o.subarray(0,s)),T.free(o)},N.update=function(t){t=t||{};var e=this.gl;this.dirty=!0,"contourEnable"in t&&(this.contourEnable=t.contourEnable),"contourColor"in t&&(this.contourColor=t.contourColor),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"lightPosition"in t&&(this.lightPosition=t.lightPosition),"opacity"in t&&(this.opacity=t.opacity),"ambient"in t&&(this.ambientLight=t.ambient),"diffuse"in t&&(this.diffuseLight=t.diffuse),"specular"in t&&(this.specularLight=t.specular),"roughness"in t&&(this.roughness=t.roughness),"fresnel"in t&&(this.fresnel=t.fresnel),t.texture?(this.texture.dispose(),this.texture=b(e,t.texture)):t.colormap&&(this.texture.shape=[256,256],this.texture.minFilter=e.LINEAR_MIPMAP_LINEAR,this.texture.magFilter=e.LINEAR,this.texture.setPixels(i(t.colormap)),this.texture.generateMipmap());var r=t.cells,n=t.positions;if(n&&r){var s=[],l=[],c=[],u=[],f=[],h=[],d=[],v=[],m=[],y=[],_=[],w=[],k=[],A=[];this.cells=r,this.positions=n;var M=t.vertexNormals,T=t.cellNormals,E=void 0===t.vertexNormalsEpsilon?p:t.vertexNormalsEpsilon,L=void 0===t.faceNormalsEpsilon?g:t.faceNormalsEpsilon;t.useFacetNormals&&!T&&(T=x.faceNormals(r,n,L)),T||M||(M=x.vertexNormals(r,n,E));var S=t.vertexColors,C=t.cellColors,z=t.meshColor||[1,1,1,1],P=t.vertexUVs,R=t.vertexIntensity,O=t.cellUVs,I=t.cellIntensity,N=1/0,j=-(1/0);if(!P&&!O)if(R)for(var F=0;Fq;++q)!isNaN(V[q])&&isFinite(V[q])&&(this.bounds[0][q]=Math.min(this.bounds[0][q],V[q]),this.bounds[1][q]=Math.max(this.bounds[1][q],V[q]));var H=0,G=0,Y=0;t:for(var F=0;Fq;++q)if(isNaN(V[q])||!isFinite(V[q]))continue t;y.push(V[0],V[1],V[2]);var Z;Z=S?S[W]:C?C[F]:z,3===Z.length?_.push(Z[0],Z[1],Z[2],1):_.push(Z[0],Z[1],Z[2],Z[3]);var K;K=P?P[W]:R?[(R[W]-N)/(j-N),0]:O?O[F]:I?[(I[F]-N)/(j-N),0]:[(V[2]-N)/(j-N),0],w.push(K[0],K[1]),D?k.push(D[W]):k.push(U),A.push(F),Y+=1;break;case 2:for(var q=0;2>q;++q)for(var W=X[q],V=n[W],Q=0;3>Q;++Q)if(isNaN(V[Q])||!isFinite(V[Q]))continue t;for(var q=0;2>q;++q){var W=X[q],V=n[W];h.push(V[0],V[1],V[2]);var Z;Z=S?S[W]:C?C[F]:z,3===Z.length?d.push(Z[0],Z[1],Z[2],1):d.push(Z[0],Z[1],Z[2],Z[3]);var K;K=P?P[W]:R?[(R[W]-N)/(j-N),0]:O?O[F]:I?[(I[F]-N)/(j-N),0]:[(V[2]-N)/(j-N),0],v.push(K[0],K[1]),m.push(F)}G+=1;break;case 3:for(var q=0;3>q;++q)for(var W=X[q],V=n[W],Q=0;3>Q;++Q)if(isNaN(V[Q])||!isFinite(V[Q]))continue t;for(var q=0;3>q;++q){var W=X[q],V=n[W];s.push(V[0],V[1],V[2]);var Z;Z=S?S[W]:C?C[F]:z,3===Z.length?l.push(Z[0],Z[1],Z[2],1):l.push(Z[0],Z[1],Z[2],Z[3]);var K;K=P?P[W]:R?[(R[W]-N)/(j-N),0]:O?O[F]:I?[(I[F]-N)/(j-N),0]:[(V[2]-N)/(j-N),0],u.push(K[0],K[1]);var $;$=M?M[W]:T[F],c.push($[0],$[1],$[2]),f.push(F)}H+=1}}this.pointCount=Y,this.edgeCount=G,this.triangleCount=H,this.pointPositions.update(y),this.pointColors.update(_),this.pointUVs.update(w),this.pointSizes.update(k),this.pointIds.update(new Uint32Array(A)),this.edgePositions.update(h),this.edgeColors.update(d),this.edgeUVs.update(v),this.edgeIds.update(new Uint32Array(m)),this.trianglePositions.update(s),this.triangleColors.update(l),this.triangleUVs.update(u),this.triangleNormals.update(c),this.triangleIds.update(new Uint32Array(f))}},N.drawTransparent=N.draw=function(t){t=t||{};for(var e=this.gl,r=t.model||I,n=t.view||I,i=t.projection||I,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;3>o;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);var s={model:r,view:n,projection:i,clipBounds:a,kambient:this.ambientLight,kdiffuse:this.diffuseLight,kspecular:this.specularLight,roughness:this.roughness,fresnel:this.fresnel,eyePosition:[0,0,0],lightPosition:[0,0,0],opacity:this.opacity,contourColor:this.contourColor,texture:0};this.texture.bind(0);var l=new Array(16);_(l,s.view,s.model),_(l,s.projection,l),w(l,l);for(var o=0;3>o;++o)s.eyePosition[o]=l[12+o]/l[15];for(var c=l[15],o=0;3>o;++o)c+=this.lightPosition[o]*l[4*o+3];for(var o=0;3>o;++o){for(var u=l[12+o],f=0;3>f;++f)u+=l[4*f+o]*this.lightPosition[f];s.lightPosition[o]=u/c}if(this.triangleCount>0){var h=this.triShader;h.bind(),h.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()}if(this.edgeCount>0&&this.lineWidth>0){var h=this.lineShader;h.bind(),h.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()}if(this.pointCount>0){var h=this.pointShader;h.bind(),h.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}if(this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0){var h=this.contourShader;h.bind(),h.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind()}},N.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||I,n=t.view||I,i=t.projection||I,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;3>o;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s={model:r,view:n,projection:i,clipBounds:a,pickId:this.pickId/255},l=this.pickShader;if(l.bind(),l.uniforms=s,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0){var l=this.pointPickShader;l.bind(),l.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}},N.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;for(var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions,i=new Array(r.length),a=0;ag;++g){var v=l[g],m=l[g+2],y=m-v,b=.5*(c[g+2]+c[g]),x=c[g+2]-c[g];e[g]=2*y/x,t[g]=2*(v-b)/x}a.bind(),i.bind(),a.attributes.dataCoord.pointer(),a.uniforms.dataShift=t,a.uniforms.dataScale=e;for(var _=0,g=0;2>g;++g){r[0]=r[1]=0,r[g]=1,a.uniforms.dataAxis=r,a.uniforms.lineWidth=f[g]/(u[g+2]-u[g])*p,a.uniforms.color=h[g];var w=6*o[g].length;d[g]&&w&&s.drawArrays(s.TRIANGLES,_,w),_+=w}}}(),u.drawTickMarks=function(){var t=[0,0],e=[0,0],r=[1,0],n=[0,1],a=[0,0],o=[0,0];return function(){for(var s=this.plot,c=this.vbo,u=this.tickShader,f=this.ticks,h=s.gl,d=s._tickBounds,p=s.dataBox,g=s.viewBox,v=s.pixelRatio,m=s.screenBox,y=m[2]-m[0],b=m[3]-m[1],x=g[2]-g[0],_=g[3]-g[1],w=0;2>w;++w){var k=d[w],A=d[w+2],M=A-k,T=.5*(p[w+2]+p[w]),E=p[w+2]-p[w];e[w]=2*M/E,t[w]=2*(k-T)/E}e[0]*=x/y,t[0]*=x/y,e[1]*=_/b,t[1]*=_/b,u.bind(),c.bind(),u.attributes.dataCoord.pointer();var L=u.uniforms;L.dataShift=t,L.dataScale=e;var S=s.tickMarkLength,C=s.tickMarkWidth,z=s.tickMarkColor,P=0,R=6*f[0].length,O=Math.min(l.ge(f[0],(p[0]-d[0])/(d[2]-d[0]),i),f[0].length),I=Math.min(l.gt(f[0],(p[2]-d[0])/(d[2]-d[0]),i),f[0].length),N=P+6*O,j=6*Math.max(0,I-O),F=Math.min(l.ge(f[1],(p[1]-d[1])/(d[3]-d[1]),i),f[1].length),B=Math.min(l.gt(f[1],(p[3]-d[1])/(d[3]-d[1]),i),f[1].length),D=R+6*F,U=6*Math.max(0,B-F);a[0]=2*(g[0]-S[1])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[1]*v/y,o[1]=C[1]*v/b,U&&(L.color=z[1],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,D,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[1]-S[0])/b-1,o[0]=C[0]*v/y,o[1]=S[0]*v/b,j&&(L.color=z[0],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,N,j)),a[0]=2*(g[2]+S[3])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[3]*v/y,o[1]=C[3]*v/b,U&&(L.color=z[3],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,D,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[3]+S[2])/b-1,o[0]=C[2]*v/y,o[1]=S[2]*v/b,j&&(L.color=z[2],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,N,j))}}(),u.update=function(){var t=[1,1,-1,-1,1,-1],e=[1,-1,1,1,-1,-1];return function(r){for(var n=r.ticks,i=r.bounds,a=new Float32Array(18*(n[0].length+n[1].length)),o=(this.plot.zeroLineEnable,0),s=[[],[]],l=0;2>l;++l)for(var c=s[l],u=n[l],f=i[l],h=i[l+2],d=0;dg;++g)a[o++]=p,a[o++]=t[g],a[o++]=e[g]}this.ticks=s,this.vbo.update(a)}}(),u.dispose=function(){this.vbo.dispose(),this.shader.dispose(),this.tickShader.dispose()}},{"./shaders":146,"binary-search-bounds":148,"gl-buffer":107,"gl-shader":166}],145:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[-1,-1,-1,1,1,-1,1,1]),i=o(e,s.lineVert,s.lineFrag),l=new n(t,r,i);return l}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawLine=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o,s){var l=this.plot,c=this.shader,u=l.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,c.uniforms.start=t,c.uniforms.end=e,c.uniforms.width=o*l.pixelRatio,c.uniforms.color=s,u.drawArrays(u.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":146,"gl-buffer":107,"gl-shader":166}],146:[function(t,e,r){"use strict";var n="precision lowp float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = vec4(color.xyz * color.w, color.w);\n}\n";e.exports={lineVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 start, end;\nuniform float width;\n\nvec2 perp(vec2 v) {\n return vec2(v.y, -v.x);\n}\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n vec2 delta = normalize(perp(start - end));\n vec2 offset = mix(start, end, 0.5 * (coord.y+1.0));\n gl_Position = vec4(screen(offset + 0.5 * width * delta * coord.x), 0, 1);\n}\n",lineFrag:n,textVert:"#define GLSLIFY 1\nattribute vec3 textCoordinate;\n\nuniform vec2 dataScale, dataShift, dataAxis, screenOffset, textScale;\nuniform float angle;\n\nvoid main() {\n float dataOffset = textCoordinate.z;\n vec2 glyphOffset = textCoordinate.xy;\n mat2 glyphMatrix = mat2(cos(angle), sin(angle), -sin(angle), cos(angle));\n vec2 screenCoordinate = dataAxis * (dataScale * dataOffset + dataShift) +\n glyphMatrix * glyphOffset * textScale + screenOffset;\n gl_Position = vec4(screenCoordinate, 0, 1);\n}\n",textFrag:n,gridVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale;\nuniform float lineWidth;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n pos += 10.0 * dataCoord.y * vec2(dataAxis.y, -dataAxis.x) + dataCoord.z * lineWidth;\n gl_Position = vec4(pos, 0, 1);\n}\n",gridFrag:n,boxVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 lo, hi;\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n gl_Position = vec4(screen(mix(lo, hi, coord)), 0, 1);\n}\n",tickVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale, screenOffset, tickScale;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n gl_Position = vec4(pos + tickScale*dataCoord.yz + screenOffset, 0, 1);\n}\n"}},{}],147:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r,this.tickOffset=[[],[]],this.tickX=[[],[]],this.labelOffset=[0,0],this.labelCount=[0,0]}function i(t){var e=t.gl,r=a(e),i=o(e,c.textVert,c.textFrag),s=new n(t,r,i);return s}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("text-cache"),l=t("binary-search-bounds"),c=t("./shaders"),u=n.prototype;u.drawTicks=function(){var t=[0,0],e=[0,0],r=[0,0];return function(n){var i=this.plot,a=this.shader,o=this.tickX[n],s=this.tickOffset[n],c=i.gl,u=i.viewBox,f=i.dataBox,h=i.screenBox,d=i.pixelRatio,p=i.tickEnable,g=i.tickPad,v=i.tickColor,m=i.tickAngle,y=(i.tickMarkLength,i.labelEnable),b=i.labelPad,x=i.labelColor,_=i.labelAngle,w=this.labelOffset[n],k=this.labelCount[n],A=l.lt(o,f[n]),M=l.le(o,f[n+2]);t[0]=t[1]=0,t[n]=1,e[n]=(u[2+n]+u[n])/(h[2+n]-h[n])-1;var T=2/h[2+(1^n)]-h[1^n];e[1^n]=T*u[1^n]-1,p[n]&&(e[1^n]-=T*d*g[n],M>A&&s[M]>s[A]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n],a.uniforms.angle=m[n],c.drawArrays(c.TRIANGLES,s[A],s[M]-s[A]))),y[n]&&k&&(e[1^n]-=T*d*b[n],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n],a.uniforms.angle=_[n],c.drawArrays(c.TRIANGLES,w,k)),e[1^n]=T*u[2+(1^n)]-1,p[n+2]&&(e[1^n]+=T*d*g[n+2],M>A&&s[M]>s[A]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n+2],a.uniforms.angle=m[n+2],c.drawArrays(c.TRIANGLES,s[A],s[M]-s[A]))),y[n+2]&&k&&(e[1^n]+=T*d*b[n+2],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n+2],a.uniforms.angle=_[n+2],c.drawArrays(c.TRIANGLES,w,k))}}(),u.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,i=r.gl,a=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,o=r.titleCenter,c=r.pixelRatio;if(this.titleCount){for(var u=0;2>u;++u)e[u]=2*(o[u]*c-a[u])/(a[2+u]-a[u])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,i.drawArrays(i.TRIANGLES,this.titleOffset,this.titleCount)}}}(),u.bind=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){var n=this.plot,i=this.shader,a=n._tickBounds,o=n.dataBox,s=n.screenBox,l=n.viewBox;i.bind();for(var c=0;2>c;++c){var u=a[c],f=a[c+2],h=f-u,d=.5*(o[c+2]+o[c]),p=o[c+2]-o[c],g=l[c],v=l[c+2],m=v-g,y=s[c],b=s[c+2],x=b-y;e[c]=2*h/p*m/x,t[c]=2*(u-d)/p*m/x}r[1]=2*n.pixelRatio/(s[3]-s[1]),r[0]=r[1]*(s[3]-s[1])/(s[2]-s[0]),i.uniforms.dataScale=e,i.uniforms.dataShift=t,i.uniforms.textScale=r,this.vbo.bind(),i.attributes.textCoordinate.pointer()}}(),u.update=function(t){for(var e=[],r=t.ticks,n=t.bounds,i=0;2>i;++i){for(var a=[Math.floor(e.length/3)],o=[-(1/0)],l=r[i],c=0;ci;++i){this.labelOffset[i]=Math.floor(e.length/3);for(var g=s(t.labelFont[i],t.labels[i]).data,p=t.labelSize[i],c=0;cp;++p)if(f[p]&&n[p]<=0&&n[p+2]>=0){var g=e[p]-n[p]*(e[p+2]-e[p])/(n[p+2]-n[p]);0===p?o.drawLine(g,e[1],g,e[3],d[p],h[p]):o.drawLine(e[0],g,e[2],g,d[p],h[p])}}for(var p=0;pp;++p)s.drawTicks(p);this.titleEnable&&s.drawTitle();for(var b=this.overlays,p=0;pc;++c){var u=s[c].slice(0);0!==u.length&&(u.sort(a),l[c]=Math.min(l[c],u[0].x),l[c+2]=Math.max(l[c+2],u[u.length-1].x))}this.grid.update({bounds:l,ticks:s}),this.text.update({bounds:l,ticks:s,labels:t.labels||["x","y"],labelSize:t.labelSize||[12,12],labelFont:t.labelFont||["sans-serif","sans-serif"],title:t.title||"",titleSize:t.titleSize||18,titleFont:t.titleFont||"sans-serif"}),this.setDirty()},h.dispose=function(){this.box.dispose(),this.grid.dispose(),this.text.dispose(),this.line.dispose();for(var t=this.objects.length-1;t>=0;--t)this.objects[t].dispose();this.objects.length=0;for(var t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},h.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},h.removeObject=function(t){for(var e=this.objects,r=0;re){var r=Math.round(Math.pow(10,-e));return Math.ceil(t*r)/r}if(e>0){var r=Math.round(Math.pow(10,e));return Math.ceil(t/r)*r}return Math.ceil(t)}function o(t){return"boolean"==typeof t?t:!0}function s(t){function e(){if(!_&&H.autoResize){var t=w.parentNode,e=1,r=1;t&&t!==document.body?(e=t.clientWidth,r=t.clientHeight):(e=window.innerWidth,r=window.innerHeight);var n=0|Math.ceil(e*H.pixelRatio),i=0|Math.ceil(r*H.pixelRatio);if(n!==w.width||i!==w.height){w.width=n,w.height=i;var a=w.style;a.position=a.position||"absolute",a.left="0px",a.top="0px",a.width=e+"px",a.height=r+"px",F=!0}}}function r(){for(var t=O.length,e=j.length,r=0;e>r;++r)N[r]=0;t:for(var r=0;t>r;++r){var n=O[r],i=n.pickSlots;if(i){for(var a=0;e>a;++a)if(N[a]+i<255){I[r]=a,n.setPickBase(N[a]+1),N[a]+=i;continue t}var o=h(A,q);I[r]=e,j.push(o),N.push(i),n.setPickBase(1),e+=1}else I[r]=-1}for(;e>0&&0===N[e-1];)N.pop(),j.pop().dispose()}function s(){return H.contextLost?!0:void(A.isContextLost()&&(H.contextLost=!0,H.mouseListener.enabled=!1,H.selection.object=null,H.oncontextloss&&H.oncontextloss()))}function y(){if(!s()){A.colorMask(!0,!0,!0,!0),A.depthMask(!0),A.disable(A.BLEND),A.enable(A.DEPTH_TEST);for(var t=O.length,e=j.length,r=0;e>r;++r){var n=j[r];n.shape=G,n.begin();for(var i=0;t>i;++i)if(I[i]===r){var a=O[i];a.drawPick&&(a.pixelRatio=1,a.drawPick(V))}n.end()}}}function b(){if(!s()){e();var t=H.camera.tick();V.view=H.camera.matrix,F=F||t,B=B||t,z.pixelRatio=H.pixelRatio,R.pixelRatio=H.pixelRatio;var r=O.length,n=W[0],i=W[1];n[0]=n[1]=n[2]=1/0,i[0]=i[1]=i[2]=-(1/0);for(var o=0;r>o;++o){var l=O[o];l.pixelRatio=H.pixelRatio,l.axes=H.axes,F=F||!!l.dirty,B=B||!!l.dirty;var c=l.bounds;if(c)for(var f=c[0],h=c[1],d=0;3>d;++d)n[d]=Math.min(n[d],f[d]),i[d]=Math.max(i[d],h[d])}var g=H.bounds;if(H.autoBounds)for(var d=0;3>d;++d){if(i[d]d;++d)b=b||Z[0][d]!==g[0][d]||Z[1][d]!==g[1][d],Z[0][d]=g[0][d],Z[1][d]=g[1][d];if(b){for(var x=[0,0,0],o=0;3>o;++o)x[o]=a((g[1][o]-g[0][o])/10);z.autoTicks?z.update({bounds:g,tickSpacing:x}):z.update({bounds:g})}B=B||b,F=F||b;var _=A.drawingBufferWidth,w=A.drawingBufferHeight;q[0]=_,q[1]=w,G[0]=0|Math.max(_/H.pixelRatio,1),G[1]=0|Math.max(w/H.pixelRatio,1),v(D,H.fovy,_/w,H.zNear,H.zFar);for(var o=0;16>o;++o)U[o]=0;U[15]=1;for(var k=0,o=0;3>o;++o)k=Math.max(k,g[1][o]-g[0][o]);for(var o=0;3>o;++o)H.autoScale?U[5*o]=H.aspect[o]/(g[1][o]-g[0][o]):U[5*o]=1/k,H.autoCenter&&(U[12+o]=.5*-U[5*o]*(g[0][o]+g[1][o]));for(var o=0;r>o;++o){var l=O[o];l.axesBounds=g,H.clipToBounds&&(l.clipBounds=g)}if(T.object&&(H.snapToData?R.position=T.dataCoordinate:R.position=T.dataPosition,R.bounds=g),B&&(B=!1,y()),F){H.axesPixels=u(H.axes,V,_,w),H.onrender&&H.onrender(),A.bindFramebuffer(A.FRAMEBUFFER,null),A.viewport(0,0,_,w);var M=H.clearColor;A.clearColor(M[0],M[1],M[2],M[3]),A.clear(A.COLOR_BUFFER_BIT|A.DEPTH_BUFFER_BIT),A.depthMask(!0),A.colorMask(!0,!0,!0,!0),A.enable(A.DEPTH_TEST),A.depthFunc(A.LEQUAL),A.disable(A.BLEND),A.disable(A.CULL_FACE);var S=!1;z.enable&&(S=S||z.isTransparent(),z.draw(V)),R.axes=z,T.object&&R.draw(V),A.disable(A.CULL_FACE);for(var o=0;r>o;++o){var l=O[o];l.axes=z,l.pixelRatio=H.pixelRatio,l.isOpaque&&l.isOpaque()&&l.draw(V),l.isTransparent&&l.isTransparent()&&(S=!0)}if(S){E.shape=q,E.bind(),A.clear(A.DEPTH_BUFFER_BIT),A.colorMask(!1,!1,!1,!1),A.depthMask(!0),A.depthFunc(A.LESS),z.enable&&z.isTransparent()&&z.drawTransparent(V);for(var o=0;r>o;++o){var l=O[o];l.isOpaque&&l.isOpaque()&&l.draw(V)}A.enable(A.BLEND),A.blendEquation(A.FUNC_ADD),A.blendFunc(A.ONE,A.ONE_MINUS_SRC_ALPHA),A.colorMask(!0,!0,!0,!0),A.depthMask(!1),A.clearColor(0,0,0,0),A.clear(A.COLOR_BUFFER_BIT),z.isTransparent()&&z.drawTransparent(V);for(var o=0;r>o;++o){var l=O[o];l.isTransparent&&l.isTransparent()&&l.drawTransparent(V)}A.bindFramebuffer(A.FRAMEBUFFER,null),A.blendFunc(A.ONE,A.ONE_MINUS_SRC_ALPHA),A.disable(A.DEPTH_TEST),L.bind(),E.color[0].bind(0),L.uniforms.accumBuffer=0,p(A),A.disable(A.BLEND)}F=!1;for(var o=0;r>o;++o)O[o].dirty=!1}}}function x(){_||H.contextLost||(requestAnimationFrame(x),b())}t=t||{};var _=!1,w=(t.pixelRatio||parseFloat(window.devicePixelRatio),t.canvas);if(!w)if(w=document.createElement("canvas"),t.container){var k=t.container;k.appendChild(w)}else document.body.appendChild(w);var A=t.gl;if(A||(A=i(w,t.glOptions||{premultipliedAlpha:!0,antialias:!0})),!A)throw new Error("webgl not supported");var M=t.bounds||[[-10,-10,-10],[10,10,10]],T=new n,E=d(A,[A.drawingBufferWidth,A.drawingBufferHeight],{preferFloat:!0}),L=m(A),S=t.camera||{eye:[2,0,0],center:[0,0,0],up:[0,1,0],zoomMin:.1,zoomMax:100,mode:"turntable"},C=t.axes||{},z=c(A,C);z.enable=!C.disable;var P=t.spikes||{},R=f(A,P),O=[],I=[],N=[],j=[],F=!0,B=!0,D=new Array(16),U=new Array(16),V={view:null,projection:D,model:U},B=!0,q=[A.drawingBufferWidth,A.drawingBufferHeight],H={gl:A,contextLost:!1,pixelRatio:t.pixelRatio||parseFloat(window.devicePixelRatio),canvas:w,selection:T,camera:l(w,S),axes:z,axesPixels:null,spikes:R,bounds:M,objects:O,shape:q,aspect:t.aspectRatio||[1,1,1],pickRadius:t.pickRadius||10,zNear:t.zNear||.01,zFar:t.zFar||1e3,fovy:t.fovy||Math.PI/4,clearColor:t.clearColor||[0,0,0,0],autoResize:o(t.autoResize),autoBounds:o(t.autoBounds),autoScale:!!t.autoScale,autoCenter:o(t.autoCenter),clipToBounds:o(t.clipToBounds),snapToData:!!t.snapToData,onselect:t.onselect||null,onrender:t.onrender||null,onclick:t.onclick||null,cameraParams:V,oncontextloss:null,mouseListener:null},G=[A.drawingBufferWidth/H.pixelRatio|0,A.drawingBufferHeight/H.pixelRatio|0];H.autoResize&&e(),window.addEventListener("resize",e),H.update=function(t){_||(t=t||{},F=!0,B=!0)},H.add=function(t){_||(t.axes=z,O.push(t),I.push(-1),F=!0,B=!0,r())},H.remove=function(t){if(!_){var e=O.indexOf(t);0>e||(O.splice(e,1),I.pop(),F=!0,B=!0,r())}},H.dispose=function(){if(!_&&(_=!0,window.removeEventListener("resize",e),w.removeEventListener("webglcontextlost",s),H.mouseListener.enabled=!1,!H.contextLost)){z.dispose(),R.dispose();for(var t=0;ts;++s){var l=j[s].query(e,G[1]-r-1,H.pickRadius);if(l){if(l.distance>T.distance)continue;for(var c=0;i>c;++c){var u=O[c];if(I[c]===s){var f=u.pick(l);f&&(T.buttons=t,T.screen=l.coord,T.distance=l.distance,T.object=u,T.index=f.distance,T.dataPosition=f.position,T.dataCoordinate=f.dataCoordinate,T.data=f,o=!0)}}}}}a&&a!==T.object&&(a.highlight&&a.highlight(null),F=!0),T.object&&(T.object.highlight&&T.object.highlight(T.data),F=!0),o=o||T.object!==a,o&&H.onselect&&H.onselect(T),1&t&&!(1&X)&&H.onclick&&H.onclick(T),X=t}}),w.addEventListener("webglcontextlost",s);var W=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],Z=[W[0].slice(),W[1].slice()];return x(),H.redraw=function(){_||(F=!0,b())},H}e.exports=s;var l=t("3d-view-controls"),c=t("gl-axes3d"),u=t("gl-axes3d/properties"),f=t("gl-spikes3d"),h=t("gl-select-static"),d=t("gl-fbo"),p=t("a-big-triangle"),g=t("mouse-change"),v=t("gl-mat4/perspective"),m=t("./lib/shader")},{"./lib/shader":150,"3d-view-controls":20,"a-big-triangle":22,"gl-axes3d":99,"gl-axes3d/properties":106,"gl-fbo":114,"gl-mat4/perspective":131,"gl-select-static":165,"gl-spikes3d":175,"mouse-change":211}],152:[function(t,e,r){function n(t,e,r,n){var i,a,o,s,l,c=e[0],u=e[1],f=e[2],h=e[3],d=r[0],p=r[1],g=r[2],v=r[3];return a=c*d+u*p+f*g+h*v,0>a&&(a=-a,d=-d,p=-p,g=-g,v=-v),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n),t[0]=s*c+l*d,t[1]=s*u+l*p,t[2]=s*f+l*g,t[3]=s*h+l*v,t}e.exports=n},{}],153:[function(t,e,r){"use strict";e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n fragColor = color;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n",fragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n}\n",pickVertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 id;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\nuniform vec4 pickOffset;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n vec4 fragId = id + pickOffset;\n\n fragId.y += floor(fragId.x / 256.0);\n fragId.x -= floor(fragId.x / 256.0) * 256.0;\n\n fragId.z += floor(fragId.y / 256.0);\n fragId.y -= floor(fragId.y / 256.0) * 256.0;\n\n fragId.w += floor(fragId.z / 256.0);\n fragId.z -= floor(fragId.z / 256.0) * 256.0;\n\n fragColor = fragId / 255.0;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n",pickFragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = fragColor;\n}\n"}},{}],154:[function(t,e,r){"use strict";function n(t){if(t in h)return h[t];var e=u(t,{polygons:!0,font:"sans-serif",textAlign:"left",textBaseline:"alphabetic"}),r=[],n=[];e.forEach(function(t){t.forEach(function(t){for(var e=0;eo;++o)i[o]=Math.min(i[o],r[a+o]),i[2+o]=Math.max(i[2+o],r[a+o]);return h[t]={coords:r,normals:n,bounds:i}}function i(t,e,r,n,i,a,o){this.plot=t,this.shader=e,this.pickShader=r,this.positionBuffer=n,this.offsetBuffer=i,this.colorBuffer=a,this.idBuffer=o,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.numVertices=0,this.pickOffset=0,this.points=null}function a(t,e){var r=t.gl,n=o(r,f.vertex,f.fragment),a=o(r,f.pickVertex,f.pickFragment),l=s(r),c=s(r),u=s(r),h=s(r),d=new i(t,n,a,l,c,u,h);return d.update(e),t.addObject(d),d}e.exports=a;var o=t("gl-shader"),s=t("gl-buffer"),l=t("text-cache"),c=t("typedarray-pool"),u=t("vectorize-text"),f=t("./lib/shaders"),h={},d=i.prototype;!function(){function t(){var t=this.plot,n=this.bounds,i=t.viewBox,a=t.dataBox,o=t.pixelRatio,s=n[2]-n[0],l=n[3]-n[1],c=a[2]-a[0],u=a[3]-a[1];e[0]=2*s/c,e[4]=2*l/u,e[6]=2*(n[0]-a[0])/c-1,e[7]=2*(n[1]-a[1])/u-1;var f=i[2]-i[0],h=i[3]-i[1];r[0]=2*o/f,r[1]=2*o/h}var e=[1,0,0,0,1,0,0,0,1],r=[1,1];d.draw=function(){var n=this.plot,i=this.shader,a=this.numVertices;if(a){var o=n.gl;t.call(this),i.bind(),i.uniforms.pixelScale=r,i.uniforms.viewTransform=e,this.positionBuffer.bind(),i.attributes.position.pointer(),this.offsetBuffer.bind(),i.attributes.offset.pointer(),this.colorBuffer.bind(),i.attributes.color.pointer(o.UNSIGNED_BYTE,!0),o.drawArrays(o.TRIANGLES,0,a)}};var n=[0,0,0,0];d.drawPick=function(i){var a=this.plot,o=this.pickShader,s=this.numVertices,l=a.gl;if(this.pickOffset=i,!s)return i;for(var c=0;4>c;++c)n[c]=i>>8*c&255;return t.call(this),o.bind(),o.uniforms.pixelScale=r,o.uniforms.viewTransform=e,o.uniforms.pickOffset=n,this.positionBuffer.bind(),o.attributes.position.pointer(),this.offsetBuffer.bind(),o.attributes.offset.pointer(),this.idBuffer.bind(),o.attributes.id.pointer(l.UNSIGNED_BYTE,!1),l.drawArrays(l.TRIANGLES,0,s),i+this.numPoints}}(),d.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},d.update=function(t){t=t||{};var e=t.positions||[],r=t.colors||[],i=t.glyphs||[],a=t.sizes||[],o=t.borderWidths||[],s=t.borderColors||[];this.points=e;for(var u=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=0,h=0;h>1;for(var d=0;2>d;++d)u[d]=Math.min(u[d],e[2*h+d]),u[2+d]=Math.max(u[2+d],e[2*h+d])}u[0]===u[2]&&(u[2]+=1),u[3]===u[1]&&(u[3]+=1);for(var p=1/(u[2]-u[0]),g=1/(u[3]-u[1]),v=u[0],m=u[1],y=c.mallocFloat32(2*f),b=c.mallocFloat32(2*f),x=c.mallocUint8(4*f),_=c.mallocUint32(f),w=0,h=0;h=a?i(0,a-1,t,e,r,n):f(0,a-1,t,e,r,n)}function i(t,e,r,n,i,a){for(var o=t+1;e>=o;++o){for(var s=r[o],l=n[2*o],c=n[2*o+1],u=i[o],f=a[o],h=o;h>t;){var d=r[h-1],p=n[2*(h-1)];if((d-s||l-p)>=0)break;r[h]=d,n[2*h]=p,n[2*h+1]=n[2*h-1],i[h]=i[h-1],a[h]=a[h-1],h-=1}r[h]=s,n[2*h]=l,n[2*h+1]=c,i[h]=u,a[h]=f}}function a(t,e,r,n,i,a){var o=r[t],s=n[2*t],l=n[2*t+1],c=i[t],u=a[t];r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e],r[e]=o,n[2*e]=s,n[2*e+1]=l,i[e]=c,a[e]=u}function o(t,e,r,n,i,a){r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e]}function s(t,e,r,n,i,a,o){var s=n[t],l=i[2*t],c=i[2*t+1],u=a[t],f=o[t];n[t]=n[e],i[2*t]=i[2*e],i[2*t+1]=i[2*e+1],a[t]=a[e],o[t]=o[e],n[e]=n[r],i[2*e]=i[2*r],i[2*e+1]=i[2*r+1],a[e]=a[r],o[e]=o[r],n[r]=s,i[2*r]=l,i[2*r+1]=c,a[r]=u,o[r]=f}function l(t,e,r,n,i,a,o,s,l,c,u){s[t]=s[e],l[2*t]=l[2*e],l[2*t+1]=l[2*e+1],c[t]=c[e],u[t]=u[e],s[e]=r,l[2*e]=n,l[2*e+1]=i,c[e]=a,u[e]=o}function c(t,e,r,n,i){return(r[t]-r[e]||n[2*e]-n[2*t]||i[t]-i[e])<0}function u(t,e,r,n,i,a,o,s){return(e-a[t]||o[2*t]-r||i-s[t])<0}function f(t,e,r,n,d,p){var g=(e-t+1)/6|0,v=t+g,m=e-g,y=t+e>>1,b=y-g,x=y+g,_=v,w=b,k=y,A=x,M=m,T=t+1,E=e-1,L=0;c(_,w,r,n,d,p)&&(L=_,_=w,w=L),c(A,M,r,n,d,p)&&(L=A,A=M,M=L),c(_,k,r,n,d,p)&&(L=_,_=k,k=L),c(w,k,r,n,d,p)&&(L=w,w=k,k=L),c(_,A,r,n,d,p)&&(L=_,_=A,A=L),c(k,A,r,n,d,p)&&(L=k,k=A,A=L),c(w,M,r,n,d,p)&&(L=w,w=M,M=L),c(w,k,r,n,d,p)&&(L=w,w=k,k=L),c(A,M,r,n,d,p)&&(L=A,A=M,M=L);var S=r[w],C=n[2*w],z=n[2*w+1],P=d[w],R=p[w],O=r[A],I=n[2*A],N=n[2*A+1],j=d[A],F=p[A],B=_,D=k,U=M,V=v,q=y,H=m,G=r[B],Y=r[D],X=r[U];r[V]=G,r[q]=Y,r[H]=X;for(var W=0;2>W;++W){var Z=n[2*B+W],K=n[2*D+W],Q=n[2*U+W];n[2*V+W]=Z,n[2*q+W]=K,n[2*H+W]=Q}var $=d[B],J=d[D],tt=d[U];d[V]=$,d[q]=J,d[H]=tt;var et=p[B],rt=p[D],nt=p[U];p[V]=et,p[q]=rt,p[H]=nt,o(b,t,r,n,d,p),o(x,e,r,n,d,p);for(var it=T;E>=it;++it)if(u(it,S,C,z,P,r,n,d))it!==T&&a(it,T,r,n,d,p),++T;else if(!u(it,O,I,N,j,r,n,d))for(;;){if(u(E,O,I,N,j,r,n,d)){u(E,S,C,z,P,r,n,d)?(s(it,T,E,r,n,d,p),++T,--E):(a(it,E,r,n,d,p),--E);break}if(--E=T-2-t?i(t,T-2,r,n,d,p):f(t,T-2,r,n,d,p),h>=e-(E+2)?i(E+2,e,r,n,d,p):f(E+2,e,r,n,d,p),h>=E-T?i(T,E,r,n,d,p):f(T,E,r,n,d,p)}e.exports=n;var h=32},{}],158:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s){for(var l=r,c=r;n>c;++c){var u=t[2*c],f=t[2*c+1],h=e[c];u>=i&&o>=u&&f>=a&&s>=f&&(c===l?l+=1:(t[2*c]=t[2*l],t[2*c+1]=t[2*l+1],e[c]=e[l],t[2*l]=u,t[2*l+1]=f,e[l]=h,l+=1))}return l}function i(t,e,r){this.pixelSize=t,this.offset=e,this.count=r}function a(t,e,r,a){function l(i,a,o,s,c,u){var f=.5*o,h=s+1,d=c-s;r[_]=d,x[_++]=u;for(var p=0;2>p;++p)for(var g=0;2>g;++g){var v=i+p*f,m=a+g*f,y=n(t,e,h,c,v,m,v+f,m+f);if(y!==h){if(y-h>=Math.max(.9*d,32)){var b=c+s>>>1;l(v,m,f,h,b,u+1),h=b}l(v,m,f,h,y,u+1),h=y}}}var c=t.length>>>1;if(1>c)return[];for(var u=1/0,f=1/0,h=-(1/0),d=-(1/0),p=0;c>p;++p){var g=t[2*p],v=t[2*p+1];u=Math.min(u,g),h=Math.max(h,g),f=Math.min(f,v),d=Math.max(d,v),e[p]=p}u===h&&(h+=1+Math.abs(h)),f===d&&(d+=1+Math.abs(h));var m=1/(h-u),y=1/(d-f),b=Math.max(h-u,d-f);a=a||[0,0,0,0],a[0]=u,a[1]=f,a[2]=h,a[3]=d;var x=o.mallocInt32(c),_=0;l(u,f,b,0,c,0),s(x,t,e,r,c);for(var w=[],k=0,A=c,_=c-1;_>=0;--_){t[2*_]=(t[2*_]-u)*m,t[2*_+1]=(t[2*_+1]-f)*y;var M=x[_];M!==k&&(w.push(new i(b*Math.pow(.5,M),_+1,A-(_+1))),A=_+1,k=M)}return w.push(new i(b*Math.pow(.5,M+1),0,A)),o.free(x),w}var o=t("typedarray-pool"),s=t("./lib/sort");e.exports=a},{"./lib/sort":157,"typedarray-pool":282}],159:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.weightBuffer=n,this.shader=i,this.pickShader=a,this.scales=[],this.size=12,this.borderSize=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.pickOffset=0,this.points=null,this.xCoords=null}function i(t,e){var r=t.gl,i=o(r),s=o(r),l=o(r),c=a(r,u.pointVertex,u.pointFragment),f=a(r,u.pickVertex,u.pickFragment),h=new n(t,i,s,l,c,f);return h.update(e),t.addObject(h),h}var a=t("gl-shader"),o=t("gl-buffer"),s=t("binary-search-bounds"),l=t("snap-points-2d"),c=t("typedarray-pool"),u=t("./lib/shader");e.exports=i;var f=n.prototype;f.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.xCoords&&c.free(this.xCoords),this.plot.removeObject(this)},f.update=function(t){function e(e,r){return e in t?t[e]:r}t=t||{},this.size=e("size",12),this.color=e("color",[1,0,0,1]).slice(),this.borderSize=e("borderSize",1),this.borderColor=e("borderColor",[0,0,0,1]).slice(),this.xCoords&&c.free(this.xCoords);var r=t.positions,n=c.mallocFloat32(r.length),i=c.mallocInt32(r.length>>>1);n.set(r);var a=c.mallocFloat32(r.length);this.points=r,this.scales=l(n,i,a,this.bounds),this.offsetBuffer.update(n),this.pickBuffer.update(i),this.weightBuffer.update(a);for(var o=c.mallocFloat32(r.length>>>1),s=0,u=0;s>>1,this.pickOffset=0},f.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0,0,0];return function(r){var n=this.plot,i=this.pickShader,a=this.scales,o=this.offsetBuffer,l=this.pickBuffer,c=this.bounds,u=this.size,f=this.borderSize,h=n.gl,d=n.pickPixelRatio,p=n.viewBox,g=n.dataBox;if(0===this.pointCount)return r;var v=c[2]-c[0],m=c[3]-c[1],y=g[2]-g[0],b=g[3]-g[1],x=(p[2]-p[0])*d/n.pixelRatio,_=(p[3]-p[1])*d/n.pixelRatio,w=Math.min(y/x,b/_);t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(c[0]-g[0])/y-1,t[7]=2*(c[1]-g[1])/b-1,this.pickOffset=r,e[0]=255&r,e[1]=r>>8&255,e[2]=r>>16&255,e[3]=r>>24&255,i.bind(),i.uniforms.matrix=t,i.uniforms.color=this.color,i.uniforms.borderColor=this.borderColor,i.uniforms.pointSize=d*(u+f),i.uniforms.pickOffset=e,0===this.borderSize?i.uniforms.centerFraction=2:i.uniforms.centerFraction=u/(u+f+1.25),o.bind(),i.attributes.position.pointer(),l.bind(),i.attributes.pickId.pointer(h.UNSIGNED_BYTE);for(var k=this.xCoords,A=(g[0]-c[0]-w*u*d)/v,M=(g[2]-c[0]+w*u*d)/v,T=a.length-1;T>=0;--T){var E=a[T];if(!(E.pixelSize1)){var L=E.offset,S=E.count+L,C=s.ge(k,A,L,S-1),z=s.lt(k,M,C,S-1)+1;z>C&&h.drawArrays(h.POINTS,C,z-C)}}return r+this.pointCount}}(),f.draw=function(){var t=[1,0,0,0,1,0,0,0,1];return function(){var e=this.plot,r=this.shader,n=this.scales,i=this.offsetBuffer,a=this.bounds,o=this.size,l=this.borderSize,c=e.gl,u=e.pixelRatio,f=e.viewBox,h=e.dataBox;if(0!==this.pointCount){var d=a[2]-a[0],p=a[3]-a[1],g=h[2]-h[0],v=h[3]-h[1],m=f[2]-f[0],y=f[3]-f[1],b=Math.min(g/m,v/y);t[0]=2*d/g,t[4]=2*p/v,t[6]=2*(a[0]-h[0])/g-1,t[7]=2*(a[1]-h[1])/v-1,r.bind(),r.uniforms.matrix=t,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointSize=u*(o+l),r.uniforms.useWeight=1,0===this.borderSize?r.uniforms.centerFraction=2:r.uniforms.centerFraction=o/(o+l+1.25),i.bind(),r.attributes.position.pointer(),this.weightBuffer.bind(),r.attributes.weight.pointer();for(var x=this.xCoords,_=(h[0]-a[0]-b*o*u)/d,w=(h[2]-a[0]+b*o*u)/d,k=!0,A=n.length-1;A>=0;--A){var M=n[A];if(!(M.pixelSize1)){var T=M.offset,E=M.count+T,L=s.ge(x,_,T,E-1),S=s.lt(x,w,L,E-1)+1;S>L&&c.drawArrays(c.POINTS,L,S-L),k&&(k=!1,r.uniforms.useWeight=0)}}}}}(),f.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}}},{"./lib/shader":155,"binary-search-bounds":156,"gl-buffer":107,"gl-shader":166,"snap-points-2d":158,"typedarray-pool":282}],160:[function(t,e,r){"use strict";function n(t,e){var r=a[e];if(r||(r=a[e]={}),t in r)return r[t];for(var n=i(t,{textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),o=i(t,{triangles:!0,textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),s=[[1/0,1/0],[-(1/0),-(1/0)]],l=0;lu;++u)s[0][u]=Math.min(s[0][u],c[u]),s[1][u]=Math.max(s[1][u],c[u]);return r[t]=[o,n,s]}var i=t("vectorize-text");e.exports=n;var a={}},{"vectorize-text":285}],161:[function(t,e,r){function n(t,e){var r=i(t,e),n=r.attributes;return n.position.location=0,n.color.location=1,n.glyph.location=2,n.id.location=3,r}var i=t("gl-shader"),a="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1])) ) {\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}",o="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || any(greaterThan(position, clipBounds[1]))) {\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}",s="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) ||\n any(greaterThan(position, clipBounds[1])) ) {\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",l="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if(any(lessThan(dataCoordinate, fragClipBounds[0])) ||\n any(greaterThan(dataCoordinate, fragClipBounds[1])) ) {\n discard;\n } else {\n gl_FragColor = interpColor * opacity;\n }\n}\n",c="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if(any(lessThan(dataCoordinate, fragClipBounds[0])) || \n any(greaterThan(dataCoordinate, fragClipBounds[1])) ) {\n discard;\n } else {\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n }\n}",u=[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"glyph",type:"vec2"},{name:"id",type:"vec4"}],f={vertex:a,fragment:l,attributes:u},h={vertex:o,fragment:l,attributes:u},d={vertex:s,fragment:l,attributes:u},p={vertex:a,fragment:c,attributes:u},g={vertex:o,fragment:c,attributes:u},v={vertex:s,fragment:c,attributes:u};r.createPerspective=function(t){return n(t,f)},r.createOrtho=function(t){return n(t,h)},r.createProject=function(t){return n(t,d)},r.createPickPerspective=function(t){return n(t,p)},r.createPickOrtho=function(t){return n(t,g)},r.createPickProject=function(t){return n(t,v)}},{"gl-shader":166}],162:[function(t,e,r){"use strict";function n(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];return t[0]=e[0]*r+e[4]*n+e[8]*i+e[12]*a,t[1]=e[1]*r+e[5]*n+e[9]*i+e[13]*a,t[2]=e[2]*r+e[6]*n+e[10]*i+e[14]*a,t[3]=e[3]*r+e[7]*n+e[11]*i+e[15]*a,t}function i(t,e,r,i){return n(i,i,r),n(i,i,e),n(i,i,t)}function a(t,e){this.index=t,this.dataCoordinate=this.position=e}function o(t,e,r,n,i,o,s,l,c,u,f,h){this.gl=t,this.pixelRatio=1,this.shader=e,this.orthoShader=r,this.projectShader=n,this.pointBuffer=i,this.colorBuffer=o,this.glyphBuffer=s,this.idBuffer=l,this.vao=c,this.vertexCount=0,this.lineVertexCount=0,this.opacity=1,this.lineWidth=0,this.projectScale=[2/3,2/3,2/3],this.projectOpacity=[1,1,1],this.pickId=0,this.pickPerspectiveShader=u,this.pickOrthoShader=f,this.pickProjectShader=h,this.points=[],this._selectResult=new a(0,[0,0,0]),this.useOrtho=!0,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.axesProject=[!0,!0,!0],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.highlightId=[1,1,1,1],this.highlightScale=2,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.dirty=!0}function s(t){return t[0]=t[1]=t[2]=0,t}function l(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t}function c(t,e,r,n){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[r]=n,t}function u(t){for(var e=S,r=0;2>r;++r)for(var n=0;3>n;++n)e[r][n]=Math.max(Math.min(t[r][n],1e8),-1e8);return e}function f(t,e,r,n,a){var o,f=e.axesProject,h=e.gl,d=t.uniforms,p=r.model||x,g=r.view||x,v=r.projection||x,y=e.axesBounds,b=u(e.clipBounds);o=e.axes?e.axes.lastCubeProps.axis:[1,1,1],w[0]=2/h.drawingBufferWidth,w[1]=2/h.drawingBufferHeight,t.bind(),d.view=g,d.projection=v,d.screenSize=w,d.highlightId=e.highlightId,d.highlightScale=e.highlightScale,d.clipBounds=b,d.pickGroup=e.pickId/255,d.pixelRatio=e.pixelRatio;for(var _=0;3>_;++_)if(f[_]&&e.projectOpacity[_]<1===n){d.scale=e.projectScale[_],d.opacity=e.projectOpacity[_];for(var S=E,C=0;16>C;++C)S[C]=0;for(var C=0;4>C;++C)S[5*C]=1;S[5*_]=0,o[_]<0?S[12+_]=y[0][_]:S[12+_]=y[1][_],m(S,p,S),d.model=S;var z=(_+1)%3,P=(_+2)%3,R=s(k),O=s(A);R[z]=1,O[P]=1;var I=i(v,g,p,l(M,R)),N=i(v,g,p,l(T,O));if(Math.abs(I[1])>Math.abs(N[1])){var j=I;I=N,N=j,j=R,R=O,O=j;var F=z;z=P,P=F}I[0]<0&&(R[z]=-1),N[1]>0&&(O[P]=-1);for(var B=0,D=0,C=0;4>C;++C)B+=Math.pow(p[4*z+C],2), -D+=Math.pow(p[4*P+C],2);R[z]/=Math.sqrt(B),O[P]/=Math.sqrt(D),d.axes[0]=R,d.axes[1]=O,d.fragClipBounds[0]=c(L,b[0],_,-1e8),d.fragClipBounds[1]=c(L,b[1],_,1e8),e.vao.draw(h.TRIANGLES,e.vertexCount),e.lineWidth>0&&(h.lineWidth(e.lineWidth),e.vao.draw(h.LINES,e.lineVertexCount,e.vertexCount))}}function h(t,e,r,n,i,a){var o=r.gl;if(r.vao.bind(),i===r.opacity<1||a){t.bind();var s=t.uniforms;s.model=n.model||x,s.view=n.view||x,s.projection=n.projection||x,w[0]=2/o.drawingBufferWidth,w[1]=2/o.drawingBufferHeight,s.screenSize=w,s.highlightId=r.highlightId,s.highlightScale=r.highlightScale,s.fragClipBounds=P,s.clipBounds=r.axes.bounds,s.opacity=r.opacity,s.pickGroup=r.pickId/255,s.pixelRatio=r.pixelRatio,r.vao.draw(o.TRIANGLES,r.vertexCount),r.lineWidth>0&&(o.lineWidth(r.lineWidth),r.vao.draw(o.LINES,r.lineVertexCount,r.vertexCount))}f(e,r,n,i,a),r.vao.unbind()}function d(t){var e=t.gl,r=y.createPerspective(e),n=y.createOrtho(e),i=y.createProject(e),a=y.createPickPerspective(e),s=y.createPickOrtho(e),l=y.createPickProject(e),c=p(e),u=p(e),f=p(e),h=p(e),d=g(e,[{buffer:c,size:3,type:e.FLOAT},{buffer:u,size:4,type:e.FLOAT},{buffer:f,size:2,type:e.FLOAT},{buffer:h,size:4,type:e.UNSIGNED_BYTE,normalized:!0}]),v=new o(e,r,n,i,c,u,f,h,d,a,s,l);return v.update(t),v}var p=t("gl-buffer"),g=t("gl-vao"),v=t("typedarray-pool"),m=t("gl-mat4/multiply"),y=t("./lib/shaders"),b=t("./lib/glyphs"),x=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];e.exports=d;var _=o.prototype;_.pickSlots=1,_.setPickBase=function(t){this.pickId=t},_.isTransparent=function(){if(this.opacity<1)return!0;for(var t=0;3>t;++t)if(this.axesProject[t]&&this.projectOpacity[t]<1)return!0;return!1},_.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;3>t;++t)if(this.axesProject[t]&&this.projectOpacity[t]>=1)return!0;return!1};var w=[0,0],k=[0,0,0],A=[0,0,0],M=[0,0,0,1],T=[0,0,0,1],E=x.slice(),L=[0,0,0],S=[[0,0,0],[0,0,0]],C=[-1e8,-1e8,-1e8],z=[1e8,1e8,1e8],P=[C,z];_.draw=function(t){var e=this.useOrtho?this.orthoShader:this.shader;h(e,this.projectShader,this,t,!1,!1)},_.drawTransparent=function(t){var e=this.useOrtho?this.orthoShader:this.shader;h(e,this.projectShader,this,t,!0,!1)},_.drawPick=function(t){var e=this.useOrtho?this.pickOrthoShader:this.pickPerspectiveShader;h(e,this.pickProjectShader,this,t,!1,!0)},_.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[2]+(t.value[1]<<8)+(t.value[0]<<16);if(e>=this.pointCount||0>e)return null;var r=this.points[e],n=this._selectResult;n.index=e;for(var i=0;3>i;++i)n.position[i]=n.dataCoordinate[i]=r[i];return n},_.highlight=function(t){if(t){var e=t.index,r=255&e,n=e>>8&255,i=e>>16&255;this.highlightId=[r/255,n/255,i/255,0]}else this.highlightId=[1,1,1,1]},_.update=function(t){if(t=t||{},"perspective"in t&&(this.useOrtho=!t.perspective),"orthographic"in t&&(this.useOrtho=!!t.orthographic),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"project"in t)if(Array.isArray(t.project))this.axesProject=t.project;else{var e=!!t.project;this.axesProject=[e,e,e]}if("projectScale"in t)if(Array.isArray(t.projectScale))this.projectScale=t.projectScale.slice();else{var r=+t.projectScale;this.projectScale=[r,r,r]}if("projectOpacity"in t)if(Array.isArray(t.projectOpacity))this.projectOpacity=t.projectOpacity.slice();else{var r=+t.projectOpacity;this.projectOpacity=[r,r,r]}"opacity"in t&&(this.opacity=t.opacity),this.dirty=!0;var n=t.position;if(n){var i=t.font||"normal",a=t.alignment||[0,0],o=[1/0,1/0,1/0],s=[-(1/0),-(1/0),-(1/0)],l=t.glyph,c=t.color,u=t.size,f=t.angle,h=t.lineColor,d=0,p=0,g=0,m=n.length;t:for(var y=0;m>y;++y){for(var x=n[y],_=0;3>_;++_)if(isNaN(x[_])||!isFinite(x[_]))continue t;var w;w=Array.isArray(l)?b(l[y],i):l?b(l,i):b("\u25cf",i);var k=w[0],A=w[1],M=w[2];p+=3*k.cells.length,g+=2*A.edges.length}var T=p+g,E=v.mallocFloat(3*T),L=v.mallocFloat(4*T),S=v.mallocFloat(2*T),C=v.mallocUint32(T),z=[0,a[1]],P=0,R=p,O=[0,0,0,1],I=[0,0,0,1],N=Array.isArray(c)&&Array.isArray(c[0]),j=Array.isArray(h)&&Array.isArray(h[0]);t:for(var y=0;m>y;++y){for(var x=n[y],_=0;3>_;++_){if(isNaN(x[_])||!isFinite(x[_])){d+=1;continue t}s[_]=Math.max(s[_],x[_]),o[_]=Math.min(o[_],x[_])}var w;w=Array.isArray(l)?b(l[y],i):l?b(l,i):b("\u25cf",i);var k=w[0],A=w[1],M=w[2];if(Array.isArray(c)){var F;if(F=N?c[y]:c,3===F.length){for(var _=0;3>_;++_)O[_]=F[_];O[3]=1}else if(4===F.length)for(var _=0;4>_;++_)O[_]=F[_]}else O[0]=O[1]=O[2]=0,O[3]=1;if(Array.isArray(h)){var F;if(F=j?h[y]:h,3===F.length){for(var _=0;3>_;++_)I[_]=F[_];I[_]=1}else if(4===F.length)for(var _=0;4>_;++_)I[_]=F[_]}else I[0]=I[1]=I[2]=0,I[3]=1;var B=.5;Array.isArray(u)?B=+u[y]:u?B=+u:this.useOrtho&&(B=12);var D=0;Array.isArray(f)?D=+f[y]:f&&(D=+f);for(var U=Math.cos(D),V=Math.sin(D),x=n[y],_=0;3>_;++_)s[_]=Math.max(s[_],x[_]),o[_]=Math.min(o[_],x[_]);a[0]<0?z[0]=a[0]*(1+M[1][0]):a[0]>0&&(z[0]=-a[0]*(1+M[0][0]));for(var q=k.cells,H=k.positions,_=0;_Y;++Y){for(var X=0;3>X;++X)E[3*P+X]=x[X];for(var X=0;4>X;++X)L[4*P+X]=O[X];C[P]=d;var W=H[G[Y]];S[2*P]=B*(U*W[0]-V*W[1]+z[0]),S[2*P+1]=B*(V*W[0]+U*W[1]+z[1]),P+=1}for(var q=A.edges,H=A.positions,_=0;_Y;++Y){for(var X=0;3>X;++X)E[3*R+X]=x[X];for(var X=0;4>X;++X)L[4*R+X]=I[X];C[R]=d;var W=H[G[Y]];S[2*R]=B*(U*W[0]-V*W[1]+z[0]),S[2*R+1]=B*(V*W[0]+U*W[1]+z[1]),R+=1}d+=1}this.vertexCount=p,this.lineVertexCount=g,this.pointBuffer.update(E),this.colorBuffer.update(L),this.glyphBuffer.update(S),this.idBuffer.update(new Uint32Array(C)),v.free(E),v.free(L),v.free(S),v.free(C),this.bounds=[o,s],this.points=n,this.pointCount=n.length}},_.dispose=function(){this.shader.dispose(),this.orthoShader.dispose(),this.pickPerspectiveShader.dispose(),this.pickOrthoShader.dispose(),this.vao.dispose(),this.pointBuffer.dispose(),this.colorBuffer.dispose(),this.glyphBuffer.dispose(),this.idBuffer.dispose()}},{"./lib/glyphs":160,"./lib/shaders":161,"gl-buffer":107,"gl-mat4/multiply":130,"gl-vao":182,"typedarray-pool":282}],163:[function(t,e,r){"use strict";r.boxVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n",r.boxFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"},{}],164:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.boxBuffer=e,this.boxShader=r,this.enabled=!0,this.selectBox=[1/0,1/0,-(1/0),-(1/0)],this.borderColor=[0,0,0,1],this.innerFill=!1,this.innerColor=[0,0,0,.25],this.outerFill=!0,this.outerColor=[0,0,0,.5],this.borderWidth=10}function i(t,e){var r=t.gl,i=o(r,[0,0,0,1,1,0,1,1]),l=a(r,s.boxVertex,s.boxFragment),c=new n(t,i,l);return c.update(e),t.addOverlay(c),c}var a=t("gl-shader"),o=t("gl-buffer"),s=t("./lib/shaders");e.exports=i;var l=n.prototype;l.draw=function(){if(this.enabled){var t=this.plot,e=this.selectBox,r=this.borderWidth,n=(this.innerFill,this.innerColor),i=(this.outerFill,this.outerColor),a=this.borderColor,o=t.box,s=t.screenBox,l=t.dataBox,c=t.viewBox,u=t.pixelRatio,f=(e[0]-l[0])*(c[2]-c[0])/(l[2]-l[0])+c[0],h=(e[1]-l[1])*(c[3]-c[1])/(l[3]-l[1])+c[1],d=(e[2]-l[0])*(c[2]-c[0])/(l[2]-l[0])+c[0],p=(e[3]-l[1])*(c[3]-c[1])/(l[3]-l[1])+c[1];if(f=Math.max(f,c[0]),h=Math.max(h,c[1]),d=Math.min(d,c[2]),p=Math.min(p,c[3]),!(f>d||h>p)){o.bind();var g=s[2]-s[0],v=s[3]-s[1];if(this.outerFill&&(o.drawBox(0,0,g,h,i),o.drawBox(0,h,f,p,i),o.drawBox(0,p,g,v,i),o.drawBox(d,h,g,p,i)),this.innerFill&&o.drawBox(f,h,d,p,n),r>0){var m=r*u;o.drawBox(f-m,h-m,d+m,h+m,a),o.drawBox(f-m,p-m,d+m,p+m,a),o.drawBox(f-m,h-m,f+m,p+m,a),o.drawBox(d-m,h-m,d+m,p+m,a)}}}},l.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},l.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":163,"gl-buffer":107,"gl-shader":166}],165:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.coord=[t,e],this.id=r,this.value=n,this.distance=i}function i(t,e,r){this.gl=t,this.fbo=e,this.buffer=r,this._readTimeout=null;var n=this;this._readCallback=function(){n.gl&&(e.bind(),t.readPixels(0,0,e.shape[0],e.shape[1],t.RGBA,t.UNSIGNED_BYTE,n.buffer),n._readTimeout=null)}}function a(t,e){var r=o(t,e),n=s.mallocUint8(e[0]*e[1]*4);return new i(t,r,n)}e.exports=a;var o=t("gl-fbo"),s=t("typedarray-pool"),l=t("ndarray"),c=t("bit-twiddle").nextPow2,u=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(255>_inline_34_arg0_||255>_inline_34_arg1_||255>_inline_34_arg2_||255>_inline_34_arg3_){var _inline_34_l=_inline_34_arg4_-_inline_34_arg6_[0],_inline_34_a=_inline_34_arg5_-_inline_34_arg6_[1],_inline_34_f=_inline_34_l*_inline_34_l+_inline_34_a*_inline_34_a;_inline_34_fthis.buffer.length){s.free(this.buffer);for(var n=this.buffer=s.mallocUint8(c(r*e*4)),i=0;r*e*4>i;++i)n[i]=255}return t}}}),f.begin=function(){var t=this.gl;this.shape;t&&(this.fbo.bind(),t.clearColor(1,1,1,1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT))},f.end=function(){var t=this.gl;t&&(t.bindFramebuffer(t.FRAMEBUFFER,null),this._readTimeout||clearTimeout(this._readTimeout),this._readTimeout=setTimeout(this._readCallback,1))},f.query=function(t,e,r){if(!this.gl)return null;var i=this.fbo.shape.slice();t=0|t,e=0|e,"number"!=typeof r&&(r=1);var a=0|Math.min(Math.max(t-r,0),i[0]),o=0|Math.min(Math.max(t+r,0),i[0]),s=0|Math.min(Math.max(e-r,0),i[1]),c=0|Math.min(Math.max(e+r,0),i[1]);if(a>=o||s>=c)return null;var f=[o-a,c-s],h=l(this.buffer,[f[0],f[1],4],[4,4*i[0],1],4*(a+i[0]*s)),d=u(h.hi(f[0],f[1],1),r,r),p=d[0],g=d[1];if(0>p||Math.pow(this.radius,2)=0){for(var A=0|k.type.charAt(k.type.length-1),M=new Array(A),T=0;A>T;++T)M[T]=_.length,x.push(k.name+"["+T+"]"),"number"==typeof k.location?_.push(k.location+T):Array.isArray(k.location)&&k.location.length===A&&"number"==typeof k.location[T]?_.push(0|k.location[T]):_.push(-1);b.push({name:k.name,type:k.type,locations:M})}else b.push({name:k.name,type:k.type,locations:[_.length]}),x.push(k.name),"number"==typeof k.location?_.push(0|k.location):_.push(-1)}for(var E=0,w=0;w<_.length;++w)if(_[w]<0){for(;_.indexOf(E)>=0;)E+=1;_[w]=E}var L=new Array(r.length);a(),d._relink=a,d.types={uniforms:l(r),attributes:l(n)},d.attributes=s(p,d,b,_),Object.defineProperty(d,"uniforms",o(p,d,r,L))},e.exports=a},{"./lib/GLError":167,"./lib/create-attributes":168,"./lib/create-uniforms":169,"./lib/reflect":170,"./lib/runtime-reflect":171,"./lib/shader-cache":172}],167:[function(t,e,r){function n(t,e,r){this.shortMessage=e||"",this.longMessage=r||"",this.rawError=t||"",this.message="gl-shader: "+(e||t||"")+(r?"\n"+r:""),this.stack=(new Error).stack}n.prototype=new Error,n.prototype.name="GLError",n.prototype.constructor=n,e.exports=n},{}],168:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}function i(t,e,r,i,a,o,s){for(var l=["gl","v"],c=[],u=0;a>u;++u)l.push("x"+u),c.push("x"+u);l.push("if(x0.length===void 0){return gl.vertexAttrib"+a+"f(v,"+c.join()+")}else{return gl.vertexAttrib"+a+"fv(v,x0)}");var f=Function.apply(null,l),h=new n(t,e,r,i,a,f);Object.defineProperty(o,s,{set:function(e){return t.disableVertexAttribArray(i[r]),f(t,i[r],e),e},get:function(){return h},enumerable:!0})}function a(t,e,r,n,a,o,s){for(var l=new Array(a),c=new Array(a),u=0;a>u;++u)i(t,e,r[u],n,a,l,u),c[u]=l[u];Object.defineProperty(l,"location",{set:function(t){if(Array.isArray(t))for(var e=0;a>e;++e)c[e].location=t[e];else for(var e=0;a>e;++e)c[e].location=t+e;return t},get:function(){for(var t=new Array(a),e=0;a>e;++e)t[e]=n[r[e]];return t},enumerable:!0}),l.pointer=function(e,i,o,s){e=e||t.FLOAT,i=!!i,o=o||a*a,s=s||0;for(var l=0;a>l;++l){var c=n[r[l]];t.vertexAttribPointer(c,a,e,i,o,s+l*a),t.enableVertexAttribArray(c)}};var f=new Array(a),h=t["vertexAttrib"+a+"fv"];Object.defineProperty(o,s,{set:function(e){for(var i=0;a>i;++i){var o=n[r[i]];if(t.disableVertexAttribArray(o),Array.isArray(e[0]))h.call(t,o,e[i]);else{for(var s=0;a>s;++s)f[s]=e[a*i+s];h.call(t,o,f)}}return e},get:function(){return l},enumerable:!0})}function o(t,e,r,n){for(var o={},l=0,c=r.length;c>l;++l){var u=r[l],f=u.name,h=u.type,d=u.locations;switch(h){case"bool":case"int":case"float":i(t,e,d[0],n,1,o,f);break;default:if(h.indexOf("vec")>=0){var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);i(t,e,d[0],n,p,o,f)}else{if(!(h.indexOf("mat")>=0))throw new s("","Unknown data type for attribute "+f+": "+h);var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);a(t,e,d,n,p,o,f)}}}return o}e.exports=o;var s=t("./GLError"),l=n.prototype;l.pointer=function(t,e,r,n){var i=this,a=i._gl,o=i._locations[i._index];a.vertexAttribPointer(o,i._dimension,t||a.FLOAT,!!e,r||0,n||0),a.enableVertexAttribArray(o)},l.set=function(t,e,r,n){return this._constFunc(this._locations[this._index],t,e,r,n)},Object.defineProperty(l,"location",{get:function(){return this._locations[this._index]},set:function(t){return t!==this._locations[this._index]&&(this._locations[this._index]=0|t,this._wrapper.program=null),0|t}})},{"./GLError":167}],169:[function(t,e,r){"use strict";function n(t){var e=new Function("y","return function(){return y}");return e(t)}function i(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e,r,a){function l(r){var n=new Function("gl","wrapper","locations","return function(){return gl.getUniform(wrapper.program,locations["+r+"])}");return n(t,e,a)}function c(t,e,r){switch(r){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+e+"],obj"+t+")";case"float":return"gl.uniform1f(locations["+e+"],obj"+t+")";default:var n=r.indexOf("vec");if(!(n>=0&&1>=n&&r.length===4+n)){if(0===r.indexOf("mat")&&4===r.length){var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+i+"fv(locations["+e+"],false,obj"+t+")"}throw new s("","Unknown uniform data type for "+name+": "+r)}var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+i+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+i+"fv(locations["+e+"],obj"+t+")";default:throw new s("","Unrecognized data type for vector "+name+": "+r)}}}function u(t,e){if("object"!=typeof e)return[[t,e]];var r=[];for(var n in e){var i=e[n],a=t;a+=parseInt(n)+""===n?"["+n+"]":"."+n,"object"==typeof i?r.push.apply(r,u(a,i)):r.push([a,i])}return r}function f(e){for(var n=["return function updateProperty(obj){"],i=u("",e),o=0;o=0&&1>=e&&t.length===4+e){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid data type");return"b"===t.charAt(0)?i(r,!1):i(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+t);return i(r*r,0)}throw new s("","Unknown uniform data type for "+name+": "+t)}}function d(t,e,i){if("object"==typeof i){var o=p(i);Object.defineProperty(t,e,{get:n(o),set:f(i),enumerable:!0,configurable:!1})}else a[i]?Object.defineProperty(t,e,{get:l(i),set:f(i),enumerable:!0,configurable:!1}):t[e]=h(r[i].type)}function p(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var c=1;ca;++a){var o=t.getActiveUniform(e,a);if(o){var s=n(t,o.type);if(o.size>1)for(var l=0;la;++a){var o=t.getActiveAttrib(e,a);o&&i.push({name:o.name,type:n(t,o.type)})}return i}r.uniforms=i,r.attributes=a;var o={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"},s=null},{}],172:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.id=t,this.src=e,this.type=r,this.shader=n,this.count=a,this.programs=[],this.cache=o}function i(t){this.gl=t,this.shaders=[{},{}],this.programs={}}function a(t,e,r){var n=t.createShader(e);if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){var i=t.getShaderInfoLog(n);try{var a=f(i,r,e)}catch(o){throw console.warn("Failed to format compiler error: "+o),new u(i,"Error compiling shader:\n"+i)}throw new u(i,a.short,a.long)}return n}function o(t,e,r,n,i){var a=t.createProgram();t.attachShader(a,e),t.attachShader(a,r);for(var o=0;on;++n){var a=t.programs[r[n]];a&&(delete t.programs[n],e.deleteProgram(a))}e.deleteShader(this.shader),delete t.shaders[this.type===e.FRAGMENT_SHADER|0][this.src]}};var g=i.prototype;g.getShaderReference=function(t,e){var r=this.gl,i=this.shaders[t===r.FRAGMENT_SHADER|0],o=i[e];if(o&&r.isShader(o.shader))o.count+=1;else{var s=a(r,t,e);o=i[e]=new n(p++,e,t,s,[],1,this)}return o},g.getProgram=function(t,e,r,n){var i=[t.id,e.id,r.join(":"),n.join(":")].join("@"),a=this.programs[i];return a&&this.gl.isProgram(a)||(this.programs[i]=a=o(this.gl,t.shader,e.shader,r,n),t.programs.push(i),e.programs.push(i)),a}},{"./GLError":167,"gl-format-compiler-error":115,"weakmap-shim":290}],173:[function(t,e,r){"use strict";function n(t){this.plot=t,this.enable=[!0,!0,!1,!1],this.width=[1,1,1,1],this.color=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.center=[1/0,1/0]}function i(t,e){var r=new n(t);return r.update(e),t.addOverlay(r),r}e.exports=i;var a=n.prototype;a.update=function(t){t=t||{},this.enable=(t.enable||[!0,!0,!1,!1]).slice(),this.width=(t.width||[1,1,1,1]).slice(),this.color=(t.color||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]).map(function(t){return t.slice()}),this.center=(t.center||[1/0,1/0]).slice(),this.plot.setOverlayDirty()},a.draw=function(){var t=this.enable,e=this.width,r=this.color,n=this.center,i=this.plot,a=i.line,o=i.dataBox,s=i.viewBox;if(a.bind(),o[0]<=n[0]&&n[0]<=o[2]&&o[1]<=n[1]&&n[1]<=o[3]){var l=s[0]+(n[0]-o[0])/(o[2]-o[0])*(s[2]-s[0]),c=s[1]+(n[1]-o[1])/(o[3]-o[1])*(s[3]-s[1]);t[0]&&a.drawLine(l,c,s[0],c,e[0],r[0]),t[1]&&a.drawLine(l,c,l,s[1],e[1],r[1]),t[2]&&a.drawLine(l,c,s[2],c,e[2],r[2]),t[3]&&a.drawLine(l,c,l,s[3],e[3],r[3])}},a.dispose=function(){this.plot.removeOverlay(this)}},{}],174:[function(t,e,r){"use strict";var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, color;\nattribute float weight;\n\nuniform mat4 model, view, projection;\nuniform vec3 coordinates[3];\nuniform vec4 colors[3];\nuniform vec2 screenShape;\nuniform float lineWidth;\n\nvarying vec4 fragColor;\n\nvoid main() {\n vec3 vertexPosition = mix(coordinates[0],\n mix(coordinates[2], coordinates[1], 0.5 * (position + 1.0)), abs(position));\n\n vec4 clipPos = projection * view * model * vec4(vertexPosition, 1.0);\n vec2 clipOffset = (projection * view * model * vec4(color, 0.0)).xy;\n vec2 delta = weight * clipOffset * screenShape;\n vec2 lineOffset = normalize(vec2(delta.y, -delta.x)) / screenShape;\n\n gl_Position = vec4(clipPos.xy + clipPos.w * 0.5 * lineWidth * lineOffset, clipPos.z, clipPos.w);\n fragColor = color.x * colors[0] + color.y * colors[1] + color.z * colors[2];\n}\n",a="precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}";e.exports=function(t){return n(t,i,a,null,[{name:"position",type:"vec3"},{name:"color",type:"vec3"},{name:"weight",type:"float"}])}},{"gl-shader":166}],175:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n,this.pixelRatio=1,this.bounds=[[-1e3,-1e3,-1e3],[1e3,1e3,1e3]],this.position=[0,0,0],this.lineWidth=[2,2,2],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.enabled=[!0,!0,!0],this.drawSides=[!0,!0,!0],this.axes=null}function i(t,e){function r(t,e,r,n,a,o){var s=[t,e,r,0,0,0,1];s[n+3]=1,s[n]=a,i.push.apply(i,s),s[6]=-1,i.push.apply(i,s),s[n]=o,i.push.apply(i,s),i.push.apply(i,s),s[6]=1,i.push.apply(i,s),s[n]=a,i.push.apply(i,s)}var i=[];r(0,0,0,0,0,1),r(0,0,0,1,0,1),r(0,0,0,2,0,1),r(1,0,0,1,-1,1),r(1,0,0,2,-1,1),r(0,1,0,0,-1,1),r(0,1,0,2,-1,1),r(0,0,1,0,-1,1),r(0,0,1,1,-1,1);var l=a(t,i),c=o(t,[{type:t.FLOAT,buffer:l,size:3,offset:0,stride:28},{type:t.FLOAT,buffer:l,size:3,offset:12,stride:28},{type:t.FLOAT,buffer:l,size:1,offset:24,stride:28}]),u=s(t);u.attributes.position.location=0,u.attributes.color.location=1,u.attributes.weight.location=2;var f=new n(t,l,c,u);return f.update(e),f}var a=t("gl-buffer"),o=t("gl-vao"),s=t("./shaders/index");e.exports=i;var l=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],c=n.prototype,u=[0,0,0],f=[0,0,0],h=[0,0];c.isTransparent=function(){return!1},c.drawTransparent=function(t){},c.draw=function(t){var e=this.gl,r=this.vao,n=this.shader;r.bind(),n.bind();var i,a=t.model||l,o=t.view||l,s=t.projection||l;this.axes&&(i=this.axes.lastCubeProps.axis);for(var c=u,d=f,p=0;3>p;++p)i&&i[p]<0?(c[p]=this.bounds[0][p],d[p]=this.bounds[1][p]):(c[p]=this.bounds[1][p],d[p]=this.bounds[0][p]);h[0]=e.drawingBufferWidth,h[1]=e.drawingBufferHeight,n.uniforms.model=a,n.uniforms.view=o,n.uniforms.projection=s,n.uniforms.coordinates=[this.position,c,d],n.uniforms.colors=this.colors,n.uniforms.screenShape=h;for(var p=0;3>p;++p)n.uniforms.lineWidth=this.lineWidth[p]*this.pixelRatio,this.enabled[p]&&(r.draw(e.TRIANGLES,6,6*p),this.drawSides[p]&&r.draw(e.TRIANGLES,12,18+12*p));r.unbind()},c.update=function(t){t&&("bounds"in t&&(this.bounds=t.bounds),"position"in t&&(this.position=t.position),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"colors"in t&&(this.colors=t.colors),"enabled"in t&&(this.enabled=t.enabled),"drawSides"in t&&(this.drawSides=t.drawSides))},c.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders/index":174,"gl-buffer":107,"gl-vao":182}],176:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute vec3 f;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 lightPosition, eyePosition;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n worldCoordinate = vec3(uv.zw, f.x);\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 //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",a="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(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\n\n\nfloat beckmannSpecular_1_1(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness) {\n return beckmannDistribution_2_0(dot(surfaceNormal, normalize(lightDirection + viewDirection)), roughness);\n}\n\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;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n if(kill > 0.0 ||\n any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n discard;\n }\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 = beckmannSpecular_1_1(L, V, N, roughness);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(colormap, vec2(value, value));\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",o="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\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",s="precision mediump float;\n#define GLSLIFY 1\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 any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n 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";r.createShader=function(t){var e=n(t,i,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createPickShader=function(t){var e=n(t,i,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0, -e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createContourShader=function(t){var e=n(t,o,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e},r.createPickContourShader=function(t){var e=n(t,o,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e}},{"gl-shader":166}],177:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.position=t,this.index=e,this.uv=r,this.level=n,this.dataCoordinate=i}function i(t){var e=x([y({colormap:t,nshades:N,format:"rgba"}).map(function(t){return[t[0],t[1],t[2],255*t[3]]})]);return b.divseq(e,255),e}function a(t,e,r,i,a,o,s,l,c,u,f,h,d,p){this.gl=t,this.shape=e,this.bounds=r,this.intensityBounds=[],this._shader=i,this._pickShader=a,this._coordinateBuffer=o,this._vao=s,this._colorMap=l,this._contourShader=c,this._contourPickShader=u,this._contourBuffer=f,this._contourVAO=h,this._contourOffsets=[[],[],[]],this._contourCounts=[[],[],[]],this._vertexCount=0,this._pickResult=new n([0,0,0],[0,0],[0,0],[0,0,0],[0,0,0]),this._dynamicBuffer=d,this._dynamicVAO=p,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=[[.5,.5,.5,1],[.5,.5,.5,1],[.5,.5,.5,1]],this.showContour=!0,this.showSurface=!0,this.enableHighlight=[!0,!0,!0],this.highlightColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.highlightTint=[1,1,1],this.highlightLevel=[-1,-1,-1],this.enableDynamic=[!0,!0,!0],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=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.surfaceProject=[!1,!1,!1],this.contourProject=[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],this.colorBounds=[!1,!1],this._field=[_(m.mallocFloat(1024),[0,0]),_(m.mallocFloat(1024),[0,0]),_(m.mallocFloat(1024),[0,0])],this.pickId=1,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.snapToData=!1,this.opacity=1,this.lightPosition=[10,1e4,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.dirty=!0}function o(t,e){var r,n,i,a=e.axes&&e.axes.lastCubeProps.axis||F,o=e.showSurface,s=e.showContour;for(r=0;3>r;++r)for(o=o||e.surfaceProject[r],n=0;3>n;++n)s=s||e.contourProject[r][n];for(r=0;3>r;++r){var l=B.projections[r];for(n=0;16>n;++n)l[n]=0;for(n=0;4>n;++n)l[5*n]=1;l[5*r]=0,l[12+r]=e.axesBounds[+(a[r]>0)][r],k(l,t.model,l);var c=B.clipBounds[r];for(i=0;2>i;++i)for(n=0;3>n;++n)c[i][n]=t.clipBounds[i][n];c[0][r]=-1e8,c[1][r]=1e8}return B.showSurface=o,B.showContour=s,B}function s(t,e){t=t||{};var r=this.gl;r.disable(r.CULL_FACE),this._colorMap.bind(0);var n=D;n.model=t.model||R,n.view=t.view||R,n.projection=t.projection||R,n.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]],n.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]],n.contourColor=this.contourColor[0],n.inverseModel=A(n.inverseModel,n.model);for(var i=0;2>i;++i)for(var a=n.clipBounds[i],s=0;3>s;++s)a[s]=Math.min(Math.max(this.clipBounds[i][s],-1e8),1e8);n.kambient=this.ambientLight,n.kdiffuse=this.diffuseLight,n.kspecular=this.specularLight,n.roughness=this.roughness,n.fresnel=this.fresnel,n.opacity=this.opacity,n.height=0,n.permutation=V;var l=U;for(k(l,n.view,n.model),k(l,n.projection,l),A(l,l),i=0;3>i;++i)n.eyePosition[i]=l[12+i]/l[15];var c=l[15];for(i=0;3>i;++i)c+=this.lightPosition[i]*l[4*i+3];for(i=0;3>i;++i){var u=l[12+i];for(s=0;3>s;++s)u+=l[4*s+i]*this.lightPosition[s];n.lightPosition[i]=u/c}var f=o(n,this);if(f.showSurface&&e===this.opacity<1){for(this._shader.bind(),this._shader.uniforms=n,this._vao.bind(),this.showSurface&&this._vertexCount&&this._vao.draw(r.TRIANGLES,this._vertexCount),i=0;3>i;++i)this.surfaceProject[i]&&this.vertexCount&&(this._shader.uniforms.model=f.projections[i],this._shader.uniforms.clipBounds=f.clipBounds[i],this._vao.draw(r.TRIANGLES,this._vertexCount));this._vao.unbind()}if(f.showContour&&!e){var h=this._contourShader;n.kambient=1,n.kdiffuse=0,n.kspecular=0,n.opacity=1,h.bind(),h.uniforms=n;var d=this._contourVAO;for(d.bind(),i=0;3>i;++i)for(h.uniforms.permutation=I[i],r.lineWidth(this.contourWidth[i]),s=0;si;++i)for(h.uniforms.model=f.projections[i],h.uniforms.clipBounds=f.clipBounds[i],s=0;3>s;++s)if(this.contourProject[i][s]){h.uniforms.permutation=I[s],r.lineWidth(this.contourWidth[s]);for(var p=0;pi;++i)if(0!==this._dynamicCounts[i])for(h.uniforms.model=n.model,h.uniforms.clipBounds=n.clipBounds,h.uniforms.permutation=I[i],r.lineWidth(this.dynamicWidth[i]),h.uniforms.contourColor=this.dynamicColor[i],h.uniforms.contourTint=this.dynamicTint[i],h.uniforms.height=this.dynamicLevel[i],d.draw(r.LINES,this._dynamicCounts[i],this._dynamicOffsets[i]),s=0;3>s;++s)this.contourProject[s][i]&&(h.uniforms.model=f.projections[s],h.uniforms.clipBounds=f.clipBounds[s],d.draw(r.LINES,this._dynamicCounts[i],this._dynamicOffsets[i]));d.unbind()}}function l(t,e){var r=e.shape.slice(),n=t.shape.slice();b.assign(t.lo(1,1).hi(r[0],r[1]),e),b.assign(t.lo(1).hi(r[0],1),e.hi(r[0],1)),b.assign(t.lo(1,n[1]-1).hi(r[0],1),e.lo(0,r[1]-1).hi(r[0],1)),b.assign(t.lo(0,1).hi(1,r[1]),e.hi(1)),b.assign(t.lo(n[0]-1,1).hi(1,r[1]),e.lo(r[0]-1)),t.set(0,0,e.get(0,0)),t.set(0,n[1]-1,e.get(0,r[1]-1)),t.set(n[0]-1,0,e.get(r[0]-1,0)),t.set(n[0]-1,n[1]-1,e.get(r[0]-1,r[1]-1))}function c(t,e){return Array.isArray(t)?[e(t[0]),e(t[1]),e(t[2])]:[e(t),e(t),e(t)]}function u(t){return Array.isArray(t)?3===t.length?[t[0],t[1],t[2],1]:[t[0],t[1],t[2],t[3]]:[0,0,0,1]}function f(t){if(Array.isArray(t)){if(Array.isArray(t))return[u(t[0]),u(t[1]),u(t[2])];var e=u(t);return[e.slice(),e.slice(),e.slice()]}}function h(t){var e=t.gl,r=L(e),n=C(e),i=S(e),o=z(e),s=p(e),l=g(e,[{buffer:s,size:4,stride:P,offset:0},{buffer:s,size:3,stride:P,offset:16},{buffer:s,size:3,stride:P,offset:28}]),c=p(e),u=g(e,[{buffer:c,size:4,stride:20,offset:0},{buffer:c,size:1,stride:20,offset:16}]),f=p(e),h=g(e,[{buffer:f,size:2,type:e.FLOAT}]),d=v(e,1,N,e.RGBA,e.UNSIGNED_BYTE);d.minFilter=e.LINEAR,d.magFilter=e.LINEAR;var m=new a(e,[0,0],[[0,0,0],[0,0,0]],r,n,s,l,d,i,o,c,u,f,h),y={levels:[[],[],[]]};for(var b in t)y[b]=t[b];return y.colormap=y.colormap||"jet",m.update(y),m}e.exports=h;var d=t("bit-twiddle"),p=t("gl-buffer"),g=t("gl-vao"),v=t("gl-texture2d"),m=t("typedarray-pool"),y=t("colormap"),b=t("ndarray-ops"),x=t("ndarray-pack"),_=t("ndarray"),w=t("surface-nets"),k=t("gl-mat4/multiply"),A=t("gl-mat4/invert"),M=t("binary-search-bounds"),T=t("ndarray-gradient"),E=t("./lib/shaders"),L=E.createShader,S=E.createContourShader,C=E.createPickShader,z=E.createPickContourShader,P=40,R=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],O=[[0,0],[0,1],[1,0],[1,1],[1,0],[0,1]],I=[[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 t=0;3>t;++t){var e=I[t],r=(t+1)%3,n=(t+2)%3;e[r+0]=1,e[n+3]=1,e[t+6]=1}}();var N=265,j=a.prototype;j.isTransparent=function(){return this.opacity<1},j.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;3>t;++t)if(this._contourCounts[t].length>0||this._dynamicCounts[t]>0)return!0;return!1},j.pickSlots=1,j.setPickBase=function(t){this.pickId=t};var F=[0,0,0],B={showSurface:!1,showContour:!1,projections:[R.slice(),R.slice(),R.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]},D={model:R,view:R,projection:R,inverseModel:R.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1e3,1e3,1e3],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1},U=R.slice(),V=[1,0,0,0,1,0,0,0,1];j.draw=function(t){return s.call(this,t,!1)},j.drawTransparent=function(t){return s.call(this,t,!0)};var q={model:R,view:R,projection:R,inverseModel:R,clipBounds:[[0,0,0],[0,0,0]],height:0,shape:[0,0],pickId:0,lowerBound:[0,0,0],upperBound:[0,0,0],zOffset:0,permutation:[1,0,0,0,1,0,0,0,1],lightPosition:[0,0,0],eyePosition:[0,0,0]};j.drawPick=function(t){t=t||{};var e=this.gl;e.disable(e.CULL_FACE);var r=q;r.model=t.model||R,r.view=t.view||R,r.projection=t.projection||R,r.shape=this._field[2].shape,r.pickId=this.pickId/255,r.lowerBound=this.bounds[0],r.upperBound=this.bounds[1],r.permutation=V;for(var n=0;2>n;++n)for(var i=r.clipBounds[n],a=0;3>a;++a)i[a]=Math.min(Math.max(this.clipBounds[n][a],-1e8),1e8);var s=o(r,this);if(s.showSurface){for(this._pickShader.bind(),this._pickShader.uniforms=r,this._vao.bind(),this._vao.draw(e.TRIANGLES,this._vertexCount),n=0;3>n;++n)this.surfaceProject[n]&&(this._pickShader.uniforms.model=s.projections[n],this._pickShader.uniforms.clipBounds=s.clipBounds[n],this._vao.draw(e.TRIANGLES,this._vertexCount));this._vao.unbind()}if(s.showContour){var l=this._contourPickShader;l.bind(),l.uniforms=r;var c=this._contourVAO;for(c.bind(),a=0;3>a;++a)for(e.lineWidth(this.contourWidth[a]),l.uniforms.permutation=I[a],n=0;nn;++n)for(l.uniforms.model=s.projections[n],l.uniforms.clipBounds=s.clipBounds[n],a=0;3>a;++a)if(this.contourProject[n][a]){l.uniforms.permutation=I[a],e.lineWidth(this.contourWidth[a]);for(var u=0;u>4)/16)/255,i=Math.floor(n),a=n-i,o=e[1]*(t.value[1]+(15&t.value[2])/16)/255,s=Math.floor(o),l=o-s;i+=1,s+=1;var c=r.position;c[0]=c[1]=c[2]=0;for(var u=0;2>u;++u)for(var f=u?a:1-a,h=0;2>h;++h)for(var d=h?l:1-l,p=i+u,g=s+h,v=f*d,m=0;3>m;++m)c[m]+=this._field[m].get(p,g)*v;for(var y=this._pickResult.level,b=0;3>b;++b)if(y[b]=M.le(this.contourLevels[b],c[b]),y[b]<0)this.contourLevels[b].length>0&&(y[b]=0);else if(y[b]Math.abs(_-c[b])&&(y[b]+=1)}for(r.index[0]=.5>a?i:i+1,r.index[1]=.5>l?s:s+1,r.uv[0]=n/e[0],r.uv[1]=o/e[1],m=0;3>m;++m)r.dataCoordinate[m]=this._field[m].get(r.index[0],r.index[1]);return r},j.update=function(t){t=t||{},this.dirty=!0,"contourWidth"in t&&(this.contourWidth=c(t.contourWidth,Number)),"showContour"in t&&(this.showContour=c(t.showContour,Boolean)),"showSurface"in t&&(this.showSurface=!!t.showSurface),"contourTint"in t&&(this.contourTint=c(t.contourTint,Boolean)),"contourColor"in t&&(this.contourColor=f(t.contourColor)),"contourProject"in t&&(this.contourProject=c(t.contourProject,function(t){return c(t,Boolean)})),"surfaceProject"in t&&(this.surfaceProject=t.surfaceProject),"dynamicColor"in t&&(this.dynamicColor=f(t.dynamicColor)),"dynamicTint"in t&&(this.dynamicTint=c(t.dynamicTint,Number)),"dynamicWidth"in t&&(this.dynamicWidth=c(t.dynamicWidth,Number)),"opacity"in t&&(this.opacity=t.opacity),"colorBounds"in t&&(this.colorBounds=t.colorBounds);var e=t.field||t.coords&&t.coords[2]||null,r=!1;if(e||(e=this._field[2].shape[0]||this._field[2].shape[2]?this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2):this._field[2].hi(0,0)),"field"in t||"coords"in t){var n=(e.shape[0]+2)*(e.shape[1]+2);n>this._field[2].data.length&&(m.freeFloat(this._field[2].data),this._field[2].data=m.mallocFloat(d.nextPow2(n))),this._field[2]=_(this._field[2].data,[e.shape[0]+2,e.shape[1]+2]),l(this._field[2],e),this.shape=e.shape.slice();for(var a=this.shape,o=0;2>o;++o)this._field[2].size>this._field[o].data.length&&(m.freeFloat(this._field[o].data),this._field[o].data=m.mallocFloat(this._field[2].size)),this._field[o]=_(this._field[o].data,[a[0]+2,a[1]+2]);if(t.coords){var s=t.coords;if(!Array.isArray(s)||3!==s.length)throw new Error("gl-surface: invalid coordinates for x/y");for(o=0;2>o;++o){var u=s[o];for(y=0;2>y;++y)if(u.shape[y]!==a[y])throw new Error("gl-surface: coords have incorrect shape");l(this._field[o],u)}}else if(t.ticks){var h=t.ticks;if(!Array.isArray(h)||2!==h.length)throw new Error("gl-surface: invalid ticks");for(o=0;2>o;++o){var p=h[o];if((Array.isArray(p)||p.length)&&(p=_(p)),p.shape[0]!==a[o])throw new Error("gl-surface: invalid tick length");var g=_(p.data,a);g.stride[o]=p.stride[0],g.stride[1^o]=0,l(this._field[o],g)}}else{for(o=0;2>o;++o){var v=[0,0];v[o]=1,this._field[o]=_(this._field[o].data,[a[0]+2,a[1]+2],v,0)}this._field[0].set(0,0,0);for(var y=0;yo;++o)T(x.pick(o),b[o],"mirror");var k=_(m.mallocFloat(3*b[2].size),[a[0]+2,a[1]+2,3]);for(o=0;oI?(I=Math.max(Math.abs(z),Math.abs(P),Math.abs(R)),1e-8>I?(R=1,P=z=0,I=1):I=1/I):I=1/Math.sqrt(I),k.set(o,y,0,z*I),k.set(o,y,1,P*I),k.set(o,y,2,R*I)}m.free(x.data);var N=[1/0,1/0,1/0],j=[-(1/0),-(1/0),-(1/0)],F=1/0,B=-(1/0),D=(a[0]-1)*(a[1]-1)*6,U=m.mallocFloat(d.nextPow2(10*D)),V=0,q=0;for(o=0;oH;++H)for(var G=0;2>G;++G)for(var Y=0;3>Y;++Y){var X=this._field[Y].get(1+o+H,1+y+G);if(isNaN(X)||!isFinite(X))continue t}for(Y=0;6>Y;++Y){var W=o+O[Y][0],Z=y+O[Y][1],K=this._field[0].get(W+1,Z+1),Q=this._field[1].get(W+1,Z+1);X=this._field[2].get(W+1,Z+1);var $=X;z=k.get(W+1,Z+1,0),P=k.get(W+1,Z+1,1),R=k.get(W+1,Z+1,2),t.intensity&&($=t.intensity.get(W,Z)),U[V++]=W,U[V++]=Z,U[V++]=K,U[V++]=Q,U[V++]=X,U[V++]=0,U[V++]=$,U[V++]=z,U[V++]=P,U[V++]=R,N[0]=Math.min(N[0],K),N[1]=Math.min(N[1],Q),N[2]=Math.min(N[2],X),F=Math.min(F,$),j[0]=Math.max(j[0],K),j[1]=Math.max(j[1],Q),j[2]=Math.max(j[2],X),B=Math.max(B,$),q+=1}}for(t.intensityBounds&&(F=+t.intensityBounds[0],B=+t.intensityBounds[1]),o=6;V>o;o+=10)U[o]=(U[o]-F)/(B-F);this._vertexCount=q,this._coordinateBuffer.update(U.subarray(0,V)),m.freeFloat(U),m.free(k.data),this.bounds=[N,j],this.intensity=t.intensity||this._field[2],this.intensityBounds[0]===F&&this.intensityBounds[1]===B||(r=!0),this.intensityBounds=[F,B]}if("levels"in t){var J=t.levels;for(J=Array.isArray(J[0])?J.slice():[[],[],J],o=0;3>o;++o)J[o]=J[o].slice(),J.sort(function(t,e){return t-e});t:for(o=0;3>o;++o){if(J[o].length!==this.contourLevels[o].length){r=!0;break}for(y=0;yet;++et){J=this.contourLevels[et];var rt=[],nt=[],it=[0,0,0];for(o=0;oY;++Y){var st=at.positions[ot[Y]],lt=st[0],ct=0|Math.floor(lt),ut=lt-ct,ft=st[1],ht=0|Math.floor(ft),dt=ft-ht,pt=!1;e:for(var gt=0;3>gt;++gt){it[gt]=0;var vt=(et+gt+1)%3;for(H=0;2>H;++H){var mt=H?ut:1-ut;for(W=0|Math.min(Math.max(ct+H,0),a[0]),G=0;2>G;++G){var yt=G?dt:1-dt;if(Z=0|Math.min(Math.max(ht+G,0),a[1]),X=2>gt?this._field[vt].get(W,Z):(this.intensity.get(W,Z)-this.intensityBounds[0])/(this.intensityBounds[1]-this.intensityBounds[0]),!isFinite(X)||isNaN(X)){pt=!0;break e}var bt=mt*yt;it[gt]+=bt*X}}}if(pt){if(Y>0){for(var xt=0;5>xt;++xt)tt.pop();q-=1}continue t}tt.push(it[0],it[1],st[0],st[1],it[2]),q+=1}}nt.push(q)}this._contourOffsets[et]=rt,this._contourCounts[et]=nt}var _t=m.mallocFloat(tt.length);for(o=0;ot;++t)m.freeFloat(this._field[t].data)},j.highlight=function(t){if(!t)return this._dynamicCounts=[0,0,0],this.dyanamicLevel=[NaN,NaN,NaN],void(this.highlightLevel=[-1,-1,-1]);for(var e=0;3>e;++e)this.enableHighlight[e]?this.highlightLevel[e]=t.level[e]:this.highlightLevel[e]=-1;var r;if(r=this.snapToData?t.dataCoordinate:t.position,this.enableDynamic[0]&&r[0]!==this.dynamicLevel[0]||this.enableDynamic[1]&&r[1]!==this.dynamicLevel[1]||this.enableDynamic[2]&&r[2]!==this.dynamicLevel[2]){for(var n=0,i=this.shape,a=m.mallocFloat(12*i[0]*i[1]),o=0;3>o;++o)if(this.enableDynamic[o]){this.dynamicLevel[o]=r[o];var s=(o+1)%3,l=(o+2)%3,c=this._field[o],u=this._field[s],f=this._field[l],h=(this.intensity,w(c,r[o])),d=h.cells,p=h.positions;for(this._dynamicOffsets[o]=n,e=0;ev;++v){var y=p[g[v]],b=+y[0],x=0|b,_=0|Math.min(x+1,i[0]),k=b-x,A=1-k,M=+y[1],T=0|M,E=0|Math.min(T+1,i[1]),L=M-T,S=1-L,C=A*S,z=A*L,P=k*S,R=k*L,O=C*u.get(x,T)+z*u.get(x,E)+P*u.get(_,T)+R*u.get(_,E),I=C*f.get(x,T)+z*f.get(x,E)+P*f.get(_,T)+R*f.get(_,E);if(isNaN(O)||isNaN(I)){v&&(n-=1);break}a[2*n+0]=O,a[2*n+1]=I,n+=1}this._dynamicCounts[o]=n-this._dynamicOffsets[o]}else this.dynamicLevel[o]=NaN,this._dynamicCounts[o]=0;this._dynamicBuffer.update(a.subarray(0,2*n)),m.freeFloat(a)}}},{"./lib/shaders":176,"binary-search-bounds":47,"bit-twiddle":48,colormap:73,"gl-buffer":107,"gl-mat4/invert":128,"gl-mat4/multiply":130,"gl-texture2d":178,"gl-vao":182,ndarray:225,"ndarray-gradient":216,"ndarray-ops":219,"ndarray-pack":220,"surface-nets":273,"typedarray-pool":282}],178:[function(t,e,r){"use strict";function n(t){v=[t.LINEAR,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_NEAREST],m=[t.NEAREST,t.LINEAR,t.NEAREST_MIPMAP_NEAREST,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_LINEAR],y=[t.REPEAT,t.CLAMP_TO_EDGE,t.MIRRORED_REPEAT]}function i(t,e,r){var n=t.gl,i=n.getParameter(n.MAX_TEXTURE_SIZE);if(0>e||e>i||0>r||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function a(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}function o(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function s(t,e,r,n,i,a,s,l){var c=l.dtype,u=l.shape.slice();if(u.length<2||u.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var f=0,h=0,v=o(u,l.stride.slice());"float32"===c?f=t.FLOAT:"float64"===c?(f=t.FLOAT,v=!1,c="float32"):"uint8"===c?f=t.UNSIGNED_BYTE:(f=t.UNSIGNED_BYTE,v=!1,c="uint8");var m=1;if(2===u.length)h=t.LUMINANCE,u=[u[0],u[1],1],l=d(l.data,u,[l.stride[0],l.stride[1],1],l.offset);else{if(3!==u.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===u[2])h=t.ALPHA;else if(2===u[2])h=t.LUMINANCE_ALPHA;else if(3===u[2])h=t.RGB;else{if(4!==u[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");h=t.RGBA}m=u[2]}if(h!==t.LUMINANCE&&h!==t.ALPHA||i!==t.LUMINANCE&&i!==t.ALPHA||(h=i),h!==i)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=l.size,x=s.indexOf(n)<0;if(x&&s.push(n),f===a&&v)0===l.offset&&l.data.length===y?x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,l.data):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,l.data):x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,l.data.subarray(l.offset,l.offset+y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,l.data.subarray(l.offset,l.offset+y));else{var _;_=a===t.FLOAT?g.mallocFloat32(y):g.mallocUint8(y);var w=d(_,u,[u[2],u[2]*u[0],1]);f===t.FLOAT&&a===t.UNSIGNED_BYTE?b(w,l):p.assign(w,l),x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,_.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,_.subarray(0,y)),a===t.FLOAT?g.freeFloat32(_):g.freeUint8(_)}}function l(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function c(t,e,r,n,i){var o=t.getParameter(t.MAX_TEXTURE_SIZE);if(0>e||e>o||0>r||r>o)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var s=l(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new a(t,s,e,r,n,i)}function u(t,e,r,n){var i=l(t);return t.texImage2D(t.TEXTURE_2D,0,r,r,n,e),new a(t,i,0|e.width,0|e.height,r,n)}function f(t,e){var r=e.dtype,n=e.shape.slice(),i=t.getParameter(t.MAX_TEXTURE_SIZE);if(n[0]<0||n[0]>i||n[1]<0||n[1]>i)throw new Error("gl-texture2d: Invalid texture size");var s=o(n,e.stride.slice()),c=0;"float32"===r?c=t.FLOAT:"float64"===r?(c=t.FLOAT,s=!1,r="float32"):"uint8"===r?c=t.UNSIGNED_BYTE:(c=t.UNSIGNED_BYTE,s=!1,r="uint8");var u=0;if(2===n.length)u=t.LUMINANCE,n=[n[0],n[1],1],e=d(e.data,n,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==n.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===n[2])u=t.ALPHA;else if(2===n[2])u=t.LUMINANCE_ALPHA;else if(3===n[2])u=t.RGB;else{if(4!==n[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");u=t.RGBA}}c!==t.FLOAT||t.getExtension("OES_texture_float")||(c=t.UNSIGNED_BYTE,s=!1);var f,h,v=e.size;if(s)f=0===e.offset&&e.data.length===v?e.data:e.data.subarray(e.offset,e.offset+v);else{var m=[n[2],n[2]*n[0],1];h=g.malloc(v,r);var y=d(h,n,m,0);"float32"!==r&&"float64"!==r||c!==t.UNSIGNED_BYTE?p.assign(y,e):b(y,e),f=h.subarray(0,v)}var x=l(t);return t.texImage2D(t.TEXTURE_2D,0,u,n[0],n[1],0,u,c,f),s||g.free(h),new a(t,x,n[0],n[1],u,c)}function h(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");if(v||n(t),"number"==typeof arguments[1])return c(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return c(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1];if(e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof HTMLVideoElement||e instanceof ImageData)return u(t,e,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return f(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")}var d=t("ndarray"),p=t("ndarray-ops"),g=t("typedarray-pool");e.exports=h;var v=null,m=null,y=null,b=function(t,e){p.muls(t,e,255)},x=a.prototype;Object.defineProperties(x,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;2>e;++e)if(y.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return i(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return t=0|t,i(this,t,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t=0|t,i(this,this._shape[0],t),t}}}),x.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},x.dispose=function(){this.gl.deleteTexture(this.handle)},x.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},x.setPixels=function(t,e,r,n){var i=this.gl;if(this.bind(),Array.isArray(e)?(n=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),n=n||0,t instanceof HTMLCanvasElement||t instanceof ImageData||t instanceof HTMLImageElement||t instanceof HTMLVideoElement){var a=this._mipLevels.indexOf(n)<0;a?(i.texImage2D(i.TEXTURE_2D,0,this.format,this.format,this.type,t),this._mipLevels.push(n)):i.texSubImage2D(i.TEXTURE_2D,n,e,r,this.format,this.type,t)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>n||r+t.shape[0]>this._shape[0]>>>n||0>e||0>r)throw new Error("gl-texture2d: Texture dimensions are out of bounds");s(i,e,r,n,this.format,this.type,this._mipLevels,t)}}},{ndarray:225,"ndarray-ops":219,"typedarray-pool":282}],179:[function(t,e,r){"use strict";function n(t,e,r){e?e.bind():t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);var n=0|t.getParameter(t.MAX_VERTEX_ATTRIBS);if(r){if(r.length>n)throw new Error("gl-vao: Too many vertex attributes");for(var i=0;ii;++i)t.disableVertexAttribArray(i)}else{t.bindBuffer(t.ARRAY_BUFFER,null);for(var i=0;n>i;++i)t.disableVertexAttribArray(i)}}e.exports=n},{}],180:[function(t,e,r){"use strict";function n(t){this.gl=t,this._elements=null,this._attributes=null,this._elementsType=t.UNSIGNED_SHORT}function i(t){return new n(t)}var a=t("./do-bind.js");n.prototype.bind=function(){a(this.gl,this._elements,this._attributes)},n.prototype.update=function(t,e,r){this._elements=e,this._attributes=t,this._elementsType=r||this.gl.UNSIGNED_SHORT},n.prototype.dispose=function(){},n.prototype.unbind=function(){},n.prototype.draw=function(t,e,r){r=r||0;var n=this.gl;this._elements?n.drawElements(t,e,this._elementsType,r):n.drawArrays(t,r,e)},e.exports=i},{"./do-bind.js":179}],181:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.location=t,this.dimension=e,this.a=r,this.b=n,this.c=i,this.d=a}function i(t,e,r){this.gl=t,this._ext=e,this.handle=r,this._attribs=[],this._useElements=!1,this._elementsType=t.UNSIGNED_SHORT}function a(t,e){return new i(t,e,e.createVertexArrayOES())}var o=t("./do-bind.js");n.prototype.bind=function(t){switch(this.dimension){case 1:t.vertexAttrib1f(this.location,this.a);break;case 2:t.vertexAttrib2f(this.location,this.a,this.b);break;case 3:t.vertexAttrib3f(this.location,this.a,this.b,this.c);break;case 4:t.vertexAttrib4f(this.location,this.a,this.b,this.c,this.d)}},i.prototype.bind=function(){this._ext.bindVertexArrayOES(this.handle);for(var t=0;t0&&(a=1/Math.sqrt(a), -t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t}e.exports=n},{}],188:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}e.exports=n},{}],189:[function(t,e,r){function n(t,e,r,n){return i[0]=n,i[1]=r,i[2]=e,i[3]=t,a[0]}e.exports=n;var i=new Uint8Array(4),a=new Float32Array(i.buffer)},{}],190:[function(t,e,r){function n(t){for(var e=Array.isArray(t)?t:i(t),r=0;rF;){switch(e=F,D){case f:F=L();break;case h:F=E();break;case d:F=T();break;case p:F=S();break;case g:F=P();break;case w:F=z();break;case v:F=R();break;case u:F=O();break;case x:F=M();break;case c:F=A()}if(e!==F)switch(W[e]){case"\n":H=0,++q;break;default:++H}}return B+=F,W=W.slice(F),V}function n(t){return U.length&&e(U.join("")),D=_,e("(eof)"),V}function A(){return U=U.length?[]:U,"/"===N&&"*"===I?(G=B+F-1,D=f,N=I,F+1):"/"===N&&"/"===I?(G=B+F-1,D=h,N=I,F+1):"#"===I?(D=d,G=B+F,F):/\s/.test(I)?(D=x,G=B+F,F):(Y=/\d/.test(I),X=/[^\w_]/.test(I),G=B+F,D=Y?g:X?p:u,F)}function M(){return/[^\s]/g.test(I)?(e(U.join("")),D=c,F):(U.push(I),N=I,F+1)}function T(){return"\r"!==I&&"\n"!==I||"\\"===N?(U.push(I),N=I,F+1):(e(U.join("")),D=c,F)}function E(){return T()}function L(){return"/"===I&&"*"===N?(U.push(I),e(U.join("")),D=c,F+1):(U.push(I),N=I,F+1)}function S(){if("."===N&&/\d/.test(I))return D=v,F;if("/"===N&&"*"===I)return D=f,F;if("/"===N&&"/"===I)return D=h,F;if("."===I&&U.length){for(;C(U););return D=v,F}if(";"===I||")"===I||"("===I){if(U.length)for(;C(U););return e(I),D=c,F+1}var t=2===U.length&&"="!==I;if(/[\w_\d\s]/.test(I)||t){for(;C(U););return D=c,F}return U.push(I),N=I,F+1}function C(t){for(var r,n,i=0;;){if(r=a.indexOf(t.slice(0,t.length+i).join("")),n=a[r],-1===r){if(i--+t.length>0)continue;n=t.slice(0,1).join("")}return e(n),G+=n.length,U=U.slice(n.length),U.length}}function z(){return/[^a-fA-F0-9]/.test(I)?(e(U.join("")),D=c,F):(U.push(I),N=I,F+1)}function P(){return"."===I?(U.push(I),D=v,N=I,F+1):/[eE]/.test(I)?(U.push(I),D=v,N=I,F+1):"x"===I&&1===U.length&&"0"===U[0]?(D=w,U.push(I),N=I,F+1):/[^\d]/.test(I)?(e(U.join("")),D=c,F):(U.push(I),N=I,F+1)}function R(){return"f"===I&&(U.push(I),N=I,F+=1),/[eE]/.test(I)?(U.push(I),N=I,F+1):"-"===I&&/[eE]/.test(N)?(U.push(I),N=I,F+1):/[^\d]/.test(I)?(e(U.join("")),D=c,F):(U.push(I),N=I,F+1)}function O(){if(/[^\d\w_]/.test(I)){var t=U.join("");return D=K.indexOf(t)>-1?b:Z.indexOf(t)>-1?y:m,e(U.join("")),D=c,F}return U.push(I),N=I,F+1}var I,N,j,F=0,B=0,D=c,U=[],V=[],q=1,H=0,G=0,Y=!1,X=!1,W="";t=t||{};var Z=o,K=i;return"300 es"===t.version&&(Z=l,K=s),function(t){return V=[],null!==t?r(t.replace?t.replace(/\r\n/g,"\n"):t):n()}}e.exports=n;var i=t("./lib/literals"),a=t("./lib/operators"),o=t("./lib/builtins"),s=t("./lib/literals-300es"),l=t("./lib/builtins-300es"),c=999,u=9999,f=0,h=1,d=2,p=3,g=4,v=5,m=6,y=7,b=8,x=9,_=10,w=11,k=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":193,"./lib/builtins-300es":192,"./lib/literals":195,"./lib/literals-300es":194,"./lib/operators":196}],192:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["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","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"])},{"./builtins":193}],193:[function(t,e,r){e.exports=["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"]},{}],194:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","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"])},{"./literals":195}],195:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","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","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"]},{}],196:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],197:[function(t,e,r){function n(t,e){var r=i(e),n=[];return n=n.concat(r(t)),n=n.concat(r(null))}var i=t("./index");e.exports=n},{"./index":191}],198:[function(t,e,r){r.read=function(t,e,r,n,i){var a,o,s=8*i-n-1,l=(1<>1,u=-7,f=r?i-1:0,h=r?-1:1,d=t[e+f];for(f+=h,a=d&(1<<-u)-1,d>>=-u,u+=s;u>0;a=256*a+t[e+f],f+=h,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+f],f+=h,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:(d?-1:1)*(1/0);o+=Math.pow(2,n),a-=c}return(d?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:a-1,p=n?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),e+=o+f>=1?h/l:h*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=u?(s=0,o=u):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,c-=8);t[r+d-p]|=128*g}},{}],199:[function(t,e,r){"use strict";function n(t,e,r){this.vertices=t,this.adjacent=e,this.boundary=r,this.lastVisited=-1}function i(t,e,r){this.vertices=t,this.cell=e,this.index=r}function a(t,e){return u(t.vertices,e.vertices)}function o(t){for(var e=["function orient(){var tuple=this.tuple;return test("],r=0;t>=r;++r)r>0&&e.push(","),e.push("tuple[",r,"]");e.push(")}return orient");var n=new Function("test",e.join("")),i=c[t+1];return i||(i=c),n(i)}function s(t,e,r){this.dimension=t,this.vertices=e,this.simplices=r,this.interior=r.filter(function(t){return!t.boundary}),this.tuple=new Array(t+1);for(var n=0;t>=n;++n)this.tuple[n]=this.vertices[n];var i=f[t];i||(i=f[t]=o(t)),this.orient=i}function l(t,e){var r=t.length;if(0===r)throw new Error("Must have at least d+1 points");var i=t[0].length;if(i>=r)throw new Error("Must input at least d+1 points");var a=t.slice(0,i+1),o=c.apply(void 0,a);if(0===o)throw new Error("Input not in general position");for(var l=new Array(i+1),u=0;i>=u;++u)l[u]=u;0>o&&(l[0]=1,l[1]=0);for(var f=new n(l,new Array(i+1),!1),h=f.adjacent,d=new Array(i+2),u=0;i>=u;++u){for(var p=l.slice(),g=0;i>=g;++g)g===u&&(p[g]=-1);var v=p[0];p[0]=p[1],p[1]=v;var m=new n(p,new Array(i+1),!0);h[u]=m,d[u]=m}d[i+1]=f;for(var u=0;i>=u;++u)for(var p=h[u].vertices,y=h[u].adjacent,g=0;i>=g;++g){var b=p[g];if(0>b)y[g]=f;else for(var x=0;i>=x;++x)h[x].vertices.indexOf(b)<0&&(y[g]=h[x])}for(var _=new s(i,a,d),w=!!e,u=i+1;r>u;++u)_.insert(t[u],w);return _.boundary()}e.exports=l;var c=t("robust-orientation"),u=t("simplicial-complex").compareCells;n.prototype.flip=function(){var t=this.vertices[0];this.vertices[0]=this.vertices[1],this.vertices[1]=t;var e=this.adjacent[0];this.adjacent[0]=this.adjacent[1],this.adjacent[1]=e};var f=[],h=s.prototype;h.handleBoundaryDegeneracy=function(t,e){var r=this.dimension,n=this.vertices.length-1,i=this.tuple,a=this.vertices,o=[t];for(t.lastVisited=-n;o.length>0;){t=o.pop();for(var s=(t.vertices,t.adjacent),l=0;r>=l;++l){var c=s[l];if(c.boundary&&!(c.lastVisited<=-n)){for(var u=c.vertices,f=0;r>=f;++f){var h=u[f];0>h?i[f]=e:i[f]=a[h]}var d=this.orient();if(d>0)return c;c.lastVisited=-n,0===d&&o.push(c)}}}return null},h.walk=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,a=this.tuple,o=e?this.interior.length*Math.random()|0:this.interior.length-1,s=this.interior[o];t:for(;!s.boundary;){for(var l=s.vertices,c=s.adjacent,u=0;n>=u;++u)a[u]=i[l[u]];s.lastVisited=r;for(var u=0;n>=u;++u){var f=c[u];if(!(f.lastVisited>=r)){var h=a[u];a[u]=t;var d=this.orient();if(a[u]=h,0>d){s=f;continue t}f.boundary?f.lastVisited=-r:f.lastVisited=r}}return}return s},h.addPeaks=function(t,e){var r=this.vertices.length-1,o=this.dimension,s=this.vertices,l=this.tuple,c=this.interior,u=this.simplices,f=[e];e.lastVisited=r,e.vertices[e.vertices.indexOf(-1)]=r,e.boundary=!1,c.push(e);for(var h=[];f.length>0;){var e=f.pop(),d=e.vertices,p=e.adjacent,g=d.indexOf(r);if(!(0>g))for(var v=0;o>=v;++v)if(v!==g){var m=p[v];if(m.boundary&&!(m.lastVisited>=r)){var y=m.vertices;if(m.lastVisited!==-r){for(var b=0,x=0;o>=x;++x)y[x]<0?(b=x,l[x]=t):l[x]=s[y[x]];var _=this.orient();if(_>0){y[b]=r,m.boundary=!1,c.push(m),f.push(m),m.lastVisited=r;continue}m.lastVisited=-r}var w=m.adjacent,k=d.slice(),A=p.slice(),M=new n(k,A,!0);u.push(M);var T=w.indexOf(e);if(!(0>T)){w[T]=M,A[g]=m,k[v]=-1,A[v]=e,p[v]=M,M.flip();for(var x=0;o>=x;++x){var E=k[x];if(!(0>E||E===r)){for(var L=new Array(o-1),S=0,C=0;o>=C;++C){var z=k[C];0>z||C===x||(L[S++]=z)}h.push(new i(L,M,x))}}}}}}h.sort(a);for(var v=0;v+1O||0>I||(P.cell.adjacent[P.index]=R.cell,R.cell.adjacent[R.index]=P.cell)}},h.insert=function(t,e){var r=this.vertices;r.push(t);var n=this.walk(t,e);if(n){for(var i=this.dimension,a=this.tuple,o=0;i>=o;++o){var s=n.vertices[o];0>s?a[o]=t:a[o]=r[s]}var l=this.orient(a);0>l||(0!==l||(n=this.handleBoundaryDegeneracy(n,t)))&&this.addPeaks(t,n)}},h.boundary=function(){for(var t=this.dimension,e=[],r=this.simplices,n=r.length,i=0;n>i;++i){var a=r[i];if(a.boundary){for(var o=new Array(t),s=a.vertices,l=0,c=0,u=0;t>=u;++u)s[u]>=0?o[l++]=s[u]:c=1&u;if(c===(1&t)){var f=o[0];o[0]=o[1],o[1]=f}e.push(o)}}return e}},{"robust-orientation":253,"simplicial-complex":263}],200:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}function i(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function a(t,e){var r=p(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function o(t,e){var r=t.intervals([]);r.push(e),a(t,r)}function s(t,e){var r=t.intervals([]),n=r.indexOf(e);return 0>n?y:(r.splice(n,1),a(t,r),b)}function l(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function u(t,e){for(var r=0;r>1],a=[],o=[],s=[],r=0;r3*(e+1)?o(this,t):this.left.insert(t):this.left=p([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?o(this,t):this.right.insert(t):this.right=p([t]);else{var r=m.ge(this.leftPoints,t,h),n=m.ge(this.rightPoints,t,d);this.leftPoints.splice(r,0,t),this.rightPoints.splice(n,0,t)}},_.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1))return s(this,t);var n=this.left.remove(t);return n===x?(this.left=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(t[0]>this.mid){if(!this.right)return y;var a=this.left?this.left.count:0;if(4*a>3*(e-1))return s(this,t);var n=this.right.remove(t);return n===x?(this.right=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(1===this.count)return this.leftPoints[0]===t?x:y;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var o=this,l=this.left;l.right;)o=l,l=l.right;if(o===this)l.right=this.right;else{var c=this.left,n=this.right;o.count-=l.count,o.right=l.left,l.left=c,l.right=n}i(this,l),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?i(this,this.left):i(this,this.right);return b}for(var c=m.ge(this.leftPoints,t,h);cthis.mid){if(this.right){var r=this.right.queryPoint(t,e);if(r)return r}return c(this.rightPoints,t,e)}return u(this.leftPoints,e)},_.queryInterval=function(t,e,r){if(tthis.mid&&this.right){var n=this.right.queryInterval(t,e,r);if(n)return n}return ethis.mid?c(this.rightPoints,t,r):u(this.leftPoints,r)};var w=g.prototype;w.insert=function(t){this.root?this.root.insert(t):this.root=new n(t[0],null,null,[t],[t])},w.remove=function(t){if(this.root){var e=this.root.remove(t);return e===x&&(this.root=null),e!==y}return!1},w.queryPoint=function(t,e){return this.root?this.root.queryPoint(t,e):void 0},w.queryInterval=function(t,e,r){return e>=t&&this.root?this.root.queryInterval(t,e,r):void 0},Object.defineProperty(w,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(w,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":47}],201:[function(t,e,r){"use strict";function n(t,e){e=e||new Array(t.length);for(var r=0;rr;++r)e[r]=r;return e}e.exports=n},{}],203:[function(t,e,r){e.exports=function(t){return!(null==t||!(t._isBuffer||t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)))}},{}],204:[function(t,e,r){"use strict";function n(t,e,r){for(var n=new Array(t),i=0;t>i;++i)n[i]=0,i===e&&(n[i]+=.5),i===r&&(n[i]+=.5);return n}function i(t,e){if(0===e||e===(1<=a;++a)if(e&1<=s;++s)~e&1<n;++n)r[n]=i(t,n);return r}e.exports=a;var o=t("convex-hull")},{"convex-hull":77}],205:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}function i(t,e){t[0][0]=e[0],t[0][1]=e[1],t[0][2]=e[2],t[1][0]=e[4],t[1][1]=e[5],t[1][2]=e[6],t[2][0]=e[8],t[2][1]=e[9],t[2][2]=e[10]}function a(t,e,r,n,i){t[0]=e[0]*n+r[0]*i,t[1]=e[1]*n+r[1]*i,t[2]=e[2]*n+r[2]*i}var o=t("./normalize"),s=t("gl-mat4/create"),l=t("gl-mat4/clone"),c=t("gl-mat4/determinant"),u=t("gl-mat4/invert"),f=t("gl-mat4/transpose"),h={length:t("gl-vec3/length"),normalize:t("gl-vec3/normalize"),dot:t("gl-vec3/dot"),cross:t("gl-vec3/cross")},d=s(),p=s(),g=[0,0,0,0],v=[[0,0,0],[0,0,0],[0,0,0]],m=[0,0,0];e.exports=function(t,e,r,s,y,b){if(e||(e=[0,0,0]),r||(r=[0,0,0]),s||(s=[0,0,0]),y||(y=[0,0,0,1]),b||(b=[0,0,0,1]),!o(d,t))return!1;if(l(p,d),p[3]=0,p[7]=0,p[11]=0,p[15]=1,Math.abs(c(p)<1e-8))return!1;var x=d[3],_=d[7],w=d[11],k=d[12],A=d[13],M=d[14],T=d[15];if(0!==x||0!==_||0!==w){g[0]=x,g[1]=_,g[2]=w,g[3]=T;var E=u(p,p);if(!E)return!1;f(p,p),n(y,g,p)}else y[0]=y[1]=y[2]=0,y[3]=1;if(e[0]=k,e[1]=A,e[2]=M,i(v,d),r[0]=h.length(v[0]),h.normalize(v[0],v[0]),s[0]=h.dot(v[0],v[1]),a(v[1],v[1],v[0],1,-s[0]),r[1]=h.length(v[1]),h.normalize(v[1],v[1]),s[0]/=r[1],s[1]=h.dot(v[0],v[2]),a(v[2],v[2],v[0],1,-s[1]),s[2]=h.dot(v[1],v[2]),a(v[2],v[2],v[1],1,-s[2]),r[2]=h.length(v[2]),h.normalize(v[2],v[2]),s[1]/=r[2],s[2]/=r[2],h.cross(m,v[1],v[2]),h.dot(v[0],m)<0)for(var L=0;3>L;L++)r[L]*=-1,v[L][0]*=-1,v[L][1]*=-1,v[L][2]*=-1;return b[0]=.5*Math.sqrt(Math.max(1+v[0][0]-v[1][1]-v[2][2],0)),b[1]=.5*Math.sqrt(Math.max(1-v[0][0]+v[1][1]-v[2][2],0)),b[2]=.5*Math.sqrt(Math.max(1-v[0][0]-v[1][1]+v[2][2],0)),b[3]=.5*Math.sqrt(Math.max(1+v[0][0]+v[1][1]+v[2][2],0)),v[2][1]>v[1][2]&&(b[0]=-b[0]),v[0][2]>v[2][0]&&(b[1]=-b[1]),v[1][0]>v[0][1]&&(b[2]=-b[2]),!0}},{"./normalize":206,"gl-mat4/clone":122,"gl-mat4/create":123,"gl-mat4/determinant":124,"gl-mat4/invert":128,"gl-mat4/transpose":138,"gl-vec3/cross":183,"gl-vec3/dot":184,"gl-vec3/length":185,"gl-vec3/normalize":187}],206:[function(t,e,r){e.exports=function(t,e){var r=e[15];if(0===r)return!1;for(var n=1/r,i=0;16>i;i++)t[i]=e[i]*n;return!0}},{}],207:[function(t,e,r){function n(t,e,r,n){if(0===u(e)||0===u(r))return!1;var i=c(e,h.translate,h.scale,h.skew,h.perspective,h.quaternion),a=c(r,d.translate,d.scale,d.skew,d.perspective,d.quaternion);return i&&a?(s(p.translate,h.translate,d.translate,n),s(p.skew,h.skew,d.skew,n),s(p.scale,h.scale,d.scale,n),s(p.perspective,h.perspective,d.perspective,n),f(p.quaternion,h.quaternion,d.quaternion,n),l(t,p.translate,p.scale,p.skew,p.perspective,p.quaternion),!0):!1}function i(){return{translate:a(),scale:a(1),skew:a(),perspective:o(),quaternion:o()}}function a(t){return[t||0,t||0,t||0]}function o(){return[0,0,0,1]}var s=t("gl-vec3/lerp"),l=t("mat4-recompose"),c=t("mat4-decompose"),u=t("gl-mat4/determinant"),f=t("quat-slerp"),h=i(),d=i(),p=i();e.exports=n},{"gl-mat4/determinant":124,"gl-vec3/lerp":186,"mat4-decompose":205,"mat4-recompose":208,"quat-slerp":240}],208:[function(t,e,r){var n={identity:t("gl-mat4/identity"),translate:t("gl-mat4/translate"),multiply:t("gl-mat4/multiply"),create:t("gl-mat4/create"),scale:t("gl-mat4/scale"),fromRotationTranslation:t("gl-mat4/fromRotationTranslation")},i=(n.create(),n.create());e.exports=function(t,e,r,a,o,s){return n.identity(t),n.fromRotationTranslation(t,s,e),t[3]=o[0],t[7]=o[1],t[11]=o[2],t[15]=o[3],n.identity(i),0!==a[2]&&(i[9]=a[2],n.multiply(t,t,i)),0!==a[1]&&(i[9]=0,i[8]=a[1],n.multiply(t,t,i)),0!==a[0]&&(i[8]=0,i[4]=a[0],n.multiply(t,t,i)),n.scale(t,t,r),t}},{"gl-mat4/create":123,"gl-mat4/fromRotationTranslation":126,"gl-mat4/identity":127,"gl-mat4/multiply":130,"gl-mat4/scale":136,"gl-mat4/translate":137}],209:[function(t,e,r){"use strict";function n(t){this._components=t.slice(),this._time=[0],this.prevMatrix=t.slice(),this.nextMatrix=t.slice(),this.computedMatrix=t.slice(),this.computedInverse=t.slice(),this.computedEye=[0,0,0],this.computedUp=[0,0,0],this.computedCenter=[0,0,0],this.computedRadius=[0],this._limits=[-(1/0),1/0]}function i(t){t=t||{};var e=t.matrix||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return new n(e)}var a=t("binary-search-bounds"),o=t("mat4-interpolate"),s=t("gl-mat4/invert"),l=t("gl-mat4/rotateX"),c=t("gl-mat4/rotateY"),u=t("gl-mat4/rotateZ"),f=t("gl-mat4/lookAt"),h=t("gl-mat4/translate"),d=(t("gl-mat4/scale"),t("gl-vec3/normalize")),p=[0,0,0];e.exports=i;var g=n.prototype;g.recalcMatrix=function(t){var e=this._time,r=a.le(e,t),n=this.computedMatrix;if(!(0>r)){var i=this._components;if(r===e.length-1)for(var l=16*r,c=0;16>c;++c)n[c]=i[l++];else{for(var u=e[r+1]-e[r],l=16*r,f=this.prevMatrix,h=!0,c=0;16>c;++c)f[c]=i[l++];for(var p=this.nextMatrix,c=0;16>c;++c)p[c]=i[l++],h=h&&f[c]===p[c];if(1e-6>u||h)for(var c=0;16>c;++c)n[c]=f[c];else o(n,f,p,(t-e[r])/u)}var g=this.computedUp;g[0]=n[1],g[1]=n[5],g[2]=n[6],d(g,g);var v=this.computedInverse;s(v,n);var m=this.computedEye,y=v[15];m[0]=v[12]/y,m[1]=v[13]/y,m[2]=v[14]/y;for(var b=this.computedCenter,x=Math.exp(this.computedRadius[0]),c=0;3>c;++c)b[c]=m[c]-n[2+4*c]*x}},g.idle=function(t){if(!(tn;++n)e.push(e[r++]);this._time.push(t)}},g.flush=function(t){var e=a.gt(this._time,t)-2;0>e||(this._time.slice(0,e),this._components.slice(0,16*e))},g.lastT=function(){return this._time[this._time.length-1]},g.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||p,n=n||this.computedUp,this.setMatrix(t,f(this.computedMatrix,e,r,n));for(var i=0,a=0;3>a;++a)i+=Math.pow(r[a]-e[a],2);i=Math.log(Math.sqrt(i)),this.computedRadius[0]=i},g.rotate=function(t,e,r,n){this.recalcMatrix(t);var i=this.computedInverse;e&&c(i,i,e),r&&l(i,i,r),n&&u(i,i,n),this.setMatrix(t,s(this.computedMatrix,i))};var v=[0,0,0];g.pan=function(t,e,r,n){v[0]=-(e||0),v[1]=-(r||0),v[2]=-(n||0),this.recalcMatrix(t);var i=this.computedInverse;h(i,i,v),this.setMatrix(t,s(i,i))},g.translate=function(t,e,r,n){v[0]=e||0,v[1]=r||0,v[2]=n||0,this.recalcMatrix(t);var i=this.computedMatrix;h(i,i,v),this.setMatrix(t,i)},g.setMatrix=function(t,e){if(!(tr;++r)this._components.push(e[r])}},g.setDistance=function(t,e){this.computedRadius[0]=e},g.setDistanceLimits=function(t,e){var r=this._limits;r[0]=t,r[1]=e},g.getDistanceLimits=function(t){var e=this._limits;return t?(t[0]=e[0],t[1]=e[1],t):e}},{"binary-search-bounds":47,"gl-mat4/invert":128,"gl-mat4/lookAt":129,"gl-mat4/rotateX":133,"gl-mat4/rotateY":134,"gl-mat4/rotateZ":135,"gl-mat4/scale":136,"gl-mat4/translate":137,"gl-vec3/normalize":187,"mat4-interpolate":207}],210:[function(t,e,r){"use strict";function n(t){var e=t.length;if(3>e){for(var r=new Array(e),n=0;e>n;++n)r[n]=n;return 2===e&&t[0][0]===t[1][0]&&t[0][1]===t[1][1]?[0]:r}for(var a=new Array(e),n=0;e>n;++n)a[n]=n;a.sort(function(e,r){var n=t[e][0]-t[r][0];return n?n:t[e][1]-t[r][1]});for(var o=[a[0],a[1]],s=[a[0],a[1]],n=2;e>n;++n){for(var l=a[n],c=t[l],u=o.length;u>1&&i(t[o[u-2]],t[o[u-1]],c)<=0;)u-=1,o.pop();for(o.push(l),u=s.length;u>1&&i(t[s[u-2]],t[s[u-1]],c)>=0;)u-=1,s.pop();s.push(l)}for(var r=new Array(s.length+o.length-2),f=0,n=0,h=o.length;h>n;++n)r[f++]=o[n];for(var d=s.length-2;d>0;--d)r[f++]=s[d];return r}e.exports=n;var i=t("robust-orientation")[3]},{"robust-orientation":253}],211:[function(t,e,r){"use strict";function n(t,e){function r(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==g.alt,g.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==g.shift,g.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==g.control,g.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==g.meta,g.meta=!!t.metaKey),e}function n(t,n){var a=i.x(n),o=i.y(n);"buttons"in n&&(t=0|n.buttons),(t!==h||a!==d||o!==p||r(n))&&(h=0|t,d=a||0,p=o||0,e&&e(h,d,p,g))}function a(t){n(0,t)}function o(){(h||d||p||g.shift||g.alt||g.meta||g.control)&&(d=p=0,h=0,g.shift=g.alt=g.control=g.meta=!1,e&&e(0,0,0,g))}function s(t){r(t)&&e&&e(h,d,p,g)}function l(t){0===i.buttons(t)?n(0,t):n(h,t)}function c(t){n(h|i.buttons(t),t)}function u(t){n(h&~i.buttons(t),t)}function f(){v||(v=!0,t.addEventListener("mousemove",l),t.addEventListener("mousedown",c),t.addEventListener("mouseup",u),t.addEventListener("mouseleave",a),t.addEventListener("mouseenter",a),t.addEventListener("mouseout",a),t.addEventListener("mouseover",a),t.addEventListener("blur",o),t.addEventListener("keyup",s),t.addEventListener("keydown",s),t.addEventListener("keypress",s),t!==window&&(window.addEventListener("blur",o),window.addEventListener("keyup",s),window.addEventListener("keydown",s),window.addEventListener("keypress",s)))}e||(e=t,t=window);var h=0,d=0,p=0,g={shift:!1,alt:!1,control:!1,meta:!1},v=!1;f();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return v},set:function(t){t&&f()},enumerable:!0},buttons:{get:function(){return h},enumerable:!0},x:{get:function(){return d},enumerable:!0},y:{get:function(){return p},enumerable:!0},mods:{get:function(){return g},enumerable:!0}}),m}e.exports=n;var i=t("mouse-event")},{"mouse-event":212}],212:[function(t,e,r){"use strict";function n(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<i;++i)e&1<e;++e)F.push(u(e),"+=",d(e,x[t]),";");F.push("}")}function z(t){for(var e=t-1;e>=0;--e)S(e,0);for(var r=[],e=0;I>e;++e)L[e]?r.push(i(e)+".get("+u(e)+")"):r.push(i(e)+"["+u(e)+"]");for(var e=0;b>e;++e)r.push(c(e));F.push(k,"[",T,"++]=phase(",r.join(),");");for(var e=0;t>e;++e)C(e);for(var n=0;I>n;++n)F.push(u(n),"+=",d(n,x[t]),";")}function P(t){for(var e=0;I>e;++e)L[e]?F.push(a(e,0),"=",i(e),".get(",u(e),");"):F.push(a(e,0),"=",i(e),"[",u(e),"];");for(var r=[],e=0;I>e;++e)r.push(a(e,0));for(var e=0;b>e;++e)r.push(c(e));F.push(p(0),"=",k,"[",T,"]=phase(",r.join(),");");for(var n=1;1<n;++n)F.push(p(n),"=",k,"[",T,"+",v(n),"];");for(var o=[],n=1;1<n;++n)o.push("("+p(0)+"!=="+p(n)+")");F.push("if(",o.join("||"),"){");for(var s=[],e=0;N>e;++e)s.push(h(e)); -for(var e=0;I>e;++e){s.push(a(e,0));for(var n=1;1<n;++n)L[e]?F.push(a(e,n),"=",i(e),".get(",u(e),"+",f(e,n),");"):F.push(a(e,n),"=",i(e),"[",u(e),"+",f(e,n),"];"),s.push(a(e,n))}for(var e=0;1<e;++e)s.push(p(e));for(var e=0;b>e;++e)s.push(c(e));F.push("vertex(",s.join(),");",m(0),"=",w,"[",T,"]=",A,"++;");for(var l=(1<n;++n)if(0===(t&~(1<0;_=_-1&g)x.push(w+"["+T+"+"+v(_)+"]");x.push(m(0));for(var _=0;I>_;++_)1&n?x.push(a(_,l),a(_,g)):x.push(a(_,g),a(_,l));1&n?x.push(d,y):x.push(y,d);for(var _=0;b>_;++_)x.push(c(_));F.push("if(",d,"!==",y,"){","face(",x.join(),")}")}F.push("}",T,"+=1;")}function R(){for(var t=1;1<t;++t)F.push(E,"=",v(t),";",v(t),"=",g(t),";",g(t),"=",E,";")}function O(t,e){if(0>t)return void P(e);z(t),F.push("if(",o(x[t]),">0){",h(x[t]),"=1;"),O(t-1,e|1<r;++r)F.push(u(r),"+=",d(r,x[t]),";");t===N-1&&(F.push(T,"=0;"),R()),S(t,2),O(t-1,e),t===N-1&&(F.push("if(",h(x[N-1]),"&1){",T,"=0;}"),R()),C(t),F.push("}")}var I=L.length,N=x.length;if(2>N)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var j="extractContour"+x.join("_"),F=[],B=[],D=[],U=0;I>U;++U)D.push(n(U));for(var U=0;b>U;++U)D.push(c(U));for(var U=0;N>U;++U)B.push(o(U)+"="+n(0)+".shape["+U+"]|0");for(var U=0;I>U;++U){B.push(i(U)+"="+n(U)+".data",l(U)+"="+n(U)+".offset|0");for(var V=0;N>V;++V)B.push(s(U,V)+"="+n(U)+".stride["+V+"]|0")}for(var U=0;I>U;++U){B.push(u(U)+"="+l(U)),B.push(a(U,0));for(var V=1;1<V;++V){for(var q=[],H=0;N>H;++H)V&1<U;++U)for(var V=0;N>V;++V){var G=[s(U,x[V])];V>0&&G.push(s(U,x[V-1])+"*"+o(x[V-1])),B.push(d(U,x[V])+"=("+G.join("-")+")|0")}for(var U=0;N>U;++U)B.push(h(U)+"=0");B.push(A+"=0");for(var Y=["2"],U=N-2;U>=0;--U)Y.push(o(x[U]));B.push(M+"=("+Y.join("*")+")|0",k+"=mallocUint32("+M+")",w+"=mallocUint32("+M+")",T+"=0"),B.push(p(0)+"=0");for(var V=1;1<V;++V){for(var X=[],W=[],H=0;N>H;++H)V&1<n&&e("Must have at least one array argument");var i=t.scalarArguments||0;0>i&&e("Scalar arg count must be > 0"),"function"!=typeof t.vertex&&e("Must specify vertex creation function"),"function"!=typeof t.cell&&e("Must specify cell creation function"),"function"!=typeof t.phase&&e("Must specify phase function");for(var a=t.getters||[],o=new Array(n),s=0;n>s;++s)a.indexOf(s)>=0?o[s]=!0:o[s]=!1;return b(t.vertex,t.cell,t.phase,i,r,o)}var _=t("typedarray-pool");e.exports=x;var w="V",k="P",A="N",M="Q",T="X",E="T"},{"typedarray-pool":282}],215:[function(t,e,r){"use strict";var n=t("cwise/lib/wrapper")({args:["index","array","scalar"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_4_arg1_=_inline_4_arg2_.apply(void 0,_inline_4_arg0_)}",args:[{name:"_inline_4_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_4_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_4_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"cwise",blockSize:64});e.exports=function(t,e){return n(t,e),t}},{"cwise/lib/wrapper":86}],216:[function(t,e,r){"use strict";function n(t){if(t in l)return l[t];for(var e=[],r=0;t>r;++r)e.push("out",r,"s=0.5*(inp",r,"l-inp",r,"r);");for(var n=["array"],i=["junk"],r=0;t>r;++r){n.push("array"),i.push("out"+r+"s");var a=o(t);a[r]=-1,n.push({array:0,offset:a.slice()}),a[r]=1,n.push({array:0,offset:a.slice()}),i.push("inp"+r+"l","inp"+r+"r")}return l[t]=s({args:n,pre:u,post:u,body:{body:e.join(""),args:i.map(function(t){return{name:t,lvalue:0===t.indexOf("out"),rvalue:0===t.indexOf("inp"),count:"junk"!==t|0}}),thisVars:[],localVars:[]},funcName:"fdTemplate"+t})}function i(t){function e(e){for(var r=a-e.length,n=[],i=[],s=[],l=0;a>l;++l)e.indexOf(l+1)>=0?s.push("0"):e.indexOf(-(l+1))>=0?s.push("s["+l+"]-1"):(s.push("-1"),n.push("1"),i.push("s["+l+"]-2"));var c=".lo("+n.join()+").hi("+i.join()+")";if(0===n.length&&(c=""),r>0){o.push("if(1");for(var l=0;a>l;++l)e.indexOf(l+1)>=0||e.indexOf(-(l+1))>=0||o.push("&&s[",l,"]>2");o.push("){grad",r,"(src.pick(",s.join(),")",c);for(var l=0;a>l;++l)e.indexOf(l+1)>=0||e.indexOf(-(l+1))>=0||o.push(",dst.pick(",s.join(),",",l,")",c);o.push(");")}for(var l=0;l1){dst.set(",s.join(),",",u,",0.5*(src.get(",h.join(),")-src.get(",d.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):o.push("if(s[",u,"]>1){diff(",f,",src.pick(",h.join(),")",c,",src.pick(",d.join(),")",c,");}else{zero(",f,");};");break;case"mirror":0===r?o.push("dst.set(",s.join(),",",u,",0);"):o.push("zero(",f,");");break;case"wrap":var p=s.slice(),g=s.slice();e[l]<0?(p[u]="s["+u+"]-2",g[u]="0"):(p[u]="s["+u+"]-1",g[u]="1"),0===r?o.push("if(s[",u,"]>2){dst.set(",s.join(),",",u,",0.5*(src.get(",p.join(),")-src.get(",g.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):o.push("if(s[",u,"]>2){diff(",f,",src.pick(",p.join(),")",c,",src.pick(",g.join(),")",c,");}else{zero(",f,");};");break;default:throw new Error("ndarray-gradient: Invalid boundary condition")}}r>0&&o.push("};")}var r=t.join(),i=c[r];if(i)return i;for(var a=t.length,o=["function gradient(dst,src){var s=src.shape.slice();"],s=0;1<s;++s){for(var u=[],d=0;a>d;++d)s&1<=s;++s)v.push("grad"+s),m.push(n(s));v.push(o.join(""));var y=Function.apply(void 0,v),i=y.apply(void 0,m);return l[r]=i,i}function a(t,e,r){if(Array.isArray(r)){if(r.length!==e.dimension)throw new Error("ndarray-gradient: invalid boundary conditions")}else r="string"==typeof r?o(e.dimension,r):o(e.dimension,"clamp");if(t.dimension!==e.dimension+1)throw new Error("ndarray-gradient: output dimension must be +1 input dimension");if(t.shape[e.dimension]!==e.dimension)throw new Error("ndarray-gradient: output shape must match input shape");for(var n=0;nr;++r){t[r]=o[(n+1)*n+r];for(var i=0;n>i;++i)t[r]+=o[(n+1)*i+r]*e[i]}for(var a=o[(n+1)*(n+1)-1],i=0;n>i;++i)a+=o[(n+1)*i+n]*e[i];for(var s=1/a,r=0;n>r;++r)t[r]*=s;return t}),t}var i=t("ndarray-warp"),a=t("gl-matrix-invert");e.exports=n},{"gl-matrix-invert":139,"ndarray-warp":224}],218:[function(t,e,r){"use strict";function n(t,e){var r=Math.floor(e),n=e-r,i=r>=0&&r=0&&r+1=0&&n=0&&n+1=0&&s=0&&s+1=0&&i=0&&i+1=0&&l=0&&l+1=0&&h=0&&h+1e;++e)r=+arguments[e+1],i[e]=Math.floor(r),a[e]=r-i[e],o[e]=0<=i[e]&&i[e]e;++e){for(c=1,u=t.offset,l=0;n>l;++l)if(e&1<>",rrshift:">>>"};!function(){for(var t in l){var e=l[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var c={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in c){var e=c[t];r[t]=a({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var u={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in u){var e=u[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var f=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=o({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=o({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=o({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":83}],220:[function(t,e,r){"use strict";var n=t("ndarray"),i=t("./doConvert.js");e.exports=function(t,e){for(var r=[],a=t,o=1;a instanceof Array;)r.push(a.length),o*=a.length,a=a[0];return 0===r.length?n():(e||(e=n(new Float64Array(o),r)),i(e,t),e)}},{"./doConvert.js":221,ndarray:225}],221:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}",args:[{name:"_inline_1_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_1_i","_inline_1_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},funcName:"convert",blockSize:64})},{"cwise-compiler":83}],222:[function(t,e,r){"use strict";function n(t){switch(t){case"uint8":return[l.mallocUint8,l.freeUint8];case"uint16":return[l.mallocUint16,l.freeUint16];case"uint32":return[l.mallocUint32,l.freeUint32];case"int8":return[l.mallocInt8,l.freeInt8];case"int16":return[l.mallocInt16,l.freeInt16];case"int32":return[l.mallocInt32,l.freeInt32];case"float32":return[l.mallocFloat,l.freeFloat];case"float64":return[l.mallocDouble,l.freeDouble];default:return null}}function i(t){for(var e=[],r=0;t>r;++r)e.push("s"+r);for(var r=0;t>r;++r)e.push("n"+r);for(var r=1;t>r;++r)e.push("d"+r);for(var r=1;t>r;++r)e.push("e"+r);for(var r=1;t>r;++r)e.push("f"+r);return e}function a(t,e){function r(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function a(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}var o=["'use strict'"],s=["ndarrayInsertionSort",t.join("d"),e].join(""),l=["left","right","data","offset"].concat(i(t.length)),c=n(e),u=["i,j,cptr,ptr=left*s0+offset"];if(t.length>1){for(var f=[],h=1;h1){o.push("dptr=0;sptr=ptr");for(var h=t.length-1;h>=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"left){","dptr=0","sptr=cptr-s0");for(var h=1;hb){break __l}"].join(""));for(var h=t.length-1;h>=1;--h)o.push("sptr+=e"+h,"dptr+=f"+h,"}");o.push("dptr=cptr;sptr=cptr-s0");for(var h=t.length-1;h>=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"left)&&("+r("cptr-s0")+">scratch)){",a("cptr",r("cptr-s0")),"cptr-=s0","}",a("cptr","scratch"));if(o.push("}"),t.length>1&&c&&o.push("free(scratch)"),o.push("} return "+s),c){var p=new Function("malloc","free",o.join("\n"));return p(c[0],c[1])}var p=new Function(o.join("\n"));return p()}function o(t,e,r){function a(t){return["(offset+",t,"*s0)"].join("")}function o(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function s(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}function l(e,r,n){if(1===e.length)_.push("ptr0="+a(e[0]));else for(var i=0;i=0;--i){var o=t[i];0!==o&&_.push(["for(i",o,"=0;i",o,"1)for(var i=0;i1?_.push("ptr_shift+=d"+o):_.push("ptr0+=d"+o),_.push("}"))}}function u(e,r,n,i){if(1===r.length)_.push("ptr0="+a(r[0]));else{for(var o=0;o1)for(var o=0;o=1;--o)n&&_.push("pivot_ptr+=f"+o),r.length>1?_.push("ptr_shift+=e"+o):_.push("ptr0+=e"+o),_.push("}")}function f(){t.length>1&&A&&_.push("free(pivot1)","free(pivot2)")}function h(e,r){var n="el"+e,i="el"+r;if(t.length>1){var s="__l"+ ++M;u(s,[n,i],!1,["comp=",o("ptr0"),"-",o("ptr1"),"\n","if(comp>0){tmp0=",n,";",n,"=",i,";",i,"=tmp0;break ",s,"}\n","if(comp<0){break ",s,"}"].join(""))}else _.push(["if(",o(a(n)),">",o(a(i)),"){tmp0=",n,";",n,"=",i,";",i,"=tmp0}"].join(""))}function d(e,r){t.length>1?l([e,r],!1,s("ptr0",o("ptr1"))):_.push(s(a(e),o(a(r))))}function p(e,r,n){if(t.length>1){var i="__l"+ ++M;u(i,[r],!0,[e,"=",o("ptr0"),"-pivot",n,"[pivot_ptr]\n","if(",e,"!==0){break ",i,"}"].join(""))}else _.push([e,"=",o(a(r)),"-pivot",n].join(""))}function g(e,r){t.length>1?l([e,r],!1,["tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1","tmp")].join("")):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1","tmp")].join(""))}function v(e,r,n){t.length>1?(l([e,r,n],!1,["tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1",o("ptr2")),"\n",s("ptr2","tmp")].join("")),_.push("++"+r,"--"+n)):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","ptr2=",a(n),"\n","++",r,"\n","--",n,"\n","tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1",o("ptr2")),"\n",s("ptr2","tmp")].join(""))}function m(t,e){g(t,e),_.push("--"+e)}function y(e,r,n){t.length>1?l([e,r],!0,[s("ptr0",o("ptr1")),"\n",s("ptr1",["pivot",n,"[pivot_ptr]"].join(""))].join("")):_.push(s(a(e),o(a(r))),s(a(r),"pivot"+n))}function b(e,r){_.push(["if((",r,"-",e,")<=",c,"){\n","insertionSort(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}else{\n",w,"(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}"].join(""))}function x(e,r,n){t.length>1?(_.push(["__l",++M,":while(true){"].join("")),l([e],!0,["if(",o("ptr0"),"!==pivot",r,"[pivot_ptr]){break __l",M,"}"].join("")),_.push(n,"}")):_.push(["while(",o(a(e)),"===pivot",r,"){",n,"}"].join(""))}var _=["'use strict'"],w=["ndarrayQuickSort",t.join("d"),e].join(""),k=["left","right","data","offset"].concat(i(t.length)),A=n(e),M=0;_.push(["function ",w,"(",k.join(","),"){"].join(""));var T=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1=0","comp_pivot2=0","comp=0"];if(t.length>1){for(var E=[],L=1;LL;++L)T.push("b_ptr"+L);T.push("ptr3","ptr4","ptr5","ptr6","ptr7","pivot_ptr","ptr_shift","elementSize="+E.join("*")),A?T.push("pivot1=malloc(elementSize)","pivot2=malloc(elementSize)"):T.push("pivot1=new Array(elementSize),pivot2=new Array(elementSize)")}else T.push("pivot1","pivot2");if(_.push("var "+T.join(",")),h(1,2),h(4,5),h(1,3),h(2,3),h(1,4),h(3,4),h(2,5),h(2,3),h(4,5),t.length>1?l(["el1","el2","el3","el4","el5","index1","index3","index5"],!0,["pivot1[pivot_ptr]=",o("ptr1"),"\n","pivot2[pivot_ptr]=",o("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",o("ptr0"),"\n","y=",o("ptr2"),"\n","z=",o("ptr4"),"\n",s("ptr5","x"),"\n",s("ptr6","y"),"\n",s("ptr7","z")].join("")):_.push(["pivot1=",o(a("el2")),"\n","pivot2=",o(a("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",o(a("el1")),"\n","y=",o(a("el3")),"\n","z=",o(a("el5")),"\n",s(a("index1"),"x"),"\n",s(a("index3"),"y"),"\n",s(a("index5"),"z")].join("")),d("index2","left"),d("index4","right"),_.push("if(pivots_are_equal){"),_.push("for(k=less;k<=great;++k){"),p("comp","k",1),_.push("if(comp===0){continue}"),_.push("if(comp<0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),_.push("while(true){"),p("comp","great",1),_.push("if(comp>0){"),_.push("great--"),_.push("}else if(comp<0){"),v("k","less","great"),_.push("break"),_.push("}else{"),m("k","great"),_.push("break"),_.push("}"),_.push("}"),_.push("}"),_.push("}"),_.push("}else{"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1<0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2>0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp>0){"),_.push("if(--greatindex5){"),x("less",1,"++less"),x("great",2,"--great"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1===0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2===0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp===0){"),_.push("if(--great1&&A){var S=new Function("insertionSort","malloc","free",_.join("\n"));return S(r,A[0],A[1])}var S=new Function("insertionSort",_.join("\n"));return S(r)}function s(t,e){var r=["'use strict'"],n=["ndarraySortWrapper",t.join("d"),e].join(""),s=["array"];r.push(["function ",n,"(",s.join(","),"){"].join(""));for(var l=["data=array.data,offset=array.offset|0,shape=array.shape,stride=array.stride"],u=0;u0?l.push(["d",v,"=s",v,"-d",p,"*n",p].join("")):l.push(["d",v,"=s",v].join("")),p=v);var d=t.length-1-u;0!==d&&(g>0?l.push(["e",d,"=s",d,"-e",g,"*n",g,",f",d,"=",f[d],"-f",g,"*n",g].join("")):l.push(["e",d,"=s",d,",f",d,"=",f[d]].join("")),g=d)}r.push("var "+l.join(","));var m=["0","n0-1","data","offset"].concat(i(t.length));r.push(["if(n0<=",c,"){","insertionSort(",m.join(","),")}else{","quickSort(",m.join(","),")}"].join("")),r.push("}return "+n);var y=new Function("insertionSort","quickSort",r.join("\n")),b=a(t,e),x=o(t,e,b);return y(b,x)}var l=t("typedarray-pool"),c=32;e.exports=s},{"typedarray-pool":282}],223:[function(t,e,r){"use strict";function n(t){var e=t.order,r=t.dtype,n=[e,r],o=n.join(":"),s=a[o];return s||(a[o]=s=i(e,r)),s(t),t}var i=t("./lib/compile_sort.js"),a={};e.exports=n},{"./lib/compile_sort.js":222}],224:[function(t,e,r){"use strict";var n=t("ndarray-linear-interpolate"),i=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=new Array(_inline_18_arg4_)}",args:[{name:"_inline_18_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_18_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_18_arg2_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_18_arg3_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_18_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_19_arg2_(this_warped,_inline_19_arg0_),_inline_19_arg1_=_inline_19_arg3_.apply(void 0,this_warped)}",args:[{name:"_inline_19_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_19_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_19_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_19_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_19_arg4_",lvalue:!1,rvalue:!1,count:0}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warpND",blockSize:64}),a=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0]}", -args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_22_arg2_(this_warped,_inline_22_arg0_),_inline_22_arg1_=_inline_22_arg3_(_inline_22_arg4_,this_warped[0])}",args:[{name:"_inline_22_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_22_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_22_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_22_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_22_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp1D",blockSize:64}),o=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_25_arg2_(this_warped,_inline_25_arg0_),_inline_25_arg1_=_inline_25_arg3_(_inline_25_arg4_,this_warped[0],this_warped[1])}",args:[{name:"_inline_25_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_25_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_25_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_25_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_25_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp2D",blockSize:64}),s=t("cwise/lib/wrapper")({args:["index","array","scalar","scalar","scalar"],pre:{body:"{this_warped=[0,0,0]}",args:[],thisVars:["this_warped"],localVars:[]},body:{body:"{_inline_28_arg2_(this_warped,_inline_28_arg0_),_inline_28_arg1_=_inline_28_arg3_(_inline_28_arg4_,this_warped[0],this_warped[1],this_warped[2])}",args:[{name:"_inline_28_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_28_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_28_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_28_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_28_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_warped"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"warp3D",blockSize:64});e.exports=function(t,e,r){switch(e.shape.length){case 1:a(t,r,n.d1,e);break;case 2:o(t,r,n.d2,e);break;case 3:s(t,r,n.d3,e);break;default:i(t,r,n.bind(void 0,e),e.shape.length)}return t}},{"cwise/lib/wrapper":86,"ndarray-linear-interpolate":218}],225:[function(t,e,r){function n(t,e){return t[0]-e[0]}function i(){var t,e=this.stride,r=new Array(e.length);for(t=0;te&&(r="View_Nil"+t);var n="generic"===t;if(-1===e){var a="function "+r+"(a){this.data=a;};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+r+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+r+"(a){return new "+r+"(a);}",o=new Function(a);return o()}if(0===e){var a="function "+r+"(a,d) {this.data = a;this.offset = d};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+r+"_copy() {return new "+r+"(this.data,this.offset)};proto.pick=function "+r+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+r+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+r+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+r+"(a,b,c,d){return new "+r+"(a,d)}",o=new Function("TrivialArray",a);return o(f[t][0])}var a=["'use strict'"],s=l(e),c=s.map(function(t){return"i"+t}),u="this.offset+"+s.map(function(t){return"this.stride["+t+"]*i"+t}).join("+"),h=s.map(function(t){return"b"+t}).join(","),d=s.map(function(t){return"c"+t}).join(",");a.push("function "+r+"(a,"+h+","+d+",d){this.data=a","this.shape=["+h+"]","this.stride=["+d+"]","this.offset=d|0}","var proto="+r+".prototype","proto.dtype='"+t+"'","proto.dimension="+e),a.push("Object.defineProperty(proto,'size',{get:function "+r+"_size(){return "+s.map(function(t){return"this.shape["+t+"]"}).join("*"),"}})"),1===e?a.push("proto.order=[0]"):(a.push("Object.defineProperty(proto,'order',{get:"),4>e?(a.push("function "+r+"_order(){"),2===e?a.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+c.join(",")+",v){"),n?a.push("return this.data.set("+u+",v)}"):a.push("return this.data["+u+"]=v}"),a.push("proto.get=function "+r+"_get("+c.join(",")+"){"),n?a.push("return this.data.get("+u+")}"):a.push("return this.data["+u+"]}"),a.push("proto.index=function "+r+"_index(",c.join(),"){return "+u+"}"),a.push("proto.hi=function "+r+"_hi("+c.join(",")+"){return new "+r+"(this.data,"+s.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+s.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=s.map(function(t){return"a"+t+"=this.shape["+t+"]"}),g=s.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+c.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+g.join(","));for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){d=i"+v+"|0;b+=c"+v+"*d;a"+v+"-=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+c.join(",")+"){var "+s.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+s.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'){d=i"+v+"|0;if(d<0){c+=b"+v+"*(a"+v+"-1);a"+v+"=ceil(-a"+v+"/d)}else{a"+v+"=ceil(a"+v+"/d)}b"+v+"*=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"b"+t}).join(",")+",c)}");for(var m=new Array(e),y=new Array(e),v=0;e>v;++v)m[v]="a[i"+v+"]",y[v]="b[i"+v+"]";a.push("proto.transpose=function "+r+"_transpose("+c+"){"+c.map(function(t,e){return t+"=("+t+"===undefined?"+e+":"+t+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+r+"(this.data,"+m.join(",")+","+y.join(",")+",this.offset)}"),a.push("proto.pick=function "+r+"_pick("+c+"){var a=[],b=[],c=this.offset");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+s.map(function(t){return"shape["+t+"]"}).join(",")+","+s.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}");var o=new Function("CTOR_LIST","ORDER",a.join("\n"));return o(f[t],i)}function o(t){if(c(t))return"buffer";if(u)switch(Object.prototype.toString.call(t)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(t)?"array":"generic"}function s(t,e,r,n){if(void 0===t){var i=f.array[0];return i([])}"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var s=e.length;if(void 0===r){r=new Array(s);for(var l=s-1,c=1;l>=0;--l)r[l]=c,c*=e[l]}if(void 0===n){n=0;for(var l=0;s>l;++l)r[l]<0&&(n-=(e[l]-1)*r[l])}for(var u=o(t),h=f[u];h.length<=s+1;)h.push(a(u,h.length-1));var i=h[s+1];return i(t,e,r,n)}var l=t("iota-array"),c=t("is-buffer"),u="undefined"!=typeof Float64Array,f={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=s},{"iota-array":202,"is-buffer":203}],226:[function(t,e,r){"use strict";function n(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return 0>e?-a:a;var r=i.hi(t),n=i.lo(t);return e>t==t>0?n===o?(r+=1,n=0):n+=1:0===n?(n=o,r-=1):n-=1,i.pack(n,r)}var i=t("double-bits"),a=Math.pow(2,-1074),o=-1>>>0;e.exports=n},{"double-bits":89}],227:[function(t,e,r){var n=1e-6,i=1e-6;r.vertexNormals=function(t,e,r){for(var i=e.length,a=new Array(i),o=void 0===r?n:r,s=0;i>s;++s)a[s]=[0,0,0];for(var s=0;sx;++x)v[x]=d[x]-p[x],m+=v[x]*v[x],y[x]=g[x]-p[x],b+=y[x]*y[x];if(m*b>o)for(var _=a[u],w=1/Math.sqrt(m*b),x=0;3>x;++x){var k=(x+1)%3,A=(x+2)%3;_[x]+=w*(y[k]*v[A]-y[A]*v[k])}}for(var s=0;i>s;++s){for(var _=a[s],M=0,x=0;3>x;++x)M+=_[x]*_[x];if(M>o)for(var w=1/Math.sqrt(M),x=0;3>x;++x)_[x]*=w;else for(var x=0;3>x;++x)_[x]=0}return a},r.faceNormals=function(t,e,r){for(var n=t.length,a=new Array(n),o=void 0===r?i:r,s=0;n>s;++s){for(var l=t[s],c=new Array(3),u=0;3>u;++u)c[u]=e[l[u]];for(var f=new Array(3),h=new Array(3),u=0;3>u;++u)f[u]=c[1][u]-c[0][u],h[u]=c[2][u]-c[0][u];for(var d=new Array(3),p=0,u=0;3>u;++u){var g=(u+1)%3,v=(u+2)%3;d[u]=f[g]*h[v]-f[v]*h[g],p+=d[u]*d[u]}p=p>o?1/Math.sqrt(p):0;for(var u=0;3>u;++u)d[u]*=p;a[s]=d}return a}},{}],228:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c){var u=e+a+c;if(f>0){var f=Math.sqrt(u+1);t[0]=.5*(o-l)/f,t[1]=.5*(s-n)/f,t[2]=.5*(r-a)/f,t[3]=.5*f}else{var h=Math.max(e,a,c),f=Math.sqrt(2*h-u+1);e>=h?(t[0]=.5*f,t[1]=.5*(i+r)/f,t[2]=.5*(s+n)/f,t[3]=.5*(o-l)/f):a>=h?(t[0]=.5*(r+i)/f,t[1]=.5*f,t[2]=.5*(l+o)/f,t[3]=.5*(s-n)/f):(t[0]=.5*(n+s)/f,t[1]=.5*(o+l)/f,t[2]=.5*f,t[3]=.5*(r-i)/f)}return t}e.exports=n},{}],229:[function(t,e,r){"use strict";function n(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function i(t,e,r,n){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2)+Math.pow(n,2))}function a(t,e){var r=e[0],n=e[1],a=e[2],o=e[3],s=i(r,n,a,o);s>1e-6?(t[0]=r/s,t[1]=n/s,t[2]=a/s,t[3]=o/s):(t[0]=t[1]=t[2]=0,t[3]=1)}function o(t,e,r){this.radius=l([r]),this.center=l(e),this.rotation=l(t),this.computedRadius=this.radius.curve(0),this.computedCenter=this.center.curve(0),this.computedRotation=this.rotation.curve(0),this.computedUp=[.1,0,0],this.computedEye=[.1,0,0],this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.recalcMatrix(0)}function s(t){t=t||{};var e=t.center||[0,0,0],r=t.rotation||[0,0,0,1],n=t.radius||1;e=[].slice.call(e,0,3),r=[].slice.call(r,0,4),a(r,r);var i=new o(r,e,Math.log(n));return i.setDistanceLimits(t.zoomMin,t.zoomMax),("eye"in t||"up"in t)&&i.lookAt(0,t.eye,t.center,t.up),i}e.exports=s;var l=t("filtered-vector"),c=t("gl-mat4/lookAt"),u=t("gl-mat4/fromQuat"),f=t("gl-mat4/invert"),h=t("./lib/quatFromFrame"),d=o.prototype;d.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())},d.recalcMatrix=function(t){this.radius.curve(t),this.center.curve(t),this.rotation.curve(t);var e=this.computedRotation;a(e,e);var r=this.computedMatrix;u(r,e);var n=this.computedCenter,i=this.computedEye,o=this.computedUp,s=Math.exp(this.computedRadius[0]);i[0]=n[0]+s*r[2],i[1]=n[1]+s*r[6],i[2]=n[2]+s*r[10],o[0]=r[1],o[1]=r[5],o[2]=r[9];for(var l=0;3>l;++l){for(var c=0,f=0;3>f;++f)c+=r[l+4*f]*i[f];r[12+l]=-c}},d.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;16>n;++n)e[n]=r[n];return e}return r},d.idle=function(t){this.center.idle(t),this.radius.idle(t),this.rotation.idle(t)},d.flush=function(t){this.center.flush(t),this.radius.flush(t),this.rotation.flush(t)},d.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=a[1],s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],f=a[4],h=a[8],d=u*o+f*s+h*l;u-=o*d,f-=s*d,h-=l*d;var p=n(u,f,h);u/=p,f/=p,h/=p;var g=a[2],v=a[6],m=a[10],y=g*o+v*s+m*l,b=g*u+v*f+m*h;g-=y*o+b*u,v-=y*s+b*f,m-=y*l+b*h;var x=n(g,v,m);g/=x,v/=x,m/=x;var _=u*e+o*r,w=f*e+s*r,k=h*e+l*r;this.center.move(t,_,w,k);var A=Math.exp(this.computedRadius[0]);A=Math.max(1e-4,A+i),this.radius.set(t,Math.log(A))},d.rotate=function(t,e,r,a){this.recalcMatrix(t),e=e||0,r=r||0;var o=this.computedMatrix,s=o[0],l=o[4],c=o[8],u=o[1],f=o[5],h=o[9],d=o[2],p=o[6],g=o[10],v=e*s+r*u,m=e*l+r*f,y=e*c+r*h,b=-(p*y-g*m),x=-(g*v-d*y),_=-(d*m-p*v),w=Math.sqrt(Math.max(0,1-Math.pow(b,2)-Math.pow(x,2)-Math.pow(_,2))),k=i(b,x,_,w);k>1e-6?(b/=k,x/=k,_/=k,w/=k):(b=x=_=0,w=1);var A=this.computedRotation,M=A[0],T=A[1],E=A[2],L=A[3],S=M*w+L*b+T*_-E*x,C=T*w+L*x+E*b-M*_,z=E*w+L*_+M*x-T*b,P=L*w-M*b-T*x-E*_;if(a){b=d,x=p,_=g;var R=Math.sin(a)/n(b,x,_);b*=R,x*=R,_*=R,w=Math.cos(e),S=S*w+P*b+C*_-z*x,C=C*w+P*x+z*b-S*_,z=z*w+P*_+S*x-C*b,P=P*w-S*b-C*x-z*_}var O=i(S,C,z,P);O>1e-6?(S/=O,C/=O,z/=O,P/=O):(S=C=z=0,P=1),this.rotation.set(t,S,C,z,P)},d.lookAt=function(t,e,r,n){this.recalcMatrix(t),r=r||this.computedCenter,e=e||this.computedEye,n=n||this.computedUp;var i=this.computedMatrix;c(i,e,r,n);var o=this.computedRotation;h(o,i[0],i[1],i[2],i[4],i[5],i[6],i[8],i[9],i[10]),a(o,o),this.rotation.set(t,o[0],o[1],o[2],o[3]);for(var s=0,l=0;3>l;++l)s+=Math.pow(r[l]-e[l],2);this.radius.set(t,.5*Math.log(Math.max(s,1e-6))),this.center.set(t,r[0],r[1],r[2])},d.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},d.setMatrix=function(t,e){var r=this.computedRotation;h(r,e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]),a(r,r),this.rotation.set(t,r[0],r[1],r[2],r[3]);var n=this.computedMatrix;f(n,e);var i=n[15];if(Math.abs(i)>1e-6){var o=n[12]/i,s=n[13]/i,l=n[14]/i;this.recalcMatrix(t);var c=Math.exp(this.computedRadius[0]);this.center.set(t,o-n[2]*c,s-n[6]*c,l-n[10]*c),this.radius.idle(t)}else this.center.idle(t),this.radius.idle(t)},d.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},d.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-(1/0),e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},d.getDistanceLimits=function(t){var e=this.radius.bounds;return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},d.toJSON=function(){return this.recalcMatrix(this.lastT()),{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}},d.fromJSON=function(t){var e=this.lastT(),r=t.center;r&&this.center.set(e,r[0],r[1],r[2]);var n=t.rotation;n&&this.rotation.set(e,n[0],n[1],n[2],n[3]);var i=t.distance;i&&i>0&&this.radius.set(e,Math.log(i)),this.setDistanceLimits(t.zoomMin,t.zoomMax)}},{"./lib/quatFromFrame":228,"filtered-vector":96,"gl-mat4/fromQuat":125,"gl-mat4/invert":128,"gl-mat4/lookAt":129}],230:[function(t,e,r){"use strict";var n=t("repeat-string");e.exports=function(t,e,r){return r="undefined"!=typeof r?r+"":" ",n(r,e)+t}},{"repeat-string":246}],231:[function(t,e,r){e.exports=function(t,e){e||(e=[0,""]),t=String(t);var r=parseFloat(t,10);return e[0]=r,e[1]=t.match(/[\d.\-\+]*\s*(.*)/)[1]||"",e}},{}],232:[function(t,e,r){"use strict";function n(t){var e=t.length;if(i>e){for(var r=1,n=0;e>n;++n)for(var o=0;n>o;++o)if(t[n]n;++n)s[n]=0;for(var r=1,n=0;e>n;++n)if(!s[n]){var l=1;s[n]=1;for(var o=t[n];o!==n;o=t[o]){if(s[o])return a.freeUint8(s),0;l+=1,s[o]=1}1&l||(r=-r)}return a.freeUint8(s),r}e.exports=n;var i=32,a=t("typedarray-pool")},{"typedarray-pool":282}],233:[function(t,e,r){"use strict";function n(t){var e=t.length;switch(e){case 0:case 1:return 0;case 2:return t[1]}var r,n,i,s=a.mallocUint32(e),l=a.mallocUint32(e),c=0;for(o(t,l),i=0;e>i;++i)s[i]=t[i];for(i=e-1;i>0;--i)n=l[i],r=s[i],s[i]=s[n],s[n]=r,l[i]=l[r],l[r]=n,c=(c+r)*i;return a.freeUint32(l),a.freeUint32(s),c}function i(t,e,r){switch(t){case 0:return r?r:[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}r=r||new Array(t);var n,i,a,o=1;for(r[0]=0,a=1;t>a;++a)r[a]=a,o=o*a|0;for(a=t-1;a>0;--a)n=e/o|0,e=e-n*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}var a=t("typedarray-pool"),o=t("invert-permutation");r.rank=n,r.unrank=i},{"invert-permutation":201,"typedarray-pool":282}],234:[function(t,e,r){"use strict";function n(t,e){function r(t,e){var r=c[e][t[e]];r.splice(r.indexOf(t),1)}function n(t,n,a){for(var o,s,l,u=0;2>u;++u)if(c[u][n].length>0){o=c[u][n][0],l=u;break}s=o[1^l];for(var f=0;2>f;++f)for(var h=c[f][n],d=0;d0&&(o=p,s=g,l=f)}return a?s:(o&&r(o,l),s)}function a(t,a){var o=c[a][t][0],s=[t];r(o,a);for(var l=o[1^a];;){for(;l!==t;)s.push(l),l=n(s[s.length-2],l,!1);if(c[0][t].length+c[1][t].length===0)break;var u=s[s.length-1],f=t,h=s[1],d=n(u,f,!0);if(i(e[u],e[f],e[h],e[d])<0)break;s.push(t),l=n(u,f)}return s}function o(t,e){return e[1]===e[e.length-1]}for(var s=0|e.length,l=t.length,c=[new Array(s),new Array(s)],u=0;s>u;++u)c[0][u]=[],c[1][u]=[];for(var u=0;l>u;++u){var f=t[u];c[0][f[0]].push(f),c[1][f[1]].push(f)}for(var h=[],u=0;s>u;++u)c[0][u].length+c[1][u].length===0&&h.push([u]);for(var u=0;s>u;++u)for(var d=0;2>d;++d){for(var p=[];c[d][u].length>0;){var g=(c[0][u].length,a(u,d));o(p,g)?p.push.apply(p,g):(p.length>0&&h.push(p),p=g)}p.length>0&&h.push(p)}return h}e.exports=n;var i=t("compare-angle")},{"compare-angle":74}],235:[function(t,e,r){"use strict";function n(t,e){for(var r=i(t,e.length),n=new Array(e.length),a=new Array(e.length),o=[],s=0;s=l&&o.push(s)}for(;o.length>0;){var c=o.pop();n[c]=!1;for(var u=r[c],s=0;sn;++n)r[n]=e;return r}function i(t){for(var e=new Array(t),r=0;t>r;++r)e[r]=[];return e}function a(t,e){function r(t){for(var r=t.length,n=[0],i=0;r>i;++i){var a=e[t[i]],o=e[t[(i+1)%r]],s=c(-a[0],a[1]),l=c(-a[0],o[1]),f=c(o[0],a[1]),h=c(o[0],o[1]);n=u(n,u(u(s,l),u(f,h)))}return n[n.length-1]>0}function a(t){for(var e=t.length,r=0;e>r;++r)if(!O[t[r]])return!1;return!0}var d=h(t,e);t=d[0],e=d[1];for(var p=e.length,g=(t.length,o(t,e.length)),v=0;p>v;++v)if(g[v].length%2===1)throw new Error("planar-graph-to-polyline: graph must be manifold");var m=s(t,e);m=m.filter(r);for(var y=m.length,b=new Array(y),x=new Array(y),v=0;y>v;++v){b[v]=v;var _=new Array(y),w=m[v].map(function(t){return e[t]}),k=l([w]),A=0;t:for(var M=0;y>M;++M)if(_[M]=0,v!==M){for(var T=m[M],E=T.length,L=0;E>L;++L){var S=k(e[T[L]]);if(0!==S){0>S&&(_[M]=1,A+=1);continue t}}_[M]=1,A+=1}x[v]=[A,v,_]}x.sort(function(t,e){return e[0]-t[0]});for(var v=0;y>v;++v)for(var _=x[v],C=_[1],z=_[2],M=0;y>M;++M)z[M]&&(b[M]=C);for(var P=i(y),v=0;y>v;++v)P[v].push(b[v]),P[b[v]].push(v);for(var R={},O=n(p,!1),v=0;y>v;++v)for(var T=m[v],E=T.length,M=0;E>M;++M){var I=T[M],N=T[(M+1)%E],j=Math.min(I,N)+":"+Math.max(I,N);if(j in R){var F=R[j];P[F].push(v),P[v].push(F),O[I]=O[N]=!0}else R[j]=v}for(var B=[],D=n(y,-1),v=0;y>v;++v)b[v]!==v||a(m[v])?D[v]=-1:(B.push(v),D[v]=0);for(var d=[];B.length>0;){var U=B.pop(),V=P[U];f(V,function(t,e){return t-e});var q,H=V.length,G=D[U];if(0===G){var T=m[U];q=[T]}for(var v=0;H>v;++v){var Y=V[v];if(!(D[Y]>=0)&&(D[Y]=1^G,B.push(Y),0===G)){var T=m[Y];a(T)||(T.reverse(),q.push(T))}}0===G&&d.push(q)}return d}e.exports=a;var o=t("edges-to-adjacency-list"),s=t("planar-dual"),l=t("point-in-big-polygon"),c=t("two-product"),u=t("robust-sum"),f=t("uniq"),h=t("./lib/trim-leaves")},{"./lib/trim-leaves":235,"edges-to-adjacency-list":91,"planar-dual":234,"point-in-big-polygon":237,"robust-sum":258,"two-product":280,uniq:284}],237:[function(t,e,r){function n(){return!0}function i(t){return function(e,r){var i=t[e];return i?!!i.queryPoint(r,n):!1}}function a(t){for(var e={},r=0;rn)return 1;var i=t[n];if(!i){if(!(n>0&&e[n]===r[0]))return 1;i=t[n-1]}for(var a=1;i;){var o=i.key,s=f(r,o[0],o[1]);if(o[0][0]s)i=i.left;else{if(!(s>0))return 0;a=-1,i=i.right}else if(s>0)i=i.left;else{if(!(0>s))return 0;a=1,i=i.right}}return a}}function s(t){return 1}function l(t){return function(e){return t(e[0],e[1])?0:1}}function c(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}function u(t){for(var e=t.length,r=[],n=[],i=0;e>i;++i)for(var u=t[i],f=u.length,d=f-1,p=0;f>p;d=p++){var g=u[d],v=u[p];g[0]===v[0]?n.push([g,v]):r.push([g,v])}if(0===r.length)return 0===n.length?s:l(a(n));var m=h(r),y=o(m.slabs,m.coordinates);return 0===n.length?y:c(a(n),y)}e.exports=u;var f=t("robust-orientation")[3],h=t("slab-decomposition"),d=t("interval-tree-1d"),p=t("binary-search-bounds")},{"binary-search-bounds":47,"interval-tree-1d":200,"robust-orientation":253,"slab-decomposition":269}],238:[function(t,e,r){"use strict";function n(t,e,r,n,s){i.length=x+_)if(0>x)0>_&&0>h?(_=0,-h>=c?(x=1,y=c+2*h+p):(x=-h/c,y=h*x+p)):(x=0,d>=0?(_=0,y=p):-d>=f?(_=1,y=f+2*d+p):(_=-d/f,y=d*_+p));else if(0>_)_=0,h>=0?(x=0,y=p):-h>=c?(x=1,y=c+2*h+p):(x=-h/c,y=h*x+p);else{var w=1/b;x*=w,_*=w,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p}else{var k,A,M,T;0>x?(k=u+h,A=f+d,A>k?(M=A-k,T=c-2*u+f,M>=T?(x=1,_=0,y=c+2*h+p):(x=M/T,_=1-x,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)):(x=0,0>=A?(_=1,y=f+2*d+p):d>=0?(_=0,y=p):(_=-d/f,y=d*_+p))):0>_?(k=u+d,A=c+h,A>k?(M=A-k,T=c-2*u+f,M>=T?(_=1,x=0,y=f+2*d+p):(_=M/T,x=1-_,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)):(_=0,0>=A?(x=1,y=c+2*h+p):h>=0?(x=0,y=p):(x=-h/c,y=h*x+p))):(M=f+d-u-h,0>=M?(x=0,_=1,y=f+2*d+p):(T=c-2*u+f,M>=T?(x=1,_=0,y=c+2*h+p):(x=M/T,_=1-x,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)))}for(var E=1-x-_,l=0;ly?0:y}var i=new Float64Array(4),a=new Float64Array(4),o=new Float64Array(4);e.exports=n},{}],239:[function(t,e,r){function n(){u&&s&&(u=!1,s.length?c=s.concat(c):f=-1,c.length&&i())}function i(){if(!u){var t=setTimeout(n);u=!0;for(var e=c.length;e;){for(s=c,c=[];++f1)for(var r=1;ra;++a)n[a]=i(t[a],e[a]);return n}var i=t("big-rat/add");e.exports=n},{"big-rat/add":31}],242:[function(t,e,r){"use strict";function n(t){for(var e=new Array(t.length),r=0;rs;++s)o[s]=a(t[s],r);return o}var i=t("big-rat"),a=t("big-rat/mul");e.exports=n},{"big-rat":34,"big-rat/mul":43}],244:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),a=0;r>a;++a)n[a]=i(t[a],e[a]);return n}var i=t("big-rat/sub");e.exports=n},{"big-rat/sub":45}],245:[function(t,e,r){"use strict";function n(t){t.sort(a);for(var e=t.length,r=0,n=0;e>n;++n){var s=t[n],l=o(s);if(0!==l){if(r>0){var c=t[r-1];if(0===i(s,c)&&o(c)!==l){r-=1;continue}}t[r++]=s}}return t.length=r,t}var i=t("compare-cell"),a=t("compare-oriented-cell"),o=t("cell-orientation");e.exports=n},{"cell-orientation":66,"compare-cell":75,"compare-oriented-cell":76}],246:[function(t,e,r){"use strict";function n(t,e){if("string"!=typeof t)throw new TypeError("repeat-string expects a string.");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;for(i===t&&"undefined"!=typeof i||(i=t,a="");r>a.length&&e>0&&(1&e&&(a+=t),e>>=1);)t+=t;return a.substr(0,r)}var i,a="";e.exports=n},{}],247:[function(t,e,r){(function(t){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],248:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i];r=a+o;var s=r-a,l=o-s;l&&(t[--n]=r,r=l)}for(var c=0,i=n;e>i;++i){var a=t[i],o=r;r=a+o;var s=r-a,l=o-s;l&&(t[c++]=l)}return t[c++]=r,t.length=c,t}e.exports=n},{}],249:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m[",r,"][",n,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("");for(var e=[],r=0;rn;++n)t.push("det"+n),r.push("case ",n,":return det",n,"(m);");r.push("}var det=CACHE[m.length];if(!det)det=CACHE[m.length]=gen(m.length);return det(m);}return robustDeterminant"),t.push("CACHE","gen",r.join(""));var i=Function.apply(void 0,t);e.exports=i.apply(void 0,g.concat([g,l]));for(var n=0;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-2,"]"].join("")}return e}function a(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",a(t.slice(0,e)),",",a(t.slice(e)),")"].join("")}function o(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return o(e,t)}function s(t){return t&!0?"-":""}function l(t){if(2===t.length)return[["diff(",o(t[0][0],t[1][1]),",",o(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;rn;++n)r.push(["prod(m",t,"[",n,"],m",t,"[",n,"])"].join(""));return a(r)}function u(t){for(var e=[],r=[],o=i(t),s=0;t>s;++s)o[0][s]="1",o[t-1][s]="w"+s;for(var s=0;t>s;++s)0===(1&s)?e.push.apply(e,l(n(o,s))):r.push.apply(r,l(n(o,s)));for(var u=a(e),f=a(r),h="exactInSphere"+t,d=[],s=0;t>s;++s)d.push("m"+s);for(var p=["function ",h,"(",d.join(),"){"],s=0;t>s;++s){p.push("var w",s,"=",c(s,t),";");for(var g=0;t>g;++g)g!==s&&p.push("var w",s,"m",g,"=scale(w",s,",m",g,"[0]);")}p.push("var p=",u,",n=",f,",d=diff(p,n);return d[d.length-1];}return ",h);var x=new Function("sum","diff","prod","scale",p.join(""));return x(m,y,v,b)}function f(){return 0}function h(){return 0}function d(){return 0}function p(t){var e=_[t.length];return e||(e=_[t.length]=u(t.length)),e.apply(void 0,t)}function g(){for(;_.length<=x;)_.push(u(_.length));for(var t=[],r=["slow"],n=0;x>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function testInSphere(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;x>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var v=t("two-product"),m=t("robust-sum"),y=t("robust-subtract"),b=t("robust-scale"),x=6,_=[f,h,d];g()},{"robust-scale":255,"robust-subtract":257,"robust-sum":258,"two-product":280}],252:[function(t,e,r){"use strict";function n(t){for(var e="robustLinearSolve"+t+"d",r=["function ",e,"(A,b){return ["],n=0;t>n;++n){r.push("det([");for(var i=0;t>i;++i){i>0&&r.push(","),r.push("[");for(var a=0;t>a;++a)a>0&&r.push(","),a===n?r.push("+b[",i,"]"):r.push("+A[",i,"][",a,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var o=new Function("det",r.join(""));return o(6>t?s[t]:s)}function i(){return[0]}function a(t,e){return[[e[0]],[t[0][0]]]}function o(){for(;c.lengthi;++i)t.push("s"+i),r.push("case ",i,":return s",i,"(A,b);");r.push("}var s=CACHE[A.length];if(!s)s=CACHE[A.length]=g(A.length);return s(A,b)}return dispatchLinearSolve"),t.push("CACHE","g",r.join(""));var a=Function.apply(void 0,t);e.exports=a.apply(void 0,c.concat([c,n]));for(var i=0;l>i;++i)e.exports[i]=c[i]}var s=t("robust-determinant"),l=6,c=[i,a];o()},{"robust-determinant":249}],253:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-1,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join(""); -}function s(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;rc;++c)0===(1&c)?e.push.apply(e,s(n(a,c))):r.push.apply(r,s(n(a,c))),l.push("m"+c);var u=o(e),g=o(r),v="orientation"+t+"Exact",m=["function ",v,"(",l.join(),"){var p=",u,",n=",g,",d=sub(p,n);return d[d.length-1];};return ",v].join(""),y=new Function("sum","prod","scale","sub",m);return y(h,f,d,p)}function c(t){var e=_[t.length];return e||(e=_[t.length]=l(t.length)),e.apply(void 0,t)}function u(){for(;_.length<=g;)_.push(l(_.length));for(var t=[],r=["slow"],n=0;g>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;g>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var f=t("two-product"),h=t("robust-sum"),d=t("robust-scale"),p=t("robust-subtract"),g=5,v=1.1102230246251565e-16,m=(3+16*v)*v,y=(7+56*v)*v,b=l(3),x=l(4),_=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,r){var n,i=(t[1]-r[1])*(e[0]-r[0]),a=(t[0]-r[0])*(e[1]-r[1]),o=i-a;if(i>0){if(0>=a)return o;n=i+a}else{if(!(0>i))return o;if(a>=0)return o;n=-(i+a)}var s=m*n;return o>=s||-s>=o?o:b(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],d=a*c,p=o*l,g=o*s,v=i*c,m=i*l,b=a*s,_=u*(d-p)+f*(g-v)+h*(m-b),w=(Math.abs(d)+Math.abs(p))*Math.abs(u)+(Math.abs(g)+Math.abs(v))*Math.abs(f)+(Math.abs(m)+Math.abs(b))*Math.abs(h),k=y*w;return _>k||-_>k?_:x(t,e,r,n)}];u()},{"robust-scale":255,"robust-subtract":257,"robust-sum":258,"two-product":280}],254:[function(t,e,r){"use strict";function n(t,e){if(1===t.length)return a(e,t[0]);if(1===e.length)return a(t,e[0]);if(0===t.length||0===e.length)return[0];var r=[0];if(t.lengthu;++u){i(t[u],e,l);var f=s[1];a(f,l[0],s),s[0]&&(o[c++]=s[0]);var h=l[1],d=s[1],p=h+d,g=p-h,v=d-g;s[1]=p,v&&(o[c++]=v)}return s[1]&&(o[c++]=s[1]),0===c&&(o[c++]=0),o.length=c,o}var i=t("two-product"),a=t("two-sum");e.exports=n},{"two-product":280,"two-sum":281}],256:[function(t,e,r){"use strict";function n(t,e,r,n){for(var i=0;2>i;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),c=r[i],u=n[i],f=Math.min(c,u),h=Math.max(c,u);if(s>h||f>l)return!1}return!0}function i(t,e,r,i){var o=a(t,r,i),s=a(e,r,i);if(o>0&&s>0||0>o&&0>s)return!1;var l=a(r,t,e),c=a(i,t,e);return l>0&&c>0||0>l&&0>c?!1:0===o&&0===s&&0===l&&0===c?n(t,e,r,i):!0}e.exports=i;var a=t("robust-orientation")[3]},{"robust-orientation":253}],257:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],-e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=-e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=-e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=-e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],258:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],259:[function(t,e,r){"use strict";e.exports=function(t){return 0>t?-1:t>0?1:0}},{}],260:[function(t,e,r){"use strict";function n(t){return a(i(t))}e.exports=n;var i=t("boundary-cells"),a=t("reduce-simplicial-complex")},{"boundary-cells":50,"reduce-simplicial-complex":245}],261:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=0,n=0;e>n;++n)r=0|Math.max(r,t[n].length);return r-1}function i(t,e){for(var r=t.length,n=f.mallocUint8(r),i=0;r>i;++i)n[i]=t[i]o;++o)for(var s=t[o],e=s.length,l=0;e>l;++l)for(var c=0;l>c;++c){var d=s[c],p=s[l];i[a++]=0|Math.min(d,p),i[a++]=0|Math.max(d,p)}var g=a/2|0;h(u(i,[g,2]));for(var v=2,o=2;a>o;o+=2)i[o-2]===i[o]&&i[o-1]===i[o+1]||(i[v++]=i[o],i[v++]=i[o+1]);return u(i,[v/2|0,2])}function o(t,e,r,n){for(var i=t.data,a=t.shape[0],o=f.mallocDouble(a),s=0,l=0;a>l;++l){var c=i[2*l],h=i[2*l+1];if(r[c]!==r[h]){var d=e[c],p=e[h];i[2*s]=c,i[2*s+1]=h,o[s++]=(p-n)/(p-d)}}return t.shape[0]=s,u(o,[s])}function s(t,e){var r=f.mallocInt32(2*e),n=t.shape[0],i=t.data;r[0]=0;for(var a=0,o=0;n>o;++o){var s=i[2*o];if(s!==a){for(r[2*a+1]=o;++ai;++i)n[i]=[r[2*i],r[2*i+1]];return n}function c(t,e,r,c){r=r||0,"undefined"==typeof c&&(c=n(t));var u=t.length;if(0===u||1>c)return{cells:[],vertexIds:[],vertexWeights:[]};var h=i(e,+r),p=a(t,c),g=o(p,e,h,+r),v=s(p,0|e.length),m=d(c)(t,p.data,v,h),y=l(p),b=[].slice.call(g.data,0,g.shape[0]);return f.free(h),f.free(p.data),f.free(g.data),f.free(v),{cells:m,vertexIds:y,vertexWeights:b}}e.exports=c;var u=t("ndarray"),f=t("typedarray-pool"),h=t("ndarray-sort"),d=t("./lib/codegen")},{"./lib/codegen":262,ndarray:225,"ndarray-sort":223,"typedarray-pool":282}],262:[function(t,e,r){"use strict";function n(t){function e(t){if(!(t.length<=0)){c.push("R.push(");for(var e=0;e0&&c.push(","),c.push("[");for(var n=0;n0&&c.push(","),c.push("B(C,E,c[",i[0],"],c[",i[1],"])")}c.push("]")}c.push(");")}}var r=0,n=new Array(t+1);n[0]=[[]];for(var i=1;t>=i;++i)for(var s=n[i]=o(i),l=0;l>1,v=E[2*m+1];","if(v===b){return m}","if(b1;--i){t+1>i&&c.push("else "),c.push("if(l===",i,"){");for(var u=[],l=0;i>l;++l)u.push("(S[c["+l+"]]<<"+l+")");c.push("var M=",u.join("+"),";if(M===0||M===",(1<n;++n)e=r(e,t[n].length);return e-1}function i(t){for(var e=-1,r=Math.max,n=0,i=t.length;i>n;++n)for(var a=t[n],o=0,s=a.length;s>o;++o)e=r(e,a[o]);return e+1}function a(t){for(var e=new Array(t.length),r=0,n=t.length;n>r;++r)e[r]=t[r].slice(0);return e}function o(t,e){var r=t.length,n=t.length-e.length,i=Math.min;if(n)return n;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:var a=t[0]+t[1]-e[0]-e[1];return a?a:i(t[0],t[1])-i(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(a=o+t[2]-(s+e[2]))return a;var l=i(t[0],t[1]),c=i(e[0],e[1]),a=i(l,t[2])-i(c,e[2]);return a?a:i(l+t[2],o)-i(c+e[2],s);default:var u=t.slice(0);u.sort();var f=e.slice(0);f.sort();for(var h=0;r>h;++h)if(n=u[h]-f[h])return n;return 0}}function s(t,e){return o(t[0],e[0])}function l(t,e){if(e){for(var r=t.length,n=new Array(r),i=0;r>i;++i)n[i]=[t[i],e[i]];n.sort(s);for(var i=0;r>i;++i)t[i]=n[i][0],e[i]=n[i][1];return t}return t.sort(o),t}function c(t){if(0===t.length)return[];for(var e=1,r=t.length,n=1;r>n;++n){var i=t[n];if(o(i,t[n-1])){if(n===e){e++;continue}t[e++]=i}}return t.length=e,t}function u(t,e){for(var r=0,n=t.length-1,i=-1;n>=r;){var a=r+n>>1,s=o(t[a],e);0>=s?(0===s&&(i=a),r=a+1):s>0&&(n=a-1)}return i}function f(t,e){for(var r=new Array(t.length),n=0,i=r.length;i>n;++n)r[n]=[];for(var a=[],n=0,s=e.length;s>n;++n)for(var l=e[n],c=l.length,f=1,h=1<f;++f){a.length=b.popCount(f);for(var d=0,p=0;c>p;++p)f&1<g))for(;;)if(r[g++].push(n),g>=t.length||0!==o(t[g],a))break}return r}function h(t,e){if(!e)return f(c(p(t,0)),t,0);for(var r=new Array(e),n=0;e>n;++n)r[n]=[];for(var n=0,i=t.length;i>n;++n)for(var a=t[n],o=0,s=a.length;s>o;++o)r[a[o]].push(n);return r}function d(t){for(var e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0|i.length,o=1,s=1<o;++o){for(var c=[],u=0;a>u;++u)o>>>u&1&&c.push(i[u]);e.push(c)}return l(e)}function p(t,e){if(0>e)return[];for(var r=[],n=(1<r;++r)for(var i=t[r],a=0,o=i.length;o>a;++a){for(var s=new Array(i.length-1),c=0,u=0;o>c;++c)c!==a&&(s[u++]=i[c]);e.push(s)}return l(e)}function v(t,e){for(var r=new x(e),n=0;ne;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n,n.prototype.length=function(){return this.roots.length},n.prototype.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},n.prototype.find=function(t){for(var e=this.roots;e[t]!==t;){var r=e[t];e[t]=e[r],t=r}return t},n.prototype.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],267:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.abs(a(t,e,r)),i=Math.sqrt(Math.pow(e[0]-r[0],2)+Math.pow(e[1]-r[1],2));return n/i}function i(t,e,r){function i(t){if(x[t])return 1/0;var r=m[t],i=y[t];return 0>r||0>i?1/0:n(e[t],e[r],e[i])}function a(t,e){var r=M[t],n=M[e];M[t]=n,M[e]=r,T[r]=e,T[n]=t}function s(t){return b[M[t]]}function l(t){return 1&t?t-1>>1:(t>>1)-1}function c(t){for(var e=s(t);;){var r=e,n=2*t+1,i=2*(t+1),o=t;if(L>n){var l=s(n);r>l&&(o=n,r=l)}if(L>i){var c=s(i);r>c&&(o=i)}if(o===t)return t;a(t,o),t=o}}function u(t){for(var e=s(t);t>0;){var r=l(t);if(r>=0){var n=s(r);if(n>e){a(t,r),t=r;continue}}return t}}function f(){if(L>0){var t=M[0];return a(0,L-1),L-=1,c(0),t}return-1}function h(t,e){var r=M[t];return b[r]===e?t:(b[r]=-(1/0),u(t),f(),b[r]=e,L+=1,u(L-1))}function d(t){if(!x[t]){x[t]=!0;var e=m[t],r=y[t];m[r]>=0&&(m[r]=e),y[e]>=0&&(y[e]=r),T[e]>=0&&h(T[e],i(e)),T[r]>=0&&h(T[r],i(r))}}function p(t,e){if(t[e]<0)return e;var r=e,n=e;do{var i=t[n];if(!x[n]||0>i||i===n)break;if(n=i,i=t[n],!x[n]||0>i||i===n)break;n=i,r=t[r]}while(r!==n);for(var a=e;a!==n;a=t[a])t[a]=n;return n}for(var g=e.length,v=t.length,m=new Array(g),y=new Array(g),b=new Array(g),x=new Array(g),_=0;g>_;++_)m[_]=y[_]=-1,b[_]=1/0,x[_]=!1;for(var _=0;v>_;++_){var w=t[_];if(2!==w.length)throw new Error("Input must be a graph");var k=w[1],A=w[0];-1!==y[A]?y[A]=-2:y[A]=k,-1!==m[k]?m[k]=-2:m[k]=A}for(var M=[],T=new Array(g),_=0;g>_;++_){var E=b[_]=i(_);1/0>E?(T[_]=M.length,M.push(_)):T[_]=-1}for(var L=M.length,_=L>>1;_>=0;--_)c(_);for(;;){var S=f();if(0>S||b[S]>r)break;d(S)}for(var C=[],_=0;g>_;++_)x[_]||(T[_]=C.length,C.push(e[_].slice()));var z=(C.length,[]);return t.forEach(function(t){var e=p(m,t[0]),r=p(y,t[1]);if(e>=0&&r>=0&&e!==r){var n=T[e],i=T[r];n!==i&&z.push([n,i])}}),o.unique(o.normalize(z)),{positions:C,edges:z}}e.exports=i;var a=t("robust-orientation"),o=t("simplicial-complex")},{"robust-orientation":253,"simplicial-complex":265}],268:[function(t,e,r){"use strict";function n(t,e){var r,n;if(e[0][0]e[1][0])){var i=Math.min(t[0][1],t[1][1]),o=Math.max(t[0][1],t[1][1]),s=Math.min(e[0][1],e[1][1]),l=Math.max(e[0][1],e[1][1]);return s>o?o-s:i>l?i-l:o-l}r=e[1],n=e[0]}var c,u;t[0][1]e[1][0]))return n(e,t);r=e[1],i=e[0]}var o,s;if(t[0][0]t[1][0]))return-n(t,e);o=t[1],s=t[0]}var l=a(r,i,s),c=a(r,i,o);if(0>l){if(0>=c)return l}else if(l>0){if(c>=0)return l}else if(c)return c;if(l=a(s,o,i),c=a(s,o,r),0>l){if(0>=c)return l}else if(l>0){if(c>=0)return l}else if(c)return c;return i[0]-s[0]}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":253}],269:[function(t,e,r){"use strict";function n(t,e,r){this.slabs=t,this.coordinates=e,this.horizontal=r}function i(t,e){return t.y-e}function a(t,e){for(var r=null;t;){var n,i,o=t.key;o[0][0]s)t=t.left;else if(s>0)if(e[0]!==o[1][0])r=t,t=t.right;else{var l=a(t.right,e);if(l)return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l=a(t.right,e);if(l)return l;t=t.left}}return r}function o(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function s(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}function l(t){for(var e=t.length,r=2*e,i=new Array(r),a=0;e>a;++a){var l=t[a],c=l[0][0]a;){for(var v=i[a].x,m=[];r>a;){var y=i[a];if(y.x!==v)break;a+=1,y.segment[0][0]===y.x&&y.segment[1][0]===y.x?y.create&&(y.segment[0][1]e)return-1;var r=(this.slabs[e],a(this.slabs[e],t)),n=-1;if(r&&(n=r.value),this.coordinates[e]===t[0]){var o=null;if(r&&(o=r.key),e>0){var s=a(this.slabs[e-1],t);s&&(o?h(s.key,o)>0&&(o=s.key,n=s.value):(n=s.value,o=s.key))}var l=this.horizontal[e];if(l.length>0){var u=c.ge(l,t[1],i);if(u=l.length)return n;d=l[u]}}if(d.start)if(o){var p=f(o[0],o[1],[t[0],d.y]);o[0][0]>o[1][0]&&(p=-p),p>0&&(n=d.index)}else n=d.index;else d.y!==t[1]&&(n=d.index)}}}return n}},{"./lib/order-segments":268,"binary-search-bounds":47,"functional-red-black-tree":97,"robust-orientation":253}],270:[function(t,e,r){"use strict";function n(t,e){var r=c(l(t,e),[e[e.length-1]]);return r[r.length-1]}function i(t,e,r,n){var i=n-e,a=-e/i;0>a?a=0:a>1&&(a=1);for(var o=1-a,s=t.length,l=new Array(s),c=0;s>c;++c)l[c]=a*t[c]+o*r[c];return l}function a(t,e){for(var r=[],a=[],o=n(t[t.length-1],e),s=t[t.length-1],l=t[0],c=0;co&&u>0||o>0&&0>u){var f=i(s,u,l,o);r.push(f),a.push(f.slice())}0>u?a.push(l.slice()):u>0?r.push(l.slice()):(r.push(l.slice()),a.push(l.slice())),o=u}return{positive:r,negative:a}}function o(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;la&&c>0||a>0&&0>c)&&r.push(i(o,c,s,a)),c>=0&&r.push(s.slice()),a=c}return r}function s(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;la&&c>0||a>0&&0>c)&&r.push(i(o,c,s,a)),0>=c&&r.push(s.slice()),a=c}return r}var l=t("robust-dot-product"),c=t("robust-sum");e.exports=a,e.exports.positive=o,e.exports.negative=s},{"robust-dot-product":250,"robust-sum":258}],271:[function(e,r,n){!function(e){function r(){var t=arguments[0],e=r.cache;return e[t]&&e.hasOwnProperty(t)||(e[t]=r.parse(t)),r.format.call(null,e[t],arguments)}function i(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}function a(t,e){return Array(e+1).join(t)}var o={not_string:/[^s]/,number:/[diefg]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijosuxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};r.format=function(t,e){var n,s,l,c,u,f,h,d=1,p=t.length,g="",v=[],m=!0,y="";for(s=0;p>s;s++)if(g=i(t[s]),"string"===g)v[v.length]=t[s];else if("array"===g){if(c=t[s],c[2])for(n=e[d],l=0;l=0),c[8]){case"b":n=n.toString(2);break;case"c":n=String.fromCharCode(n);break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,c[6]?parseInt(c[6]):0);break;case"e":n=c[7]?n.toExponential(c[7]):n.toExponential();break;case"f":n=c[7]?parseFloat(n).toFixed(c[7]):parseFloat(n);break;case"g":n=c[7]?parseFloat(n).toPrecision(c[7]):parseFloat(n);break;case"o":n=n.toString(8);break;case"s":n=(n=String(n))&&c[7]?n.substring(0,c[7]):n;break;case"u":n>>>=0;break;case"x":n=n.toString(16);break;case"X":n=n.toString(16).toUpperCase()}o.json.test(c[8])?v[v.length]=n:(!o.number.test(c[8])||m&&!c[3]?y="":(y=m?"+":"-",n=n.toString().replace(o.sign,"")),f=c[4]?"0"===c[4]?"0":c[4].charAt(1):" ",h=c[6]-(y+n).length,u=c[6]&&h>0?a(f,h):"",v[v.length]=c[5]?y+n+u:"0"===f?y+u+n:u+y+n)}return v.join("")},r.cache={},r.parse=function(t){for(var e=t,r=[],n=[],i=0;e;){if(null!==(r=o.text.exec(e)))n[n.length]=r[0];else if(null!==(r=o.modulo.exec(e)))n[n.length]="%";else{if(null===(r=o.placeholder.exec(e)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){i|=1;var a=[],s=r[2],l=[];if(null===(l=o.key.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(a[a.length]=l[1];""!==(s=s.substring(l[0].length));)if(null!==(l=o.key_access.exec(s)))a[a.length]=l[1];else{if(null===(l=o.index_access.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");a[a.length]=l[1]}r[2]=a}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=r}e=e.substring(r[0].length)}return n};var s=function(t,e,n){return n=(e||[]).slice(0),n.splice(0,0,t),r.apply(null,n)};"undefined"!=typeof n?(n.sprintf=r,n.vsprintf=s):(e.sprintf=r,e.vsprintf=s,"function"==typeof t&&t.amd&&t(function(){return{sprintf:r,vsprintf:s}}))}("undefined"==typeof window?this:window)},{}],272:[function(t,e,r){"use strict";function n(t){return t.split("").map(function(t){return t in i?i[t]:""}).join("")}e.exports=n;var i={" ":" ",0:"\u2070",1:"\xb9",2:"\xb2",3:"\xb3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079","+":"\u207a","-":"\u207b",a:"\u1d43",b:"\u1d47",c:"\u1d9c",d:"\u1d48",e:"\u1d49",f:"\u1da0",g:"\u1d4d",h:"\u02b0",i:"\u2071",j:"\u02b2",k:"\u1d4f",l:"\u02e1",m:"\u1d50",n:"\u207f",o:"\u1d52",p:"\u1d56",r:"\u02b3",s:"\u02e2",t:"\u1d57",u:"\u1d58",v:"\u1d5b",w:"\u02b7",x:"\u02e3",y:"\u02b8",z:"\u1dbb"}},{}],273:[function(t,e,r){"use strict";function n(t,e){var r=t.length,n=["'use strict';"],i="surfaceNets"+t.join("_")+"d"+e;n.push("var contour=genContour({","order:[",t.join(),"],","scalarArguments: 3,","phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },"),"generic"===e&&n.push("getters:[0],");for(var a=[],l=[],c=0;r>c;++c)a.push("d"+c),l.push("d"+c);for(var c=0;1<c;++c)a.push("v"+c),l.push("v"+c);for(var c=0;1<c;++c)a.push("p"+c),l.push("p"+c);a.push("a","b","c"),l.push("a","c"),n.push("vertex:function vertexFunc(",a.join(),"){");for(var u=[],c=0;1<c;++c)u.push("(p"+c+"<<"+c+")");n.push("var m=(",u.join("+"),")|0;if(m===0||m===",(1<<(1<=1<<(1<>>7){");for(var c=0;1<<(1<c;++c){if(1<<(1<128&&c%128===0){f.length>0&&h.push("}}");var d="vExtra"+f.length;n.push("case ",c>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&c,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;r>b;++b)p[b]=[],g[b]=[],v[b]=0,m[b]=0;for(var b=0;1<b;++b)for(var x=0;r>x;++x){var _=b^1<b)&&!(c&1<<_)!=!(c&1<w?(p[x].push("-v"+b+"-v"+_),v[x]+=2):(p[x].push("v"+b+"+v"+_),v[x]-=2),y+=1;for(var k=0;r>k;++k)k!==x&&(_&1<x;++x)if(0===p[x].length)A.push("d"+x+"-0.5");else{var M="";v[x]<0?M=v[x]+"*c":v[x]>0&&(M="+"+v[x]+"*c");var T=.5*(p[x].length/y),E=.5+.5*(m[x]/y);A.push("d"+x+"-"+E+"-"+T+"*("+p[x].join("+")+M+")/("+g[x].join("+")+")")}h.push("a.push([",A.join(),"]);","break;")}n.push("}},"),f.length>0&&h.push("}}");for(var L=[],c=0;1<c;++c)L.push("v"+c);L.push("c0","c1","p0","p1","a","b","c"),n.push("cell:function cellFunc(",L.join(),"){");var S=s(r-1);n.push("if(p0){b.push(",S.map(function(t){return"["+t.map(function(t){return"v"+t})+"]"}).join(),")}else{b.push(",S.map(function(t){var e=t.slice();return e.reverse(),"["+e.map(function(t){return"v"+t})+"]"}).join(),")}}});function ",i,"(array,level){var verts=[],cells=[];contour(array,verts,cells,level);return {positions:verts,cells:cells};} return ",i,";");for(var c=0;co;++o)i[o]=[r[o]],a[o]=[o];return{positions:i,cells:a}}function a(t,e){if(t.dimension<=0)return{positions:[],cells:[]};if(1===t.dimension)return i(t,e);var r=t.order.join()+"-"+t.dtype,a=c[r],e=+e||0;return a||(a=c[r]=n(t.order,t.dtype)),a(t,e)}e.exports=a;var o=t("ndarray-extract-contour"),s=t("triangulate-hypercube"),l=t("zero-crossings"),c={}},{"ndarray-extract-contour":214,"triangulate-hypercube":278,"zero-crossings":292}],274:[function(t,e,r){(function(r){"use strict";function n(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;ol;++l){var c=r[s[l]];n[i++]=c[0],n[i++]=c[1]+1.4,a=Math.max(c[0],a)}return{data:n,shape:a}}function i(t,e){var r=s[t];r||(r=s[t]={" ":{data:new Float32Array(0),shape:.2}});var o=r[e];if(!o)if(e.length<=1||!/\d/.test(e))o=r[e]=n(a(e,{triangles:!0,font:t,textAlign:"left",textBaseline:"alphabetic"}));else{for(var l=e.split(/(\d|\s)/),c=new Array(l.length),u=0,f=0,h=0;h0&&(f+=.02);for(var d=new Float32Array(u),p=0,g=-.5*f,h=0;h.5?l/(2-a-o):l/(a+o),a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,l:s}}function o(t,e,r){function n(t,e,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?t+6*(e-t)*r:.5>r?e:2/3>r?t+(e-t)*(2/3-r)*6:t}var i,a,o;if(t=T(t,360),e=T(e,100),r=T(r,100),0===e)i=a=o=r;else{var s=.5>r?r*(1+e):r+e-r*e,l=2*r-s;i=n(l,s,t+1/3),a=n(l,s,t),o=n(l,s,t-1/3)}return{r:255*i,g:255*a,b:255*o}}function s(t,e,r){t=T(t,255),e=T(e,255),r=T(r,255);var n,i,a=q(t,e,r),o=V(t,e,r),s=a,l=a-o;if(i=0===a?0:l/a,a==o)n=0;else{switch(a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,v:s}}function l(t,e,r){t=6*T(t,360),e=T(e,100),r=T(r,100);var n=D.floor(t),i=t-n,a=r*(1-e),o=r*(1-i*e),s=r*(1-(1-i)*e),l=n%6,c=[r,o,a,a,s,r][l],u=[s,r,r,o,a,a][l],f=[a,a,s,r,r,o][l];return{r:255*c,g:255*u,b:255*f}}function c(t,e,r,n){var i=[z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function u(t,e,r,n){var i=[z(R(n)),z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return i.join("")}function f(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s-=r/100,n.s=E(n.s),e(n)}function h(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s+=r/100,n.s=E(n.s),e(n)}function d(t){return e(t).desaturate(100)}function p(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l+=r/100,n.l=E(n.l),e(n)}function g(t,r){r=0===r?0:r||10;var n=e(t).toRgb();return n.r=q(0,V(255,n.r-U(255*-(r/100)))),n.g=q(0,V(255,n.g-U(255*-(r/100)))),n.b=q(0,V(255,n.b-U(255*-(r/100)))),e(n)}function v(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l-=r/100,n.l=E(n.l),e(n)}function m(t,r){var n=e(t).toHsl(),i=(U(n.h)+r)%360;return n.h=0>i?360+i:i,e(n)}function y(t){var r=e(t).toHsl();return r.h=(r.h+180)%360,e(r)}function b(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+120)%360,s:r.s,l:r.l}),e({h:(n+240)%360,s:r.s,l:r.l})]}function x(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+90)%360,s:r.s,l:r.l}),e({h:(n+180)%360,s:r.s,l:r.l}),e({h:(n+270)%360,s:r.s,l:r.l})]}function _(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+72)%360,s:r.s,l:r.l}),e({h:(n+216)%360,s:r.s,l:r.l})]}function w(t,r,n){r=r||6,n=n||30;var i=e(t).toHsl(),a=360/n,o=[e(t)];for(i.h=(i.h-(a*r>>1)+720)%360;--r;)i.h=(i.h+a)%360,o.push(e(i));return o}function k(t,r){r=r||6;for(var n=e(t).toHsv(),i=n.h,a=n.s,o=n.v,s=[],l=1/r;r--;)s.push(e({h:i,s:a,v:o})),o=(o+l)%1;return s}function A(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}function M(t){return t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=1),t}function T(t,e){S(t)&&(t="100%");var r=C(t);return t=V(e,q(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),D.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function E(t){return V(1,q(0,t))}function L(t){return parseInt(t,16)}function S(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function C(t){return"string"==typeof t&&-1!=t.indexOf("%")}function z(t){return 1==t.length?"0"+t:""+t}function P(t){return 1>=t&&(t=100*t+"%"),t}function R(t){return Math.round(255*parseFloat(t)).toString(16)}function O(t){return L(t)/255}function I(t){t=t.replace(j,"").replace(F,"").toLowerCase();var e=!1;if(G[t])t=G[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=X.rgb.exec(t))?{r:r[1],g:r[2],b:r[3]}:(r=X.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=X.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=X.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=X.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=X.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=X.hex8.exec(t))?{a:O(r[1]),r:L(r[2]),g:L(r[3]),b:L(r[4]),format:e?"name":"hex8"}:(r=X.hex6.exec(t))?{r:L(r[1]),g:L(r[2]),b:L(r[3]),format:e?"name":"hex"}:(r=X.hex3.exec(t))?{r:L(r[1]+""+r[1]),g:L(r[2]+""+r[2]),b:L(r[3]+""+r[3]),format:e?"name":"hex"}:!1}function N(t){var e,r;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==r&&"large"!==r&&(r="small"),{level:e,size:r}}var j=/^\s+/,F=/\s+$/,B=0,D=Math,U=D.round,V=D.min,q=D.max,H=D.random;e.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3; -},getLuminance:function(){var t,e,r,n,i,a,o=this.toRgb();return t=o.r/255,e=o.g/255,r=o.b/255,n=.03928>=t?t/12.92:Math.pow((t+.055)/1.055,2.4),i=.03928>=e?e/12.92:Math.pow((e+.055)/1.055,2.4),a=.03928>=r?r/12.92:Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*i+.0722*a},setAlpha:function(t){return this._a=M(t),this._roundA=U(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=a(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=a(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return u(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:U(this._r),g:U(this._g),b:U(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+U(this._r)+", "+U(this._g)+", "+U(this._b)+")":"rgba("+U(this._r)+", "+U(this._g)+", "+U(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:U(100*T(this._r,255))+"%",g:U(100*T(this._g,255))+"%",b:U(100*T(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%)":"rgba("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:Y[c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+u(this._r,this._g,this._b,this._a),n=r,i=this._gradientType?"GradientType = 1, ":"";if(t){var a=e(t);n=a.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+r+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0,i=!e&&n&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return i?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return e(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(p,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(v,arguments)},desaturate:function(){return this._applyModification(f,arguments)},saturate:function(){return this._applyModification(h,arguments)},greyscale:function(){return this._applyModification(d,arguments)},spin:function(){return this._applyModification(m,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(w,arguments)},complement:function(){return this._applyCombination(y,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(_,arguments)},triad:function(){return this._applyCombination(b,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},e.fromRatio=function(t,r){if("object"==typeof t){var n={};for(var i in t)t.hasOwnProperty(i)&&("a"===i?n[i]=t[i]:n[i]=P(t[i]));t=n}return e(t,r)},e.equals=function(t,r){return t&&r?e(t).toRgbString()==e(r).toRgbString():!1},e.random=function(){return e.fromRatio({r:H(),g:H(),b:H()})},e.mix=function(t,r,n){n=0===n?0:n||50;var i,a=e(t).toRgb(),o=e(r).toRgb(),s=n/100,l=2*s-1,c=o.a-a.a;i=l*c==-1?l:(l+c)/(1+l*c),i=(i+1)/2;var u=1-i,f={r:o.r*i+a.r*u,g:o.g*i+a.g*u,b:o.b*i+a.b*u,a:o.a*s+a.a*(1-s)};return e(f)},e.readability=function(t,r){var n=e(t),i=e(r);return(Math.max(n.getLuminance(),i.getLuminance())+.05)/(Math.min(n.getLuminance(),i.getLuminance())+.05)},e.isReadable=function(t,r,n){var i,a,o=e.readability(t,r);switch(a=!1,i=N(n),i.level+i.size){case"AAsmall":case"AAAlarge":a=o>=4.5;break;case"AAlarge":a=o>=3;break;case"AAAsmall":a=o>=7}return a},e.mostReadable=function(t,r,n){var i,a,o,s,l=null,c=0;n=n||{},a=n.includeFallbackColors,o=n.level,s=n.size;for(var u=0;uc&&(c=i,l=e(r[u]));return e.isReadable(t,l,{level:o,size:s})||!a?l:(n.includeFallbackColors=!1,e.mostReadable(t,["#fff","#000"],n))};var G=e.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Y=e.hexNames=A(G),X=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",r="(?:"+e+")|(?:"+t+")",n="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",i="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof r&&r.exports?r.exports=e:"function"==typeof t&&t.amd?t(function(){return e}):window.tinycolor=e}()},{}],276:[function(t,e,r){"use strict";function n(t,e){var r=o(getComputedStyle(t).getPropertyValue(e));return r[0]*a(r[1],t)}function i(t,e){var r=document.createElement("div");r.style["font-size"]="128"+t,e.appendChild(r);var i=n(r,"font-size")/128;return e.removeChild(r),i}function a(t,e){switch(e=e||document.body,t=(t||"px").trim().toLowerCase(),e!==window&&e!==document||(e=document.body),t){case"%":return e.clientHeight/100;case"ch":case"ex":return i(t,e);case"em":return n(e,"font-size");case"rem":return n(document.body,"font-size");case"vw":return window.innerWidth/100;case"vh":return window.innerHeight/100;case"vmin":return Math.min(window.innerWidth,window.innerHeight)/100;case"vmax":return Math.max(window.innerWidth,window.innerHeight)/100;case"in":return s;case"cm":return s/2.54;case"mm":return s/25.4;case"pt":return s/72;case"pc":return s/6}return 1}var o=t("parse-unit");e.exports=a;var s=96},{"parse-unit":231}],277:[function(e,r,n){!function(e,i){"object"==typeof n&&"undefined"!=typeof r?i(n):"function"==typeof t&&t.amd?t(["exports"],i):i(e.topojson=e.topojson||{})}(this,function(t){"use strict";function e(){}function r(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0),t[0]=(r+=t[0])*i+o,t[1]=(n+=t[1])*a+s}}function n(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0);var l=Math.round((t[0]-o)/i),c=Math.round((t[1]-s)/a);t[0]=l-r,t[1]=c-n,r=l,n=c}}function i(t,e){for(var r,n=t.length,i=n-e;i<--n;)r=t[i],t[i++]=t[n],t[n]=r}function a(t,e){for(var r=0,n=t.length;n>r;){var i=r+n>>>1;t[i]t?~t:t],a=0,o=n.length;o>a;++a)e.push(r=n[a].slice()),u(r,a);0>t&&i(e,o)}function a(t){return t=t.slice(),u(t,0),t}function o(t){for(var e=[],r=0,i=t.length;i>r;++r)n(t[r],e);return e.length<2&&e.push(e[0].slice()),e}function s(t){for(var e=o(t);e.length<4;)e.push(e[0].slice());return e}function l(t){return t.map(s)}function c(t){var e=t.type;return"GeometryCollection"===e?{type:e,geometries:t.geometries.map(c)}:e in h?{type:e,coordinates:h[e](t)}:null}var u=r(t.transform),f=t.arcs,h={Point:function(t){return a(t.coordinates)},MultiPoint:function(t){return t.coordinates.map(a)},LineString:function(t){return o(t.arcs)},MultiLineString:function(t){return t.arcs.map(o)},Polygon:function(t){return l(t.arcs)},MultiPolygon:function(t){return t.arcs.map(l)}};return c(e)}function c(t,e){function r(e){var r,n=t.arcs[0>e?~e:e],i=n[0];return t.transform?(r=[0,0],n.forEach(function(t){r[0]+=t[0],r[1]+=t[1]})):r=n[n.length-1],0>e?[r,i]:[i,r]}function n(t,e){for(var r in t){var n=t[r];delete e[n.start],delete n.start,delete n.end,n.forEach(function(t){i[0>t?~t:t]=1}),s.push(n)}}var i={},a={},o={},s=[],l=-1;return e.forEach(function(r,n){var i,a=t.arcs[0>r?~r:r];a.length<3&&!a[1][0]&&!a[1][1]&&(i=e[++l],e[l]=r,e[n]=i)}),e.forEach(function(t){var e,n,i=r(t),s=i[0],l=i[1];if(e=o[s])if(delete o[e.end],e.push(t),e.end=l,n=a[l]){delete a[n.start];var c=n===e?e:e.concat(n);a[c.start=e.start]=o[c.end=n.end]=c}else a[e.start]=o[e.end]=e;else if(e=a[l])if(delete a[e.start],e.unshift(t),e.start=s,n=o[s]){delete o[n.end];var u=n===e?e:n.concat(e);a[u.start=n.start]=o[u.end=e.end]=u}else a[e.start]=o[e.end]=e;else e=[t],a[e.start=s]=o[e.end=l]=e}),n(o,a),n(a,o),e.forEach(function(t){i[0>t?~t:t]||s.push([t])}),s}function u(t){return l(t,f.apply(this,arguments))}function f(t,e,r){function n(t){var e=0>t?~t:t;(u[e]||(u[e]=[])).push({i:t,g:l})}function i(t){t.forEach(n)}function a(t){t.forEach(i)}function o(t){"GeometryCollection"===t.type?t.geometries.forEach(o):t.type in f&&(l=t,f[t.type](t.arcs))}var s=[];if(arguments.length>1){var l,u=[],f={LineString:i,MultiLineString:a,Polygon:a,MultiPolygon:function(t){t.forEach(a)}};o(e),u.forEach(arguments.length<3?function(t){s.push(t[0].i)}:function(t){r(t[0].g,t[t.length-1].g)&&s.push(t[0].i)})}else for(var h=0,d=t.arcs.length;d>h;++h)s.push(h);return{type:"MultiLineString",arcs:c(t,s)}}function h(t){var e=t[0],r=t[1],n=t[2];return Math.abs((e[0]-n[0])*(r[1]-e[1])-(e[0]-r[0])*(n[1]-e[1]))}function d(t){for(var e,r=-1,n=t.length,i=t[n-1],a=0;++re?~e:e]||(i[e]=[])).push(t)})}),a.push(t)}function n(e){return Math.abs(d(l(t,{type:"Polygon",arcs:[e]}).coordinates[0]))}var i={},a=[],o=[];return e.forEach(function(t){"Polygon"===t.type?r(t.arcs):"MultiPolygon"===t.type&&t.arcs.forEach(r)}),a.forEach(function(t){if(!t._){var e=[],r=[t];for(t._=1,o.push(e);t=r.pop();)e.push(t),t.forEach(function(t){t.forEach(function(t){i[0>t?~t:t].forEach(function(t){t._||(t._=1,r.push(t))})})})}}),a.forEach(function(t){delete t._}),{type:"MultiPolygon",arcs:o.map(function(e){var r,a=[];if(e.forEach(function(t){t.forEach(function(t){t.forEach(function(t){i[0>t?~t:t].length<2&&a.push(t)})})}),a=c(t,a),(r=a.length)>1)for(var o,s,l=1,u=n(a[0]);r>l;++l)(o=n(a[l]))>u&&(s=a[0],a[0]=a[l],a[l]=s,u=o);return a})}}function v(t){function e(t,e){t.forEach(function(t){0>t&&(t=~t);var r=i[t];r?r.push(e):i[t]=[e]})}function r(t,r){t.forEach(function(t){e(t,r)})}function n(t,e){"GeometryCollection"===t.type?t.geometries.forEach(function(t){n(t,e)}):t.type in s&&s[t.type](t.arcs,e)}var i={},o=t.map(function(){return[]}),s={LineString:e,MultiLineString:r,Polygon:r,MultiPolygon:function(t,e){t.forEach(function(t){r(t,e)})}};t.forEach(n);for(var l in i)for(var c=i[l],u=c.length,f=0;u>f;++f)for(var h=f+1;u>h;++h){var d,p=c[f],g=c[h];(d=o[p])[l=a(d,g)]!==g&&d.splice(l,0,g),(d=o[g])[l=a(d,p)]!==p&&d.splice(l,0,p)}return o}function m(t,e){return t[1][2]-e[1][2]}function y(){function t(t,e){for(;e>0;){var r=(e+1>>1)-1,i=n[r];if(m(t,i)>=0)break;n[i._=e]=i,n[t._=e=r]=t}}function e(t,e){for(;;){var r=e+1<<1,a=r-1,o=e,s=n[o];if(i>a&&m(n[a],s)<0&&(s=n[o=a]),i>r&&m(n[r],s)<0&&(s=n[o=r]),o===e)break;n[s._=e]=s,n[t._=e=o]=t}}var r={},n=[],i=0;return r.push=function(e){return t(n[e._=i]=e,i++),i},r.pop=function(){if(!(0>=i)){var t,r=n[0];return--i>0&&(t=n[i],e(n[t._=0]=t,0)),r}},r.remove=function(r){var a,o=r._;if(n[o]===r)return o!==--i&&(a=n[i],(m(a,r)<0?t:e)(n[a._=o]=a,o)),o},r}function b(t,e){function i(t){s.remove(t),t[1][2]=e(t),s.push(t)}var a=r(t.transform),o=n(t.transform),s=y();return e||(e=h),t.arcs.forEach(function(t){var r,n,l,c,u=[],f=0;for(n=0,l=t.length;l>n;++n)c=t[n],a(t[n]=[c[0],c[1],1/0],n);for(n=1,l=t.length-1;l>n;++n)r=t.slice(n-1,n+2),r[1][2]=e(r),u.push(r),s.push(r);for(n=0,l=u.length;l>n;++n)r=u[n],r.previous=u[n-1],r.next=u[n+1];for(;r=s.pop();){var h=r.previous,d=r.next;r[1][2]t)return[];if(0===t)return[[0]];for(var e=0|Math.round(o(t+1)),r=[],n=0;e>n;++n){for(var s=i.unrank(t,n),l=[0],c=0,u=0;uMath.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,s=0;3>s;++s)a+=t[s]*t[s],o+=i[s]*t[s];for(var s=0;3>s;++s)i[s]-=o/a*t[s];return h(i,i),i}function o(t,e,r,n,i,a,o,s){this.center=l(r),this.up=l(n),this.right=l(i),this.radius=l([a]),this.angle=l([o,s]),this.angle.bounds=[[-(1/0),-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var c=0;16>c;++c)this.computedMatrix[c]=.5;this.recalcMatrix(0)}function s(t){t=t||{};var e=t.center||[0,0,0],r=t.up||[0,1,0],i=t.right||a(r),s=t.radius||1,l=t.theta||0,c=t.phi||0;if(e=[].slice.call(e,0,3),r=[].slice.call(r,0,3),h(r,r),i=[].slice.call(i,0,3),h(i,i),"eye"in t){var u=t.eye,p=[u[0]-e[0],u[1]-e[1],u[2]-e[2]];f(i,p,r),n(i[0],i[1],i[2])<1e-6?i=a(r):h(i,i),s=n(p[0],p[1],p[2]);var g=d(r,p)/s,v=d(i,p)/s;c=Math.acos(g),l=Math.acos(v)}return s=Math.log(s),new o(t.zoomMin,t.zoomMax,e,r,i,s,l,c)}e.exports=s;var l=t("filtered-vector"),c=t("gl-mat4/invert"),u=t("gl-mat4/rotate"),f=t("gl-vec3/cross"),h=t("gl-vec3/normalize"),d=t("gl-vec3/dot"),p=o.prototype;p.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-(1/0),e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},p.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},p.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,i=0,a=0,o=0;3>o;++o)a+=e[o]*r[o],i+=e[o]*e[o];for(var s=Math.sqrt(i),l=0,o=0;3>o;++o)r[o]-=e[o]*a/i,l+=r[o]*r[o],e[o]/=s;for(var c=Math.sqrt(l),o=0;3>o;++o)r[o]/=c;var u=this.computedToward;f(u,e,r),h(u,u);for(var d=Math.exp(this.computedRadius[0]),p=this.computedAngle[0],g=this.computedAngle[1],v=Math.cos(p),m=Math.sin(p),y=Math.cos(g),b=Math.sin(g),x=this.computedCenter,_=v*y,w=m*y,k=b,A=-v*b,M=-m*b,T=y,E=this.computedEye,L=this.computedMatrix,o=0;3>o;++o){var S=_*r[o]+w*u[o]+k*e[o];L[4*o+1]=A*r[o]+M*u[o]+T*e[o],L[4*o+2]=S,L[4*o+3]=0}var C=L[1],z=L[5],P=L[9],R=L[2],O=L[6],I=L[10],N=z*I-P*O,j=P*R-C*I,F=C*O-z*R,B=n(N,j,F);N/=B,j/=B,F/=B,L[0]=N,L[4]=j,L[8]=F;for(var o=0;3>o;++o)E[o]=x[o]+L[2+4*o]*d;for(var o=0;3>o;++o){for(var l=0,D=0;3>D;++D)l+=L[o+4*D]*E[D];L[12+o]=-l}L[15]=1},p.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;16>n;++n)e[n]=r[n];return e}return r};var g=[0,0,0];p.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;g[0]=i[2],g[1]=i[6],g[2]=i[10];for(var a=this.computedUp,o=this.computedRight,s=this.computedToward,l=0;3>l;++l)i[4*l]=a[l],i[4*l+1]=o[l],i[4*l+2]=s[l];u(i,i,n,g);for(var l=0;3>l;++l)a[l]=i[4*l],o[l]=i[4*l+1];this.up.set(t,a[0],a[1],a[2]),this.right.set(t,o[0],o[1],o[2])}},p.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=(Math.exp(this.computedRadius[0]),a[1]),s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],f=a[4],h=a[8],d=u*o+f*s+h*l;u-=o*d,f-=s*d,h-=l*d;var p=n(u,f,h);u/=p,f/=p,h/=p;var g=u*e+o*r,v=f*e+s*r,m=h*e+l*r;this.center.move(t,g,v,m);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+i),this.radius.set(t,Math.log(y))},p.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},p.setMatrix=function(t,e,r,a){var o=1;"number"==typeof r&&(o=0|r),(0>o||o>3)&&(o=1);var s=(o+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var l=e[o],u=e[o+4],f=e[o+8];if(a){var h=Math.abs(l),d=Math.abs(u),p=Math.abs(f),g=Math.max(h,d,p);h===g?(l=0>l?-1:1,u=f=0):p===g?(f=0>f?-1:1,l=u=0):(u=0>u?-1:1,l=f=0)}else{var v=n(l,u,f);l/=v,u/=v,f/=v}var m=e[s],y=e[s+4],b=e[s+8],x=m*l+y*u+b*f;m-=l*x,y-=u*x,b-=f*x;var _=n(m,y,b);m/=_,y/=_,b/=_;var w=u*b-f*y,k=f*m-l*b,A=l*y-u*m,M=n(w,k,A);w/=M,k/=M,A/=M,this.center.jump(t,H,G,Y),this.radius.idle(t),this.up.jump(t,l,u,f),this.right.jump(t,m,y,b);var T,E;if(2===o){var L=e[1],S=e[5],C=e[9],z=L*m+S*y+C*b,P=L*w+S*k+C*A;T=0>N?-Math.PI/2:Math.PI/2,E=Math.atan2(P,z)}else{var R=e[2],O=e[6],I=e[10],N=R*l+O*u+I*f,j=R*m+O*y+I*b,F=R*w+O*k+I*A;T=Math.asin(i(N)),E=Math.atan2(F,j)}this.angle.jump(t,E,T),this.recalcMatrix(t);var B=e[2],D=e[6],U=e[10],V=this.computedMatrix;c(V,e);var q=V[15],H=V[12]/q,G=V[13]/q,Y=V[14]/q,X=Math.exp(this.computedRadius[0]);this.center.jump(t,H-B*X,G-D*X,Y-U*X)},p.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},p.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},p.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},p.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},p.lookAt=function(t,e,r,a){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter,a=a||this.computedUp;var o=a[0],s=a[1],l=a[2],c=n(o,s,l);if(!(1e-6>c)){o/=c,s/=c,l/=c;var u=e[0]-r[0],f=e[1]-r[1],h=e[2]-r[2],d=n(u,f,h);if(!(1e-6>d)){u/=d,f/=d,h/=d;var p=this.computedRight,g=p[0],v=p[1],m=p[2],y=o*g+s*v+l*m;g-=y*o,v-=y*s,m-=y*l;var b=n(g,v,m);if(!(.01>b&&(g=s*h-l*f,v=l*u-o*h,m=o*f-s*u,b=n(g,v,m),1e-6>b))){g/=b,v/=b,m/=b,this.up.set(t,o,s,l),this.right.set(t,g,v,m),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(d));var x=s*m-l*v,_=l*g-o*m,w=o*v-s*g,k=n(x,_,w);x/=k,_/=k,w/=k;var A=o*u+s*f+l*h,M=g*u+v*f+m*h,T=x*u+_*f+w*h,E=Math.asin(i(A)),L=Math.atan2(T,M),S=this.angle._state,C=S[S.length-1],z=S[S.length-2];C%=2*Math.PI;var P=Math.abs(C+2*Math.PI-L),R=Math.abs(C-L),O=Math.abs(C-2*Math.PI-L);R>P&&(C+=2*Math.PI),R>O&&(C-=2*Math.PI),this.angle.jump(this.angle.lastT(),C,z),this.angle.set(t,L,E)}}}}},{"filtered-vector":96,"gl-mat4/invert":128,"gl-mat4/rotate":132,"gl-vec3/cross":183,"gl-vec3/dot":184,"gl-vec3/normalize":187}],280:[function(t,e,r){"use strict";function n(t,e,r){var n=t*e,a=i*t,o=a-t,s=a-o,l=t-s,c=i*e,u=c-e,f=c-u,h=e-f,d=n-s*f,p=d-l*f,g=p-s*h,v=l*h-g;return r?(r[0]=v,r[1]=n,r):[v,n]}e.exports=n;var i=+(Math.pow(2,27)+1)},{}],281:[function(t,e,r){"use strict";function n(t,e,r){var n=t+e,i=n-t,a=n-i,o=e-i,s=t-a;return r?(r[0]=s+o,r[1]=n,r):[s+o,n]}e.exports=n},{}],282:[function(t,e,r){(function(e,n){"use strict";function i(t){if(t){var e=t.length||t.byteLength,r=y.log2(e);w[r].push(t)}}function a(t){i(t.buffer)}function o(t){var t=y.nextPow2(t),e=y.log2(t),r=w[e];return r.length>0?r.pop():new ArrayBuffer(t)}function s(t){return new Uint8Array(o(t),0,t)}function l(t){return new Uint16Array(o(2*t),0,t)}function c(t){return new Uint32Array(o(4*t),0,t)}function u(t){return new Int8Array(o(t),0,t)}function f(t){return new Int16Array(o(2*t),0,t)}function h(t){return new Int32Array(o(4*t),0,t)}function d(t){return new Float32Array(o(4*t),0,t)}function p(t){return new Float64Array(o(8*t),0,t)}function g(t){return x?new Uint8ClampedArray(o(t),0,t):s(t)}function v(t){return new DataView(o(t),0,t)}function m(t){t=y.nextPow2(t);var e=y.log2(t),r=k[e];return r.length>0?r.pop():new n(t)}var y=t("bit-twiddle"),b=t("dup");e.__TYPEDARRAY_POOL||(e.__TYPEDARRAY_POOL={UINT8:b([32,0]),UINT16:b([32,0]),UINT32:b([32,0]),INT8:b([32,0]),INT16:b([32,0]),INT32:b([32,0]),FLOAT:b([32,0]),DOUBLE:b([32,0]),DATA:b([32,0]),UINT8C:b([32,0]),BUFFER:b([32,0])});var x="undefined"!=typeof Uint8ClampedArray,_=e.__TYPEDARRAY_POOL;_.UINT8C||(_.UINT8C=b([32,0])),_.BUFFER||(_.BUFFER=b([32,0]));var w=_.DATA,k=_.BUFFER;r.free=function(t){if(n.isBuffer(t))k[y.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|y.log2(e);w[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=a,r.freeArrayBuffer=i,r.freeBuffer=function(t){k[y.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return o(t);switch(e){case"uint8":return s(t);case"uint16":return l(t);case"uint32":return c(t);case"int8":return u(t);case"int16":return f(t);case"int32":return h(t);case"float":case"float32":return d(t);case"double":case"float64":return p(t);case"uint8_clamped":return g(t);case"buffer":return m(t);case"data":case"dataview":return v(t);default:return null}return null},r.mallocArrayBuffer=o,r.mallocUint8=s,r.mallocUint16=l,r.mallocUint32=c,r.mallocInt8=u,r.mallocInt16=f,r.mallocInt32=h,r.mallocFloat32=r.mallocFloat=d,r.mallocFloat64=r.mallocDouble=p,r.mallocUint8Clamped=g,r.mallocDataView=v,r.mallocBuffer=m,r.clearCache=function(){for(var t=0;32>t;++t)_.UINT8[t].length=0,_.UINT16[t].length=0,_.UINT32[t].length=0,_.INT8[t].length=0,_.INT16[t].length=0,_.INT32[t].length=0,_.FLOAT[t].length=0,_.DOUBLE[t].length=0,_.UINT8C[t].length=0,w[t].length=0,k[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":48,buffer:58,dup:90}],283:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;t>e;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n;var i=n.prototype;Object.defineProperty(i,"length",{get:function(){return this.roots.length}}),i.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},i.find=function(t){for(var e=t,r=this.roots;r[t]!==t;)t=r[t];for(;r[e]!==t;){var n=r[e];r[e]=t,e=n}return t},i.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],284:[function(t,e,r){"use strict";function n(t,e){for(var r=1,n=t.length,i=t[0],a=t[0],o=1;n>o;++o)if(a=i,i=t[o],e(i,a)){if(o===r){r++;continue}t[r++]=i}return t.length=r,t}function i(t){for(var e=1,r=t.length,n=t[0],i=t[0],a=1;r>a;++a,i=n)if(i=n,n=t[a],n!==i){if(a===e){e++;continue}t[e++]=n}return t.length=e,t}function a(t,e,r){return 0===t.length?t:e?(r||t.sort(e),n(t,e)):(r||t.sort(),i(t))}e.exports=a},{}],285:[function(t,e,r){"use strict";function n(t,e){return"object"==typeof e&&null!==e||(e={}),i(t,e.canvas||a,e.context||o,e)}e.exports=n;var i=t("./lib/vtext"),a=null,o=null;"undefined"!=typeof document&&(a=document.createElement("canvas"),a.width=8192,a.height=1024,o=a.getContext("2d"))},{"./lib/vtext":286}],286:[function(t,e,r){"use strict";function n(t,e,r){for(var n=e.textAlign||"start",i=e.textBaseline||"alphabetic",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;s>l;++l)for(var c=t[l],u=0;2>u;++u)a[u]=0|Math.min(a[u],c[u]),o[u]=0|Math.max(o[u],c[u]);var f=0;switch(n){case"center":f=-.5*(a[0]+o[0]);break;case"right":case"end":f=-o[0];break;case"left":case"start":f=-a[0];break;default:throw new Error("vectorize-text: Unrecognized textAlign: '"+n+"'")}var h=0;switch(i){case"hanging":case"top":h=-a[1];break;case"middle":h=-.5*(a[1]+o[1]);break;case"alphabetic":case"ideographic":h=-3*r;break;case"bottom":h=-o[1];break;default:throw new Error("vectorize-text: Unrecoginized textBaseline: '"+i+"'")}var d=1/r;return"lineHeight"in e?d*=+e.lineHeight:"width"in e?d=e.width/(o[0]-a[0]):"height"in e&&(d=e.height/(o[1]-a[1])),t.map(function(t){return[d*(t[0]+f),d*(t[1]+h)]})}function i(t,e,r,n){var i=0|Math.ceil(e.measureText(r).width+2*n);if(i>8192)throw new Error("vectorize-text: String too long (sorry, this will get fixed later)");var a=3*n;t.height=0?l[r]:e)}function e(t){var e=n(t);return e?c in e:s.indexOf(t)>=0}function r(t,e){var r,i=n(t);return i?i[c]=e:(r=s.indexOf(t),r>=0?l[r]=e:(r=s.length,l[r]=e,s[r]=t)),this}function o(t){var e,r,i=n(t);return i?c in i&&delete i[c]:(e=s.indexOf(t),0>e?!1:(r=s.length-1,s[e]=void 0,l[e]=l[r],s[e]=s[r],s.length=r,l.length=r,!0))}this instanceof x||a();var s=[],l=[],c=b++;return Object.create(x.prototype,{get___:{value:i(t)},has___:{value:i(e)},set___:{value:i(r)},delete___:{value:i(o)}})};x.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0, -configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},"delete":{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof s?!function(){function r(){function e(t,e){return u?c.has(t)?c.get(t):u.get___(t,e):c.get(t,e)}function r(t){return c.has(t)||(u?u.has___(t):!1)}function n(t){var e=!!c.delete(t);return u?u.delete___(t)||e:e}this instanceof x||a();var l,c=new s,u=void 0,f=!1;return l=o?function(t,e){return c.set(t,e),c.has(t)||(u||(u=new x),u.set(t,e)),this}:function(t,e){if(f)try{c.set(t,e)}catch(r){u||(u=new x),u.set___(t,e)}else c.set(t,e);return this},Object.create(x.prototype,{get___:{value:i(e)},has___:{value:i(r)},set___:{value:i(l)},delete___:{value:i(n)},permitHostObjects___:{value:i(function(e){if(e!==t)throw new Error("bogus call to permitHostObjects___");f=!0})}})}o&&"undefined"!=typeof Proxy&&(Proxy=void 0),r.prototype=x.prototype,e.exports=r,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=x)}}()},{}],288:[function(t,e,r){function n(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:i(e,t)}}var i=t("./hidden-store.js");e.exports=n},{"./hidden-store.js":289}],289:[function(t,e,r){function n(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}e.exports=n},{}],290:[function(t,e,r){function n(){var t=i();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){t(e).value=r},has:function(e){return"value"in t(e)},"delete":function(e){return delete t(e).value}}}var i=t("./create-store.js");e.exports=n},{"./create-store.js":288}],291:[function(t,e,r){e.exports=t("cwise-compiler")({args:["array",{offset:[1],array:0},"scalar","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\n var _inline_1_da = _inline_1_arg0_ - _inline_1_arg3_\n var _inline_1_db = _inline_1_arg1_ - _inline_1_arg3_\n if((_inline_1_da >= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":83}],292:[function(t,e,r){"use strict";function n(t,e){var r=[];return e=+e||0,i(t.hi(t.shape[0]-1),r,e),r}e.exports=n;var i=t("./lib/zc-core")},{"./lib/zc-core":291}],293:[function(t,e,r){"use strict";e.exports=["",{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],294:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:o({},i,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":367,"../../plots/cartesian/constants":398,"../../plots/font_attributes":411,"./arrow_paths":293}],295:[function(t,e,r){"use strict";function n(t,e){function r(e,r){return c.coerce(t,n,v.layoutAttributes,e,r)}var n={};r("opacity"),r("align"),r("bgcolor");var i=r("bordercolor"),a=f.opacity(i);r("borderpad");var o=r("borderwidth"),s=r("showarrow");s&&(r("arrowcolor",a?n.bordercolor:f.defaultLine),r("arrowhead"),r("arrowsize"),r("arrowwidth",2*(a&&o||1)),r("ax"),r("ay"),c.noneOrAll(t,n,["ax","ay"])),r("text",s?" ":"new text"),r("textangle"),c.coerceFont(r,"font",e.font);for(var l=["x","y"],h=0;2>h;h++){var d=l[h],p={_fullLayout:e},g=u.coerceRef(t,n,p,d),m=.5;if("paper"!==g){var y=u.getFromId(p,g);if(m=y.range[0]+m*(y.range[1]-y.range[0]),-1!==["date","category"].indexOf(y.type)&&"string"==typeof t[d]){var b;"date"===y.type?(b=c.dateTime2ms(t[d]),b!==!1&&(t[d]=b)):(y._categories||[]).length&&(b=y._categories.indexOf(t[d]),-1!==b&&(t[d]=b))}}r(d,m),s||r(d+"anchor")}return c.noneOrAll(t,n,["x","y"]),n}function i(t){var e=t._fullLayout;e.annotations.forEach(function(e){var r=u.getFromId(t,e.xref),n=u.getFromId(t,e.yref);if(r||n){var i=(e._xsize||0)/2,a=e._xshift||0,o=(e._ysize||0)/2,s=e._yshift||0,l=i-a,c=i+a,f=o-s,h=o+s;if(e.showarrow){var d=3*e.arrowsize*e.arrowwidth;l=Math.max(l,d),c=Math.max(c,d),f=Math.max(f,d),h=Math.max(h,d)}r&&r.autorange&&u.expand(r,[r.l2c(e.x)],{ppadplus:c,ppadminus:l}),n&&n.autorange&&u.expand(n,[n.l2c(e.y)],{ppadplus:h,ppadminus:f})}})}function a(t,e,r,n,i,a,o,s){var l=r-t,c=i-t,u=o-i,f=n-e,h=a-e,d=s-a,p=l*d-u*f;if(0===p)return null;var g=(c*d-u*h)/p,v=(c*f-l*h)/p;return 0>v||v>1||0>g||g>1?null:{x:t+l*g,y:e+f*g}}var o=t("d3"),s=t("fast-isnumeric"),l=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),h=t("../drawing"),d=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var r=t.annotations||[],i=e.annotations=[],a=0;at?"left":t>2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var n=W.select(".annotation-math-group"),i=!n.empty(),s=h.bBox((i?n:tt).node()),d=s.width,m=s.height,y=Math.round(d+2*Q),b=Math.round(m+2*Q);U._w=d,U._h=m;var x=!1;if(["x","y"].forEach(function(e){var n,i=u.getFromId(t,U[e+"ref"]||e),a=(G+("x"===e?0:90))*Math.PI/180,o=y*Math.abs(Math.cos(a))+b*Math.abs(Math.sin(a)),s=U[e+"anchor"];if(i){if(!i.autorange&&(U[e]-i.range[0])*(U[e]-i.range[1])>0)return void(x=!0);H[e]=i._offset+i.l2p(U[e]),n=.5}else n=U[e],"y"===e&&(n=1-n),H[e]="x"===e?S.l+S.w*n:S.t+S.h*n;var l=0;l=U.showarrow?U["a"+e]:o*r(n,s),H[e]+=l,U["_"+e+"type"]=i&&i.type,U["_"+e+"size"]=o,U["_"+e+"shift"]=l}),x)return void W.remove();var w,k;U.showarrow&&(w=c.constrain(H.x-U.ax,1,_.width-1),k=c.constrain(H.y-U.ay,1,_.height-1)),H.x=c.constrain(H.x,1,_.width-1),H.y=c.constrain(H.y,1,_.height-1);var A=Q-s.top,M=Q-s.left;i?n.select("svg").attr({x:Q-1,y:Q}):(tt.attr({x:M,y:A}),tt.selectAll("tspan.line").attr({y:A,x:M})),$.call(h.setRect,Z/2,Z/2,y-Z,b-Z);var T=Math.round(H.x-y/2),E=Math.round(H.y-b/2);W.attr("transform","translate("+T+", "+E+")");var L="annotations["+e+"]",C=function(r,n){o.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var i=H.x+r,s=H.y+n,u=c.rotationXYMatrix(G,i,s),d=c.apply2DTransform(u),p=c.apply2DTransform2(u),m=$.attr("width")/2,y=$.attr("height")/2,b=[[i-m,s-y,i-m,s+y],[i-m,s+y,i+m,s+y],[i+m,s+y,i+m,s-y],[i+m,s-y,i-m,s-y]].map(p);if(!b.reduce(function(t,e){return t^!!a(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){b.forEach(function(t){var e=a(i,s,w,k,t[0],t[1],t[2],t[3]);e&&(i=e.x,s=e.y)});var x=U.arrowwidth,_=U.arrowcolor,A=Y.append("g").style({opacity:f.opacity(_)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),M=A.append("path").attr("d","M"+i+","+s+"L"+w+","+k).style("stroke-width",x+"px").call(f.stroke,f.rgb(_));v.arrowhead(M,U.arrowhead,"end",U.arrowsize);var T=A.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(i-w)+","+(s-k),transform:"translate("+w+","+k+")"}).style("stroke-width",x+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var E,C,z;g.init({element:T.node(),prepFn:function(){C=Number(W.attr("x")),z=Number(W.attr("y")),E={},V&&V.autorange&&(E[V._name+".autorange"]=!0),q&&q.autorange&&(E[q._name+".autorange"]=!0)},moveFn:function(t,e){A.attr("transform","translate("+t+","+e+")");var r=d(C,z),n=r[0]+t,i=r[1]+e;W.call(h.setPosition,n,i),E[L+".x"]=V?U.x+t/V._m:(w+t-S.l)/S.w,E[L+".y"]=q?U.y+e/q._m:1-(k+e-S.t)/S.h,X.attr({transform:"rotate("+G+","+n+","+i+")"})},doneFn:function(e){if(e){l.relayout(t,E);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}};U.showarrow&&C(0,0);var z=c.rotationXYMatrix(G,H.x,H.y),P=c.apply2DTransform(z);if(t._context.editable){var R,O,I;g.init({element:W.node(),prepFn:function(){R=Number(W.attr("x")),O=Number(W.attr("y")),I={}},moveFn:function(t,e){W.call(h.setPosition,R+t,O+e);var r="pointer";if(U.showarrow)I[L+".ax"]=U.ax+t,I[L+".ay"]=U.ay+e,C(t,e);else{if(V)I[L+".x"]=U.x+t/V._m;else{var n=U._xsize/S.w,i=U.x+U._xshift/S.w-n/2;I[L+".x"]=g.align(i+t/S.w,n,0,1,U.xanchor)}if(q)I[L+".y"]=U.y+e/q._m;else{var a=U._ysize/S.h,o=U.y-U._yshift/S.h-a/2;I[L+".y"]=g.align(o-e/S.h,a,0,1,U.yanchor)}V&&q||(r=g.cursor(V?.5:I[L+".x"],q?.5:I[L+".y"],U.xanchor,U.yanchor))}var s=P(R,O),l=s[0]+t,c=s[1]+e;W.call(h.setPosition,l,c),X.attr({transform:"rotate("+G+","+l+","+c+")"}),p(W,r)},doneFn:function(e){if(p(W),e){l.relayout(t,I);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}var b,x=t.layout,_=t._fullLayout;if(!s(e)||-1===e){if(!e&&Array.isArray(i))return x.annotations=i,v.supplyLayoutDefaults(x,_),void v.drawAll(t);if("remove"===i)return delete x.annotations,_.annotations=[],void v.drawAll(t);if(r&&"add"!==i){for(b=0;b<_.annotations.length;b++)v.draw(t,b,r,i);return}e=_.annotations.length,_.annotations.push({})}if(!r&&i){if("remove"===i){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),x.annotations.splice(e,1),b=e;b<_.annotations.length;b++)_._infolayer.selectAll('.annotation[data-index="'+(b+1)+'"]').attr("data-index",String(b)),v.draw(t,b);return}if("add"===i||c.isPlainObject(i)){_.annotations.splice(e,0,{});var w=c.isPlainObject(i)?c.extendFlat({},i):{text:"New text"};for(x.annotations?x.annotations.splice(e,0,w):x.annotations=[w],b=_.annotations.length-1;b>e;b--)_._infolayer.selectAll('.annotation[data-index="'+(b-1)+'"]').attr("data-index",String(b)),v.draw(t,b)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=x.annotations[e],A=_.annotations[e];if(k){var M={xref:k.xref,yref:k.yref},T={};"string"==typeof r&&r?T[r]=i:c.isPlainObject(r)&&(T=r);var E=Object.keys(T);for(b=0;bb;b++){var z=C[b];if(void 0===T[z]&&void 0!==k[z]){var P=u.getFromId(t,u.coerceRef(M,{},t,z)),R=u.getFromId(t,u.coerceRef(k,{},t,z)),O=k[z],I=A["_"+z+"type"];if(void 0!==T[z+"ref"]){var N="auto"===k[z+"anchor"],j="x"===z?S.w:S.h,F=(A["_"+z+"size"]||0)/(2*j);if(P&&R)O=(O-P.range[0])/(P.range[1]-P.range[0]),O=R.range[0]+O*(R.range[1]-R.range[0]);else if(P){if(O=(O-P.range[0])/(P.range[1]-P.range[0]),O=P.domain[0]+O*(P.domain[1]-P.domain[0]),N){var B=O+F,D=O-F;2/3>O+D?O=D:O+B>4/3&&(O=B)}}else R&&(N&&(1/3>O?O+=F:O>2/3&&(O-=F)),O=(O-R.domain[0])/(R.domain[1]-R.domain[0]),O=R.range[0]+O*(R.range[1]-R.range[0]))}R&&R===P&&I&&("log"===I&&"log"!==R.type?O=Math.pow(10,O):"log"!==I&&"log"===R.type&&(O=O>0?Math.log(O)/Math.LN10:void 0)),k[z]=O}}var U=n(k,_);_.annotations[e]=U;var V=u.getFromId(t,U.xref),q=u.getFromId(t,U.yref),H={x:0,y:0},G=+U.textangle||0,Y=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",U.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:U})}),X=Y.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),W=X.append("g"),Z=U.borderwidth,K=U.borderpad,Q=Z+K,$=W.append("rect").attr("class","bg").style("stroke-width",Z+"px").call(f.stroke,U.bordercolor).call(f.fill,U.bgcolor),J=U.font,tt=W.append("text").classed("annotation",!0).attr("data-unformatted",U.text).text(U.text);t._context.editable?tt.call(d.makeEditable,W).call(m).on("edit",function(r){U.text=r,this.attr({"data-unformatted":U.text}),this.call(m);var n={};n["annotations["+e+"].text"]=U.text,V&&V.autorange&&(n[V._name+".autorange"]=!0),q&&q.autorange&&(n[q._name+".autorange"]=!0),l.relayout(t,n)}):tt.call(m),X.attr({transform:"rotate("+G+","+H.x+","+H.y+")"}).call(h.setPosition,H.x,H.y)}},v.arrowhead=function(t,e,r,n){s(n)||(n=1);var i=t.node(),a=v.ARROWPATHS[e||0];if(a){"string"==typeof r&&r||(r="end");var l,c,u,d,p=(h.getPx(t,"stroke-width")||1)*n,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=r.indexOf("start")>=0,b=r.indexOf("end")>=0,x=a.backoff*p;if("line"===i.nodeName){if(l={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(l.y-c.y,l.x-c.x),d=u+Math.PI,x){var _=x*Math.cos(u),w=x*Math.sin(u);y&&(l.x-=_,l.y-=w,t.attr({x1:l.x,y1:l.y})),b&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===i.nodeName){var k=i.getTotalLength(),A="";if(y){var M=i.getPointAtLength(0),T=i.getPointAtLength(.1);u=Math.atan2(M.y-T.y,M.x-T.x),l=i.getPointAtLength(Math.min(x,k)),x&&(A="0px,"+x+"px,")}if(b){var E=i.getPointAtLength(k),L=i.getPointAtLength(k-.1);if(d=Math.atan2(E.y-L.y,E.x-L.x),c=i.getPointAtLength(Math.max(0,k-x)),x){var S=A?2*x:x;A+=k-S+"px,"+k+"px"}}else A&&(A+=k+"px");A&&t.style("stroke-dasharray",A)}var C=function(r,n){e>5&&(n=0),o.select(i.parentElement).append("path").attr({"class":t.attr("class"),d:a.path,transform:"translate("+r.x+","+r.y+")rotate("+180*n/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(l,u),b&&C(c,d)}},v.calcAutorange=function(t){var e=t._fullLayout,r=e.annotations;if(r.length&&t._fullData.length){var n={};r.forEach(function(t){n[t.xref]=!0,n[t.yref]=!0});var a=u.list(t).filter(function(t){return t.autorange&&n[t._id]});if(a.length)return c.syncOrAsync([v.drawAll,i],t)}}},{"../../lib":372,"../../lib/setcursor":380,"../../lib/svg_text_utils":384,"../../plotly":390,"../../plots/cartesian/axes":393,"../color":297,"../dragelement":317,"../drawing":319,"./arrow_paths":293,"./attributes":294,d3:87,"fast-isnumeric":95}],296:[function(t,e,r){"use strict";r.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],r.defaultLine="#444",r.lightLine="#eee",r.background="#fff",r.lightFraction=1e3/11},{}],297:[function(t,e,r){"use strict";function n(t){if(a(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var r=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!r)return t;var n=r[1].trim().split(/\s*[\s,]\s*/),i="a"===e.charAt(3)&&4===n.length;if(!i&&3!==n.length)return t;for(var o=0;o=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}var i=t("tinycolor2"),a=t("fast-isnumeric"),o=e.exports={},s=t("./attributes");o.defaults=s.defaults,o.defaultLine=s.defaultLine,o.lightLine=s.lightLine,o.background=s.background,o.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},o.rgb=function(t){return o.tinyRGB(i(t))},o.opacity=function(t){return t?i(t).getAlpha():0},o.addOpacity=function(t,e){var r=i(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},o.combine=function(t,e){var r=i(t).toRgb();if(1===r.a)return i(t).toRgbString();var n=i(e||o.background).toRgb(),a=1===n.a?n:{r:255*(1-n.a)+n.r*n.a,g:255*(1-n.a)+n.g*n.a,b:255*(1-n.a)+n.b*n.a},s={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return i(s).toRgbString()},o.stroke=function(t,e){var r=i(e);t.style({stroke:o.tinyRGB(r),"stroke-opacity":r.getAlpha()})},o.fill=function(t,e){var r=i(e);t.style({fill:o.tinyRGB(r),"fill-opacity":r.getAlpha()})},o.clean=function(t){if(t&&"object"==typeof t){var e,r,i,a,s=Object.keys(t);for(e=0;el&&(a[1]-=(ot-l)/2)):r.node()&&!r.classed("js-placeholder")&&(ot=h.bBox(e.node()).height),ot){if(ot+=5,"top"===x.titleside)$.domain[1]-=ot/M.h,a[1]*=-1;else{$.domain[0]+=ot/M.h;var u=Math.max(1,r.selectAll("tspan.line").size());a[1]+=(1-u)*l}e.attr("transform","translate("+a+")"),$.setScale()}}it.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(M.h*(1-$.domain[1]))+")");var f=it.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var r=[0===e?E[0]:(S[e]+S[e-1])/2,e===S.length-1?E[1]:(S[e]+S[e+1])/2].map($.c2p).map(Math.round);e!==S.length-1&&(r[1]+=r[1]>r[0]?1:-1);var a=z(t).replace("e-",""),o=i(a).toHexString();n.select(this).attr({x:Y,width:Math.max(B,2),y:n.min(r),height:Math.max(n.max(r)-n.min(r),2),fill:o})});var d=it.select(".cblines").selectAll("path.cbline").data(x.line.color&&x.line.width?L:[]);return d.enter().append("path").classed("cbline",!0),d.exit().remove(),d.each(function(t){n.select(this).attr("d","M"+Y+","+(Math.round($.c2p(t))+x.line.width/2%1)+"h"+B).call(h.lineGroupStyle,x.line.width,C(t),x.line.dash)}),$._axislayer.selectAll("g."+$._id+"tick,path").remove(),$._pos=Y+B+(x.outlinewidth||0)/2-("outside"===x.ticks?1:0),$.side="right",c.syncOrAsync([function(){return s.doTicks(t,$,!0)},function(){if(-1===["top","bottom"].indexOf(x.titleside)){var e=$.titlefont.size,r=$._offset+$._length/2,i=M.l+($.position||0)*M.w+("right"===$.side?10+e*($.showticklabels?1:.5):-10-e*($.showticklabels?.5:0));w("h"+$._id+"title",{avoid:{selection:n.select(t).selectAll("g."+$._id+"tick"),side:x.titleside,offsetLeft:M.l,offsetTop:M.t,maxShift:A.width},attributes:{x:i,y:r,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,r){var n,i=b();n=o.traceIs(i,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var a={propContainer:$,propName:n,traceIndex:i.index,dfltName:"colorscale",containerGroup:it.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;it.selectAll("."+s+",."+s+"-math-group").remove(),p.draw(t,e,u(a,r||{}))}function k(){var r=B+x.outlinewidth/2+h.bBox($._axislayer.node()).width;if(N=at.select("text"),N.node()&&!N.classed("js-placeholder")){var n,i=at.select(".h"+$._id+"title-math-group").node();n=i&&-1!==["top","bottom"].indexOf(x.titleside)?h.bBox(i).width:h.bBox(at.node()).right-Y-M.l,r=Math.max(r,n)}var a=2*x.xpad+r+x.borderwidth+x.outlinewidth/2,s=Z-K;it.select(".cbbg").attr({x:Y-x.xpad-(x.borderwidth+x.outlinewidth)/2,y:K-H,width:Math.max(a,2),height:Math.max(s+2*H,2)}).call(d.fill,x.bgcolor).call(d.stroke,x.bordercolor).style({"stroke-width":x.borderwidth}),it.selectAll(".cboutline").attr({x:Y,y:K+x.ypad+("top"===x.titleside?ot:0),width:Math.max(B,2),height:Math.max(s-2*x.ypad-ot,2)}).call(d.stroke,x.outlinecolor).style({fill:"None","stroke-width":x.outlinewidth});var l=({center:.5,right:1}[x.xanchor]||0)*a;it.attr("transform","translate("+(M.l-l)+","+M.t+")"),o.autoMargin(t,e,{x:x.x,y:x.y,l:a*({right:1,center:.5}[x.xanchor]||0),r:a*({left:1,center:.5}[x.xanchor]||0),t:s*({bottom:1,middle:.5}[x.yanchor]||0),b:s*({top:1,middle:.5}[x.yanchor]||0)})}var A=t._fullLayout,M=A._size;if("function"!=typeof x.fillcolor&&"function"!=typeof x.line.color)return void A._infolayer.selectAll("g."+e).remove();var T,E=n.extent(("function"==typeof x.fillcolor?x.fillcolor:x.line.color).domain()),L=[],S=[],C="function"==typeof x.line.color?x.line.color:function(){return x.line.color},z="function"==typeof x.fillcolor?x.fillcolor:function(){return x.fillcolor},P=x.levels.end+x.levels.size/100,R=x.levels.size,O=1.001*E[0]-.001*E[1],I=1.001*E[1]-.001*E[0];for(T=x.levels.start;0>(T-P)*R;T+=R)T>O&&I>T&&L.push(T);if("function"==typeof x.fillcolor)if(x.filllevels)for(P=x.filllevels.end+x.filllevels.size/100,R=x.filllevels.size,T=x.filllevels.start;0>(T-P)*R;T+=R)T>E[0]&&T1){var nt=Math.pow(10,Math.floor(Math.log(rt)/Math.LN10));tt*=nt*c.roundUp(rt/nt,[2,5,10]),(Math.abs(x.levels.start)/x.levels.size+1e-6)%1<2e-6&&($.tick0=0)}$.dtick=tt}$.domain=[W+G,W+V-G],$.setScale();var it=A._infolayer.selectAll("g."+e).data([0]);it.enter().append("g").classed(e,!0).each(function(){var t=n.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),it.attr("transform","translate("+Math.round(M.l)+","+Math.round(M.t)+")");var at=it.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(M.l)+",-"+Math.round(M.t)+")");$._axislayer=it.select(".cbaxis");var ot=0;if(-1!==["top","bottom"].indexOf(x.titleside)){var st,lt=M.l+(x.x+q)*M.w,ct=$.titlefont.size;st="top"===x.titleside?(1-(W+V-G))*M.h+M.t+3+.75*ct:(1-(W+G))*M.h+M.t-3-.25*ct,w($._id+"title",{attributes:{x:lt,y:st,"text-anchor":"start"}})}var ut=c.syncOrAsync([o.previousPromises,_,o.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,ht,dt;l.init({element:it.node(),prepFn:function(){ft=it.attr("transform"),f(it)},moveFn:function(t,e){it.attr("transform",ft+" translate("+t+","+e+")"),ht=l.align(X+t/M.w,D,0,1,x.xanchor),dt=l.align(W-e/M.h,V,0,1,x.yanchor);var r=l.getCursor(ht,dt,x.xanchor,x.yanchor);f(it,r)},doneFn:function(e){f(it),e&&void 0!==ht&&void 0!==dt&&a.restyle(t,{"colorbar.x":ht,"colorbar.y":dt},b().index)}})}return ut}function b(){var r,n,i=e.substr(2);for(r=0;ru*f?i.RdBu:u>=0?i.Reds:i.Blues,l.colorscale=h,s.reversescale&&(h=a(h)),s.colorscale=h)}},{"../../lib":372,"./flip_scale":307,"./scales":314}],305:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":314}],306:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,c,u){var f=u.prefix,h=u.cLetter,d=f.slice(0,f.length-1),p=f?i.nestedProperty(t,d).get()||{}:t,g=f?i.nestedProperty(e,d).get()||{}:e,v=p[h+"min"],m=p[h+"max"],y=p.colorscale,b=n(v)&&n(m)&&m>v;c(f+h+"auto",!b),c(f+h+"min"),c(f+h+"max");var x;void 0!==y&&(x=!s(y)),c(f+"autocolorscale",x);var _=c(f+"colorscale"),w=c(f+"reversescale");if(w&&(g.colorscale=l(_)),"marker.line."!==f){var k;f&&(k=a(p));var A=c(f+"showscale",k);A&&o(p,g,r)}}},{"../../lib":372,"../colorbar/defaults":299,"../colorbar/has_colorbar":301,"./flip_scale":307,"./is_valid_scale":311, -"fast-isnumeric":95}],307:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=t.length,n=new Array(r),i=r-1,a=0;i>=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],308:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return e||(e=i),t?("string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e):e}},{"./default_scale":305,"./is_valid_scale_array":312,"./scales":314}],309:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(Array.isArray(o))for(var l=0;lh;h++)l=t[h],u[h]=e+l[0]*(r-e),f[h]=i(l[1]).toRgb();var d=n.scale.linear().domain(u).interpolate(n.interpolateObject).range(f);return function(t){if(a(t)){var n=o.constrain(t,e,r),l=d(n);return i(l).toRgbString()}return i(t).isValid()?t:s.defaultLine}}},{"../../lib":372,"../color":297,d3:87,"fast-isnumeric":95,tinycolor2:275}],314:[function(t,e,r){"use strict";e.exports={Greys:[[0,"rgb(0,0,0)"],[1,"rgb(255,255,255)"]],YlGnBu:[[0,"rgb(8,29,88)"],[.125,"rgb(37,52,148)"],[.25,"rgb(34,94,168)"],[.375,"rgb(29,145,192)"],[.5,"rgb(65,182,196)"],[.625,"rgb(127,205,187)"],[.75,"rgb(199,233,180)"],[.875,"rgb(237,248,217)"],[1,"rgb(255,255,217)"]],Greens:[[0,"rgb(0,68,27)"],[.125,"rgb(0,109,44)"],[.25,"rgb(35,139,69)"],[.375,"rgb(65,171,93)"],[.5,"rgb(116,196,118)"],[.625,"rgb(161,217,155)"],[.75,"rgb(199,233,192)"],[.875,"rgb(229,245,224)"],[1,"rgb(247,252,245)"]],YlOrRd:[[0,"rgb(128,0,38)"],[.125,"rgb(189,0,38)"],[.25,"rgb(227,26,28)"],[.375,"rgb(252,78,42)"],[.5,"rgb(253,141,60)"],[.625,"rgb(254,178,76)"],[.75,"rgb(254,217,118)"],[.875,"rgb(255,237,160)"],[1,"rgb(255,255,204)"]],Bluered:[[0,"rgb(0,0,255)"],[1,"rgb(255,0,0)"]],RdBu:[[0,"rgb(5,10,172)"],[.35,"rgb(106,137,247)"],[.5,"rgb(190,190,190)"],[.6,"rgb(220,170,132)"],[.7,"rgb(230,145,90)"],[1,"rgb(178,10,28)"]],Reds:[[0,"rgb(220,220,220)"],[.2,"rgb(245,195,157)"],[.4,"rgb(245,160,105)"],[1,"rgb(178,10,28)"]],Blues:[[0,"rgb(5,10,172)"],[.35,"rgb(40,60,190)"],[.5,"rgb(70,100,245)"],[.6,"rgb(90,120,245)"],[.7,"rgb(106,137,247)"],[1,"rgb(220,220,220)"]],Picnic:[[0,"rgb(0,0,255)"],[.1,"rgb(51,153,255)"],[.2,"rgb(102,204,255)"],[.3,"rgb(153,204,255)"],[.4,"rgb(204,204,255)"],[.5,"rgb(255,255,255)"],[.6,"rgb(255,204,255)"],[.7,"rgb(255,153,255)"],[.8,"rgb(255,102,204)"],[.9,"rgb(255,102,102)"],[1,"rgb(255,0,0)"]],Rainbow:[[0,"rgb(150,0,90)"],[.125,"rgb(0,0,200)"],[.25,"rgb(0,25,255)"],[.375,"rgb(0,152,255)"],[.5,"rgb(44,255,150)"],[.625,"rgb(151,255,0)"],[.75,"rgb(255,234,0)"],[.875,"rgb(255,111,0)"],[1,"rgb(255,0,0)"]],Portland:[[0,"rgb(12,51,131)"],[.25,"rgb(10,136,186)"],[.5,"rgb(242,211,56)"],[.75,"rgb(242,143,56)"],[1,"rgb(217,30,30)"]],Jet:[[0,"rgb(0,0,131)"],[.125,"rgb(0,60,170)"],[.375,"rgb(5,255,255)"],[.625,"rgb(255,255,0)"],[.875,"rgb(250,0,0)"],[1,"rgb(128,0,0)"]],Hot:[[0,"rgb(0,0,0)"],[.3,"rgb(230,0,0)"],[.6,"rgb(255,210,0)"],[1,"rgb(255,255,255)"]],Blackbody:[[0,"rgb(0,0,0)"],[.2,"rgb(230,0,0)"],[.4,"rgb(230,210,0)"],[.7,"rgb(255,255,255)"],[1,"rgb(160,200,255)"]],Earth:[[0,"rgb(0,0,130)"],[.1,"rgb(0,180,180)"],[.2,"rgb(40,210,40)"],[.4,"rgb(230,230,50)"],[.6,"rgb(120,70,20)"],[1,"rgb(255,255,255)"]],Electric:[[0,"rgb(0,0,0)"],[.15,"rgb(30,0,100)"],[.4,"rgb(120,0,100)"],[.6,"rgb(160,90,0)"],[.8,"rgb(230,200,0)"],[1,"rgb(255,250,220)"]],Viridis:[[0,"#440154"],[.06274509803921569,"#48186a"],[.12549019607843137,"#472d7b"],[.18823529411764706,"#424086"],[.25098039215686274,"#3b528b"],[.3137254901960784,"#33638d"],[.3764705882352941,"#2c728e"],[.4392156862745098,"#26828e"],[.5019607843137255,"#21918c"],[.5647058823529412,"#1fa088"],[.6274509803921569,"#28ae80"],[.6901960784313725,"#3fbc73"],[.7529411764705882,"#5ec962"],[.8156862745098039,"#84d44b"],[.8784313725490196,"#addc30"],[.9411764705882353,"#d8e219"],[1,"#fde725"]]}},{}],315:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i){var a=(t-r)/(n-r),o=a+e/(n-r),s=(a+o)/2;return"left"===i||"bottom"===i?a:"center"===i||"middle"===i?s:"right"===i||"top"===i?o:2/3-s>a?a:o>4/3-s?o:s}},{}],316:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":372}],317:[function(t,e,r){"use strict";function n(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function i(t){t._dragging=!1,t._replotPending&&a.plot(t)}var a=t("../../plotly"),o=t("../../lib"),s=t("../../plots/cartesian/constants"),l=e.exports={};l.align=t("./align"),l.getCursor=t("./cursor");var c=t("./unhover");l.unhover=c.wrapped,l.unhoverRaw=c.raw,l.init=function(t){function e(e){return p._dragged=!1,p._dragging=!0,c=e.clientX,u=e.clientY,d=e.target,f=(new Date).getTime(),f-p._mouseDownTimev&&(g=Math.max(g-1,1)),t.doneFn&&t.doneFn(p._dragged,g),!p._dragged){var r=document.createEvent("MouseEvents");r.initEvent("click",!0,!0),d.dispatchEvent(r)}return i(p),p._dragged=!1,o.pauseEvent(e)}var c,u,f,h,d,p=o.getPlotDiv(t.element)||{},g=1,v=s.DBLCLICKDELAY;p._mouseDownTime||(p._mouseDownTime=0),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":372,"../../plotly":390,"../../plots/cartesian/constants":398,"./align":315,"./cursor":316,"./unhover":318}],318:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=e.exports={};i.wrapped=function(t,e,r){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),i.raw(t,e,r)},i.raw=function(t,e){var r=t._fullLayout;e||(e={}),e.target&&n.triggerHandler(t,"plotly_beforehover",e)===!1||(r._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":366}],319:[function(t,e,r){"use strict";function n(t,e,r,n){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],c=Math.pow(a*a+o*o,x/2),u=Math.pow(s*s+l*l,x/2),f=(u*u*a-c*c*s)*n,h=(u*u*o-c*c*l)*n,d=3*u*(c+u),p=3*c*(c+u);return[[i.round(e[0]+(d&&f/d),2),i.round(e[1]+(d&&h/d),2)],[i.round(e[0]-(p&&f/p),2),i.round(e[1]-(p&&h/p),2)]]}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../plots/plots"),s=t("../color"),l=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../traces/scatter/subtypes"),d=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,r,n){e&&e.family&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},p.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},p.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},p.setRect=function(t,e,r,n,i){t.call(p.setPosition,e,r).call(p.setSize,n,i)},p.translatePoints=function(t,e,r){t.each(function(t){var n=t.xp||e.c2p(t.x),o=t.yp||r.c2p(t.y),s=i.select(this);a(n)&&a(o)?"text"===this.nodeName?s.attr("x",n).attr("y",o):s.attr("transform","translate("+n+","+o+")"):s.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:1>e?1:Math.round(e):r||0},p.lineGroupStyle=function(t,e,r,n){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=n||a.dash||"";i.select(this).call(s.stroke,r||a.color).call(p.dashLine,l,o)})},p.dashLine=function(t,e,r){var n=Math.max(r,3);"solid"===e?e="":"dot"===e?e=n+"px,"+n+"px":"dash"===e?e=3*n+"px,"+3*n+"px":"longdash"===e?e=5*n+"px,"+5*n+"px":"dashdot"===e?e=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===e&&(e=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var r=i.select(this);try{r.call(s.fill,e[0].trace.fillcolor)}catch(n){console.log(n,t),r.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var r=e.marker,n=r.line;if(o.traceIs(e,"symbols")){var a=d(e);t.attr("d",function(t){var n;n="various"===t.ms||"various"===r.size?3:h.isBubble(e)?a(t.ms):(r.size||6)/2,t.mrc=n;var i=p.symbolNumber(t.mx||r.symbol)||0,o=i%100;return t.om=i%200>=100,p.symbolFuncs[o](n)+(i>=200?m:"")}).style("opacity",function(t){return(t.mo+1||r.opacity+1)-1})}var l=(e._input||{}).marker||{},c=p.tryColorscale(r,l,""),u=p.tryColorscale(r,l,"line.");t.each(function(t){var e,a,o;t.so?(o=n.outlierwidth,a=n.outliercolor,e=r.outliercolor):(o=(t.mlw+1||n.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,a="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(n.color)?s.defaultLine:n.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(r.color)?s.defaultLine:r.color||"rgba(0,0,0,0)");var l=i.select(this);t.om?l.call(s.stroke,e).style({"stroke-width":(o||1)+"px",fill:"none"}):(l.style("stroke-width",o+"px").call(s.fill,e),o&&l.call(s.stroke,a))})}},p.tryColorscale=function(t,e,r){var n=c.nestedProperty(t,r+"color").get(),i=c.nestedProperty(t,r+"colorscale").get(),o=c.nestedProperty(t,r+"cauto").get(),s=c.nestedProperty(t,r+"cmin"),u=c.nestedProperty(t,r+"cmax"),f=s.get(),h=u.get();return i&&Array.isArray(n)?(!o&&a(f)&&a(h)||(f=1/0,h=-(1/0),n.forEach(function(t){a(t)&&(f>t&&(f=+t),t>h&&(h=+t))}),f>h&&(f=0,h=1),s.set(f),u.set(h),c.nestedProperty(e,r+"cmin").set(f),c.nestedProperty(e,r+"cmax").set(h)),l.makeScaleFunction(i,f,h)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},b=1.3;p.textPointStyle=function(t,e){t.each(function(t){var r=i.select(this),n=t.tx||e.text;if(!n||Array.isArray(n))return void r.remove();var o=t.tp||e.textposition,s=-1!==o.indexOf("top")?"top":-1!==o.indexOf("bottom")?"bottom":"middle",l=-1!==o.indexOf("left")?"end":-1!==o.indexOf("right")?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=a(c)&&c>0?c:0,r.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",l).text(n).call(u.convertToTspans);var h=i.select(this.parentNode),d=r.selectAll("tspan.line"),g=((d[0].length||1)-1)*b+1,v=y[l]*f,m=.75*c+y[s]*f+(y[s]-1)*g*c/2;h.attr("transform","translate("+v+","+m+")"),g>1&&d.attr({x:r.attr("x"),y:r.attr("y")})})};var x=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,i="M"+t[0],a=[];for(r=1;rr;r++)o.push(n(t[r-1],t[r],t[r+1],e));for(o.push(n(t[a-1],t[a],t[0],e)),r=1;a>=r;r++)i+="C"+o[r-1][1]+" "+o[r][0]+" "+t[r];return i+="C"+o[a][1]+" "+o[0][0]+" "+t[0]+"Z"};var _={hv:function(t,e){return"H"+i.round(e[0],2)+"V"+i.round(e[1],2)},vh:function(t,e){return"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},hvh:function(t,e){return"H"+i.round((t[0]+e[0])/2,2)+"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},vhv:function(t,e){return"V"+i.round((t[1]+e[1])/2,2)+"H"+i.round(e[0],2)+"V"+i.round(e[1],2)}},w=function(t,e){return"L"+i.round(e[0],2)+","+i.round(e[1],2)};p.steps=function(t){var e=_[t]||w;return function(t){for(var r="M"+i.round(t[0][0],2)+","+i.round(t[0][1],2),n=1;n=A&&(i.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(l),c.extendFlat({},l)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var r="#"+e,n=i.select("base");n.size()&&n.attr("href")&&(r=window.location.href+r),t.attr("clip-path","url("+r+")")}},{"../../constants/xmlns_namespaces":360,"../../lib":372,"../../lib/svg_text_utils":384,"../../plots/plots":441,"../../traces/scatter/make_bubble_size_func":553,"../../traces/scatter/subtypes":559,"../color":297,"../colorscale":310,"./symbol_defs":320,d3:87,"fast-isnumeric":95}],320:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+","+r+"H"+e+"L0,-"+i+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+",-"+r+"H"+e+"L0,"+i+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M"+r+",-"+e+"V"+e+"L-"+i+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+r+",-"+e+"V"+e+"L"+i+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(t*-.309,2),o=n.round(.809*t,2);return"M"+e+","+a+"L"+r+","+o+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(e*-.309,2),c=n.round(.118*e,2),u=n.round(.809*e,2),f=n.round(.382*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+c+"L"+o+","+u+"L0,"+f+"L-"+o+","+u+"L-"+a+","+c+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:87}],321:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],322:[function(t,e,r){"use strict";function n(t,e,r,n){var a=e["error_"+n]||{},l=a.visible&&-1!==["linear","log"].indexOf(r.type),c=[];if(l){for(var u=s(a),f=0;fs;s++)o[s]={x:r[s],y:i[s]};return o[0].trace=t,n.calc({calcdata:[o],_fullLayout:e}),o},n.plot=t("./plot"),n.style=t("./style"),n.hoverInfo=function(t,e,r){(e.error_y||{}).visible&&(r.yerr=t.yh-t.y,e.error_y.symmetric||(r.yerrneg=t.y-t.ys)),(e.error_x||{}).visible&&(r.xerr=t.xh-t.x,e.error_x.symmetric||(r.xerrneg=t.x-t.xs))}},{"./attributes":321,"./calc":322,"./defaults":324,"./plot":326,"./style":327}],326:[function(t,e,r){"use strict";function n(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};return void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0))),void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0))),n}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),s=t("../../traces/scatter/subtypes");e.exports=function(t,e){var r=e.x(),l=e.y();t.each(function(t){var e=t[0].trace,c=e.error_x||{},u=e.error_y||{},f=s.hasMarkers(e)&&e.marker.maxdisplayed>0;if(u.visible||c.visible){var h=i.select(this).selectAll("g.errorbar").data(o.identity);h.enter().append("g").classed("errorbar",!0),h.each(function(t){var e=i.select(this),o=n(t,r,l);if(!f||t.vis){var s;if(u.visible&&a(o.x)&&a(o.yh)&&a(o.ys)){var h=u.width;s="M"+(o.x-h)+","+o.yh+"h"+2*h+"m-"+h+",0V"+o.ys,o.noYS||(s+="m-"+h+",0h"+2*h),e.append("path").classed("yerror",!0).attr("d",s)}if(c.visible&&a(o.y)&&a(o.xh)&&a(o.xs)){var d=(c.copy_ystyle?u:c).width;s="M"+o.xh+","+(o.y-d)+"v"+2*d+"m0,-"+d+"H"+o.xs,o.noXS||(s+="m0,-"+d+"v"+2*d),e.append("path").classed("xerror",!0).attr("d",s)}}})}})}},{"../../lib":372,"../../traces/scatter/subtypes":559,d3:87,"fast-isnumeric":95}],327:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":297,d3:87}],328:[function(t,e,r){"use strict";r.isRightAnchor=function(t){return"right"===t.xanchor||"auto"===t.xanchor&&t.x>=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],329:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:a({},n,{}),traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":367,"../../plots/font_attributes":411,"../color/attributes":296}],330:[function(t,e,r){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],331:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/plots"),a=t("./attributes"),o=t("./helpers");e.exports=function(t,e,r){function s(t,e){return n.coerce(l,c,a,t,e)}for(var l=t.legend||{},c=e.legend={},u=0,f="normal",h=0;h1);p!==!1&&(s("bgcolor",e.paper_bgcolor),s("bordercolor"),s("borderwidth"),n.coerceFont(s,"font",e.font),s("traceorder",f),o.isGrouped(e.legend)&&s("tracegroupgap"),s("x"),s("xanchor"),s("y"),s("yanchor"),n.noneOrAll(l,c,["x","y"]))}},{"../../lib":372,"../../plots/plots":441,"./attributes":329,"./helpers":334}],332:[function(t,e,r){"use strict";function n(t,e,r,n,o){function c(t){l.util.convertToTspans(t,function(){e.firstRender&&(i(e,o),a(e))}),t.selectAll("tspan.line").attr({x:t.attr("x")})}var f=e._fullLayout,d=r[0].trace,p=u.traceIs(d,"pie"),g=d.index,v=p?r[0].label:d.name,m=s.select(t).selectAll("text.legendtext").data([0]);m.enter().append("text").classed("legendtext",!0),m.attr({x:40,y:0,"data-unformatted":v}).style("text-anchor","start").classed("user-select-none",!0).call(h.font,f.legend.font).text(v),e._context.editable&&!p?m.call(l.util.makeEditable).call(c).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(c),this.text()||(t=" "),l.restyle(e,"name",t,g)}):m.call(c)}function i(t,e){var r=t._fullLayout,n=r.legend,i=n.borderwidth;n.width=0,n.height=0,e.each(function(t){var e,r,a=t[0].trace,o=s.select(this),l=o.selectAll(".legendtoggle"),c=o.selectAll(".legendtext"),u=o.selectAll(".legendtext>tspan"),f=1.3*n.font.size,d=u[0].length||1,p=c.node()&&h.bBox(c.node()).width,g=o.select("g[class*=math-group]");if(!a.showlegend)return void o.remove();if(g.node()){var v=h.bBox(g.node());f=v.height,p=v.width,g.attr("transform","translate(0,"+f/4+")")}else e=f*(.3+(1-d)/2),c.attr("y",e),u.attr("y",e);r=Math.max(f*d,16)+3,o.attr("transform","translate("+i+","+(5+i+n.height+r/2)+")"),l.attr({x:0,y:-r/2,height:r}),n.height+=r,n.width=Math.max(n.width,p||0)}),n.width+=45+2*i,n.height+=10+2*i,m.isGrouped(n)&&(n.height+=(n._lgroupsLength-1)*n.tracegroupgap),e.selectAll(".legendtoggle").attr("width",(t._context.editable?0:n.width)+40),n.width=Math.ceil(n.width),n.height=Math.ceil(n.height)}function a(t){var e=t._fullLayout,r=e.legend,n="left";y.isRightAnchor(r)?n="right":y.isCenterAnchor(r)&&(n="center");var i="top";y.isBottomAnchor(r)?i="bottom":y.isMiddleAnchor(r)&&(i="middle"),u.autoMargin(t,"legend",{ -x:r.x,y:r.y,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:r.height*({top:1,middle:.5}[i]||0),t:r.height*({bottom:1,middle:.5}[i]||0)})}function o(t){var e=t._fullLayout,r=e.legend,n="left";y.isRightAnchor(r)?n="right":y.isCenterAnchor(r)&&(n="center"),u.autoMargin(t,"legend",{x:r.x,y:.5,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:0,t:0})}var s=t("d3"),l=t("../../plotly"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../dragelement"),h=t("../drawing"),d=t("../color"),p=t("./constants"),g=t("./get_legend_data"),v=t("./style"),m=t("./helpers"),y=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e),T.attr("transform","translate(0, "+e+")"),E.call(h.setRect,x.width,t,p.scrollBarWidth,p.scrollBarHeight),A.select("rect").attr({y:x.borderwidth-e})}var r=t._fullLayout,b="legend"+r._uid;if(r._infolayer&&t.calcdata){var x=r.legend,_=r.showlegend&&g(t.calcdata,x),w=r.hiddenlabels||[];if(!r.showlegend||!_.length)return r._infolayer.selectAll(".legend").remove(),r._topdefs.select("#"+b).remove(),void u.autoMargin(t,"legend");"undefined"==typeof t.firstRender?t.firstRender=!0:t.firstRender&&(t.firstRender=!1);var k=r._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({"class":"legend","pointer-events":"all"});var A=r._topdefs.selectAll("#"+b).data([0]);A.enter().append("clipPath").attr("id",b).append("rect");var M=k.selectAll("rect.bg").data([0]);M.enter().append("rect").attr({"class":"bg","shape-rendering":"crispEdges"}).call(d.stroke,x.bordercolor).call(d.fill,x.bgcolor).style("stroke-width",x.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var E=k.selectAll("rect.scrollbar").data([0]);E.enter().append("rect").attr({"class":"scrollbar",rx:20,ry:2,width:0,height:0}).call(d.fill,"#808BA4");var L=T.selectAll("g.groups").data(_);L.enter().append("g").attr("class","groups"),L.exit().remove(),m.isGrouped(x)&&L.attr("transform",function(t,e){return"translate(0,"+e*x.tracegroupgap+")"});var S=L.selectAll("g.traces").data(c.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(v).style("opacity",function(t){var e=t[0].trace;return u.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(e,r){n(this,t,e,r,S);var i=s.select(this).selectAll("rect").data([0]);i.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(d.fill,"rgba(0,0,0,0)"),i.on("click",function(){if(!t._dragged){var r,n,i=t._fullData,a=e[0].trace,o=a.legendgroup,s=[];if(u.traceIs(a,"pie")){var c=e[0].label,f=w.slice(),h=f.indexOf(c);-1===h?f.push(c):f.splice(h,1),l.relayout(t,"hiddenlabels",f)}else{if(""===o)s=[a.index];else for(var d=0;dz?o(t):a(t);var P=r._size,R=P.l+P.w*x.x,O=P.t+P.h*(1-x.y);y.isRightAnchor(x)?R-=x.width:y.isCenterAnchor(x)&&(R-=x.width/2),y.isBottomAnchor(x)?O-=x.height:y.isMiddleAnchor(x)&&(O-=x.height/2);var I=x.height,N=P.h;I>N?(O=P.t,I=N):(O>z&&(O=z-I),C>O&&(O=C),I=Math.min(z-O,x.height)),k.attr("transform","translate("+R+","+O+")"),M.attr({width:x.width-x.borderwidth,height:I-x.borderwidth,x:x.borderwidth/2,y:x.borderwidth/2});var j=T.attr("data-scroll")||0;if(T.attr("transform","translate(0, "+j+")"),A.select("rect").attr({width:x.width-2*x.borderwidth,height:I-2*x.borderwidth,x:x.borderwidth-j,y:x.borderwidth}),T.call(h.setClipUrl,b),x.height-I>0&&!t._context.staticPlot){M.attr({width:x.width-2*x.borderwidth+p.scrollBarWidth+p.scrollBarMargin}),A.select("rect").attr({width:x.width-2*x.borderwidth+p.scrollBarWidth+p.scrollBarMargin}),t.firstRender&&e(p.scrollBarMargin,0);var F=I-p.scrollBarHeight-2*p.scrollBarMargin,B=x.height-I,D=p.scrollBarMargin,U=0;e(D,U),k.on("wheel",null),k.on("wheel",function(){U=c.constrain(T.attr("data-scroll")-s.event.deltaY/F*B,-B,0),D=p.scrollBarMargin-U/B*F,e(D,U),s.event.preventDefault()}),E.on(".drag",null),T.on(".drag",null);var V=s.behavior.drag().on("drag",function(){D=c.constrain(s.event.y-p.scrollBarHeight/2,p.scrollBarMargin,p.scrollBarMargin+F),U=-(D-p.scrollBarMargin)/F*B,e(D,U)});E.call(V),T.call(V)}if(t._context.editable){var q,H,G,Y;k.classed("cursor-move",!0),f.init({element:k.node(),prepFn:function(){var t=c.getTranslate(k);G=t.x,Y=t.y},moveFn:function(t,e){var r=G+t,n=Y+e,i="translate("+r+", "+n+")";k.attr("transform",i),q=f.align(r,0,P.l,P.l+P.w,x.xanchor),H=f.align(n,0,P.t+P.h,P.t,x.yanchor)},doneFn:function(e){e&&void 0!==q&&void 0!==H&&l.relayout(t,{"legend.x":q,"legend.y":H})}})}}}},{"../../lib":372,"../../plotly":390,"../../plots/plots":441,"../color":297,"../dragelement":317,"../drawing":319,"./anchor_utils":328,"./constants":330,"./get_legend_data":333,"./helpers":334,"./style":336,d3:87}],333:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("./helpers");e.exports=function(t,e){function r(t,r){if(""!==t&&i.isGrouped(e))-1===l.indexOf(t)?(l.push(t),c=!0,s[t]=[[r]]):s[t].push([r]);else{var n="~~i"+f;l.push(n),s[n]=[[r]],f++}}var a,o,s={},l=[],c=!1,u={},f=0;for(a=0;aa;a++)m=s[l[a]],y[a]=i.isReversed(e)?m.reverse():m;else{for(y=[new Array(b)],a=0;b>a;a++)m=s[l[a]][0],y[0][i.isReversed(e)?b-a-1:a]=m;b=1}return e._lgroupsLength=b,y}},{"../../plots/plots":441,"./helpers":334}],334:[function(t,e,r){"use strict";var n=t("../../plots/plots");r.legendGetsTrace=function(t){return t.visible&&n.traceIs(t,"showLegend")},r.isGrouped=function(t){return-1!==(t.traceorder||"").indexOf("grouped")},r.isReversed=function(t){return-1!==(t.traceorder||"").indexOf("reversed")}},{"../../plots/plots":441}],335:[function(t,e,r){"use strict";var n=e.exports={};n.layoutAttributes=t("./attributes"),n.supplyLayoutDefaults=t("./defaults"),n.draw=t("./draw"),n.style=t("./style")},{"./attributes":329,"./defaults":331,"./draw":332,"./style":336}],336:[function(t,e,r){"use strict";function n(t){var e=t[0].trace,r=e.visible&&e.fill&&"none"!==e.fill,n=d.hasLines(e),i=l.select(this).select(".legendfill").selectAll("path").data(r?[t]:[]);i.enter().append("path").classed("js-fill",!0),i.exit().remove(),i.attr("d","M5,0h30v6h-30z").call(f.fillGroupStyle);var a=l.select(this).select(".legendlines").selectAll("path").data(n?[t]:[]);a.enter().append("path").classed("js-line",!0).attr("d","M5,0h30"),a.exit().remove(),a.call(f.lineGroupStyle)}function i(t){function e(t,e,r){var n=c.nestedProperty(o,t).get(),i=Array.isArray(n)&&e?e(n):n;if(r){if(ir[1])return r[1]}return i}function r(t){return t[0]}var n,i,a=t[0],o=a.trace,s=d.hasMarkers(o),u=d.hasText(o),h=d.hasLines(o);if(s||u||h){var p={},g={};s&&(p.mc=e("marker.color",r),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",r),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),h&&(g.line={width:e("line.width",r,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",r),p.ts=10,p.tc=e("textfont.color",r),p.tf=e("textfont.family",r)),n=[c.minExtend(a,p)],i=c.minExtend(o,g)}var v=l.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(s?n:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,i),s&&(n[0].mrc=3);var y=v.selectAll("g.pointtext").data(u?n:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,i)}function a(t){var e=t[0].trace,r=e.marker||{},n=r.line||{},i=l.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);i.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),i.exit().remove(),i.each(function(t){var e=(t.mlw+1||n.width+1)-1,i=l.select(this);i.style("stroke-width",e+"px").call(h.fill,t.mc||r.color),e&&i.call(h.stroke,t.mlc||n.color)})}function o(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);r.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.each(function(t){var r=(t.lw+1||e.line.width+1)-1,n=l.select(this);n.style("stroke-width",r+"px").call(h.fill,t.fc||e.fillcolor),r&&n.call(h.stroke,t.lc||e.line.color)})}function s(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);r.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.size()&&r.call(p,t[0],e)}var l=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),h=t("../color"),d=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=l.select(this),r=e.selectAll("g.legendfill").data([t]);r.enter().append("g").classed("legendfill",!0);var n=e.selectAll("g.legendlines").data([t]);n.enter().append("g").classed("legendlines",!0);var i=e.selectAll("g.legendsymbols").data([t]);i.enter().append("g").classed("legendsymbols",!0),i.style("opacity",t[0].trace.opacity),i.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(a).each(o).each(s).each(n).each(i)}},{"../../lib":372,"../../plots/plots":441,"../../traces/pie/style_one":538,"../../traces/scatter/subtypes":559,"../color":297,"../drawing":319,d3:87}],337:[function(t,e,r){"use strict";function n(t,e){var r=e.currentTarget,n=r.getAttribute("data-attr"),i=r.getAttribute("data-val")||!0,a=t._fullLayout,o={};if("zoom"===n){for(var s,l,u="in"===i?.5:2,h=(1+u)/2,d=(1-u)/2,p=c.Axes.list(t,null,!0),v=0;vy;y++){var b=s[y];h=m[b]={};for(var x=0;x1)return n(["resetViews","toggleHover"]),o(v,r);u&&(n(["zoom3d","pan3d","orbitRotation","tableRotation"]),n(["resetCameraDefault3d","resetCameraLastSave3d"]),n(["hoverClosest3d"])),h&&(n(["zoomInGeo","zoomOutGeo","resetGeo"]),n(["hoverClosestGeo"]));var m=i(s),y=[];return((c||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(c||g)&&a(l)&&(y.push("select2d"),y.push("lasso2d")),y.length&&n(y),!c&&!p||m||g||n(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&d?n(["toggleHover"]):p?n(["hoverClosestGl2d"]):c?n(["hoverClosestCartesian","hoverCompareCartesian"]):d&&n(["hoverClosestPie"]),o(v,r)}function i(t){for(var e=l.Axes.list({_fullLayout:t},null,!0),r=!0,n=0;n0);if(h){var d=i(e,r,s);l("x",d[0]),l("y",d[1]),a.noneOrAll(t,e,["x","y"]),l("xanchor"),l("yanchor"),a.coerceFont(l,"font",r.font),l("bgcolor"),l("bordercolor"),l("borderwidth")}}},{"../../lib":372,"./attributes":340,"./button_attributes":341,"./constants":342}],344:[function(t,e,r){"use strict";function n(t){for(var e=m.list(t,"x",!0),r=[],n=0;nr){var i=r;r=e,e=i}s.setAttributes(x,{"data-min":e,"data-max":r}),s.setAttributes(z,{x:e,width:r-e}),s.setAttributes(k,{width:e}),s.setAttributes(A,{x:r,width:h-r}),s.setAttributes(M,{transform:"translate("+(e-p-1)+")"}),s.setAttributes(L,{transform:"translate("+r+")"});var o=f.range[0],l=f.range[1],c=l-o,u=e/h*c+o,d=r/h*c+o;window.requestAnimationFrame?window.requestAnimationFrame(function(){n.relayout(t,"xaxis.range",[u,d])}):setTimeout(function(){n.relayout(t,"xaxis.range",[u,d])},16)}var c=t._fullLayout,u=c._infolayer.selectAll("g.range-slider"),f=c.xaxis.rangeslider,h=c._size.w,d=(c.height-c.margin.b-c.margin.t)*f.thickness,p=2,g=Math.floor(f.borderwidth/2),v=c.margin.l,m=c.height-d-c.margin.b,y=0,b=h,x=document.createElementNS(o,"g");s.setAttributes(x,{"class":"range-slider","data-min":y,"data-max":b,"pointer-events":"all",transform:"translate("+v+","+m+")"});var _=document.createElementNS(o,"rect"),w=f.borderwidth%2===0?f.borderwidth:f.borderwidth-1;s.setAttributes(_,{fill:f.bgcolor,stroke:f.bordercolor,"stroke-width":f.borderwidth,height:d+w,width:h+w,transform:"translate(-"+g+", -"+g+")","shape-rendering":"crispEdges"});var k=document.createElementNS(o,"rect");s.setAttributes(k,{x:0,width:y,height:d,fill:"rgba(0,0,0,0.4)"});var A=document.createElementNS(o,"rect");s.setAttributes(A,{x:b,width:h-b,height:d,fill:"rgba(0,0,0,0.4)"});var M=document.createElementNS(o,"g"),T=document.createElementNS(o,"rect"),E=document.createElementNS(o,"rect");s.setAttributes(M,{transform:"translate("+(y-p-1)+")"}),s.setAttributes(T,{width:10,height:d,x:-6,fill:"transparent",cursor:"col-resize"}),s.setAttributes(E,{width:p,height:d/2,y:d/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(M,[E,T]);var L=document.createElementNS(o,"g"),S=document.createElementNS(o,"rect"),C=document.createElementNS(o,"rect");s.setAttributes(L,{transform:"translate("+b+")"}),s.setAttributes(S,{width:10,height:d,x:-2,fill:"transparent",cursor:"col-resize"}),s.setAttributes(C,{width:p,height:d/2,y:d/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(L,[C,S]);var z=document.createElementNS(o,"rect"); -s.setAttributes(z,{x:y,width:b-y,height:d,cursor:"ew-resize",fill:"transparent"}),x.addEventListener("mousedown",function(t){function e(t){var e=+t.clientX-a;switch(i){case z:x.style.cursor="ew-resize",r(+l+e,+s+e);break;case T:x.style.cursor="col-resize",r(+s+e,+l);break;case S:x.style.cursor="col-resize",r(+s,+l+e);break;default:x.style.cursor="ew-resize",r(o,o+e)}}function n(){window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",n),x.style.cursor="auto"}var i=t.target,a=t.clientX,o=a-x.getBoundingClientRect().left,s=x.getAttribute("data-min"),l=x.getAttribute("data-max");window.addEventListener("mousemove",e),window.addEventListener("mouseup",n)}),f.range||(f.range=i.getAutoRange(c.xaxis));var P=l(t,h,d);s.appendChildren(x,[_,P,k,A,z,M,L]),e(c.xaxis.range[0],c.xaxis.range[1]),u.data([0]).enter().append(function(){return f.setRange=e,x})}},{"../../constants/xmlns_namespaces":360,"../../lib":372,"../../plotly":390,"../../plots/cartesian/axes":393,"./helpers":350,"./range_plot":352}],349:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(t,e){return n.coerce(s,l,i,t,e)}if(t[r].rangeslider){var s="object"==typeof t[r].rangeslider?t[r].rangeslider:{},l=e[r].rangeslider={};if(o("bgcolor"),o("bordercolor"),o("borderwidth"),o("thickness"),o("visible"),o("range"),l.range&&!e[r].autorange){var c=l.range,u=e[r].range;c[0]=Math.min(c[0],u[0]),c[1]=Math.max(c[1],u[1])}else e[r]._needsExpand=!0;l.visible&&a.forEach(function(t){var r=e[t]||{};r.fixedrange=!0,e[t]=r})}}},{"../../lib":372,"./attributes":347}],350:[function(t,e,r){"use strict";r.setAttributes=function(t,e){for(var r in e)t.setAttribute(r,e[r])},r.appendChildren=function(t,e){for(var r=0;rl;l++){var c=s[l],u={_fullLayout:e},f=x.coerceRef(t,n,u,c);if("path"!==o){var h=.25,d=.75;if("paper"!==f){var p=x.getFromId(u,f),g=a(p);h=g(p.range[0]+h*(p.range[1]-p.range[0])),d=g(p.range[0]+d*(p.range[1]-p.range[0]))}r(c+"0",h),r(c+"1",d)}}return"path"===o?r("path"):b.noneOrAll(t,n,["x0","x1","y0","y1"]),n}function i(t){return"category"===t.type?t.c2l:t.d2l}function a(t){return"category"===t.type?t.l2c:t.l2d}function o(t,e){t.layout.shapes=e,k.supplyLayoutDefaults(t.layout,t._fullLayout),k.drawAll(t)}function s(t){delete t.layout.shapes,t._fullLayout.shapes=[],k.drawAll(t)}function l(t,e,r){for(var n=0;ne;i--)h(t,i).selectAll('[data-index="'+(i-1)+'"]').attr("data-index",i),k.draw(t,i)}function f(t,e,r,o){function s(e){var r=e.append("path").attr(z).style("opacity",S.opacity).call(_.stroke,P).call(_.fill,S.fillcolor).call(w.dashLine,S.line.dash,S.line.width);C&&r.call(w.setClipUrl,"clip"+t._fullLayout._uid+C)}var l,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},p={};"string"==typeof r&&r?p[r]=o:b.isPlainObject(r)&&(p=r);var v=Object.keys(p);for(l=0;ll;l++){var k=y[l];if(void 0===p[k]&&void 0!==u[k]){var A,M=k.charAt(0),T=x.getFromId(t,x.coerceRef(f,{},t,M)),E=x.getFromId(t,x.coerceRef(u,{},t,M)),L=u[k];void 0!==p[M+"ref"]&&(T?(A=i(T)(L),L=(A-T.range[0])/(T.range[1]-T.range[0])):L=(L-E.domain[0])/(E.domain[1]-E.domain[0]),E?(A=E.range[0]+L*(E.range[1]-E.range[0]),L=a(E)(A)):L=T.domain[0]+L*(T.domain[1]-T.domain[0])),u[k]=L}}var S=n(u,t._fullLayout);t._fullLayout.shapes[e]=S;var C,z={"data-index":e,"fill-rule":"evenodd",d:g(t,S)},P=S.line.width?S.line.color:"rgba(0,0,0,0)";if("below"!==S.layer)C=(S.xref+S.yref).replace(/paper/g,""),s(t._fullLayout._shapeUpperLayer);else if("paper"===S.xref&&"paper"===S.yref)C="",s(t._fullLayout._shapeLowerLayer);else{var R,O=t._fullLayout._plots||{},I=Object.keys(O);for(l=0,c=I.length;c>l;l++)R=O[I[l]],C=I[l],d(t,S,R.id)&&s(R.shapelayer)}}}function h(t,e){var r=t._fullLayout.shapes[e],n=t._fullLayout._shapeUpperLayer;return r?"below"===r.layer&&(n="paper"===r.xref&&"paper"===r.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._subplotShapeLayer):console.log("getShapeLayer: undefined shape: index",e),n}function d(t,e,r){var n=y.Axes.getFromId(t,r,"x")._id,i=y.Axes.getFromId(t,r,"y")._id;return"below"===e.layer&&(n===e.xref||i===e.yref)}function p(t){return function(e){return t(e.replace("_"," "))}}function g(t,e){var r,n,a,o,s=e.type,l=x.getFromId(t,e.xref),c=x.getFromId(t,e.yref),u=t._fullLayout._size;if(l?(r=i(l),n=function(t){return l._offset+l.l2p(r(t,!0))}):n=function(t){return u.l+u.w*t},c?(a=i(c),o=function(t){return c._offset+c.l2p(a(t,!0))}):o=function(t){return u.t+u.h*(1-t)},"path"===s)return l&&"date"===l.type&&(n=p(n)),c&&"date"===c.type&&(o=p(o)),k.convertPath(e.path,n,o);var f=n(e.x0),h=n(e.x1),d=o(e.y0),g=o(e.y1);if("line"===s)return"M"+f+","+d+"L"+h+","+g;if("rect"===s)return"M"+f+","+d+"H"+h+"V"+g+"H"+f+"Z";var v=(f+h)/2,m=(d+g)/2,y=Math.abs(v-f),b=Math.abs(m-d),_="A"+y+","+b,w=v+y+","+m,A=v+","+(m-b);return"M"+w+_+" 0 1,1 "+A+_+" 0 0,1 "+w+"Z"}function v(t,e,r,n,i){var a="category"===t.type?Number:t.d2c;if(void 0!==e)return[a(e),a(r)];if(n){var o,s,l,c,u,f=1/0,h=-(1/0),d=n.match(A);for("date"===t.type&&(a=p(a)),o=0;ou&&(f=u),u>h&&(h=u)));return h>=f?[f,h]:void 0}}var m=t("fast-isnumeric"),y=t("../../plotly"),b=t("../../lib"),x=t("../../plots/cartesian/axes"),_=t("../color"),w=t("../drawing"),k=e.exports={};k.layoutAttributes=t("./attributes"),k.supplyLayoutDefaults=function(t,e){for(var r=t.shapes||[],i=e.shapes=[],a=0;as&&(t="X"),t});return n>s&&(l=l.replace(/[\s,]*X.*/,""),console.log("ignoring extra params in segment "+t)),i+l})},k.calcAutorange=function(t){var e,r,n,i,a,o=t._fullLayout,s=o.shapes;if(s.length&&t._fullData.length)for(e=0;eh?r=h:(u.left-=b.offsetLeft,u.right-=b.offsetLeft,u.top-=b.offsetTop,u.bottom-=b.offsetTop,b.selection.each(function(){var t=l.bBox(this);s.bBoxIntersect(u,t,c)&&(r=Math.max(r,o*(t[b.side]-u[a])+c))}),r=Math.min(h,r)),r>0||0>h){var d={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[b.side];e.attr("transform","translate("+d+")")}}}function p(){E=0,L=!0,S=z,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)})}var g=r.propContainer,v=r.propName,m=r.traceIndex,y=r.dfltName,b=r.avoid||{},x=r.attributes,_=r.transform,w=r.containerGroup,k=t._fullLayout,A=g.titlefont.family,M=g.titlefont.size,T=g.titlefont.color,E=1,L=!1,S=g.title.trim();""===S&&(E=0),S.match(/Click to enter .+ title/)&&(E=.2,L=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var z="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==m?a.restyle(t,v,e,m):a.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(x).selectAll("tspan.line").attr(x)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",L)}},{"../../lib":372,"../../lib/svg_text_utils":384,"../../plotly":390,"../../plots/plots":441,"../color":297,"../drawing":319,d3:87,"fast-isnumeric":95}],356:[function(t,e,r){"use strict";var n=e.exports={};n.projNames={equirectangular:"equirectangular",mercator:"mercator",orthographic:"orthographic","natural earth":"naturalEarth",kavrayskiy7:"kavrayskiy7",miller:"miller",robinson:"robinson",eckert4:"eckert4","azimuthal equal area":"azimuthalEqualArea","azimuthal equidistant":"azimuthalEquidistant","conic equal area":"conicEqualArea","conic conformal":"conicConformal","conic equidistant":"conicEquidistant",gnomonic:"gnomonic",stereographic:"stereographic",mollweide:"mollweide",hammer:"hammer","transverse mercator":"transverseMercator","albers usa":"albersUsa"},n.axesNames=["lonaxis","lataxis"],n.lonaxisSpan={orthographic:180,"azimuthal equal area":360,"azimuthal equidistant":360,"conic conformal":180,gnomonic:160,stereographic:180,"transverse mercator":180,"*":360},n.lataxisSpan={"conic conformal":150,stereographic:179.5,"*":180},n.scopeDefaults={world:{lonaxisRange:[-180,180],lataxisRange:[-90,90],projType:"equirectangular",projRotate:[0,0,0]},usa:{lonaxisRange:[-180,-50],lataxisRange:[15,80],projType:"albers usa"},europe:{lonaxisRange:[-30,60],lataxisRange:[30,80],projType:"conic conformal",projRotate:[15,0,0],projParallels:[0,60]},asia:{lonaxisRange:[22,160],lataxisRange:[-15,55],projType:"mercator",projRotate:[0,0,0]},africa:{lonaxisRange:[-30,60],lataxisRange:[-40,40],projType:"mercator",projRotate:[0,0,0]},"north america":{lonaxisRange:[-180,-45],lataxisRange:[5,85],projType:"conic conformal",projRotate:[-100,0,0],projParallels:[29.5,45.5]},"south america":{lonaxisRange:[-100,-30],lataxisRange:[-60,15],projType:"mercator",projRotate:[0,0,0]}},n.clipPad=.001,n.precision=.1,n.landColor="#F0DC82",n.waterColor="#3399FF",n.locationmodeToLayer={"ISO-3":"countries","USA-states":"subunits","country names":"countries"},n.sphereSVG={type:"Sphere"},n.fillLayers=["ocean","land","lakes"],n.lineLayers=["subunits","countries","coastlines","rivers","frame"],n.baseLayers=["ocean","land","lakes","subunits","countries","coastlines","rivers","lataxis","lonaxis","frame"],n.layerNameToAdjective={ocean:"ocean",land:"land",lakes:"lake",subunits:"subunit",countries:"country",coastlines:"coastline",rivers:"river",frame:"frame"},n.baseLayersOverChoropleth=["rivers","lakes"]},{}],357:[function(t,e,r){"use strict";e.exports={solid:[1],dot:[1,1],dash:[4,1],longdash:[8,1],dashdot:[4,1,1,1],longdashdot:[8,1,1,1]}},{}],358:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],359:[function(t,e,r){"use strict";e.exports={circle:"\u25cf","circle-open":"\u25cb",square:"\u25a0","square-open":"\u25a1",diamond:"\u25c6","diamond-open":"\u25c7",cross:"+",x:"\u274c"}},{}],360:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],361:[function(t,e,r){"use strict";var n=t("./plotly");r.version="1.10.1",r.plot=n.plot,r.newPlot=n.newPlot,r.restyle=n.restyle,r.relayout=n.relayout,r.redraw=n.redraw,r.extendTraces=n.extendTraces,r.prependTraces=n.prependTraces,r.addTraces=n.addTraces,r.deleteTraces=n.deleteTraces,r.moveTraces=n.moveTraces,r.purge=n.purge,r.setPlotConfig=t("./plot_api/set_plot_config"),r.register=n.register,r.Icons=t("../build/ploticon"),r.Plots=n.Plots,r.Fx=n.Fx,r.Snapshot=n.Snapshot,r.PlotSchema=n.PlotSchema,r.Queue=n.Queue,r.d3=t("d3")},{"../build/ploticon":2,"./plot_api/set_plot_config":389,"./plotly":390,d3:87}],362:[function(t,e,r){"use strict";"undefined"!=typeof MathJax?(r.MathJax=!0,MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:!0,displayAlign:"left",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]}}),MathJax.Hub.Configured()):r.MathJax=!1},{}],363:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){Array.isArray(t)&&(e[r]=t[n])}},{}],364:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("./nested_property"),o=t("../components/colorscale/get_scale"),s=(Object.keys(t("../components/colorscale/scales")),/^([2-9]|[1-9][0-9]+)$/);r.valObjects={data_array:{coerceFunction:function(t,e,r){Array.isArray(t)?e.set(t):void 0!==r&&e.set(r)}},enumerated:{coerceFunction:function(t,e,r,n){n.coerceNumber&&(t=+t),-1===n.values.indexOf(t)?e.set(r):e.set(t)}},"boolean":{coerceFunction:function(t,e,r){t===!0||t===!1?e.set(t):e.set(r)}},number:{coerceFunction:function(t,e,r,i){!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if(n.strict===!0&&"string"!=typeof t)return void e.set(r);var i=String(t);void 0===t||n.noBlank===!0&&!i?e.set(r):e.set(i)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r){var n=r.length;return"string"==typeof t&&t.substr(0,n)===r&&s.test(t.substr(n))?void e.set(t):void e.set(r)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"!=typeof t)return void e.set(r);if(-1!==n.extras.indexOf(t))return void e.set(t);for(var i=t.split("+"),a=0;a2)return!1;var l=o[0].split("-");if(l.length>3||3!==l.length&&o[1])return!1;if(4===l[0].length)r=Number(l[0]);else{if(2!==l[0].length)return!1;var c=(new Date).getFullYear();r=((Number(l[0])-c+70)%100+200)%100+c-70}return s(r)?1===l.length?new Date(r,0,1).getTime():(n=Number(l[1])-1,l[1].length>2||!(n>=0&&11>=n)?!1:2===l.length?new Date(r,n,1).getTime():(i=Number(l[2]),l[2].length>2||!(i>=1&&31>=i)?!1:(i=new Date(r,n,i).getTime(),o[1]?(l=o[1].split(":"),l.length>3?!1:(a=Number(l[0]),l[0].length>2||!(a>=0&&23>=a)?!1:(i+=36e5*a,1===l.length?i:(n=Number(l[1]),l[1].length>2||!(n>=0&&59>=n)?!1:(i+=6e4*n,2===l.length?i:(t=Number(l[2]),t>=0&&60>t?i+1e3*t:!1)))))):i))):!1},r.isDateTime=function(t){return r.dateTime2ms(t)!==!1},r.ms2DateTime=function(t,e){if("undefined"==typeof o)return void console.log("d3 is not defined");e||(e=0);var r=new Date(t),i=o.time.format("%Y-%m-%d")(r);return 7776e6>e?(i+=" "+n(r.getHours(),2),432e6>e&&(i+=":"+n(r.getMinutes(),2),108e5>e&&(i+=":"+n(r.getSeconds(),2),3e5>e&&(i+="."+n(r.getMilliseconds(),3)))),i.replace(/([:\s]00)*\.?[0]*$/,"")):i};var l={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},c={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},u=o.time.format.utc,f={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(u),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(u)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(u)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){c[t].forEach(function(e){f[t].D.push(u(e)),["H","I","D"].forEach(function(r){l[r].forEach(function(n){var i=f[t][r];i.push(u(e+"~"+n)),i.push(u(n+"~"+e))})})})});var h=/[a-z]*/g,d=function(t){return t.substr(0,3)},p=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,g=/[\s,\/\-\.\(\)]+/g,v=/~?([ap])~?m(~|$)/,m=function(t,e){return e+"m "},y=/\d\d\d\d/,b=/(^|~)[a-z]{3}/,x=/[ap]m/,_=/:/,w=/q([1-4])/,k=["31~mar","30~jun","30~sep","31~dec"],A=function(t,e){return k[e-1]},M=/ ?([+\-]\d\d:?\d\d|Z)$/;r.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(h,d).replace(p,"").replace(g,"~").replace(v,m).replace(w,A).trim().replace(M,"");var e,r,n=null,o=i(t),s=a(t);e=f[o][s],r=e.length;for(var l=0;r>l&&!(n=e[l].parse(t));l++);if(!(n instanceof Date))return!1;var c=n.getTimezoneOffset();return n.setTime(n.getTime()+60*c*1e3),n}},{d3:87,"fast-isnumeric":95}],366:[function(t,e,r){"use strict";var n=t("events").EventEmitter,i={init:function(t){if(t._ev instanceof n)return t;var e=new n;return t._ev=e,t.on=e.on.bind(e),t.once=e.once.bind(e),t.removeListener=e.removeListener.bind(e),t.removeAllListeners=e.removeAllListeners.bind(e),t.emit=function(r,n){"undefined"!=typeof jQuery&&jQuery(t).trigger(r,n),e.emit(r,n)},t},triggerHandler:function(t,e,r){var n,i;"undefined"!=typeof jQuery&&(n=jQuery(t).triggerHandler(e,r));var a=t._ev;if(!a)return n;var o=a._events[e];if(!o)return n;"function"==typeof o&&(o=[o]);for(var s=o.pop(),l=0;lp;p++){o=t[p];for(s in o)l=h[s],c=o[s],e&&c&&(i(c)||(u=a(c)))?(u?(u=!1,f=l&&a(l)?l:[]):f=l&&i(l)?l:{},h[s]=n([f,c],e,r)):("undefined"!=typeof c||r)&&(h[s]=c)}return h}var i=t("./is_plain_object.js"),a=Array.isArray;r.extendFlat=function(){return n(arguments,!1,!1)},r.extendDeep=function(){return n(arguments,!0,!1)},r.extendDeepAll=function(){return n(arguments,!0,!0)}},{"./is_plain_object.js":373}],368:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=0;ry;y++)f=s(p,y),d=l(e,y),m[y]=n(f,d);else m=n(p,e);return m}var s=t("tinycolor2"),l=t("fast-isnumeric"),c=t("../components/colorscale/make_scale_function"),u=t("../components/color/attributes").defaultLine,f=t("./str2rgbarray"),h=1;e.exports=o},{"../components/color/attributes":296,"../components/colorscale/make_scale_function":313,"./str2rgbarray":383,"fast-isnumeric":95,tinycolor2:275}],371:[function(t,e,r){"use strict";function n(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(e>r)break;t=t.slice(0,e)+l(t.slice(e+5,r))+t.slice(r+6)}return t}function i(t){return t.replace(/\/g,"\n")}function a(t){return t.replace(/\<.*\>/g,"")}function o(t){for(var e=0;(e=t.indexOf("&",e))>=0;){var r=t.indexOf(";",e);if(e>r)e+=1;else{var n=c[t.slice(e+1,r)];t=n?t.slice(0,e)+n+t.slice(r+1):t.slice(0,e)+t.slice(r+1)}}return t}function s(t){return""+o(a(n(i(t))))}var l=t("superscript-text"),c={mu:"\u03bc",amp:"&",lt:"<",gt:">"};e.exports=s},{"superscript-text":272}],372:[function(t,e,r){"use strict";var n=t("d3"),i=e.exports={};i.nestedProperty=t("./nested_property"),i.isPlainObject=t("./is_plain_object");var a=t("./coerce");i.valObjects=a.valObjects,i.coerce=a.coerce,i.coerce2=a.coerce2,i.coerceFont=a.coerceFont;var o=t("./dates");i.dateTime2ms=o.dateTime2ms,i.isDateTime=o.isDateTime,i.ms2DateTime=o.ms2DateTime,i.parseDate=o.parseDate;var s=t("./search");i.findBin=s.findBin,i.sorterAsc=s.sorterAsc,i.sorterDes=s.sorterDes,i.distinctVals=s.distinctVals,i.roundUp=s.roundUp;var l=t("./stats");i.aggNums=l.aggNums,i.len=l.len,i.mean=l.mean,i.variance=l.variance,i.stdev=l.stdev,i.interp=l.interp;var c=t("./matrix");i.init2dArray=c.init2dArray,i.transposeRagged=c.transposeRagged,i.dot=c.dot,i.translationMatrix=c.translationMatrix,i.rotationMatrix=c.rotationMatrix,i.rotationXYMatrix=c.rotationXYMatrix,i.apply2DTransform=c.apply2DTransform,i.apply2DTransform2=c.apply2DTransform2;var u=t("./extend");i.extendFlat=u.extendFlat,i.extendDeep=u.extendDeep,i.extendDeepAll=u.extendDeepAll,i.notifier=t("./notifier"),i.swapAttrs=function(t,e,r,n){r||(r="x"),n||(n="y");for(var a=0;ar?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},i.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},i.identity=function(t){return t},i.randstr=function f(t,e,r){if(r||(r=16),void 0===e&&(e=24),0>=e)return"0";var n,i,a,o=Math.log(Math.pow(2,e))/Math.log(r),s="";for(n=2;o===1/0;n*=2)o=Math.log(Math.pow(2,e/n))/Math.log(r)*n;var l=o-Math.floor(o);for(n=0;n-1||c!==1/0&&c>=Math.pow(2,e)?f(t,e,r):s},i.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={};return r.optionList=[],r._newoption=function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)},r["_"+e]=t,r},i.smooth=function(t,e){if(e=Math.round(e)||0,2>e)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,c=new Array(l),u=new Array(o);for(r=0;l>r;r++)c[r]=(1-Math.cos(Math.PI*(r+1)/e))/(2*e);for(r=0;o>r;r++){for(a=0,n=0;l>n;n++)i=r+n+1-e,-o>i?i-=s*Math.round(i/s):i>=s&&(i-=s*Math.floor(i/s)),0>i?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*c[n];u[r]=a}return u},i.promiseError=function(t){console.log(t,t.stack)},i.syncOrAsync=function(t,e,r){function n(){return i.markTime("async done "+o.name),i.syncOrAsync(t,e,r)}for(var a,o;t.length;){if(o=t.splice(0,1)[0],a=o(e),a&&a.then)return a.then(n).then(void 0,i.promiseError);i.markTime("sync done "+o.name)}return r&&r(e)},i.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},i.noneOrAll=function(t,e,r){if(t){var n,i,a=!1,o=!0;for(n=0;ni;i++)e[i][r]=t[i]},i.minExtend=function(t,e){var r={};"object"!=typeof e&&(e={});var n,a,o,s=3,l=Object.keys(t);for(n=0;nn;n++)r[n]=new Array(e);return r},r.transposeRagged=function(t){var e,r,n=0,i=t.length;for(e=0;i>e;e++)n=Math.max(n,t[e].length);var a=new Array(n);for(e=0;n>e;e++)for(a[e]=new Array(i),r=0;i>r;r++)a[e][r]=t[r][e];return a},r.dot=function(t,e){if(!t.length||!e.length||t.length!==e.length)return null;var n,i,a=t.length;if(t[0].length)for(n=new Array(a),i=0;a>i;i++)n[i]=r.dot(t[i],e);else if(e[0].length){var o=r.transposeRagged(e);for(n=new Array(o.length),i=0;ii;i++)n+=t[i]*e[i];return n},r.translationMatrix=function(t,e){return[[1,0,t],[0,1,e],[0,0,1]]},r.rotationMatrix=function(t){var e=t*Math.PI/180;return[[Math.cos(e),-Math.sin(e),0],[Math.sin(e),Math.cos(e),0],[0,0,1]]},r.rotationXYMatrix=function(t,e,n){return r.dot(r.dot(r.translationMatrix(e,n),r.rotationMatrix(t)),r.translationMatrix(-e,-n))},r.apply2DTransform=function(t){return function(){var e=arguments;3===e.length&&(e=e[0]);var n=1===arguments.length?e[0]:[e[0],e[1]];return r.dot(t,[n[0],n[1],1]).slice(0,2)}},r.apply2DTransform2=function(t){var e=r.apply2DTransform(t);return function(t){return e(t.slice(0,2)).concat(e(t.slice(2,4)))}}},{}],375:[function(t,e,r){"use strict";function n(t,e){return function(){var r,i,a,o,s,l=t;for(o=0;o=0;e--){if(n=t[e],o=!1,Array.isArray(n))for(r=n.length-1;r>=0;r--)c(n[r])?o?n[r]=void 0:n.pop():o=!0;else if("object"==typeof n&&null!==n)for(a=Object.keys(n),o=!1,r=a.length-1;r>=0;r--)c(n[a[r]])&&!i(n[a[r]],a[r])?delete n[a[r]]:o=!0;if(o)return}}function c(t){return void 0===t||null===t?!0:"object"!=typeof t?!1:Array.isArray(t)?!t.length:!Object.keys(t).length}function u(t,e,r){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:r,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,l=e.split(".");sr||r>a||o>n||n>s?!1:!e||!c(t)}function r(t,e){var r=t[0],l=t[1];if(i>r||r>a||o>l||l>s)return!1;var c,u,f,h,d,p=n.length,g=n[0][0],v=n[0][1],m=0;for(c=1;p>c;c++)if(u=g,f=v,g=n[c][0],v=n[c][1],h=Math.min(u,g),!(h>r||r>Math.max(u,g)||l>Math.max(f,v)))if(l=l&&r!==h&&m++}return m%2===1}var n=t.slice(),i=n[0][0],a=i,o=n[0][1],s=o;n.push(n[0]);for(var l=1;la;a++)if(o=[t[a][0]-l[0],t[a][1]-l[1]],s=n(o,c),0>s||s>u||Math.abs(n(o,h))>i)return!0;return!1};i.filter=function(t,e){function r(r){t.push(r);var s=n.length,l=i;n.splice(o+1);for(var c=l+1;c1){var s=t.pop();r(s)}return{addPt:r,raw:t,filtered:n}}},{"./matrix":374}],378:[function(t,e,r){"use strict";function n(t,e){for(var r,n=[],a=0;a=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;rt}function i(t,e){return e>=t}function a(t,e){return t>e}function o(t,e){return t>=e}var s=t("fast-isnumeric");r.findBin=function(t,e,r){if(s(e.start))return r?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var l,c,u=0,f=e.length,h=0;for(c=e[e.length-1]>=e[0]?r?n:i:r?o:a;f>u&&h++<100;)l=Math.floor((u+f)/2),c(e[l],t)?u=l+1:f=l;return h>90&&console.log("Long binary search..."),u-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;n>s;s++)e[s+1]>e[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,c=r?Math.ceil:Math.floor;a>i&&o++<100;)n=c((i+a)/2),e[n]<=t?i=n+s:a=n-l;return e[i]}},{"fast-isnumeric":95}],380:[function(t,e,r){"use strict";e.exports=function(t,e){(t.attr("class")||"").split(" ").forEach(function(e){0===e.indexOf("cursor-")&&t.classed(e,!1)}),e&&t.classed("cursor-"+e,!0)}},{}],381:[function(t,e,r){"use strict";var n=t("../components/color"),i=function(){};e.exports=function(t){for(var e in t)"function"==typeof t[e]&&(t[e]=i);t.destroy=function(){t.container.parentNode.removeChild(t.container)};var r=document.createElement("div");return r.textContent="Webgl is not supported by your browser - visit http://get.webgl.org for more info",r.style.cursor="pointer",r.style.fontSize="24px",r.style.color=n.defaults[0],t.container.appendChild(r),t.container.style.background="#FFFFFF",t.container.onclick=function(){window.open("http://get.webgl.org")},!1}},{"../components/color":297}],382:[function(t,e,r){"use strict";var n=t("fast-isnumeric");r.aggNums=function(t,e,i,a){var o,s;if(a||(a=i.length),n(e)||(e=!1),Array.isArray(i[0])){for(s=new Array(a),o=0;a>o;o++)s[o]=r.aggNums(t,e,i[o]);i=s}for(o=0;a>o;o++)n(e)?n(i[o])&&(e=t(+e,+i[o])):e=i[o];return e},r.len=function(t){return r.aggNums(function(t){return t+1},0,t)},r.mean=function(t,e){return e||(e=r.len(t)),r.aggNums(function(t,e){return t+e},0,t)/e},r.variance=function(t,e,i){return e||(e=r.len(t)),n(i)||(i=r.mean(t,e)),r.aggNums(function(t,e){return t+Math.pow(e-i,2)},0,t)/e},r.stdev=function(t,e,n){return Math.sqrt(r.variance(t,e,n))},r.interp=function(t,e){if(!n(e))throw"n should be a finite number";if(e=e*t.length-.5,0>e)return t[0];if(e>t.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"fast-isnumeric":95}],383:[function(t,e,r){"use strict";function n(t){return t=i(t),a.str2RgbaArray(t.toRgbString())}var i=t("tinycolor2"),a=t("arraytools");e.exports=n},{arraytools:27,tinycolor2:275}],384:[function(t,e,r){"use strict";function n(t,e){return t.node().getBoundingClientRect()[e]}function i(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function a(t,e,r){var n="math-output-"+l.Lib.randstr([],64),a=c.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(i(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,a.node()],function(){var e=c.select("body").select("#MathJax_SVG_glyphs");if(a.select(".MathJax_SVG").empty()||!a.select("svg").node())console.log("There was an error in the tex syntax.",t),r();else{var n=a.select("svg").node().getBoundingClientRect();r(a.select(".MathJax_SVG"),e,n)}a.remove()})}function o(t){for(var e=l.util.html_entity_decode(t),r=e.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),r=e&&e[2].toLowerCase(),n=h[r];if(void 0!==n){var i=e[1],a=e[3],o=a.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===r){if(i)return"";if("href"!==a.substr(0,4).toLowerCase())return"";var s=document.createElement("a");return s.href=a.substr(4).replace(/["'=]/g,""),-1===d.indexOf(s.protocol)?"":'"}if("br"===r)return"
";if(i)return"sup"===r?'':"sub"===r?'':"";var c=""}return l.util.xml_entity_encode(t).replace(/");i>0;i=r.indexOf("
",i+1))n.push(i);var a=0;n.forEach(function(t){for(var e=t+a,n=r.slice(0,e),i="",o=n.length-1;o>=0;o--){var s=n[o].match(/<(\/?).*>/i);if(s&&"
"!==n[o]){s[1]||(i=n[o]);break}}i&&(r.splice(e+1,0,i),r.splice(e,0,""),a+=2)});var o=r.join(""),s=o.split(/
/gi);return s.length>1&&(r=s.map(function(t,e){return''+t+""})),r.join("")}function s(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-c.top+"px",left:a()-c.left+"px","z-index":1e3}),this}}var l=t("../plotly"),c=t("d3"),u=t("../constants/xmlns_namespaces"),f=e.exports={};c.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),r=(new DOMParser).parseFromString(e,"application/xml"),n=r.documentElement.firstChild;n;)this.node().appendChild(this.node().ownerDocument.importNode(n,!0)),n=n.nextSibling;return r.querySelector("parsererror")?(console.log(r.querySelector("parsererror div").textContent),null):c.select(this.node().lastChild)},f.html_entity_decode=function(t){var e=c.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),r},f.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},f.convertToTspans=function(t,e){function r(){d.empty()||(p=u.attr("class")+"-math",d.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),h=t.appendSVG(s),h||t.text(i),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(u)}var i=t.text(),s=o(i),u=t,f=!u.attr("data-notex")&&s.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),h=i,d=c.select(u.node().parentNode);if(!d.empty()){var p=u.attr("class")?u.attr("class").split(" ")[0]:"text";p+="-math",d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=l.Lib.getPlotDiv(u.node());(v&&v._promises||[]).push(new Promise(function(t){u.style({visibility:"hidden"});var i={fontSize:parseInt(u.style("font-size"),10)};a(f[2],i,function(i,a,o){d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove();var s=i&&i.select("svg");if(!s||!s.node())return r(),void t();var l=d.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});l.node().appendChild(s.node()),a&&a.node()&&s.node().insertBefore(a.node().cloneNode(!0),s.node().firstChild),s.attr({"class":p,height:o.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=u.style("fill")||"black";s.select("g").attr({fill:c,stroke:c});var f=n(s,"width"),h=n(s,"height"),g=+u.attr("x")-f*{start:0,middle:.5,end:1}[u.attr("text-anchor")||"start"],v=parseInt(u.style("font-size"),10)||n(u,"height"),m=-v/4;"y"===p[0]?(l.attr({transform:"rotate("+[-90,+u.attr("x"),+u.attr("y")]+") translate("+[-f/2,m-h/2]+")"}),s.attr({x:+u.attr("x"),y:+u.attr("y")})):"l"===p[0]?s.attr({x:u.attr("x"),y:m-h/2}):"a"===p[0]?s.attr({x:0,y:m}):s.attr({x:g,y:+u.attr("y")+m-h/2}),e&&e.call(u,l),t(l)})}))}else r();return t}};var h={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},d=["http:","https:","mailto:"],p=new RegExp("]*)?/?>","g");f.plainText=function(t){return(t||"").replace(p," ")},f.makeEditable=function(t,e,r){function n(){a(),o.style({opacity:0});var t,e=h.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0})}function i(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}function a(){var t=c.select(l.Lib.getPlotDiv(o.node())),e=t.select(".svg-container"),n=e.append("div");n.classed("plugin-editable editable",!0).style({position:"absolute","font-family":o.style("font-family")||"Arial","font-size":o.style("font-size")||12,color:r.fill||o.style("fill")||"black",opacity:1,"background-color":r.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(o.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(r.text||o.attr("data-unformatted")).call(s(o,e,r)).on("blur",function(){o.text(this.textContent).style({opacity:1});var t,e=c.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0});var r=this.textContent;c.select(this).transition().duration(0).remove(),c.select(document).on("mouseup",null),u.edit.call(o,r)}).on("focus",function(){var t=this;c.select(document).on("mouseup",function(){return c.event.target===t?!1:void(document.activeElement===n.node()&&n.node().blur())})}).on("keyup",function(){27===c.event.which?(o.style({opacity:1}),c.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),u.cancel.call(o,this.textContent)):(u.input.call(o,this.textContent),c.select(this).call(s(o,e,r)))}).on("keydown",function(){13===c.event.which&&this.blur()}).call(i)}r||(r={});var o=this,u=c.dispatch("edit","input","cancel"),f=c.select(this.node()).style({"pointer-events":"all"}),h=e||f;return e&&f.style({"pointer-events":"none"}),r.immediate?n():h.on("click",n),c.rebind(this,u,"on")}},{"../constants/xmlns_namespaces":360,"../plotly":390,d3:87}],385:[function(t,e,r){"use strict";var n=e.exports={},i=t("../constants/geo_constants").locationmodeToLayer,a=t("topojson").feature;n.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},n.getTopojsonPath=function(t,e){return t+e+".json"},n.getTopojsonFeatures=function(t,e){var r=i[t.locationmode],n=e.objects[r];return a(e,n).features}},{"../constants/geo_constants":356,topojson:277}],386:[function(t,e,r){"use strict";function n(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function i(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function a(t,e){t._context||(t._context=R.extendFlat({},P.defaultConfig));var r=t._context;e&&(Object.keys(e).forEach(function(t){t in r&&("setBackground"===t&&"opaque"===e[t]?r[t]=i:r[t]=e[t])}),e.plot3dPixelRatio&&!r.plotGlPixelRatio&&(r.plotGlPixelRatio=r.plot3dPixelRatio)),r.staticPlot&&(r.editable=!1,r.autosizable=!1,r.scrollZoom=!1,r.doubleClick=!1,r.showTips=!1,r.showLink=!1,r.displayModeBar=!1)}function o(t,e,r){var n=S.select(t).selectAll(".plot-container").data([0]);n.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=n.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e),r&&(t.layout=r),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(w(t,{}),t._fullLayout.autosize=r.autosize=!0),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var a=t.framework.svg(),o=1,s=t._fullLayout.title;""!==s&&s||(o=0);var l="Click to enter title",c=function(){this.call(P.util.convertToTspans)},u=a.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":s}),s&&s!==l||(o=.2,u.attr({"data-unformatted":l}).text(l).style({opacity:o}).on("mouseover.opacity",function(){S.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){S.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),N.addLinks(t),Promise.resolve()}function s(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var n=P.Axes.list({_fullLayout:t});for(e=0;ee;e++){var o=t.annotations[e];o.ref&&("paper"===o.ref?(o.xref="paper",o.yref="paper"):"data"===o.ref&&(o.xref="x",o.yref="y"),delete o.ref),l(o,"xref"),l(o,"yref")}void 0===t.shapes||Array.isArray(t.shapes)||(console.log("shapes must be an array"),delete t.shapes);var s=(t.shapes||[]).length;for(e=0;s>e;e++){var c=t.shapes[e];l(c,"xref"),l(c,"yref")}var u=t.legend;u&&(u.x>3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var h=N.getSubplotIds(t,"gl3d");for(e=0;er;++r)b[r]=v[e]+m*y[2+4*r];d.camera={eye:{x:b[0],y:b[1],z:b[2]},center:{x:v[0],y:v[1],z:v[2]},up:{x:y[1],y:y[5],z:y[9]}},delete d.cameraposition}}return R.markTime("finished rest of cleanLayout, starting color"),F.clean(t),R.markTime("finished cleanLayout color.clean"),t}function l(t,e){var r=t[e],n=e.charAt(0);r&&"paper"!==r&&(t[e]=P.Axes.cleanId(r,n))}function c(t,e){for(var r=[],n=(t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid})),i=0;ia&&(s=R.randstr(n),-1!==r.indexOf(s));a++);o.uid=R.randstr(n),n.push(o.uid)}if(r.push(o.uid),"histogramy"===o.type&&"xbins"in o&&!("ybins"in o)&&(o.ybins=o.xbins,delete o.xbins),o.error_y&&"opacity"in o.error_y){var l=F.defaults,c=o.error_y.color||(N.traceIs(o,"bar")?F.defaultLine:l[i%l.length]);o.error_y.color=F.addOpacity(F.rgb(c),F.opacity(c)*o.error_y.opacity),delete o.error_y.opacity}if("bardir"in o&&("h"!==o.bardir||!N.traceIs(o,"bar")&&"histogram"!==o.type.substr(0,9)||(o.orientation="h",x(o)),delete o.bardir),"histogramy"===o.type&&x(o),"histogramx"!==o.type&&"histogramy"!==o.type||(o.type="histogram"),"scl"in o&&(o.colorscale=o.scl,delete o.scl),"reversescl"in o&&(o.reversescale=o.reversescl,delete o.reversescl),o.xaxis&&(o.xaxis=P.Axes.cleanId(o.xaxis,"x")),o.yaxis&&(o.yaxis=P.Axes.cleanId(o.yaxis,"y")),N.traceIs(o,"gl3d")&&o.scene&&(o.scene=N.subplotsRegistry.gl3d.cleanId(o.scene)),N.traceIs(o,"pie")||(Array.isArray(o.textposition)?o.textposition=o.textposition.map(u):o.textposition&&(o.textposition=u(o.textposition))),N.traceIs(o,"2dMap")&&("YIGnBu"===o.colorscale&&(o.colorscale="YlGnBu"),"YIOrRd"===o.colorscale&&(o.colorscale="YlOrRd")),N.traceIs(o,"markerColorscale")&&o.marker){var h=o.marker;"YIGnBu"===h.colorscale&&(h.colorscale="YlGnBu"),"YIOrRd"===h.colorscale&&(h.colorscale="YlOrRd")}if("surface"===o.type&&R.isPlainObject(o.contours)){var d=["x","y","z"];for(a=0;an?a.push(i+n):a.push(n);return a}function p(t,e,r){var n,i;for(n=0;n=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||0>i&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function g(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),p(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&p(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function v(t,e,r){var n,i;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),n=0;n=0&&l0){var s=_(t._boundingBoxMargins),l=s.left+s.right,c=s.bottom+s.top,u=a._container.node().getBoundingClientRect(),f=1-2*o.frameMargins;i=Math.round(f*(u.width-l)),n=Math.round(f*(u.height-c))}else r=window.getComputedStyle(t),n=parseFloat(r.height)||a.height,i=parseFloat(r.width)||a.width;return Math.abs(a.width-i)>1||Math.abs(a.height-n)>1?(a.height=t.layout.height=n,a.width=t.layout.width=i):"initial"!==a.autosize&&(delete e.autosize,a.autosize=t.layout.autosize=!0),N.sanitizeMargins(a),e}function k(t){var e=S.select(t),r=t._fullLayout;if(r._hasGL3D&&N.subplotsRegistry.gl3d.initAxes(t),r._container=e.selectAll(".plot-container").data([0]),r._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),r._paperdiv=r._container.selectAll(".svg-container").data([0]),r._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===r.autosize&&(w(t,{}),r.autosize=!0,t.layout.autosize=!0),r._glcontainer=r._paperdiv.selectAll(".gl-container").data([0]),r._glcontainer.enter().append("div").classed("gl-container",!0),r._geocontainer=r._paperdiv.selectAll(".geo-container").data([0]),r._geocontainer.enter().append("div").classed("geo-container",!0),r._paperdiv.selectAll(".main-svg").remove(),r._paper=r._paperdiv.insert("svg",":first-child").classed("main-svg",!0),r._toppaper=r._paperdiv.append("svg").classed("main-svg",!0),!r._uid){ -var n=[];S.selectAll("defs").each(function(){this.id&&n.push(this.id.split("-")[1])}),r._uid=R.randstr(n)}r._paperdiv.selectAll(".main-svg").attr(X.svgAttrs),r._defs=r._paper.append("defs").attr("id","defs-"+r._uid),r._topdefs=r._toppaper.append("defs").attr("id","topdefs-"+r._uid),r._draggers=r._paper.append("g").classed("draglayer",!0);var i=r._paper.append("g").classed("layer-below",!0);r._shapeLowerLayer=i.append("g").classed("shapelayer",!0);var a=P.Axes.getSubplots(t);a.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,a),r._hasCartesian&&M(t,a),r._ternarylayer=r._paper.append("g").classed("ternarylayer",!0),r._subplotShapeLayer=r._paper.selectAll(".shapelayer-subplot");var o=r._paper.append("g").classed("layer-above",!0);r._shapeUpperLayer=o.append("g").classed("shapelayer",!0),r._pielayer=r._paper.append("g").classed("pielayer",!0),r._glimages=r._paper.append("g").classed("glimages",!0),r._geoimages=r._paper.append("g").classed("geoimages",!0),r._infolayer=r._toppaper.append("g").classed("infolayer",!0),r._zoomlayer=r._toppaper.append("g").classed("zoomlayer",!0),r._hoverlayer=r._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var s=R.syncOrAsync([T,function(){return P.Axes.doTicks(t,"redraw")},j.init],t);return s&&s.then&&t._promises.push(s),s}function A(t,e){function r(e,r){return function(){return P.Axes.getFromId(t,e,r)}}for(var n,i,a=t._fullLayout._plots={},o=0;o0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),A=w===_;x?t.framework===k&&!b&&A||(t.framework=k,k(t)):A?b&&k(t):(t.framework=k,k(t)),b&&P.Axes.saveRangeInitial(t);var M=t._fullLayout,E=!t.calcdata||t.calcdata.length!==(t.data||[]).length;E&&h(t);for(var L=0;LG.range[0]?[1,2]:[2,1]);else{var X=G.range[0],W=G.range[1];"log"===O?(0>=X&&0>=W&&i(V+".autorange",!0),0>=X?X=W/1e6:0>=W&&(W=X/1e6),i(V+".range[0]",Math.log(X)/Math.LN10),i(V+".range[1]",Math.log(W)/Math.LN10)):(i(V+".range[0]",Math.pow(10,X)),i(V+".range[1]",Math.pow(10,W)))}else i(V+".autorange",!0)}if("reverse"===B)q.range?q.range.reverse():(i(V+".autorange",!0),q.range=[1,0]),H.autorange?_=!0:x=!0;else if("annotations"===z.parts[0]||"shapes"===z.parts[0]){var Z=z.parts[1],K=z.parts[0],Q=p[K]||[],$=P[R.titleCase(K)],J=Q[Z]||{};2===z.parts.length&&("add"===v[C]||R.isPlainObject(v[C])?E[C]="remove":"remove"===v[C]?-1===Z?(E[K]=Q,delete E[C]):E[C]=J:console.log("???",v)),!a(J,"x")&&!a(J,"y")||R.containsAny(C,["color","opacity","align","dash"])||(_=!0),$.draw(t,Z,z.parts.slice(2).join("."),v[C]),delete v[C]}else 0===z.parts[0].indexOf("scene")?x=!0:0===z.parts[0].indexOf("geo")?x=!0:0===z.parts[0].indexOf("ternary")?x=!0:!g._hasGL2D||-1===C.indexOf("axis")&&"plot_bgcolor"!==z.parts[0]?"hiddenlabels"===C?_=!0:-1!==z.parts[0].indexOf("legend")?m=!0:-1!==C.indexOf("title")?y=!0:-1!==z.parts[0].indexOf("bgcolor")?b=!0:z.parts.length>1&&R.containsAny(z.parts[1],["tick","exponent","grid","zeroline"])?y=!0:-1!==C.indexOf(".linewidth")&&-1!==C.indexOf("axis")?y=b=!0:z.parts.length>1&&-1!==z.parts[1].indexOf("line")?b=!0:z.parts.length>1&&"mirror"===z.parts[1]?y=b=!0:"margin.pad"===C?y=b=!0:"margin"===z.parts[0]||"autorange"===z.parts[1]||"rangemode"===z.parts[1]||"type"===z.parts[1]||"domain"===z.parts[1]||C.match(/^(bar|box|font)/)?_=!0:-1!==["hovermode","dragmode"].indexOf(C)?k=!0:-1===["hovermode","dragmode","height","width","autosize"].indexOf(C)&&(x=!0):x=!0,z.set(O)}I&&I.add(t,tt,[t,E],tt,[t,M]),v.autosize&&(v=w(t,v)),(v.height||v.width||v.autosize)&&(_=!0);var et=Object.keys(v),rt=[N.previousPromises];if(x||_)rt.push(function(){return t.layout=void 0,_&&(t.calcdata=void 0),P.plot(t,"",p)});else if(et.length&&(N.supplyDefaults(t),g=t._fullLayout,m&&rt.push(function(){return U.draw(t),N.previousPromises(t)}),b&&rt.push(T),y&&rt.push(function(){return P.Axes.doTicks(t,"redraw"),L(t),N.previousPromises(t)}),k)){var nt;for(Y(t),nt=N.getSubplotIds(g,"gl3d"),d=0;dc&&u>e&&(void 0===i[r]?a[f]=E.tickText(t,e):a[f]=s(t,e,String(i[r])),f++);return f=864e5?t._tickround="d":r>=36e5?t._tickround="H":r>=6e4?t._tickround="M":r>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(r/2)/Math.LN10);else{x(r)||(r=Number(r.substr(1))),t._tickround=2-Math.floor(Math.log(r)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var n=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(n)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((n-1)/3):t._tickexponent=n); -}else"M"===r.charAt(0)?t._tickround=2===r.length?"m":"y":t._tickround=null}function o(t,e){var r=t.match(V),n=new Date(e);if(r){var i=Math.min(+r[1]||6,6),a=String(e/1e3%1+2.0000005).substr(2,i).replace(/0+$/,"")||"0";return b.time.format(t.replace(V,a))(n)}return b.time.format(t)(n)}function s(t,e,r){var n=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}function l(t,e,r,n){var i,a=e.x,s=t._tickround,l=new Date(a),c="";r&&t.hoverformat?i=o(t.hoverformat,a):t.tickformat?i=o(t.tickformat,a):(n&&(x(s)?s+=2:s={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[s]),"y"===s?i=N(l):"m"===s?i=j(l):(a!==t._tmin||r||(c="
"+N(l)),"d"===s?i=F(l):"H"===s?i=B(l):(a!==t._tmin||r||(c="
"+F(l)+", "+N(l)),i=D(l),"M"!==s&&(i+=U(l),"S"!==s&&(i+=h(y(a/1e3,1),t,"none",r).substr(1)))))),e.text=i+c}function c(t,e,r,n,i){var a=t.dtick,o=e.x;if(!n||"string"==typeof a&&"L"===a.charAt(0)||(a="L3"),t.tickformat||"string"==typeof a&&"L"===a.charAt(0))e.text=h(Math.pow(10,o),t,i,n);else if(x(a)||"D"===a.charAt(0)&&y(o+.01,1)<.1)if(-1!==["e","E","power"].indexOf(t.exponentformat)){var s=Math.round(o);0===s?e.text=1:1===s?e.text="10":s>1?e.text="10"+s+"":e.text="10\u2212"+-s+"",e.fontSize*=1.25}else e.text=h(Math.pow(10,o),t,"","fakehover"),"D1"===a&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==a.charAt(0))throw"unrecognized dtick "+String(a);e.text=String(Math.round(Math.pow(10,y(o,1)))),e.fontSize*=.75}if("D1"===t.dtick){var l=String(e.text).charAt(0);"0"!==l&&"1"!==l||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(0>o?.5:.25)))}}function u(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r=""),e.text=String(r)}function f(t,e,r,n,i){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide"),e.text=h(e.x,t,i,n)}function h(t,e,r,n){var i=0>t,o=e._tickround,s=r||e.exponentformat||"B",l=e._tickexponent,c=e.tickformat;if(n){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:x(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};a(u),o=(Number(u._tickround)||0)+4,l=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return b.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-o)/2;if("none"===s&&(l=0),t=Math.abs(t),f>t)t="0",i=!1;else{if(t+=f,l&&(t*=Math.pow(10,-l),o+=l),0===o)t=String(Math.floor(t));else if(0>o){t=String(Math.round(t)),t=t.substr(0,t.length+o);for(var h=o;0>h;h++)t+="0"}else{t=String(t);var p=t.indexOf(".")+1;p&&(t=t.substr(0,p+o).replace(/\.?0+$/,""))}t=d(t,e._gd._fullLayout.separators)}if(l&&"hide"!==s){var g;g=0>l?"\u2212"+-l:"power"!==s?"+"+l:String(l),"e"===s||("SI"===s||"B"===s)&&(l>12||-15>l)?t+="e"+g:"E"===s?t+="E"+g:"power"===s?t+="×10"+g+"":"B"===s&&9===l?t+="B":"SI"!==s&&"B"!==s||(t+=q[l/3+5])}return i?"\u2212"+t:t}function d(t,e){var r=e.charAt(0),n=e.charAt(1),i=t.split("."),a=i[0],o=i.length>1?r+i[1]:"";if(n&&(i.length>1||a.length>4))for(;H.test(a);)a=a.replace(H,"$1"+n+"$2");return a+o}function p(t,e){var r,n,i=[];for(r=0;r1)for(n=1;n2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},E.getAutoRange=function(t){var e,r=[],n=t._min[0].val,i=t._max[0].val;for(e=1;e0&&u>0&&f/u>h&&(l=o,c=s,h=f/u);return n===i?r=d?[n+1,"normal"!==t.rangemode?0:n-1]:["normal"!==t.rangemode?0:n-1,n+1]:h&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode&&l.val>=0?l={val:0,pad:0}:"nonnegative"===t.rangemode&&(l.val-h*l.pad<0&&(l={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),h=(c.val-l.val)/(t._length-l.pad-c.pad)),r=[l.val-h*l.pad,c.val+h*c.pad],r[0]===r[1]&&(r=[r[0]-1,r[0]+1]),d&&r.reverse()),r},E.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=E.getAutoRange(t);var r=t._gd.layout[t._name];r||(t._gd.layout[t._name]=r={}),r!==t&&(r.range=t.range.slice(),r.autorange=t.autorange)}},E.saveRangeInitial=function(t,e){for(var r=E.list(t,"",!0),n=!1,i=0;ip&&(p=g/10),c=t.c2l(p),u=t.c2l(g),y&&(c=Math.min(0,c),u=Math.max(0,u)),n(c)){for(d=!0,o=0;o=h?d=!1:s.val>=c&&s.pad<=h&&(t._min.splice(o,1),o--);d&&t._min.push({val:c,pad:y&&0===c?0:h})}if(n(u)){for(d=!0,o=0;o=u&&s.pad>=f?d=!1:s.val<=u&&s.pad<=f&&(t._max.splice(o,1),o--);d&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),r||(r={}),t._m||t.setScale();var a,o,s,l,c,u,f,h,d,p,g,v=e.length,m=r.padded?.05*t._length:0,y=r.tozero&&("linear"===t.type||"-"===t.type),b=n((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),_=n((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),w=n(r.vpadplus||r.vpad),k=n(r.vpadminus||r.vpad);for(a=0;6>a;a++)i(a);for(a=v-1;a>5;a--)i(a)}},E.autoBin=function(t,e,r,n){function i(t){return(1+100*(t-d)/f.dtick)%100<2}var a=w.aggNums(Math.min,null,t),o=w.aggNums(Math.max,null,t);if("category"===e.type)return{start:a-.5,end:o+.5,size:1};var s;if(r)s=(o-a)/r;else{var l=w.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(l.minDiff)/Math.LN10)),u=c*w.roundUp(l.minDiff/c,[.9,1.9,4.9,9.9],!0);s=Math.max(u,2*w.stdev(t)/Math.pow(t.length,n?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[a,o]};E.autoTicks(f,s);var h,d=E.tickIncrement(E.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;yg&&(p>.3*b||i(a)||i(o))){var _=f.dtick/2;d+=a>d+_?_:-_}var k=1+Math.floor((o-d)/f.dtick);h=d+k*f.dtick}else for(h=d;o>=h;)h=E.tickIncrement(h,f.dtick);return{start:d,end:h,size:f.dtick}},E.calcTicks=function(t){if("array"===t.tickmode)return n(t);if("auto"===t.tickmode||!t.dtick){var e,r=t.nticks;r||("category"===t.type?(e=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/e):(e="y"===t._id.charAt(0)?40:80,r=w.constrain(t._length/e,4,9)+1)),E.autoTicks(t,Math.abs(t.range[1]-t.range[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),a(t),t._tmin=E.tickFirst(t);var i=t.range[1]=s:s>=l)&&(o.push(l),!(o.length>1e3));l=E.tickIncrement(l,t.dtick,i));t._tmax=o[o.length-1];for(var c=new Array(o.length),u=0;u157788e5?(e/=315576e5,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*i(e,r,C)):e>12096e5?(e/=26298e5,t.dtick="M"+i(e,1,z)):e>432e5?(t.dtick=i(e,864e5,R),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=i(e,36e5,z):e>3e4?t.dtick=i(e,6e4,P):e>500?t.dtick=i(e,1e3,P):(r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,C));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var n=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/n,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+i(e,r,C)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,C));if(0===t.dtick&&(t.dtick=1),!x(t.dtick)&&"string"!=typeof t.dtick){var a=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(a)}},E.tickIncrement=function(t,e,r){var n=r?-1:1;if(x(e))return t+n*e;var i=e.charAt(0),a=n*Number(e.substr(1));if("M"===i){var o=new Date(t);return o.setMonth(o.getMonth()+a)}if("L"===i)return Math.log(Math.pow(10,t)+a)/Math.LN10;if("D"===i){var s="D2"===e?I:O,l=t+.01*n,c=w.roundUp(y(l,1),s,r);return Math.floor(l)+Math.log(b.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},E.tickFirst=function(t){var e=t.range[1]n:n>c;)c=E.tickIncrement(c,i,e);return c}if("L"===u)return Math.log(r((Math.pow(10,n)-a)/f)*f+a)/Math.LN10;if("D"===u){var h="D2"===i?I:O,d=w.roundUp(y(n,1),h,e);return Math.floor(n)+Math.log(b.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(i)};var N=b.time.format("%Y"),j=b.time.format("%b %Y"),F=b.time.format("%b %-d"),B=b.time.format("%b %-d %Hh"),D=b.time.format("%H:%M"),U=b.time.format(":%S"),V=/%(\d?)f/g;E.tickText=function(t,e,r){function n(n){var i;return void 0===n?!0:r?"none"===n:(i={first:t._tmin,last:t._tmax}[n],"all"!==n&&e!==i)}var i,a,o=s(t,e),h="array"===t.tickmode,d=r||h;if(h&&Array.isArray(t.ticktext)){var p=Math.abs(t.range[1]-t.range[0])/1e4;for(a=0;a1&&er&&(M=90),i(u,M)}c._lastangle=M}return o(e),e+" done"}function l(){c._boundingBox=r.node().getBoundingClientRect()}var u=r.selectAll("g."+C).data(y,S);if(!c.showticklabels||!x(n))return u.remove(),void o(e);var f,h,p,m,_;"x"===v?(_="bottom"===D?1:-1,f=function(t){return t.dx+I*_},m=n+(O+R)*_,h=function(t){return t.dy+m+t.fontSize*("bottom"===D?1:-.5)},p=function(t){return x(t)&&0!==t&&180!==t?0>t*_?"end":"start":"middle"}):(_="right"===D?1:-1,h=function(t){return t.dy+t.fontSize/2-I*_},f=function(t){return t.dx+n+(O+R+(90===Math.abs(c.tickangle)?t.fontSize/2:0))*_},p=function(t){return x(t)&&90===Math.abs(t)?"middle":"right"===D?"start":"end"});var A=0,M=0,E=[];u.enter().append("g").classed(C,1).append("text").attr("text-anchor","middle").each(function(e){var r=b.select(this),n=t._promises.length;r.call(T.setPosition,f(e),h(e)).call(T.font,e.font,e.fontSize,e.fontColor).text(e.text).call(k.convertToTspans),n=t._promises[n],n?E.push(t._promises.pop().then(function(){i(r,c.tickangle)})):i(r,c.tickangle)}),u.exit().remove(),u.each(function(t){A=Math.max(A,t.fontSize)}),i(u,c._lastangle||c.tickangle);var L=w.syncOrAsync([a,s,l]);return L&&L.then&&t._promises.push(L),L}function o(e){if(!r){var n,i,a,o,s=L.getFromId(t,e),l=b.select(t).selectAll("g."+e+"tick"),c={selection:l,side:s.side},f=e.charAt(0),h=t._fullLayout._size,d=1.5,p=s.titlefont.size;if(l.size()){var g=b.select(l.node().parentNode).attr("transform").match(/translate\(([-\.\d]+),([-\.\d]+)\)/);g&&(c.offsetLeft=+g[1],c.offsetTop=+g[2])}"x"===f?(i="free"===s.anchor?{_offset:h.t+(1-(s.position||0))*h.h,_length:0}:L.getFromId(t,s.anchor),a=s._offset+s._length/2,o=i._offset+("top"===s.side?-10-p*(d+(s.showticklabels?1:0)):i._length+10+p*(d+(s.showticklabels?1.5:.5))),s.rangeslider&&s.rangeslider.visible&&s._boundingBox&&(o+=(u.height-u.margin.b-u.margin.t)*s.rangeslider.thickness+s._boundingBox.height),c.side||(c.side="bottom")):(i="free"===s.anchor?{_offset:h.l+(s.position||0)*h.w,_length:0}:L.getFromId(t,s.anchor),o=s._offset+s._length/2,a=i._offset+("right"===s.side?i._length+10+p*(d+(s.showticklabels?1:.5)):-10-p*(d+(s.showticklabels?.5:0))),n={rotate:"-90",offset:0},c.side||(c.side="left")),A.draw(t,e+"title",{propContainer:s,propName:s._name+".title",dfltName:f.toUpperCase()+" axis",avoid:c,transform:n,attributes:{x:a,y:o,"text-anchor":"middle"}})}}function s(t,e){return t.visible!==!0||t.xaxis+t.yaxis!==e?!1:_.Plots.traceIs(t,"bar")&&t.orientation==={x:"h",y:"v"}[v]?!0:t.fill&&t.fill.charAt(t.fill.length-1)===v}function l(e,r,i){var a=e.gridlayer,o=e.zerolinelayer,l=e["hidegrid"+v]?[]:V,u=c._gridpath||"M0,0"+("x"===v?"v":"h")+r._length,f=a.selectAll("path."+z).data(c.showgrid===!1?[]:l,S);if(f.enter().append("path").classed(z,1).classed("crisp",1).attr("d",u).each(function(t){c.zeroline&&("linear"===c.type||"-"===c.type)&&Math.abs(t.x)g;g++){var y=c.mirrors[o._id+h[g]];"ticks"!==y&&"labels"!==y||(f[g]=!0)}return void 0!==n[2]&&(f[2]=!0),f.forEach(function(t,e){var r=n[e],i=U[e];t&&x(r)&&(d+=p(r+R*i,i*c.ticklen))}),i(r,d),l(e,o,t),a(r,n[3])}}).filter(function(t){return t&&t.then});return H.length?Promise.all(H):0},E.swap=function(t,e){for(var r=p(t,e),n=0;n2*n}function u(t){for(var e,r=Math.max(1,(t.length-1)/1e3),n=0,i=0,a=0;a2*n}var f=t("fast-isnumeric"),h=t("tinycolor2").mix,d=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),b=t("./tick_label_defaults"),x=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),A=t("./axis_ids");e.exports=function(t,e,r,i){function a(r,n){return d.coerce2(t,e,v,r,n)}var o=i.letter,s=i.font||{},l="Click to enter "+(i.title||o.toUpperCase()+" axis")+" title";i.name&&(e._name=i.name,e._id=A.name2id(i.name));var c=r("type");"-"===c&&(n(e,i.data),"-"===e.type?e.type="linear":c=t.type=e.type),e._initialCategories="category"===c?w(o,t.categoryorder,t.categoryarray,i.data):[],_(e);var u=r("color"),p=u===t.color?u:s.color;r("title",l),d.coerceFont(r,"titlefont",{family:s.family,size:Math.round(1.2*s.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),M=r("autorange",!k);M&&r("rangemode");var T=r("range",[-1,"x"===o?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),d.noneOrAll(t.range,e.range,[0,1]),r("fixedrange"),m(t,e,r,c),b(t,e,r,c,i),y(t,e,r,i),x(t,e,r);var E=a("linecolor",u),L=a("linewidth"),S=r("showline",!!E||!!L);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&r("mirror");var C=a("gridcolor",h(u,i.bgColor,g).toRgbString()),z=a("gridwidth"),P=r("showgrid",i.showGrid||!!C||!!z);P||(delete e.gridcolor,delete e.gridwidth);var R=a("zerolinecolor",u),O=a("zerolinewidth"),I=r("zeroline",i.showGrid||!!R||!!O);return I||(delete e.zerolinecolor,delete e.zerolinewidth),e}},{"../../components/color/attributes":296,"../../lib":372,"../plots":441,"./axis_ids":395,"./category_order_defaults":396,"./clean_datum":397,"./layout_attributes":402,"./ordered_categories":404,"./set_convert":407,"./tick_label_defaults":408,"./tick_mark_defaults":409,"./tick_value_defaults":410,"fast-isnumeric":95,tinycolor2:275}],395:[function(t,e,r){"use strict";function n(t,e,r){function n(t,r){for(var n=Object.keys(t),i=/^[xyz]axis[0-9]*/,a=[],o=0;o0;-1===i.indexOf(t.categoryorder)&&a?r("categoryorder","array"):"array"!==t.categoryorder||a?r("categoryorder"):(t.categoryorder="trace",r("categoryorder"))}}},{"./layout_attributes":402}],397:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return i.ms2DateTime(t);if("string"!=typeof t&&!n(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){console.log(e,t)}return t}},{"../../lib":372,"fast-isnumeric":95}],398:[function(t,e,r){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:100,BENDPX:1.5}},{}],399:[function(t,e,r){"use strict";function n(t,e){var r,n=t.range[e],i=Math.abs(n-t.range[1-e]);return"date"===t.type?c.ms2DateTime(n,i):"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,o.format("."+r+"g")(Math.pow(10,n))):(r=Math.floor(Math.log(Math.abs(n))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,o.format("."+String(r)+"g")(n))}function i(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function a(t){o.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var o=t("d3"),s=t("tinycolor2"),l=t("../../plotly"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../components/color"),h=t("../../components/drawing"),d=t("../../lib/setcursor"),p=t("../../components/dragelement"),g=t("./axes"),v=t("./select"),m=t("./constants"),y=!0;e.exports=function(t,e,r,o,b,x,_,w){function k(t,e){for(var r=0;r.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+ht+", "+dt+")").attr("d",ot+"Z"),ut=ft.append("path").attr("class","zoombox-corners").style({fill:f.background,stroke:f.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+ht+", "+dt+")").attr("d","M0,0Z"),T();for(var a=0;ai?(lt="",it.r=it.l,it.t=it.b,ut.attr("d","M0,0Z")):(it.t=0,it.b=V,lt="x",ut.attr("d","M"+(it.l-.5)+","+(nt-H-.5)+"h-3v"+(2*H+1)+"h3ZM"+(it.r+.5)+","+(nt-H-.5)+"h3v"+(2*H+1)+"h-3Z")):!Z||i.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),ut.transition().style("opacity",1).duration(200),st=!0)}function L(t,e,r){var n,i,a;for(n=0;nzoom back out","long"),y=!1)))}function C(e,r){var i=1===(_+w).length;if(e)I();else if(2!==r||i){if(1===r&&i){var a=_?D[0]:B[0],o="s"===_||"w"===w?0:1,s=a._name+".range["+o+"]",c=n(a,o),f="left",h="middle";if(a.fixedrange)return;_?(h="n"===_?"top":"bottom","right"===a.side&&(f="right")):"e"===w&&(f="right"),J.call(u.makeEditable,null,{immediate:!0,background:j.paper_bgcolor,text:String(c),fill:a.tickfont?a.tickfont.color:"#444",horizontalAlign:f,verticalAlign:h}).on("edit",function(e){var r="category"===a.type?a.c2l(e):a.d2l(e);void 0!==r&&l.relayout(t,s,r)})}}else O()}function z(e){function r(t,e,r){if(!t.fixedrange){A(t.range);var n=t.range,i=n[0]+(n[1]-n[0])*e;t.range=[i+(n[0]-i)*r,i+(n[1]-i)*r]}}if(t._context.scrollZoom||j._enablescrollzoom){var n=t.querySelector(".plotly");if(!(n.scrollHeight-n.clientHeight>10||n.scrollWidth-n.clientWidth>10)){clearTimeout(gt);var i=-e.deltaY;if(isFinite(i)||(i=e.wheelDelta/10),!isFinite(i))return void console.log("did not find wheel motion attributes",e);var a,o=Math.exp(-Math.min(Math.max(i,-20),20)/100),s=mt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-s.left)/s.width,u=pt[0]+pt[2]*l,f=(s.bottom-e.clientY)/s.height,h=pt[1]+pt[3]*(1-f);if(w){for(a=0;a=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function i(t,e,r){for(var i=1-e,a=0,o=0;o0;n--)r.push(e);return r}function i(t,e){for(var r=[],n=0;nj||j>B.width||0>F||F>B.height)return _.unhoverRaw(t,e)}else j="xpx"in e?e.xpx:p[0]._length/2,F="ypx"in e?e.ypx:v[0]._length/2;if(x="xval"in e?n(d,e.xval):i(p,j),A="yval"in e?n(d,e.yval):i(v,F),!g(x[0])||!g(A[0]))return console.log("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var D=1/0;for(T=0;T1||-1!==L.hoverinfo.indexOf("name")?L.name:void 0,index:!1,distance:Math.min(D,k.MAXDIST),color:b.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},O=I.length,"array"===C){var U=e[T];"pointNumber"in U?(R.index=U.pointNumber,C="closest"):(C="","xval"in U&&(z=U.xval,C="x"),"yval"in U&&(P=U.yval,C=C?"closest":"y"))}else z=x[S],P=A[S];if(L._module&&L._module.hoverPoints){var V=L._module.hoverPoints(R,z,P,C);if(V)for(var q,H=0;HO&&(I.splice(0,O),D=I[0].distance)}if(0===I.length)return _.unhoverRaw(t,e);var G="y"===y&&N.length>1;I.sort(function(t,e){return t.distance-e.distance});var Y=b.combine(a.plot_bgcolor||b.background,a.paper_bgcolor),X={hovermode:y,rotateLabels:G,bgColor:Y,container:a._hoverlayer,outerContainer:a._paperdiv},W=c(I,X);u(I,G?"xa":"ya"),f(W,G);var Z=t._hoverdata,K=[];for(M=0;M128?"#000":b.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,r=u.textContent||"",r.length>15&&(r=r.substr(0,12)+"...")}void 0!==t.extraText&&(n+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(n+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(n+="y: "+t.yLabel+"
"),n+=(n?"z: ":"")+t.zLabel):M&&t[i+"Label"]===g?n=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(n=t.yLabel):n=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(n+=(n?"
":"")+t.text),""===n&&(""===r&&e.remove(),n=r);var f=e.select("text.nums").style("fill",c).call(x.setPosition,0,0).text(n).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(x.setPosition,0,0);var h=e.select("text.name"),v=0;r&&r!==n?(h.style("fill",l).text(r).call(x.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),h.selectAll("tspan.line").call(x.setPosition,0,0),v=h.node().getBoundingClientRect().width+2*P):(h.remove(),e.select("rect").remove()),e.select("path").style({fill:l,stroke:c});var m,k,E=f.node().getBoundingClientRect(),L=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),R=Math.abs(t.y1-t.y0),O=E.width+z+P+v;t.ty0=_-E.top,t.bx=E.width+2*P,t.by=E.height+2*P,t.anchor="start",t.txwidth=E.width,t.tx2width=v,t.offset=0,a?(t.pos=L,m=A>=S+R/2+O,k=S-R/2-O>=0,"top"!==t.idealAlign&&m||!k?m?(S+=R/2,t.anchor="start"):t.anchor="middle":(S-=R/2,t.anchor="end")):(t.pos=S,m=w>=L+C/2+O,k=L-C/2-O>=0,"left"!==t.idealAlign&&m||!k?m?(L+=C/2,t.anchor="start"):t.anchor="middle":(L-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&h.attr("text-anchor",t.anchor),e.attr("transform","translate("+L+","+S+")"+(a?"rotate("+T+")":""))}),S}function u(t,e){function r(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(.01>a)){if(-.01>i){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos>e.pmax-1&&(l.del=!0,c--);for(o=0;o=c);o++)if(l=t[o],l.pos=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos+l.dp+l.size>e.pmax&&(l.del=!0,c--)}}}for(var n,i,a,o,s,l,c,u=0,f=t.map(function(t,r){var n=t[e];return[{i:r,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===n._id.charAt(0)?L:1)/2,pmin:n._offset,pmax:n._offset+n._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(s=d.length-1;s>=0;s--)d[s].dp+=i;for(h.push.apply(h,d),f.splice(o+1,1),c=0,s=h.length-1;s>=0;s--)c+=h[s].dp;for(a=c/h.length,s=h.length-1;s>=0;s--)h[s].dp-=a;n=!1}else o++}f.forEach(r)}for(o=f.length-1;o>=0;o--){var v=f[o];for(s=v.length-1;s>=0;s--){var m=v[s],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var r=d.select(this);if(t.del)return void r.remove();var n="end"===t.anchor?-1:1,i=r.select("text.nums"),a={start:1,end:-1,middle:0}[t.anchor],o=a*(z+P),s=o+a*(t.txwidth+P),l=0,c=t.offset;"middle"===t.anchor&&(o-=t.tx2width/2,s-=t.tx2width/2),e&&(c*=-C,l=t.offset*S),r.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(n*z+l)+","+(z+c)+"v"+(t.by/2-z)+"h"+n*t.bx+"v-"+t.by+"H"+(n*z+l)+"V"+(c-z)+"Z"),i.call(x.setPosition,o+l,c+t.ty0-t.by/2+P).selectAll("tspan.line").attr({x:i.attr("x"),y:i.attr("y")}),t.tx2width&&(r.select("text.name, text.name tspan.line").call(x.setPosition,s+a*P+l,c+t.ty0-t.by/2+P),r.select("rect").call(x.setRect,s+(a-1)*t.tx2width/2+l,c-t.by/2-1,t.tx2width,t.by+2))})}function h(t,e,r){if(!e.target)return!1;if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}var d=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),b=t("../../components/color"),x=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),A=t("./dragbox"),M=e.exports={};M.unhover=_.unhover,M.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},M.supplyLayoutDefaults=function(t,e,r){function n(r,n){return v.coerce(t,e,M.layoutAttributes,r,n)}n("dragmode");var i;if(e._hasCartesian){var a=e._isHoriz=M.isHoriz(r);i=a?"y":"x"}else i="closest";n("hovermode",i)},M.isHoriz=function(t){for(var e=!0,r=0;rt._lastHoverTime+k.HOVERMINTIME?(o(t,e,r),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){o(t,e,r),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},M.getDistanceFunction=function(t,e,r,n){return"closest"===t?n||a(e,r):"x"===t?e:r},M.getClosest=function(t,e,r){if(r.index!==!1)r.index>=0&&r.indext*e||0===t?k.MAXDIST*(.6-.3/Math.max(3,Math.abs(t-e))):1/0}},{"../../components/color":297,"../../components/dragelement":317,"../../components/drawing":319,"../../lib":372,"../../lib/events":366,"../../lib/svg_text_utils":384,"./axes":393,"./constants":398,"./dragbox":399,d3:87,"fast-isnumeric":95,tinycolor2:275}],401:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../plots"),a=t("./constants");r.name="cartesian",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex=a.idRegex,r.attrRegex=a.attrRegex,r.attributes=t("./attributes"),r.plot=function(t){function e(t,e){for(var r=[],n=0;nf[1]-.01&&(e.domain=[0,1]),i.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":372,"fast-isnumeric":95}],406:[function(t,e,r){"use strict";function n(t){return t._id}var i=t("../../lib/polygon"),a=t("../../components/color"),o=t("./axes"),s=t("./constants"),l=i.filter,c=i.tester,u=s.MINSELECT;e.exports=function(t,e,r,i,f){function h(t){var e="y"===t._id.charAt(0)?1:0;return function(r){return t.p2d(r[e])}}function d(t,e){return t-e}var p,g=i.gd._fullLayout._zoomlayer,v=i.element.getBoundingClientRect(),m=i.plotinfo.x()._offset,y=i.plotinfo.y()._offset,b=e-v.left,x=r-v.top,_=b,w=x,k="M"+b+","+x,A=i.xaxes[0]._length,M=i.yaxes[0]._length,T=i.xaxes.map(n),E=i.yaxes.map(n),L=i.xaxes.concat(i.yaxes);"lasso"===f&&(p=l([[b,x]],s.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",k+"Z");var C,z,P,R,O,I=g.append("path").attr("class","zoombox-corners").style({fill:a.background,stroke:a.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),N=[],j=i.gd,F=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(0>=e&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-3*u*Math.abs(n-i))}return o.BADNUM}function r(t){return Math.pow(10,t)}function c(t){return i(t)?Number(t):o.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?r:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,r=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var n=l.getFromId(t._gd,t.overlaying);t.domain=n.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;2>e;e++)i(t.range[e])||(t.range[e]=i(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=r.t+(1-t.domain[1])*r.h,t._length=r.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=r.l+t.domain[0]*r.w,t._length=r.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]), -t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw a.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return i(e)?n.round(t._b+t._m*e,2):o.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,r){return t.l2p(t.c2l(e,r))},t.p2c=function(e){return t.l2c(t.p2l(e))},-1!==["linear","log","-"].indexOf(t.type))t.c2d=c,t.d2c=function(t){return t=s(t),i(t)?Number(t):o.BADNUM},t.d2l=function(e,r){return"log"===t.type?t.c2l(t.d2c(e),r):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return i(t)?a.ms2DateTime(t):o.BADNUM},t.d2c=function(t){return i(t)?Number(t):a.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(a.dateTime2ms);!i(t.range[0])&&i(f[0])&&(t.range[0]=f[0]),!i(t.range[1])&&i(f[1])&&(t.range[1]=f[1])}catch(h){console.log(h,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&-1===t._categories.indexOf(e)&&t._categories.push(e);var r=t._categories.indexOf(e);return-1===r?o.BADNUM:r},t.d2l=t.d2c);t.makeCalcdata=function(e,r){var n,i,a;if(r in e)for(n=e[r],i=new Array(n.length),a=0;an?"0":"1.0"}var r=this.framework,n=r.select("g.choroplethlayer"),i=r.select("g.scattergeolayer"),a=this.projection,o=this.path,s=this.clipAngle;r.selectAll("path.basepath").attr("d",o),r.selectAll("path.graticulepath").attr("d",o),n.selectAll("path.choroplethlocation").attr("d",o),n.selectAll("path.basepath").attr("d",o),i.selectAll("path.js-line").attr("d",o),null!==s?(i.selectAll("path.point").style("opacity",e).attr("transform",t),i.selectAll("text").style("opacity",e).attr("transform",t)):(i.selectAll("path.point").attr("transform",t),i.selectAll("text").attr("transform",t))}},{"../../components/color":297,"../../components/drawing":319,"../../constants/geo_constants":356,"../../constants/xmlns_namespaces":360,"../../lib/filter_visible":368,"../../lib/topojson_utils":385,"../../plots/cartesian/axes":393,"./projections":419,"./set_scale":420,"./zoom":421,"./zoom_reset":422,d3:87,topojson:277}],413:[function(t,e,r){"use strict";var n=t("./geo"),i=t("../../plots/plots");r.name="geo",r.attr="geo",r.idRoot="geo",r.idRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"geo");void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var o=0;o=n}function a(t,e){for(var r=e[0],n=e[1],i=!1,a=0,o=t.length,s=o-1;o>a;s=a++){var l=t[a],c=l[0],u=l[1],f=t[s],h=f[0],d=f[1];u>n^d>n&&(h-c)*(n-u)/(d-u)+c>r&&(i=!i)}return i}function o(t){return t>1?L:-1>t?-L:Math.asin(t)}function s(t,e){var r=(2+L)*Math.sin(e);e/=2;for(var n=0,i=1/0;10>n&&Math.abs(i)>M;n++){var a=Math.cos(e);e-=i=(e+Math.sin(e)*(a+2)-r)/(2*a*(1+a))}return[2/Math.sqrt(E*(4+E))*t*(1+Math.cos(e)),2*Math.sqrt(E/(4+E))*Math.sin(e)]}function l(t,e){function r(r,n){var i=R(r/e,n);return i[0]*=t,i}return arguments.length<2&&(e=t),1===e?R:e===1/0?u:(r.invert=function(r,n){var i=R.invert(r/t,n);return i[0]*=e,i},r)}function c(){var t=2,e=P(l),r=e(t);return r.coefficient=function(r){return arguments.length?e(t=+r):t},r}function u(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function f(t,e){return[3*t/(2*E)*Math.sqrt(E*E/3-e*e),e]}function h(t,e){return[t,1.25*Math.log(Math.tan(E/4+.4*e))]}function d(t){return function(e){var r,n=t*Math.sin(e),i=30;do e-=r=(e+Math.sin(e)-n)/(1+Math.cos(e));while(Math.abs(r)>M&&--i>0);return e/2}}function p(t,e,r){function n(r,n){return[t*r*Math.cos(n=i(n)),e*Math.sin(n)]}var i=d(r);return n.invert=function(n,i){var a=o(i/e);return[n/(t*Math.cos(a)),o((2*a+Math.sin(2*a))/r)]},n}function g(t,e){var r=e*e,n=r*r;return[t*(.8707-.131979*r+n*(-.013791+n*(.003971*r-.001529*n))),e*(1.007226+r*(.015085+n*(-.044475+.028874*r-.005916*n)))]}function v(t,e){var r,n=Math.min(18,36*Math.abs(e)/E),i=Math.floor(n),a=n-i,o=(r=I[i])[0],s=r[1],l=(r=I[++i])[0],c=r[1],u=(r=I[Math.min(19,++i)])[0],f=r[1];return[t*(l+a*(u-o)/2+a*a*(u-2*l+o)/2),(e>0?L:-L)*(c+a*(f-s)/2+a*a*(f-2*c+s)/2)]}function m(t,e){return[t*Math.cos(e),e]}i.geo.project=function(t,r){var n=r.stream;if(!n)throw new Error("not yet supported");return(t&&y.hasOwnProperty(t.type)?y[t.type]:e)(t,n)};var y={Feature:t,FeatureCollection:function(e,r){return{type:"FeatureCollection",features:e.features.map(function(e){return t(e,r)})}}},b=[],x=[],_={point:function(t,e){b.push([t,e])},result:function(){var t=b.length?b.length<2?{type:"Point",coordinates:b[0]}:{type:"MultiPoint",coordinates:b}:null;return b=[],t}},w={lineStart:r,point:function(t,e){b.push([t,e])},lineEnd:function(){b.length&&(x.push(b),b=[])},result:function(){var t=x.length?x.length<2?{type:"LineString",coordinates:x[0]}:{type:"MultiLineString",coordinates:x}:null;return x=[],t}},k={polygonStart:r,lineStart:r,point:function(t,e){b.push([t,e])},lineEnd:function(){var t=b.length;if(t){do b.push(b[0].slice());while(++t<4);x.push(b),b=[]}},polygonEnd:r,result:function(){if(!x.length)return null;var t=[],e=[];return x.forEach(function(r){n(r)?t.push([r]):e.push(r)}),e.forEach(function(e){var r=e[0];t.some(function(t){return a(t[0],r)?(t.push(e),!0):void 0})||t.push([e])}),x=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},A={Point:_,MultiPoint:_,LineString:w,MultiLineString:w,Polygon:k,MultiPolygon:k,Sphere:k},M=1e-6,T=M*M,E=Math.PI,L=E/2,S=(Math.sqrt(E),E/180),C=180/E,z=i.geo.projection,P=i.geo.projectionMutator;i.geo.interrupt=function(t){function e(e,r){for(var n=0>r?-1:1,i=l[+(0>r)],a=0,o=i.length-1;o>a&&e>i[a][2][0];++a);var s=t(e-i[a][1][0],r);return s[0]+=t(i[a][1][0],n*r>n*i[a][0][1]?i[a][0][1]:r)[0],s}function r(){s=l.map(function(e){return e.map(function(e){var r,n=t(e[0][0],e[0][1])[0],i=t(e[2][0],e[2][1])[0],a=t(e[1][0],e[0][1])[1],o=t(e[1][0],e[1][1])[1];return a>o&&(r=a,a=o,o=r),[[n,a],[i,o]]})})}function n(){for(var t=1e-6,e=[],r=0,n=l[0].length;n>r;++r){var o=l[0][r],s=180*o[0][0]/E,c=180*o[0][1]/E,u=180*o[1][1]/E,f=180*o[2][0]/E,h=180*o[2][1]/E;e.push(a([[s+t,c+t],[s+t,u-t],[f-t,u-t],[f-t,h+t]],30))}for(var r=l[1].length-1;r>=0;--r){var o=l[1][r],s=180*o[0][0]/E,c=180*o[0][1]/E,u=180*o[1][1]/E,f=180*o[2][0]/E,h=180*o[2][1]/E;e.push(a([[f-t,h-t],[f-t,u+t],[s+t,u+t],[s+t,c-t]],30))}return{type:"Polygon",coordinates:[i.merge(e)]}}function a(t,e){for(var r,n,i,a=-1,o=t.length,s=t[0],l=[];++ac;++c)l.push([s[0]+c*n,s[1]+c*i]);s=r}return l.push(r),l}function o(t,e){return Math.abs(t[0]-e[0])n)],a=l[+(0>n)],c=0,u=i.length;u>c;++c){var f=i[c];if(f[0][0]<=r&&rM&&--i>0);return[t/(.8707+(a=n*n)*(-.131979+a*(-.013791+a*a*a*(.003971-.001529*a)))),n]},(i.geo.naturalEarth=function(){return z(g)}).raw=g;var I=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];I.forEach(function(t){t[1]*=1.0144}),v.invert=function(t,e){var r=e/L,n=90*r,i=Math.min(18,Math.abs(n/5)),a=Math.max(0,Math.floor(i));do{var o=I[a][1],s=I[a+1][1],l=I[Math.min(19,a+2)][1],c=l-o,u=l-2*s+o,f=2*(Math.abs(r)-s)/c,h=u/c,d=f*(1-h*f*(1-2*h*f));if(d>=0||1===a){n=(e>=0?5:-5)*(d+i);var p,g=50;do i=Math.min(18,Math.abs(n)/5),a=Math.floor(i),d=i-a,o=I[a][1],s=I[a+1][1],l=I[Math.min(19,a+2)][1],n-=(p=(e>=0?L:-L)*(s+d*(l-o)/2+d*d*(l-2*s+o)/2)-e)*C;while(Math.abs(p)>T&&--g>0);break}}while(--a>=0);var v=I[a][0],m=I[a+1][0],y=I[Math.min(19,a+2)][0];return[t/(m+d*(y-v)/2+d*d*(y-2*m+v)/2),n*S]},(i.geo.robinson=function(){return z(v)}).raw=v,m.invert=function(t,e){return[t/Math.cos(e),e]},(i.geo.sinusoidal=function(){return z(m)}).raw=m}var i=t("d3");e.exports=n},{d3:87}],420:[function(t,e,r){"use strict";function n(t,e){var r=t.projection,n=t.lonaxis,o=t.lataxis,l=t.domain,c=t.framewidth||0,u=e.w*(l.x[1]-l.x[0]),f=e.h*(l.y[1]-l.y[0]),h=n.range[0]+s,d=n.range[1]-s,p=o.range[0]+s,g=o.range[1]-s,v=n._fullRange[0]+s,m=n._fullRange[1]-s,y=o._fullRange[0]+s,b=o._fullRange[1]-s;r._translate0=[e.l+u/2,e.t+f/2];var x=d-h,_=g-p,w=[h+x/2,p+_/2],k=r._rotate;r._center=[w[0]+k[0],w[1]+k[1]];var A=function(e){function n(t){return Math.min(_*u/(t[1][0]-t[0][0]),_*f/(t[1][1]-t[0][1]))}var o,s,l,x,_=e.scale(),w=r._translate0,k=i(h,p,d,g),A=i(v,y,m,b);l=a(e,k),o=n(l),x=a(e,A),r._fullScale=n(x),e.scale(o),l=a(e,k),s=[w[0]-l[0][0]+c,w[1]-l[0][1]+c],r._translate=s,e.translate(s),l=a(e,k),t._isAlbersUsa||e.clipExtent(l),o=r.scale*o,r._scale=o,t._width=Math.round(l[1][0])+c,t._height=Math.round(l[1][1])+c,t._marginX=(u-Math.round(l[1][0]))/2,t._marginY=(f-Math.round(l[1][1]))/2};return A}function i(t,e,r,n){var i=(r-t)/4;return{type:"Polygon",coordinates:[[[t,e],[t,n],[t+i,n],[t+2*i,n],[t+3*i,n],[r,n],[r,e],[r-i,e],[r-2*i,e],[r-3*i,e],[t,e]]]}}function a(t,e){return o.geo.path().projection(t).bounds(e)}var o=t("d3"),s=t("../../constants/geo_constants").clipPad;e.exports=n},{"../../constants/geo_constants":356,d3:87}],421:[function(t,e,r){"use strict";function n(t,e){var r;return(r=e._isScoped?a:e._clipAngle?s:o)(t,e.projection)}function i(t,e){var r=e._fullScale;return _.behavior.zoom().translate(t.translate()).scale(t.scale()).scaleExtent([.5*r,100*r])}function a(t,e){function r(){_.select(this).style(A)}function n(){o.scale(_.event.scale).translate(_.event.translate),t.render()}function a(){_.select(this).style(M)}var o=t.projection,s=i(o,e);return s.on("zoomstart",r).on("zoom",n).on("zoomend",a),s}function o(t,e){function r(t){return v.invert(t)}function n(t){var e=v(r(t));return Math.abs(e[0]-t[0])>y||Math.abs(e[1]-t[1])>y}function a(){_.select(this).style(A),l=_.mouse(this),c=v.rotate(),u=v.translate(),f=c,h=r(l)}function o(){return d=_.mouse(this),n(l)?(m.scale(v.scale()),void m.translate(v.translate())):(v.scale(_.event.scale),v.translate([u[0],_.event.translate[1]]),h?r(d)&&(g=r(d),p=[f[0]+(g[0]-h[0]),c[1],c[2]],v.rotate(p),f=p):(l=d,h=r(l)),void t.render())}function s(){_.select(this).style(M)}var l,c,u,f,h,d,p,g,v=t.projection,m=i(v,e),y=2;return m.on("zoomstart",a).on("zoom",o).on("zoomend",s),m}function s(t,e){function r(t){m++||t({type:"zoomstart"})}function n(t){t({type:"zoom"})}function a(t){--m||t({type:"zoomend"})}var o,s=t.projection,d={r:s.rotate(),k:s.scale()},p=i(s,e),g=x(p,"zoomstart","zoom","zoomend"),m=0,y=p.on;return p.on("zoomstart",function(){_.select(this).style(A);var t=_.mouse(this),e=s.rotate(),i=e,a=s.translate(),m=c(e);o=l(s,t),y.call(p,"zoom",function(){var r=_.mouse(this);if(s.scale(d.k=_.event.scale),o){if(l(s,r)){s.rotate(e).translate(a);var c=l(s,r),p=f(o,c),y=v(u(m,p)),b=d.r=h(y,o,i);isFinite(b[0])&&isFinite(b[1])&&isFinite(b[2])||(b=i),s.rotate(b),i=b}}else t=r,o=l(s,t);n(g.of(this,arguments))}),r(g.of(this,arguments))}).on("zoomend",function(){_.select(this).style(M),y.call(p,"zoom",null),a(g.of(this,arguments))}).on("zoom.redraw",function(){t.render()}),_.rebind(p,g,"on")}function l(t,e){var r=t.invert(e);return r&&isFinite(r[0])&&isFinite(r[1])&&m(r)}function c(t){var e=.5*t[0]*w,r=.5*t[1]*w,n=.5*t[2]*w,i=Math.sin(e),a=Math.cos(e),o=Math.sin(r),s=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return[a*s*c+i*o*l,i*s*c-a*o*l,a*o*c+i*s*l,a*s*l-i*o*c]}function u(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=e[0],s=e[1],l=e[2],c=e[3];return[r*o-n*s-i*l-a*c,r*s+n*o+i*c-a*l,r*l-n*c+i*o+a*s,r*c+n*l-i*s+a*o]}function f(t,e){if(t&&e){var r=b(t,e),n=Math.sqrt(y(r,r)),i=.5*Math.acos(Math.max(-1,Math.min(1,y(t,e)))),a=Math.sin(i)/n;return n&&[Math.cos(i),r[2]*a,-r[1]*a,r[0]*a]}}function h(t,e,r){var n=g(e,2,t[0]);n=g(n,1,t[1]),n=g(n,0,t[2]-r[2]);var i,a,o=e[0],s=e[1],l=e[2],c=n[0],u=n[1],f=n[2],h=Math.atan2(s,o)*k,p=Math.sqrt(o*o+s*s);Math.abs(u)>p?(a=(u>0?90:-90)-h,i=0):(a=Math.asin(u/p)*k-h,i=Math.sqrt(p*p-u*u));var v=180-a-2*h,m=(Math.atan2(f,c)-Math.atan2(l,i))*k,y=(Math.atan2(f,c)-Math.atan2(l,-i))*k,b=d(r[0],r[1],a,m),x=d(r[0],r[1],v,y);return x>=b?[a,m,r[2]]:[v,y,r[2]]}function d(t,e,r,n){var i=p(r-t),a=p(n-e);return Math.sqrt(i*i+a*a)}function p(t){return(t%360+540)%360-180}function g(t,e,r){var n=r*w,i=t.slice(),a=0===e?1:0,o=2===e?1:2,s=Math.cos(n),l=Math.sin(n);return i[a]=t[a]*s-t[o]*l,i[o]=t[o]*s+t[a]*l,i}function v(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*k,Math.asin(Math.max(-1,Math.min(1,2*(t[0]*t[2]-t[3]*t[1]))))*k,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*k]}function m(t){var e=t[0]*w,r=t[1]*w,n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function y(t,e){for(var r=0,n=0,i=t.length;i>n;++n)r+=t[n]*e[n];return r}function b(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function x(t){for(var e=0,r=arguments.length,n=[];++ed;++d){for(e=c[d],r=t[this.scene[e]._name],n=/Click to enter .+ title/.test(r.title)?"":r.title,p=0;2>=p;p+=2)this.labelEnable[d+p]=!1,this.labels[d+p]=o(n),this.labelColor[d+p]=s(r.titlefont.color),this.labelFont[d+p]=r.titlefont.family,this.labelSize[d+p]=r.titlefont.size,this.labelPad[d+p]=this.getLabelPad(e,r),this.tickEnable[d+p]=!1,this.tickColor[d+p]=s((r.tickfont||{}).color), -this.tickAngle[d+p]="auto"===r.tickangle?0:Math.PI*-r.tickangle/180,this.tickPad[d+p]=this.getTickPad(r),this.tickMarkLength[d+p]=0,this.tickMarkWidth[d+p]=r.tickwidth||0,this.tickMarkColor[d+p]=s(r.tickcolor),this.borderLineEnable[d+p]=!1,this.borderLineColor[d+p]=s(r.linecolor),this.borderLineWidth[d+p]=r.linewidth||0;u=this.hasSharedAxis(r),a=this.hasAxisInDfltPos(e,r)&&!u,l=this.hasAxisInAltrPos(e,r)&&!u,i=r.mirror||!1,f=u?-1!==String(i).indexOf("all"):!!i,h=u?"allticks"===i:-1!==String(i).indexOf("ticks"),a?this.labelEnable[d]=!0:l&&(this.labelEnable[d+2]=!0),a?this.tickEnable[d]=r.showticklabels:l&&(this.tickEnable[d+2]=r.showticklabels),(a||f)&&(this.borderLineEnable[d]=r.showline),(l||f)&&(this.borderLineEnable[d+2]=r.showline),(a||h)&&(this.tickMarkLength[d]=this.getTickMarkLength(r)),(l||h)&&(this.tickMarkLength[d+2]=this.getTickMarkLength(r)),this.gridLineEnable[d]=r.showgrid,this.gridLineColor[d]=s(r.gridcolor),this.gridLineWidth[d]=r.gridwidth,this.zeroLineEnable[d]=r.zeroline,this.zeroLineColor[d]=s(r.zerolinecolor),this.zeroLineWidth[d]=r.zerolinewidth}},l.hasSharedAxis=function(t){var e=this.scene,r=a.Plots.getSubplotIds(e.fullLayout,"gl2d"),n=a.Axes.findSubplotsWithAxis(r,t);return 0!==n.indexOf(e.id)},l.hasAxisInDfltPos=function(t,e){var r=e.side;return"xaxis"===t?"bottom"===r:"yaxis"===t?"left"===r:void 0},l.hasAxisInAltrPos=function(t,e){var r=e.side;return"xaxis"===t?"top"===r:"yaxis"===t?"right"===r:void 0},l.getLabelPad=function(t,e){var r=1.5,n=e.titlefont.size,i=e.showticklabels;return"xaxis"===t?"top"===e.side?-10+n*(r+(i?1:0)):-10+n*(r+(i?.5:0)):"yaxis"===t?"right"===e.side?10+n*(r+(i?1:.5)):10+n*(r+(i?.5:0)):void 0},l.getTickPad=function(t){return"outside"===t.ticks?10+t.ticklen:15},l.getTickMarkLength=function(t){if(!t.ticks)return 0;var e=t.ticklen;return"inside"===t.ticks?-e:e},e.exports=i},{"../../lib/html2unicode":371,"../../lib/str2rgbarray":383,"../../plotly":390}],425:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("./scene2d"),a=n.Plots;r.name="gl2d",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex={x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},r.attrRegex={x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},r.attributes=t("../cartesian/attributes"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,n=a.getSubplotIds(e,"gl2d"),o=0;or;++r){var n=t[r],i=e[r];if(n.length!==i.length)return!0;for(var a=0;ao;++o,--s)for(var l=0;r>l;++l)for(var c=0;4>c;++c){var u=i[4*(r*o+l)+c];i[4*(r*o+l)+c]=i[4*(r*s+l)+c],i[4*(r*s+l)+c]=u}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticPlot&&this.container.removeChild(a),p},m.computeTickMarks=function(){this.xaxis._length=this.glplot.viewBox[2]-this.glplot.viewBox[0],this.yaxis._length=this.glplot.viewBox[3]-this.glplot.viewBox[1];for(var t=[s.calcTicks(this.xaxis),s.calcTicks(this.yaxis)],e=0;2>e;++e)for(var r=0;rk;++k)w[k]=Math.min(w[k],a.bounds[k]),w[k+2]=Math.max(w[k+2],a.bounds[k+2])}var A;for(n=0;2>n;++n)w[n]>w[n+2]&&(w[n]=-1,w[n+2]=1),A=this[v[n]],A._length=y.viewBox[n+2]-y.viewBox[n],s.doAutoRange(A);y.ticks=this.computeTickMarks();var M=this.xaxis.range,T=this.yaxis.range;y.dataBox=[M[0],T[0],M[1],T[1]],y.merge(r),o.update(y),this.glplot.draw()},m.draw=function(){if(!this.stopped){requestAnimationFrame(this.redraw);var t=this.glplot,e=this.camera,r=e.mouseListener,n=this.fullLayout;this.cameraChanged();var i=r.x*t.pixelRatio,a=this.canvas.height-t.pixelRatio*r.y;if(e.boxEnabled&&"zoom"===n.dragmode)this.selectBox.enabled=!0,this.selectBox.selectBox=[Math.min(e.boxStart[0],e.boxEnd[0]),Math.min(e.boxStart[1],e.boxEnd[1]),Math.max(e.boxStart[0],e.boxEnd[0]),Math.max(e.boxStart[1],e.boxEnd[1])],t.setDirty();else{this.selectBox.enabled=!1;var o=n._size,s=this.xaxis.domain,c=this.yaxis.domain,u=t.pick(i/t.pixelRatio+o.l+s[0]*o.w,a/t.pixelRatio-(o.t+(1-c[1])*o.h));if(u&&n.hovermode){var f=u.object._trace.handlePick(u);if(f&&(!this.lastPickResult||this.lastPickResult.trace!==f.trace||this.lastPickResult.dataCoord[0]!==f.dataCoord[0]||this.lastPickResult.dataCoord[1]!==f.dataCoord[1])){var h=this.lastPickResult=f;this.spikes.update({center:u.dataCoord}),h.screenCoord=[((t.viewBox[2]-t.viewBox[0])*(u.dataCoord[0]-t.dataBox[0])/(t.dataBox[2]-t.dataBox[0])+t.viewBox[0])/t.pixelRatio,(this.canvas.height-(t.viewBox[3]-t.viewBox[1])*(u.dataCoord[1]-t.dataBox[1])/(t.dataBox[3]-t.dataBox[1])-t.viewBox[1])/t.pixelRatio];var d=h.hoverinfo;if("all"!==d){var p=d.split("+");-1===p.indexOf("x")&&(h.traceCoord[0]=void 0),-1===p.indexOf("y")&&(h.traceCoord[1]=void 0),-1===p.indexOf("z")&&(h.traceCoord[2]=void 0),-1===p.indexOf("text")&&(h.textLabel=void 0),-1===p.indexOf("name")&&(h.name=void 0)}l.loneHover({x:h.screenCoord[0],y:h.screenCoord[1],xLabel:this.hoverFormatter("xaxis",h.traceCoord[0]),yLabel:this.hoverFormatter("yaxis",h.traceCoord[1]),zLabel:h.traceCoord[2],text:h.textLabel,name:h.name,color:h.color},{container:this.svgContainer}),this.lastPickResult={dataCoord:u.dataCoord}}}else!u&&this.lastPickResult&&(this.spikes.update({}),this.lastPickResult=null,l.loneUnhover(this.svgContainer))}t.draw()}},m.hoverFormatter=function(t,e){if(void 0!==e){var r=this[t];return s.tickText(r,r.c2l(e),"hover").text}}},{"../../lib/html2unicode":371,"../../lib/show_no_webgl_msg":381,"../../plots/cartesian/axes":393,"../../plots/cartesian/graph_interact":400,"./camera":423,"./convert":424,"gl-plot2d":149,"gl-select-box":164,"gl-spikes2d":173}],427:[function(t,e,r){"use strict";function n(t,e){t=t||document.body,e=e||{};var r=[.01,1/0];"distanceLimits"in e&&(r[0]=e.distanceLimits[0],r[1]=e.distanceLimits[1]),"zoomMin"in e&&(r[0]=e.zoomMin),"zoomMax"in e&&(r[1]=e.zoomMax);var n=a({center:e.center||[0,0,0],up:e.up||[0,1,0],eye:e.eye||[0,0,10],mode:e.mode||"orbit",distanceLimits:r}),l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0,u=t.clientWidth,f=t.clientHeight,h={keyBindingMode:"rotate",view:n,element:t,delay:e.delay||16,rotateSpeed:e.rotateSpeed||1,zoomSpeed:e.zoomSpeed||1,translateSpeed:e.translateSpeed||1,flipX:!!e.flipX,flipY:!!e.flipY,modes:n.modes,tick:function(){var e=i(),r=this.delay,a=e-2*r;n.idle(e-r),n.recalcMatrix(a),n.flush(e-(100+2*r));for(var o=!0,s=n.computedMatrix,h=0;16>h;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){var e=n.computedUp.slice(),r=n.computedEye.slice(),a=n.computedCenter.slice();if(n.setMode(t),"turntable"===t){var o=i();n._active.lookAt(o,r,a,e),n._active.lookAt(o+500,r,a,[0,0,1]),n._active.flush(o)}return n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s="rotate"===h.keyBindingMode,l="pan"===h.keyBindingMode,u="zoom"===h.keyBindingMode,f=!!o.control,g=!!o.alt,v=!!o.shift,m=!!(1&e),y=!!(2&e),b=!!(4&e),x=1/t.clientHeight,_=x*(r-d),w=x*(a-p),k=h.flipX?1:-1,A=h.flipY?1:-1,M=i(),T=Math.PI*h.rotateSpeed;if((s&&m&&!f&&!g&&!v||m&&!f&&!g&&v)&&n.rotate(M,k*T*_,-A*T*w,0),(l&&m&&!f&&!g&&!v||y||m&&f&&!g&&!v)&&n.pan(M,-h.translateSpeed*_*c,h.translateSpeed*w*c,0),u&&m&&!f&&!g&&!v||b||m&&!f&&g&&!v){var E=-h.zoomSpeed*w/window.innerHeight*(M-n.lastT())*100;n.pan(M,0,0,c*(Math.exp(E)-1))}return d=r,p=a,!0}),s(t,function(t,e){var r=h.flipX?1:-1,a=h.flipY?1:-1,o=i();if(Math.abs(t)>Math.abs(e))n.rotate(o,0,0,-t*r*Math.PI*h.rotateSpeed/window.innerWidth);else{var s=-h.zoomSpeed*a*e/window.innerHeight*(o-n.lastT())/100;n.pan(o,0,0,c*(Math.exp(s)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":21,"mouse-change":211,"mouse-wheel":213,"right-now":247}],428:[function(t,e,r){"use strict";var n=t("./scene"),i=t("../plots"),a=["xaxis","yaxis","zaxis"];r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"gl3d");e._paperdiv.style({width:e.width+"px",height:e.height+"px"}),t._context.setBackground(t,e.paper_bgcolor);for(var o=0;ol;++l){var c=a[l],u=s[c];u._gd=t}}},{"../plots":441,"./layout/attributes":429,"./layout/defaults":433,"./layout/layout_attributes":434,"./scene":438,"./set_convert":439}],429:[function(t,e,r){"use strict";e.exports={scene:{valType:"subplotid",dflt:"scene"}}},{}],430:[function(t,e,r){"use strict";var n=t("../../../components/color"),i=t("../../cartesian/layout_attributes"),a=t("../../../lib/extend").extendFlat;e.exports={showspikes:{valType:"boolean",dflt:!0},spikesides:{valType:"boolean",dflt:!0},spikethickness:{valType:"number",min:0,dflt:2},spikecolor:{valType:"color",dflt:n.defaultLine},showbackground:{valType:"boolean",dflt:!1},backgroundcolor:{valType:"color",dflt:"rgba(204, 204, 204, 0.5)"},showaxeslabels:{valType:"boolean",dflt:!0},color:i.color,categoryorder:i.categoryorder,categoryarray:i.categoryarray,title:i.title,titlefont:i.titlefont,type:i.type,autorange:i.autorange,rangemode:i.rangemode,range:i.range,fixedrange:i.fixedrange,tickmode:i.tickmode,nticks:i.nticks,tick0:i.tick0,dtick:i.dtick,tickvals:i.tickvals,ticktext:i.ticktext,ticks:i.ticks,mirror:i.mirror,ticklen:i.ticklen,tickwidth:i.tickwidth,tickcolor:i.tickcolor,showticklabels:i.showticklabels,tickfont:i.tickfont,tickangle:i.tickangle,tickprefix:i.tickprefix,showtickprefix:i.showtickprefix,ticksuffix:i.ticksuffix,showticksuffix:i.showticksuffix,showexponent:i.showexponent,exponentformat:i.exponentformat,tickformat:i.tickformat,hoverformat:i.hoverformat,showline:i.showline,linecolor:i.linecolor,linewidth:i.linewidth,showgrid:i.showgrid,gridcolor:a({},i.gridcolor,{dflt:"rgb(204, 204, 204)"}),gridwidth:i.gridwidth,zeroline:i.zeroline,zerolinecolor:i.zerolinecolor,zerolinewidth:i.zerolinewidth}},{"../../../components/color":297,"../../../lib/extend":367,"../../cartesian/layout_attributes":402}],431:[function(t,e,r){"use strict";var n=t("tinycolor2").mix,i=t("../../../lib"),a=t("./axis_attributes"),o=t("../../cartesian/axis_defaults"),s=["xaxis","yaxis","zaxis"],l=function(){},c=13600/187;e.exports=function(t,e,r){function u(t,e){return i.coerce(f,h,a,t,e)}for(var f,h,d=0;dr;++r){var n=t[c[r]];e.labels[r]=o(n.title),"titlefont"in n&&(n.titlefont.color&&(e.labelColor[r]=s(n.titlefont.color)),n.titlefont.family&&(e.labelFont[r]=n.titlefont.family),n.titlefont.size&&(e.labelSize[r]=n.titlefont.size)),"showline"in n&&(e.lineEnable[r]=n.showline),"linecolor"in n&&(e.lineColor[r]=s(n.linecolor)),"linewidth"in n&&(e.lineWidth[r]=n.linewidth),"showgrid"in n&&(e.gridEnable[r]=n.showgrid),"gridcolor"in n&&(e.gridColor[r]=s(n.gridcolor)),"gridwidth"in n&&(e.gridWidth[r]=n.gridwidth),"log"===n.type?e.zeroEnable[r]=!1:"zeroline"in n&&(e.zeroEnable[r]=n.zeroline),"zerolinecolor"in n&&(e.zeroLineColor[r]=s(n.zerolinecolor)),"zerolinewidth"in n&&(e.zeroLineWidth[r]=n.zerolinewidth),"ticks"in n&&n.ticks?e.lineTickEnable[r]=!0:e.lineTickEnable[r]=!1,"ticklen"in n&&(e.lineTickLength[r]=e._defaultLineTickLength[r]=n.ticklen),"tickcolor"in n&&(e.lineTickColor[r]=s(n.tickcolor)),"tickwidth"in n&&(e.lineTickWidth[r]=n.tickwidth),"tickangle"in n&&(e.tickAngle[r]="auto"===n.tickangle?0:Math.PI*-n.tickangle/180),"showticklabels"in n&&(e.tickEnable[r]=n.showticklabels),"tickfont"in n&&(n.tickfont.color&&(e.tickColor[r]=s(n.tickfont.color)),n.tickfont.family&&(e.tickFont[r]=n.tickfont.family),n.tickfont.size&&(e.tickSize[r]=n.tickfont.size)),"mirror"in n?-1!==["ticks","all","allticks"].indexOf(n.mirror)?(e.lineTickMirror[r]=!0,e.lineMirror[r]=!0):n.mirror===!0?(e.lineTickMirror[r]=!1,e.lineMirror[r]=!0):(e.lineTickMirror[r]=!1,e.lineMirror[r]=!1):e.lineMirror[r]=!1,"showbackground"in n&&n.showbackground!==!1?(e.backgroundEnable[r]=!0,e.backgroundColor[r]=s(n.backgroundcolor)):e.backgroundEnable[r]=!1}},e.exports=i},{"../../../lib/html2unicode":371,"../../../lib/str2rgbarray":383,arraytools:27}],433:[function(t,e,r){"use strict";function n(t,e,r,n){for(var a=r("bgcolor"),l=i.combine(a,n.paper_bgcolor),c=Object.keys(o.camera),u=0;ue;++e){var r=t[o[e]];this.enabled[e]=r.showspikes,this.colors[e]=a(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness}},e.exports=i},{"../../../lib/str2rgbarray":383}],436:[function(t,e,r){"use strict";function n(t){for(var e=new Array(3),r=0;3>r;++r){for(var n=t[r],i=new Array(n.length),a=0;au;++u){var f=i[s[u]];if(f._length=(r[u].hi-r[u].lo)*r[u].pixelsPerDataUnit/t.dataScale[u],Math.abs(f._length)===1/0)c[u]=[];else{f.range[0]=r[u].lo/t.dataScale[u],f.range[1]=r[u].hi/t.dataScale[u],f._m=1/(t.dataScale[u]*r[u].pixelsPerDataUnit),f.range[0]===f.range[1]&&(f.range[0]-=1,f.range[1]+=1);var h=f.tickmode;if("auto"===f.tickmode){f.tickmode="linear";var d=f.nticks||a.Lib.constrain(f._length/40,4,9);a.Axes.autoTicks(f,Math.abs(f.range[1]-f.range[0])/d)}for(var p=a.Axes.calcTicks(f),g=0;gu;++u){l[u]=.5*(t.glplot.bounds[0][u]+t.glplot.bounds[1][u]);for(var g=0;2>g;++g)e.bounds[g][u]=t.glplot.bounds[g][u]}t.contourLevels=n(c)}e.exports=i;var a=t("../../../plotly"),o=t("../../../lib/html2unicode"),s=["xaxis","yaxis","zaxis"],l=[0,0,0]},{"../../../lib/html2unicode":371,"../../../plotly":390}],437:[function(t,e,r){"use strict";function n(t,e){var r,n,i=[0,0,0,0];for(r=0;4>r;++r)for(n=0;4>n;++n)i[n]+=t[4*r+n]*e[r];return i}function i(t,e){var r=n(t.projection,n(t.view,n(t.model,[e[0],e[1],e[2],1])));return r}e.exports=i},{}],438:[function(t,e,r){"use strict";function n(t){function e(e,r){if("string"==typeof r)return r;var n=t.fullSceneLayout[e];return d.tickText(n,n.c2l(r),"hover").text}var r=t.svgContainer,n=t.container.getBoundingClientRect(),i=n.width,a=n.height;r.setAttributeNS(null,"viewBox","0 0 "+i+" "+a),r.setAttributeNS(null,"width",i),r.setAttributeNS(null,"height",a),w(t),t.glplot.axes.update(t.axesOptions);for(var o=Object.keys(t.traces),s=null,l=t.glplot.selection,c=0;ca;++a){var u=l[A[a]];b(u)}t?Array.isArray(t)||(t=[t]):t=[];for(var f=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],a=0;ao;++o)f[0][o]>f[1][o]?d[o]=1:f[1][o]===f[0][o]?d[o]=1:d[o]=1/(f[1][o]-f[0][o]);this.dataScale=d;for(var a=0;aa;++a){var u=l[A[a]],_=u.type;if(_ in x?(x[_].acc*=d[a],x[_].count+=1):x[_]={acc:d[a],count:1},u.autorange){for(m[0][a]=1/0,m[1][a]=-(1/0),o=0;om[1][a])m[0][a]=-1,m[1][a]=1;else{var k=m[1][a]-m[0][a];m[0][a]-=k/32,m[1][a]+=k/32}}else{var M=l[A[a]].range;m[0][a]=M[0],m[1][a]=M[1]}m[0][a]===m[1][a]&&(m[0][a]-=1,m[1][a]+=1),y[a]=m[1][a]-m[0][a],this.glplot.bounds[0][a]=m[0][a]*d[a],this.glplot.bounds[1][a]=m[1][a]*d[a]}for(var T=[1,1,1],a=0;3>a;++a){var u=l[A[a]],_=u.type,E=x[_];T[a]=Math.pow(E.acc,1/E.count)/d[a]}var L,S=4;if("auto"===l.aspectmode)L=Math.max.apply(null,T)/Math.min.apply(null,T)<=S?T:[1,1,1];else if("cube"===l.aspectmode)L=[1,1,1];else if("data"===l.aspectmode)L=T;else{if("manual"!==l.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var C=l.aspectratio;L=[C.x,C.y,C.z]}l.aspectratio.x=c.aspectratio.x=L[0],l.aspectratio.y=c.aspectratio.y=L[1],l.aspectratio.z=c.aspectratio.z=L[2],this.glplot.aspect=L;var z=l.domain||null,P=e._size||null;if(z&&P){var R=this.container.style;R.position="absolute",R.left=P.l+z.x[0]*P.w+"px",R.top=P.t+(1-z.y[1])*P.h+"px",R.width=P.w*(z.x[1]-z.x[0])+"px",R.height=P.h*(z.y[1]-z.y[0])+"px"}this.glplot.redraw()}},k.destroy=function(){this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null},k.setCameraToDefault=function(){this.setCamera({eye:{x:1.25,y:1.25,z:1.25},center:{x:0,y:0,z:0},up:{x:0,y:0,z:1}})},k.getCamera=function(){this.glplot.camera.view.recalcMatrix(this.camera.view.lastT()); -var t=this.glplot.camera.up,e=this.glplot.camera.center,r=this.glplot.camera.eye;return{up:{x:t[0],y:t[1],z:t[2]},center:{x:e[0],y:e[1],z:e[2]},eye:{x:r[0],y:r[1],z:r[2]}}},k.setCamera=function(t){function e(t){return[[t.eye.x,t.eye.y,t.eye.z],[t.center.x,t.center.y,t.center.z],[t.up.x,t.up.y,t.up.z]]}var r={};r[this.id]=t,this.glplot.camera.lookAt.apply(this,e(t)),this.graphDiv.emit("plotly_relayout",r)},k.saveCamera=function(t){function e(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return t[i[r]][a[n]]===e[i[r]][a[n]]}var r=this.getCamera(),n=f.nestedProperty(t,this.id+".camera"),i=n.get(),a=!1;if(void 0===i)a=!0;else for(var o=0;3>o;o++)for(var s=0;3>s;s++)if(!e(r,i,o,s)){a=!0;break}return a&&n.set(r),a},k.updateFx=function(t,e){var r=this.camera;r&&("orbit"===t?(r.mode="orbit",r.keyBindingMode="rotate"):"turntable"===t?(r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate"):r.keyBindingMode=t),this.fullSceneLayout.hovermode=e},k.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(l),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,n=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var i=new Uint8Array(r*n*4);e.readPixels(0,0,r,n,e.RGBA,e.UNSIGNED_BYTE,i);for(var a=0,o=n-1;o>a;++a,--o)for(var s=0;r>s;++s)for(var c=0;4>c;++c){var u=i[4*(r*a+s)+c];i[4*(r*a+s)+c]=i[4*(r*o+s)+c],i[4*(r*o+s)+c]=u}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticMode&&this.container.removeChild(l),p},e.exports=a},{"../../lib":372,"../../lib/show_no_webgl_msg":381,"../../lib/str2rgbarray":383,"../../plots/cartesian/axes":393,"../../plots/cartesian/graph_interact":400,"../../plots/plots":441,"./camera":427,"./layout/convert":432,"./layout/spikes":435,"./layout/tick_marks":436,"./project":437,"./set_convert":439,"gl-plot3d":151}],439:[function(t,e,r){"use strict";var n=t("../cartesian/axes"),i=function(){};e.exports=function(t){n.setConvert(t),t.setScale=i}},{"../cartesian/axes":393}],440:[function(t,e,r){"use strict";var n=t("../plotly"),i=t("./font_attributes"),a=t("../components/color/attributes"),o=n.Lib.extendFlat;e.exports={font:{family:o({},i.family,{dflt:'"Open Sans", verdana, arial, sans-serif'}),size:o({},i.size,{dflt:12}),color:o({},i.color,{dflt:a.defaultLine})},title:{valType:"string",dflt:"Click to enter Plot title"},titlefont:o({},i,{}),autosize:{valType:"enumerated",values:[!0,!1,"initial"]},width:{valType:"number",min:10,dflt:700},height:{valType:"number",min:10,dflt:450},margin:{l:{valType:"number",min:0,dflt:80},r:{valType:"number",min:0,dflt:80},t:{valType:"number",min:0,dflt:100},b:{valType:"number",min:0,dflt:80},pad:{valType:"number",min:0,dflt:0},autoexpand:{valType:"boolean",dflt:!0}},paper_bgcolor:{valType:"color",dflt:a.background},plot_bgcolor:{valType:"color",dflt:a.background},separators:{valType:"string",dflt:".,"},hidesources:{valType:"boolean",dflt:!1},smith:{valType:"enumerated",values:[!1],dflt:!1},showlegend:{valType:"boolean"},_hasCartesian:{valType:"boolean",dflt:!1},_hasGL3D:{valType:"boolean",dflt:!1},_hasGeo:{valType:"boolean",dflt:!1},_hasPie:{valType:"boolean",dflt:!1},_hasGL2D:{valType:"boolean",dflt:!1},_hasTernary:{valType:"boolean",dflt:!1},_composedModules:{"*":"Fx"},_nestedModules:{xaxis:"Axes",yaxis:"Axes",scene:"gl3d",geo:"geo",legend:"Legend",annotations:"Annotations",shapes:"Shapes",ternary:"ternary"}}},{"../components/color/attributes":296,"../plotly":390,"./font_attributes":411}],441:[function(t,e,r){"use strict";function n(t){return"object"==typeof t&&(t=t.type),t}function i(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#","class":"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){d.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}function a(t,e){for(var r,n=Object.keys(e),i=0;i=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var o=r.select(".js-link-to-tool"),s=r.select(".js-link-spacer"),c=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&i(t,o),s.text(o.text()&&c.text()?" - ":"")},d.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",r=l.select(t).append("div").attr("id","hiddenform").style("display","none"),n=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),i=n.append("input").attr({type:"text",name:"data"});return i.node().value=d.graphJson(t,!1,"keepdata"),n.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1},d.supplyDefaults=function(t){var e,r,n,i,o,s=t._fullLayout||{},l=t._fullLayout={},c=t.layout||{},f=t._fullData||[],h=t._fullData=[],p=t.data||[],g=t._modules=[];for(d.supplyLayoutGlobalDefaults(c,l),l._dataLength=p.length,d.supplyDataDefaults(p,h,l,g),e=0;ea&&(e=(r-1)/(i.l+i.r),i.l=Math.floor(e*i.l),i.r=Math.floor(e*i.r)),0>o&&(e=(n-1)/(i.t+i.b),i.t=Math.floor(e*i.t),i.b=Math.floor(e*i.b))}},d.autoMargin=function(t,e,r){var n=t._fullLayout;if(n._pushmargin||(n._pushmargin={}),n.margin.autoexpand!==!1){if(r){var i=void 0===r.pad?12:r.pad;r.l+r.r>.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0),n._pushmargin[e]={l:{val:r.x,size:r.l+i},r:{val:r.x,size:r.r+i},b:{val:r.y,size:r.b+i},t:{val:r.y,size:r.t+i}}}else delete n._pushmargin[e];t._replotting||d.doAutoMargin(t)}},d.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var r=e._size,n=JSON.stringify(r),i=Math.max(e.margin.l||0,0),a=Math.max(e.margin.r||0,0),o=Math.max(e.margin.t||0,0),s=Math.max(e.margin.b||0,0),l=e._pushmargin;return e.margin.autoexpand!==!1&&(l.base={l:{val:0,size:i},r:{val:1,size:a},t:{val:1,size:o},b:{val:0,size:s}},Object.keys(l).forEach(function(t){var r=l[t].l||{},n=l[t].b||{},u=r.val,f=r.size,h=n.val,d=n.size;Object.keys(l).forEach(function(t){if(c(f)&&l[t].r){var r=l[t].r.val,n=l[t].r.size;if(r>u){var p=(f*r+(n-e.width)*u)/(r-u),g=(n*(1-u)+(f-e.width)*(1-r))/(r-u);p>=0&&g>=0&&p+g>i+a&&(i=p,a=g)}}if(c(d)&&l[t].t){var v=l[t].t.val,m=l[t].t.size;if(v>h){var y=(d*v+(m-e.height)*h)/(v-h),b=(m*(1-h)+(d-e.height)*(1-v))/(v-h);y>=0&&b>=0&&y+b>s+o&&(s=y,o=b)}}})})),r.l=Math.round(i),r.r=Math.round(a),r.t=Math.round(o),r.b=Math.round(s),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,t._replotting||"{}"===n||n===JSON.stringify(e._size)?void 0:u.plot(t)},d.graphJson=function(t,e,r,n,i){function a(t){if("function"==typeof t)return null;if(f.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0&&!f.isPlainObject(t.stream))continue}else if("keepall"!==r&&(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0))continue;i[e]=a(t[e])}return i}return Array.isArray(t)?t.map(a):t&&t.getTime?f.ms2DateTime(t):t}(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&d.supplyDefaults(t);var o=i?t._fullData:t.data,s=i?t._fullLayout:t.layout,l={data:(o||[]).map(function(t){var r=a(t);return e&&delete r.fit,r})};return e||(l.layout=a(s)),t.framework&&t.framework.isPolar&&(l=t.framework.getConfig()),"object"===n?l:JSON.stringify(l)}},{"../components/color":297,"../lib":372,"../plotly":390,"./attributes":391,"./font_attributes":411,"./layout_attributes":440,d3:87,"fast-isnumeric":95}],442:[function(t,e,r){"use strict";var n=t("../../traces/scatter/attributes"),i=n.marker;e.exports={r:n.r,t:n.t,marker:{color:i.color,size:i.size,symbol:i.symbol,opacity:i.opacity}}},{"../../traces/scatter/attributes":540}],443:[function(t,e,r){"use strict";function n(t,e){var r={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return a({},e,r)}var i=t("../cartesian/layout_attributes"),a=t("../../lib/extend").extendFlat,o=a({},i.domain,{});e.exports={radialaxis:n("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:o,orientation:{valType:"number"}}),angularaxis:n("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:o}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":367,"../cartesian/layout_attributes":402}],444:[function(t,e,r){var n=t("../../plotly"),i=t("d3"),a=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},o=n.Lib.extendDeepAll;a.Axis=function(){function t(t){r=t||r;var c=l.data,f=l.layout;return("string"==typeof r||r.nodeName)&&(r=i.select(r)),r.datum(c).each(function(t,r){function l(t,e){return s(t)%360+f.orientation}var c=t.slice();u={data:a.util.cloneJson(c),layout:a.util.cloneJson(f)};var h=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[h],h=(h+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:i.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var d=c.filter(function(t,e){var r=t.visible;return"undefined"==typeof r||r===!0}),p=!1,g=d.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=i.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var r=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,n){t.yStack=[r],m.push(r),r=a.util.sumArrays(t.r,r)}),t.values});d=i.merge(y)}d.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var b=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;b=Math.max(10,b);var x,_=[f.margin.left+b,f.margin.top+b];if(p){var w=i.max(a.util.sumArrays(a.util.arrayLast(d).r[0],a.util.arrayLast(m)));x=[0,w]}else x=i.extent(a.util.flattenArray(d.map(function(t,e){return t.r})));f.radialAxis.domain!=a.DATAEXTENT&&(x[0]=0),n=i.scale.linear().domain(f.radialAxis.domain!=a.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:x).range([0,b]),u.layout.radialAxis.domain=n.domain();var k,A=a.util.flattenArray(d.map(function(t,e){return t.t})),M="string"==typeof A[0];M&&(A=a.util.deduplicate(A),k=A.slice(),A=i.range(A.length),d=d.map(function(t,e){var r=t;return t.t=[A],p&&(r.yStack=t.yStack),r}));var T=d.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===d.length,E=null===f.needsEndSpacing?M||!T:f.needsEndSpacing,L=f.angularAxis.domain&&f.angularAxis.domain!=a.DATAEXTENT&&!M&&f.angularAxis.domain[0]>=0,S=L?f.angularAxis.domain:i.extent(A),C=Math.abs(A[1]-A[0]);T&&!M&&(C=0);var z=S.slice();E&&M&&(z[1]+=C);var P=f.angularAxis.ticksCount||4;P>8&&(P=P/(P/8)+P%8),f.angularAxis.ticksStep&&(P=(z[1]-z[0])/P);var R=f.angularAxis.ticksStep||(z[1]-z[0])/(P*(f.minorTicks+1));k&&(R=Math.max(Math.round(R),1)),z[2]||(z[2]=R);var O=i.range.apply(this,z);if(O=O.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=i.scale.linear().domain(z.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=s.domain(),u.layout.angularAxis.endPadding=E?C:0,e=i.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var I="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",N=(new DOMParser).parseFromString(I,"application/xml"),j=this.appendChild(this.ownerDocument.importNode(N.documentElement,!0));e=i.select(j)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var F,B=e.select(".chart-group"),D={fill:"none",stroke:f.tickColor},U={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){F=e.select(".legend-group").attr({transform:"translate("+[b,f.margin.top]+")"}).style({display:"block"});var V=d.map(function(t,e){var r=a.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});a.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:o({},a.Legend.defaultConfig().legendConfig,{container:F,elements:V,reverseOrder:f.legend.reverseOrder})})();var q=F.node().getBBox();b=Math.min(f.width-q.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,b=Math.max(10,b),_=[f.margin.left+b,f.margin.top+b],n.range([0,b]),u.layout.radialAxis.domain=n.domain(),F.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else F=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),B.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(f.width-(f.margin.left+f.margin.right+2*b+(q?q.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*b))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),e.select(".outer-group").attr("transform","translate("+H+")"),f.title){var G=e.select("g.title-group text").style(U).text(f.title),Y=G.node().getBBox();G.attr({x:_[0]-Y.width/2,y:_[1]-b-20})}var X=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var W=X.selectAll("circle.grid-circle").data(n.ticks(5));W.enter().append("circle").attr({"class":"grid-circle"}).style(D),W.attr("r",n),W.exit().remove()}X.select("circle.outside-circle").attr({r:b}).style(D);var Z=e.select("circle.background-circle").attr({r:b}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var K=i.svg.axis().scale(n).ticks(5).tickSize(5);X.call(K).attr({transform:"rotate("+f.radialAxis.orientation+")"}),X.selectAll(".domain").style(D),X.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(U).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,U["font-size"]]+")":"translate("+[0,U["font-size"]]+")"}}),X.selectAll("g>line").style({stroke:"black"})}var Q=e.select(".angular.axis-group").selectAll("g.angular-tick").data(O),$=Q.enter().append("g").classed("angular-tick",!0);Q.attr({transform:function(t,e){return"rotate("+l(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),Q.exit().remove(),$.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(D),$.selectAll(".minor").style({stroke:f.minorTickColor}),Q.select("line.grid-line").attr({x1:f.tickLength?b-f.tickLength:0,x2:b}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),$.append("text").classed("axis-text",!0).style(U);var J=Q.select("text.axis-text").attr({x:b+f.labelOffset,dy:".35em",transform:function(t,e){var r=l(t,e),n=b+f.labelOffset,i=f.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?270>r&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(180>=r&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(U);f.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=i.max(B.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));F.attr({transform:"translate("+[b+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,rt=e.select("g.geometry-group").selectAll("g.geometry").data(d);if(rt.enter().append("g").attr({"class":function(t,e){return"geometry geometry"+e}}),rt.exit().remove(),d[0]||et){var nt=[];d.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=s,r.container=rt.filter(function(t,r){return r==e}),r.geometry=t.geometry,r.orientation=f.orientation,r.direction=f.direction,r.index=e,nt.push({data:t,geometryConfig:r})});var it=i.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(nt),at=[];it.forEach(function(t,e){"unstacked"===t.key?at=at.concat(t.values.map(function(t,e){return[t]})):at.push(t.values)}),at.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return o(a[r].defaultConfig(),t)});a[r]().config(n)()})}var ot,st,lt=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=a.tooltipPanel().config({container:ct,fontSize:8})(),ft=a.tooltipPanel().config({container:ct,fontSize:8})(),ht=a.tooltipPanel().config({container:ct,hasTick:!0})();if(!M){var dt=lt.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});B.on("mousemove.angular-guide",function(t,e){var r=a.util.getMousePos(Z).angle;dt.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-f.orientation)%360;ot=s.invert(n);var i=a.util.convertToCartesian(b+12,r+180);ut.text(a.util.round(ot)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){lt.select("line").style({opacity:0})})}var pt=lt.select("circle").style({stroke:"grey",fill:"none"});B.on("mousemove.radial-guide",function(t,e){var r=a.util.getMousePos(Z).radius;pt.attr({r:r}).style({opacity:.5}),st=n.invert(a.util.getMousePos(Z).radius);var i=a.util.convertToCartesian(r,f.radialAxis.orientation);ft.text(a.util.round(st)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),ht.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,r){var n=i.select(this),o=n.style("fill"),s="black",l=n.style("opacity")||1;if(n.attr({"data-opacity":l}),"none"!=o){n.attr({"data-fill":o}),s=i.hsl(o).darker().toString(),n.style({fill:s,opacity:1});var c={t:a.util.round(t[0]),r:a.util.round(t[1])};M&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),h=e.node().getBoundingClientRect(),d=[f.left+f.width/2-H[0]-h.left,f.top+f.height/2-H[1]-h.top];ht.config({color:s}).text(u),ht.move(d)}else o=n.style("stroke"),n.attr({"data-stroke":o}),s=i.hsl(o).darker().toString(),n.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0!=i.event.which?!1:void(i.select(this).attr("data-fill")&&ht.show())}).on("mouseout.tooltip",function(t,e){ht.hide();var r=i.select(this),n=r.attr("data-fill");n?r.style({fill:n,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})}),h}var e,r,n,s,l={data:[],layout:{}},c={},u={},f=i.dispatch("hover"),h={};return h.render=function(e){return t(e),this},h.config=function(t){if(!arguments.length)return l;var e=a.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),o(l.data[e],a.Axis.defaultConfig().data[0]),o(l.data[e],t)}),o(l.layout,a.Axis.defaultConfig().layout),o(l.layout,e.layout),this},h.getLiveConfig=function(){return u},h.getinputConfig=function(){return c},h.radialScale=function(t){return n},h.angularScale=function(t){return s},h.svg=function(){return e},i.rebind(h,f,"on"),h},a.Axis.defaultConfig=function(t,e){var r={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:i.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return r},a.util={},a.DATAEXTENT="dataExtent",a.AREA="AreaChart",a.LINE="LinePlot",a.DOT="DotPlot",a.BAR="BarChart",a.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},a.util._extend=function(t,e){for(var r in t)e[r]=t[r]},a.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},a.util.dataFromEquation2=function(t,e){var r=e||6,n=i.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180,i=t(n);return[e,i]});return n},a.util.dataFromEquation=function(t,e,r){var n=e||6,a=[],o=[];i.range(0,360+n,n).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},a.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return i.range(e).map(function(t,e){return r[e]||r[0]})},a.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=a.util.ensureArray(t[e],r)}),t},a.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},a.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},a.util.sumArrays=function(t,e){return i.zip(t,e).map(function(t,e){return i.sum(t)})},a.util.arrayLast=function(t){return t[t.length-1]},a.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},a.util.flattenArray=function(t){for(var e=[];!a.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},a.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},a.util.convertToCartesian=function(t,e){var r=e*Math.PI/180,n=t*Math.cos(r),i=t*Math.sin(r);return[n,i]},a.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},a.util.getMousePos=function(t){var e=i.mouse(t.node()),r=e[0],n=e[1],a={};return a.x=r,a.y=n,a.pos=e,a.angle=180*(Math.atan2(n,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+n*n),a},a.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;a>i;i++)e=t[i],e in r?(r[e]++,n[e]=r[e]):r[e]=1;return n},a.util.duplicates=function(t){return Object.keys(a.util.duplicatesCount(t))},a.util.translator=function(t,e,r,n){if(n){var i=r.slice();r=e,e=i}var a=e.reduce(function(t,e){return"undefined"!=typeof t?t[e]:void 0},t);"undefined"!=typeof a&&(e.reduce(function(t,r,n){return"undefined"!=typeof t?(n===e.length-1&&delete t[r], -t[r]):void 0},t),r.reduce(function(t,e,n){return"undefined"==typeof t[e]&&(t[e]={}),n===r.length-1&&(t[e]=a),t[e]},t))},a.PolyChart=function(){function t(){var t=r[0].geometryConfig,e=t.container;"string"==typeof e&&(e=i.select(e)),e.datum(r).each(function(e,r){function n(e,r){var n=t.radialScale(e[1]),i=(t.angularScale(e[0])+t.orientation)*Math.PI/180;return{r:n,t:i}}function a(t){var e=t.r*Math.cos(t.t),r=t.r*Math.sin(t.t);return{x:e,y:r}}var o=!!e[0].data.yStack,l=e.map(function(t,e){return o?i.zip(t.data.t[0],t.data.r[0],t.data.yStack[0]):i.zip(t.data.t[0],t.data.r[0])}),c=t.angularScale,u=t.radialScale.domain()[0],f={};f.bar=function(r,n,a){var o=e[a].data,s=t.radialScale(r[1])-t.radialScale(0),l=t.radialScale(r[2]||0),u=o.barWidth;i.select(this).attr({"class":"mark bar",d:"M"+[[s+l,-u/2],[s+l,u/2],[l,u/2],[l,-u/2]].join("L")+"Z",transform:function(e,r){return"rotate("+(t.orientation+c(e[0]))+")"}})},f.dot=function(t,r,o){var s=t[2]?[t[0],t[1]+t[2]]:t,l=i.svg.symbol().size(e[o].data.dotSize).type(e[o].data.dotType)(t,r);i.select(this).attr({"class":"mark dot",d:l,transform:function(t,e){var r=a(n(s));return"translate("+[r.x,r.y]+")"}})};var h=i.svg.line.radial().interpolate(e[0].data.lineInterpolation).radius(function(e){return t.radialScale(e[1])}).angle(function(e){return t.angularScale(e[0])*Math.PI/180});f.line=function(r,n,a){var o=r[2]?l[a].map(function(t,e){return[t[0],t[1]+t[2]]}):l[a];if(i.select(this).each(f.dot).style({opacity:function(t,r){return+e[a].data.dotVisible},fill:v.stroke(r,n,a)}).attr({"class":"mark dot"}),!(n>0)){var s=i.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({"class":"line",d:h(o),transform:function(e,r){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(r,n,a)},"fill-opacity":0,stroke:function(t,e){return v.stroke(r,n,a)},"stroke-width":function(t,e){return v["stroke-width"](r,n,a)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](r,n,a)},opacity:function(t,e){return v.opacity(r,n,a)},display:function(t,e){return v.display(r,n,a)}})}};var d=t.angularScale.range(),p=Math.abs(d[1]-d[0])/l[0].length*Math.PI/180,g=i.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,r,n){i.select(this).attr({"class":"mark arc",d:g,transform:function(e,r){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var v={fill:function(t,r,n){return e[n].data.color},stroke:function(t,r,n){return e[n].data.strokeColor},"stroke-width":function(t,r,n){return e[n].data.strokeSize+"px"},"stroke-dasharray":function(t,r,n){return s[e[n].data.strokeDash]},opacity:function(t,r,n){return e[n].data.opacity},display:function(t,r,n){return"undefined"==typeof e[n].data.visible||e[n].data.visible?"block":"none"}},m=i.select(this).selectAll("g.layer").data(l);m.enter().append("g").attr({"class":"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({"class":"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,r=[a.PolyChart.defaultConfig()],n=i.dispatch("hover"),s={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){r[e]||(r[e]={}),o(r[e],a.PolyChart.defaultConfig()),o(r[e],t)}),this):r},t.getColorScale=function(){return e},i.rebind(t,n,"on"),t},a.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:i.scale.category20()}};return t},a.BarChart=function(){return a.PolyChart()},a.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},a.AreaChart=function(){return a.PolyChart()},a.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},a.DotPlot=function(){return a.PolyChart()},a.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},a.LinePlot=function(){return a.PolyChart()},a.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},a.Legend=function(){function t(){var r=e.legendConfig,n=e.data.map(function(t,e){return[].concat(t).map(function(t,n){var i=o({},r.elements[e]);return i.name=t,i.color=[].concat(r.elements[e].color)[n],i})}),a=i.merge(n);a=a.filter(function(t,e){return r.elements[e]&&(r.elements[e].visibleInLegend||"undefined"==typeof r.elements[e].visibleInLegend)}),r.reverseOrder&&(a=a.reverse());var s=r.container;("string"==typeof s||s.nodeName)&&(s=i.select(s));var l=a.map(function(t,e){return t.color}),c=r.fontSize,u=null==r.isContinuous?"number"==typeof a[0]:r.isContinuous,f=u?r.height:c*a.length,h=s.classed("legend-group",!0),d=h.selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=i.range(a.length),v=i.scale[u?"linear":"ordinal"]().domain(g).range(l),m=i.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var r=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=i.svg.symbolTypes.indexOf(t)?i.svg.symbol().type(t).size(r)():i.svg.symbol().type("square").size(r)()};if(u){var b=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);b.enter().append("stop"),b.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:r.height,width:r.colorBandWidth,fill:"url(#grad1)"})}else{var x=d.select(".legend-marks").selectAll("path.legend-mark").data(a);x.enter().append("path").classed("legend-mark",!0),x.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var r=t.symbol;return y(r,c)},fill:function(t,e){return v(e)}}),x.exit().remove()}var _=i.svg.axis().scale(m).orient("right"),w=d.select("g.legend-axis").attr({transform:"translate("+[u?r.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?r.textColor:"none"}),w.selectAll("text").style({fill:r.textColor,"font-size":r.fontSize}).text(function(t,e){return a[e].name}),t}var e=a.Legend.defaultConfig(),r=i.dispatch("hover");return t.config=function(t){return arguments.length?(o(e,t),this):e},i.rebind(t,r,"on"),t},a.Legend.defaultConfig=function(t,e){var r={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return r},a.tooltipPanel=function(){var t,e,r,n={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+a.tooltipPanel.uid++,l=10,c=function(){t=n.container.selectAll("g."+s).data([0]);var i=t.enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=i.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=i.append("text").attr({dx:n.padding+l,dy:.3*+n.fontSize}),c};return c.text=function(a){var o=i.hsl(n.color).l,s=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":n.fontSize+"px"}).text(f);var h=n.padding,d=e.node().getBBox(),p={fill:n.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[n.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),c},c.move=function(e){return t?(t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c):void 0},c.hide=function(){return t?(t.style({display:"none"}),c):void 0},c.show=function(){return t?(t.style({display:"block"}),c):void 0},c.config=function(t){return o(n,t),c},c},a.tooltipPanel.uid=1,a.adapter={},a.adapter.plotly=function(){var t={};return t.convert=function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=o({},t),i=[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]];return i.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",n.dotVisible===!0?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var n=a.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var i=n.indexOf(t.geometry);-1!=i&&(r.data[e].groupId=i)})}if(t.layout){var s=o({},t.layout),l=[[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]];if(l.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};i.entries(s.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),s.margin=f}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r},t}},{"../../plotly":390,"./micropolar_manager":445,d3:87}],445:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("d3"),a=t("./undo_manager"),o=e.exports={},s=n.Lib.extendDeepAll;o.framework=function(t){function e(e,a){return a&&(f=a),i.select(i.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),r=r?s(r,e):e,c||(c=n.micropolar.Axis()),u=n.micropolar.adapter.plotly().convert(r),c.config(u).render(f),t.data=r.data,t.layout=r.layout,o.fillLayout(t),r}var r,l,c,u,f,h=new a;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return r},e.getLiveConfig=function(){return n.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=n.micropolar.util.cloneJson(r);!function(e,r){h.add({undo:function(){r&&t(r)},redo:function(){t(e)}})}(e,l),l=n.micropolar.util.cloneJson(e)},e.undo=function(){h.undo()},e.redo=function(){h.redo()},e},o.fillLayout=function(t){var e=i.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:n.Color.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../plotly":390,"./undo_manager":446,d3:87}],446:[function(t,e,r){"use strict";e.exports=function(){function t(t,e){return t?(i=!0,t[e](),i=!1,this):this}var e,r=[],n=-1,i=!1;return{add:function(t){return i?this:(r.splice(n+1,r.length-n),r.push(t),n=r.length-1,this)},setCallback:function(t){e=t},undo:function(){var i=r[n];return i?(t(i,"undo"),n-=1,e&&e(i.undo),this):this},redo:function(){var i=r[n+1];return i?(t(i,"redo"),n+=1,e&&e(i.redo),this):this},clear:function(){r=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return ng;g++){var v=d[g];s=t[v]?t[v]:t[v]={},e[v]=l={},o("domain."+h,[g/p,(g+1)/p]),o("domain."+{x:"y",y:"x"}[h]),a.id=v,f(s,l,o,a)}}},{"../lib":372,"./plots":441}],448:[function(t,e,r){"use strict";var n=t("./ternary"),i=t("../../plots/plots");r.name="ternary",r.attr="subplot",r.idRoot="ternary",r.idRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"ternary"),o=0;o=o&&(d.min=0,p.min=0,g.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}var i=t("../../../components/color"),a=t("../../subplot_defaults"),o=t("./layout_attributes"),s=t("./axis_defaults"),l=["aaxis","baxis","caxis"];e.exports=function(t,e,r){e._hasTernary&&a(t,e,r,{type:"ternary",attributes:o,handleDefaults:n,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../../components/color":297,"../../subplot_defaults":447,"./axis_defaults":451,"./layout_attributes":453}],453:[function(t,e,r){"use strict";var n=t("../../../components/color/attributes"),i=t("./axis_attributes");e.exports={domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},bgcolor:{valType:"color",dflt:n.background},sum:{valType:"number",dflt:1,min:0},aaxis:i,baxis:i,caxis:i}},{"../../../components/color/attributes":296,"./axis_attributes":450}],454:[function(t,e,r){"use strict";function n(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework()}function i(t){a.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var a=t("d3"),o=t("tinycolor2"),s=t("../../plotly"),l=t("../../lib"),c=t("../../components/color"),u=t("../../components/drawing"),f=t("../cartesian/set_convert"),h=t("../../lib/extend").extendFlat,d=t("../cartesian/axes"),p=t("../../lib/filter_visible"),g=t("../../components/dragelement"),v=t("../../components/titles"),m=t("../cartesian/select"),y=t("../cartesian/constants"),b=t("../cartesian/graph_interact");e.exports=n;var x=n.prototype;x.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={}},x.plot=function(t,e){var r,n=this,i=e[n.id],a=e._size;l.getPlotDiv(n.plotContainer.node())!==n.graphDiv&&(n.init(n.graphDiv._fullLayout),n.makeFramework()),n.adjustLayout(i,a);var o=n.traceHash,s={};for(r=0;r_*y?(a=y,i=a*_):(i=m,a=i/_),o=g*i/m,s=v*a/y,r=e.l+e.w*d-i/2,n=e.t+e.h*(1-p)-a/2,l.x0=r,l.y0=n,l.w=i,l.h=a,l.sum=b,l.xaxis={type:"linear",range:[x+2*k-b,b-x-2*w],domain:[d-o/2,d+o/2],_id:"x",_gd:l.graphDiv},f(l.xaxis),l.xaxis.setScale(),l.yaxis={type:"linear",range:[x,b-w-k],domain:[p-s/2,p+s/2],_id:"y",_gd:l.graphDiv},f(l.yaxis),l.yaxis.setScale();var A=l.yaxis.domain[0],M=l.aaxis=h({},t.aaxis,{range:[x,b-w-k],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[A,A+s*_],_axislayer:l.layers.aaxis,_gridlayer:l.layers.agrid,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l"+a+",-"+i/2});f(M);var T=l.baxis=h({},t.baxis,{range:[b-x-k,w],side:"bottom",_counterangle:30,domain:l.xaxis.domain,_axislayer:l.layers.baxis,_gridlayer:l.layers.bgrid,_counteraxis:l.aaxis,_pos:0,_gd:l.graphDiv,_id:"x",_length:i,_gridpath:"M0,0l-"+i/2+",-"+a});f(T),M._counteraxis=T;var E=l.caxis=h({},t.caxis,{range:[b-x-w,k],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[A,A+s*_],_axislayer:l.layers.caxis,_gridlayer:l.layers.cgrid,_counteraxis:l.baxis,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l-"+a+","+i/2});f(E);var L="M"+r+","+(n+a)+"h"+i+"l-"+i/2+",-"+a+"Z";l.clipDef.select("path").attr("d",L),l.layers.plotbg.select("path").attr("d",L);var S="translate("+r+","+n+")";l.plotContainer.selectAll(".scatterlayer,.maplayer,.zoom").attr("transform",S);var C="translate("+r+","+(n+a)+")";l.layers.baxis.attr("transform",C),l.layers.bgrid.attr("transform",C);var z="translate("+(r+i/2)+","+n+")rotate(30)";l.layers.aaxis.attr("transform",z),l.layers.agrid.attr("transform",z);var P="translate("+(r+i/2)+","+n+")rotate(-30)";l.layers.caxis.attr("transform",P),l.layers.cgrid.attr("transform",P),l.drawAxes(!0),l.plotContainer.selectAll(".crisp").classed("crisp",!1);var R=l.layers.axlines;R.select(".aline").attr("d",M.showline?"M"+r+","+(n+a)+"l"+i/2+",-"+a:"M0,0").call(c.stroke,M.linecolor||"#000").style("stroke-width",(M.linewidth||0)+"px"),R.select(".bline").attr("d",T.showline?"M"+r+","+(n+a)+"h"+i:"M0,0").call(c.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),R.select(".cline").attr("d",E.showline?"M"+(r+i/2)+","+n+"l"+i/2+","+a:"M0,0").call(c.stroke,E.linecolor||"#000").style("stroke-width",(E.linewidth||0)+"px")},x.drawAxes=function(t){var e=this,r=e.graphDiv,n=e.id.substr(7)+"title",i=e.aaxis,a=e.baxis,o=e.caxis;if(d.doTicks(r,i,!0),d.doTicks(r,a,!0),d.doTicks(r,o,!0),t){var s=Math.max(i.showticklabels?i.tickfont.size/2:0,(o.showticklabels?.75*o.tickfont.size:0)+("outside"===o.ticks?.87*o.ticklen:0));v.draw(r,"a"+n,{propContainer:i,propName:e.id+".aaxis.title",dfltName:"Component A",attributes:{x:e.x0+e.w/2,y:e.y0-i.titlefont.size/3-s,"text-anchor":"middle"}});var l=(a.showticklabels?a.tickfont.size:0)+("outside"===a.ticks?a.ticklen:0)+3;v.draw(r,"b"+n,{propContainer:a,propName:e.id+".baxis.title",dfltName:"Component B",attributes:{x:e.x0-l,y:e.y0+e.h+.83*a.titlefont.size+l,"text-anchor":"middle"}}),v.draw(r,"c"+n,{propContainer:o,propName:e.id+".caxis.title",dfltName:"Component C",attributes:{x:e.x0+e.w+l,y:e.y0+e.h+.83*o.titlefont.size+l,"text-anchor":"middle"}})}};var w=y.MINZOOM/2+.87,k="m-0.87,.5h"+w+"v3h-"+(w+5.2)+"l"+(w/2+2.6)+",-"+(.87*w+4.5)+"l2.6,1.5l-"+w/2+","+.87*w+"Z",A="m0.87,.5h-"+w+"v3h"+(w+5.2)+"l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-2.6,1.5l"+w/2+","+.87*w+"Z",M="m0,1l"+w/2+","+.87*w+"l2.6,-1.5l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-"+(w/2+2.6)+","+(.87*w+4.5)+"l2.6,1.5l"+w/2+",-"+.87*w+"Z",T="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",E=!0;x.initInteractions=function(){function t(t,e,r){var n=j.getBoundingClientRect();x=e-n.left,w=r-n.top,L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L,S=N.aaxis.range[1]-L.a,z=o(N.graphDiv._fullLayout[N.id].bgcolor).getLuminance(),P="M0,"+N.h+"L"+N.w/2+", 0L"+N.w+","+N.h+"Z",R=!1,O=B.append("path").attr("class","zoombox").style({fill:z>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",P),I=B.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),p()}function e(t,e){return 1-e/N.h}function r(t,e){return 1-(t+(N.h-e)/Math.sqrt(3))/N.w}function n(t,e){return(t-(N.h-e)/Math.sqrt(3))/N.w}function a(t,i){var a=x+t,o=w+i,s=Math.max(0,Math.min(1,e(x,w),e(a,o))),l=Math.max(0,Math.min(1,r(x,w),r(a,o))),c=Math.max(0,Math.min(1,n(x,w),n(a,o))),u=(s/2+c)*N.w,f=(1-s/2-l)*N.w,h=(u+f)/2,d=f-u,p=(1-s)*N.h,g=p-d/_;d.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),I.transition().style("opacity",1).duration(200),R=!0)}function u(t,e){if(C===L)return 2===e&&v(),i(F);i(F);var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r),E&&F.data&&F._context.showTips&&(l.notifier("Double-click to
zoom back out","long"),E=!1)}function f(){L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L}function h(t,e){var r=t/N.xaxis._m,n=e/N.yaxis._m;C={a:L.a-n,b:L.b+(r+n)/2,c:L.c-(r-n)/2};var i=[C.a,C.b,C.c].sort(),a={a:i.indexOf(C.a),b:i.indexOf(C.b),c:i.indexOf(C.c)};i[0]<0&&(i[1]+i[0]/2<0?(i[2]+=i[0]+i[1],i[0]=i[1]=0):(i[2]+=i[0]/2,i[1]+=i[0]/2,i[0]=0),C={a:i[a.a],b:i[a.b],c:i[a.c]},e=(L.a-C.a)*N.yaxis._m,t=(L.c-C.c-L.b+C.b)*N.xaxis._m);var o="translate("+(N.x0+t)+","+(N.y0+e)+")";N.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",o),N.aaxis.range=[C.a,N.sum-C.b-C.c],N.baxis.range=[N.sum-C.a-C.c,C.b],N.caxis.range=[N.sum-C.a-C.b,C.c],N.drawAxes(!1),N.plotContainer.selectAll(".crisp").classed("crisp",!1)}function d(t,e){if(t){var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r)}else 2===e&&v()}function p(){N.plotContainer.selectAll(".select-outline").remove()}function v(){var t={};t[N.id+".aaxis.min"]=0,t[N.id+".baxis.min"]=0,t[N.id+".caxis.min"]=0,F.emit("plotly_doubleclick",null),s.relayout(F,t)}var x,w,L,S,C,z,P,R,O,I,N=this,j=N.layers.plotbg.select("path").node(),F=N.graphDiv,B=N.layers.zoom,D={element:j,gd:F,plotinfo:{plot:B},doubleclick:v,subplot:N.id,prepFn:function(e,r,n){D.xaxes=[N.xaxis],D.yaxes=[N.yaxis];var i=F._fullLayout.dragmode;e.shiftKey&&(i="pan"===i?"zoom":"pan"),"lasso"===i?D.minDrag=1:D.minDrag=void 0,"zoom"===i?(D.moveFn=a,D.doneFn=u,t(e,r,n)):"pan"===i?(D.moveFn=h,D.doneFn=d,f(),p()):"select"!==i&&"lasso"!==i||m(e,r,n,D,i)}};g.init(D),j.onmousemove=function(t){b.hover(F,t,N.id),F._fullLayout._lasthover=j,F._fullLayout._hoversubplot=N.id},j.onmouseout=function(t){F._dragging||g.unhover(F,t)},j.onclick=function(t){b.click(F,t)},F._fullLayout._plots||(F._fullLayout._plots={}),F._fullLayout._plots[N.id]={overlays:[],xaxis:N.xaxis,yaxis:N.yaxis,x:function(){return N.xaxis},y:function(){return N.yaxis}}}},{"../../components/color":297,"../../components/dragelement":317,"../../components/drawing":319,"../../components/titles":355,"../../lib":372,"../../lib/extend":367,"../../lib/filter_visible":368,"../../plotly":390,"../cartesian/axes":393,"../cartesian/constants":398,"../cartesian/graph_interact":400,"../cartesian/select":406,"../cartesian/set_convert":407,d3:87,tinycolor2:275}],455:[function(t,e,r){"use strict";function n(t){var e;switch(t){case"themes__thumb":e={autosize:!0,width:150,height:150,title:"",showlegend:!1,margin:{l:5,r:5,t:5,b:5,pad:0},annotations:[]};break;case"thumbnail":e={title:"",hidesources:!0,showlegend:!1,borderwidth:0,bordercolor:"",margin:{l:1,r:1,t:1,b:1,pad:0},annotations:[]};break;default:e={}}return e}function i(t){var e=["xaxis","yaxis","zaxis"];return e.indexOf(t.slice(0,5))>-1}var a=t("../plotly"),o=a.Lib.extendFlat,s=a.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var r,l=t.data,c=t.layout,u=s([],l),f=s({},c,n(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var h=Object.keys(f);for(r=0;rl;l++)n(r[l])&&n(s[l])&&d.push({p:r[l],s:s[l],b:0});return a(e,"marker")&&o(e,e.marker.color,"marker","c"),a(e,"marker.line")&&o(e,e.marker.line.color,"marker.line","c"),d}},{"../../components/colorscale/calc":304,"../../components/colorscale/has_colorscale":309,"../../plots/cartesian/axes":393,"fast-isnumeric":95}],463:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("../scatter/xy_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=a(t,e,u);return f?(u("orientation",e.x&&!e.y?"h":"v"),u("text"),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),void s(t,e,i.defaultLine,{axis:"x",inherit:"y"})):void(e.visible=!1)}},{"../../components/color":297,"../../components/errorbars/defaults":324,"../../lib":372,"../bar/style_defaults":471,"../scatter/xy_defaults":561,"./attributes":461}],464:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../components/errorbars"),a=t("../../components/color");e.exports=function(t,e,r,o){var s,l=t.cd,c=l[0].trace,u=l[0].t,f=t.xa,h=t.ya,d="closest"===o?u.barwidth/2:u.dbar*(1-f._gd._fullLayout.bargap)/2;s="closest"!==o?function(t){return t.p}:"h"===c.orientation?function(t){return t.y}:function(t){return t.x};var p,g;"h"===c.orientation?(p=function(t){return n.inbox(t.b-e,t.x-e)+(t.x-e)/(t.x-t.b)},g=function(t){var e=s(t)-r;return n.inbox(e-d,e+d)}):(g=function(t){return n.inbox(t.b-r,t.y-r)+(t.y-r)/(t.y-t.b)},p=function(t){var r=s(t)-e;return n.inbox(r-d,r+d)});var v=n.getDistanceFunction(o,p,g);if(n.getClosest(l,v,t),t.index!==!1){var m=l[t.index],y=m.mcc||c.marker.color,b=m.mlcc||c.marker.line.color,x=m.mlw||c.marker.line.width;return a.opacity(y)?t.color=y:a.opacity(b)&&x&&(t.color=b),"h"===c.orientation?(t.x0=t.x1=f.c2p(m.x,!0),t.xLabelVal=m.s,t.y0=h.c2p(s(m)-d,!0),t.y1=h.c2p(s(m)+d,!0),t.yLabelVal=m.p):(t.y0=t.y1=h.c2p(m.y,!0),t.yLabelVal=m.s,t.x0=f.c2p(s(m)-d,!0),t.x1=f.c2p(s(m)+d,!0),t.xLabelVal=m.p),m.tx&&(t.text=m.tx),i.hoverInfo(m,c,t),[t]}}},{"../../components/color":297,"../../components/errorbars":325,"../../plots/cartesian/graph_interact":400}],465:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("./layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.calc=t("./calc"),n.setPositions=t("./set_positions"),n.colorbar=t("../scatter/colorbar"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.moduleType="trace",n.name="bar",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","oriented","markerColorscale","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":401,"../scatter/colorbar":543,"./arrays_to_calcdata":460,"./attributes":461,"./calc":462,"./defaults":463,"./hover":464,"./layout_attributes":466,"./layout_defaults":467,"./plot":468,"./set_positions":469,"./style":470}],466:[function(t,e,r){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","group","overlay"],dflt:"group"},barnorm:{valType:"enumerated",values:["","fraction","percent"],dflt:""},bargap:{valType:"number",min:0,max:1},bargroupgap:{valType:"number",min:0,max:1,dflt:0}}},{}],467:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./layout_attributes");e.exports=function(t,e,r){function s(r,n){return a.coerce(t,e,o,r,n)}for(var l=!1,c=!1,u=!1,f={},h=0;h=2?a(t):t>e?Math.ceil(t):Math.floor(t)}var h,d,p,g;if("h"===s.orientation?(p=u.c2p(r.poffset+e.p,!0),g=u.c2p(r.poffset+e.p+r.barwidth,!0),h=c.c2p(e.b,!0),d=c.c2p(e.s+e.b,!0)):(h=c.c2p(r.poffset+e.p,!0),d=c.c2p(r.poffset+e.p+r.barwidth,!0),g=u.c2p(e.s+e.b,!0),p=u.c2p(e.b,!0)),!(i(h)&&i(d)&&i(p)&&i(g)&&h!==d&&p!==g))return void n.select(this).remove();var v=(e.mlw+1||s.marker.line.width+1||(e.trace?e.trace.marker.line.width:0)+1)-1,m=n.round(v/2%1,2);if(!t._context.staticPlot){var y=o.opacity(e.mc||s.marker.color),b=1>y||v>.01?a:l;h=b(h,d),d=b(d,h),p=b(p,g),g=b(g,p)}n.select(this).attr("d","M"+h+","+p+"V"+g+"H"+d+"V"+p+"Z")})}),h.call(s.plot,e)}},{"../../components/color":297,"../../components/errorbars":325,"../../lib":372,"./arrays_to_calcdata":460,d3:87,"fast-isnumeric":95}],469:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axes"),o=t("../../lib");e.exports=function(t,e){var r,s,l=t._fullLayout,c=e.x(),u=e.y();["v","h"].forEach(function(f){function h(e){function r(t){t[p]=t.p+h}var n=[];e.forEach(function(e){t.calcdata[e].forEach(function(t){n.push(t.p)})});var i=o.distinctVals(n),s=i.vals,c=i.minDiff,u=!1,f=[];"group"===l.barmode&&e.forEach(function(e){u||(t.calcdata[e].forEach(function(t){u||f.forEach(function(e){Math.abs(t.p-e)x&&(L=!0,A=x),x>k+z&&(L=!0,k=x))}a.expand(m,[A,k],{tozero:!0,padded:L})}else{var P=function(t){return t[g]=t.s,t.s};for(r=0;r1||0===s.bargap&&0===s.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),e.selectAll("g.points").each(function(t){var e=t[0].trace,r=e.marker,o=r.line,s=(e._input||{}).marker||{},l=a.tryColorscale(r,s,""),c=a.tryColorscale(r,s,"line.");n.select(this).selectAll("path").each(function(t){var e,a,s=(t.mlw+1||o.width+1)-1,u=n.select(this);e="mc"in t?t.mcc=l(t.mc):Array.isArray(r.color)?i.defaultLine:r.color,u.style("stroke-width",s+"px").call(i.fill,e),s&&(a="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(o.color)?i.defaultLine:o.color,u.call(i.stroke,a))})}),e.call(o.style)}},{"../../components/color":297,"../../components/drawing":319,"../../components/errorbars":325,d3:87}],471:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s){r("marker.color",o),i(t,"marker")&&a(t,e,s,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),i(t,"marker.line")&&a(t,e,s,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width")}},{"../../components/color":297,"../../components/colorscale/defaults":306,"../../components/colorscale/has_colorscale":309}],472:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/color/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=o.line;e.exports={y:{valType:"data_array"},x:{valType:"data_array"},x0:{valType:"any"},y0:{valType:"any"},whiskerwidth:{valType:"number",min:0,max:1,dflt:.5},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1},jitter:{valType:"number",min:0,max:1},pointpos:{valType:"number",min:-2,max:2},orientation:{valType:"enumerated",values:["v","h"]},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)"},symbol:a({},o.symbol,{arrayOk:!1}),opacity:a({},o.opacity,{arrayOk:!1,dflt:1}),size:a({},o.size,{arrayOk:!1}),color:a({},o.color,{arrayOk:!1}),line:{color:a({},s.color,{arrayOk:!1,dflt:i.defaultLine}),width:a({},s.width,{arrayOk:!1,dflt:0}),outliercolor:{valType:"color"},outlierwidth:{valType:"number",min:0,dflt:1}}},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2}},fillcolor:n.fillcolor}},{"../../components/color/attributes":296,"../../lib/extend":367,"../scatter/attributes":540}],473:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../../plots/cartesian/axes");e.exports=function(t,e){function r(t,e,r,a,o){var s;return r in e?p=a.makeCalcdata(e,r):(s=r+"0"in e?e[r+"0"]:"name"in e&&("category"===a.type||n(e.name)&&-1!==["linear","log"].indexOf(a.type)||i.isDateTime(e.name)&&"date"===a.type)?e.name:t.numboxes,s=a.d2c(s),p=o.map(function(){return s})),p}function o(t,e,r,a,o){var s,l,c,u,f=a.length,h=e.length,d=[],p=[];for(s=0;f>s;++s)l=a[s],t[s]={pos:l},p[s]=l-o,d[s]=[];for(p.push(a[f-1]+o),s=0;h>s;++s)u=e[s],n(u)&&(c=i.findBin(r[s],p),c>=0&&h>c&&d[c].push(u));return d}function s(t,e){var r,n,a,o;for(o=0;o1,m=r.dPos*(1-h.boxgap)*(1-h.boxgroupgap)/(v?t.numboxes:1),y=v?2*r.dPos*(-.5+(r.boxnum+.5)/t.numboxes)*(1-h.boxgap):0,b=m*g.whiskerwidth;return g.visible!==!0||r.emptybox?void a.select(this).remove():("h"===g.orientation?(l=p,f=d):(l=d,f=p),r.bPos=y,r.bdPos=m,n(),a.select(this).selectAll("path.box").data(o.identity).enter().append("path").attr("class","box").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=l.c2p(t.pos+y-b,!0),s=l.c2p(t.pos+y+b,!0),c=f.c2p(t.q1,!0),u=f.c2p(t.q3,!0),h=o.constrain(f.c2p(t.med,!0),Math.min(c,u)+1,Math.max(c,u)-1),d=f.c2p(g.boxpoints===!1?t.min:t.lf,!0),p=f.c2p(g.boxpoints===!1?t.max:t.uf,!0);"h"===g.orientation?a.select(this).attr("d","M"+h+","+r+"V"+n+"M"+c+","+r+"V"+n+"H"+u+"V"+r+"ZM"+c+","+e+"H"+d+"M"+u+","+e+"H"+p+(0===g.whiskerwidth?"":"M"+d+","+i+"V"+s+"M"+p+","+i+"V"+s)):a.select(this).attr("d","M"+r+","+h+"H"+n+"M"+r+","+c+"H"+n+"V"+u+"H"+r+"ZM"+e+","+c+"V"+d+"M"+e+","+u+"V"+p+(0===g.whiskerwidth?"":"M"+i+","+d+"H"+s+"M"+i+","+p+"H"+s))}),g.boxpoints&&a.select(this).selectAll("g.points").data(function(t){return t.forEach(function(t){t.t=r,t.trace=g}),t}).enter().append("g").attr("class","points").selectAll("path").data(function(t){var e,r,n,a,s,l,f,h="all"===g.boxpoints?t.val:t.val.filter(function(e){return et.uf}),d=(t.q3-t.q1)*u,p=[],v=0;if(g.jitter){for(e=0;et.lo&&(n.so=!0),n})}).enter().append("path").call(s.translatePoints,d,p),void(g.boxmean&&a.select(this).selectAll("path.mean").data(o.identity).enter().append("path").attr("class","mean").style("fill","none").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=f.c2p(t.mean,!0),o=f.c2p(t.mean-t.sd,!0),s=f.c2p(t.mean+t.sd,!0);"h"===g.orientation?a.select(this).attr("d","M"+i+","+r+"V"+n+("sd"!==g.boxmean?"":"m0,0L"+o+","+e+"L"+i+","+r+"L"+s+","+e+"Z")):a.select(this).attr("d","M"+r+","+i+"H"+n+("sd"!==g.boxmean?"":"m0,0L"+e+","+o+"L"+r+","+i+"L"+e+","+s+"Z"))})))})}},{"../../components/drawing":319,"../../lib":372,d3:87}],480:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib");e.exports=function(t,e){var r,o,s,l,c=t._fullLayout,u=e.x(),f=e.y(),h=["v","h"];for(o=0;ol&&(e.z=u.slice(0,l)),s("locationmode"),s("text"),s("marker.line.color"),s("marker.line.width"),i(t,e,o,s,{prefix:"",cLetter:"z"}),void s("hoverinfo",1===o._dataLength?"location+z+text":void 0)):void(e.visible=!1)}},{"../../components/colorscale/defaults":306,"../../lib":372,"./attributes":482}],485:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../heatmap/colorbar"),n.calc=t("./calc"),n.plot=t("./plot").plot,n.moduleType="trace",n.name="choropleth",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","noOpacity"],n.meta={},e.exports=n},{"../../plots/geo":413,"../heatmap/colorbar":499,"./attributes":482,"./calc":483,"./defaults":484,"./plot":486}],486:[function(t,e,r){"use strict";function n(t,e){function r(e){var r=t.mockAxis;return o.tickText(r,r.c2l(e),"hover").text}var n=e.hoverinfo;if("none"===n)return function(t){delete t.nameLabel,delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("name"),s=-1!==i.indexOf("location"),l=-1!==i.indexOf("z"),c=-1!==i.indexOf("text"),u=!a&&s;return function(t){var n=[];u?t.nameLabel=t.id:(a&&(t.nameLabel=e.name),s&&n.push(t.id)),l&&n.push(r(t.z)),c&&n.push(t.tx),t.textLabel=n.join("
")}}function i(t){return function(e,r){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:r,location:e.id,z:e.z}]}}}var a=t("d3"),o=t("../../plots/cartesian/axes"),s=t("../../plots/cartesian/graph_interact"),l=t("../../components/color"),c=t("../../components/drawing"),u=t("../../components/colorscale/get_scale"),f=t("../../components/colorscale/make_scale_function"),h=t("../../lib/topojson_utils").getTopojsonFeatures,d=t("../../lib/geo_location_utils").locationToFeature,p=t("../../lib/array_to_calc_item"),g=t("../../constants/geo_constants"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){for(var r,n=[],i=t.locations,a=i.length,o=h(t,e),s=(t.marker||{}).line||{},l=0;a>l;l++)r=d(t.locationmode,i[l],o),void 0!==r&&(r.z=t.z[l],void 0!==t.text&&(r.tx=t.text[l]),p(s.color,r,"mlc",l),p(s.width,r,"mlw",l),n.push(r));return n.length>0&&(n[0].trace=t),n},m.plot=function(t,e,r){var o,l=t.framework,c=l.select("g.choroplethlayer"),u=l.select("g.baselayer"),f=l.select("g.baselayeroverchoropleth"),h=g.baseLayersOverChoropleth,d=c.selectAll("g.trace.choropleth").data(e,function(t){return t.uid});d.enter().append("g").attr("class","trace choropleth"),d.exit().remove(),d.each(function(e){function r(e,r){if(t.showHover){var n=t.projection(e.properties.ct);c(e),s.loneHover({x:n[0],y:n[1],name:e.nameLabel,text:e.textLabel},{container:t.hoverContainer.node()}),f=u(e,r),t.graphDiv.emit("plotly_hover",f)}}function o(e,r){t.graphDiv.emit("plotly_click",u(e,r))}var l=m.calcGeoJSON(e,t.topojson),c=n(t,e),u=i(e),f=null,h=a.select(this).selectAll("path.choroplethlocation").data(l);h.enter().append("path").classed("choroplethlocation",!0).on("mouseover",r).on("click",o).on("mouseout",function(){s.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",f)}).on("mousedown",function(){s.loneUnhover(t.hoverContainer)}).on("mouseup",r),h.exit().remove()}),f.selectAll("*").remove();for(var p=0;pr;r++)e=f[r],d[r]=e[0]*(t.zmax-t.zmin)+t.zmin,p[r]=e[1];var g=n.extent([t.zmin,t.zmax,a.start,a.start+l*(c-1)]),v=g[t.zminr;r++)e=f[r],d[r]=(e[0]*(c+u-1)-u/2)*l+o,p[r]=e[1];var y=n.scale.linear().interpolate(n.interpolateRgb).domain(d).range(p);return y}},{"../../components/colorscale/get_scale":308,d3:87}],494:[function(t,e,r){"use strict";function n(t,e,r){_.markTime("in Contour.plot");var n=r[0].trace,a=r[0].x,s=r[0].y,c=n.contours,u=n.uid,f=e.x(),h=e.y(),v=t._fullLayout,b="contour"+u,x=i(c,e,r[0]);if(n.visible!==!0)return v._paper.selectAll("."+b+",.hm"+u).remove(),void v._infolayer.selectAll(".cb"+u).remove();"heatmap"===c.coloring?(n.zauto&&n.autocontour===!1&&(n._input.zmin=n.zmin=c.start-c.size/2,n._input.zmax=n.zmax=n.zmin+x.length*c.size),k(t,e,[r])):v._paper.selectAll(".hm"+u).remove(),o(x),l(x);var w=f.c2p(a[0],!0),A=f.c2p(a[a.length-1],!0),M=h.c2p(s[0],!0),T=h.c2p(s[s.length-1],!0),E=[[w,T],[A,T],[A,M],[w,M]],L=d(e,r,b);p(L,E,c),g(L,x,E,c),m(L,x,c),y(L,e,r[0],E),_.markTime("done Contour.plot")}function i(t,e,r){for(var n=t.size||1,i=[],a=t.start;at?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);if(5===r||10===r){var n=(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4;return t>n?5===r?713:1114:5===r?104:208}return 15===r?0:r}function o(t){var e,r,n,i,o,s,l,c,u,f=t[0].z,h=f.length,d=f[0].length,p=2===h||2===d;for(r=0;h-1>r;r++)for(i=[],0===r&&(i=i.concat(A)),r===h-2&&(i=i.concat(M)),e=0;d-1>e;e++)for(n=i.slice(),0===e&&(n=n.concat(T)),e===d-2&&(n=n.concat(E)),o=e+","+r,s=[[f[r][e],f[r][e+1]],[f[r+1][e],f[r+1][e+1]]],u=0;ui;i++){if(s>20?(s=S[s][(l[0]||l[1])<0?0:1],t.crossings[o]=C[s]):delete t.crossings[o],l=L[s],!l){console.log("found bad marching index",s,e,t.level);break}if(d.push(h(t,e,l)),e[0]+=l[0],e[1]+=l[1],u(d[d.length-1],d[d.length-2])&&d.pop(),o=e.join(","),o===a&&l.join(",")===p||r&&(l[0]&&(e[0]<0||e[0]>v-2)||l[1]&&(e[1]<0||e[1]>g-2)))break;s=t.crossings[o]}1e4===i&&console.log("Infinite loop in contour?");var m,y,b,x,_,w,k,A=u(d[0],d[d.length-1]),M=0,T=.2*t.smoothing,E=[],z=0;for(i=1;i=z;i--)if(m=E[i],P>m){for(b=0,y=i-1;y>=z&&m+E[y]b&&m+E[b]e;)e++,r=Object.keys(i.crossings)[0].split(",").map(Number),s(i,r);1e4===e&&console.log("Infinite loop in contour?")}}function c(t,e,r){var n=0,i=0;return t>20&&e?208===t||1114===t?n=0===r[0]?1:-1:i=0===r[1]?1:-1:-1!==A.indexOf(t)?i=1:-1!==T.indexOf(t)?n=1:-1!==M.indexOf(t)?i=-1:n=-1,[n,i]}function u(t,e){return Math.abs(t[0]-e[0])<.01&&Math.abs(t[1]-e[1])<.01}function f(t,e){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function h(t,e,r){var n=e[0]+Math.max(r[0],0),i=e[1]+Math.max(r[1],0),a=t.z[i][n],o=t.xaxis,s=t.yaxis;if(r[1]){var l=(t.level-a)/(t.z[i][n+1]-a);return[o.c2p((1-l)*t.x[n]+l*t.x[n+1],!0),s.c2p(t.y[i],!0)]}var c=(t.level-a)/(t.z[i+1][n]-a);return[o.c2p(t.x[n],!0),s.c2p((1-c)*t.y[i]+c*t.y[i+1],!0)]}function d(t,e,r){var n=t.plot.select(".maplayer").selectAll("g.contour."+r).data(e);return n.enter().append("g").classed("contour",!0).classed(r,!0),n.exit().remove(),n}function p(t,e,r){var n=t.selectAll("g.contourbg").data([0]);n.enter().append("g").classed("contourbg",!0);var i=n.selectAll("path").data("fill"===r.coloring?[0]:[]);i.enter().append("path"),i.exit().remove(),i.attr("d","M"+e.join("L")+"Z").style("stroke","none")}function g(t,e,r,n){var i=t.selectAll("g.contourfill").data([0]);i.enter().append("g").classed("contourfill",!0);var a=i.selectAll("path").data("fill"===n.coloring?e:[]);a.enter().append("path"),a.exit().remove(),a.each(function(t){var e=v(t,r);e?x.select(this).attr("d",e).style("stroke","none"):x.select(this).remove()})}function v(t,e){function r(t){return Math.abs(t[1]-e[0][1])<.01}function n(t){return Math.abs(t[1]-e[2][1])<.01}function i(t){return Math.abs(t[0]-e[0][0])<.01}function a(t){return Math.abs(t[0]-e[2][0])<.01}for(var o,s,l,c,u,f,h=t.edgepaths.length||t.z[0][0]l;l++){if(!o){console.log("missing end?",d,t);break}for(r(o)&&!a(o)?s=e[1]:i(o)?s=e[0]:n(o)?s=e[3]:a(o)&&(s=e[2]),u=0;u=0&&(s=v,c=u):Math.abs(o[1]-s[1])<.01?Math.abs(o[1]-v[1])<.01&&(v[0]-o[0])*(s[0]-v[0])>=0&&(s=v,c=u):console.log("endpt to newendpt is not vert. or horz.",o,s,v)}if(o=s,c>=0)break;h+="L"+s}if(c===t.edgepaths.length){console.log("unclosed perimeter path");break}d=c,g=-1===p.indexOf(d),g&&(d=p[0],h+="Z")}for(d=0;de;e++)s.push(1);for(e=0;a>e;e++)i.push(s.slice());for(e=0;eo;o++)for(n=i(l,o),u[o]=new Array(n),s=0;n>s;s++)u[o][s]=e(a(l,o,s));return u}function i(t,e,r,n,i,a){var o,s,l,c=[],u=h.traceIs(t,"contour"),f=h.traceIs(t,"histogram"),d=h.traceIs(t,"gl2d");if(Array.isArray(e)&&!f&&"category"!==a.type){e=e.map(a.d2c);var p=e.length;if(!(i>=p))return u?e.slice(0,i):e.slice(0,i+1);if(u||d)c=e.slice(0,i);else if(1===i)c=[e[0]-.5,e[0]+.5];else{for(c=[1.5*e[0]-.5*e[1]],l=1;p>l;l++)c.push(.5*(e[l-1]+e[l]));c.push(1.5*e[p-1]-.5*e[p-2])}if(i>p){var g=c[c.length-1],v=g-c[c.length-2];for(l=p;i>l;l++)g+=v,c.push(g)}}else for(s=n||1,o=void 0===r?0:f||"category"===a.type?r:a.d2c(r),l=u||d?0:-.5;i>l;l++)c.push(o+s*l);return c}function a(t){return.5-.25*Math.min(1,.5*t)}function o(t,e,r){var n,i,o=1;if(Array.isArray(r))for(n=0;nn&&o>y;n++)o=l(t,e,a(o));return o>y&&console.log("interp2d didn't converge quickly",o),t}function s(t){var e,r,n,i,a,o,s,l,c=[],u={},f=[],h=t[0],d=[],p=[0,0,0],g=m(t);for(r=0;rn;n++)void 0===d[n]&&(o=(void 0!==d[n-1]?1:0)+(void 0!==d[n+1]?1:0)+(void 0!==e[n]?1:0)+(void 0!==h[n]?1:0),o?(0===r&&o++,0===n&&o++,r===t.length-1&&o++,n===d.length-1&&o++,4>o&&(u[[r,n]]=[r,n,o]),c.push([r,n,o])):f.push([r,n]));for(;f.length;){for(s={},l=!1,a=f.length-1;a>=0;a--)i=f[a],r=i[0],n=i[1],o=((u[[r-1,n]]||p)[2]+(u[[r+1,n]]||p)[2]+(u[[r,n-1]]||p)[2]+(u[[r,n+1]]||p)[2])/20,o&&(s[i]=[r,n,o],f.splice(a,1),l=!0);if(!l)throw"findEmpties iterated with no new neighbors";for(i in s)u[i]=s[i],c.push(s[i])}return c.sort(function(t,e){return e[2]-t[2]})}function l(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g,v=0;for(o=0;os;s++)l=b[s],c=t[i+l[0]],c&&(u=c[a+l[1]],void 0!==u&&(0===h?p=g=u:(p=Math.min(p,u),g=Math.max(g,u)),f++,h+=u));if(0===f)throw"iterateInterp2d order is wrong: no defined neighbors";t[i][a]=h/f,void 0===d?4>f&&(v=1):(t[i][a]=(1+r)*t[i][a]-r*d,g>p&&(v=Math.max(v,Math.abs(t[i][a]-d)/(g-p))))}return v}var c=t("fast-isnumeric"),u=t("../../lib"),f=t("../../plots/cartesian/axes"),h=t("../../plots/plots"),d=t("../histogram2d/calc"),p=t("../../components/colorscale/calc"),g=t("./has_columns"),v=t("./convert_column_xyz"),m=t("./max_row_length");e.exports=function(t,e){function r(t){E=e._input.zsmooth=e.zsmooth=!1,u.notifier("cannot fast-zsmooth: "+t)}u.markTime("start convert x&y");var a,l,c,y,b,x,_,w,k=f.getFromId(t,e.xaxis||"x"),A=f.getFromId(t,e.yaxis||"y"),M=h.traceIs(e,"contour"),T=h.traceIs(e,"histogram"),E=M?"best":e.zsmooth;if(k._minDtick=0,A._minDtick=0,u.markTime("done convert x&y"),T){var L=d(t,e);a=L.x,l=L.x0,c=L.dx,y=L.y,b=L.y0,x=L.dy,_=L.z}else g(e)&&v(e,k,A),a=e.x?k.makeCalcdata(e,"x"):[],y=e.y?A.makeCalcdata(e,"y"):[],l=e.x0||0,c=e.dx||1,b=e.y0||0,x=e.dy||1,_=n(e),(M||e.connectgaps)&&(e._emptypoints=s(_),e._interpz=o(_,e._emptypoints,e._interpz));if("fast"===E)if("log"===k.type||"log"===A.type)r("log axis found");else if(!T){if(a.length){var S=(a[a.length-1]-a[0])/(a.length-1),C=Math.abs(S/100);for(w=0;wC){r("x scale is not linear");break}}if(y.length&&"fast"===E){var z=(y[y.length-1]-y[0])/(y.length-1),P=Math.abs(z/100);for(w=0;wP){r("y scale is not linear");break}}}var R=m(_),O="scaled"===e.xtype?"":e.x,I=i(e,O,l,c,R,k),N="scaled"===e.ytype?"":e.y,j=i(e,N,b,x,_.length,A);f.expand(k,I),f.expand(A,j);var F={x:I,y:j,z:_};if(p(e,_,"","z"),M&&e.contours&&"heatmap"===e.contours.coloring){var B="contour"===e.type?"heatmap":"histogram2d";F.xfill=i(B,O,l,c,R,k),F.yfill=i(B,N,b,x,_.length,A)}return[F]};var y=.01,b=[[-1,0],[1,0],[0,-1],[0,1]]},{"../../components/colorscale/calc":304,"../../lib":372,"../../plots/cartesian/axes":393,"../../plots/plots":441,"../histogram2d/calc":518,"./convert_column_xyz":500,"./has_columns":502,"./max_row_length":505,"fast-isnumeric":95}],499:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c="cb"+r.uid,u=s(r.colorscale),f=r.zmin,h=r.zmax;if(i(f)||(f=a.aggNums(Math.min,null,r.z)),i(h)||(h=a.aggNums(Math.max,null,r.z)),t._fullLayout._infolayer.selectAll("."+c).remove(),!r.showscale)return void o.autoMargin(t,c);var d=e[0].t.cb=l(t,c);d.fillcolor(n.scale.linear().domain(u.map(function(t){return f+t[0]*(h-f)})).range(u.map(function(t){return t[1]}))).filllevels({start:f,end:h,size:(h-f)/254}).options(r.colorbar)(),a.markTime("done colorbar")}},{"../../components/colorbar/draw":300,"../../components/colorscale/get_scale":308,"../../lib":372,"../../plots/plots":441,d3:87,"fast-isnumeric":95}],500:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a=t.x.slice(),o=t.y.slice(),s=t.z,l=t.text,c=Math.min(a.length,o.length,s.length),u=void 0!==l&&!Array.isArray(l[0]);for(ci;i++)a[i]=e.d2c(a[i]),o[i]=r.d2c(o[i]);var f,h,d,p=n.distinctVals(a),g=p.vals,v=n.distinctVals(o),m=v.vals,y=n.init2dArray(m.length,g.length);for(u&&(d=n.init2dArray(m.length,g.length)),i=0;c>i;i++)f=n.findBin(a[i]+p.minDiff/2,g),h=n.findBin(o[i]+v.minDiff/2,m),y[h][f]=s[i],u&&(d[h][f]=l[i]);t.x=g,t.y=m,t.z=y,u&&(t.text=d)}},{"../../lib":372}],501:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./has_columns"),a=t("./xyz_defaults"),o=t("../../components/colorscale/defaults"),s=t("./attributes");e.exports=function(t,e,r,l){function c(r,i){return n.coerce(t,e,s,r,i)}var u=a(t,e,c);return u?(c("text"),c("zsmooth"),c("connectgaps",i(e)&&e.zsmooth!==!1),void o(t,e,l,c,{prefix:"",cLetter:"z"})):void(e.visible=!1)}},{"../../components/colorscale/defaults":306,"../../lib":372,"./attributes":497,"./has_columns":502,"./xyz_defaults":508}],502:[function(t,e,r){"use strict";e.exports=function(t){return!Array.isArray(t.z[0])}},{}],503:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../lib");e.exports=function(t,e,r,a,o){if(!(t.distancec||c>=m[0].length||0>u||u>m.length)return}else{if(n.inbox(e-g[0],e-g[g.length-1])>n.MAXDIST||n.inbox(r-v[0],r-v[v.length-1])>n.MAXDIST)return;if(o){var w;for(b=[2*g[0]-g[1]],w=1;w0;)_=v.c2p(C[M]),M--;for(x>_&&(w=_,_=x,x=w,N=!0),M=0;void 0===k&&M0;)A=m.c2p(z[M]),M--;if(k>A&&(w=k,k=A,A=w,j=!0),P&&(C=r[0].xfill,z=r[0].yfill),"fast"!==R){var F="best"===R?0:.5;x=Math.max(-F*v._length,x),_=Math.min((1+F)*v._length,_),k=Math.max(-F*m._length,k),A=Math.min((1+F)*m._length,A)}var B=Math.round(_-x),D=Math.round(A-k);if(!(0>=B||0>=D)){var U,V;"fast"===R?(U=I,V=O):(U=B,V=D);var q=document.createElement("canvas");q.width=U,q.height=V;var H,G,Y=q.getContext("2d"),X=i.scale.linear().domain(S.map(function(t){return t[0]})).range(S.map(function(t){var e=a(t[1]).toRgb();return[e.r,e.g,e.b,e.a]})).clamp(!0);"fast"===R?(H=N?function(t){return I-1-t}:o.identity,G=j?function(t){return O-1-t}:o.identity):(H=function(t){return o.constrain(Math.round(v.c2p(C[t])-x),0,B)},G=function(t){return o.constrain(Math.round(m.c2p(z[t])-k),0,D)});var W,Z,K,Q,$,J,tt=G(0),et=[tt,tt],rt=N?0:1,nt=j?0:1,it=0,at=0,ot=0,st=0;if(o.markTime("done init png"),R){var lt=0,ct=new Uint8Array(B*D*4);if("best"===R){var ut,ft,ht,dt=new Array(C.length),pt=new Array(z.length),gt=new Array(B);for(M=0;MM;M++)gt[M]=n(M,dt);for(Z=0;D>Z;Z++)for(ut=n(Z,pt),ft=T[ut.bin0],ht=T[ut.bin1],M=0;B>M;M++,lt+=4)J=d(ft,ht,gt[M],ut),h(ct,lt,J)}else for(Z=0;O>Z;Z++)for($=T[Z],et=G(Z),M=0;I>M;M++)J=f($[M],1),lt=4*(et*B+H(M)),h(ct,lt,J);var vt=Y.createImageData(B,D);vt.data.set(ct),Y.putImageData(vt,0,0)}else for(Z=0;O>Z;Z++)if($=T[Z],et.reverse(),et[nt]=G(Z+1),et[0]!==et[1]&&void 0!==et[0]&&void 0!==et[1])for(K=H(0),W=[K,K],M=0;I>M;M++)W.reverse(),W[rt]=H(M+1),W[0]!==W[1]&&void 0!==W[0]&&void 0!==W[1]&&(Q=$[M],J=f(Q,(W[1]-W[0])*(et[1]-et[0])),Y.fillStyle="rgba("+J.join(",")+")",Y.fillRect(W[0],et[0],W[1]-W[0],et[1]-et[0]));o.markTime("done filling png"),at=Math.round(at/it),ot=Math.round(ot/it),st=Math.round(st/it);var mt=a("rgb("+at+","+ot+","+st+")");t._hmpixcount=(t._hmpixcount||0)+it,t._hmlumcount=(t._hmlumcount||0)+it*mt.getLuminance();var yt=e.plot.select(".imagelayer").selectAll("g.hm."+b).data([0]);yt.enter().append("g").classed("hm",!0).classed(b,!0),yt.exit().remove();var bt=yt.selectAll("image").data(r);bt.enter().append("svg:image"),bt.exit().remove(),bt.attr({xmlns:c.svg,"xlink:href":q.toDataURL("image/png"),height:D,width:B,x:x,y:k,preserveAspectRatio:"none"}),o.markTime("done showing png")}}var i=t("d3"),a=t("tinycolor2"),o=t("../../lib"),s=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),c=t("../../constants/xmlns_namespaces"),u=t("./max_row_length");e.exports=function(t,e,r){for(var i=0;i0&&(n=!0);for(var s=0;si;i++)e[i]?(t[i]/=e[i],n+=t[i]):t[i]=null;return n}},{}],511:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){return r("histnorm"),n.forEach(function(t){var e=r(t+"bins.start"),n=r(t+"bins.end"),i=r("autobin"+t,!(e&&n));r(i?"nbins"+t:t+"bins.size")}),e}},{}],512:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports={count:function(t,e,r){return r[t]++,1},sum:function(t,e,r,i){var a=i[e];return n(a)?(a=Number(a),r[t]+=a,a):0},avg:function(t,e,r,i,a){var o=i[e];return n(o)&&(o=Number(o),r[t]+=o,a[t]++),0},min:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]>a)return r[t]=a,a-r[t]}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]r&&c.length<5e3;)g=a.tickIncrement(r,b.size),c.push((r+g)/2),u.push(S),x&&_.push(r),E&&w.push(1/(g-r)),P&&k.push(0),r=g;var R=u.length;for(r=0;r=0&&R>m&&(A+=C(m,r,u,y,k));P&&(A=l(u,k)),z&&z(u,A,w);var O=Math.min(c.length,u.length),I=[],N=0,j=O-1;for(r=0;O>r;r++)if(u[r]){N=r;break}for(r=O-1;r>N;r--)if(u[r]){j=r;break}for(r=N;j>=r;r++)n(c[r])&&n(u[r])&&I.push({p:c[r],s:u[r],b:0});return I}}},{"../../lib":372,"../../plots/cartesian/axes":393,"./average":510,"./bin_functions":512,"./norm_functions":516,"fast-isnumeric":95}],514:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("./bin_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=u("x"),h=u("y");u("text");var d=u("orientation",h&&!f?"h":"v"),p=e["v"===d?"x":"y"];if(!p||!p.length)return void(e.visible=!1);var g=e["h"===d?"x":"y"];g&&u("histfunc");var v="h"===d?["y"]:["x"];a(t,e,u,v),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),s(t,e,i.defaultLine,{axis:"x",inherit:"y"})}},{"../../components/color":297,"../../components/errorbars/defaults":324,"../../lib":372,"../bar/style_defaults":471,"./attributes":509,"./bin_defaults":511}],515:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("../bar/layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("../bar/layout_defaults"),n.calc=t("./calc"),n.setPositions=t("../bar/set_positions"),n.plot=t("../bar/plot"),n.style=t("../bar/style"),n.colorbar=t("../scatter/colorbar"),n.hoverPoints=t("../bar/hover"),n.moduleType="trace",n.name="histogram",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","histogram","oriented","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":401,"../bar/hover":464,"../bar/layout_attributes":466,"../bar/layout_defaults":467,"../bar/plot":468,"../bar/set_positions":469,"../bar/style":470,"../scatter/colorbar":543,"./attributes":509,"./calc":513,"./defaults":514}],516:[function(t,e,r){"use strict";e.exports={percent:function(t,e){for(var r=t.length,n=100/e,i=0;r>i;i++)t[i]*=n},probability:function(t,e){for(var r=t.length,n=0;r>n;n++)t[n]/=e},density:function(t,e,r,n){var i=t.length;n=n||1;for(var a=0;i>a;a++)t[a]*=r[a]*n},"probability density":function(t,e,r,n){var i=t.length;n&&(e/=n);for(var a=0;i>a;a++)t[a]*=r[a]/e}}},{}],517:[function(t,e,r){"use strict";var n=t("../histogram/attributes"),i=t("../heatmap/attributes");e.exports={x:n.x,y:n.y,z:{valType:"data_array"},marker:{color:{valType:"data_array"}},histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zauto:i.zauto,zmin:i.zmin,zmax:i.zmax,colorscale:i.colorscale,autocolorscale:i.autocolorscale,reversescale:i.reversescale,showscale:i.showscale,zsmooth:i.zsmooth,_nestedModules:{colorbar:"Colorbar"}}},{"../heatmap/attributes":497,"../histogram/attributes":509}],518:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("../histogram/bin_functions"),o=t("../histogram/norm_functions"),s=t("../histogram/average");e.exports=function(t,e){var r,l,c,u,f,h,d=i.getFromId(t,e.xaxis||"x"),p=e.x?d.makeCalcdata(e,"x"):[],g=i.getFromId(t,e.yaxis||"y"),v=e.y?g.makeCalcdata(e,"y"):[],m=Math.min(p.length,v.length); -p.length>m&&p.splice(m,p.length-m),v.length>m&&v.splice(m,v.length-m),n.markTime("done convert data"),!e.autobinx&&"xbins"in e||(e.xbins=i.autoBin(p,d,e.nbinsx,"2d"),"histogram2dcontour"===e.type&&(e.xbins.start-=e.xbins.size,e.xbins.end+=e.xbins.size),e._input.xbins=e.xbins),!e.autobiny&&"ybins"in e||(e.ybins=i.autoBin(v,g,e.nbinsy,"2d"),"histogram2dcontour"===e.type&&(e.ybins.start-=e.ybins.size,e.ybins.end+=e.ybins.size),e._input.ybins=e.ybins),n.markTime("done autoBin"),f=[];var y,b,x=[],_=[],w="string"==typeof e.xbins.size?[]:e.xbins,k="string"==typeof e.xbins.size?[]:e.ybins,A=0,M=[],T=e.histnorm,E=e.histfunc,L=-1!==T.indexOf("density"),S="max"===E||"min"===E,C=S?null:0,z=a.count,P=o[T],R=!1,O=[],I=[],N="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";N&&"count"!==E&&(R="avg"===E,z=a[E]);var j=e.xbins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6;for(h=j.start;F>h;h=i.tickIncrement(h,j.size))x.push(C),Array.isArray(w)&&w.push(h),R&&_.push(0);Array.isArray(w)&&w.push(h);var B=x.length;for(r=e.xbins.start,l=(h-r)/B,r+=l/2,j=e.ybins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6,h=j.start;F>h;h=i.tickIncrement(h,j.size))f.push(x.concat()),Array.isArray(k)&&k.push(h),R&&M.push(_.concat());Array.isArray(k)&&k.push(h);var D=f.length;for(c=e.ybins.start,u=(h-c)/D,c+=u/2,L&&(O=x.map(function(t,e){return Array.isArray(w)?1/(w[e+1]-w[e]):1/l}),I=f.map(function(t,e){return Array.isArray(k)?1/(k[e+1]-k[e]):1/u})),n.markTime("done making bins"),h=0;m>h;h++)y=n.findBin(p[h],w),b=n.findBin(v[h],k),y>=0&&B>y&&b>=0&&D>b&&(A+=z(y,h,f[b],N,M[b]));if(R)for(b=0;D>b;b++)A+=s(f[b],M[b]);if(P)for(b=0;D>b;b++)P(f[b],A,O,I[b]);return n.markTime("done binning"),{x:p,x0:r,dx:l,y:v,y0:c,dy:u,z:f}}},{"../../lib":372,"../../plots/cartesian/axes":393,"../histogram/average":510,"../histogram/bin_functions":512,"../histogram/norm_functions":516}],519:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./sample_defaults"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r){function s(r,i){return n.coerce(t,e,o,r,i)}i(t,e,s),s("zsmooth"),a(t,e,r,s,{prefix:"",cLetter:"z"})}},{"../../components/colorscale/defaults":306,"../../lib":372,"./attributes":517,"./sample_defaults":521}],520:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../heatmap/calc"),n.plot=t("../heatmap/plot"),n.colorbar=t("../heatmap/colorbar"),n.style=t("../heatmap/style"),n.hoverPoints=t("../heatmap/hover"),n.moduleType="trace",n.name="histogram2d",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":401,"../heatmap/calc":498,"../heatmap/colorbar":499,"../heatmap/hover":503,"../heatmap/plot":506,"../heatmap/style":507,"./attributes":517,"./defaults":519}],521:[function(t,e,r){"use strict";var n=t("../histogram/bin_defaults");e.exports=function(t,e,r){var i=r("x"),a=r("y");if(!(i&&i.length&&a&&a.length))return void(e.visible=!1);var o=r("z")||r("marker.color");o&&r("histfunc");var s=["x","y"];n(t,e,r,s)}},{"../histogram/bin_defaults":511}],522:[function(t,e,r){"use strict";var n=t("../histogram2d/attributes"),i=t("../contour/attributes");e.exports={x:n.x,y:n.y,z:n.z,marker:n.marker,histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zauto:i.zauto,zmin:i.zmin,zmax:i.zmax,colorscale:i.colorscale,autocolorscale:i.autocolorscale,reversescale:i.reversescale,showscale:i.showscale,autocontour:i.autocontour,ncontours:i.ncontours,contours:i.contours,line:i.line,_nestedModules:{colorbar:"Colorbar"}}},{"../contour/attributes":487,"../histogram2d/attributes":517}],523:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../histogram2d/sample_defaults"),a=t("../contour/style_defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,i){return n.coerce(t,e,o,r,i)}i(t,e,l);var c=n.coerce2(t,e,o,"contours.start"),u=n.coerce2(t,e,o,"contours.end"),f=l("autocontour",!(c&&u));l(f?"ncontours":"contours.size"),a(t,e,l,s)}},{"../../lib":372,"../contour/style_defaults":496,"../histogram2d/sample_defaults":521,"./attributes":522}],524:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../contour/calc"),n.plot=t("../contour/plot"),n.style=t("../contour/style"),n.colorbar=t("../contour/colorbar"),n.hoverPoints=t("../contour/hover"),n.moduleType="trace",n.name="histogram2dcontour",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","contour","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":401,"../contour/calc":488,"../contour/colorbar":489,"../contour/hover":491,"../contour/plot":494,"../contour/style":495,"./attributes":522,"./defaults":523}],525:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../surface/attributes"),a=t("../../lib/extend").extendFlat;e.exports={x:{valType:"data_array"},y:{valType:"data_array"},z:{valType:"data_array"},i:{valType:"data_array"},j:{valType:"data_array"},k:{valType:"data_array"},delaunayaxis:{valType:"enumerated",values:["x","y","z"],dflt:"z"},alphahull:{valType:"number",dflt:-1},intensity:{valType:"data_array"},color:{valType:"color"},vertexcolor:{valType:"data_array"},facecolor:{valType:"data_array"},opacity:a({},i.opacity),flatshading:{valType:"boolean",dflt:!1},contour:{show:a({},i.contours.x.show,{}),color:a({},i.contours.x.color),width:a({},i.contours.x.width)},colorscale:n.colorscale,reversescale:n.reversescale,showscale:n.showscale,lighting:a({},i.lighting),_nestedModules:{colorbar:"Colorbar"}}},{"../../components/colorscale/attributes":303,"../../lib/extend":367,"../surface/attributes":585}],526:[function(t,e,r){"use strict";function n(t,e,r){this.scene=t,this.uid=r,this.mesh=e,this.name="",this.color="#fff",this.data=null,this.showContour=!1}function i(t){return t.map(function(t){var e=t[0],r=c(t[1]),n=r.toRgb();return{index:e,rgb:[n.r,n.g,n.b,1]}})}function a(t){return t.map(d)}function o(t,e,r){for(var n=new Array(t.length),i=0;i0)s=f(t.alphahull,l);else{var c=["x","y","z"].indexOf(t.delaunayaxis);s=u(l.map(function(t){return[t[(c+1)%3],t[(c+2)%3]]}))}var p={positions:l,cells:s,ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,opacity:t.opacity,contourEnable:t.contour.show,contourColor:d(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",p.vertexIntensity=t.intensity,p.colormap=i(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolors[0],p.vertexColors=a(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],p.cellColors=a(t.facecolor)):(this.color=t.color,p.meshColor=d(t.color)),this.mesh.update(p)},p.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=s},{"../../lib/str2rgbarray":383,"alpha-shape":26,"convex-hull":77,"delaunay-triangulate":88,"gl-mesh3d":142,tinycolor2:275}],527:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/colorbar/defaults"),a=t("./attributes");e.exports=function(t,e,r,o){function s(r,i){return n.coerce(t,e,a,r,i)}function l(t){var e=t.map(function(t){var e=s(t);return e&&Array.isArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var c=l(["x","y","z"]),u=l(["i","j","k"]);return c?(u&&u.forEach(function(t){for(var e=0;el||(c=p[r],void 0!==c&&""!==c||(c=r),c=String(c),void 0===y[c]&&(y[c]=!0,u=a(e.marker.colors[r]),u.isValid()?(u=o.addOpacity(u,u.getAlpha()),m[c]||(m[c]=u)):m[c]?u=m[c]:(u=!1,b=!0),f=-1!==_.indexOf(c),f||(x+=l),g.push({v:l,label:c,color:u,i:r,hidden:f}))));if(e.sort&&g.sort(function(t,e){return e.v-t.v}),b)for(r=0;r")}return g};var l},{"../../components/color":297,"./helpers":532,"fast-isnumeric":95,tinycolor2:275}],531:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(r,a){return n.coerce(t,e,i,r,a)}var s=n.coerceFont,l=o("values");if(!Array.isArray(l)||!l.length)return void(e.visible=!1);var c=o("labels");Array.isArray(c)||(o("label0"),o("dlabel"));var u=o("marker.line.width");u&&o("marker.line.color");var f=o("marker.colors");Array.isArray(f)||(e.marker.colors=[]),o("scalegroup");var h=o("text"),d=o("textinfo",Array.isArray(h)?"text+percent":"percent");if(o("hoverinfo",1===a._dataLength?"label+text+value+percent":void 0),d&&"none"!==d){var p=o("textposition"),g=Array.isArray(p)||"auto"===p,v=g||"inside"===p,m=g||"outside"===p;if(v||m){var y=s(o,"textfont",a.font);v&&s(o,"insidetextfont",y),m&&s(o,"outsidetextfont",y)}}o("domain.x"),o("domain.y"),o("hole"),o("sort"),o("direction"),o("rotation"),o("pull")}},{"../../lib":372,"./attributes":529}],532:[function(t,e,r){"use strict";r.formatPiePercent=function(t){var e=(100*t).toPrecision(3);return-1!==e.indexOf(".")?e.replace(/[.]?0+$/,"")+"%":e+"%"},r.formatPieValue=function(t){var e=t.toPrecision(10);return-1!==e.indexOf(".")?e.replace(/[.]?0+$/,""):e}},{}],533:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.layoutAttributes=t("./layout_attributes"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.styleOne=t("./style_one"),n.moduleType="trace",n.name="pie",n.basePlotModule=t("../../plots/cartesian"),n.categories=["pie","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":401,"./attributes":529,"./calc":530,"./defaults":531,"./layout_attributes":534,"./layout_defaults":535,"./plot":536,"./style":537,"./style_one":538}],534:[function(t,e,r){"use strict";e.exports={hiddenlabels:{valType:"data_array"}}},{}],535:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e){function r(r,a){return n.coerce(t,e,i,r,a)}r("hiddenlabels")}},{"../../lib":372,"./layout_attributes":534}],536:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,o=Math.PI*Math.min(e.v/r.vTotal,.5),s=1-r.trace.hole,l=i(e,r),c={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(c.scale>=1)return c;var u=a+1/(2*Math.tan(o)),f=r.r*Math.min(1/(Math.sqrt(u*u+.5)+u),s/(Math.sqrt(a*a+s/2)+a)),h={scale:2*f/t.height,rCenter:Math.cos(f/r.r)-f*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},d=1/a,p=d+1/(2*Math.tan(o)),g=r.r*Math.min(1/(Math.sqrt(p*p+.5)+p),s/(Math.sqrt(d*d+s/2)+d)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},m=v.scale>h.scale?v:h;return c.scale<1&&m.scale>c.scale?m:c}function i(t,e){if(t.v===e.vTotal&&!e.trace.hole)return 1;var r=Math.PI*Math.min(t.v/e.vTotal,.5);return Math.min(1/(1+1/Math.sin(r)),(1-e.trace.hole)/2)}function a(t,e){var r=e.pxmid[0],n=e.pxmid[1],i=t.width/2,a=t.height/2;return 0>r&&(i*=-1),0>n&&(a*=-1),{scale:1,rCenter:1,rotate:0,x:i+Math.abs(a)*(i>0?1:-1)/2,y:a/(1+r*r/(n*n)),outside:!0}}function o(t,e){function r(t,e){return t.pxmid[1]-e.pxmid[1]}function n(t,e){return e.pxmid[1]-t.pxmid[1]}function i(t,r){r||(r={});var n,i,a,s,h,d,g=r.labelExtraY+(o?r.yLabelMax:r.yLabelMin),v=o?t.yLabelMin:t.yLabelMax,m=o?t.yLabelMax:t.yLabelMin,y=t.cyFinal+c(t.px0[1],t.px1[1]),b=g-v;if(b*f>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(i=0;i=e.pull[a.i]||((t.pxmid[1]-a.pxmid[1])*f>0?(s=a.cyFinal+c(a.px0[1],a.px1[1]),b=s-v-t.labelExtraY,b*f>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-y)*f>0&&(n=3*u*Math.abs(i-p.indexOf(t)),h=a.cxFinal+l(a.px0[0],a.px1[0]),d=h+n-(t.cxFinal+t.pxmid[0])-t.labelExtraX,d*u>0&&(t.labelExtraX+=d)))}var a,o,s,l,c,u,f,h,d,p,g,v,m;for(o=0;2>o;o++)for(s=o?r:n,c=o?Math.max:Math.min,f=o?1:-1,a=0;2>a;a++){for(l=a?Math.max:Math.min,u=a?1:-1,h=t[o][a],h.sort(s),d=t[1-o][a],p=d.concat(h),v=[],g=0;gu&&(u=s.pull[a]);o.r=Math.min(r/c(s.tilt,Math.sin(l),s.depth),n/c(s.tilt,Math.cos(l),s.depth))/(2+2*u),o.cx=e.l+e.w*(s.domain.x[1]+s.domain.x[0])/2,o.cy=e.t+e.h*(2-s.domain.y[1]-s.domain.y[0])/2,s.scalegroup&&-1===d.indexOf(s.scalegroup)&&d.push(s.scalegroup)}for(a=0;af.vTotal/2?1:0)}function c(t,e,r){if(!t)return 1;var n=Math.sin(t*Math.PI/180);return Math.max(.01,r*n*Math.abs(e)+2*Math.sqrt(1-n*n*e*e))}var u=t("d3"),f=t("../../plots/cartesian/graph_interact"),h=t("../../components/color"),d=t("../../components/drawing"),p=t("../../lib/svg_text_utils"),g=t("./helpers");e.exports=function(t,e){var r=t._fullLayout;s(e,r._size);var c=r._pielayer.selectAll("g.trace").data(e);c.enter().append("g").attr({"stroke-linejoin":"round","class":"trace"}),c.exit().remove(),c.order(),c.each(function(e){var s=u.select(this),c=e[0],v=c.trace,m=0,y=(v.depth||0)*c.r*Math.sin(m)/2,b=v.tiltaxis||0,x=b*Math.PI/180,_=[y*Math.sin(x),y*Math.cos(x)],w=c.r*Math.cos(m),k=s.selectAll("g.part").data(v.tilt?["top","sides"]:["top"]);k.enter().append("g").attr("class",function(t){return t+" part"}),k.exit().remove(),k.order(),l(e),s.selectAll(".top").each(function(){var s=u.select(this).selectAll("g.slice").data(e);s.enter().append("g").classed("slice",!0),s.exit().remove();var l=[[[],[]],[[],[]]],m=!1;s.each(function(o){function s(e){var r=t._fullLayout,n=t._fullData[v.index],a=n.hoverinfo;if("all"===a&&(a="label+text+value+percent+name"),!t._dragging&&r.hovermode!==!1&&"none"!==a&&a){var s=i(o,c),l=k+o.pxmid[0]*(1-s),u=A+o.pxmid[1]*(1-s),h=[];-1!==a.indexOf("label")&&h.push(o.label),n.text&&n.text[o.i]&&-1!==a.indexOf("text")&&h.push(n.text[o.i]),-1!==a.indexOf("value")&&h.push(g.formatPieValue(o.v)),-1!==a.indexOf("percent")&&h.push(g.formatPiePercent(o.v/c.vTotal)),f.loneHover({x0:l-s*c.r,x1:l+s*c.r,y:u,text:h.join("
"),name:-1!==a.indexOf("name")?n.name:void 0,color:o.color,idealAlign:o.pxmid[0]<0?"left":"right"},{container:r._hoverlayer.node(),outerContainer:r._paper.node()}),f.hover(t,e,"pie"),E=!0}}function h(e){t.emit("plotly_unhover",{points:[e]}),E&&(f.loneUnhover(r._hoverlayer.node()),E=!1)}function y(){t._hoverdata=[o],t._hoverdata.trace=e.trace,f.click(t,{target:!0})}function x(t,e,r,n){return"a"+n*c.r+","+n*w+" "+b+" "+o.largeArc+(r?" 1 ":" 0 ")+n*(e[0]-t[0])+","+n*(e[1]-t[1])}if(o.hidden)return void u.select(this).selectAll("path,g").remove();l[o.pxmid[1]<0?0:1][o.pxmid[0]<0?0:1].push(o);var k=c.cx+_[0],A=c.cy+_[1],M=u.select(this),T=M.selectAll("path.surface").data([o]),E=!1;if(T.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),M.select("path.textline").remove(),M.on("mouseover",s).on("mouseout",h).on("click",y),v.pull){var L=+(Array.isArray(v.pull)?v.pull[o.i]:v.pull)||0;L>0&&(k+=L*o.pxmid[0],A+=L*o.pxmid[1])}o.cxFinal=k,o.cyFinal=A;var S=v.hole;if(o.v===c.vTotal){var C="M"+(k+o.px0[0])+","+(A+o.px0[1])+x(o.px0,o.pxmid,!0,1)+x(o.pxmid,o.px0,!0,1)+"Z";S?T.attr("d","M"+(k+S*o.px0[0])+","+(A+S*o.px0[1])+x(o.px0,o.pxmid,!1,S)+x(o.pxmid,o.px0,!1,S)+"Z"+C):T.attr("d",C)}else{var z=x(o.px0,o.px1,!0,1);if(S){var P=1-S;T.attr("d","M"+(k+S*o.px1[0])+","+(A+S*o.px1[1])+x(o.px1,o.px0,!1,S)+"l"+P*o.px0[0]+","+P*o.px0[1]+z+"Z")}else T.attr("d","M"+k+","+A+"l"+o.px0[0]+","+o.px0[1]+z+"Z")}var R=Array.isArray(v.textposition)?v.textposition[o.i]:v.textposition,O=M.selectAll("g.slicetext").data(o.text&&"none"!==R?[0]:[]);O.enter().append("g").classed("slicetext",!0),O.exit().remove(),O.each(function(){var t=u.select(this).selectAll("text").data([0]);t.enter().append("text").attr("data-notex",1),t.exit().remove(),t.text(o.text).attr({"class":"slicetext",transform:"","data-bb":"","text-anchor":"middle",x:0,y:0}).call(d.font,"outside"===R?v.outsidetextfont:v.insidetextfont).call(p.convertToTspans),t.selectAll("tspan.line").attr({x:0,y:0});var e,r=d.bBox(t.node());"outside"===R?e=a(r,o):(e=n(r,o,c),"auto"===R&&e.scale<1&&(t.call(d.font,v.outsidetextfont),v.outsidetextfont.family===v.insidetextfont.family&&v.outsidetextfont.size===v.insidetextfont.size||(t.attr({"data-bb":""}),r=d.bBox(t.node())),e=a(r,o)));var i=k+o.pxmid[0]*e.rCenter+(e.x||0),s=A+o.pxmid[1]*e.rCenter+(e.y||0);e.outside&&(o.yLabelMin=s-r.height/2,o.yLabelMid=s,o.yLabelMax=s+r.height/2,o.labelExtraX=0,o.labelExtraY=0,m=!0),t.attr("transform","translate("+i+","+s+")"+(e.scale<1?"scale("+e.scale+")":"")+(e.rotate?"rotate("+e.rotate+")":"")+"translate("+-(r.left+r.right)/2+","+-(r.top+r.bottom)/2+")")})}),m&&o(l,v),s.each(function(t){if(t.labelExtraX||t.labelExtraY){var e=u.select(this),r=e.select("g.slicetext text");r.attr("transform","translate("+t.labelExtraX+","+t.labelExtraY+")"+r.attr("transform"));var n=t.cxFinal+t.pxmid[0],i=t.cyFinal+t.pxmid[1],a="M"+n+","+i,o=(t.yLabelMax-t.yLabelMin)*(t.pxmid[0]<0?-1:1)/4;if(t.labelExtraX){var s=t.labelExtraX*t.pxmid[1]/t.pxmid[0],l=t.yLabelMid+t.labelExtraY-(t.cyFinal+t.pxmid[1]);a+=Math.abs(s)>Math.abs(l)?"l"+l*t.pxmid[0]/t.pxmid[1]+","+l+"H"+(n+t.labelExtraX+o):"l"+t.labelExtraX+","+s+"v"+(l-s)+"h"+o}else a+="V"+(t.yLabelMid+t.labelExtraY)+"h"+o;e.append("path").classed("textline",!0).call(h.stroke,v.outsidetextfont.color).attr({"stroke-width":Math.min(2,v.outsidetextfont.size/8),d:a,fill:"none"})}})})}),setTimeout(function(){c.selectAll("tspan").each(function(){var t=u.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":297,"../../components/drawing":319,"../../lib/svg_text_utils":384,"../../plots/cartesian/graph_interact":400,"./helpers":532,d3:87}],537:[function(t,e,r){"use strict";var n=t("d3"),i=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0],r=e.trace,a=n.select(this);a.style({opacity:r.opacity}),a.selectAll(".top path.surface").each(function(t){n.select(this).call(i,t,r)})})}},{"./style_one":538,d3:87}],538:[function(t,e,r){"use strict";var n=t("../../components/color");e.exports=function(t,e,r){var i=r.marker.line.color;Array.isArray(i)&&(i=i[e.i]||n.defaultLine);var a=r.marker.line.width||0;Array.isArray(a)&&(a=a[e.i]||0),t.style({"stroke-width":a,fill:e.color}).call(n.stroke,i)}},{"../../components/color":297}],539:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t){var e=t[0].trace,r=e.marker;if(n.mergeArray(e.text,t,"tx"),n.mergeArray(e.textposition,t,"tp"),e.textfont&&(n.mergeArray(e.textfont.size,t,"ts"),n.mergeArray(e.textfont.color,t,"tc"),n.mergeArray(e.textfont.family,t,"tf")),r&&r.line){var i=r.line;n.mergeArray(r.opacity,t,"mo"),n.mergeArray(r.symbol,t,"mx"),n.mergeArray(r.color,t,"mc"),n.mergeArray(i.color,t,"mlc"),n.mergeArray(i.width,t,"mlw")}}},{"../../lib":372}],540:[function(t,e,r){"use strict";var n=t("../../components/drawing");t("./constants");e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number",min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:{symbol:{valType:"enumerated",values:n.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},color:{valType:"color",arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number",dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},colorscale:{valType:"colorscale"},cauto:{valType:"boolean",dflt:!0},cmax:{valType:"number",dflt:null},cmin:{valType:"number",dflt:null},autocolorscale:{valType:"boolean",dflt:!0},reversescale:{valType:"boolean",dflt:!1},showscale:{valType:"boolean",dflt:!1},line:{color:{valType:"color",arrayOk:!0},width:{valType:"number",min:0,arrayOk:!0},colorscale:{valType:"colorscale"},cauto:{valType:"boolean",dflt:!0},cmax:{valType:"number",dflt:null},cmin:{valType:"number",dflt:null},autocolorscale:{valType:"boolean",dflt:!0},reversescale:{valType:"boolean",dflt:!1}}},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:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/drawing":319,"./constants":544}],541:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./subtypes"),s=t("./marker_colorscale_calc");e.exports=function(t,e){var r=i.getFromId(t,e.xaxis||"x"),l=i.getFromId(t,e.yaxis||"y");a.markTime("in Scatter.calc");var c=r.makeCalcdata(e,"x");a.markTime("finished convert x");var u=l.makeCalcdata(e,"y");a.markTime("finished convert y");var f,h,d,p=Math.min(c.length,u.length);r._minDtick=0,l._minDtick=0,c.length>p&&c.splice(p,c.length-p),u.length>p&&u.splice(p,u.length-p);var g={padded:!0},v={padded:!0};if(o.hasMarkers(e)){if(f=e.marker,h=f.size,Array.isArray(h)){var m={type:"linear"};i.setConvert(m),h=m.makeCalcdata(e.marker,"size"),h.length>p&&h.splice(p,h.length-p)}var y,b=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/b),3)}:function(t){return Math.max((t||0)/b,3)},g.ppad=v.ppad=Array.isArray(h)?h.map(y):y(h)}s(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||c[0]===c[p-1]&&u[0]===u[p-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(o.hasMarkers(e)||o.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||c[0]===c[p-1]&&u[0]===u[p-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(v.padded=!1):v.tozero=!0,a.markTime("ready for Axes.expand"),i.expand(r,c,g),a.markTime("done expand x"),i.expand(l,u,v),a.markTime("done expand y");var x=new Array(p);for(d=0;p>d;d++)x[d]=n(c[d])&&n(u[d])?{x:c[d],y:u[d]}:{x:!1,y:!1};return void 0!==typeof h&&a.mergeArray(h,x,"ms"),t.firstscatter=!1,x}},{"../../lib":372,"../../plots/cartesian/axes":393,"./marker_colorscale_calc":554,"./subtypes":559,"fast-isnumeric":95}],542:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i,a;for(e=0;e=0;i--)if(a=t[i],"scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}},{}],543:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c=r.marker,u="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void o.autoMargin(t,u);var f=s(c.colorscale),h=c.color,d=c.cmin,p=c.cmax;i(d)||(d=a.aggNums(Math.min,null,h)),i(p)||(p=a.aggNums(Math.max,null,h));var g=e[0].t.cb=l(t,u);g.fillcolor(n.scale.linear().domain(f.map(function(t){return d+t[0]*(p-d)})).range(f.map(function(t){return t[1]}))).filllevels({start:d,end:p,size:(p-d)/254}).options(c.colorbar)(),a.markTime("done colorbar")}},{"../../components/colorbar/draw":300,"../../components/colorscale/get_scale":308,"../../lib":372,"../../plots/plots":441,d3:87,"fast-isnumeric":95}],544:[function(t,e,r){"use strict";e.exports={PTS_LINESONLY:20}},{}],545:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("./constants"),o=t("./subtypes"),s=t("./xy_defaults"),l=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),h=t("./fillcolor_defaults"),d=t("../../components/errorbars/defaults");e.exports=function(t,e,r,p){function g(r,a){return n.coerce(t,e,i,r,a)}var v=s(t,e,g),m=vi(f))break;l=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,c=f,d=!1):m>y&&(m=y,u=f,d=!0)}if(d?(C[z++]=c,l!==u&&(C[z++]=u)):(u!==s&&(C[z++]=u),l!==c&&(C[z++]=c)),C[z++]=l,o>=t.length||!f)break;C[z++]=f,s=f}}else C[z++]=c}E.push(C.slice(0,z))}return E}},{"../../plots/cartesian/axes":393}],552:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=r("line.shape");"spline"===n&&r("line.smoothing")}},{}],553:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t){var e=t.marker,r=e.sizeref||1,i=e.sizemin||0,a="area"===e.sizemode?function(t){return Math.sqrt(t/r)}:function(t){return t/r};return function(t){var e=a(t/2);return n(e)&&e>0?Math.max(e,i):0}}},{"fast-isnumeric":95}],554:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("./subtypes");e.exports=function(t){if(a.hasMarkers(t)){var e=t.marker;n(t,"marker")&&i(t,e.color,"marker","c"),n(t,"marker.line")&&i(t,e.line.color,"marker.line","c")}}},{"../../components/colorscale/calc":304,"../../components/colorscale/has_colorscale":309,"./subtypes":559}],555:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l){var c,u=o.isBubble(t),f=(t.line||{}).color;f&&(r=f),l("marker.symbol"),l("marker.opacity",u?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),c=f&&e.marker.color!==f?f:u?n.background:n.defaultLine,l("marker.line.color",c),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",u?1:0),u&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode"))}},{"../../components/color":297,"../../components/colorscale/defaults":306,"../../components/colorscale/has_colorscale":309,"./subtypes":559}],556:[function(t,e,r){"use strict";function n(t,e,r){var n=e.x(),a=e.y(),o=i.extent(n.range.map(n.l2c)),s=i.extent(a.range.map(a.l2c));r.forEach(function(t,e){var n=t[0].trace;if(l.hasMarkers(n)){var i=n.marker.maxdisplayed;if(0!==i){var a=t.filter(function(t){return t.x>=o[0]&&t.x<=o[1]&&t.y>=s[0]&&t.y<=s[1]}),c=Math.ceil(a.length/i),u=0;r.forEach(function(t,r){var n=t[0].trace;l.hasMarkers(n)&&n.marker.maxdisplayed>0&&e>r&&u++});var f=Math.round(u*c/3+Math.floor(u/3)*c/7.1);t.forEach(function(t){delete t.vis}),a.forEach(function(t,e){0===Math.round((e+f)%c)&&(t.vis=!0)})}}})}var i=t("d3"),a=t("../../lib"),o=t("../../components/drawing"),s=t("../../components/errorbars"),l=t("./subtypes"),c=t("./arrays_to_calcdata"),u=t("./line_points");e.exports=function(t,e,r){function f(t){return t.filter(function(t){return t.vis})}n(t,e,r);var h=e.x(),d=e.y(),p=e.plot.select(".scatterlayer").selectAll("g.trace.scatter").data(r);p.enter().append("g").attr("class","trace scatter").style("stroke-miterlimit",2),p.call(s.plot,e);var g,v,m,y,b="";p.each(function(t){var e=t[0].trace,r=e.line,n=i.select(this);if(e.visible===!0&&(v=e.fill.charAt(e.fill.length-1),"x"!==v&&"y"!==v&&(v=""),t[0].node3=n,c(t),l.hasLines(e)||"none"!==e.fill)){var a,s,f,p,x,_="",w="";g="tozero"===e.fill.substr(0,6)||"toself"===e.fill||"to"===e.fill.substr(0,2)&&!b?n.append("path").classed("js-fill",!0):null,y&&(m=y.datum(t)),y=n.append("path").classed("js-fill",!0),-1!==["hv","vh","hvh","vhv"].indexOf(r.shape)?(f=o.steps(r.shape),p=o.steps(r.shape.split("").reverse().join(""))):f=p="spline"===r.shape?function(t){var e=t[t.length-1];return t[0][0]===e[0]&&t[0][1]===e[1]?o.smoothclosed(t.slice(1),r.smoothing):o.smoothopen(t,r.smoothing)}:function(t){return"M"+t.join("L")},x=function(t){return p(t.reverse())};var k=u(t,{xaxis:h,yaxis:d,connectGaps:e.connectgaps,baseTolerance:Math.max(r.width||1,3)/4,linear:"linear"===r.shape});if(k.length){for(var A=k[0][0],M=k[k.length-1],T=M[M.length-1],E=0;E1&&n.append("path").classed("js-line",!0).attr("d",a)}g?A&&T&&(v?("y"===v?A[1]=T[1]=d.c2p(0,!0):"x"===v&&(A[0]=T[0]=h.c2p(0,!0)),g.attr("d",_+"L"+T+"L"+A+"Z")):g.attr("d",_+"Z")):"tonext"===e.fill.substr(0,6)&&_&&b&&("tonext"===e.fill?m.attr("d",_+"Z"+b+"Z"):m.attr("d",_+"L"+b.substr(1)+"Z")),b=w}}}),p.selectAll("path:not([d])").remove(),p.append("g").attr("class","points").each(function(t){var e=t[0].trace,r=i.select(this),n=l.hasMarkers(e),s=l.hasText(e);!n&&!s||e.visible!==!0?r.remove():(n&&r.selectAll("path.point").data(e.marker.maxdisplayed?f:a.identity).enter().append("path").classed("point",!0).call(o.translatePoints,h,d),s&&r.selectAll("g").data(e.marker.maxdisplayed?f:a.identity).enter().append("g").append("text").call(o.translatePoints,h,d))})}},{"../../components/drawing":319,"../../components/errorbars":325,"../../lib":372,"./arrays_to_calcdata":539,"./line_points":551,"./subtypes":559,d3:87}],557:[function(t,e,r){"use strict";var n=t("./subtypes"),i=.2;e.exports=function(t,e){var r,a,o,s,l=t.cd,c=t.xaxis,u=t.yaxis,f=[],h=l[0].trace,d=h.index,p=h.marker;if(n.hasMarkers(h)||n.hasText(h)){var g=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(r=0;rs;s++){for(var l=[[0,0,0],[0,0,0]],c=0;3>c;c++)if(r[c])for(var u=0;2>u;u++)l[u][c]=r[c][s][u];o[s]=l}return o}var o=t("../../components/errorbars/compute_error");e.exports=a},{"../../components/errorbars/compute_error":323}],565:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.linePlot=null,this.scatterPlot=null,this.errorBars=null,this.textMarkers=null,this.delaunayMesh=null,this.color=null,this.mode="",this.dataPoints=[],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.textLabels=null,this.data=null}function i(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],s=[];for(n=0;ni;i++){var a=t[i];a&&a.copy_zstyle!==!1&&(a=t[2]),a&&(e[i]=a.width/2,r[i]=b(a.color),n=a.thickness)}return{capSize:e,color:r,lineWidth:n}}function o(t){var e=[0,0];return Array.isArray(t)?[0,-1]:(t.indexOf("bottom")>=0&&(e[1]+=1),t.indexOf("top")>=0&&(e[1]-=1),t.indexOf("left")>=0&&(e[0]-=1),t.indexOf("right")>=0&&(e[0]+=1),e)}function s(t,e){return e(4*t)}function l(t){return k[t]}function c(t,e,r,n,i){var a=null;if(Array.isArray(t)){a=[];for(var o=0;e>o;o++)void 0===t[o]?a[o]=n:a[o]=r(t[o],i)}else a=r(t,y.identity);return a}function u(t,e){var r,n,i,u,f,h,d=[],p=t.fullSceneLayout,g=t.dataScale,v=p.xaxis,m=p.yaxis,w=p.zaxis,k=e.marker,M=e.line,T=e.x||[],E=e.y||[],L=e.z||[],S=T.length;for(n=0;S>n;n++)i=v.d2l(T[n])*g[0],u=m.d2l(E[n])*g[1],f=w.d2l(L[n])*g[2],d[n]=[i,u,f];if(Array.isArray(e.text))h=e.text;else if(void 0!==e.text)for(h=new Array(S),n=0;S>n;n++)h[n]=e.text;if(r={position:d,mode:e.mode,text:h},"line"in e&&(r.lineColor=b(M.color),r.lineWidth=M.width,r.lineDashes=M.dash),"marker"in e){var C=_(e);r.scatterColor=x(k,1,S),r.scatterSize=c(k.size,S,s,20,C),r.scatterMarker=c(k.symbol,S,l,"\u25cf"),r.scatterLineWidth=k.line.width,r.scatterLineColor=x(k.line,1,S),r.scatterAngle=0}"textposition"in e&&(r.textOffset=o(e.textposition),r.textColor=x(e.textfont,1,S),r.textSize=c(e.textfont.size,S,y.identity,12),r.textFont=e.textfont.family,r.textAngle=0);var z=["x","y","z"];for(r.project=[!1,!1,!1],r.projectScale=[1,1,1],r.projectOpacity=[1,1,1],n=0;3>n;++n){var P=e.projection[z[n]];(r.project[n]=P.show)&&(r.projectOpacity[n]=P.opacity,r.projectScale[n]=P.scale)}r.errorBounds=A(e,g);var R=a([e.error_x,e.error_y,e.error_z]);return r.errorColor=R.color,r.errorLineWidth=R.lineWidth,r.errorCapSize=R.capSize,r.delaunayAxis=e.surfaceaxis,r.delaunayColor=b(e.surfacecolor),r}function f(t){if(Array.isArray(t)){var e=t[0];return Array.isArray(e)&&(t=e),"rgb("+t.slice(0,3).map(function(t){return Math.round(255*t)})+")"}return null}function h(t,e){var r=new n(t,e.uid);return r.update(e),r}var d=t("gl-line3d"),p=t("gl-scatter3d"),g=t("gl-error3d"),v=t("gl-mesh3d"),m=t("delaunay-triangulate"),y=t("../../lib"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/make_bubble_size_func"),w=t("../../constants/gl3d_dashes"),k=t("../../constants/gl_markers"),A=t("./calc_errors"),M=n.prototype;M.handlePick=function(t){if(t.object&&(t.object===this.linePlot||t.object===this.delaunayMesh||t.object===this.textMarkers||t.object===this.scatterPlot)){t.object.highlight&&t.object.highlight(null),this.scatterPlot&&(t.object=this.scatterPlot,this.scatterPlot.highlight(t.data)),this.textLabels&&void 0!==this.textLabels[t.data.index]?t.textLabel=this.textLabels[t.data.index]:t.textLabel="";var e=t.data.index;return t.traceCoordinate=[this.data.x[e],this.data.y[e],this.data.z[e]],!0}},M.update=function(t){var e,r,n,a,o=this.scene.glplot.gl,s=w.solid;this.data=t;var l=u(this.scene,t);"mode"in l&&(this.mode=l.mode),"lineDashes"in l&&l.lineDashes in w&&(s=w[l.lineDashes]),this.color=f(l.scatterColor)||f(l.lineColor),this.dataPoints=l.position,e={gl:o,position:l.position,color:l.lineColor,lineWidth:l.lineWidth||1,dashes:s[0],dashScale:s[1],opacity:t.opacity,connectGaps:t.connectgaps},-1!==this.mode.indexOf("lines")?this.linePlot?this.linePlot.update(e):(this.linePlot=d(e),this.scene.glplot.add(this.linePlot)):this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose(),this.linePlot=null);var c=t.opacity;if(t.marker&&t.marker.opacity&&(c*=t.marker.opacity),r={gl:o,position:l.position,color:l.scatterColor,size:l.scatterSize,glyph:l.scatterMarker,opacity:c,orthographic:!0,lineWidth:l.scatterLineWidth,lineColor:l.scatterLineColor,project:l.project,projectScale:l.projectScale,projectOpacity:l.projectOpacity},-1!==this.mode.indexOf("markers")?this.scatterPlot?this.scatterPlot.update(r):(this.scatterPlot=p(r),this.scatterPlot.highlightScale=1,this.scene.glplot.add(this.scatterPlot)):this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose(),this.scatterPlot=null),a={gl:o,position:l.position,glyph:l.text,color:l.textColor,size:l.textSize,angle:l.textAngle,alignment:l.textOffset,font:l.textFont,orthographic:!0,lineWidth:0,project:!1,opacity:t.opacity},this.textLabels=l.text,-1!==this.mode.indexOf("text")?this.textMarkers?this.textMarkers.update(a):(this.textMarkers=p(a),this.textMarkers.highlightScale=1,this.scene.glplot.add(this.textMarkers)):this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose(),this.textMarkers=null),n={gl:o,position:l.position,color:l.errorColor,error:l.errorBounds,lineWidth:l.errorLineWidth,capSize:l.errorCapSize,opacity:t.opacity},this.errorBars?l.errorBounds?this.errorBars.update(n):(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose(),this.errorBars=null):l.errorBounds&&(this.errorBars=g(n),this.scene.glplot.add(this.errorBars)),l.delaunayAxis>=0){var h=i(l.position,l.delaunayColor,l.delaunayAxis);h.opacity=t.opacity,this.delaunayMesh?this.delaunayMesh.update(h):(h.gl=o,this.delaunayMesh=v(h),this.scene.glplot.add(this.delaunayMesh))}else this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose(),this.delaunayMesh=null)},M.dispose=function(){this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose()),this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose()),this.errorBars&&(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose()),this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose()),this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose())},e.exports=h},{"../../constants/gl3d_dashes":358,"../../constants/gl_markers":359,"../../lib":372,"../../lib/gl_format_color":370,"../../lib/str2rgbarray":383,"../scatter/make_bubble_size_func":553,"./calc_errors":564,"delaunay-triangulate":88,"gl-error3d":112,"gl-line3d":119,"gl-mesh3d":142,"gl-scatter3d":162}],566:[function(t,e,r){"use strict";function n(t,e,r){var n=0,i=r("x"),a=r("y"),o=r("z");return i&&a&&o&&(n=Math.min(i.length,a.length,o.length),n=0&&h("surfacecolor",p||g);for(var v=["x","y","z"],m=0;3>m;++m){var y="projection."+v[m];h(y+".show")&&(h(y+".opacity"),h(y+".scale"))}c(t,e,r,{axis:"z"}),c(t,e,r,{axis:"y",inherit:"z"}),c(t,e,r,{axis:"x",inherit:"z"})}},{"../../components/errorbars/defaults":324,"../../lib":372,"../scatter/line_defaults":550,"../scatter/marker_defaults":555,"../scatter/subtypes":559,"../scatter/text_defaults":560,"./attributes":562}],567:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../constants/gl_markers":359,"../../plots/gl3d":428,"../scatter/colorbar":543,"./attributes":562,"./calc":563,"./convert":565,"./defaults":566}],568:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=n.line,l=o.line;e.exports={lon:{valType:"data_array"},lat:{valType:"data_array"},locations:{valType:"data_array"},locationmode:{valType:"enumerated",values:["ISO-3","USA-states","country names"],dflt:"ISO-3"},mode:a({},n.mode,{dflt:"markers"}),text:a({},n.text,{}),line:{color:s.color,width:s.width,dash:s.dash},marker:{symbol:o.symbol,opacity:o.opacity,size:o.size,sizeref:o.sizeref,sizemin:o.sizemin,sizemode:o.sizemode,color:o.color,colorscale:o.colorscale,cauto:o.cauto,cmax:o.cmax,cmin:o.cmin,autocolorscale:o.autocolorscale,reversescale:o.reversescale,showscale:o.showscale,line:{color:l.color,width:l.width,colorscale:l.colorscale,cauto:l.cauto,cmax:l.cmax,cmin:l.cmin,autocolorscale:l.autocolorscale,reversescale:l.reversescale}},textfont:n.textfont,textposition:n.textposition,hoverinfo:a({},i.hoverinfo,{flags:["lon","lat","location","text","name"]}),_nestedModules:{"marker.colorbar":"Colorbar"}}},{"../../lib/extend":367,"../../plots/attributes":391,"../scatter/attributes":540}],569:[function(t,e,r){"use strict";var n=t("../scatter/marker_colorscale_calc");e.exports=function(t,e){var r=[{x:!1,y:!1,trace:e,t:{}}];return n(e),r}},{"../scatter/marker_colorscale_calc":554}],570:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=0,o=r("locations");return o?(r("locationmode"),a=o.length):(n=r("lon")||[],i=r("lat")||[],a=Math.min(n.length,i.length),an;n++)r[n]=[t.lon[n],t.lat[n]];return{type:"LineString",coordinates:r,trace:t}}function a(t,e){function r(e){var r=t.mockAxis;return c.tickText(r,r.c2l(e),"hover").text+"\xb0"}var n=e.hoverinfo;if("none"===n)return function(t){delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("location")&&Array.isArray(e.locations),o=-1!==i.indexOf("lon"),s=-1!==i.indexOf("lat"),l=-1!==i.indexOf("text");return function(t){var n=[];a?n.push(t.location):o&&s?n.push("("+r(t.lon)+", "+r(t.lat)+")"):o?n.push("lon: "+r(t.lon)):s&&n.push("lat: "+r(t.lat)),l&&n.push(t.tx||e.text),t.textLabel=n.join("
")}}function o(t){var e=Array.isArray(t.locations);return function(r,n){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:n,lon:r.lon,lat:r.lat,location:e?r.location:null}]}}}var s=t("d3"),l=t("../../plots/cartesian/graph_interact"),c=t("../../plots/cartesian/axes"),u=t("../../lib/topojson_utils").getTopojsonFeatures,f=t("../../lib/geo_location_utils").locationToFeature,h=t("../../lib/array_to_calc_item"),d=t("../../components/color"),p=t("../../components/drawing"),g=t("../scatter/subtypes"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){var r,i,a,o,s=[],l=Array.isArray(t.locations);l?(o=t.locations,r=o.length,i=u(t,e),a=function(t,e){var r=f(t.locationmode,o[e],i);return void 0!==r?r.properties.ct:void 0}):(r=t.lon.length,a=function(t,e){return[t.lon[e],t.lat[e]]});for(var c=0;r>c;c++){var h=a(t,c);if(h){var d={lon:h[0],lat:h[1],location:l?t.locations[c]:null};n(t,d,c),s.push(d)}}return s.length>0&&(s[0].trace=t),s},m.plot=function(t,e){var r=t.framework.select(".scattergeolayer").selectAll("g.trace.scattergeo").data(e,function(t){return t.uid});r.enter().append("g").attr("class","trace scattergeo"),r.exit().remove(),r.selectAll("*").remove(),r.each(function(t){var e=s.select(this);g.hasLines(t)&&e.selectAll("path.js-line").data([i(t)]).enter().append("path").classed("js-line",!0)}),r.each(function(e){function r(r,n){if(t.showHover){var i=t.projection([r.lon,r.lat]);h(r),l.loneHover({x:i[0],y:i[1],name:v?e.name:void 0,text:r.textLabel,color:r.mc||(e.marker||{}).color},{container:t.hoverContainer.node()}),y=d(r,n),t.graphDiv.emit("plotly_hover",y)}}function n(e,r){t.graphDiv.emit("plotly_click",d(e,r))}var i=s.select(this),c=g.hasMarkers(e),u=g.hasText(e);if(c||u){var f=m.calcGeoJSON(e,t.topojson),h=a(t,e),d=o(e),p=e.hoverinfo,v="all"===p||-1!==p.indexOf("name"),y=null;c&&i.selectAll("path.point").data(f).enter().append("path").classed("point",!0).on("mouseover",r).on("click",n).on("mouseout",function(){l.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",y)}).on("mousedown",function(){l.loneUnhover(t.hoverContainer)}).on("mouseup",r),u&&i.selectAll("g").data(f).enter().append("g").append("text")}}),m.style(t)},m.style=function(t){var e=t.framework.selectAll("g.trace.scattergeo");e.style("opacity",function(t){return t.opacity}),e.each(function(t){s.select(this).selectAll("path.point").call(p.pointStyle,t),s.select(this).selectAll("text").call(p.textPointStyle,t)}),e.selectAll("path.js-line").style("fill","none").each(function(t){var e=t.trace,r=e.line||{};s.select(this).call(d.stroke,r.color).call(p.dashLine,r.dash||"",r.width||0)})}},{"../../components/color":297,"../../components/drawing":319,"../../lib/array_to_calc_item":363,"../../lib/geo_location_utils":369,"../../lib/topojson_utils":385,"../../plots/cartesian/axes":393,"../../plots/cartesian/graph_interact":400,"../scatter/subtypes":559,"./attributes":568,d3:87}],573:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../constants/gl2d_dashes"),a=t("../../constants/gl_markers"),o=t("../../lib/extend").extendFlat,s=n.line,l=n.marker,c=l.line;e.exports={x:n.x,x0:n.x0,dx:n.dx,y:n.y,y0:n.y0,dy:n.dy,text:o({},n.text,{}),mode:{valType:"flaglist",flags:["lines","markers"],extras:["none"]},line:{color:s.color,width:s.width,dash:{valType:"enumerated",values:Object.keys(i),dflt:"solid"}},marker:{color:l.color,symbol:{valType:"enumerated",values:Object.keys(a),dflt:"circle",arrayOk:!0},size:l.size,sizeref:l.sizeref,sizemin:l.sizemin,sizemode:l.sizemode,opacity:l.opacity,colorscale:l.colorscale,cauto:l.cauto,cmax:l.cmax,cmin:l.cmin,autocolorscale:l.autocolorscale,reversescale:l.reversescale,showscale:l.showscale,line:{color:c.color,width:c.width,colorscale:c.colorscale,cauto:c.cauto,cmax:c.cmax,cmin:c.cmin,autocolorscale:c.autocolorscale,reversescale:c.reversescale}},fill:o({},n.fill,{values:["none","tozeroy","tozerox"]}),fillcolor:n.fillcolor,_nestedModules:{error_x:"ErrorBars",error_y:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../constants/gl2d_dashes":357,"../../constants/gl_markers":359,"../../lib/extend":367,"../scatter/attributes":540}],574:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.xData=[],this.yData=[],this.textLabels=[],this.color="rgb(0, 0, 0)",this.name="",this.hoverinfo="all",this.idToIndex=[],this.bounds=[0,0,0,0],this.hasLines=!1,this.lineOptions={positions:new Float32Array,color:[0,0,0,1],width:1,fill:[!1,!1,!1,!1],fillColor:[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],dashes:[1]},this.line=d(t.glplot,this.lineOptions),this.line._trace=this,this.hasErrorX=!1,this.errorXOptions={positions:new Float32Array,errors:new Float32Array,lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorX=p(t.glplot,this.errorXOptions),this.errorX._trace=this,this.hasErrorY=!1,this.errorYOptions={positions:new Float32Array,errors:new Float32Array,lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorY=p(t.glplot,this.errorYOptions),this.errorY._trace=this,this.hasMarkers=!1,this.scatterOptions={positions:new Float32Array,sizes:[],colors:[],glyphs:[],borderWidths:[],borderColors:[],size:12,color:[0,0,0,1],borderSize:1,borderColor:[0,0,0,1]},this.scatter=f(t.glplot,this.scatterOptions),this.scatter._trace=this,this.fancyScatter=h(t.glplot,this.scatterOptions),this.fancyScatter._trace=this}function i(t,e,r){return Array.isArray(e)||(e=[e]),a(t,e,r)}function a(t,e,r){for(var n=new Array(r),i=e[0],a=0;r>a;++a)n[a]=t(a>=e.length?i:e[a]);return n}function o(t,e,r){return l(S(t,r),L(e,r),r)}function s(t,e,r,n){var i=x(t,e,n);return i=Array.isArray(i[0])?i:a(v.identity,[i],n),l(i,L(r,n),n)}function l(t,e,r){for(var n=new Array(4*r),i=0;r>i;++i){for(var a=0;3>a;++a)n[4*i+a]=t[i][a];n[4*i+3]=t[i][3]*e[i]}return n}function c(t,e){if(void 0===Float32Array.slice){for(var r=new Float32Array(e),n=0;e>n;n++)r[n]=t[n];return r}return t.slice(0,e)}function u(t,e){var r=new n(t,e.uid);return r.update(e),r}var f=t("gl-scatter2d"),h=t("gl-scatter2d-fancy"),d=t("gl-line2d"),p=t("gl-error2d"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../plots/cartesian/axes"),y=t("../../components/errorbars"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/subtypes"),w=t("../scatter/make_bubble_size_func"),k=t("../scatter/get_trace_color"),A=t("../../constants/gl_markers"),M=t("../../constants/gl2d_dashes"),T=["xaxis","yaxis"],E=n.prototype;E.handlePick=function(t){var e=this.idToIndex[t.pointId];return{trace:this,dataCoord:t.dataCoord,traceCoord:[this.xData[e],this.yData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:Array.isArray(this.color)?this.color[e]:this.color,name:this.name,hoverinfo:this.hoverinfo}},E.isFancy=function(t){if("linear"!==this.scene.xaxis.type)return!0;if("linear"!==this.scene.yaxis.type)return!0;if(!t.x||!t.y)return!0;var e=t.marker||{};if(Array.isArray(e.symbol)||"circle"!==e.symbol||Array.isArray(e.size)||Array.isArray(e.line.width)||Array.isArray(e.opacity))return!0;var r=e.color;if(Array.isArray(r))return!0;var n=Array.isArray(e.line.color);return Array.isArray(n)?!0:this.hasErrorX?!0:!!this.hasErrorY};var L=i.bind(null,function(t){return+t}),S=i.bind(null,b),C=i.bind(null,function(t){return A[t]||"\u25cf"});E.update=function(t){t.visible!==!0?(this.hasLines=!1,this.hasErrorX=!1,this.hasErrorY=!1,this.hasMarkers=!1):(this.hasLines=_.hasLines(t),this.hasErrorX=t.error_x.visible===!0,this.hasErrorY=t.error_y.visible===!0,this.hasMarkers=_.hasMarkers(t)),this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.isFancy(t)?this.updateFancy(t):this.updateFast(t),this.color=k(t,{})},E.updateFast=function(t){for(var e,r,n=this.xData=t.x,i=this.yData=t.y,a=n.length,o=new Array(a),s=new Float32Array(2*a),l=this.bounds,u=0,f=0,h=0;a>h;++h)e=n[h],r=i[h],g(e)&&g(r)&&(o[u++]=h,s[f++]=e,s[f++]=r,l[0]=Math.min(l[0],e),l[1]=Math.min(l[1],r),l[2]=Math.max(l[2],e),l[3]=Math.max(l[3],r));s=c(s,f),this.idToIndex=o,this.updateLines(t,s),this.updateError("X",t),this.updateError("Y",t);var d;if(this.hasMarkers){this.scatterOptions.positions=s;var p=b(t.marker.color),v=b(t.marker.line.color),m=t.opacity*t.marker.opacity;p[3]*=m,this.scatterOptions.color=p, -v[3]*=m,this.scatterOptions.borderColor=v,d=t.marker.size,this.scatterOptions.size=d,this.scatterOptions.borderSize=t.marker.line.width,this.scatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions),this.expandAxesFast(l,d)},E.updateFancy=function(t){var e,r,n,a,o,l,u,f,h=this.scene,d=h.xaxis,p=h.yaxis,g=this.bounds,v=this.xData=d.makeCalcdata(t,"x"),m=this.yData=p.makeCalcdata(t,"y"),b=y.calcFromTrace(t,h.fullLayout),x=v.length,_=new Array(x),k=new Float32Array(2*x),A=new Float32Array(4*x),M=new Float32Array(4*x),T=0,E=0,S=0,z=0,P="log"===d.type?function(t){return d.d2l(t)}:function(t){return t},R="log"===p.type?function(t){return p.d2l(t)}:function(t){return t};for(e=0;x>e;++e)n=P(v[e]),a=R(m[e]),isNaN(n)||isNaN(a)||(_[T++]=e,k[E++]=n,k[E++]=a,o=A[S++]=n-b[e].xs||0,l=A[S++]=b[e].xh-n||0,A[S++]=0,A[S++]=0,M[z++]=0,M[z++]=0,u=M[z++]=a-b[e].ys||0,f=M[z++]=b[e].yh-a||0,g[0]=Math.min(g[0],n-o),g[1]=Math.min(g[1],a-u),g[2]=Math.max(g[2],n+l),g[3]=Math.max(g[3],a+f));k=c(k,E),this.idToIndex=_,this.updateLines(t,k),this.updateError("X",t,k,A),this.updateError("Y",t,k,M);var O;if(this.hasMarkers){this.scatterOptions.positions=k,this.scatterOptions.sizes=new Array(T),this.scatterOptions.glyphs=new Array(T),this.scatterOptions.borderWidths=new Array(T),this.scatterOptions.colors=new Array(4*T),this.scatterOptions.borderColors=new Array(4*T);var I,N=w(t),j=t.marker,F=j.opacity,B=t.opacity,D=s(j,F,B,x),U=C(j.symbol,x),V=L(j.line.width,x),q=s(j.line,F,B,x);for(O=i(N,j.size,x),e=0;T>e;++e)for(I=_[e],this.scatterOptions.sizes[e]=4*O[I],this.scatterOptions.glyphs[e]=U[I],this.scatterOptions.borderWidths[e]=.5*V[I],r=0;4>r;++r)this.scatterOptions.colors[4*e+r]=D[4*I+r],this.scatterOptions.borderColors[4*e+r]=q[4*I+r];this.fancyScatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array,this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions),this.expandAxesFancy(v,m,O)},E.updateLines=function(t,e){if(this.hasLines){this.lineOptions.positions=e;var r=b(t.line.color);this.hasMarkers&&(r[3]*=t.marker.opacity);for(var n=Math.round(.5*this.lineOptions.width),i=(M[t.line.dash]||[1]).slice(),a=0;ao;o++)r=this.scene[T[o]],n=r._min,n||(n=[]),n.push({val:t[o],pad:a}),i=r._max,i||(i=[]),i.push({val:t[o+2],pad:a})},E.expandAxesFancy=function(t,e,r){var n=this.scene,i={padded:!0,ppad:r};m.expand(n.xaxis,t,i),m.expand(n.yaxis,e,i)},E.dispose=function(){this.line.dispose(),this.errorX.dispose(),this.errorY.dispose(),this.scatter.dispose(),this.fancyScatter.dispose()},e.exports=u},{"../../components/errorbars":325,"../../constants/gl2d_dashes":357,"../../constants/gl_markers":359,"../../lib":372,"../../lib/gl_format_color":370,"../../lib/str2rgbarray":383,"../../plots/cartesian/axes":393,"../scatter/get_trace_color":547,"../scatter/make_bubble_size_func":553,"../scatter/subtypes":559,"fast-isnumeric":95,"gl-error2d":110,"gl-line2d":117,"gl-scatter2d":159,"gl-scatter2d-fancy":154}],575:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/xy_defaults"),s=t("../scatter/marker_defaults"),l=t("../scatter/line_defaults"),c=t("../scatter/fillcolor_defaults"),u=t("../../components/errorbars/defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p=o(t,e,d);return p?(d("text"),d("mode",pr;r++)y=e.a[r],b=e.b[r],x=e.c[r],n(y)&&n(b)&&n(x)?(y=+y,b=+b,x=+x,_=v/(y+b+x),1!==_&&(y*=_,b*=_,x*=_),k=y,w=x-b,M[r]={x:w,y:k,a:y,b:b,c:x}):M[r]={x:!1,y:!1};var T,E;if(o.hasMarkers(e)&&(T=e.marker,E=T.size,Array.isArray(E))){var L={type:"linear"};i.setConvert(L),E=L.makeCalcdata(e.marker,"size"),E.length>A&&E.splice(A,E.length-A)}return s(e),void 0!==typeof E&&a.mergeArray(E,M,"ms"),M}},{"../../lib":372,"../../plots/cartesian/axes":393,"../scatter/marker_colorscale_calc":554,"../scatter/subtypes":559,"fast-isnumeric":95}],579:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/marker_defaults"),s=t("../scatter/line_defaults"),l=t("../scatter/line_shape_defaults"),c=t("../scatter/text_defaults"),u=t("../scatter/fillcolor_defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p,g=d("a"),v=d("b"),m=d("c");if(g?(p=g.length,v?(p=Math.min(p,v.length),m&&(p=Math.min(p,m.length))):p=m?Math.min(p,m.length):0):v&&m&&(p=Math.min(v.length,m.length)),!p)return void(e.visible=!1);g&&p"),s}}},{"../../plots/cartesian/axes":393,"../scatter/hover":548}],581:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../plots/ternary":448,"../scatter/colorbar":543,"./attributes":577,"./calc":578,"./defaults":579,"./hover":580,"./plot":582,"./select":583,"./style":584}],582:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e){for(var r={x:function(){return t.xaxis},y:function(){return t.yaxis},plot:t.plotContainer},i=new Array(e.length),a=t.graphDiv.calcdata,o=0;oe){for(var r=g/e,n=[0|Math.floor(t[0].shape[0]*r+1),0|Math.floor(t[0].shape[1]*r+1)],i=n[0]*n[1],o=0;or;++r)this.showContour[r]&&(e=!0,t[r]=this.scene.contourLevels[r]);e&&this.surface.update({levels:t})},v.update=function(t){var e,r=this.scene,n=r.fullSceneLayout,a=this.surface,s=t.opacity,l=i(t.colorscale,s),u=t.z,h=t.x,d=t.y,g=n.xaxis,v=n.yaxis,m=n.zaxis,y=r.dataScale,b=u[0].length,x=u.length,_=[c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x])],w=_[0],k=_[1],A=r.contourLevels;this.data=t,f(_[2],function(t,e){return m.d2l(u[e][t])*y[2]}),Array.isArray(h[0])?f(w,function(t,e){return g.d2l(h[e][t])*y[0]}):f(w,function(t){return g.d2l(h[t])*y[0]}),Array.isArray(d[0])?f(k,function(t,e){return v.d2l(d[e][t])*y[1]}):f(k,function(t,e){return v.d2l(d[e])*y[1]});var M={colormap:l,levels:[[],[],[]],showContour:[!0,!0,!0],showSurface:!t.hidesurface,contourProject:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],contourWidth:[1,1,1],contourColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],contourTint:[1,1,1],dynamicColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],dynamicWidth:[1,1,1],dynamicTint:[1,1,1],opacity:1};if(M.intensityBounds=[t.cmin,t.cmax],t.surfacecolor){var T=c(new Float32Array(b*x),[b,x]);f(T,function(e,r){return t.surfacecolor[r][e]}),_.push(T)}else M.intensityBounds[0]*=y[2],M.intensityBounds[1]*=y[2];this.dataScale=o(_),t.surfacecolor&&(M.intensity=_.pop()),"opacity"in t&&t.opacity<1&&(M.opacity=.25*t.opacity);var E=[!0,!0,!0],L=["x","y","z"];for(e=0;3>e;++e){var S=t.contours[L[e]];E[e]=S.highlight,M.showContour[e]=S.show||S.highlight,M.showContour[e]&&(M.contourProject[e]=[S.project.x,S.project.y,S.project.z],S.show?(this.showContour[e]=!0,M.levels[e]=A[e],a.highlightColor[e]=M.contourColor[e]=p(S.color),S.usecolormap?a.highlightTint[e]=M.contourTint[e]=0:a.highlightTint[e]=M.contourTint[e]=1,M.contourWidth[e]=S.width):this.showContour[e]=!1,S.highlight&&(M.dynamicColor[e]=p(S.highlightcolor),M.dynamicWidth[e]=S.highlightwidth))}M.coords=_,a.update(M),a.visible=t.visible,a.enableDynamic=E,a.snapToData=!0,"lighting"in t&&(a.ambientLight=t.lighting.ambient,a.diffuseLight=t.lighting.diffuse,a.specularLight=t.lighting.specular,a.roughness=t.lighting.roughness,a.fresnel=t.lighting.fresnel),s&&1>s&&(a.supportsTransparency=!0)},v.dispose=function(){this.scene.glplot.remove(this.surface),this.surface.dispose()},e.exports=s},{"../../lib/str2rgbarray":383,"gl-surface3d":177,ndarray:225,"ndarray-fill":215,"ndarray-homography":217,"ndarray-ops":219,tinycolor2:275}],589:[function(t,e,r){"use strict";function n(t,e,r){e in t&&!(r in t)&&(t[r]=t[e])}var i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}var c,u,f=l("z");if(!f)return void(e.visible=!1);var h=f[0].length,d=f.length;if(l("x"),l("y"),!Array.isArray(e.x))for(e.x=[],c=0;h>c;++c)e.x[c]=c;if(l("text"),!Array.isArray(e.y))for(e.y=[],c=0;d>c;++c)e.y[c]=c;l("lighting.ambient"),l("lighting.diffuse"),l("lighting.specular"),l("lighting.roughness"),l("lighting.fresnel"),l("hidesurface"),l("opacity");var p=l("surfacecolor");l("colorscale");var g=["x","y","z"];for(c=0;3>c;++c){var v="contours."+g[c],m=l(v+".show"),y=l(v+".highlight");if(m||y)for(u=0;3>u;++u)l(v+".project."+g[u]);m&&(l(v+".color"),l(v+".width"),l(v+".usecolormap")),y&&(l(v+".highlightcolor"),l(v+".highlightwidth"))}p||(n(t,"zmin","cmin"),n(t,"zmax","cmax"),n(t,"zauto","cauto")),a(t,e,s,l,{prefix:"",cLetter:"c"})}},{"../../components/colorscale/defaults":306,"../../lib":372,"./attributes":585}],590:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("./colorbar"),n.calc=t("./calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="surface",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","noOpacity"],n.meta={},e.exports=n},{"../../plots/gl3d":428,"./attributes":585,"./calc":586,"./colorbar":587,"./convert":588,"./defaults":589}],591:[function(t,e,r){"use strict";function n(t,e){function r(e,r){var i=o.nestedProperty(t,e).get(),a=o.nestedProperty(n,e).get();a.push(i[r])}var n=o.extendDeep({},t),s=e.transform,l=s.filtersrc,c=i(s),u=t[l].length,f=a(t);f.forEach(function(t){o.nestedProperty(n,t).set([])});for(var h=0;u>h;h++){var d=t[l][h];if(c(d))for(var p=0;pt};case">":return function(t){return t>e}}}function a(t,e){e=e||"";var r=[];return Object.keys(t).forEach(function(n){var i=t[n];"_"!==n.charAt(0)&&("transforms"===n?i.forEach(function(t,i){r=r.concat(a(t,e+n+"["+i+"]."))}):o.isPlainObject(i)?r=r.concat(a(i,e+n+".")):Array.isArray(i)&&r.push(e+n))}),r}var o=t("../../../../src/lib");r.moduleType="transform",r.name="filter",r.attributes={operation:{valType:"enumerated",values:["=","<",">"],dflt:"="},value:{valType:"number",dflt:0},filtersrc:{valType:"enumerated",values:["x","y"],dflt:"x"}},r.supplyDefaults=function(t,e,n){function i(e,n){return o.coerce(t,a,r.attributes,e,n)}var a={};return i("operation"),i("value"),i("filtersrc"),a},r.transform=function(t,e){var r=t.map(function(t){return n(t,e)});return r}},{"../../../../src/lib":372}],592:[function(t,e,r){"use strict";function n(t,e){for(var r=e.transform,n=r.groups,a=n.filter(function(t,e,r){return r.indexOf(t)===e}),o=new Array(a.length),s=Math.min(t.x.length,t.y.length,n.length),l=0;lf;f++)n[f]===c&&(u.x.push(t.x[f]),u.y.push(t.y[f]));u.name=c,u.marker.color=r.groupColors[c]}return o}var i=t("../../../../src/lib");r.moduleType="transform",r.name="groupby",r.attributes={active:{valType:"boolean",dflt:!0},groups:{valType:"data_array",dflt:[]},groupColors:{valType:"any",dflt:{}}},r.supplyDefaults=function(t,e,n){function a(e,n){return i.coerce(t,o,r.attributes,e,n)}var o={},s=a("active");return s?(a("groups"),a("groupColors"),o):o},r.transform=function(t,e){var r=[];return t.forEach(function(t){r=r.concat(n(t,e))}),r}},{"../../../../src/lib":372}]},{},[12])(12)}); \ No newline at end of file +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Plotly=t()}}(function(){var t;return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,function(e){var r=t[o][1][e];return i(r?r:e)},u,u.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;or;++r)e[r]=0;return e}function o(t,e,r){switch(arguments.length){case 0:return new i([0],[0],0);case 1:if("number"==typeof t){var n=a(t);return new i(n,n,0)}return new i(t,a(t.length),0);case 2:if("number"==typeof e){var n=a(t.length);return new i(t,n,+e)}r=0;case 3:if(t.length!==e.length)throw new Error("state and velocity lengths must match");return new i(t,e,r)}}e.exports=o;var s=t("cubic-hermite"),l=t("binary-search-bounds"),c=i.prototype;c.flush=function(t){var e=l.gt(this._time,t)-1;0>=e||(this._time.splice(0,e),this._state.splice(0,e*this.dimension),this._velocity.splice(0,e*this.dimension))},c.curve=function(t){var e=this._time,r=e.length,i=l.le(e,t),a=this._scratch[0],o=this._state,c=this._velocity,u=this.dimension,f=this.bounds;if(0>i)for(var h=u-1,d=0;u>d;++d,--h)a[d]=o[h];else if(i>=r-1)for(var h=o.length-1,p=t-e[r-1],d=0;u>d;++d,--h)a[d]=o[h]+p*c[h];else{for(var h=u*(i+1)-1,g=e[i],v=e[i+1],m=v-g||1,y=this._scratch[1],b=this._scratch[2],x=this._scratch[3],_=this._scratch[4],w=!0,d=0;u>d;++d,--h)y[d]=o[h],x[d]=c[h]*m,b[d]=o[h+u],_[d]=c[h+u]*m,w=w&&y[d]===b[d]&&x[d]===_[d]&&0===x[d];if(w)for(var d=0;u>d;++d)a[d]=y[d];else s(y,x,b,_,(t-g)/m,a)}for(var k=f[0],A=f[1],d=0;u>d;++d)a[d]=n(k[d],A[d],a[d]);return a},c.dcurve=function(t){var e=this._time,r=e.length,n=l.le(e,t),i=this._scratch[0],a=this._state,o=this._velocity,c=this.dimension;if(n>=r-1)for(var u=a.length-1,f=(t-e[r-1],0);c>f;++f,--u)i[f]=o[u];else{for(var u=c*(n+1)-1,h=e[n],d=e[n+1],p=d-h||1,g=this._scratch[1],v=this._scratch[2],m=this._scratch[3],y=this._scratch[4],b=!0,f=0;c>f;++f,--u)g[f]=a[u],m[f]=o[u]*p,v[f]=a[u+c],y[f]=o[u+c]*p,b=b&&g[f]===v[f]&&m[f]===y[f]&&0===m[f];if(b)for(var f=0;c>f;++f)i[f]=0;else{s.derivative(g,m,v,y,(t-h)/p,i);for(var f=0;c>f;++f)i[f]/=p}}return i},c.lastT=function(){var t=this._time;return t[t.length-1]},c.stable=function(){for(var t=this._velocity,e=t.length,r=this.dimension-1;r>=0;--r)if(t[--e])return!1;return!0},c.jump=function(t){var e=this.lastT(),r=this.dimension;if(!(e>t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1];this._time.push(e,t);for(var u=0;2>u;++u)for(var f=0;r>f;++f)i.push(i[o++]),a.push(0);this._time.push(t);for(var f=r;f>0;--f)i.push(n(l[f-1],c[f-1],arguments[f])),a.push(0)}},c.push=function(t){var e=this.lastT(),r=this.dimension;if(!(e>t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=t-e,l=this.bounds,c=l[0],u=l[1],f=s>1e-6?1/s:0;this._time.push(t);for(var h=r;h>0;--h){var d=n(c[h-1],u[h-1],arguments[h]);i.push(d),a.push((d-i[o++])*f)}}},c.set=function(t){var e=this.dimension;if(!(t0;--l)r.push(n(o[l-1],s[l-1],arguments[l])),i.push(0)}},c.move=function(t){var e=this.lastT(),r=this.dimension;if(!(e>=t||arguments.length!==r+1)){var i=this._state,a=this._velocity,o=i.length-this.dimension,s=this.bounds,l=s[0],c=s[1],u=t-e,f=u>1e-6?1/u:0;this._time.push(t);for(var h=r;h>0;--h){var d=arguments[h];i.push(n(l[h-1],c[h-1],i[o++]+d)),a.push(d*f)}}},c.idle=function(t){var e=this.lastT();if(!(e>t)){var r=this.dimension,i=this._state,a=this._velocity,o=i.length-r,s=this.bounds,l=s[0],c=s[1],u=t-e;this._time.push(t);for(var f=r-1;f>=0;--f)i.push(n(l[f],c[f],i[o]+u*a[o])),a.push(0),o+=1}}},{"binary-search-bounds":21,"cubic-hermite":22}],21:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],22:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=6*i*i-6*i,s=3*i*i-4*i+1,l=-6*i*i+6*i,c=3*i*i-2*i;if(t.length){a||(a=new Array(t.length));for(var u=t.length-1;u>=0;--u)a[u]=o*t[u]+s*e[u]+l*r[u]+c*n[u];return a}return o*t+s*e+l*r[u]+c*n}function i(t,e,r,n,i,a){var o=i-1,s=i*i,l=o*o,c=(1+2*i)*l,u=i*l,f=s*(3-2*i),h=s*o;if(t.length){a||(a=new Array(t.length));for(var d=t.length-1;d>=0;--d)a[d]=c*t[d]+u*e[d]+f*r[d]+h*n[d];return a}return c*t+u*e+f*r+h*n}e.exports=i,e.exports.derivative=n},{}],23:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return t[0]=i*l-a*s,t[1]=a*o-n*l,t[2]=n*s-i*o,t}e.exports=n},{}],24:[function(t,e,r){function n(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}e.exports=n},{}],25:[function(t,e,r){function n(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}e.exports=n},{}],26:[function(t,e,r){function n(t,e,r,n){var i=e[0],a=e[1],o=e[2];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=o+n*(r[2]-o),t}e.exports=n},{}],27:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t}e.exports=n},{}],28:[function(t,e,r){"use strict";function n(t){this._components=t.slice(),this._time=[0],this.prevMatrix=t.slice(),this.nextMatrix=t.slice(),this.computedMatrix=t.slice(),this.computedInverse=t.slice(),this.computedEye=[0,0,0],this.computedUp=[0,0,0],this.computedCenter=[0,0,0],this.computedRadius=[0],this._limits=[-(1/0),1/0]}function i(t){t=t||{};var e=t.matrix||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return new n(e)}var a=t("binary-search-bounds"),o=t("mat4-interpolate"),s=t("gl-mat4/invert"),l=t("gl-mat4/rotateX"),c=t("gl-mat4/rotateY"),u=t("gl-mat4/rotateZ"),f=t("gl-mat4/lookAt"),h=t("gl-mat4/translate"),d=(t("gl-mat4/scale"),t("gl-vec3/normalize")),p=[0,0,0];e.exports=i;var g=n.prototype;g.recalcMatrix=function(t){var e=this._time,r=a.le(e,t),n=this.computedMatrix;if(!(0>r)){var i=this._components;if(r===e.length-1)for(var l=16*r,c=0;16>c;++c)n[c]=i[l++];else{for(var u=e[r+1]-e[r],l=16*r,f=this.prevMatrix,h=!0,c=0;16>c;++c)f[c]=i[l++];for(var p=this.nextMatrix,c=0;16>c;++c)p[c]=i[l++],h=h&&f[c]===p[c];if(1e-6>u||h)for(var c=0;16>c;++c)n[c]=f[c];else o(n,f,p,(t-e[r])/u)}var g=this.computedUp;g[0]=n[1],g[1]=n[5],g[2]=n[6],d(g,g);var v=this.computedInverse;s(v,n);var m=this.computedEye,y=v[15];m[0]=v[12]/y,m[1]=v[13]/y,m[2]=v[14]/y;for(var b=this.computedCenter,x=Math.exp(this.computedRadius[0]),c=0;3>c;++c)b[c]=m[c]-n[2+4*c]*x}},g.idle=function(t){if(!(tn;++n)e.push(e[r++]);this._time.push(t)}},g.flush=function(t){var e=a.gt(this._time,t)-2;0>e||(this._time.slice(0,e),this._components.slice(0,16*e))},g.lastT=function(){return this._time[this._time.length-1]},g.lookAt=function(t,e,r,n){this.recalcMatrix(t),e=e||this.computedEye,r=r||p,n=n||this.computedUp,this.setMatrix(t,f(this.computedMatrix,e,r,n));for(var i=0,a=0;3>a;++a)i+=Math.pow(r[a]-e[a],2);i=Math.log(Math.sqrt(i)),this.computedRadius[0]=i},g.rotate=function(t,e,r,n){this.recalcMatrix(t);var i=this.computedInverse;e&&c(i,i,e),r&&l(i,i,r),n&&u(i,i,n),this.setMatrix(t,s(this.computedMatrix,i))};var v=[0,0,0];g.pan=function(t,e,r,n){v[0]=-(e||0),v[1]=-(r||0),v[2]=-(n||0),this.recalcMatrix(t);var i=this.computedInverse;h(i,i,v),this.setMatrix(t,s(i,i))},g.translate=function(t,e,r,n){v[0]=e||0,v[1]=r||0,v[2]=n||0,this.recalcMatrix(t);var i=this.computedMatrix;h(i,i,v),this.setMatrix(t,i)},g.setMatrix=function(t,e){if(!(tr;++r)this._components.push(e[r])}},g.setDistance=function(t,e){this.computedRadius[0]=e},g.setDistanceLimits=function(t,e){var r=this._limits;r[0]=t,r[1]=e},g.getDistanceLimits=function(t){var e=this._limits;return t?(t[0]=e[0],t[1]=e[1],t):e}},{"binary-search-bounds":29,"gl-mat4/invert":137,"gl-mat4/lookAt":138,"gl-mat4/rotateX":142,"gl-mat4/rotateY":143,"gl-mat4/rotateZ":144,"gl-mat4/scale":145,"gl-mat4/translate":146,"gl-vec3/normalize":27,"mat4-interpolate":30}],29:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],30:[function(t,e,r){function n(t,e,r,n){if(0===u(e)||0===u(r))return!1;var i=c(e,h.translate,h.scale,h.skew,h.perspective,h.quaternion),a=c(r,d.translate,d.scale,d.skew,d.perspective,d.quaternion);return i&&a?(s(p.translate,h.translate,d.translate,n),s(p.skew,h.skew,d.skew,n),s(p.scale,h.scale,d.scale,n),s(p.perspective,h.perspective,d.perspective,n),f(p.quaternion,h.quaternion,d.quaternion,n),l(t,p.translate,p.scale,p.skew,p.perspective,p.quaternion),!0):!1}function i(){return{translate:a(),scale:a(1),skew:a(),perspective:o(),quaternion:o()}}function a(t){return[t||0,t||0,t||0]}function o(){return[0,0,0,1]}var s=t("gl-vec3/lerp"),l=t("mat4-recompose"),c=t("mat4-decompose"),u=t("gl-mat4/determinant"),f=t("quat-slerp"),h=i(),d=i(),p=i();e.exports=n},{"gl-mat4/determinant":133,"gl-vec3/lerp":26,"mat4-decompose":31,"mat4-recompose":33,"quat-slerp":34}],31:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*o,t}function i(t,e){t[0][0]=e[0],t[0][1]=e[1],t[0][2]=e[2],t[1][0]=e[4],t[1][1]=e[5],t[1][2]=e[6],t[2][0]=e[8],t[2][1]=e[9],t[2][2]=e[10]}function a(t,e,r,n,i){t[0]=e[0]*n+r[0]*i,t[1]=e[1]*n+r[1]*i,t[2]=e[2]*n+r[2]*i}var o=t("./normalize"),s=t("gl-mat4/create"),l=t("gl-mat4/clone"),c=t("gl-mat4/determinant"),u=t("gl-mat4/invert"),f=t("gl-mat4/transpose"),h={length:t("gl-vec3/length"),normalize:t("gl-vec3/normalize"),dot:t("gl-vec3/dot"),cross:t("gl-vec3/cross")},d=s(),p=s(),g=[0,0,0,0],v=[[0,0,0],[0,0,0],[0,0,0]],m=[0,0,0];e.exports=function(t,e,r,s,y,b){if(e||(e=[0,0,0]),r||(r=[0,0,0]),s||(s=[0,0,0]),y||(y=[0,0,0,1]),b||(b=[0,0,0,1]),!o(d,t))return!1;if(l(p,d),p[3]=0,p[7]=0,p[11]=0,p[15]=1,Math.abs(c(p)<1e-8))return!1;var x=d[3],_=d[7],w=d[11],k=d[12],A=d[13],M=d[14],T=d[15];if(0!==x||0!==_||0!==w){g[0]=x,g[1]=_,g[2]=w,g[3]=T;var E=u(p,p);if(!E)return!1;f(p,p),n(y,g,p)}else y[0]=y[1]=y[2]=0,y[3]=1;if(e[0]=k,e[1]=A,e[2]=M,i(v,d),r[0]=h.length(v[0]),h.normalize(v[0],v[0]),s[0]=h.dot(v[0],v[1]),a(v[1],v[1],v[0],1,-s[0]),r[1]=h.length(v[1]),h.normalize(v[1],v[1]),s[0]/=r[1],s[1]=h.dot(v[0],v[2]),a(v[2],v[2],v[0],1,-s[1]),s[2]=h.dot(v[1],v[2]),a(v[2],v[2],v[1],1,-s[2]),r[2]=h.length(v[2]),h.normalize(v[2],v[2]),s[1]/=r[2],s[2]/=r[2],h.cross(m,v[1],v[2]),h.dot(v[0],m)<0)for(var L=0;3>L;L++)r[L]*=-1,v[L][0]*=-1,v[L][1]*=-1,v[L][2]*=-1;return b[0]=.5*Math.sqrt(Math.max(1+v[0][0]-v[1][1]-v[2][2],0)),b[1]=.5*Math.sqrt(Math.max(1-v[0][0]+v[1][1]-v[2][2],0)),b[2]=.5*Math.sqrt(Math.max(1-v[0][0]-v[1][1]+v[2][2],0)),b[3]=.5*Math.sqrt(Math.max(1+v[0][0]+v[1][1]+v[2][2],0)),v[2][1]>v[1][2]&&(b[0]=-b[0]),v[0][2]>v[2][0]&&(b[1]=-b[1]),v[1][0]>v[0][1]&&(b[2]=-b[2]),!0}},{"./normalize":32,"gl-mat4/clone":131,"gl-mat4/create":132,"gl-mat4/determinant":133,"gl-mat4/invert":137,"gl-mat4/transpose":147,"gl-vec3/cross":23,"gl-vec3/dot":24,"gl-vec3/length":25,"gl-vec3/normalize":27}],32:[function(t,e,r){e.exports=function(t,e){var r=e[15];if(0===r)return!1;for(var n=1/r,i=0;16>i;i++)t[i]=e[i]*n;return!0}},{}],33:[function(t,e,r){var n={identity:t("gl-mat4/identity"),translate:t("gl-mat4/translate"),multiply:t("gl-mat4/multiply"),create:t("gl-mat4/create"),scale:t("gl-mat4/scale"),fromRotationTranslation:t("gl-mat4/fromRotationTranslation")},i=(n.create(),n.create());e.exports=function(t,e,r,a,o,s){return n.identity(t),n.fromRotationTranslation(t,s,e),t[3]=o[0],t[7]=o[1],t[11]=o[2],t[15]=o[3],n.identity(i),0!==a[2]&&(i[9]=a[2],n.multiply(t,t,i)),0!==a[1]&&(i[9]=0,i[8]=a[1],n.multiply(t,t,i)),0!==a[0]&&(i[8]=0,i[4]=a[0],n.multiply(t,t,i)),n.scale(t,t,r),t}},{"gl-mat4/create":132,"gl-mat4/fromRotationTranslation":135,"gl-mat4/identity":136,"gl-mat4/multiply":139,"gl-mat4/scale":145,"gl-mat4/translate":146}],34:[function(t,e,r){e.exports=t("gl-quat/slerp")},{"gl-quat/slerp":35}],35:[function(t,e,r){function n(t,e,r,n){var i,a,o,s,l,c=e[0],u=e[1],f=e[2],h=e[3],d=r[0],p=r[1],g=r[2],v=r[3];return a=c*d+u*p+f*g+h*v,0>a&&(a=-a,d=-d,p=-p,g=-g,v=-v),1-a>1e-6?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o):(s=1-n,l=n),t[0]=s*c+l*d,t[1]=s*u+l*p,t[2]=s*f+l*g,t[3]=s*h+l*v,t}e.exports=n},{}],36:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c){var u=e+a+c;if(f>0){var f=Math.sqrt(u+1);t[0]=.5*(o-l)/f,t[1]=.5*(s-n)/f,t[2]=.5*(r-a)/f,t[3]=.5*f}else{var h=Math.max(e,a,c),f=Math.sqrt(2*h-u+1);e>=h?(t[0]=.5*f,t[1]=.5*(i+r)/f,t[2]=.5*(s+n)/f,t[3]=.5*(o-l)/f):a>=h?(t[0]=.5*(r+i)/f,t[1]=.5*f,t[2]=.5*(l+o)/f,t[3]=.5*(s-n)/f):(t[0]=.5*(n+s)/f,t[1]=.5*(o+l)/f,t[2]=.5*f,t[3]=.5*(r-i)/f)}return t}e.exports=n},{}],37:[function(t,e,r){"use strict";function n(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function i(t,e,r,n){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2)+Math.pow(n,2))}function a(t,e){var r=e[0],n=e[1],a=e[2],o=e[3],s=i(r,n,a,o);s>1e-6?(t[0]=r/s,t[1]=n/s,t[2]=a/s,t[3]=o/s):(t[0]=t[1]=t[2]=0,t[3]=1)}function o(t,e,r){this.radius=l([r]),this.center=l(e),this.rotation=l(t),this.computedRadius=this.radius.curve(0),this.computedCenter=this.center.curve(0),this.computedRotation=this.rotation.curve(0),this.computedUp=[.1,0,0],this.computedEye=[.1,0,0],this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.recalcMatrix(0)}function s(t){t=t||{};var e=t.center||[0,0,0],r=t.rotation||[0,0,0,1],n=t.radius||1;e=[].slice.call(e,0,3),r=[].slice.call(r,0,4),a(r,r);var i=new o(r,e,Math.log(n));return i.setDistanceLimits(t.zoomMin,t.zoomMax),("eye"in t||"up"in t)&&i.lookAt(0,t.eye,t.center,t.up),i}e.exports=s;var l=t("filtered-vector"),c=t("gl-mat4/lookAt"),u=t("gl-mat4/fromQuat"),f=t("gl-mat4/invert"),h=t("./lib/quatFromFrame"),d=o.prototype;d.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())},d.recalcMatrix=function(t){this.radius.curve(t),this.center.curve(t),this.rotation.curve(t);var e=this.computedRotation;a(e,e);var r=this.computedMatrix;u(r,e);var n=this.computedCenter,i=this.computedEye,o=this.computedUp,s=Math.exp(this.computedRadius[0]);i[0]=n[0]+s*r[2],i[1]=n[1]+s*r[6],i[2]=n[2]+s*r[10],o[0]=r[1],o[1]=r[5],o[2]=r[9];for(var l=0;3>l;++l){for(var c=0,f=0;3>f;++f)c+=r[l+4*f]*i[f];r[12+l]=-c}},d.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;16>n;++n)e[n]=r[n];return e}return r},d.idle=function(t){this.center.idle(t),this.radius.idle(t),this.rotation.idle(t)},d.flush=function(t){this.center.flush(t),this.radius.flush(t),this.rotation.flush(t)},d.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=a[1],s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],f=a[4],h=a[8],d=u*o+f*s+h*l;u-=o*d,f-=s*d,h-=l*d;var p=n(u,f,h);u/=p,f/=p,h/=p;var g=a[2],v=a[6],m=a[10],y=g*o+v*s+m*l,b=g*u+v*f+m*h;g-=y*o+b*u,v-=y*s+b*f,m-=y*l+b*h;var x=n(g,v,m);g/=x,v/=x,m/=x;var _=u*e+o*r,w=f*e+s*r,k=h*e+l*r;this.center.move(t,_,w,k);var A=Math.exp(this.computedRadius[0]);A=Math.max(1e-4,A+i),this.radius.set(t,Math.log(A))},d.rotate=function(t,e,r,a){this.recalcMatrix(t),e=e||0,r=r||0;var o=this.computedMatrix,s=o[0],l=o[4],c=o[8],u=o[1],f=o[5],h=o[9],d=o[2],p=o[6],g=o[10],v=e*s+r*u,m=e*l+r*f,y=e*c+r*h,b=-(p*y-g*m),x=-(g*v-d*y),_=-(d*m-p*v),w=Math.sqrt(Math.max(0,1-Math.pow(b,2)-Math.pow(x,2)-Math.pow(_,2))),k=i(b,x,_,w);k>1e-6?(b/=k,x/=k,_/=k,w/=k):(b=x=_=0,w=1);var A=this.computedRotation,M=A[0],T=A[1],E=A[2],L=A[3],S=M*w+L*b+T*_-E*x,C=T*w+L*x+E*b-M*_,z=E*w+L*_+M*x-T*b,P=L*w-M*b-T*x-E*_;if(a){b=d,x=p,_=g;var R=Math.sin(a)/n(b,x,_);b*=R,x*=R,_*=R,w=Math.cos(e),S=S*w+P*b+C*_-z*x,C=C*w+P*x+z*b-S*_,z=z*w+P*_+S*x-C*b,P=P*w-S*b-C*x-z*_}var O=i(S,C,z,P);O>1e-6?(S/=O,C/=O,z/=O,P/=O):(S=C=z=0,P=1),this.rotation.set(t,S,C,z,P)},d.lookAt=function(t,e,r,n){this.recalcMatrix(t),r=r||this.computedCenter,e=e||this.computedEye,n=n||this.computedUp;var i=this.computedMatrix;c(i,e,r,n);var o=this.computedRotation;h(o,i[0],i[1],i[2],i[4],i[5],i[6],i[8],i[9],i[10]),a(o,o),this.rotation.set(t,o[0],o[1],o[2],o[3]);for(var s=0,l=0;3>l;++l)s+=Math.pow(r[l]-e[l],2);this.radius.set(t,.5*Math.log(Math.max(s,1e-6))),this.center.set(t,r[0],r[1],r[2])},d.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},d.setMatrix=function(t,e){var r=this.computedRotation;h(r,e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]),a(r,r),this.rotation.set(t,r[0],r[1],r[2],r[3]);var n=this.computedMatrix;f(n,e);var i=n[15];if(Math.abs(i)>1e-6){var o=n[12]/i,s=n[13]/i,l=n[14]/i;this.recalcMatrix(t);var c=Math.exp(this.computedRadius[0]);this.center.set(t,o-n[2]*c,s-n[6]*c,l-n[10]*c),this.radius.idle(t)}else this.center.idle(t),this.radius.idle(t)},d.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},d.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-(1/0),e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},d.getDistanceLimits=function(t){var e=this.radius.bounds; +return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},d.toJSON=function(){return this.recalcMatrix(this.lastT()),{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}},d.fromJSON=function(t){var e=this.lastT(),r=t.center;r&&this.center.set(e,r[0],r[1],r[2]);var n=t.rotation;n&&this.rotation.set(e,n[0],n[1],n[2],n[3]);var i=t.distance;i&&i>0&&this.radius.set(e,Math.log(i)),this.setDistanceLimits(t.zoomMin,t.zoomMax)}},{"./lib/quatFromFrame":36,"filtered-vector":20,"gl-mat4/fromQuat":134,"gl-mat4/invert":137,"gl-mat4/lookAt":138}],38:[function(t,e,r){"use strict";function n(t,e,r){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2)+Math.pow(r,2))}function i(t){return Math.min(1,Math.max(-1,t))}function a(t){var e=Math.abs(t[0]),r=Math.abs(t[1]),n=Math.abs(t[2]),i=[0,0,0];e>Math.max(r,n)?i[2]=1:r>Math.max(e,n)?i[0]=1:i[1]=1;for(var a=0,o=0,s=0;3>s;++s)a+=t[s]*t[s],o+=i[s]*t[s];for(var s=0;3>s;++s)i[s]-=o/a*t[s];return h(i,i),i}function o(t,e,r,n,i,a,o,s){this.center=l(r),this.up=l(n),this.right=l(i),this.radius=l([a]),this.angle=l([o,s]),this.angle.bounds=[[-(1/0),-Math.PI/2],[1/0,Math.PI/2]],this.setDistanceLimits(t,e),this.computedCenter=this.center.curve(0),this.computedUp=this.up.curve(0),this.computedRight=this.right.curve(0),this.computedRadius=this.radius.curve(0),this.computedAngle=this.angle.curve(0),this.computedToward=[0,0,0],this.computedEye=[0,0,0],this.computedMatrix=new Array(16);for(var c=0;16>c;++c)this.computedMatrix[c]=.5;this.recalcMatrix(0)}function s(t){t=t||{};var e=t.center||[0,0,0],r=t.up||[0,1,0],i=t.right||a(r),s=t.radius||1,l=t.theta||0,c=t.phi||0;if(e=[].slice.call(e,0,3),r=[].slice.call(r,0,3),h(r,r),i=[].slice.call(i,0,3),h(i,i),"eye"in t){var u=t.eye,p=[u[0]-e[0],u[1]-e[1],u[2]-e[2]];f(i,p,r),n(i[0],i[1],i[2])<1e-6?i=a(r):h(i,i),s=n(p[0],p[1],p[2]);var g=d(r,p)/s,v=d(i,p)/s;c=Math.acos(g),l=Math.acos(v)}return s=Math.log(s),new o(t.zoomMin,t.zoomMax,e,r,i,s,l,c)}e.exports=s;var l=t("filtered-vector"),c=t("gl-mat4/invert"),u=t("gl-mat4/rotate"),f=t("gl-vec3/cross"),h=t("gl-vec3/normalize"),d=t("gl-vec3/dot"),p=o.prototype;p.setDistanceLimits=function(t,e){t=t>0?Math.log(t):-(1/0),e=e>0?Math.log(e):1/0,e=Math.max(e,t),this.radius.bounds[0][0]=t,this.radius.bounds[1][0]=e},p.getDistanceLimits=function(t){var e=this.radius.bounds[0];return t?(t[0]=Math.exp(e[0][0]),t[1]=Math.exp(e[1][0]),t):[Math.exp(e[0][0]),Math.exp(e[1][0])]},p.recalcMatrix=function(t){this.center.curve(t),this.up.curve(t),this.right.curve(t),this.radius.curve(t),this.angle.curve(t);for(var e=this.computedUp,r=this.computedRight,i=0,a=0,o=0;3>o;++o)a+=e[o]*r[o],i+=e[o]*e[o];for(var s=Math.sqrt(i),l=0,o=0;3>o;++o)r[o]-=e[o]*a/i,l+=r[o]*r[o],e[o]/=s;for(var c=Math.sqrt(l),o=0;3>o;++o)r[o]/=c;var u=this.computedToward;f(u,e,r),h(u,u);for(var d=Math.exp(this.computedRadius[0]),p=this.computedAngle[0],g=this.computedAngle[1],v=Math.cos(p),m=Math.sin(p),y=Math.cos(g),b=Math.sin(g),x=this.computedCenter,_=v*y,w=m*y,k=b,A=-v*b,M=-m*b,T=y,E=this.computedEye,L=this.computedMatrix,o=0;3>o;++o){var S=_*r[o]+w*u[o]+k*e[o];L[4*o+1]=A*r[o]+M*u[o]+T*e[o],L[4*o+2]=S,L[4*o+3]=0}var C=L[1],z=L[5],P=L[9],R=L[2],O=L[6],I=L[10],N=z*I-P*O,j=P*R-C*I,F=C*O-z*R,D=n(N,j,F);N/=D,j/=D,F/=D,L[0]=N,L[4]=j,L[8]=F;for(var o=0;3>o;++o)E[o]=x[o]+L[2+4*o]*d;for(var o=0;3>o;++o){for(var l=0,B=0;3>B;++B)l+=L[o+4*B]*E[B];L[12+o]=-l}L[15]=1},p.getMatrix=function(t,e){this.recalcMatrix(t);var r=this.computedMatrix;if(e){for(var n=0;16>n;++n)e[n]=r[n];return e}return r};var g=[0,0,0];p.rotate=function(t,e,r,n){if(this.angle.move(t,e,r),n){this.recalcMatrix(t);var i=this.computedMatrix;g[0]=i[2],g[1]=i[6],g[2]=i[10];for(var a=this.computedUp,o=this.computedRight,s=this.computedToward,l=0;3>l;++l)i[4*l]=a[l],i[4*l+1]=o[l],i[4*l+2]=s[l];u(i,i,n,g);for(var l=0;3>l;++l)a[l]=i[4*l],o[l]=i[4*l+1];this.up.set(t,a[0],a[1],a[2]),this.right.set(t,o[0],o[1],o[2])}},p.pan=function(t,e,r,i){e=e||0,r=r||0,i=i||0,this.recalcMatrix(t);var a=this.computedMatrix,o=(Math.exp(this.computedRadius[0]),a[1]),s=a[5],l=a[9],c=n(o,s,l);o/=c,s/=c,l/=c;var u=a[0],f=a[4],h=a[8],d=u*o+f*s+h*l;u-=o*d,f-=s*d,h-=l*d;var p=n(u,f,h);u/=p,f/=p,h/=p;var g=u*e+o*r,v=f*e+s*r,m=h*e+l*r;this.center.move(t,g,v,m);var y=Math.exp(this.computedRadius[0]);y=Math.max(1e-4,y+i),this.radius.set(t,Math.log(y))},p.translate=function(t,e,r,n){this.center.move(t,e||0,r||0,n||0)},p.setMatrix=function(t,e,r,a){var o=1;"number"==typeof r&&(o=0|r),(0>o||o>3)&&(o=1);var s=(o+2)%3;e||(this.recalcMatrix(t),e=this.computedMatrix);var l=e[o],u=e[o+4],f=e[o+8];if(a){var h=Math.abs(l),d=Math.abs(u),p=Math.abs(f),g=Math.max(h,d,p);h===g?(l=0>l?-1:1,u=f=0):p===g?(f=0>f?-1:1,l=u=0):(u=0>u?-1:1,l=f=0)}else{var v=n(l,u,f);l/=v,u/=v,f/=v}var m=e[s],y=e[s+4],b=e[s+8],x=m*l+y*u+b*f;m-=l*x,y-=u*x,b-=f*x;var _=n(m,y,b);m/=_,y/=_,b/=_;var w=u*b-f*y,k=f*m-l*b,A=l*y-u*m,M=n(w,k,A);w/=M,k/=M,A/=M,this.center.jump(t,H,G,Y),this.radius.idle(t),this.up.jump(t,l,u,f),this.right.jump(t,m,y,b);var T,E;if(2===o){var L=e[1],S=e[5],C=e[9],z=L*m+S*y+C*b,P=L*w+S*k+C*A;T=0>N?-Math.PI/2:Math.PI/2,E=Math.atan2(P,z)}else{var R=e[2],O=e[6],I=e[10],N=R*l+O*u+I*f,j=R*m+O*y+I*b,F=R*w+O*k+I*A;T=Math.asin(i(N)),E=Math.atan2(F,j)}this.angle.jump(t,E,T),this.recalcMatrix(t);var D=e[2],B=e[6],U=e[10],V=this.computedMatrix;c(V,e);var q=V[15],H=V[12]/q,G=V[13]/q,Y=V[14]/q,X=Math.exp(this.computedRadius[0]);this.center.jump(t,H-D*X,G-B*X,Y-U*X)},p.lastT=function(){return Math.max(this.center.lastT(),this.up.lastT(),this.right.lastT(),this.radius.lastT(),this.angle.lastT())},p.idle=function(t){this.center.idle(t),this.up.idle(t),this.right.idle(t),this.radius.idle(t),this.angle.idle(t)},p.flush=function(t){this.center.flush(t),this.up.flush(t),this.right.flush(t),this.radius.flush(t),this.angle.flush(t)},p.setDistance=function(t,e){e>0&&this.radius.set(t,Math.log(e))},p.lookAt=function(t,e,r,a){this.recalcMatrix(t),e=e||this.computedEye,r=r||this.computedCenter,a=a||this.computedUp;var o=a[0],s=a[1],l=a[2],c=n(o,s,l);if(!(1e-6>c)){o/=c,s/=c,l/=c;var u=e[0]-r[0],f=e[1]-r[1],h=e[2]-r[2],d=n(u,f,h);if(!(1e-6>d)){u/=d,f/=d,h/=d;var p=this.computedRight,g=p[0],v=p[1],m=p[2],y=o*g+s*v+l*m;g-=y*o,v-=y*s,m-=y*l;var b=n(g,v,m);if(!(.01>b&&(g=s*h-l*f,v=l*u-o*h,m=o*f-s*u,b=n(g,v,m),1e-6>b))){g/=b,v/=b,m/=b,this.up.set(t,o,s,l),this.right.set(t,g,v,m),this.center.set(t,r[0],r[1],r[2]),this.radius.set(t,Math.log(d));var x=s*m-l*v,_=l*g-o*m,w=o*v-s*g,k=n(x,_,w);x/=k,_/=k,w/=k;var A=o*u+s*f+l*h,M=g*u+v*f+m*h,T=x*u+_*f+w*h,E=Math.asin(i(A)),L=Math.atan2(T,M),S=this.angle._state,C=S[S.length-1],z=S[S.length-2];C%=2*Math.PI;var P=Math.abs(C+2*Math.PI-L),R=Math.abs(C-L),O=Math.abs(C-2*Math.PI-L);R>P&&(C+=2*Math.PI),R>O&&(C-=2*Math.PI),this.angle.jump(this.angle.lastT(),C,z),this.angle.set(t,L,E)}}}}},{"filtered-vector":20,"gl-mat4/invert":137,"gl-mat4/rotate":141,"gl-vec3/cross":23,"gl-vec3/dot":24,"gl-vec3/normalize":27}],39:[function(t,e,r){"use strict";function n(t,e){this._controllerNames=Object.keys(t),this._controllerList=this._controllerNames.map(function(e){return t[e]}),this._mode=e,this._active=t[e],this._active||(this._mode="turntable",this._active=t.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}function i(t){t=t||{};var e=t.eye||[0,0,1],r=t.center||[0,0,0],i=t.up||[0,1,0],l=t.distanceLimits||[0,1/0],c=t.mode||"turntable",u=a(),f=o(),h=s();return u.setDistanceLimits(l[0],l[1]),u.lookAt(0,e,r,i),f.setDistanceLimits(l[0],l[1]),f.lookAt(0,e,r,i),h.setDistanceLimits(l[0],l[1]),h.lookAt(0,e,r,i),new n({turntable:u,orbit:f,matrix:h},c)}e.exports=i;var a=t("turntable-camera-controller"),o=t("orbit-camera-controller"),s=t("matrix-camera-controller"),l=n.prototype,c=[["flush",1],["idle",1],["lookAt",4],["rotate",4],["pan",4],["translate",4],["setMatrix",2],["setDistanceLimits",2],["setDistance",2]];c.forEach(function(t){for(var e=t[0],r=[],n=0;ne)){var r=this._active,n=this._controllerList[e],i=Math.max(r.lastT(),n.lastT());r.recalcMatrix(i),n.setMatrix(i,r.computedMatrix),this._active=n,this._mode=t,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}}},l.getMode=function(){return this._mode}},{"matrix-camera-controller":28,"orbit-camera-controller":37,"turntable-camera-controller":38}],40:[function(t,e,r){function n(t,e){return a(i(t,e))}e.exports=n;var i=t("alpha-complex"),a=t("simplicial-complex-boundary")},{"alpha-complex":41,"simplicial-complex-boundary":44}],41:[function(t,e,r){"use strict";function n(t,e){return i(e).filter(function(r){for(var n=new Array(r.length),i=0;ii;++i)r+=t[i]*e[i];return r}function i(t){var e=t.length;if(0===e)return[];var r=(t[0].length,o([t.length+1,t.length+1],1)),i=o([t.length+1],1);r[e][e]=0;for(var a=0;e>a;++a){for(var l=0;a>=l;++l)r[l][a]=r[a][l]=2*n(t[a],t[l]);i[a]=n(t[a],t[a])}for(var c=s(r,i),u=0,f=c[e+1],a=0;aa;++a){for(var f=c[a],d=0,l=0;ls;++s)r[s]+=t[a][s]*n[a];return r}var o=t("dup"),s=t("robust-linear-solve");a.barycenetric=i,e.exports=a},{dup:115,"robust-linear-solve":256}],44:[function(t,e,r){"use strict";function n(t){return a(i(t))}e.exports=n;var i=t("boundary-cells"),a=t("reduce-simplicial-complex")},{"boundary-cells":45,"reduce-simplicial-complex":48}],45:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=0,n=0;e>n;++n)r+=t[n].length;for(var i=new Array(r),a=0,n=0;e>n;++n)for(var o=t[n],s=o.length,l=0;s>l;++l)for(var c=i[a++]=new Array(s-1),u=1;s>u;++u)c[u-1]=o[(l+u)%s];return i}e.exports=n},{}],46:[function(t,e,r){"use strict";function n(t){for(var e=1,r=1;rn;++n)if(t[r]n;++n){var s=t[n],l=o(s);if(0!==l){if(r>0){var c=t[r-1];if(0===i(s,c)&&o(c)!==l){r-=1;continue}}t[r++]=s}}return t.length=r,t}var i=t("compare-cell"),a=t("compare-oriented-cell"),o=t("cell-orientation");e.exports=n},{"cell-orientation":46,"compare-cell":101,"compare-oriented-cell":47}],49:[function(t,e,r){"use strict";var n=function(){function t(t){return!Array.isArray(t)&&null!==t&&"object"==typeof t}function e(t,e,r){for(var n=(e-t)/Math.max(r-1,1),i=[],a=0;r>a;a++)i.push(t+a*n);return i}function r(){for(var t=[].slice.call(arguments),e=t.map(function(t){return t.length}),r=Math.min.apply(null,e),n=[],i=0;r>i;i++){n[i]=[];for(var a=0;aa;a++)i.push([t[a],e[a],r[a]]);return i}function i(t){function e(t){for(var n=0;n>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3])),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}function c(t,e){var r,n;if("string"!=typeof t)return t;if(r=[],"#"===t[0]?(t=t.substr(1),3===t.length&&(t+=t),n=parseInt(t,16),r[0]=n>>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3]),n[4]?r[3]=parseFloat(n[4]):r[3]=1),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}var u={},f=/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,.*)?\)$/,h=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,?\s*(.*)?\)$/;return u.isPlainObject=t,u.linspace=e,u.zip3=n,u.sum=i,u.zip=r,u.isEqual=s,u.copy2D=a,u.copy1D=o,u.str2RgbArray=l,u.str2RgbaArray=c,u};e.exports=n()},{}],50:[function(t,e,r){"use strict";"use restrict";function n(t){var e=32;return t&=-t,t&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}var i=32;r.INT_BITS=i,r.INT_MAX=2147483647,r.INT_MIN=-1<0)-(0>t)},r.abs=function(t){var e=t>>i-1;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(e>t)},r.max=function(t,e){return t^(t^e)&-(e>t)},r.isPow2=function(t){return!(t&t-1||!t)},r.log2=function(t){var e,r;return e=(t>65535)<<4,t>>>=e,r=(t>255)<<3,t>>>=r,e|=r,r=(t>15)<<2,t>>>=r,e|=r,r=(t>3)<<1,t>>>=r,e|=r,e|t>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return t-=t>>>1&1431655765,t=(858993459&t)+(t>>>2&858993459),16843009*(t+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,t&=15,27030>>>t&1};var a=new Array(256);!function(t){for(var e=0;256>e;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|a[t>>>16&255]<<8|a[t>>>24&255]},r.interleave2=function(t,e){return t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},r.deinterleave2=function(t,e){return t=t>>>e&1431655765,t=858993459&(t|t>>>1),t=252645135&(t|t>>>2),t=16711935&(t|t>>>4),t=65535&(t|t>>>16),t<<16>>16},r.interleave3=function(t,e,r){return t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t|=e<<1,r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),t|r<<2},r.deinterleave3=function(t,e){return t=t>>>e&1227133513,t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),t=1023&(t|t>>>16),t<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],51:[function(t,e,r){(function(e){"use strict";function n(){try{var t=new Uint8Array(1);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function i(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t){return this instanceof a?(a.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?o(this,t):"string"==typeof t?s(this,t,arguments.length>1?arguments[1]:"utf8"):l(this,t)):arguments.length>1?new a(t,arguments[1]):new a(t)}function o(t,e){if(t=g(t,0>e?0:0|v(e)),!a.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;r++)t[r]=0;return t}function s(t,e,r){"string"==typeof r&&""!==r||(r="utf8");var n=0|y(e,r);return t=g(t,n),t.write(e,r),t}function l(t,e){if(a.isBuffer(e))return c(t,e);if(K(e))return u(t,e);if(null==e)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(e.buffer instanceof ArrayBuffer)return f(t,e);if(e instanceof ArrayBuffer)return h(t,e)}return e.length?d(t,e):p(t,e)}function c(t,e){var r=0|v(e.length);return t=g(t,r),e.copy(t,0,0,r),t}function u(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function f(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function h(t,e){return e.byteLength,a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=a.prototype):t=f(t,new Uint8Array(e)),t}function d(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function p(t,e){var r,n=0;"Buffer"===e.type&&K(e.data)&&(r=e.data,n=0|v(r.length)),t=g(t,n);for(var i=0;n>i;i+=1)t[i]=255&r[i];return t}function g(t,e){a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=a.prototype):t.length=e;var r=0!==e&&e<=a.poolSize>>>1;return r&&(t.parent=$),t}function v(t){if(t>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function m(t,e){if(!(this instanceof m))return new m(t,e);var r=new a(t,e);return delete r.parent,r}function y(t,e){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(t).length;default:if(n)return q(t).length;e=(""+e).toLowerCase(),n=!0}}function b(t,e,r){var n=!1;if(e=0|e,r=void 0===r||r===1/0?this.length:0|r,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return z(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return S(this,e,r);case"binary":return C(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function x(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=e.length;if(a%2!==0)throw new Error("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;n>o;o++){var s=parseInt(e.substr(2*o,2),16);if(isNaN(s))throw new Error("Invalid hex string");t[r+o]=s}return o}function _(t,e,r,n){return X(q(e,t.length-r),t,r,n)}function w(t,e,r,n){return X(H(e),t,r,n)}function k(t,e,r,n){return w(t,e,r,n)}function A(t,e,r,n){return X(Y(e),t,r,n)}function M(t,e,r,n){return X(G(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;r>i;){var a=t[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(r>=i+s){var l,c,u,f;switch(s){case 1:128>a&&(o=a);break;case 2:l=t[i+1],128===(192&l)&&(f=(31&a)<<6|63&l,f>127&&(o=f));break;case 3:l=t[i+1],c=t[i+2],128===(192&l)&&128===(192&c)&&(f=(15&a)<<12|(63&l)<<6|63&c,f>2047&&(55296>f||f>57343)&&(o=f));break;case 4:l=t[i+1],c=t[i+2],u=t[i+3],128===(192&l)&&128===(192&c)&&128===(192&u)&&(f=(15&a)<<18|(63&l)<<12|(63&c)<<6|63&u,f>65535&&1114112>f&&(o=f))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return L(n)}function L(t){var e=t.length;if(Q>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Q));return r}function S(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function C(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function z(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",a=e;r>a;a++)i+=V(t[a]);return i}function P(t,e,r){for(var n=t.slice(e,r),i="",a=0;at)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!a.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>i||o>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range")}function I(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,a=Math.min(t.length-r,2);a>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function N(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,a=Math.min(t.length-r,4);a>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function j(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function F(t,e,r,n,i){return i||j(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,i){return i||j(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(t,e,r,n,52,8),r+8}function B(t){if(t=U(t).replace(J,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function U(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function V(t){return 16>t?"0"+t.toString(16):t.toString(16)}function q(t,e){e=e||1/0;for(var r,n=t.length,i=null,a=[],o=0;n>o;o++){if(r=t.charCodeAt(o),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,128>r){if((e-=1)<0)break;a.push(r)}else if(2048>r){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function H(t){for(var e=[],r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function Y(t){return W.toByteArray(B(t))}function X(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}var W=t("base64-js"),Z=t("ieee754"),K=t("isarray");r.Buffer=a,r.SlowBuffer=m,r.INSPECT_MAX_BYTES=50,a.poolSize=8192;var $={};a.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),a._augment=function(t){return t.__proto__=a.prototype,t},a.TYPED_ARRAY_SUPPORT?(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})):(a.prototype.length=void 0,a.prototype.parent=void 0),a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,e){if(!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);o>i&&t[i]===e[i];)++i;return i!==o&&(r=t[i],n=e[i]),n>r?-1:r>n?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!K(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new a(0);var r;if(void 0===e)for(e=0,r=0;r0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},a.prototype.compare=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:a.compare(this,t)},a.prototype.indexOf=function(t,e){function r(t,e,r){for(var n=-1,i=0;r+i2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,e);if(a.isBuffer(t))return r(this,t,e);if("number"==typeof t)return a.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):r(this,[t],e);throw new TypeError("val must be string, number or Buffer")},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite(e))e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var i=n;n=e,e=0|r,r=i}var a=this.length-e;if((void 0===r||r>a)&&(r=a),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return x(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":return w(this,t,e,r);case"binary":return k(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var n;if(a.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=a.prototype;else{var i=e-t;n=new a(i,void 0);for(var o=0;i>o;o++)n[o]=this[o+t]}return n.length&&(n.parent=this.parent||this),n},a.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||R(t,e,this.length);for(var n=this[t],i=1,a=0;++a0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||R(t,e,this.length);for(var n=this[t],i=1,a=0;++a=i&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||R(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a},a.prototype.readInt8=function(t,e){return e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),Z.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),Z.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),Z.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),Z.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,r,n){t=+t,e=0|e,r=0|r,n||O(this,t,e,r,Math.pow(2,8*r),0);var i=1,a=0;for(this[e]=255&t;++a=0&&(a*=256);)this[e+i]=t/a&255;return e+r},a.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):N(this,t,e,!0),e+4},a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=0,o=1,s=0>t?1:0;for(this[e]=255&t;++a>0)-s&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0>t?1:0;for(this[e+a]=255&t;--a>=0&&(o*=256);)this[e+a]=(t/o>>0)-s&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):N(this,t,e,!0),e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},a.prototype.writeFloatLE=function(t,e,r){return F(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return F(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length), +t.length-er&&n>e)for(i=o-1;i>=0;i--)t[i+e]=this[i+r];else if(1e3>o||!a.TYPED_ARRAY_SUPPORT)for(i=0;o>i;i++)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},a.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new RangeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=q(t.toString()),a=i.length;for(n=e;r>n;n++)this[n]=i[n%a]}return this}};var J=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":52,ieee754:53,isarray:54}],52:[function(t,e,r){"use strict";function n(){var t,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=e.length;for(t=0;r>t;t++)l[t]=e[t];for(t=0;r>t;++t)c[e.charCodeAt(t)]=t;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63}function i(t){var e,r,n,i,a,o,s=t.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===t[s-2]?2:"="===t[s-1]?1:0,o=new u(3*s/4-a),n=a>0?s-4:s;var l=0;for(e=0,r=0;n>e;e+=4,r+=3)i=c[t.charCodeAt(e)]<<18|c[t.charCodeAt(e+1)]<<12|c[t.charCodeAt(e+2)]<<6|c[t.charCodeAt(e+3)],o[l++]=(16711680&i)>>16,o[l++]=(65280&i)>>8,o[l++]=255&i;return 2===a?(i=c[t.charCodeAt(e)]<<2|c[t.charCodeAt(e+1)]>>4,o[l++]=255&i):1===a&&(i=c[t.charCodeAt(e)]<<10|c[t.charCodeAt(e+1)]<<4|c[t.charCodeAt(e+2)]>>2,o[l++]=i>>8&255,o[l++]=255&i),o}function a(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function o(t,e,r){for(var n,i=[],o=e;r>o;o+=3)n=(t[o]<<16)+(t[o+1]<<8)+t[o+2],i.push(a(n));return i.join("")}function s(t){for(var e,r=t.length,n=r%3,i="",a=[],s=16383,c=0,u=r-n;u>c;c+=s)a.push(o(t,c,c+s>u?u:c+s));return 1===n?(e=t[r-1],i+=l[e>>2],i+=l[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=l[e>>10],i+=l[e>>4&63],i+=l[e<<2&63],i+="="),a.push(i),a.join("")}r.toByteArray=i,r.fromByteArray=s;var l=[],c=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],53:[function(t,e,r){r.read=function(t,e,r,n,i){var a,o,s=8*i-n-1,l=(1<>1,u=-7,f=r?i-1:0,h=r?-1:1,d=t[e+f];for(f+=h,a=d&(1<<-u)-1,d>>=-u,u+=s;u>0;a=256*a+t[e+f],f+=h,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=n;u>0;o=256*o+t[e+f],f+=h,u-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:(d?-1:1)*(1/0);o+=Math.pow(2,n),a-=c}return(d?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,c=8*a-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:a-1,p=n?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),e+=o+f>=1?h/l:h*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=u?(s=0,o=u):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,c-=8);t[r+d-p]|=128*g}},{}],54:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],55:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function a(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!a(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,l,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,l=0;n>l;l++)c[l].apply(this,a);return!0},n.prototype.addListener=function(t,e){var r;if(!i(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(r=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,a,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],a=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(s=a;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],56:[function(t,e,r){function n(){u=!1,s.length?c=s.concat(c):f=-1,c.length&&i()}function i(){if(!u){var t=setTimeout(n);u=!0;for(var e=c.length;e;){for(s=c,c=[];++f1)for(var r=1;rs)){if(n>i){var l=n;n=i,i=l,l=o,o=s,s=l}e.isConstraint(n,i)||a(t[n],t[i],t[o],t[s])<0&&r.push(n,i)}}function i(t,e){for(var r=[],i=t.length,o=e.stars,s=0;i>s;++s)for(var l=o[s],c=1;cu||e.isConstraint(s,u))){for(var f=l[c-1],h=-1,d=1;dh||a(t[s],t[u],t[f],t[h])<0&&r.push(s,u)}}for(;r.length>0;){for(var u=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],p=1;pf||0>h||a(t[s],t[u],t[f],t[h])>=0||(e.flip(s,u),n(t,e,r,f,s,h),n(t,e,r,s,h,f),n(t,e,r,h,u,f),n(t,e,r,u,f,h))}}var a=t("robust-in-sphere")[4];t("binary-search-bounds");e.exports=i},{"binary-search-bounds":62,"robust-in-sphere":63}],59:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function i(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}function a(t,e){for(var r=t.cells(),a=r.length,o=0;a>o;++o){var s=r[o],l=s[0],c=s[1],u=s[2];u>c?l>c&&(s[0]=c,s[1]=u,s[2]=l):l>u&&(s[0]=u,s[1]=l,s[2]=c)}r.sort(i);for(var f=new Array(a),o=0;oo;++o)for(var s=r[o],y=0;3>y;++y){var l=s[y],c=s[(y+1)%3],b=p[3*o+y]=m.locate(c,l,t.opposite(c,l)),x=g[3*o+y]=t.isConstraint(l,c);0>b&&(x?d.push(o):(h.push(o),f[o]=1),e&&v.push([c,l,-1]))}return m}function o(t,e,r){for(var n=0,i=0;i0||l.length>0;){for(;s.length>0;){var d=s.pop();if(c[d]!==-i){c[d]=i;for(var p=(u[d],0);3>p;++p){var g=h[3*d+p];g>=0&&0===c[g]&&(f[3*d+p]?l.push(g):(s.push(g),c[g]=i))}}}var v=l;l=s,s=v,l.length=0,i=-i}var m=o(u,c,e);return r?m.concat(n.boundary):m}var l=t("binary-search-bounds");e.exports=s;var c=n.prototype;c.locate=function(){var t=[0,0,0];return function(e,r,n){var a=e,o=r,s=n;return n>r?e>r&&(a=r,o=n,s=e):e>n&&(a=n,o=e,s=r),0>a?-1:(t[0]=a,t[1]=o,t[2]=s,l.eq(this.cells,t,i))}}()},{"binary-search-bounds":62}],60:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.a=t,this.b=e,this.idx=r,this.lowerIds=n,this.upperIds=i}function i(t,e,r,n){this.a=t,this.b=e,this.type=r,this.idx=n}function a(t,e){var r=t.a[0]-e.a[0]||t.a[1]-e.a[1]||t.type-e.type;return r?r:t.type!==p&&(r=d(t.a,t.b,e.b))?r:t.idx-e.idx}function o(t,e){return d(t.a,t.b,e)}function s(t,e,r,n,i){for(var a=h.lt(e,n,o),s=h.gt(e,n,o),l=a;s>l;++l){for(var c=e[l],u=c.lowerIds,f=u.length;f>1&&d(r[u[f-2]],r[u[f-1]],n)>0;)t.push([u[f-1],u[f-2],i]),f-=1;u.length=f,u.push(i);for(var p=c.upperIds,f=p.length;f>1&&d(r[p[f-2]],r[p[f-1]],n)<0;)t.push([p[f-2],p[f-1],i]),f-=1;p.length=f,p.push(i)}}function l(t,e){var r;return(r=t.a[0]f;++f)l.push(new i(t[f],null,p,f));for(var f=0;o>f;++f){var h=e[f],d=t[h[0]],m=t[h[1]];d[0]m[0]&&l.push(new i(m,d,v,f),new i(d,m,g,f))}l.sort(a);for(var y=l[0].a[0]-(1+Math.abs(l[0].a[0]))*Math.pow(2,-52),b=[new n([y,1],[y,0],-1,[],[],[],[])],x=[],f=0,_=l.length;_>f;++f){var w=l[f],k=w.type;k===p?s(x,b,t,w.a,w.idx):k===v?c(b,t,w):u(b,t,w)}return x}var h=t("binary-search-bounds"),d=t("robust-orientation")[3],p=0,g=1,v=2;e.exports=f},{"binary-search-bounds":62,"robust-orientation":259}],61:[function(t,e,r){"use strict";function n(t,e){this.stars=t,this.edges=e}function i(t,e,r){for(var n=1,i=t.length;i>n;n+=2)if(t[n-1]===e&&t[n]===r)return t[n-1]=t[i-2],t[n]=t[i-1],void(t.length=i-2)}function a(t,e){for(var r=new Array(t),i=0;t>i;++i)r[i]=[];return new n(r,e)}var o=t("binary-search-bounds");e.exports=a;var s=n.prototype;s.isConstraint=function(){function t(t,e){return t[0]-e[0]||t[1]-e[1]}var e=[0,0];return function(r,n){return e[0]=Math.min(r,n),e[1]=Math.max(r,n),o.eq(this.edges,e,t)>=0}}(),s.removeTriangle=function(t,e,r){var n=this.stars;i(n[t],e,r),i(n[e],r,t),i(n[r],t,e)},s.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},s.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;i>n;n+=2)if(r[n]===t)return r[n-1];return-1},s.flip=function(t,e){var r=this.opposite(t,e),n=this.opposite(e,t);this.removeTriangle(t,e,r),this.removeTriangle(e,t,n),this.addTriangle(t,n,r),this.addTriangle(e,r,n)},s.edges=function(){for(var t=this.stars,e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0,o=i.length;o>a;a+=2)e.push([i[a],i[a+1]]);return e},s.cells=function(){for(var t=this.stars,e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0,o=i.length;o>a;a+=2){var s=i[a],l=i[a+1];r>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],63:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-2,"]"].join("")}return e}function a(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",a(t.slice(0,e)),",",a(t.slice(e)),")"].join("")}function o(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return o(e,t)}function s(t){return t&!0?"-":""}function l(t){if(2===t.length)return[["diff(",o(t[0][0],t[1][1]),",",o(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;rn;++n)r.push(["prod(m",t,"[",n,"],m",t,"[",n,"])"].join(""));return a(r)}function u(t){for(var e=[],r=[],o=i(t),s=0;t>s;++s)o[0][s]="1",o[t-1][s]="w"+s;for(var s=0;t>s;++s)0===(1&s)?e.push.apply(e,l(n(o,s))):r.push.apply(r,l(n(o,s)));for(var u=a(e),f=a(r),h="exactInSphere"+t,d=[],s=0;t>s;++s)d.push("m"+s);for(var p=["function ",h,"(",d.join(),"){"],s=0;t>s;++s){p.push("var w",s,"=",c(s,t),";");for(var g=0;t>g;++g)g!==s&&p.push("var w",s,"m",g,"=scale(w",s,",m",g,"[0]);")}p.push("var p=",u,",n=",f,",d=diff(p,n);return d[d.length-1];}return ",h);var x=new Function("sum","diff","prod","scale",p.join(""));return x(m,y,v,b)}function f(){return 0}function h(){return 0}function d(){return 0}function p(t){var e=_[t.length];return e||(e=_[t.length]=u(t.length)),e.apply(void 0,t)}function g(){for(;_.length<=x;)_.push(u(_.length));for(var t=[],r=["slow"],n=0;x>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function testInSphere(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;x>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var v=t("two-product"),m=t("robust-sum"),y=t("robust-subtract"),b=t("robust-scale"),x=6,_=[f,h,d];g()},{"robust-scale":260,"robust-subtract":261,"robust-sum":262,"two-product":276}],64:[function(t,e,r){"use strict";function n(t){var e=x(t),r=b(y(e),t);return 0>r?[e,w(e,1/0)]:r>0?[w(e,-(1/0)),e]:[e,e]}function i(t,e){for(var r=new Array(e.length),n=0;n=t.length)return o[e-t.length];var r=t[e];return[y(r[0]),y(r[1])]}for(var o=[],s=0;s=0;--s){var g=n[s],c=g[0],v=e[c],m=v[0],x=v[1],w=t[m],A=t[x];if((w[0]-A[0]||w[1]-A[1])<0){var M=m;m=x,x=M}v[0]=m;var T,E=v[1]=g[1];for(i&&(T=v[2]);s>0&&n[s-1][0]===c;){var g=n[--s],L=g[1];i?e.push([E,L,T]):e.push([E,L]),E=L}i?e.push([E,x,T]):e.push([E,x])}return o}function c(t,e,r){for(var i=t.length+e.length,a=new g(i),o=r,s=0;ss;++s){var p=a.find(s);p===s?(d[s]=f,t[f++]=t[s]):(h=!1,d[s]=-1)}if(t.length=f,h)return null;for(var s=0;i>s;++s)d[s]<0&&(d[s]=d[a.find(s)]);return d}function u(t,e){return t[0]-e[0]||t[1]-e[1]}function f(t,e){var r=t[0]-e[0]||t[1]-e[1];return r?r:t[2]e[2]?1:0}function h(t,e,r){if(0!==t.length){if(e)for(var n=0;n0||d.length>0}function p(t,e,r){var n,i=!1;if(r){n=e;for(var a=new Array(e.length),o=0;o0?r=r.shln(f):0>f&&(u=u.shln(-f)),l(r,u)}var i=t("./is-rat"),a=t("./lib/is-bn"),o=t("./lib/num-to-bn"),s=t("./lib/str-to-bn"),l=t("./lib/rationalize"),c=t("./div");e.exports=n},{"./div":68,"./is-rat":70,"./lib/is-bn":74,"./lib/num-to-bn":75,"./lib/rationalize":76,"./lib/str-to-bn":77}],70:[function(t,e,r){"use strict";function n(t){return Array.isArray(t)&&2===t.length&&i(t[0])&&i(t[1])}var i=t("./lib/is-bn");e.exports=n},{"./lib/is-bn":74}],71:[function(t,e,r){"use strict";function n(t){return t.cmp(new i(0))}var i=t("bn.js");e.exports=n},{"bn.js":79}],72:[function(t,e,r){"use strict";function n(t){var e=t.length,r=t.words,n=0;if(1===e)n=r[0];else if(2===e)n=r[0]+67108864*r[1];else for(var n=0,i=0;e>i;i++){var a=r[i];n+=a*Math.pow(67108864,i)}return t.sign?-n:n}e.exports=n},{}],73:[function(t,e,r){"use strict";function n(t){var e=a(i.lo(t));if(32>e)return e;var r=a(i.hi(t));return r>20?52:r+32}var i=t("double-bits"),a=t("bit-twiddle").countTrailingZeros;e.exports=n},{"bit-twiddle":50,"double-bits":90}],74:[function(t,e,r){"use strict";function n(t){return t&&"object"==typeof t&&Boolean(t.words)}t("bn.js");e.exports=n},{"bn.js":79}],75:[function(t,e,r){"use strict";function n(t){var e=a.exponent(t);return 52>e?new i(t):new i(t*Math.pow(2,52-e)).shln(e-52)}var i=t("bn.js"),a=t("double-bits");e.exports=n},{"bn.js":79,"double-bits":90}],76:[function(t,e,r){"use strict";function n(t,e){var r=a(t),n=a(e);if(0===r)return[i(0),i(1)];if(0===n)return[i(0),i(0)];0>n&&(t=t.neg(),e=e.neg());var o=t.gcd(e);return o.cmpn(1)?[t.div(o),e.div(o)]:[t,e]}var i=t("./num-to-bn"),a=t("./bn-sign");e.exports=n},{"./bn-sign":71,"./num-to-bn":75}],77:[function(t,e,r){"use strict";function n(t){return new i(t)}var i=t("bn.js");e.exports=n},{"bn.js":79}],78:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[0]),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":76}],79:[function(t,e,r){!function(t,e){"use strict";function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){return null!==t&&"object"==typeof t&&Array.isArray(t.words)?t:(this.sign=!1,this.words=null,this.length=0,this.red=null,"le"!==e&&"be"!==e||(r=e,e=10),void(null!==t&&this._init(t||0,e||10,r||"be")))}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),a=e;i>a;a++){var o=t.charCodeAt(a)-48;n<<=4,n|=o>=49&&54>=o?o-49+10:o>=17&&22>=o?o-17+10:15&o}return n}function o(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;a>o;o++){var s=t.charCodeAt(o)-48;i*=n,i+=s>=49?s-49+10:s>=17?s-17+10:s}return i}function s(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).ishln(this.n).isub(this.p),this.tmp=this._tmp()}function l(){s.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function c(){s.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function u(){s.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function f(){s.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function h(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function d(t){h.call(this,t),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).ishln(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.sign=!0,this.minv=this.minv.mod(this.r)}"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26,i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&36>=e),t=t.toString().replace(/\s+/g,"");var i=0;"-"===t[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.sign=!0),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initNumber=function(t,e,n){0>t&&(this.sign=!0,t=-t),67108864>t?(this.words=[67108863&t],this.length=1):4503599627370496>t?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(9007199254740992>t),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3){var s=t[i]|t[i-1]<<8|t[i-2]<<16;this.words[o]|=s<>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}else if("le"===n)for(var i=0,o=0;i>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}return this.strip()},i.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6){var o=a(t,r,r+6);this.words[i]|=o<>>26-n&4194303,n+=24,n>=26&&(n-=26,i++)}if(r+6!==e){var o=a(t,e,r+6);this.words[i]|=o<>>26-n&4194303}this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;67108863>=i;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,s=a%n,l=Math.min(a,a-s)+r,c=0,u=r;l>u;u+=n)c=o(t,u,u+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){for(var f=1,c=o(t,u,t.length,e),u=0;s>u;u++)f*=e;this.imuln(f),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},i.prototype.inspect=function(){return(this.red?""};var p=["","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"],g=[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],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(t,e){if(t=t||10,16===t||"hex"===t){for(var n="",i=0,e=0|e||1,a=0,o=0;o>>24-i&16777215,n=0!==a||o!==this.length-1?p[6-l.length]+l+n:l+n,i+=2,i>=26&&(i-=26,o--)}for(0!==a&&(n=a.toString(16)+n);n.length%e!==0;)n="0"+n;return this.sign&&(n="-"+n),n}if(t===(0|t)&&t>=2&&36>=t){var c=g[t],u=v[t],n="",f=this.clone();for(f.sign=!1;0!==f.cmpn(0);){var h=f.modn(u).toString(t);f=f.idivn(u),n=0!==f.cmpn(0)?p[c-h.length]+h+n:h+n}return 0===this.cmpn(0)&&(n="0"+n),this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(t){this.strip();var e=new Array(this.byteLength());e[0]=0;var r=this.clone();if("le"!==t)for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[e.length-n-1]=i}else for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[n]=i}return e},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0===(8191&e)&&(r+=13,e>>>=13),0===(127&e)&&(r+=7,e>>>=7),0===(15&e)&&(r+=4,e>>>=4),0===(3&e)&&(r+=2,e>>>=2),0===(1&e)&&r++,r},i.prototype.bitLength=function(){var t=0,e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.iand=function(t){this.sign=this.sign&&t.sign;var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.ixor=function(t){this.sign=this.sign||t.sign;var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);for(var n=t/26|0,i=t%26;this.length<=n;)this.words[this.length++]=0;return e?this.words[n]=this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26}for(;0!==i&&a>>26}if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(t.sign){t.sign=!1;var e=this.iadd(t);return t.sign=!0,e._normSign()}if(this.sign)return this.sign=!1,this.iadd(t),this.sign=!0,this._normSign();var r=this.cmp(t);if(0===r)return this.sign=!1,this.length=1,this.words[0]=0,this;var n,i;r>0?(n=this,i=t):(n=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e}for(;0!==a&&o>26,this.words[o]=67108863&e}if(0===a&&o>>26,a=67108863&r,o=Math.min(n,t.length-1),s=Math.max(0,n-this.length+1);o>=s;s++){var l=n-s,c=0|this.words[l],u=0|t.words[s],f=c*u,h=67108863&f;i=i+(f/67108864|0)|0,h=h+a|0,a=67108863&h,i=i+(h>>>26)|0}e.words[n]=a,r=i}return 0!==r?e.words[n]=r:e.length--,e.strip()},i.prototype._bigMulTo=function(t,e){e.sign=t.sign!==this.sign,e.length=this.length+t.length;for(var r=0,n=0,i=0;i=l;l++){var c=i-l,u=0|this.words[c],f=0|t.words[l],h=u*f,d=67108863&h;a=a+(h/67108864|0)|0,d=d+o|0,o=67108863&d,a=a+(d>>>26)|0,n+=a>>>26,a&=67108863}e.words[i]=o,r=a,a=n}return 0!==r?e.words[i]=r:e.length--,e.strip()},i.prototype.mulTo=function(t,e){var r;return r=this.length+t.length<63?this._smallMulTo(t,e):this._bigMulTo(t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.imul=function(t){if(0===this.cmpn(0)||0===t.cmpn(0))return this.words[0]=0,this.length=1,this;var e=this.length,r=t.length;this.sign=t.sign!==this.sign,this.length=this.length+t.length,this.words[this.length-1]=0;for(var n=this.length-2;n>=0;n--){for(var i=0,a=0,o=Math.min(n,r-1),s=Math.max(0,n-e+1);o>=s;s++){var l=n-s,c=this.words[l],u=t.words[s],f=c*u,h=67108863&f;i+=f/67108864|0,h+=a,a=67108863&h,i+=h>>>26}this.words[n]=a,this.words[n+1]+=i,i=0}for(var i=0,l=1;l>>26}return this.strip()},i.prototype.imuln=function(t){r("number"==typeof t);for(var e=0,n=0;n>=26,e+=i/67108864|0,e+=a>>>26,this.words[n]=67108863&a}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.ishln=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=67108863>>>26-e<<26-e;if(0!==e){for(var a=0,o=0;o>>26-e}a&&(this.words[o]=a,this.length++)}if(0!==n){for(var o=this.length-1;o>=0;o--)this.words[o+n]=this.words[o];for(var o=0;n>o;o++)this.words[o]=0;this.length+=n}return this.strip()},i.prototype.ishrn=function(t,e,n){r("number"==typeof t&&t>=0);var i;i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<c;c++)l.words[c]=this.words[c];l.length=o}if(0===o);else if(this.length>o){this.length-=o;for(var c=0;c=0&&(0!==u||c>=i);c--){var f=this.words[c];this.words[c]=u<<26-a|f>>>a,u=f&s}return l&&0!==u&&(l.words[l.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<t?this.isubn(-t):this.sign?1===this.length&&this.words[0]=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),0>t)return this.iaddn(-t);if(this.sign)return this.sign=!1,this.iaddn(t),this.sign=!0,this;this.words[0]-=t;for(var e=0;e>26)-(c/67108864|0),this.words[i+n]=67108863&l}for(;i>26,this.words[i+n]=67108863&l}if(0===s)return this.strip();r(-1===s),s=0;for(var i=0;i>26,this.words[i]=67108863&l}return this.sign=!0,this.strip()},i.prototype._wordDiv=function(t,e){var r=this.length-t.length,n=this.clone(),a=t,o=a.words[a.length-1],s=this._countBits(o);r=26-s,0!==r&&(a=a.shln(r),n.ishln(r),o=a.words[a.length-1]);var l,c=n.length-a.length;if("mod"!==e){l=new i(null),l.length=c+1,l.words=new Array(l.length);for(var u=0;u=0;h--){var d=67108864*n.words[a.length+h]+n.words[a.length+h-1];for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(a,d,h);n.sign;)d--,n.sign=!1,n._ishlnsubmul(a,1,h),0!==n.cmpn(0)&&(n.sign=!n.sign);l&&(l.words[h]=d)}return l&&l.strip(),n.strip(),"div"!==e&&0!==r&&n.ishrn(r),{div:l?l:null,mod:n}},i.prototype.divmod=function(t,e){if(r(0!==t.cmpn(0)),this.sign&&!t.sign){var n,a,o=this.neg().divmod(t,e);return"mod"!==e&&(n=o.div.neg()),"div"!==e&&(a=0===o.mod.cmpn(0)?o.mod:t.sub(o.mod)),{div:n,mod:a}}if(!this.sign&&t.sign){var n,o=this.divmod(t.neg(),e);return"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}}return this.sign&&t.sign?this.neg().divmod(t.neg(),e):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e)},i.prototype.div=function(t){return this.divmod(t,"div").div},i.prototype.mod=function(t){return this.divmod(t,"mod").mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(0===e.mod.cmpn(0))return e.div;var r=e.div.sign?e.mod.isub(t):e.mod,n=t.shrn(1),i=t.andln(1),a=r.cmp(n);return 0>a||1===i&&0===a?e.div:e.div.sign?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(67108863>=t);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+this.words[i])%t;return n},i.prototype.idivn=function(t){r(67108863>=t);for(var e=0,n=this.length-1;n>=0;n--){var i=this.words[n]+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=new i(0),l=new i(1),c=0;e.isEven()&&n.isEven();)e.ishrn(1),n.ishrn(1),++c;for(var u=n.clone(),f=e.clone();0!==e.cmpn(0);){for(;e.isEven();)e.ishrn(1),a.isEven()&&o.isEven()?(a.ishrn(1),o.ishrn(1)):(a.iadd(u).ishrn(1),o.isub(f).ishrn(1));for(;n.isEven();)n.ishrn(1),s.isEven()&&l.isEven()?(s.ishrn(1),l.ishrn(1)):(s.iadd(u).ishrn(1),l.isub(f).ishrn(1));e.cmp(n)>=0?(e.isub(n),a.isub(s),o.isub(l)):(n.isub(e),s.isub(a),l.isub(o))}return{a:s,b:l,gcd:n.ishln(c)}},i.prototype._invmp=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(;e.isEven();)e.ishrn(1),a.isEven()?a.ishrn(1):a.iadd(s).ishrn(1);for(;n.isEven();)n.ishrn(1),o.isEven()?o.ishrn(1):o.iadd(s).ishrn(1);e.cmp(n)>=0?(e.isub(n),a.isub(o)):(n.isub(e),o.isub(a))}return 0===e.cmpn(1)?a:o},i.prototype.gcd=function(t){if(0===this.cmpn(0))return t.clone();if(0===t.cmpn(0))return this.clone();var e=this.clone(),r=t.clone();e.sign=!1,r.sign=!1;for(var n=0;e.isEven()&&r.isEven();n++)e.ishrn(1),r.ishrn(1);for(;;){for(;e.isEven();)e.ishrn(1);for(;r.isEven();)r.ishrn(1);var i=e.cmp(r);if(0>i){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.ishln(n)},i.prototype.invm=function(t){return this.egcd(t).a.mod(t)},i.prototype.isEven=function(){return 0===(1&this.words[0])},i.prototype.isOdd=function(){return 1===(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<a;a++)this.words[a]=0;return this.words[n]|=i,this.length=n+1,this}for(var o=i,a=n;0!==o&&a>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.cmpn=function(t){var e=0>t;if(e&&(t=-t),this.sign&&!e)return-1;if(!this.sign&&e)return 1;t&=67108863,this.strip();var r;if(this.length>1)r=1;else{var n=this.words[0];r=n===t?0:t>n?-1:1}return this.sign&&(r=-r),r},i.prototype.cmp=function(t){if(this.sign&&!t.sign)return-1;if(!this.sign&&t.sign)return 1;var e=this.ucmp(t);return this.sign?-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length=0;r--){var n=this.words[r],i=t.words[r];if(n!==i){i>n?e=-1:n>i&&(e=1);break}}return e},i.red=function(t){return new h(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};s.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},s.prototype.ireduce=function(t){var e,r=t;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),e=r.bitLength();while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},s.prototype.split=function(t,e){t.ishrn(this.n,0,e)},s.prototype.imulK=function(t){return t.imul(this.k)},n(l,s),l.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;n>i;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var a=t.words[9];e.words[e.length++]=a&r;for(var i=10;i>>22,a=o}t.words[i-10]=a>>>22,t.length-=9},l.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e,r=0,n=0;n>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function y(t){if(m[t])return m[t];var y;if("k256"===t)y=new l;else if("p224"===t)y=new c;else if("p192"===t)y=new u;else{if("p25519"!==t)throw new Error("Unknown prime "+t);y=new f}return m[t]=y,y},h.prototype._verify1=function(t){r(!t.sign,"red works only with positives"),r(t.red,"red works only with red numbers")},h.prototype._verify2=function(t,e){r(!t.sign&&!e.sign,"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},h.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.mod(this.m)._forceRed(this)},h.prototype.neg=function(t){var e=t.clone();return e.sign=!e.sign,e.iadd(this.m)._forceRed(this)},h.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},h.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},h.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},h.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},h.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.shln(e))},h.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},h.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},h.prototype.isqr=function(t){return this.imul(t,t)},h.prototype.sqr=function(t){return this.mul(t,t)},h.prototype.sqrt=function(t){if(0===t.cmpn(0))return t.clone();var e=this.m.andln(3);if(r(e%2===1),3===e){var n=this.m.add(new i(1)).ishrn(2),a=this.pow(t,n);return a}for(var o=this.m.subn(1),s=0;0!==o.cmpn(0)&&0===o.andln(1);)s++,o.ishrn(1);r(0!==o.cmpn(0));var l=new i(1).toRed(this),c=l.redNeg(),u=this.m.subn(1).ishrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,o),a=this.pow(t,o.addn(1).ishrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(l);){for(var g=d,v=0;0!==g.cmp(l);v++)g=g.redSqr();r(p>v);var m=this.pow(h,new i(1).ishln(p-v-1));a=a.redMul(m),h=m.redSqr(),d=d.redMul(h),p=v}return a},h.prototype.invm=function(t){var e=t._invmp(this.m);return e.sign?(e.sign=!1,this.imod(e).redNeg()):this.imod(e)},h.prototype.pow=function(t,e){var r=[];if(0===e.cmpn(0))return new i(1);for(var n=e.clone();0!==n.cmpn(0);)r.push(n.andln(1)),n.ishrn(1);for(var a=t,o=0;o=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},d.prototype.mul=function(t,e){if(0===t.cmpn(0)||0===e.cmpn(0))return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).ishrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},d.prototype.invm=function(t){var e=this.imod(t._invmp(this.m).mul(this.r2));return e._forceRed(this)}}("undefined"==typeof e||e,this)},{}],80:[function(t,e,r){"use strict";function n(t){return i(t[0])*i(t[1])}var i=t("./lib/bn-sign");e.exports=n},{"./lib/bn-sign":71}],81:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":76}],82:[function(t,e,r){"use strict";function n(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var n=e.divmod(r),o=n.div,s=i(o),l=n.mod;if(0===l.cmpn(0))return s;if(s){var c=a(s)+4,u=i(l.shln(c).divRound(r));return 0>s&&(u=-u),s+u*Math.pow(2,-c)}var f=r.bitLength()-l.bitLength()+53,u=i(l.shln(f).divRound(r));return 1023>f?u*Math.pow(2,-f):(u*=Math.pow(2,-1023),u*Math.pow(2,1023-f))}var i=t("./lib/bn-to-num"),a=t("./lib/ctz");e.exports=n},{"./lib/bn-to-num":72,"./lib/ctz":73}],83:[function(t,e,r){"use strict";function n(t,e){for(var r=0;t>r;++r)if(!(e[r]<=e[r+t]))return!0;return!1}function i(t,e,r,i){for(var a=0,o=0,s=0,l=t.length;l>s;++s){var c=t[s];if(!n(e,c)){for(var u=0;2*e>u;++u)r[a++]=c[u];i[o++]=s}}return o}function a(t,e,r,n){var a=t.length,o=e.length;if(!(0>=a||0>=o)){var s=t[0].length>>>1;if(!(0>=s)){var l,c=f.mallocDouble(2*s*a),u=f.mallocInt32(a);if(a=i(t,s,c,u),a>0){if(1===s&&n)h.init(a),l=h.sweepComplete(s,r,0,a,c,u,0,a,c,u);else{var p=f.mallocDouble(2*s*o),g=f.mallocInt32(o);o=i(e,s,p,g),o>0&&(h.init(a+o),l=1===s?h.sweepBipartite(s,r,0,a,c,u,0,o,p,g):d(s,r,n,a,c,u,o,p,g),f.free(p),f.free(g))}f.free(c),f.free(u)}return l}}}function o(t,e){u.push([t,e])}function s(t){return u=[],a(t,t,o,!0),u}function l(t,e){return u=[],a(t,e,o,!1),u}function c(t,e,r){switch(arguments.length){case 1:return s(t);case 2:return"function"==typeof e?a(t,t,e,!0):l(t,e);case 3:return a(t,e,r,!1);default:throw new Error("box-intersect: Invalid arguments")}}e.exports=c;var u,f=t("typedarray-pool"),h=t("./lib/sweep"),d=t("./lib/intersect")},{"./lib/intersect":85,"./lib/sweep":89,"typedarray-pool":278}],84:[function(t,e,r){"use strict";function n(t,e,r){var n="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),i=["function ",n,"(",w.join(),"){","var ",c,"=2*",a,";"],l="for(var i="+u+","+p+"="+c+"*"+u+";i<"+f+";++i,"+p+"+="+c+"){var x0="+h+"["+o+"+"+p+"],x1="+h+"["+o+"+"+p+"+"+a+"],xi="+d+"[i];",k="for(var j="+g+","+b+"="+c+"*"+g+";j<"+v+";++j,"+b+"+="+c+"){var y0="+m+"["+o+"+"+b+"],"+(r?"y1="+m+"["+o+"+"+b+"+"+a+"],":"")+"yi="+y+"[j];";return t?i.push(l,_,":",k):i.push(k,_,":",l),r?i.push("if(y1"+v+"-"+g+"){"),t?(e(!0,!1),o.push("}else{"),e(!1,!1)):(o.push("if("+l+"){"),e(!0,!0),o.push("}else{"),e(!0,!1),o.push("}}else{if("+l+"){"),e(!1,!0),o.push("}else{"),e(!1,!1),o.push("}")),o.push("}}return "+r);var s=i.join("")+o.join(""),c=new Function(s);return c()}var a="d",o="ax",s="vv",l="fp",c="es",u="rs",f="re",h="rb",d="ri",p="rp",g="bs",v="be",m="bb",y="bi",b="bp",x="rv",_="Q",w=[a,o,s,u,f,h,d,g,v,m,y];r.partial=i(!1),r.full=i(!0)},{}],85:[function(t,e,r){"use strict";function n(t,e){var r=8*c.log2(e+1)*(t+1)|0,n=c.nextPow2(M*r);L.lengthS&&(l.free(S),S=l.mallocDouble(i))}function i(t,e,r,n,i,a,o,s,l){var c=M*t;L[c]=e,L[c+1]=r,L[c+2]=n,L[c+3]=i,L[c+4]=a,L[c+5]=o;var u=T*t;S[u]=s,S[u+1]=l}function a(t,e,r,n,i,a,o,s,l,c,u){var f=2*t,h=l*f,d=c[h+e];t:for(var p=i,g=i*f;a>p;++p,g+=f){var v=o[g+e],m=o[g+e+t];if(!(v>d||d>m||n&&d===v)){for(var y=s[p],b=e+1;t>b;++b){var v=o[g+b],m=o[g+b+t],x=c[h+b],_=c[h+b+t];if(x>m||v>_)continue t}var w;if(w=n?r(u,y):r(y,u),void 0!==w)return w}}}function o(t,e,r,n,i,a,o,s,l,c){var u=2*t,f=s*u,h=l[f+e];t:for(var d=n,p=n*u;i>d;++d,p+=u){var g=o[d];if(g!==c){var v=a[p+e],m=a[p+e+t];if(!(v>h||h>m)){for(var y=e+1;t>y;++y){var v=a[p+y],m=a[p+y+t],b=l[f+y],x=l[f+y+t];if(b>m||v>x)continue t}var _=r(g,c);if(void 0!==_)return _}}}}function s(t,e,r,s,l,c,u,g,E){n(t,s+u);var C,z=0,P=2*t;for(i(z++,0,0,s,0,u,r?16:0,-(1/0),1/0),r||i(z++,0,0,u,0,s,1,-(1/0),1/0);z>0;){z-=1;var R=z*M,O=L[R],I=L[R+1],N=L[R+2],j=L[R+3],F=L[R+4],D=L[R+5],B=z*T,U=S[B],V=S[B+1],q=1&D,H=!!(16&D),G=l,Y=c,X=g,W=E;if(q&&(G=g,Y=E,X=l,W=c),!(2&D&&(N=_(t,O,I,N,G,Y,V),I>=N)||4&D&&(I=w(t,O,I,N,G,Y,U),I>=N))){var Z=N-I,K=F-j;if(H){if(y>t*Z*(Z+K)){if(C=d.scanComplete(t,O,e,I,N,G,Y,j,F,X,W),void 0!==C)return C;continue}}else{if(t*Math.min(Z,K)t*Z*K){if(C=d.scanBipartite(t,O,e,q,I,N,G,Y,j,F,X,W),void 0!==C)return C;continue}}var $=b(t,O,I,N,G,Y,U,V);if($>I)if(v>t*($-I)){if(C=h(t,O+1,e,I,$,G,Y,j,F,X,W),void 0!==C)return C}else if(O===t-2){if(C=q?d.sweepBipartite(t,e,j,F,X,W,I,$,G,Y):d.sweepBipartite(t,e,I,$,G,Y,j,F,X,W),void 0!==C)return C}else i(z++,O+1,I,$,j,F,q,-(1/0),1/0),i(z++,O+1,j,F,I,$,1^q,-(1/0),1/0);if(N>$){var Q=p(t,O,j,F,X,W),J=X[P*Q+O],tt=x(t,O,Q,F,X,W,J);if(F>tt&&i(z++,O,$,N,tt,F,(4|q)+(H?16:0),J,V),Q>j&&i(z++,O,$,N,j,Q,(2|q)+(H?16:0),U,J),Q+1===tt){if(C=H?o(t,O,e,$,N,G,Y,Q,X,W[Q]):a(t,O,e,q,$,N,G,Y,Q,X,W[Q]),void 0!==C)return C}else if(tt>Q){var et;if(H){if(et=k(t,O,$,N,G,Y,J),et>$){var rt=x(t,O,$,et,G,Y,J);if(O===t-2){if(rt>$&&(C=d.sweepComplete(t,e,$,rt,G,Y,Q,tt,X,W),void 0!==C))return C;if(et>rt&&(C=d.sweepBipartite(t,e,rt,et,G,Y,Q,tt,X,W),void 0!==C))return C}else rt>$&&i(z++,O+1,$,rt,Q,tt,16,-(1/0),1/0),et>rt&&(i(z++,O+1,rt,et,Q,tt,0,-(1/0),1/0),i(z++,O+1,Q,tt,rt,et,1,-(1/0),1/0))}}else et=q?A(t,O,$,N,G,Y,J):k(t,O,$,N,G,Y,J),et>$&&(O===t-2?C=q?d.sweepBipartite(t,e,Q,tt,X,W,$,et,G,Y):d.sweepBipartite(t,e,$,et,G,Y,Q,tt,X,W):(i(z++,O+1,$,et,Q,tt,q,-(1/0),1/0),i(z++,O+1,Q,tt,$,et,1^q,-(1/0),1/0)))}}}}}e.exports=s;var l=t("typedarray-pool"),c=t("bit-twiddle"),u=t("./brute"),f=u.partial,h=u.full,d=t("./sweep"),p=t("./median"),g=t("./partition"),v=128,m=1<<22,y=1<<22,b=g("!(lo>=p0)&&!(p1>=hi)",["p0","p1"]),x=g("lo===p0",["p0"]),_=g("lol;++l,s+=o)for(var c=i[s],u=l,f=o*(l-1);u>r&&i[f+e]>c;--u,f-=o){for(var h=f,d=f+o,p=0;o>p;++p,++h,++d){var g=i[h];i[h]=i[d],i[d]=g}var v=a[u];a[u]=a[u-1],a[u-1]=v}}function i(t,e,r,i,a,l){if(r+1>=i)return r;for(var c=r,u=i,f=i+r>>>1,h=2*t,d=f,p=a[h*f+e];u>c;){if(s>u-c){n(t,e,c,u,a,l),p=a[h*f+e];break}var g=u-c,v=Math.random()*g+c|0,m=a[h*v+e],y=Math.random()*g+c|0,b=a[h*y+e],x=Math.random()*g+c|0,_=a[h*x+e];b>=m?_>=b?(d=y,p=b):m>=_?(d=v,p=m):(d=x,p=_):b>=_?(d=y,p=b):_>=m?(d=v,p=m):(d=x,p=_);for(var w=h*(u-1),k=h*d,A=0;h>A;++A,++w,++k){var M=a[w];a[w]=a[k],a[k]=M}var T=l[u-1];l[u-1]=l[d],l[d]=T,d=o(t,e,c,u-1,a,l,p);for(var w=h*(u-1),k=h*d,A=0;h>A;++A,++w,++k){var M=a[w];a[w]=a[k],a[k]=M}var T=l[u-1];if(l[u-1]=l[d],l[d]=T,d>f){for(u=d-1;u>c&&a[h*(u-1)+e]===p;)u-=1;u+=1}else{if(!(f>d))break;for(c=d+1;u>c&&a[h*c+e]===p;)c+=1}}return o(t,e,r,f,a,l,a[h*f+e])}e.exports=i;var a=t("./partition"),o=a("lo=0&&n.push("lo=e[k+n]"),t.indexOf("hi")>=0&&n.push("hi=e[k+o]"),r.push(i.replace("_",n.join()).replace("$",t)),Function.apply(void 0,r)}e.exports=n;var i="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 _;if($)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"},{}],88:[function(t,e,r){"use strict";function n(t,e){4*h>=e?i(0,e-1,t):f(0,e-1,t)}function i(t,e,r){for(var n=2*(t+1),i=t+1;e>=i;++i){for(var a=r[n++],o=r[n++],s=i,l=n-2;s-- >t;){var c=r[l-2],u=r[l-1];if(a>c)break;if(c===a&&o>u)break;r[l]=c,r[l+1]=u,l-=2}r[l]=a,r[l+1]=o}}function a(t,e,r){t*=2,e*=2;var n=r[t],i=r[t+1];r[t]=r[e],r[t+1]=r[e+1],r[e]=n,r[e+1]=i}function o(t,e,r){t*=2,e*=2,r[t]=r[e],r[t+1]=r[e+1]}function s(t,e,r,n){t*=2,e*=2,r*=2;var i=n[t],a=n[t+1];n[t]=n[e],n[t+1]=n[e+1],n[e]=n[r],n[e+1]=n[r+1],n[r]=i,n[r+1]=a}function l(t,e,r,n,i){t*=2,e*=2,i[t]=i[e],i[e]=r,i[t+1]=i[e+1],i[e+1]=n}function c(t,e,r){t*=2,e*=2;var n=r[t],i=r[e];return i>n?!1:n===i?r[t+1]>r[e+1]:!0}function u(t,e,r,n){t*=2;var i=n[t];return e>i?!0:i===e?n[t+1]>1,v=g-n,m=g+n,y=d,b=v,x=g,_=m,w=p,k=t+1,A=e-1,M=0;c(y,b,r)&&(M=y,y=b,b=M),c(_,w,r)&&(M=_,_=w,w=M),c(y,x,r)&&(M=y,y=x,x=M),c(b,x,r)&&(M=b,b=x,x=M),c(y,_,r)&&(M=y,y=_,_=M),c(x,_,r)&&(M=x,x=_,_=M),c(b,w,r)&&(M=b,b=w,w=M),c(b,x,r)&&(M=b,b=x,x=M),c(_,w,r)&&(M=_,_=w,w=M);for(var T=r[2*b],E=r[2*b+1],L=r[2*_],S=r[2*_+1],C=2*y,z=2*x,P=2*w,R=2*d,O=2*g,I=2*p,N=0;2>N;++N){var j=r[C+N],F=r[z+N],D=r[P+N];r[R+N]=j,r[O+N]=F,r[I+N]=D}o(v,t,r),o(m,e,r);for(var B=k;A>=B;++B)if(u(B,T,E,r))B!==k&&a(B,k,r),++k;else if(!u(B,L,S,r))for(;;){if(u(A,L,S,r)){u(A,T,E,r)?(s(B,k,A,r),++k,--A):(a(B,A,r),--A);break}if(--A=k-2-t?i(t,k-2,r):f(t,k-2,r),h>=e-(A+2)?i(A+2,e,r):f(A+2,e,r),h>=A-k?i(k,A,r):f(k,A,r)}e.exports=n;var h=32},{}],89:[function(t,e,r){"use strict";function n(t){var e=f.nextPow2(t);g.lengthk;++k){var A=s[k],M=b*k;_[p++]=o[M+x],_[p++]=-(A+1),_[p++]=o[M+w],_[p++]=A}for(var k=l;c>k;++k){var A=f[k]+d,T=b*k;_[p++]=u[T+x],_[p++]=-A,_[p++]=u[T+w],_[p++]=A}var E=p>>>1;h(_,E);for(var L=0,S=0,k=0;E>k;++k){var C=0|_[2*k+1];if(C>=d)C=C-d|0,i(m,y,S--,C);else if(C>=0)i(g,v,L--,C);else if(-d>=C){C=-C-d|0;for(var z=0;L>z;++z){var P=e(g[z],C);if(void 0!==P)return P}a(m,y,S++,C)}else{C=-C-1|0;for(var z=0;S>z;++z){var P=e(C,m[z]);if(void 0!==P)return P}a(g,v,L++,C)}}}function s(t,e,r,n,o,s,l,c,u,f){for(var d=0,p=2*t,w=t-1,k=p-1,A=r;n>A;++A){var M=s[A]+1<<1,T=p*A;_[d++]=o[T+w],_[d++]=-M,_[d++]=o[T+k],_[d++]=M}for(var A=l;c>A;++A){var M=f[A]+1<<1,E=p*A;_[d++]=u[E+w],_[d++]=1|-M,_[d++]=u[E+k],_[d++]=1|M}var L=d>>>1;h(_,L);for(var S=0,C=0,z=0,A=0;L>A;++A){var P=0|_[2*A+1],R=1&P;if(L-1>A&&P>>1===_[2*A+3]>>1&&(R=2,A+=1),0>P){for(var O=-(P>>1)-1,I=0;z>I;++I){var N=e(b[I],O);if(void 0!==N)return N}if(0!==R)for(var I=0;S>I;++I){var N=e(g[I],O);if(void 0!==N)return N}if(1!==R)for(var I=0;C>I;++I){var N=e(m[I],O);if(void 0!==N)return N}0===R?a(g,v,S++,O):1===R?a(m,y,C++,O):2===R&&a(b,x,z++,O)}else{var O=(P>>1)-1;0===R?i(g,v,S--,O):1===R?i(m,y,C--,O):2===R&&i(b,x,z--,O)}}}function l(t,e,r,n,o,s,l,c,u,f,p,m){var y=0,b=2*t,x=e,w=e+t,k=1,A=1;n?A=d:k=d;for(var M=o;s>M;++M){var T=M+k,E=b*M;_[y++]=l[E+x],_[y++]=-T,_[y++]=l[E+w],_[y++]=T}for(var M=u;f>M;++M){var T=M+A,L=b*M;_[y++]=p[L+x],_[y++]=-T}var S=y>>>1;h(_,S);for(var C=0,M=0;S>M;++M){var z=0|_[2*M+1];if(0>z){var T=-z,P=!1;if(T>=d?(P=!n,T-=d):(P=!!n,T-=1),P)a(g,v,C++,T);else{var R=m[T],O=b*T,I=p[O+e+1],N=p[O+e+1+t];t:for(var j=0;C>j;++j){var F=g[j],D=b*F;if(!(NB;++B)if(p[O+B+t]y;++y){var b=y+d,x=p*y;_[f++]=a[x+v],_[f++]=-b,_[f++]=a[x+m],_[f++]=b}for(var y=s;l>y;++y){var b=y+1,w=p*y;_[f++]=c[w+v],_[f++]=-b}var k=f>>>1;h(_,k);for(var A=0,y=0;k>y;++y){var M=0|_[2*y+1];if(0>M){var b=-M;if(b>=d)g[A++]=b-d;else{b-=1;var T=u[b],E=p*b,L=c[E+e+1],S=c[E+e+1+t];t:for(var C=0;A>C;++C){var z=g[C],P=o[z];if(P===T)break;var R=p*z;if(!(SO;++O)if(c[E+O+t]=0;--C)if(g[C]===b){for(var O=C+1;A>O;++O)g[O-1]=g[O];break}--A}}}e.exports={init:n,sweepBipartite:o,sweepComplete:s,scanBipartite:l,scanComplete:c};var u=t("typedarray-pool"),f=t("bit-twiddle"),h=t("./sort"),d=1<<28,p=1024,g=u.mallocInt32(p),v=u.mallocInt32(p),m=u.mallocInt32(p),y=u.mallocInt32(p),b=u.mallocInt32(p),x=u.mallocInt32(p),_=u.mallocDouble(8*p)},{"./sort":88,"bit-twiddle":50,"typedarray-pool":278}],90:[function(t,e,r){(function(t){function r(t,e){return d[0]=t,d[1]=e,h[0]}function n(t){return h[0]=t,d[0]}function i(t){return h[0]=t,d[1]}function a(t,e){return d[1]=t,d[0]=e,h[0]}function o(t){return h[0]=t,d[1]}function s(t){return h[0]=t,d[0]}function l(t,e){return p.writeUInt32LE(t,0,!0),p.writeUInt32LE(e,4,!0),p.readDoubleLE(0,!0)}function c(t){return p.writeDoubleLE(t,0,!0),p.readUInt32LE(0,!0)}function u(t){return p.writeDoubleLE(t,0,!0),p.readUInt32LE(4,!0)}var f=!1;if("undefined"!=typeof Float64Array){var h=new Float64Array(1),d=new Uint32Array(h.buffer);h[0]=1,f=!0,1072693248===d[1]?(e.exports=function(t){return h[0]=t,[d[0],d[1]]},e.exports.pack=r,e.exports.lo=n,e.exports.hi=i):1072693248===d[0]?(e.exports=function(t){return h[0]=t, +[d[1],d[0]]},e.exports.pack=a,e.exports.lo=o,e.exports.hi=s):f=!1}if(!f){var p=new t(8);e.exports=function(t){return p.writeDoubleLE(t,0,!0),[p.readUInt32LE(0,!0),p.readUInt32LE(4,!0)]},e.exports.pack=l,e.exports.lo=c,e.exports.hi=u}e.exports.sign=function(t){return e.exports.hi(t)>>>31},e.exports.exponent=function(t){var r=e.exports.hi(t);return(r<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){var r=e.exports.hi(t);return!(2146435072&r)}}).call(this,t("buffer").Buffer)},{buffer:51}],91:[function(t,e,r){"use strict";function n(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return 0>e?-a:a;var r=i.hi(t),n=i.lo(t);return e>t==t>0?n===o?(r+=1,n=0):n+=1:0===n?(n=o,r-=1):n-=1,i.pack(n,r)}var i=t("double-bits"),a=Math.pow(2,-1074),o=-1>>>0;e.exports=n},{"double-bits":90}],92:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),a=0;r>a;++a)n[a]=i(t[a],e[a]);return n}var i=t("big-rat/add");e.exports=n},{"big-rat/add":66}],93:[function(t,e,r){"use strict";function n(t){for(var e=new Array(t.length),r=0;rs;++s)o[s]=a(t[s],r);return o}var i=t("big-rat"),a=t("big-rat/mul");e.exports=n},{"big-rat":69,"big-rat/mul":78}],95:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),a=0;r>a;++a)n[a]=i(t[a],e[a]);return n}var i=t("big-rat/sub");e.exports=n},{"big-rat/sub":81}],96:[function(t,e,r){"use strict";function n(t,e,r,n){for(var i=0;2>i;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),c=r[i],u=n[i],f=Math.min(c,u),h=Math.max(c,u);if(s>h||f>l)return!1}return!0}function i(t,e,r,i){var o=a(t,r,i),s=a(e,r,i);if(o>0&&s>0||0>o&&0>s)return!1;var l=a(r,t,e),c=a(i,t,e);return l>0&&c>0||0>l&&0>c?!1:0===o&&0===s&&0===l&&0===c?n(t,e,r,i):!0}e.exports=i;var a=t("robust-orientation")[3]},{"robust-orientation":259}],97:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;t>e;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n;var i=n.prototype;Object.defineProperty(i,"length",{get:function(){return this.roots.length}}),i.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},i.find=function(t){for(var e=t,r=this.roots;r[t]!==t;)t=r[t];for(;r[e]!==t;){var n=r[e];r[e]=t,e=n}return t},i.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],98:[function(t,e,r){(function(t){var r=function(){"use strict";function e(r,n,i,a){function s(r,i){if(null===r)return null;if(0==i)return r;var l,h;if("object"!=typeof r)return r;if(e.__isArray(r))l=[];else if(e.__isRegExp(r))l=new RegExp(r.source,o(r)),r.lastIndex&&(l.lastIndex=r.lastIndex);else if(e.__isDate(r))l=new Date(r.getTime());else{if(f&&t.isBuffer(r))return l=new t(r.length),r.copy(l),l;"undefined"==typeof a?(h=Object.getPrototypeOf(r),l=Object.create(h)):(l=Object.create(a),h=a)}if(n){var d=c.indexOf(r);if(-1!=d)return u[d];c.push(r),u.push(l)}for(var p in r){var g;h&&(g=Object.getOwnPropertyDescriptor(h,p)),g&&null==g.set||(l[p]=s(r[p],i-1))}return l}var l;"object"==typeof n&&(i=n.depth,a=n.prototype,l=n.filter,n=n.circular);var c=[],u=[],f="undefined"!=typeof t;return"undefined"==typeof n&&(n=!0),"undefined"==typeof i&&(i=1/0),s(r,i)}function r(t){return Object.prototype.toString.call(t)}function n(t){return"object"==typeof t&&"[object Date]"===r(t)}function i(t){return"object"==typeof t&&"[object Array]"===r(t)}function a(t){return"object"==typeof t&&"[object RegExp]"===r(t)}function o(t){var e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),e}return e.clonePrototype=function(t){if(null===t)return null;var e=function(){};return e.prototype=t,new e},e.__objToStr=r,e.__isDate=n,e.__isArray=i,e.__isRegExp=a,e.__getRegExpFlags=o,e}();"object"==typeof e&&e.exports&&(e.exports=r)}).call(this,t("buffer").Buffer)},{buffer:51}],99:[function(t,e,r){e.exports={jet:[{index:0,rgb:[0,0,131]},{index:.125,rgb:[0,60,170]},{index:.375,rgb:[5,255,255]},{index:.625,rgb:[255,255,0]},{index:.875,rgb:[250,0,0]},{index:1,rgb:[128,0,0]}],hsv:[{index:0,rgb:[255,0,0]},{index:.169,rgb:[253,255,2]},{index:.173,rgb:[247,255,2]},{index:.337,rgb:[0,252,4]},{index:.341,rgb:[0,252,10]},{index:.506,rgb:[1,249,255]},{index:.671,rgb:[2,0,253]},{index:.675,rgb:[8,0,253]},{index:.839,rgb:[255,0,251]},{index:.843,rgb:[255,0,245]},{index:1,rgb:[255,0,6]}],hot:[{index:0,rgb:[0,0,0]},{index:.3,rgb:[230,0,0]},{index:.6,rgb:[255,210,0]},{index:1,rgb:[255,255,255]}],cool:[{index:0,rgb:[0,255,255]},{index:1,rgb:[255,0,255]}],spring:[{index:0,rgb:[255,0,255]},{index:1,rgb:[255,255,0]}],summer:[{index:0,rgb:[0,128,102]},{index:1,rgb:[255,255,102]}],autumn:[{index:0,rgb:[255,0,0]},{index:1,rgb:[255,255,0]}],winter:[{index:0,rgb:[0,0,255]},{index:1,rgb:[0,255,128]}],bone:[{index:0,rgb:[0,0,0]},{index:.376,rgb:[84,84,116]},{index:.753,rgb:[169,200,200]},{index:1,rgb:[255,255,255]}],copper:[{index:0,rgb:[0,0,0]},{index:.804,rgb:[255,160,102]},{index:1,rgb:[255,199,127]}],greys:[{index:0,rgb:[0,0,0]},{index:1,rgb:[255,255,255]}],yignbu:[{index:0,rgb:[8,29,88]},{index:.125,rgb:[37,52,148]},{index:.25,rgb:[34,94,168]},{index:.375,rgb:[29,145,192]},{index:.5,rgb:[65,182,196]},{index:.625,rgb:[127,205,187]},{index:.75,rgb:[199,233,180]},{index:.875,rgb:[237,248,217]},{index:1,rgb:[255,255,217]}],greens:[{index:0,rgb:[0,68,27]},{index:.125,rgb:[0,109,44]},{index:.25,rgb:[35,139,69]},{index:.375,rgb:[65,171,93]},{index:.5,rgb:[116,196,118]},{index:.625,rgb:[161,217,155]},{index:.75,rgb:[199,233,192]},{index:.875,rgb:[229,245,224]},{index:1,rgb:[247,252,245]}],yiorrd:[{index:0,rgb:[128,0,38]},{index:.125,rgb:[189,0,38]},{index:.25,rgb:[227,26,28]},{index:.375,rgb:[252,78,42]},{index:.5,rgb:[253,141,60]},{index:.625,rgb:[254,178,76]},{index:.75,rgb:[254,217,118]},{index:.875,rgb:[255,237,160]},{index:1,rgb:[255,255,204]}],bluered:[{index:0,rgb:[0,0,255]},{index:1,rgb:[255,0,0]}],rdbu:[{index:0,rgb:[5,10,172]},{index:.35,rgb:[106,137,247]},{index:.5,rgb:[190,190,190]},{index:.6,rgb:[220,170,132]},{index:.7,rgb:[230,145,90]},{index:1,rgb:[178,10,28]}],picnic:[{index:0,rgb:[0,0,255]},{index:.1,rgb:[51,153,255]},{index:.2,rgb:[102,204,255]},{index:.3,rgb:[153,204,255]},{index:.4,rgb:[204,204,255]},{index:.5,rgb:[255,255,255]},{index:.6,rgb:[255,204,255]},{index:.7,rgb:[255,153,255]},{index:.8,rgb:[255,102,204]},{index:.9,rgb:[255,102,102]},{index:1,rgb:[255,0,0]}],rainbow:[{index:0,rgb:[150,0,90]},{index:.125,rgb:[0,0,200]},{index:.25,rgb:[0,25,255]},{index:.375,rgb:[0,152,255]},{index:.5,rgb:[44,255,150]},{index:.625,rgb:[151,255,0]},{index:.75,rgb:[255,234,0]},{index:.875,rgb:[255,111,0]},{index:1,rgb:[255,0,0]}],portland:[{index:0,rgb:[12,51,131]},{index:.25,rgb:[10,136,186]},{index:.5,rgb:[242,211,56]},{index:.75,rgb:[242,143,56]},{index:1,rgb:[217,30,30]}],blackbody:[{index:0,rgb:[0,0,0]},{index:.2,rgb:[230,0,0]},{index:.4,rgb:[230,210,0]},{index:.7,rgb:[255,255,255]},{index:1,rgb:[160,200,255]}],earth:[{index:0,rgb:[0,0,130]},{index:.1,rgb:[0,180,180]},{index:.2,rgb:[40,210,40]},{index:.4,rgb:[230,230,50]},{index:.6,rgb:[120,70,20]},{index:1,rgb:[255,255,255]}],electric:[{index:0,rgb:[0,0,0]},{index:.15,rgb:[30,0,100]},{index:.4,rgb:[120,0,100]},{index:.6,rgb:[160,90,0]},{index:.8,rgb:[230,200,0]},{index:1,rgb:[255,250,220]}],alpha:[{index:0,rgb:[255,255,255,0]},{index:0,rgb:[255,255,255,1]}]}},{}],100:[function(t,e,r){"use strict";function n(t){for(var e,r="#",n=0;3>n;++n)e=t[n],e=e.toString(16),r+=("00"+e).substr(e.length);return r}function i(t){return"rgba("+t.join(",")+")"}var a=t("arraytools"),o=t("clone"),s=t("./colorScales");e.exports=function(t){var e,r,l,c,u,f,h,d,p,g,v,m,y,b=[],x=[],_=[],w=[];if(a.isPlainObject(t)||(t={}),p=t.nshades||72,d=t.format||"hex",h=t.colormap,h||(h="jet"),"string"==typeof h){if(h=h.toLowerCase(),!s[h])throw Error(h+" not a supported colorscale");f=o(s[h])}else{if(!Array.isArray(h))throw Error("unsupported colormap option",h);f=o(h)}if(f.length>p)throw new Error(h+" map requires nshades to be at least size "+f.length);for(v=Array.isArray(t.alpha)?2!==t.alpha.length?[1,1]:o(t.alpha):"number"==typeof t.alpha?[t.alpha,t.alpha]:[1,1],e=f.map(function(t){return Math.round(t.index*p)}),v[0]<0&&(v[0]=0),v[1]<0&&(v[0]=0),v[0]>1&&(v[0]=1),v[1]>1&&(v[0]=1),y=0;y=0&&r[3]<=1||(r[3]=v[0]+(v[1]-v[0])*m);for(y=0;yx;++x)if(i=y[x]-b[x])return i;return 0}}e.exports=i;var a=Math.min},{}],102:[function(t,e,r){"use strict";function n(t){var e=t.length;if(0===e)return[];if(1===e)return[[0]];var r=t[0].length;return 0===r?[]:1===r?i(t):2===r?a(t):o(t,r)}var i=t("./lib/ch1d"),a=t("./lib/ch2d"),o=t("./lib/chnd");e.exports=n},{"./lib/ch1d":103,"./lib/ch2d":104,"./lib/chnd":105}],103:[function(t,e,r){"use strict";function n(t){for(var e=0,r=0,n=1;nt[r][0]&&(r=n);return r>e?[[e],[r]]:e>r?[[r],[e]]:[[e]]}e.exports=n},{}],104:[function(t,e,r){"use strict";function n(t){var e=i(t),r=e.length;if(2>=r)return[];for(var n=new Array(r),a=e[r-1],o=0;r>o;++o){var s=e[o];n[o]=[a,s],a=s}return n}e.exports=n;var i=t("monotone-convex-hull-2d")},{"monotone-convex-hull-2d":107}],105:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),i=0;ii;++i)e.indexOf(i)<0&&(n[a++]=t[i]);return n}function i(t,e){for(var r=t.length,n=e.length,i=0;r>i;++i)for(var a=t[i],o=0;os)a[o]=e[s];else{s-=n;for(var l=0;n>l;++l)s>=e[l]&&(s+=1);a[o]=s}}return t}function a(t,e){try{return o(t,!0)}catch(r){var a=s(t);if(a.length<=e)return[];var l=n(t,a),c=o(l,!0);return i(c,a)}}e.exports=a;var o=t("incremental-convex-hull"),s=t("affine-hull")},{"affine-hull":106,"incremental-convex-hull":235}],106:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(e+1),n=0;n=i;++i){for(var o=new Array(e),s=0;e>s;++s)o[s]=Math.pow(i+1-n,s);r[i]=o}var l=a.apply(void 0,r);if(l)return!0}return!1}function i(t){var e=t.length;if(0===e)return[];if(1===e)return[0];for(var r=t[0].length,i=[t[0]],a=[0],o=1;e>o;++o)if(i.push(t[o]),n(i,r)){if(a.push(o),a.length===r+1)return a}else i.pop();return a}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":259}],107:[function(t,e,r){"use strict";function n(t){var e=t.length;if(3>e){for(var r=new Array(e),n=0;e>n;++n)r[n]=n;return 2===e&&t[0][0]===t[1][0]&&t[0][1]===t[1][1]?[0]:r}for(var a=new Array(e),n=0;e>n;++n)a[n]=n;a.sort(function(e,r){var n=t[e][0]-t[r][0];return n?n:t[e][1]-t[r][1]});for(var o=[a[0],a[1]],s=[a[0],a[1]],n=2;e>n;++n){for(var l=a[n],c=t[l],u=o.length;u>1&&i(t[o[u-2]],t[o[u-1]],c)<=0;)u-=1,o.pop();for(o.push(l),u=s.length;u>1&&i(t[s[u-2]],t[s[u-1]],c)>=0;)u-=1,s.pop();s.push(l)}for(var r=new Array(s.length+o.length-2),f=0,n=0,h=o.length;h>n;++n)r[f++]=o[n];for(var d=s.length-2;d>0;--d)r[f++]=s[d];return r}e.exports=n;var i=t("robust-orientation")[3]},{"robust-orientation":259}],108:[function(t,e,r){e.exports={AFG:"afghan",ALA:"\\b\\wland",ALB:"albania",DZA:"algeria",ASM:"^(?=.*americ).*samoa",AND:"andorra",AGO:"angola",AIA:"anguill?a",ATA:"antarctica",ATG:"antigua",ARG:"argentin",ARM:"armenia",ABW:"^(?!.*bonaire).*\\baruba",AUS:"australia",AUT:"^(?!.*hungary).*austria|\\baustri.*\\bemp",AZE:"azerbaijan",BHS:"bahamas",BHR:"bahrain",BGD:"bangladesh|^(?=.*east).*paki?stan",BRB:"barbados",BLR:"belarus|byelo",BEL:"^(?!.*luxem).*belgium",BLZ:"belize|^(?=.*british).*honduras",BEN:"benin|dahome",BMU:"bermuda",BTN:"bhutan",BOL:"bolivia",BES:"^(?=.*bonaire).*eustatius|^(?=.*carib).*netherlands|\\bbes.?islands",BIH:"herzegovina|bosnia",BWA:"botswana|bechuana",BVT:"bouvet",BRA:"brazil",IOT:"british.?indian.?ocean",BRN:"brunei",BGR:"bulgaria",BFA:"burkina|\\bfaso|upper.?volta",BDI:"burundi",KHM:"cambodia|kampuchea|khmer",CMR:"cameroon",CAN:"canada",CPV:"verde",CYM:"cayman",CAF:"\\bcentral.african.republic",TCD:"\\bchad",CHL:"\\bchile",CHN:"^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai).*china",CXR:"christmas",CCK:"\\bcocos|keeling",COL:"colombia",COM:"comoro",COD:"\\bdem.*congo|congo.*\\bdem|congo.*\\bdr|\\bdr.*congo|belgian.?congo|congo.?free.?state|kinshasa|zaire|l.opoldville|drc|droc|rdc",COG:"^(?!.*\\bdem)(?!.*\\bdr)(?!.*kinshasa)(?!.*zaire)(?!.*belg)(?!.*l.opoldville)(?!.*free).*\\bcongo",COK:"\\bcook",CRI:"costa.?rica",CIV:"ivoire|ivory",HRV:"croatia",CUB:"\\bcuba",CUW:"^(?!.*bonaire).*\\bcura(c|\xe7)ao",CYP:"cyprus",CZE:"^(?=.*rep).*czech|czechia|bohemia",CSK:"czechoslovakia",DNK:"denmark",DJI:"djibouti",DMA:"dominica(?!n)",DOM:"dominican.rep",ECU:"ecuador",EGY:"egypt",SLV:"el.?salvador",GNQ:"guine.*eq|eq.*guine|^(?=.*span).*guinea",ERI:"eritrea",EST:"estonia",ETH:"ethiopia|abyssinia",FLK:"falkland|malvinas",FRO:"faroe|faeroe",FJI:"fiji",FIN:"finland",FRA:"^(?!.*\\bdep)(?!.*martinique).*france|french.?republic|\\bgaul",GUF:"^(?=.*french).*guiana",PYF:"french.?polynesia|tahiti",ATF:"french.?southern",GAB:"gabon",GMB:"gambia",GEO:"^(?!.*south).*georgia",DDR:"german.?democratic.?republic|democratic.?republic.*germany|east.germany",DEU:"^(?!.*east).*germany|^(?=.*\\bfed.*\\brep).*german",GHA:"ghana|gold.?coast",GIB:"gibraltar",GRC:"greece|hellenic|hellas",GRL:"greenland",GRD:"grenada",GLP:"guadeloupe",GUM:"\\bguam",GTM:"guatemala",GGY:"guernsey",GIN:"^(?!.*eq)(?!.*span)(?!.*bissau)(?!.*portu)(?!.*new).*guinea",GNB:"bissau|^(?=.*portu).*guinea",GUY:"guyana|british.?guiana",HTI:"haiti",HMD:"heard.*mcdonald",VAT:"holy.?see|vatican|papal.?st",HND:"^(?!.*brit).*honduras",HKG:"hong.?kong",HUN:"^(?!.*austr).*hungary",ISL:"iceland",IND:"india(?!.*ocea)",IDN:"indonesia",IRN:"\\biran|persia",IRQ:"\\biraq|mesopotamia",IRL:"ireland",IMN:"^(?=.*isle).*\\bman",ISR:"israel",ITA:"italy",JAM:"jamaica",JPN:"japan",JEY:"jersey",JOR:"jordan",KAZ:"kazak",KEN:"kenya|british.?east.?africa|east.?africa.?prot",KIR:"kiribati",PRK:"^(?=.*democrat).*\\bkorea|^(?=.*people).*\\bkorea|^(?=.*north).*\\bkorea|dprk",KOR:"^(?!.*democrat)(?!.*people)(?!.*north).*\\bkorea",KWT:"kuwait",KGZ:"kyrgyz|kirghiz",LAO:"\\blaos?\\b",LVA:"latvia",LBN:"lebanon",LSO:"lesotho|basuto",LBR:"liberia",LBY:"libya",LIE:"liechtenstein",LTU:"lithuania",LUX:"^(?!.*belg).*luxem",MAC:"maca(o|u)",MKD:"macedonia|fyrom",MDG:"madagascar|malagasy",MWI:"malawi|nyasa",MYS:"malaysia",MDV:"maldive",MLI:"\\bmali\\b",MLT:"\\bmalta",MHL:"marshall",MTQ:"martinique",MRT:"mauritania",MUS:"mauritius",MYT:"\\bmayotte",MEX:"\\bmexic",FSM:"micronesia",MDA:"moldov|b(a|e)ssarabia",MCO:"monaco",MNG:"mongolia",MNE:"^(?!.*serbia).*montenegro",MSR:"montserrat",MAR:"morocco|\\bmaroc",MOZ:"mozambique",MMR:"myanmar|burma",NAM:"namibia",NRU:"nauru",NPL:"nepal",NLD:"^(?!.*\\bant)(?!.*\\bcarib).*netherlands",ANT:"^(?=.*\\bant).*(nether|dutch)",NCL:"new.?caledonia",NZL:"new.?zealand",NIC:"nicaragua",NER:"\\bniger(?!ia)",NGA:"nigeria",NIU:"niue",NFK:"norfolk",MNP:"mariana",NOR:"norway",OMN:"\\boman|trucial",PAK:"^(?!.*east).*paki?stan",PLW:"palau",PSE:"palestin|\\bgaza|west.?bank",PAN:"panama",PNG:"papua|new.?guinea",PRY:"paraguay",PER:"peru",PHL:"philippines",PCN:"pitcairn",POL:"poland",PRT:"portugal",PRI:"puerto.?rico",QAT:"qatar",REU:"r(e|\xe9)union",ROU:"r(o|u|ou)mania",RUS:"\\brussia|soviet.?union|u\\.?s\\.?s\\.?r|socialist.?republics",RWA:"rwanda",BLM:"barth(e|\xe9)lemy",SHN:"helena",KNA:"kitts|\\bnevis",LCA:"\\blucia",MAF:"^(?=.*collectivity).*martin|^(?=.*france).*martin(?!ique)|^(?=.*french).*martin(?!ique)",SPM:"miquelon",VCT:"vincent",WSM:"^(?!.*amer).*samoa",SMR:"san.?marino",STP:"\\bs(a|\xe3)o.?tom(e|\xe9)",SAU:"\\bsa\\w*.?arabia",SEN:"senegal",SRB:"^(?!.*monte).*serbia",SYC:"seychell",SLE:"sierra",SGP:"singapore",SXM:"^(?!.*martin)(?!.*saba).*maarten",SVK:"^(?!.*cze).*slovak",SVN:"slovenia",SLB:"solomon",SOM:"somali",ZAF:"\\bs\\w*.?africa",SGS:"south.?georgia|sandwich",SSD:"\\bs\\w*.?sudan",ESP:"spain",LKA:"sri.?lanka|ceylon",SDN:"^(?!.*\\bs(?!u)).*sudan",SUR:"surinam|dutch.?guiana",SJM:"svalbard",SWZ:"swaziland",SWE:"sweden",CHE:"switz|swiss",SYR:"syria",TWN:"taiwan|taipei|formosa",TJK:"tajik",TZA:"tanzania",THA:"thailand|\\bsiam",TLS:"^(?=.*leste).*timor|^(?=.*east).*timor",TGO:"togo",TKL:"tokelau",TON:"tonga",TTO:"trinidad|tobago",TUN:"tunisia",TUR:"turkey",TKM:"turkmen",TCA:"turks",TUV:"tuvalu",UGA:"uganda",UKR:"ukrain",ARE:"emirates|^u\\.?a\\.?e\\.?$|united.?arab.?em",GBR:"united.?kingdom|britain|^u\\.?k\\.?$",USA:"united.?states|\\bu\\.?s\\.?a\\.?\\b|\\bu\\.?s\\.?\\b(?!.*islands)",UMI:"minor.?outlying.?is",URY:"uruguay",UZB:"uzbek",VUT:"vanuatu|new.?hebrides",VEN:"venezuela",VNM:"^(?!.*republic).*viet.?nam|^(?=.*socialist).*viet.?nam",VGB:"^(?=.*\\bu\\.?\\s?k).*virgin|^(?=.*brit).*virgin|^(?=.*kingdom).*virgin",VIR:"^(?=.*\\bu\\.?\\s?s).*virgin|^(?=.*states).*virgin",WLF:"futuna|wallis",ESH:"western.sahara",YEM:"^(?!.*arab)(?!.*north)(?!.*sana)(?!.*peo)(?!.*dem)(?!.*south)(?!.*aden)(?!.*\\bp\\.?d\\.?r).*yemen",YMD:"^(?=.*peo).*yemen|^(?!.*rep)(?=.*dem).*yemen|^(?=.*south).*yemen|^(?=.*aden).*yemen|^(?=.*\\bp\\.?d\\.?r).*yemen",YUG:"yugoslavia",ZMB:"zambia|northern.?rhodesia",EAZ:"zanzibar",ZWE:"zimbabwe|^(?!.*northern).*rhodesia"}},{}],109:[function(t,e,r){"use strict";function n(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function i(t){var e=new n;e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===o){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(i),ir.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,a(e)}var a=t("./lib/thunk.js");e.exports=i},{"./lib/thunk.js":111}],110:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],c=[],u=0,f=0;for(n=0;a>n;++n)c.push(["i",n,"=0"].join(""));for(i=0;o>i;++i)for(n=0;a>n;++n)f=u,u=t[n],0===n?c.push(["d",i,"s",n,"=t",i,"p",u].join("")):c.push(["d",i,"s",n,"=(t",i,"p",u,"-s",f,"*t",i,"p",f,")"].join(""));for(l.push("var "+c.join(",")),n=a-1;n>=0;--n)u=t[n],l.push(["for(i",n,"=0;i",n,"n;++n){for(f=u,u=t[n],i=0;o>i;++i)l.push(["p",i,"+=d",i,"s",n].join(""));s&&(n>0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",u,"]"].join(""))),l.push("}")}return l.join("\n")}function i(t,e,r,i){for(var a=e.length,o=r.arrayArgs.length,s=r.blockSize,l=r.indexArgs.length>0,c=[],u=0;o>u;++u)c.push(["var offset",u,"=p",u].join(""));for(var u=t;a>u;++u)c.push(["for(var j"+u+"=SS[",e[u],"]|0;j",u,">0;){"].join("")),c.push(["if(j",u,"<",s,"){"].join("")),c.push(["s",e[u],"=j",u].join("")),c.push(["j",u,"=0"].join("")),c.push(["}else{s",e[u],"=",s].join("")),c.push(["j",u,"-=",s,"}"].join("")),l&&c.push(["index[",e[u],"]=j",u].join(""));for(var u=0;o>u;++u){for(var f=["offset"+u],h=t;a>h;++h)f.push(["j",h,"*t",u,"p",e[h]].join(""));c.push(["p",u,"=(",f.join("+"),")"].join(""))}c.push(n(e,r,i));for(var u=t;a>u;++u)c.push("}");return c.join("\n")}function a(t){for(var e=0,r=t[0].length;r>e;){for(var n=1;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}function l(t,e){for(var r=e[1].length-Math.abs(t.arrayBlockIndices[0])|0,l=new Array(t.arrayArgs.length),u=new Array(t.arrayArgs.length),f=0;fy;++y)_.push(["s",y,"=SS[",y,"]"].join(""));for(var f=0;fy;++y)_.push(["t",f,"p",y,"=t",f,"[",p[f]+y,"]"].join(""));for(var y=0;y0&&_.push("shape=SS.slice(0)"),t.indexArgs.length>0){for(var w=new Array(r),f=0;r>f;++f)w[f]="0";_.push(["index=[",w.join(","),"]"].join(""))}for(var f=0;f3&&x.push(o(t.pre,t,u));var T=o(t.body,t,u),E=a(v);r>E?x.push(i(E,v[0],t,T)):x.push(n(v[0],t,T)),t.post.body.length>3&&x.push(o(t.post,t,u)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+x.join("\n")+"\n----------");var L=[t.funcName||"unnamed","_cwise_loop_",l[0].join("s"),"m",E,s(u)].join(""),S=new Function(["function ",L,"(",b.join(","),"){",x.join("\n"),"} return ",L].join(""));return S()}var c=t("uniq");e.exports=l},{uniq:279}],111:[function(t,e,r){"use strict";function n(t){var e=["'use strict'","var CACHED={}"],r=[],n=t.funcName+"_cwise_thunk";e.push(["return function ",n,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],c=[],u=0;u0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[u]))),c.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[u])+"]"))}t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),e.push("if (!("+c.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}"));for(var u=0;ut?-1:t>e?1:t>=e?0:NaN}function a(t){return null===t?NaN:+t}function o(t){return!isNaN(t)}function s(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}function l(t){return t.length}function c(t){for(var e=1;t*e%1;)e*=10;return e}function u(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function f(){this._=Object.create(null)}function h(t){return(t+="")===ko||t[0]===Ao?Ao+t:t}function d(t){return(t+="")[0]===Ao?t.slice(1):t}function p(t){return h(t)in this._}function g(t){return(t=h(t))in this._&&delete this._[t]}function v(){var t=[];for(var e in this._)t.push(d(e));return t}function m(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function b(){this._=Object.create(null)}function x(t){return t}function _(t,e,r){return function(){var n=r.apply(e,arguments);return n===e?t:n}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var r=0,n=Mo.length;n>r;++r){var i=Mo[r]+e;if(i in t)return i}}function k(){}function A(){}function M(t){function e(){for(var e,n=r,i=-1,a=n.length;++ir;r++)for(var i,a=t[r],o=0,s=a.length;s>o;o++)(i=a[o])&&e(i,o,r);return t}function Y(t){return Eo(t,Oo),t}function X(t){var e,r;return function(n,i,a){var o,s=t[a].update,l=s.length;for(a!=r&&(r=a,e=0),i>=e&&(e=i+1);!(o=s[e])&&++e0&&(t=t.slice(0,s));var c=Io.get(t);return c&&(t=c,l=K),s?e?i:n:e?k:a}function Z(t,e){return function(r){var n=co.event;co.event=r,e[0]=this.__data__;try{t.apply(this,e)}finally{co.event=n}}}function K(t,e){var r=Z(t,e);return function(t){var e=this,n=t.relatedTarget;n&&(n===e||8&n.compareDocumentPosition(e))||r.call(e,t)}}function $(t){var r=".dragsuppress-"+ ++jo,i="click"+r,a=co.select(n(t)).on("touchmove"+r,T).on("dragstart"+r,T).on("selectstart"+r,T);if(null==No&&(No="onselectstart"in t?!1:w(t.style,"userSelect")),No){var o=e(t).style,s=o[No];o[No]="none"}return function(t){if(a.on(r,null),No&&(o[No]=s),t){var e=function(){a.on(i,null)};a.on(i,function(){T(),e()},!0),setTimeout(e,0)}}}function Q(t,e){e.changedTouches&&(e=e.changedTouches[0]);var r=t.ownerSVGElement||t;if(r.createSVGPoint){var i=r.createSVGPoint();if(0>Fo){var a=n(t);if(a.scrollX||a.scrollY){r=co.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();Fo=!(o.f||o.e),r.remove()}}return Fo?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}function J(){return co.event.changedTouches[0].identifier}function tt(t){return t>0?1:0>t?-1:0}function et(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function rt(t){return t>1?0:-1>t?Uo:Math.acos(t)}function nt(t){return t>1?Ho:-1>t?-Ho:Math.asin(t)}function it(t){return((t=Math.exp(t))-1/t)/2}function at(t){return((t=Math.exp(t))+1/t)/2}function ot(t){return((t=Math.exp(2*t))-1)/(t+1)}function st(t){return(t=Math.sin(t/2))*t}function lt(){}function ct(t,e,r){return this instanceof ct?(this.h=+t,this.s=+e,void(this.l=+r)):arguments.length<2?t instanceof ct?new ct(t.h,t.s,t.l):kt(""+t,At,ct):new ct(t,e,r)}function ut(t,e,r){function n(t){return t>360?t-=360:0>t&&(t+=360),60>t?a+(o-a)*t/60:180>t?o:240>t?a+(o-a)*(240-t)/60:a}function i(t){return Math.round(255*n(t))}var a,o;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:0>e?0:e>1?1:e,r=0>r?0:r>1?1:r,o=.5>=r?r*(1+e):r+e-r*e,a=2*r-o,new bt(i(t+120),i(t),i(t-120))}function ft(t,e,r){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+r)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof dt?gt(t.l,t.a,t.b):gt((t=Mt((t=co.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,r)}function ht(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new dt(r,Math.cos(t*=Go)*e,Math.sin(t)*e)}function dt(t,e,r){return this instanceof dt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof dt?new dt(t.l,t.a,t.b):t instanceof ft?ht(t.h,t.c,t.l):Mt((t=bt(t)).r,t.g,t.b):new dt(t,e,r)}function pt(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return i=vt(i)*rs,n=vt(n)*ns,a=vt(a)*is,new bt(yt(3.2404542*i-1.5371385*n-.4985314*a),yt(-.969266*i+1.8760108*n+.041556*a),yt(.0556434*i-.2040259*n+1.0572252*a))}function gt(t,e,r){return t>0?new ft(Math.atan2(r,e)*Yo,Math.sqrt(e*e+r*r),t):new ft(NaN,NaN,t)}function vt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function mt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function bt(t,e,r){return this instanceof bt?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof bt?new bt(t.r,t.g,t.b):kt(""+t,bt,ut):new bt(t,e,r)}function xt(t){return new bt(t>>16,t>>8&255,255&t)}function _t(t){return xt(t)+""}function wt(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function kt(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(Et(i[0]),Et(i[1]),Et(i[2]))}return(a=ss.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o=o>>4|o,s=240&a,s=s>>4|s,l=15&a,l=l<<4|l):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function At(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=.5>l?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(r>e?6:0):e==o?(r-t)/s+2:(t-e)/s+4,n*=60):(n=NaN,i=l>0&&1>l?0:n),new ct(n,i,l)}function Mt(t,e,r){t=Tt(t),e=Tt(e),r=Tt(r);var n=mt((.4124564*t+.3575761*e+.1804375*r)/rs),i=mt((.2126729*t+.7151522*e+.072175*r)/ns),a=mt((.0193339*t+.119192*e+.9503041*r)/is);return dt(116*i-16,500*(n-i),200*(i-a))}function Tt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Et(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function Lt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,r,n){return 2===arguments.length&&"function"==typeof r&&(n=r,r=null),Ct(e,r,t,n)}}function Ct(t,e,r,n){function i(){var t,e=l.status;if(!e&&Pt(l)||e>=200&&300>e||304===e){try{t=r.call(a,l)}catch(n){return void o.error.call(a,n)}o.load.call(a,t)}else o.error.call(a,l)}var a={},o=co.dispatch("beforesend","progress","load","error"),s={},l=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(t)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(t){var e=co.event;co.event=t;try{o.progress.call(a,l)}finally{co.event=e}},a.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",a)},a.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",a):e},a.responseType=function(t){return arguments.length?(c=t,a):c},a.response=function(t){return r=t,a},["get","post"].forEach(function(t){a[t]=function(){return a.send.apply(a,[t].concat(fo(arguments)))}}),a.send=function(r,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),l.open(r,t,!0),null==e||"accept"in s||(s.accept=e+",*/*"),l.setRequestHeader)for(var u in s)l.setRequestHeader(u,s[u]);return null!=e&&l.overrideMimeType&&l.overrideMimeType(e),null!=c&&(l.responseType=c),null!=i&&a.on("error",i).on("load",function(t){i(null,t)}),o.beforesend.call(a,l),l.send(null==n?null:n),a},a.abort=function(){return l.abort(),a},co.rebind(a,o,"on"),null==n?a:a.get(zt(n))}function zt(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}function Pt(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Rt(t,e,r){var n=arguments.length;2>n&&(e=0),3>n&&(r=Date.now());var i=r+e,a={c:t,t:i,n:null};return cs?cs.n=a:ls=a,cs=a,us||(fs=clearTimeout(fs),us=1,hs(Ot)),a}function Ot(){var t=It(),e=Nt()-t;e>24?(isFinite(e)&&(clearTimeout(fs),fs=setTimeout(Ot,e)),us=0):(us=1,hs(Ot))}function It(){for(var t=Date.now(),e=ls;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Nt(){for(var t,e=ls,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}}function Dt(t){var e=t.decimal,r=t.thousands,n=t.grouping,i=t.currency,a=n&&r?function(t,e){for(var i=t.length,a=[],o=0,s=n[0],l=0;i>0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>e));)s=n[o=(o+1)%n.length];return a.reverse().join(r)}:x;return function(t){var r=ps.exec(t),n=r[1]||" ",o=r[2]||">",s=r[3]||"-",l=r[4]||"",c=r[5],u=+r[6],f=r[7],h=r[8],d=r[9],p=1,g="",v="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(c||"0"===n&&"="===o)&&(c=n="0",o="="),d){case"n":f=!0,d="g";break;case"%":p=100,v="%",d="f";break;case"p":p=100,v="%",d="r";break;case"b":case"o":case"x":case"X":"#"===l&&(g="0"+d.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,d="r"}"$"===l&&(g=i[0],v=i[1]),"r"!=d||h||(d="g"),null!=h&&("g"==d?h=Math.max(1,Math.min(21,h)):"e"!=d&&"f"!=d||(h=Math.max(0,Math.min(20,h)))),d=gs.get(d)||Bt;var b=c&&f;return function(t){var r=v;if(m&&t%1)return"";var i=0>t||0===t&&0>1/t?(t=-t,"-"):"-"===s?"":s;if(0>p){var l=co.formatPrefix(t,h);t=l.scale(t),r=l.symbol+v}else t*=p;t=d(t,h);var x,_,w=t.lastIndexOf(".");if(0>w){var k=y?t.lastIndexOf("e"):-1;0>k?(x=t,_=""):(x=t.substring(0,k),_=t.substring(k))}else x=t.substring(0,w),_=e+t.substring(w+1);!c&&f&&(x=a(x,1/0));var A=g.length+x.length+_.length+(b?0:i.length),M=u>A?new Array(A=u-A+1).join(n):"";return b&&(x=a(M+x,M.length?u-_.length:1/0)),i+=g,t=x+_,("<"===o?i+t+M:">"===o?M+i+t:"^"===o?M.substring(0,A>>=1)+i+t+M.substring(A):i+(b?t:M+t))+r}}}function Bt(t){return t+""}function Ut(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Vt(t,e,r){function n(e){var r=t(e),n=a(r,1);return n-e>e-r?r:n}function i(r){return e(r=t(new ms(r-1)),1),r}function a(t,r){return e(t=new ms(+t),r),t}function o(t,n,a){var o=i(t),s=[];if(a>1)for(;n>o;)r(o)%a||s.push(new Date(+o)),e(o,1);else for(;n>o;)s.push(new Date(+o)),e(o,1);return s}function s(t,e,r){try{ms=Ut;var n=new Ut;return n._=t,o(n,e,r)}finally{ms=Date}}t.floor=t,t.round=n,t.ceil=i,t.offset=a,t.range=o;var l=t.utc=qt(t);return l.floor=l,l.round=qt(n),l.ceil=qt(i),l.offset=qt(a),l.range=s,t}function qt(t){return function(e,r){try{ms=Ut;var n=new Ut;return n._=e,t(n,r)._}finally{ms=Date}}}function Ht(t){function e(t){function e(e){for(var r,i,a,o=[],s=-1,l=0;++ss;){if(n>=c)return-1;if(i=e.charCodeAt(s++),37===i){if(o=e.charAt(s++),a=S[o in bs?e.charAt(s++):o],!a||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}function n(t,e,r){w.lastIndex=0;var n=w.exec(e.slice(r));return n?(t.w=k.get(n[0].toLowerCase()),r+n[0].length):-1}function i(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.w=_.get(n[0].toLowerCase()),r+n[0].length):-1}function a(t,e,r){T.lastIndex=0;var n=T.exec(e.slice(r));return n?(t.m=E.get(n[0].toLowerCase()),r+n[0].length):-1}function o(t,e,r){A.lastIndex=0;var n=A.exec(e.slice(r));return n?(t.m=M.get(n[0].toLowerCase()),r+n[0].length):-1}function s(t,e,n){return r(t,L.c.toString(),e,n)}function l(t,e,n){return r(t,L.x.toString(),e,n)}function c(t,e,n){return r(t,L.X.toString(),e,n)}function u(t,e,r){var n=b.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)}var f=t.dateTime,h=t.date,d=t.time,p=t.periods,g=t.days,v=t.shortDays,m=t.months,y=t.shortMonths;e.utc=function(t){function r(t){try{ms=Ut;var e=new ms;return e._=t,n(e)}finally{ms=Date}}var n=e(t);return r.parse=function(t){try{ms=Ut;var e=n.parse(t);return e&&e._}finally{ms=Date}},r.toString=n.toString,r},e.multi=e.utc.multi=ue;var b=co.map(),x=Yt(g),_=Xt(g),w=Yt(v),k=Xt(v),A=Yt(m),M=Xt(m),T=Yt(y),E=Xt(y);p.forEach(function(t,e){b.set(t.toLowerCase(),e)});var L={a:function(t){return v[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return m[t.getMonth()]},c:e(f),d:function(t,e){return Gt(t.getDate(),e,2)},e:function(t,e){return Gt(t.getDate(),e,2)},H:function(t,e){return Gt(t.getHours(),e,2)},I:function(t,e){return Gt(t.getHours()%12||12,e,2)},j:function(t,e){return Gt(1+vs.dayOfYear(t),e,3)},L:function(t,e){return Gt(t.getMilliseconds(),e,3)},m:function(t,e){return Gt(t.getMonth()+1,e,2)},M:function(t,e){return Gt(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Gt(t.getSeconds(),e,2)},U:function(t,e){return Gt(vs.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Gt(vs.mondayOfYear(t),e,2)},x:e(h),X:e(d),y:function(t,e){return Gt(t.getFullYear()%100,e,2)},Y:function(t,e){return Gt(t.getFullYear()%1e4,e,4)},Z:le,"%":function(){return"%"}},S={a:n,A:i,b:a,B:o,c:s,d:re,e:re,H:ie,I:ie,j:ne,L:se,m:ee,M:ae,p:u,S:oe,U:Zt,w:Wt,W:Kt,x:l,X:c,y:Qt,Y:$t,Z:Jt,"%":ce};return e}function Gt(t,e,r){var n=0>t?"-":"",i=(n?-t:t)+"",a=i.length;return n+(r>a?new Array(r-a+1).join(e)+i:i)}function Yt(t){return new RegExp("^(?:"+t.map(co.requote).join("|")+")","i")}function Xt(t){for(var e=new f,r=-1,n=t.length;++r68?1900:2e3)}function ee(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function re(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function ne(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function ie(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function ae(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function oe(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function se(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function le(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=wo(e)/60|0,i=wo(e)%60;return r+Gt(n,"0",2)+Gt(i,"0",2)}function ce(t,e,r){_s.lastIndex=0;var n=_s.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function ue(t){for(var e=t.length,r=-1;++r=0?1:-1,s=o*r,l=Math.cos(e),c=Math.sin(e),u=a*c,f=i*l+u*Math.cos(s),h=u*o*Math.sin(s);Es.add(Math.atan2(h,f)),n=t,i=l,a=c}var e,r,n,i,a;Ls.point=function(o,s){Ls.point=t,n=(e=o)*Go,i=Math.cos(s=(r=s)*Go/2+Uo/4),a=Math.sin(s)},Ls.lineEnd=function(){t(e,r)}}function me(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function be(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function xe(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ke(t){return[Math.atan2(t[1],t[0]),nt(t[2])]}function Ae(t,e){return wo(t[0]-e[0])s;++s)i.point((r=t[s])[0],r[1]);return void i.lineEnd()}var l=new Oe(r,t,null,!0),c=new Oe(r,null,l,!1);l.o=c,a.push(l),o.push(c),l=new Oe(n,t,null,!1),c=new Oe(n,null,l,!0),l.o=c,a.push(l),o.push(c)}}),o.sort(e),Re(a),Re(o),a.length){for(var s=0,l=r,c=o.length;c>s;++s)o[s].e=l=!l;for(var u,f,h=a[0];;){for(var d=h,p=!0;d.v;)if((d=d.n)===h)return;u=d.z,i.lineStart();do{if(d.v=d.o.v=!0,d.e){if(p)for(var s=0,c=u.length;c>s;++s)i.point((f=u[s])[0],f[1]);else n(d.x,d.n.x,1,i);d=d.n}else{if(p){u=d.p.z;for(var s=u.length-1;s>=0;--s)i.point((f=u[s])[0],f[1])}else n(d.x,d.p.x,-1,i);d=d.p}d=d.o,u=d.z,p=!p}while(!d.v);i.lineEnd()}}}function Re(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n0){for(_||(a.polygonStart(),_=!0),a.lineStart();++o1&&2&e&&r.push(r.pop().concat(r.shift())),d.push(r.filter(Ne))}var d,p,g,v=e(a),m=i.invert(n[0],n[1]),y={point:o,lineStart:l,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=f,y.lineEnd=h,d=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=l,y.lineEnd=c,d=co.merge(d);var t=Ve(m,p);d.length?(_||(a.polygonStart(),_=!0),Pe(d,Fe,t,r,a)):t&&(_||(a.polygonStart(),_=!0),a.lineStart(),r(null,null,1,a),a.lineEnd()),_&&(a.polygonEnd(),_=!1),d=p=null},sphere:function(){a.polygonStart(),a.lineStart(),r(null,null,1,a),a.lineEnd(),a.polygonEnd()}},b=je(),x=e(b),_=!1;return y}}function Ne(t){return t.length>1}function je(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:k,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Fe(t,e){return((t=t.x)[0]<0?t[1]-Ho-Do:Ho-t[1])-((e=e.x)[0]<0?e[1]-Ho-Do:Ho-e[1])}function De(t){var e,r=NaN,n=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?Uo:-Uo,l=wo(a-r);wo(l-Uo)0?Ho:-Ho),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=Uo&&(wo(r-i)Do?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}function Ue(t,e,r,n){var i;if(null==t)i=r*Ho,n.point(-Uo,i),n.point(0,i),n.point(Uo,i),n.point(Uo,0),n.point(Uo,-i),n.point(0,-i),n.point(-Uo,-i),n.point(-Uo,0),n.point(-Uo,i);else if(wo(t[0]-e[0])>Do){var a=t[0]s;++s){var c=e[s],u=c.length;if(u)for(var f=c[0],h=f[0],d=f[1]/2+Uo/4,p=Math.sin(d),g=Math.cos(d),v=1;;){v===u&&(v=0),t=c[v];var m=t[0],y=t[1]/2+Uo/4,b=Math.sin(y),x=Math.cos(y),_=m-h,w=_>=0?1:-1,k=w*_,A=k>Uo,M=p*b;if(Es.add(Math.atan2(M*w*Math.sin(k),g*x+M*Math.cos(k))),a+=A?_+w*Vo:_,A^h>=r^m>=r){var T=be(me(f),me(t));we(T);var E=be(i,T);we(E);var L=(A^_>=0?-1:1)*nt(E[2]);(n>L||n===L&&(T[0]||T[1]))&&(o+=A^_>=0?1:-1)}if(!v++)break;h=m,p=b,g=x,f=t}}return(-Do>a||Do>a&&0>Es)^1&o}function qe(t){function e(t,e){return Math.cos(t)*Math.cos(e)>a}function r(t){var r,a,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(f,h){var d,p=[f,h],g=e(f,h),v=o?g?0:i(f,h):g?i(f+(0>f?Uo:-Uo),h):0;if(!r&&(c=l=g)&&t.lineStart(),g!==l&&(d=n(r,p),(Ae(r,d)||Ae(p,d))&&(p[0]+=Do,p[1]+=Do,g=e(p[0],p[1]))),g!==l)u=0,g?(t.lineStart(),d=n(p,r),t.point(d[0],d[1])):(d=n(r,p),t.point(d[0],d[1]),t.lineEnd()),r=d;else if(s&&r&&o^g){var m;v&a||!(m=n(p,r,!0))||(u=0,o?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||r&&Ae(r,p)||t.point(p[0],p[1]),r=p,l=g,a=v},lineEnd:function(){l&&t.lineEnd(),r=null},clean:function(){return u|(c&&l)<<1}}}function n(t,e,r){var n=me(t),i=me(e),o=[1,0,0],s=be(n,i),l=ye(s,s),c=s[0],u=l-c*c;if(!u)return!r&&t;var f=a*l/u,h=-a*c/u,d=be(o,s),p=_e(o,f),g=_e(s,h);xe(p,g);var v=d,m=ye(p,v),y=ye(v,v),b=m*m-y*(ye(p,p)-1);if(!(0>b)){var x=Math.sqrt(b),_=_e(v,(-m-x)/y);if(xe(_,p),_=ke(_),!r)return _;var w,k=t[0],A=e[0],M=t[1],T=e[1];k>A&&(w=k,k=A,A=w);var E=A-k,L=wo(E-Uo)E;if(!L&&M>T&&(w=M,M=T,T=w),S?L?M+T>0^_[1]<(wo(_[0]-k)Uo^(k<=_[0]&&_[0]<=A)){var C=_e(v,(-m+x)/y);return xe(C,p),[_,ke(C)]}}}function i(e,r){var n=o?t:Uo-t,i=0;return-n>e?i|=1:e>n&&(i|=2),-n>r?i|=4:r>n&&(i|=8),i}var a=Math.cos(t),o=a>0,s=wo(a)>Do,l=vr(t,6*Go);return Ie(e,r,l,o?[0,-t]:[-Uo,t-Uo])}function He(t,e,r,n){return function(i){var a,o=i.a,s=i.b,l=o.x,c=o.y,u=s.x,f=s.y,h=0,d=1,p=u-l,g=f-c;if(a=t-l,p||!(a>0)){if(a/=p,0>p){if(h>a)return;d>a&&(d=a)}else if(p>0){if(a>d)return;a>h&&(h=a)}if(a=r-l,p||!(0>a)){if(a/=p,0>p){if(a>d)return;a>h&&(h=a)}else if(p>0){if(h>a)return;d>a&&(d=a)}if(a=e-c,g||!(a>0)){if(a/=g,0>g){if(h>a)return;d>a&&(d=a)}else if(g>0){if(a>d)return;a>h&&(h=a)}if(a=n-c,g||!(0>a)){if(a/=g,0>g){if(a>d)return;a>h&&(h=a)}else if(g>0){if(h>a)return;d>a&&(d=a)}return h>0&&(i.a={x:l+h*p,y:c+h*g}),1>d&&(i.b={x:l+d*p,y:c+d*g}),i}}}}}}function Ge(t,e,r,n){function i(n,i){return wo(n[0]-t)0?0:3:wo(n[0]-r)0?2:1:wo(n[1]-e)0?1:0:i>0?3:2}function a(t,e){return o(t.x,e.x)}function o(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}return function(s){function l(t){for(var e=0,r=v.length,n=t[1],i=0;r>i;++i)for(var a,o=1,s=v[i],l=s.length,c=s[0];l>o;++o)a=s[o],c[1]<=n?a[1]>n&&et(c,a,t)>0&&++e:a[1]<=n&&et(c,a,t)<0&&--e,c=a;return 0!==e}function c(a,s,l,c){var u=0,f=0;if(null==a||(u=i(a,l))!==(f=i(s,l))||o(a,s)<0^l>0){do c.point(0===u||3===u?t:r,u>1?n:e);while((u=(u+l+4)%4)!==f)}else c.point(s[0],s[1])}function u(i,a){return i>=t&&r>=i&&a>=e&&n>=a}function f(t,e){u(t,e)&&s.point(t,e)}function h(){S.point=p,v&&v.push(m=[]),A=!0,k=!1,_=w=NaN}function d(){g&&(p(y,b),x&&k&&E.rejoin(),g.push(E.buffer())),S.point=f,k&&s.lineEnd()}function p(t,e){t=Math.max(-Vs,Math.min(Vs,t)),e=Math.max(-Vs,Math.min(Vs,e));var r=u(t,e);if(v&&m.push([t,e]),A)y=t,b=e,x=r,A=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&k)s.point(t,e);else{var n={a:{x:_,y:w},b:{x:t,y:e}};L(n)?(k||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),M=!1):r&&(s.lineStart(),s.point(t,e),M=!1)}_=t,w=e,k=r}var g,v,m,y,b,x,_,w,k,A,M,T=s,E=je(),L=He(t,e,r,n),S={point:f,lineStart:h,lineEnd:d,polygonStart:function(){s=E,g=[],v=[],M=!0},polygonEnd:function(){s=T,g=co.merge(g);var e=l([t,n]),r=M&&e,i=g.length;(r||i)&&(s.polygonStart(),r&&(s.lineStart(),c(null,null,1,s),s.lineEnd()),i&&Pe(g,a,e,c,s),s.polygonEnd()),g=v=m=null}};return S}}function Ye(t){var e=0,r=Uo/3,n=lr(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*Uo/180,r=t[1]*Uo/180):[e/Uo*180,r/Uo*180]},i}function Xe(t,e){function r(t,e){var r=Math.sqrt(a-2*i*Math.sin(e))/i;return[r*Math.sin(t*=i),o-r*Math.cos(t)]}var n=Math.sin(t),i=(n+Math.sin(e))/2,a=1+n*(2*i-n),o=Math.sqrt(a)/i;return r.invert=function(t,e){var r=o-e;return[Math.atan2(t,r)/i,nt((a-(t*t+r*r)*i*i)/(2*i))]},r}function We(){function t(t,e){Hs+=i*t-n*e,n=t,i=e}var e,r,n,i;Zs.point=function(a,o){Zs.point=t,e=n=a,r=i=o},Zs.lineEnd=function(){t(e,r)}}function Ze(t,e){Gs>t&&(Gs=t),t>Xs&&(Xs=t),Ys>e&&(Ys=e),e>Ws&&(Ws=e)}function Ke(){function t(t,e){o.push("M",t,",",e,a)}function e(t,e){o.push("M",t,",",e),s.point=r}function r(t,e){o.push("L",t,",",e)}function n(){s.point=t}function i(){o.push("Z")}var a=$e(4.5),o=[],s={point:t,lineStart:function(){s.point=e},lineEnd:n,polygonStart:function(){s.lineEnd=i},polygonEnd:function(){s.lineEnd=n,s.point=t},pointRadius:function(t){return a=$e(t),s},result:function(){if(o.length){var t=o.join("");return o=[],t}}};return s}function $e(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Qe(t,e){zs+=t,Ps+=e,++Rs}function Je(){function t(t,n){var i=t-e,a=n-r,o=Math.sqrt(i*i+a*a);Os+=o*(e+t)/2,Is+=o*(r+n)/2,Ns+=o,Qe(e=t,r=n)}var e,r;$s.point=function(n,i){$s.point=t,Qe(e=n,r=i)}}function tr(){$s.point=Qe}function er(){function t(t,e){var r=t-n,a=e-i,o=Math.sqrt(r*r+a*a);Os+=o*(n+t)/2,Is+=o*(i+e)/2,Ns+=o,o=i*t-n*e,js+=o*(n+t),Fs+=o*(i+e),Ds+=3*o,Qe(n=t,i=e)}var e,r,n,i;$s.point=function(a,o){$s.point=t,Qe(e=n=a,r=i=o)},$s.lineEnd=function(){t(e,r)}}function rr(t){function e(e,r){t.moveTo(e+o,r),t.arc(e,r,o,0,Vo)}function r(e,r){t.moveTo(e,r),s.point=n}function n(e,r){t.lineTo(e,r)}function i(){s.point=e}function a(){t.closePath()}var o=4.5,s={point:e,lineStart:function(){s.point=r},lineEnd:i,polygonStart:function(){s.lineEnd=a},polygonEnd:function(){s.lineEnd=i,s.point=e},pointRadius:function(t){return o=t,s},result:k};return s}function nr(t){function e(t){return(s?n:r)(t)}function r(e){return or(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})}function n(e){function r(r,n){r=t(r,n),e.point(r[0],r[1])}function n(){b=NaN,A.point=a,e.lineStart()}function a(r,n){var a=me([r,n]),o=t(r,n);i(b,x,y,_,w,k,b=o[0],x=o[1],y=r,_=a[0],w=a[1],k=a[2],s,e),e.point(b,x)}function o(){A.point=r,e.lineEnd()}function l(){n(),A.point=c,A.lineEnd=u}function c(t,e){a(f=t,h=e),d=b,p=x,g=_,v=w,m=k,A.point=a}function u(){i(b,x,y,_,w,k,d,p,f,g,v,m,s,e),A.lineEnd=o,o()}var f,h,d,p,g,v,m,y,b,x,_,w,k,A={point:r,lineStart:n,lineEnd:o,polygonStart:function(){e.polygonStart(),A.lineStart=l},polygonEnd:function(){e.polygonEnd(),A.lineStart=n}};return A}function i(e,r,n,s,l,c,u,f,h,d,p,g,v,m){var y=u-e,b=f-r,x=y*y+b*b;if(x>4*a&&v--){var _=s+d,w=l+p,k=c+g,A=Math.sqrt(_*_+w*w+k*k),M=Math.asin(k/=A),T=wo(wo(k)-1)a||wo((y*C+b*z)/x-.5)>.3||o>s*d+l*p+c*g)&&(i(e,r,n,s,l,c,L,S,T,_/=A,w/=A,k,v,m),m.point(L,S),i(L,S,T,_,w,k,u,f,h,d,p,g,v,m))}}var a=.5,o=Math.cos(30*Go),s=16;return e.precision=function(t){return arguments.length?(s=(a=t*t)>0&&16,e):Math.sqrt(a)},e}function ir(t){var e=nr(function(e,r){return t([e*Yo,r*Yo])});return function(t){return cr(e(t))}}function ar(t){this.stream=t}function or(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sr(t){return lr(function(){return t})()}function lr(t){function e(t){return t=s(t[0]*Go,t[1]*Go),[t[0]*h+l,c-t[1]*h]}function r(t){return t=s.invert((t[0]-l)/h,(c-t[1])/h),t&&[t[0]*Yo,t[1]*Yo]}function n(){s=Ce(o=hr(m,y,b),a);var t=a(g,v);return l=d-t[0]*h,c=p+t[1]*h,i()}function i(){return u&&(u.valid=!1,u=null),e}var a,o,s,l,c,u,f=nr(function(t,e){return t=a(t,e),[t[0]*h+l,c-t[1]*h]}),h=150,d=480,p=250,g=0,v=0,m=0,y=0,b=0,_=Us,w=x,k=null,A=null;return e.stream=function(t){return u&&(u.valid=!1),u=cr(_(o,f(w(t)))),u.valid=!0,u},e.clipAngle=function(t){return arguments.length?(_=null==t?(k=t,Us):qe((k=+t)*Go),i()):k},e.clipExtent=function(t){return arguments.length?(A=t,w=t?Ge(t[0][0],t[0][1],t[1][0],t[1][1]):x,i()):A},e.scale=function(t){return arguments.length?(h=+t,n()):h},e.translate=function(t){return arguments.length?(d=+t[0],p=+t[1],n()):[d,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Go,v=t[1]%360*Go,n()):[g*Yo,v*Yo]},e.rotate=function(t){return arguments.length?(m=t[0]%360*Go,y=t[1]%360*Go,b=t.length>2?t[2]%360*Go:0,n()):[m*Yo,y*Yo,b*Yo]},co.rebind(e,f,"precision"),function(){return a=t.apply(this,arguments),e.invert=a.invert&&r,n()}}function cr(t){return or(t,function(e,r){t.point(e*Go,r*Go)})}function ur(t,e){return[t,e]}function fr(t,e){return[t>Uo?t-Vo:-Uo>t?t+Vo:t,e]}function hr(t,e,r){return t?e||r?Ce(pr(t),gr(e,r)):pr(t):e||r?gr(e,r):fr}function dr(t){return function(e,r){return e+=t,[e>Uo?e-Vo:-Uo>e?e+Vo:e,r]}}function pr(t){var e=dr(t);return e.invert=dr(-t),e}function gr(t,e){function r(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*n+s*i;return[Math.atan2(l*a-u*o,s*n-c*i),nt(u*a+l*o)]}var n=Math.cos(t),i=Math.sin(t),a=Math.cos(e),o=Math.sin(e);return r.invert=function(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,c=Math.sin(e),u=c*a-l*o;return[Math.atan2(l*a+c*o,s*n+u*i),nt(u*n-s*i)]},r}function vr(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=mr(r,i),a=mr(r,a),(o>0?a>i:i>a)&&(i+=o*Vo)):(i=t+o*Vo,a=t-.5*l);for(var c,u=i;o>0?u>a:a>u;u-=l)s.point((c=ke([r,-n*Math.cos(u),-n*Math.sin(u)]))[0],c[1])}}function mr(t,e){var r=me(e);r[0]-=t,we(r);var n=rt(-r[1]);return((-r[2]<0?-n:n)+2*Math.PI-Do)%(2*Math.PI)}function yr(t,e,r){var n=co.range(t,e-Do,r).concat(e);return function(t){return n.map(function(e){return[t,e]})}}function br(t,e,r){var n=co.range(t,e-Do,r).concat(e);return function(t){return n.map(function(e){return[e,t]})}}function xr(t){return t.source}function _r(t){return t.target}function wr(t,e,r,n){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(n),s=Math.sin(n),l=i*Math.cos(t),c=i*Math.sin(t),u=o*Math.cos(r),f=o*Math.sin(r),h=2*Math.asin(Math.sqrt(st(n-e)+i*o*st(r-t))),d=1/Math.sin(h),p=h?function(t){var e=Math.sin(t*=h)*d,r=Math.sin(h-t)*d,n=r*l+e*u,i=r*c+e*f,o=r*a+e*s;return[Math.atan2(i,n)*Yo,Math.atan2(o,Math.sqrt(n*n+i*i))*Yo]}:function(){return[t*Yo,e*Yo]};return p.distance=h,p}function kr(){function t(t,i){var a=Math.sin(i*=Go),o=Math.cos(i),s=wo((t*=Go)-e),l=Math.cos(s); +Qs+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=n*a-r*o*l)*s),r*a+n*o*l),e=t,r=a,n=o}var e,r,n;Js.point=function(i,a){e=i*Go,r=Math.sin(a*=Go),n=Math.cos(a),Js.point=t},Js.lineEnd=function(){Js.point=Js.lineEnd=k}}function Ar(t,e){function r(e,r){var n=Math.cos(e),i=Math.cos(r),a=t(n*i);return[a*i*Math.sin(e),a*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),i=e(n),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,n*o),Math.asin(n&&r*a/n)]},r}function Mr(t,e){function r(t,e){o>0?-Ho+Do>e&&(e=-Ho+Do):e>Ho-Do&&(e=Ho-Do);var r=o/Math.pow(i(e),a);return[r*Math.sin(a*t),o-r*Math.cos(a*t)]}var n=Math.cos(t),i=function(t){return Math.tan(Uo/4+t/2)},a=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(i(e)/i(t)),o=n*Math.pow(i(t),a)/a;return a?(r.invert=function(t,e){var r=o-e,n=tt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(o/n,1/a))-Ho]},r):Er}function Tr(t,e){function r(t,e){var r=a-e;return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}var n=Math.cos(t),i=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),a=n/i+t;return wo(i)i;i++){for(;n>1&&et(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function Rr(t,e){return t[0]-e[0]||t[1]-e[1]}function Or(t,e,r){return(r[0]-e[0])*(t[1]-e[1])<(r[1]-e[1])*(t[0]-e[0])}function Ir(t,e,r,n){var i=t[0],a=r[0],o=e[0]-i,s=n[0]-a,l=t[1],c=r[1],u=e[1]-l,f=n[1]-c,h=(s*(l-c)-f*(i-a))/(f*o-s*u);return[i+h*o,l+h*u]}function Nr(t){var e=t[0],r=t[t.length-1];return!(e[0]-r[0]||e[1]-r[1])}function jr(){an(this),this.edge=this.site=this.circle=null}function Fr(t){var e=fl.pop()||new jr;return e.site=t,e}function Dr(t){Zr(t),ll.remove(t),fl.push(t),an(t)}function Br(t){var e=t.circle,r=e.x,n=e.cy,i={x:r,y:n},a=t.P,o=t.N,s=[t];Dr(t);for(var l=a;l.circle&&wo(r-l.circle.x)u;++u)c=s[u],l=s[u-1],en(c.edge,l.site,c.site,i);l=s[0],c=s[f-1],c.edge=Jr(l.site,c.site,null,i),Wr(l),Wr(c)}function Ur(t){for(var e,r,n,i,a=t.x,o=t.y,s=ll._;s;)if(n=Vr(s,o)-a,n>Do)s=s.L;else{if(i=a-qr(s,o),!(i>Do)){n>-Do?(e=s.P,r=s):i>-Do?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=Fr(t);if(ll.insert(e,l),e||r){if(e===r)return Zr(e),r=Fr(e.site),ll.insert(l,r),l.edge=r.edge=Jr(e.site,l.site),Wr(e),void Wr(r);if(!r)return void(l.edge=Jr(e.site,l.site));Zr(e),Zr(r);var c=e.site,u=c.x,f=c.y,h=t.x-u,d=t.y-f,p=r.site,g=p.x-u,v=p.y-f,m=2*(h*v-d*g),y=h*h+d*d,b=g*g+v*v,x={x:(v*y-d*b)/m+u,y:(h*b-g*y)/m+f};en(r.edge,c,p,x),l.edge=Jr(c,t,null,x),r.edge=Jr(t,p,null,x),Wr(e),Wr(r)}}function Vr(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-(1/0);r=o.site;var s=r.x,l=r.y,c=l-e;if(!c)return s;var u=s-n,f=1/a-1/c,h=u/c;return f?(-h+Math.sqrt(h*h-2*f*(u*u/(-2*c)-l+c/2+i-a/2)))/f+n:(n+s)/2}function qr(t,e){var r=t.N;if(r)return Vr(r,e);var n=t.site;return n.y===e?n.x:1/0}function Hr(t){this.site=t,this.edges=[]}function Gr(t){for(var e,r,n,i,a,o,s,l,c,u,f=t[0][0],h=t[1][0],d=t[0][1],p=t[1][1],g=sl,v=g.length;v--;)if(a=g[v],a&&a.prepare())for(s=a.edges,l=s.length,o=0;l>o;)u=s[o].end(),n=u.x,i=u.y,c=s[++o%l].start(),e=c.x,r=c.y,(wo(n-e)>Do||wo(i-r)>Do)&&(s.splice(o,0,new rn(tn(a.site,u,wo(n-f)Do?{x:f,y:wo(e-f)Do?{x:wo(r-p)Do?{x:h,y:wo(e-h)Do?{x:wo(r-d)=-Bo)){var d=l*l+c*c,p=u*u+f*f,g=(f*d-c*p)/h,v=(l*p-u*d)/h,f=v+s,m=hl.pop()||new Xr;m.arc=t,m.site=i,m.x=g+o,m.y=f+Math.sqrt(g*g+v*v),m.cy=f,t.circle=m;for(var y=null,b=ul._;b;)if(m.yv||v>=s)return;if(h>p){if(a){if(a.y>=c)return}else a={x:v,y:l};r={x:v,y:c}}else{if(a){if(a.yn||n>1)if(h>p){if(a){if(a.y>=c)return}else a={x:(l-i)/n,y:l};r={x:(c-i)/n,y:c}}else{if(a){if(a.yd){if(a){if(a.x>=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xa||f>o||n>h||i>d)){if(p=t.point){var p,g=e-t.x,v=r-t.y,m=g*g+v*v;if(l>m){var y=Math.sqrt(l=m);n=e-y,i=r-y,a=e+y,o=r+y,s=p}}for(var b=t.nodes,x=.5*(u+h),_=.5*(f+d),w=e>=x,k=r>=_,A=k<<1|w,M=A+4;M>A;++A)if(t=b[3&A])switch(3&A){case 0:c(t,u,f,x,_);break;case 1:c(t,x,f,h,_);break;case 2:c(t,u,_,x,d);break;case 3:c(t,x,_,h,d)}}}(t,n,i,a,o),s}function mn(t,e){t=co.rgb(t),e=co.rgb(e);var r=t.r,n=t.g,i=t.b,a=e.r-r,o=e.g-n,s=e.b-i;return function(t){return"#"+wt(Math.round(r+a*t))+wt(Math.round(n+o*t))+wt(Math.round(i+s*t))}}function yn(t,e){var r,n={},i={};for(r in t)r in e?n[r]=_n(t[r],e[r]):i[r]=t[r];for(r in e)r in t||(i[r]=e[r]);return function(t){for(r in n)i[r]=n[r](t);return i}}function bn(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function xn(t,e){var r,n,i,a=pl.lastIndex=gl.lastIndex=0,o=-1,s=[],l=[];for(t+="",e+="";(r=pl.exec(t))&&(n=gl.exec(e));)(i=n.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:bn(r,n)})),a=gl.lastIndex;return an;++n)s[(r=l[n]).i]=r.x(t);return s.join("")})}function _n(t,e){for(var r,n=co.interpolators.length;--n>=0&&!(r=co.interpolators[n](t,e)););return r}function wn(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;s>r;++r)n.push(_n(t[r],e[r]));for(;a>r;++r)i[r]=t[r];for(;o>r;++r)i[r]=e[r];return function(t){for(r=0;s>r;++r)i[r]=n[r](t);return i}}function kn(t){return function(e){return 0>=e?0:e>=1?1:t(e)}}function An(t){return function(e){return 1-t(1-e)}}function Mn(t){return function(e){return.5*(.5>e?t(2*e):2-t(2-2*e))}}function Tn(t){return t*t}function En(t){return t*t*t}function Ln(t){if(0>=t)return 0;if(t>=1)return 1;var e=t*t,r=e*t;return 4*(.5>t?r:3*(t-e)+r-.75)}function Sn(t){return function(e){return Math.pow(e,t)}}function Cn(t){return 1-Math.cos(t*Ho)}function zn(t){return Math.pow(2,10*(t-1))}function Pn(t){return 1-Math.sqrt(1-t*t)}function Rn(t,e){var r;return arguments.length<2&&(e=.45),arguments.length?r=e/Vo*Math.asin(1/t):(t=1,r=e/4),function(n){return 1+t*Math.pow(2,-10*n)*Math.sin((n-r)*Vo/e)}}function On(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function In(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Nn(t,e){t=co.hcl(t),e=co.hcl(e);var r=t.h,n=t.c,i=t.l,a=e.h-r,o=e.c-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.c:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ht(r+a*t,n+o*t,i+s*t)+""}}function jn(t,e){t=co.hsl(t),e=co.hsl(e);var r=t.h,n=t.s,i=t.l,a=e.h-r,o=e.s-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.s:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ut(r+a*t,n+o*t,i+s*t)+""}}function Fn(t,e){t=co.lab(t),e=co.lab(e);var r=t.l,n=t.a,i=t.b,a=e.l-r,o=e.a-n,s=e.b-i;return function(t){return pt(r+a*t,n+o*t,i+s*t)+""}}function Dn(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function Bn(t){var e=[t.a,t.b],r=[t.c,t.d],n=Vn(e),i=Un(e,r),a=Vn(qn(r,e,-i))||0;e[0]*r[1]180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(Hn(r)+"rotate(",null,")")-2,x:bn(t,e)})):e&&r.push(Hn(r)+"rotate("+e+")")}function Xn(t,e,r,n){t!==e?n.push({i:r.push(Hn(r)+"skewX(",null,")")-2,x:bn(t,e)}):e&&r.push(Hn(r)+"skewX("+e+")")}function Wn(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(Hn(r)+"scale(",null,",",null,")");n.push({i:i-4,x:bn(t[0],e[0])},{i:i-2,x:bn(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(Hn(r)+"scale("+e+")")}function Zn(t,e){var r=[],n=[];return t=co.transform(t),e=co.transform(e),Gn(t.translate,e.translate,r,n),Yn(t.rotate,e.rotate,r,n),Xn(t.skew,e.skew,r,n),Wn(t.scale,e.scale,r,n),t=e=null,function(t){for(var e,i=-1,a=n.length;++i=0;)r.push(i[n])}function li(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++or;++r)(e=t[r][1])>i&&(n=r,i=e);return n}function bi(t){return t.reduce(xi,0)}function xi(t,e){return t+e[1]}function _i(t,e){return wi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wi(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function ki(t){return[co.min(t),co.max(t)]}function Ai(t,e){return t.value-e.value}function Mi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ti(t,e){t._pack_next=e,e._pack_prev=t}function Ei(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function Li(t){function e(t){u=Math.min(t.x-t.r,u),f=Math.max(t.x+t.r,f),h=Math.min(t.y-t.r,h),d=Math.max(t.y+t.r,d)}if((r=t.children)&&(c=r.length)){var r,n,i,a,o,s,l,c,u=1/0,f=-(1/0),h=1/0,d=-(1/0);if(r.forEach(Si),n=r[0],n.x=-n.r,n.y=0,e(n),c>1&&(i=r[1],i.x=i.r,i.y=0,e(i),c>2))for(a=r[2],Pi(n,i,a),e(a),Mi(n,a),n._pack_prev=a,Mi(a,i),i=n._pack_next,o=3;c>o;o++){Pi(n,i,a=r[o]);var p=0,g=1,v=1;for(s=i._pack_next;s!==i;s=s._pack_next,g++)if(Ei(s,a)){p=1;break}if(1==p)for(l=n._pack_prev;l!==s._pack_prev&&!Ei(l,a);l=l._pack_prev,v++);p?(v>g||g==v&&i.ro;o++)a=r[o],a.x-=m,a.y-=y,b=Math.max(b,a.r+Math.sqrt(a.x*a.x+a.y*a.y));t.r=b,r.forEach(Ci)}}function Si(t){t._pack_next=t._pack_prev=t}function Ci(t){delete t._pack_next,delete t._pack_prev}function zi(t,e,r,n){var i=t.children;if(t.x=e+=n*t.x,t.y=r+=n*t.y,t.r*=n,i)for(var a=-1,o=i.length;++a=0;)e=i[a],e.z+=r,e.m+=r,r+=e.s+(n+=e.c)}function Fi(t,e,r){return t.a.parent===e.parent?t.a:r}function Di(t){return 1+co.max(t,function(t){return t.y})}function Bi(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ui(t){var e=t.children;return e&&e.length?Ui(e[0]):t}function Vi(t){var e,r=t.children;return r&&(e=r.length)?Vi(r[e-1]):t}function qi(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Hi(t,e){var r=t.x+e[3],n=t.y+e[0],i=t.dx-e[1]-e[3],a=t.dy-e[0]-e[2];return 0>i&&(r+=i/2,i=0),0>a&&(n+=a/2,a=0),{x:r,y:n,dx:i,dy:a}}function Gi(t){var e=t[0],r=t[t.length-1];return r>e?[e,r]:[r,e]}function Yi(t){return t.rangeExtent?t.rangeExtent():Gi(t.range())}function Xi(t,e,r,n){var i=r(t[0],t[1]),a=n(e[0],e[1]);return function(t){return a(i(t))}}function Wi(t,e){var r,n=0,i=t.length-1,a=t[n],o=t[i];return a>o&&(r=n,n=i,i=r,r=a,a=o,o=r),t[n]=e.floor(a),t[i]=e.ceil(o),t}function Zi(t){return t?{floor:function(e){return Math.floor(e/t)*t},ceil:function(e){return Math.ceil(e/t)*t}}:Tl}function Ki(t,e,r,n){var i=[],a=[],o=0,s=Math.min(t.length,e.length)-1;for(t[s]2?Ki:Xi,l=n?$n:Kn;return o=i(t,e,l,r),s=i(e,t,l,_n),a}function a(t){return o(t)}var o,s;return a.invert=function(t){return s(t)},a.domain=function(e){return arguments.length?(t=e.map(Number),i()):t},a.range=function(t){return arguments.length?(e=t,i()):e},a.rangeRound=function(t){return a.range(t).interpolate(Dn)},a.clamp=function(t){return arguments.length?(n=t,i()):n},a.interpolate=function(t){return arguments.length?(r=t,i()):r},a.ticks=function(e){return ea(t,e)},a.tickFormat=function(e,r){return ra(t,e,r)},a.nice=function(e){return Ji(t,e),i()},a.copy=function(){return $i(t,e,r,n)},i()}function Qi(t,e){return co.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ji(t,e){return Wi(t,Zi(ta(t,e)[2])),Wi(t,Zi(ta(t,e)[2])),t}function ta(t,e){null==e&&(e=10);var r=Gi(t),n=r[1]-r[0],i=Math.pow(10,Math.floor(Math.log(n/e)/Math.LN10)),a=e/n*i;return.15>=a?i*=10:.35>=a?i*=5:.75>=a&&(i*=2),r[0]=Math.ceil(r[0]/i)*i,r[1]=Math.floor(r[1]/i)*i+.5*i,r[2]=i,r}function ea(t,e){return co.range.apply(co,ta(t,e))}function ra(t,e,r){var n=ta(t,e);if(r){var i=ps.exec(r);if(i.shift(),"s"===i[8]){var a=co.formatPrefix(Math.max(wo(n[0]),wo(n[1])));return i[7]||(i[7]="."+na(a.scale(n[2]))),i[8]="f",r=co.format(i.join("")),function(t){return r(a.scale(t))+a.symbol}}i[7]||(i[7]="."+ia(i[8],n)),r=i.join("")}else r=",."+na(n[2])+"f";return co.format(r)}function na(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ia(t,e){var r=na(e[2]);return t in El?Math.abs(r-na(Math.max(wo(e[0]),wo(e[1]))))+ +("e"!==t):r-2*("%"===t)}function aa(t,e,r,n){function i(t){return(r?Math.log(0>t?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function a(t){return r?Math.pow(e,t):-Math.pow(e,-t)}function o(e){return t(i(e))}return o.invert=function(e){return a(t.invert(e))},o.domain=function(e){return arguments.length?(r=e[0]>=0,t.domain((n=e.map(Number)).map(i)),o):n},o.base=function(r){return arguments.length?(e=+r,t.domain(n.map(i)),o):e},o.nice=function(){var e=Wi(n.map(i),r?Math:Sl);return t.domain(e),n=e.map(a),o},o.ticks=function(){var t=Gi(n),o=[],s=t[0],l=t[1],c=Math.floor(i(s)),u=Math.ceil(i(l)),f=e%1?2:e;if(isFinite(u-c)){if(r){for(;u>c;c++)for(var h=1;f>h;h++)o.push(a(c)*h);o.push(a(c))}else for(o.push(a(c));c++0;h--)o.push(a(c)*h);for(c=0;o[c]l;u--);o=o.slice(c,u)}return o},o.tickFormat=function(t,r){if(!arguments.length)return Ll;arguments.length<2?r=Ll:"function"!=typeof r&&(r=co.format(r));var n=Math.max(1,e*t/o.ticks().length);return function(t){var o=t/a(Math.round(i(t)));return e-.5>o*e&&(o*=e),n>=o?r(t):""}},o.copy=function(){return aa(t.copy(),e,r,n)},Qi(o,t)}function oa(t,e,r){function n(e){return t(i(e))}var i=sa(e),a=sa(1/e);return n.invert=function(e){return a(t.invert(e))},n.domain=function(e){return arguments.length?(t.domain((r=e.map(Number)).map(i)),n):r},n.ticks=function(t){return ea(r,t)},n.tickFormat=function(t,e){return ra(r,t,e)},n.nice=function(t){return n.domain(Ji(r,t))},n.exponent=function(o){return arguments.length?(i=sa(e=o),a=sa(1/e),t.domain(r.map(i)),n):e},n.copy=function(){return oa(t.copy(),e,r)},Qi(n,t)}function sa(t){return function(e){return 0>e?-Math.pow(-e,t):Math.pow(e,t)}}function la(t,e){function r(r){return a[((i.get(r)||("range"===e.t?i.set(r,t.push(r)):NaN))-1)%a.length]}function n(e,r){return co.range(t.length).map(function(t){return e+r*t})}var i,a,o;return r.domain=function(n){if(!arguments.length)return t;t=[],i=new f;for(var a,o=-1,s=n.length;++or?[NaN,NaN]:[r>0?s[r-1]:t[0],re?NaN:e/a+t,[e,e+1/a]},n.copy=function(){return ua(t,e,r)},i()}function fa(t,e){function r(r){return r>=r?e[co.bisect(t,r)]:void 0}return r.domain=function(e){return arguments.length?(t=e,r):t},r.range=function(t){return arguments.length?(e=t,r):e},r.invertExtent=function(r){return r=e.indexOf(r),[t[r-1],t[r]]},r.copy=function(){return fa(t,e)},r}function ha(t){function e(t){return+t}return e.invert=e,e.domain=e.range=function(r){return arguments.length?(t=r.map(e),e):t},e.ticks=function(e){return ea(t,e)},e.tickFormat=function(e,r){return ra(t,e,r)},e.copy=function(){return ha(t)},e}function da(){return 0}function pa(t){return t.innerRadius}function ga(t){return t.outerRadius}function va(t){return t.startAngle}function ma(t){return t.endAngle}function ya(t){return t&&t.padAngle}function ba(t,e,r,n){return(t-r)*e-(e-n)*t>0?0:1}function xa(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,c=-s*a,u=t[0]+l,f=t[1]+c,h=e[0]+l,d=e[1]+c,p=(u+h)/2,g=(f+d)/2,v=h-u,m=d-f,y=v*v+m*m,b=r-n,x=u*d-h*f,_=(0>m?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*m-v*_)/y,k=(-x*v-m*_)/y,A=(x*m+v*_)/y,M=(-x*v+m*_)/y,T=w-p,E=k-g,L=A-p,S=M-g;return T*T+E*E>L*L+S*S&&(w=A,k=M),[[w-l,k-c],[w*r/b,k*r/b]]}function _a(t){function e(e){function o(){c.push("M",a(t(u),s))}for(var l,c=[],u=[],f=-1,h=e.length,d=Lt(r),p=Lt(n);++f1?t.join("L"):t+"Z"}function ka(t){return t.join("L")+"Z"}function Aa(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1&&i.push("H",n[0]),i.join("")}function Ma(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var c=2;c9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));for(s=-1;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}function Ua(t){return t.length<3?wa(t):t[0]+Ca(t,Ba(t))}function Va(t){for(var e,r,n,i=-1,a=t.length;++i=e?o(t-e):void(c.c=o)}function o(r){var i=p.active,a=p[i];a&&(a.timer.c=null,a.timer.t=NaN,--p.count,delete p[i],a.event&&a.event.interrupt.call(t,t.__data__,a.index));for(var o in p)if(n>+o){var f=p[o];f.timer.c=null,f.timer.t=NaN,--p.count,delete p[o]}c.c=s,Rt(function(){return c.c&&s(r||1)&&(c.c=null,c.t=NaN),1},0,l),p.active=n,g.event&&g.event.start.call(t,t.__data__,e),d=[],g.tween.forEach(function(r,n){(n=n.call(t,t.__data__,e))&&d.push(n)}),h=g.ease,u=g.duration}function s(i){for(var a=i/u,o=h(a),s=d.length;s>0;)d[--s].call(t,o);return a>=1?(g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[n]:delete t[r],1):void 0}var l,c,u,h,d,p=t[r]||(t[r]={active:0,count:0}),g=p[n];g||(l=i.time,c=Rt(a,0,l),g=p[n]={tween:new f,time:l,timer:c,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++p.count)}function ro(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate("+(isFinite(n)?n:r(t))+",0)"})}function no(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate(0,"+(isFinite(n)?n:r(t))+")"})}function io(t){return t.toISOString()}function ao(t,e,r){function n(e){return t(e)}function i(t,r){var n=t[1]-t[0],i=n/r,a=co.bisect(tc,i);return a==tc.length?[e.year,ta(t.map(function(t){return t/31536e6}),r)[2]]:a?e[i/tc[a-1]1?{floor:function(e){for(;r(e=t.floor(e));)e=oo(e-1);return e},ceil:function(e){for(;r(e=t.ceil(e));)e=oo(+e+1);return e}}:t))},n.ticks=function(t,e){var r=Gi(n.domain()),a=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return a&&(t=a[0],e=a[1]),t.range(r[0],oo(+r[1]+1),1>e?1:e)},n.tickFormat=function(){return r},n.copy=function(){return ao(t.copy(),e,r)},Qi(n,t)}function oo(t){return new Date(t)}function so(t){return JSON.parse(t.responseText)}function lo(t){var e=ho.createRange();return e.selectNode(ho.body),e.createContextualFragment(t.responseText)}var co={version:"3.5.16"},uo=[].slice,fo=function(t){return uo.call(t); +},ho=this.document;if(ho)try{fo(ho.documentElement.childNodes)[0].nodeType}catch(po){fo=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),ho)try{ho.createElement("DIV").style.setProperty("opacity",0,"")}catch(go){var vo=this.Element.prototype,mo=vo.setAttribute,yo=vo.setAttributeNS,bo=this.CSSStyleDeclaration.prototype,xo=bo.setProperty;vo.setAttribute=function(t,e){mo.call(this,t,e+"")},vo.setAttributeNS=function(t,e,r){yo.call(this,t,e,r+"")},bo.setProperty=function(t,e,r){xo.call(this,t,e+"",r)}}co.ascending=i,co.descending=function(t,e){return t>e?-1:e>t?1:e>=t?0:NaN},co.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},co.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},co.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}else{for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}return[r,i]},co.sum=function(t,e){var r,n=0,i=t.length,a=-1;if(1===arguments.length)for(;++a1?l/(u-1):void 0},co.deviation=function(){var t=co.variance.apply(this,arguments);return t?Math.sqrt(t):t};var _o=s(i);co.bisectLeft=_o.left,co.bisect=co.bisectRight=_o.right,co.bisector=function(t){return s(1===t.length?function(e,r){return i(t(e),r)}:t)},co.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,2>a&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},co.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},co.pairs=function(t){for(var e,r=0,n=t.length-1,i=t[0],a=new Array(0>n?0:n);n>r;)a[r]=[e=i,i=t[++r]];return a},co.transpose=function(t){if(!(i=t.length))return[];for(var e=-1,r=co.min(t,l),n=new Array(r);++e=0;)for(n=t[i],e=n.length;--e>=0;)r[--o]=n[e];return r};var wo=Math.abs;co.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r===1/0)throw new Error("infinite range");var n,i=[],a=c(wo(r)),o=-1;if(t*=a,e*=a,r*=a,0>r)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=a.length)return n?n.call(i,o):r?o.sort(r):o;for(var l,c,u,h,d=-1,p=o.length,g=a[s++],v=new f;++d=a.length)return t;var n=[],i=o[r++];return t.forEach(function(t,i){n.push({key:t,values:e(i,r)})}),i?n.sort(function(t,e){return i(t.key,e.key)}):n}var r,n,i={},a=[],o=[];return i.map=function(e,r){return t(r,e,0)},i.entries=function(r){return e(t(co.map,r,0),0)},i.key=function(t){return a.push(t),i},i.sortKeys=function(t){return o[a.length-1]=t,i},i.sortValues=function(t){return r=t,i},i.rollup=function(t){return n=t,i},i},co.set=function(t){var e=new b;if(t)for(var r=0,n=t.length;n>r;++r)e.add(t[r]);return e},u(b,{has:p,add:function(t){return this._[h(t+="")]=!0,t},remove:g,values:v,size:m,empty:y,forEach:function(t){for(var e in this._)t.call(this,d(e))}}),co.behavior={},co.rebind=function(t,e){for(var r,n=1,i=arguments.length;++n=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},co.event=null,co.requote=function(t){return t.replace(To,"\\$&")};var To=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Eo={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]},Lo=function(t,e){return e.querySelector(t)},So=function(t,e){return e.querySelectorAll(t)},Co=function(t,e){var r=t.matches||t[w(t,"matchesSelector")];return(Co=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(Lo=function(t,e){return Sizzle(t,e)[0]||null},So=Sizzle,Co=Sizzle.matchesSelector),co.selection=function(){return co.select(ho.documentElement)};var zo=co.selection.prototype=[];zo.select=function(t){var e,r,n,i,a=[];t=C(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Ro.hasOwnProperty(r)?{space:Ro[r],local:t}:t}},zo.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node();return t=co.ns.qualify(t),t.local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}for(e in t)this.each(P(e,t[e]));return this}return this.each(P(t,e))},zo.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=I(t)).length,i=-1;if(e=r.classList){for(;++ii){if("string"!=typeof t){2>i&&(e="");for(r in t)this.each(F(r,t[r],e));return this}if(2>i){var a=this.node();return n(a).getComputedStyle(a,null).getPropertyValue(t)}r=""}return this.each(F(t,e,r))},zo.property=function(t,e){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(e in t)this.each(D(e,t[e]));return this}return this.each(D(t,e))},zo.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},zo.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},zo.append=function(t){return t=B(t),this.select(function(){return this.appendChild(t.apply(this,arguments))})},zo.insert=function(t,e){return t=B(t),e=C(e),this.select(function(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)})},zo.remove=function(){return this.each(U)},zo.data=function(t,e){function r(t,r){var n,i,a,o=t.length,u=r.length,h=Math.min(o,u),d=new Array(u),p=new Array(u),g=new Array(o);if(e){var v,m=new f,y=new Array(o);for(n=-1;++nn;++n)p[n]=V(r[n]);for(;o>n;++n)g[n]=t[n]}p.update=d,p.parentNode=d.parentNode=g.parentNode=t.parentNode,s.push(p),l.push(d),c.push(g)}var n,i,a=-1,o=this.length;if(!arguments.length){for(t=new Array(o=(n=this[0]).length);++aa;a++){i.push(e=[]),e.parentNode=(r=this[a]).parentNode;for(var s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return S(i)},zo.order=function(){for(var t=-1,e=this.length;++t=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},zo.sort=function(t){t=H.apply(this,arguments);for(var e=-1,r=this.length;++et;t++)for(var r=this[t],n=0,i=r.length;i>n;n++){var a=r[n];if(a)return a}return null},zo.size=function(){var t=0;return G(this,function(){++t}),t};var Oo=[];co.selection.enter=Y,co.selection.enter.prototype=Oo,Oo.append=zo.append,Oo.empty=zo.empty,Oo.node=zo.node,Oo.call=zo.call,Oo.size=zo.size,Oo.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++sn){if("string"!=typeof t){2>n&&(e=!1);for(r in t)this.each(W(r,t[r],e));return this}if(2>n)return(n=this.node()["__on"+t])&&n._;r=!1}return this.each(W(t,e,r))};var Io=co.map({mouseenter:"mouseover",mouseleave:"mouseout"});ho&&Io.forEach(function(t){"on"+t in ho&&Io.remove(t)});var No,jo=0;co.mouse=function(t){return Q(t,E())};var Fo=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;co.touch=function(t,e,r){if(arguments.length<3&&(r=e,e=E().changedTouches),e)for(var n,i=0,a=e.length;a>i;++i)if((n=e[i]).identifier===r)return Q(t,n)},co.behavior.drag=function(){function t(){this.on("mousedown.drag",a).on("touchstart.drag",o)}function e(t,e,n,a,o){return function(){function s(){var t,r,n=e(h,g);n&&(t=n[0]-b[0],r=n[1]-b[1],p|=t|r,b=n,d({type:"drag",x:n[0]+c[0],y:n[1]+c[1],dx:t,dy:r}))}function l(){e(h,g)&&(m.on(a+v,null).on(o+v,null),y(p),d({type:"dragend"}))}var c,u=this,f=co.event.target.correspondingElement||co.event.target,h=u.parentNode,d=r.of(u,arguments),p=0,g=t(),v=".drag"+(null==g?"":"-"+g),m=co.select(n(f)).on(a+v,s).on(o+v,l),y=$(f),b=e(h,g);i?(c=i.apply(u,arguments),c=[c.x-b[0],c.y-b[1]]):c=[0,0],d({type:"dragstart"})}}var r=L(t,"drag","dragstart","dragend"),i=null,a=e(k,co.mouse,n,"mousemove","mouseup"),o=e(J,co.touch,x,"touchmove","touchend");return t.origin=function(e){return arguments.length?(i=e,t):i},co.rebind(t,r,"on")},co.touches=function(t,e){return arguments.length<2&&(e=E().touches),e?fo(e).map(function(e){var r=Q(t,e);return r.identifier=e.identifier,r}):[]};var Do=1e-6,Bo=Do*Do,Uo=Math.PI,Vo=2*Uo,qo=Vo-Do,Ho=Uo/2,Go=Uo/180,Yo=180/Uo,Xo=Math.SQRT2,Wo=2,Zo=4;co.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],c=e[2],u=s-i,f=l-a,h=u*u+f*f;if(Bo>h)n=Math.log(c/o)/Xo,r=function(t){return[i+t*u,a+t*f,o*Math.exp(Xo*t*n)]};else{var d=Math.sqrt(h),p=(c*c-o*o+Zo*h)/(2*o*Wo*d),g=(c*c-o*o-Zo*h)/(2*c*Wo*d),v=Math.log(Math.sqrt(p*p+1)-p),m=Math.log(Math.sqrt(g*g+1)-g);n=(m-v)/Xo,r=function(t){var e=t*n,r=at(v),s=o/(Wo*d)*(r*ot(Xo*e+v)-it(v));return[i+s*u,a+s*f,o*r/at(Xo*e+v)]}}return r.duration=1e3*n,r},co.behavior.zoom=function(){function t(t){t.on(z,f).on($o+".zoom",d).on("dblclick.zoom",p).on(O,h)}function e(t){return[(t[0]-A.x)/A.k,(t[1]-A.y)/A.k]}function r(t){return[t[0]*A.k+A.x,t[1]*A.k+A.y]}function i(t){A.k=Math.max(E[0],Math.min(E[1],t))}function a(t,e){e=r(e),A.x+=t[0]-e[0],A.y+=t[1]-e[1]}function o(e,r,n,o){e.__chart__={x:A.x,y:A.y,k:A.k},i(Math.pow(2,o)),a(v=r,n),e=co.select(e),S>0&&(e=e.transition().duration(S)),e.call(t.event)}function s(){_&&_.domain(x.range().map(function(t){return(t-A.x)/A.k}).map(x.invert)),k&&k.domain(w.range().map(function(t){return(t-A.y)/A.k}).map(w.invert))}function l(t){C++||t({type:"zoomstart"})}function c(t){s(),t({type:"zoom",scale:A.k,translate:[A.x,A.y]})}function u(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){s=1,a(co.mouse(i),h),c(o)}function r(){f.on(P,null).on(R,null),d(s),u(o)}var i=this,o=I.of(i,arguments),s=0,f=co.select(n(i)).on(P,t).on(R,r),h=e(co.mouse(i)),d=$(i);Hl.call(i),l(o)}function h(){function t(){var t=co.touches(p);return d=A.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function r(){var e=co.event.target;co.select(e).on(x,n).on(_,s),w.push(e);for(var r=co.event.changedTouches,i=0,a=r.length;a>i;++i)v[r[i].identifier]=null;var l=t(),c=Date.now();if(1===l.length){if(500>c-b){var u=l[0];o(p,u,v[u.identifier],Math.floor(Math.log(A.k)/Math.LN2)+1),T()}b=c}else if(l.length>1){var u=l[0],f=l[1],h=u[0]-f[0],d=u[1]-f[1];m=h*h+d*d}}function n(){var t,e,r,n,o=co.touches(p);Hl.call(p);for(var s=0,l=o.length;l>s;++s,n=null)if(r=o[s],n=v[r.identifier]){if(e)break;t=r,e=n}if(n){var u=(u=r[0]-t[0])*u+(u=r[1]-t[1])*u,f=m&&Math.sqrt(u/m);t=[(t[0]+r[0])/2,(t[1]+r[1])/2],e=[(e[0]+n[0])/2,(e[1]+n[1])/2],i(f*d)}b=null,a(t,e),c(g)}function s(){if(co.event.touches.length){for(var e=co.event.changedTouches,r=0,n=e.length;n>r;++r)delete v[e[r].identifier];for(var i in v)return void t()}co.selectAll(w).on(y,null),k.on(z,f).on(O,h),M(),u(g)}var d,p=this,g=I.of(p,arguments),v={},m=0,y=".zoom-"+co.event.changedTouches[0].identifier,x="touchmove"+y,_="touchend"+y,w=[],k=co.select(p),M=$(p);r(),l(g),k.on(z,null).on(O,r)}function d(){var t=I.of(this,arguments);y?clearTimeout(y):(Hl.call(this),g=e(v=m||co.mouse(this)),l(t)),y=setTimeout(function(){y=null,u(t)},50),T(),i(Math.pow(2,.002*Ko())*A.k),a(v,g),c(t)}function p(){var t=co.mouse(this),r=Math.log(A.k)/Math.LN2;o(this,t,e(t),co.event.shiftKey?Math.ceil(r)-1:Math.floor(r)+1)}var g,v,m,y,b,x,_,w,k,A={x:0,y:0,k:1},M=[960,500],E=Qo,S=250,C=0,z="mousedown.zoom",P="mousemove.zoom",R="mouseup.zoom",O="touchstart.zoom",I=L(t,"zoomstart","zoom","zoomend");return $o||($o="onwheel"in ho?(Ko=function(){return-co.event.deltaY*(co.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ho?(Ko=function(){return co.event.wheelDelta},"mousewheel"):(Ko=function(){return-co.event.detail},"MozMousePixelScroll")),t.event=function(t){t.each(function(){var t=I.of(this,arguments),e=A;Vl?co.select(this).transition().each("start.zoom",function(){A=this.__chart__||{x:0,y:0,k:1},l(t)}).tween("zoom:zoom",function(){var r=M[0],n=M[1],i=v?v[0]:r/2,a=v?v[1]:n/2,o=co.interpolateZoom([(i-A.x)/A.k,(a-A.y)/A.k,r/A.k],[(i-e.x)/e.k,(a-e.y)/e.k,r/e.k]);return function(e){var n=o(e),s=r/n[2];this.__chart__=A={x:i-n[0]*s,y:a-n[1]*s,k:s},c(t)}}).each("interrupt.zoom",function(){u(t)}).each("end.zoom",function(){u(t)}):(this.__chart__=A,l(t),c(t),u(t))})},t.translate=function(e){return arguments.length?(A={x:+e[0],y:+e[1],k:A.k},s(),t):[A.x,A.y]},t.scale=function(e){return arguments.length?(A={x:A.x,y:A.y,k:null},i(+e),s(),t):A.k},t.scaleExtent=function(e){return arguments.length?(E=null==e?Qo:[+e[0],+e[1]],t):E},t.center=function(e){return arguments.length?(m=e&&[+e[0],+e[1]],t):m},t.size=function(e){return arguments.length?(M=e&&[+e[0],+e[1]],t):M},t.duration=function(e){return arguments.length?(S=+e,t):S},t.x=function(e){return arguments.length?(_=e,x=e.copy(),A={x:0,y:0,k:1},t):_},t.y=function(e){return arguments.length?(k=e,w=e.copy(),A={x:0,y:0,k:1},t):k},co.rebind(t,I,"on")};var Ko,$o,Qo=[0,1/0];co.color=lt,lt.prototype.toString=function(){return this.rgb()+""},co.hsl=ct;var Jo=ct.prototype=new lt;Jo.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,this.l/t)},Jo.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,t*this.l)},Jo.rgb=function(){return ut(this.h,this.s,this.l)},co.hcl=ft;var ts=ft.prototype=new lt;ts.brighter=function(t){return new ft(this.h,this.c,Math.min(100,this.l+es*(arguments.length?t:1)))},ts.darker=function(t){return new ft(this.h,this.c,Math.max(0,this.l-es*(arguments.length?t:1)))},ts.rgb=function(){return ht(this.h,this.c,this.l).rgb()},co.lab=dt;var es=18,rs=.95047,ns=1,is=1.08883,as=dt.prototype=new lt;as.brighter=function(t){return new dt(Math.min(100,this.l+es*(arguments.length?t:1)),this.a,this.b)},as.darker=function(t){return new dt(Math.max(0,this.l-es*(arguments.length?t:1)),this.a,this.b)},as.rgb=function(){return pt(this.l,this.a,this.b)},co.rgb=bt;var os=bt.prototype=new lt;os.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&i>e&&(e=i),r&&i>r&&(r=i),n&&i>n&&(n=i),new bt(Math.min(255,e/t),Math.min(255,r/t),Math.min(255,n/t))):new bt(i,i,i)},os.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new bt(t*this.r,t*this.g,t*this.b)},os.hsl=function(){return At(this.r,this.g,this.b)},os.toString=function(){return"#"+wt(this.r)+wt(this.g)+wt(this.b)};var ss=co.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ss.forEach(function(t,e){ss.set(t,xt(e))}),co.functor=Lt,co.xhr=St(x),co.dsv=function(t,e){function r(t,r,a){arguments.length<3&&(a=r,r=null);var o=Ct(t,e,null==r?n:i(r),a);return o.row=function(t){return arguments.length?o.response(null==(r=t)?n:i(t)):r},o}function n(t){return r.parse(t.responseText)}function i(t){return function(e){return r.parse(e.responseText,t)}}function a(e){return e.map(o).join(t)}function o(t){return s.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var s=new RegExp('["'+t+"\n]"),l=t.charCodeAt(0);return r.parse=function(t,e){var n;return r.parseRows(t,function(t,r){if(n)return n(t,r-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");n=e?function(t,r){return e(i(t),r)}:i})},r.parseRows=function(t,e){function r(){if(u>=c)return o;if(i)return i=!1,a;var e=u;if(34===t.charCodeAt(e)){for(var r=e;r++u;){var n=t.charCodeAt(u++),s=1;if(10===n)i=!0;else if(13===n)i=!0,10===t.charCodeAt(u)&&(++u,++s);else if(n!==l)continue;return t.slice(e,u-s)}return t.slice(e)}for(var n,i,a={},o={},s=[],c=t.length,u=0,f=0;(n=r())!==o;){for(var h=[];n!==a&&n!==o;)h.push(n),n=r();e&&null==(h=e(h,f++))||s.push(h)}return s},r.format=function(e){if(Array.isArray(e[0]))return r.formatRows(e);var n=new b,i=[];return e.forEach(function(t){for(var e in t)n.has(e)||i.push(n.add(e))}),[i.map(o).join(t)].concat(e.map(function(e){return i.map(function(t){return o(e[t])}).join(t)})).join("\n")},r.formatRows=function(t){return t.map(a).join("\n")},r},co.csv=co.dsv(",","text/csv"),co.tsv=co.dsv(" ","text/tab-separated-values");var ls,cs,us,fs,hs=this[w(this,"requestAnimationFrame")]||function(t){setTimeout(t,17)};co.timer=function(){Rt.apply(this,arguments)},co.timer.flush=function(){It(),Nt()},co.round=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)};var ds=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Ft);co.formatPrefix=function(t,e){var r=0;return(t=+t)&&(0>t&&(t*=-1),e&&(t=co.round(t,jt(t,e))),r=1+Math.floor(1e-12+Math.log(t)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),ds[8+r/3]};var ps=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,gs=co.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=co.round(t,jt(t,e))).toFixed(Math.max(0,Math.min(20,jt(t*(1+1e-15),e))))}}),vs=co.time={},ms=Date;Ut.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ys.setUTCDate.apply(this._,arguments)},setDay:function(){ys.setUTCDay.apply(this._,arguments)},setFullYear:function(){ys.setUTCFullYear.apply(this._,arguments)},setHours:function(){ys.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ys.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ys.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ys.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ys.setUTCSeconds.apply(this._,arguments)},setTime:function(){ys.setTime.apply(this._,arguments)}};var ys=Date.prototype;vs.year=Vt(function(t){return t=vs.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),vs.years=vs.year.range,vs.years.utc=vs.year.utc.range,vs.day=Vt(function(t){var e=new ms(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),vs.days=vs.day.range,vs.days.utc=vs.day.utc.range,vs.dayOfYear=function(t){var e=vs.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var r=vs[t]=Vt(function(t){return(t=vs.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)-(r!==e)});vs[t+"s"]=r.range,vs[t+"s"].utc=r.utc.range,vs[t+"OfYear"]=function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)}}),vs.week=vs.sunday,vs.weeks=vs.sunday.range,vs.weeks.utc=vs.sunday.utc.range,vs.weekOfYear=vs.sundayOfYear;var bs={"-":"",_:" ",0:"0"},xs=/^\s*\d+/,_s=/^%/;co.locale=function(t){return{numberFormat:Dt(t),timeFormat:Ht(t)}};var ws=co.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});co.format=ws.numberFormat,co.geo={},fe.prototype={s:0,t:0,add:function(t){he(t,this.t,ks),he(ks.s,this.s,this),this.s?this.t+=ks.t:this.s=ks.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ks=new fe;co.geo.stream=function(t,e){t&&As.hasOwnProperty(t.type)?As[t.type](t,e):de(t,e)};var As={Feature:function(t,e){de(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++nt?4*Uo+t:t,Ls.lineStart=Ls.lineEnd=Ls.point=k}};co.geo.bounds=function(){function t(t,e){b.push(x=[u=t,h=t]),f>e&&(f=e),e>d&&(d=e)}function e(e,r){var n=me([e*Go,r*Go]);if(m){var i=be(m,n),a=[i[1],-i[0],0],o=be(a,i);we(o),o=ke(o);var l=e-p,c=l>0?1:-1,g=o[0]*Yo*c,v=wo(l)>180;if(v^(g>c*p&&c*e>g)){var y=o[1]*Yo;y>d&&(d=y)}else if(g=(g+360)%360-180,v^(g>c*p&&c*e>g)){var y=-o[1]*Yo;f>y&&(f=y)}else f>r&&(f=r),r>d&&(d=r);v?p>e?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e):h>=u?(u>e&&(u=e),e>h&&(h=e)):e>p?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e)}else t(e,r);m=n,p=e}function r(){_.point=e}function n(){x[0]=u,x[1]=h,_.point=t,m=null}function i(t,r){if(m){var n=t-p;y+=wo(n)>180?n+(n>0?360:-360):n}else g=t,v=r;Ls.point(t,r),e(t,r)}function a(){Ls.lineStart()}function o(){i(g,v),Ls.lineEnd(),wo(y)>Do&&(u=-(h=180)),x[0]=u,x[1]=h,m=null}function s(t,e){return(e-=t)<0?e+360:e}function l(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tEs?(u=-(h=180),f=-(d=90)):y>Do?d=90:-Do>y&&(f=-90),x[0]=u,x[1]=h}};return function(t){d=h=-(u=f=1/0),b=[],co.geo.stream(t,_);var e=b.length;if(e){b.sort(l);for(var r,n=1,i=b[0],a=[i];e>n;++n)r=b[n],c(r[0],i)||c(r[1],i)?(s(i[0],r[1])>s(i[0],i[1])&&(i[1]=r[1]),s(r[0],i[1])>s(i[0],i[1])&&(i[0]=r[0])):a.push(i=r);for(var o,r,p=-(1/0),e=a.length-1,n=0,i=a[e];e>=n;i=r,++n)r=a[n],(o=s(i[1],r[0]))>p&&(p=o,u=r[0],h=i[1])}return b=x=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[h,d]]}}(),co.geo.centroid=function(t){Ss=Cs=zs=Ps=Rs=Os=Is=Ns=js=Fs=Ds=0,co.geo.stream(t,Bs);var e=js,r=Fs,n=Ds,i=e*e+r*r+n*n;return Bo>i&&(e=Os,r=Is,n=Ns,Do>Cs&&(e=zs,r=Ps,n=Rs),i=e*e+r*r+n*n,Bo>i)?[NaN,NaN]:[Math.atan2(r,e)*Yo,nt(n/Math.sqrt(i))*Yo]};var Ss,Cs,zs,Ps,Rs,Os,Is,Ns,js,Fs,Ds,Bs={sphere:k,point:Me,lineStart:Ee,lineEnd:Le,polygonStart:function(){Bs.lineStart=Se},polygonEnd:function(){Bs.lineStart=Ee}},Us=Ie(ze,De,Ue,[-Uo,-Uo/2]),Vs=1e9;co.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),i=a(t),i.valid=!0,i},extent:function(s){return arguments.length?(a=Ge(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(co.geo.conicEqualArea=function(){return Ye(Xe)}).raw=Xe,co.geo.albers=function(){return co.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},co.geo.albersUsa=function(){ +function t(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}var e,r,n,i,a=co.geo.albers(),o=co.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=co.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};return t.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&.234>i&&n>=-.425&&-.214>n?o:i>=.166&&.234>i&&n>=-.214&&-.115>n?s:a).invert(t)},t.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},t.precision=function(e){return arguments.length?(a.precision(e),o.precision(e),s.precision(e),t):a.precision()},t.scale=function(e){return arguments.length?(a.scale(e),o.scale(.35*e),s.scale(e),t.translate(a.translate())):a.scale()},t.translate=function(e){if(!arguments.length)return a.translate();var c=a.scale(),u=+e[0],f=+e[1];return r=a.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(l).point,n=o.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+Do,f+.12*c+Do],[u-.214*c-Do,f+.234*c-Do]]).stream(l).point,i=s.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+Do,f+.166*c+Do],[u-.115*c-Do,f+.234*c-Do]]).stream(l).point,t},t.scale(1070)};var qs,Hs,Gs,Ys,Xs,Ws,Zs={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Hs=0,Zs.lineStart=We},polygonEnd:function(){Zs.lineStart=Zs.lineEnd=Zs.point=k,qs+=wo(Hs/2)}},Ks={point:Ze,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},$s={point:Qe,lineStart:Je,lineEnd:tr,polygonStart:function(){$s.lineStart=er},polygonEnd:function(){$s.point=Qe,$s.lineStart=Je,$s.lineEnd=tr}};co.geo.path=function(){function t(t){return t&&("function"==typeof s&&a.pointRadius(+s.apply(this,arguments)),o&&o.valid||(o=i(a)),co.geo.stream(t,o)),a.result()}function e(){return o=null,t}var r,n,i,a,o,s=4.5;return t.area=function(t){return qs=0,co.geo.stream(t,i(Zs)),qs},t.centroid=function(t){return zs=Ps=Rs=Os=Is=Ns=js=Fs=Ds=0,co.geo.stream(t,i($s)),Ds?[js/Ds,Fs/Ds]:Ns?[Os/Ns,Is/Ns]:Rs?[zs/Rs,Ps/Rs]:[NaN,NaN]},t.bounds=function(t){return Xs=Ws=-(Gs=Ys=1/0),co.geo.stream(t,i(Ks)),[[Gs,Ys],[Xs,Ws]]},t.projection=function(t){return arguments.length?(i=(r=t)?t.stream||ir(t):x,e()):r},t.context=function(t){return arguments.length?(a=null==(n=t)?new Ke:new rr(t),"function"!=typeof s&&a.pointRadius(s),e()):n},t.pointRadius=function(e){return arguments.length?(s="function"==typeof e?e:(a.pointRadius(+e),+e),t):s},t.projection(co.geo.albersUsa()).context(null)},co.geo.transform=function(t){return{stream:function(e){var r=new ar(e);for(var n in t)r[n]=t[n];return r}}},ar.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},co.geo.projection=sr,co.geo.projectionMutator=lr,(co.geo.equirectangular=function(){return sr(ur)}).raw=ur.invert=ur,co.geo.rotation=function(t){function e(e){return e=t(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e}return t=hr(t[0]%360*Go,t[1]*Go,t.length>2?t[2]*Go:0),e.invert=function(e){return e=t.invert(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e},e},fr.invert=ur,co.geo.circle=function(){function t(){var t="function"==typeof n?n.apply(this,arguments):n,e=hr(-t[0]*Go,-t[1]*Go,0).invert,i=[];return r(null,null,1,{point:function(t,r){i.push(t=e(t,r)),t[0]*=Yo,t[1]*=Yo}}),{type:"Polygon",coordinates:[i]}}var e,r,n=[0,0],i=6;return t.origin=function(e){return arguments.length?(n=e,t):n},t.angle=function(n){return arguments.length?(r=vr((e=+n)*Go,i*Go),t):e},t.precision=function(n){return arguments.length?(r=vr(e*Go,(i=+n)*Go),t):i},t.angle(90)},co.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Go,i=t[1]*Go,a=e[1]*Go,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),c=Math.cos(i),u=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-l*f*s)*r),l*u+c*f*s)},co.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return co.range(Math.ceil(a/v)*v,i,v).map(h).concat(co.range(Math.ceil(c/m)*m,l,m).map(d)).concat(co.range(Math.ceil(n/p)*p,r,p).filter(function(t){return wo(t%v)>Do}).map(u)).concat(co.range(Math.ceil(s/g)*g,o,g).filter(function(t){return wo(t%m)>Do}).map(f))}var r,n,i,a,o,s,l,c,u,f,h,d,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[h(a).concat(d(l).slice(1),h(i).reverse().slice(1),d(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(a=+e[0][0],i=+e[1][0],c=+e[0][1],l=+e[1][1],a>i&&(e=a,a=i,i=e),c>l&&(e=c,c=l,l=e),t.precision(y)):[[a,c],[i,l]]},t.minorExtent=function(e){return arguments.length?(n=+e[0][0],r=+e[1][0],s=+e[0][1],o=+e[1][1],n>r&&(e=n,n=r,r=e),s>o&&(e=s,s=o,o=e),t.precision(y)):[[n,s],[r,o]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=yr(s,o,90),f=br(n,r,y),h=yr(c,l,90),d=br(a,i,y),t):y},t.majorExtent([[-180,-90+Do],[180,90-Do]]).minorExtent([[-180,-80-Do],[180,80+Do]])},co.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}var e,r,n=xr,i=_r;return t.distance=function(){return co.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},t.source=function(r){return arguments.length?(n=r,e="function"==typeof r?null:r,t):n},t.target=function(e){return arguments.length?(i=e,r="function"==typeof e?null:e,t):i},t.precision=function(){return arguments.length?t:0},t},co.geo.interpolate=function(t,e){return wr(t[0]*Go,t[1]*Go,e[0]*Go,e[1]*Go)},co.geo.length=function(t){return Qs=0,co.geo.stream(t,Js),Qs};var Qs,Js={sphere:k,point:k,lineStart:kr,lineEnd:k,polygonStart:k,polygonEnd:k},tl=Ar(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(co.geo.azimuthalEqualArea=function(){return sr(tl)}).raw=tl;var el=Ar(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},x);(co.geo.azimuthalEquidistant=function(){return sr(el)}).raw=el,(co.geo.conicConformal=function(){return Ye(Mr)}).raw=Mr,(co.geo.conicEquidistant=function(){return Ye(Tr)}).raw=Tr;var rl=Ar(function(t){return 1/t},Math.atan);(co.geo.gnomonic=function(){return sr(rl)}).raw=rl,Er.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Ho]},(co.geo.mercator=function(){return Lr(Er)}).raw=Er;var nl=Ar(function(){return 1},Math.asin);(co.geo.orthographic=function(){return sr(nl)}).raw=nl;var il=Ar(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(co.geo.stereographic=function(){return sr(il)}).raw=il,Sr.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ho]},(co.geo.transverseMercator=function(){var t=Lr(Sr),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):(t=r(),[t[0],t[1],t[2]-90])},r([0,0,90])}).raw=Sr,co.geom={},co.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,i=Lt(r),a=Lt(n),o=t.length,s=[],l=[];for(e=0;o>e;e++)s.push([+i.call(this,t[e],e),+a.call(this,t[e],e),e]);for(s.sort(Rr),e=0;o>e;e++)l.push([s[e][0],-s[e][1]]);var c=Pr(s),u=Pr(l),f=u[0]===c[0],h=u[u.length-1]===c[c.length-1],d=[];for(e=c.length-1;e>=0;--e)d.push(t[s[c[e]][2]]);for(e=+f;e=n&&c.x<=a&&c.y>=i&&c.y<=o?[[n,o],[a,o],[a,i],[n,i]]:[];u.point=t[s]}),e}function r(t){return t.map(function(t,e){return{x:Math.round(a(t,e)/Do)*Do,y:Math.round(o(t,e)/Do)*Do,i:e}})}var n=Cr,i=zr,a=n,o=i,s=dl;return t?e(t):(e.links=function(t){return cn(r(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cn(r(t)).cells.forEach(function(r,n){for(var i,a,o=r.site,s=r.edges.sort(Yr),l=-1,c=s.length,u=s[c-1].edge,f=u.l===o?u.r:u.l;++l=c,h=n>=u,d=h<<1|f;t.leaf=!1,t=t.nodes[d]||(t.nodes[d]=pn()),f?i=c:s=c,h?o=u:l=u,a(t,e,r,n,i,o,s,l)}var u,f,h,d,p,g,v,m,y,b=Lt(s),x=Lt(l);if(null!=e)g=e,v=r,m=n,y=i;else if(m=y=-(g=v=1/0),f=[],h=[],p=t.length,o)for(d=0;p>d;++d)u=t[d],u.xm&&(m=u.x),u.y>y&&(y=u.y),f.push(u.x),h.push(u.y);else for(d=0;p>d;++d){var _=+b(u=t[d],d),w=+x(u,d);g>_&&(g=_),v>w&&(v=w),_>m&&(m=_),w>y&&(y=w),f.push(_),h.push(w)}var k=m-g,A=y-v;k>A?y=v+k:m=g+A;var M=pn();if(M.add=function(t){a(M,t,+b(t,++d),+x(t,d),g,v,m,y)},M.visit=function(t){gn(t,M,g,v,m,y)},M.find=function(t){return vn(M,t[0],t[1],g,v,m,y)},d=-1,null==e){for(;++d=0?t.slice(0,e):t,n=e>=0?t.slice(e+1):"in";return r=ml.get(r)||vl,n=yl.get(n)||x,kn(n(r.apply(null,uo.call(arguments,1))))},co.interpolateHcl=Nn,co.interpolateHsl=jn,co.interpolateLab=Fn,co.interpolateRound=Dn,co.transform=function(t){var e=ho.createElementNS(co.ns.prefix.svg,"g");return(co.transform=function(t){if(null!=t){e.setAttribute("transform",t);var r=e.transform.baseVal.consolidate()}return new Bn(r?r.matrix:bl)})(t)},Bn.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var bl={a:1,b:0,c:0,d:1,e:0,f:0};co.interpolateTransform=Zn,co.layout={},co.layout.bundle=function(){return function(t){for(var e=[],r=-1,n=t.length;++rs*s/m){if(g>l){var c=e.charge/l;t.px-=a*c,t.py-=o*c}return!0}if(e.point&&l&&g>l){var c=e.pointCharge/l;t.px-=a*c,t.py-=o*c}}return!e.charge}}function e(t){t.px=co.event.x,t.py=co.event.y,l.resume()}var r,n,i,a,o,s,l={},c=co.dispatch("start","tick","end"),u=[1,1],f=.9,h=xl,d=_l,p=-30,g=wl,v=.1,m=.64,y=[],b=[];return l.tick=function(){if((i*=.99)<.005)return r=null,c.end({type:"end",alpha:i=0}),!0;var e,n,l,h,d,g,m,x,_,w=y.length,k=b.length;for(n=0;k>n;++n)l=b[n],h=l.source,d=l.target,x=d.x-h.x,_=d.y-h.y,(g=x*x+_*_)&&(g=i*o[n]*((g=Math.sqrt(g))-a[n])/g,x*=g,_*=g,d.x-=x*(m=h.weight+d.weight?h.weight/(h.weight+d.weight):.5),d.y-=_*m,h.x+=x*(m=1-m),h.y+=_*m);if((m=i*v)&&(x=u[0]/2,_=u[1]/2,n=-1,m))for(;++n0?i=t:(r.c=null,r.t=NaN,r=null,c.end({type:"end",alpha:i=0})):t>0&&(c.start({type:"start",alpha:i=t}),r=Rt(l.tick)),l):i},l.start=function(){function t(t,n){if(!r){for(r=new Array(i),l=0;i>l;++l)r[l]=[];for(l=0;c>l;++l){var a=b[l];r[a.source.index].push(a.target),r[a.target.index].push(a.source)}}for(var o,s=r[e],l=-1,u=s.length;++le;++e)(n=y[e]).index=e,n.weight=0;for(e=0;c>e;++e)n=b[e],"number"==typeof n.source&&(n.source=y[n.source]),"number"==typeof n.target&&(n.target=y[n.target]),++n.source.weight,++n.target.weight;for(e=0;i>e;++e)n=y[e],isNaN(n.x)&&(n.x=t("x",f)),isNaN(n.y)&&(n.y=t("y",g)),isNaN(n.px)&&(n.px=n.x),isNaN(n.py)&&(n.py=n.y);if(a=[],"function"==typeof h)for(e=0;c>e;++e)a[e]=+h.call(this,b[e],e);else for(e=0;c>e;++e)a[e]=h;if(o=[],"function"==typeof d)for(e=0;c>e;++e)o[e]=+d.call(this,b[e],e);else for(e=0;c>e;++e)o[e]=d;if(s=[],"function"==typeof p)for(e=0;i>e;++e)s[e]=+p.call(this,y[e],e);else for(e=0;i>e;++e)s[e]=p;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return n||(n=co.behavior.drag().origin(x).on("dragstart.force",ei).on("drag.force",e).on("dragend.force",ri)),arguments.length?void this.on("mouseover.force",ni).on("mouseout.force",ii).call(n):n},co.rebind(l,c,"on")};var xl=20,_l=1,wl=1/0;co.layout.hierarchy=function(){function t(i){var a,o=[i],s=[];for(i.depth=0;null!=(a=o.pop());)if(s.push(a),(c=r.call(t,a,a.depth))&&(l=c.length)){for(var l,c,u;--l>=0;)o.push(u=c[l]),u.parent=a,u.depth=a.depth+1;n&&(a.value=0),a.children=c}else n&&(a.value=+n.call(t,a,a.depth)||0),delete a.children;return li(i,function(t){var r,i;e&&(r=t.children)&&r.sort(e),n&&(i=t.parent)&&(i.value+=t.value)}),s}var e=fi,r=ci,n=ui;return t.sort=function(r){return arguments.length?(e=r,t):e},t.children=function(e){return arguments.length?(r=e,t):r},t.value=function(e){return arguments.length?(n=e,t):n},t.revalue=function(e){return n&&(si(e,function(t){t.children&&(t.value=0)}),li(e,function(e){var r;e.children||(e.value=+n.call(t,e,e.depth)||0),(r=e.parent)&&(r.value+=e.value)})),e},t},co.layout.partition=function(){function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,c=-1;for(n=e.value?n/e.value:0;++cf?-1:1),p=co.sum(c),g=p?(f-l*d)/p:0,v=co.range(l),m=[];return null!=r&&v.sort(r===kl?function(t,e){return c[e]-c[t]}:function(t,e){return r(o[t],o[e])}),v.forEach(function(t){m[t]={data:o[t],value:s=c[t],startAngle:u,endAngle:u+=s*g+d,padAngle:h}}),m}var e=Number,r=kl,n=0,i=Vo,a=0;return t.value=function(r){return arguments.length?(e=r,t):e},t.sort=function(e){return arguments.length?(r=e,t):r},t.startAngle=function(e){return arguments.length?(n=e,t):n},t.endAngle=function(e){return arguments.length?(i=e,t):i},t.padAngle=function(e){return arguments.length?(a=e,t):a},t};var kl={};co.layout.stack=function(){function t(s,l){if(!(h=s.length))return s;var c=s.map(function(r,n){return e.call(t,r,n)}),u=c.map(function(e){return e.map(function(e,r){return[a.call(t,e,r),o.call(t,e,r)]})}),f=r.call(t,u,l);c=co.permute(c,f),u=co.permute(u,f);var h,d,p,g,v=n.call(t,u,l),m=c[0].length;for(p=0;m>p;++p)for(i.call(t,c[0][p],g=v[p],u[0][p][1]),d=1;h>d;++d)i.call(t,c[d][p],g+=u[d-1][p][1],u[d][p][1]);return s}var e=x,r=vi,n=mi,i=gi,a=di,o=pi;return t.values=function(r){return arguments.length?(e=r,t):e},t.order=function(e){return arguments.length?(r="function"==typeof e?e:Al.get(e)||vi,t):r},t.offset=function(e){return arguments.length?(n="function"==typeof e?e:Ml.get(e)||mi,t):n},t.x=function(e){return arguments.length?(a=e,t):a},t.y=function(e){return arguments.length?(o=e,t):o},t.out=function(e){return arguments.length?(i=e,t):i},t};var Al=co.map({"inside-out":function(t){var e,r,n=t.length,i=t.map(yi),a=t.map(bi),o=co.range(n).sort(function(t,e){return i[t]-i[e]}),s=0,l=0,c=[],u=[];for(e=0;n>e;++e)r=o[e],l>s?(s+=a[r],c.push(r)):(l+=a[r],u.push(r));return u.reverse().concat(c)},reverse:function(t){return co.range(t.length).reverse()},"default":vi}),Ml=co.map({silhouette:function(t){var e,r,n,i=t.length,a=t[0].length,o=[],s=0,l=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];n>s&&(s=n),o.push(n)}for(r=0;a>r;++r)l[r]=(s-o[r])/2;return l},wiggle:function(t){var e,r,n,i,a,o,s,l,c,u=t.length,f=t[0],h=f.length,d=[];for(d[0]=l=c=0,r=1;h>r;++r){for(e=0,i=0;u>e;++e)i+=t[e][r][1];for(e=0,a=0,s=f[r][0]-f[r-1][0];u>e;++e){for(n=0,o=(t[e][r][1]-t[e][r-1][1])/(2*s);e>n;++n)o+=(t[n][r][1]-t[n][r-1][1])/s;a+=o*t[e][r][1]}d[r]=l-=i?a/i*s:0,c>l&&(c=l)}for(r=0;h>r;++r)d[r]-=c;return d},expand:function(t){var e,r,n,i=t.length,a=t[0].length,o=1/i,s=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];if(n)for(e=0;i>e;e++)t[e][r][1]/=n;else for(e=0;i>e;e++)t[e][r][1]=o}for(r=0;a>r;++r)s[r]=0;return s},zero:mi});co.layout.histogram=function(){function t(t,a){for(var o,s,l=[],c=t.map(r,this),u=n.call(this,c,a),f=i.call(this,u,c,a),a=-1,h=c.length,d=f.length-1,p=e?1:1/h;++a0)for(a=-1;++a=u[0]&&s<=u[1]&&(o=l[co.bisect(f,s,1,d)-1],o.y+=p,o.push(t[a]));return l}var e=!0,r=Number,n=ki,i=_i;return t.value=function(e){return arguments.length?(r=e,t):r},t.range=function(e){return arguments.length?(n=Lt(e),t):n},t.bins=function(e){return arguments.length?(i="number"==typeof e?function(t){return wi(t,e)}:Lt(e),t):i},t.frequency=function(r){return arguments.length?(e=!!r,t):e},t},co.layout.pack=function(){function t(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],c=i[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,li(s,function(t){t.r=+u(t.value)}),li(s,Li),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/c))/2;li(s,function(t){t.r+=f}),li(s,Li),li(s,function(t){t.r-=f})}return zi(s,l/2,c/2,e?1:1/Math.max(2*s.r/l,2*s.r/c)),o}var e,r=co.layout.hierarchy().sort(Ai),n=0,i=[1,1];return t.size=function(e){return arguments.length?(i=e,t):i},t.radius=function(r){return arguments.length?(e=null==r||"function"==typeof r?r:+r,t):e},t.padding=function(e){return arguments.length?(n=+e,t):n},oi(t,r)},co.layout.tree=function(){function t(t,i){var u=o.call(this,t,i),f=u[0],h=e(f);if(li(h,r),h.parent.m=-h.z,si(h,n),c)si(f,a);else{var d=f,p=f,g=f;si(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=s(d,p)/2-d.x,m=l[0]/(p.x+s(p,d)/2+v),y=l[1]/(g.depth||1);si(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return u}function e(t){for(var e,r={A:null,children:[t]},n=[r];null!=(e=n.pop());)for(var i,a=e.children,o=0,s=a.length;s>o;++o)n.push((a[o]=i={_:a[o],parent:e,children:(i=a[o].children)&&i.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=i);return r.children[0]}function r(t){var e=t.children,r=t.parent.children,n=t.i?r[t.i-1]:null;if(e.length){ji(t);var a=(e[0].z+e[e.length-1].z)/2;n?(t.z=n.z+s(t._,n._),t.m=t.z-a):t.z=a}else n&&(t.z=n.z+s(t._,n._));t.parent.A=i(t,n,t.parent.A||r[0])}function n(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function i(t,e,r){if(e){for(var n,i=t,a=t,o=e,l=i.parent.children[0],c=i.m,u=a.m,f=o.m,h=l.m;o=Ii(o),i=Oi(i),o&&i;)l=Oi(l),a=Ii(a),a.a=t,n=o.z+f-i.z-c+s(o._,i._),n>0&&(Ni(Fi(o,t,r),t,n),c+=n,u+=n),f+=o.m,c+=i.m,h+=l.m,u+=a.m;o&&!Ii(a)&&(a.t=o,a.m+=f-u),i&&!Oi(l)&&(l.t=i,l.m+=c-h,r=t)}return r}function a(t){t.x*=l[0],t.y=t.depth*l[1]}var o=co.layout.hierarchy().sort(null).value(null),s=Ri,l=[1,1],c=null;return t.separation=function(e){return arguments.length?(s=e,t):s},t.size=function(e){return arguments.length?(c=null==(l=e)?a:null,t):c?null:l},t.nodeSize=function(e){return arguments.length?(c=null==(l=e)?null:a,t):c?l:null},oi(t,o)},co.layout.cluster=function(){function t(t,a){var o,s=e.call(this,t,a),l=s[0],c=0;li(l,function(t){var e=t.children;e&&e.length?(t.x=Bi(e),t.y=Di(e)):(t.x=o?c+=r(t,o):0,t.y=0,o=t)});var u=Ui(l),f=Vi(l),h=u.x-r(u,f)/2,d=f.x+r(f,u)/2;return li(l,i?function(t){t.x=(t.x-l.x)*n[0],t.y=(l.y-t.y)*n[1]}:function(t){t.x=(t.x-h)/(d-h)*n[0],t.y=(1-(l.y?t.y/l.y:1))*n[1]}),s}var e=co.layout.hierarchy().sort(null).value(null),r=Ri,n=[1,1],i=!1;return t.separation=function(e){return arguments.length?(r=e,t):r},t.size=function(e){return arguments.length?(i=null==(n=e),t):i?null:n},t.nodeSize=function(e){return arguments.length?(i=null!=(n=e),t):i?n:null},oi(t,e)},co.layout.treemap=function(){function t(t,e){for(var r,n,i=-1,a=t.length;++ie?0:e),r.area=isNaN(n)||0>=n?0:n}function e(r){var a=r.children;if(a&&a.length){var o,s,l,c=f(r),u=[],h=a.slice(),p=1/0,g="slice"===d?c.dx:"dice"===d?c.dy:"slice-dice"===d?1&r.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(t(h,c.dx*c.dy/r.value),u.area=0;(l=h.length)>0;)u.push(o=h[l-1]),u.area+=o.area,"squarify"!==d||(s=n(u,g))<=p?(h.pop(),p=s):(u.area-=u.pop().area,i(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(i(u,g,c,!0),u.length=u.area=0),a.forEach(e)}}function r(e){var n=e.children;if(n&&n.length){var a,o=f(e),s=n.slice(),l=[];for(t(s,o.dx*o.dy/e.value),l.area=0;a=s.pop();)l.push(a),l.area+=a.area,null!=a.z&&(i(l,a.z?o.dx:o.dy,o,!s.length),l.length=l.area=0);n.forEach(r)}}function n(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++or&&(a=r),r>i&&(i=r));return n*=n,e*=e,n?Math.max(e*i*p/n,n/(e*a*p)):1/0}function i(t,e,r,n){var i,a=-1,o=t.length,s=r.x,c=r.y,u=e?l(t.area/e):0;if(e==r.dx){for((n||u>r.dy)&&(u=r.dy);++ar.dx)&&(u=r.dx);++ar&&(e=1),1>r&&(t=0),function(){var r,n,i;do r=2*Math.random()-1,n=2*Math.random()-1,i=r*r+n*n;while(!i||i>1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=co.random.normal.apply(co,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=co.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,r=0;t>r;r++)e+=Math.random();return e}}},co.scale={};var Tl={floor:x,ceil:x};co.scale.linear=function(){return $i([0,1],[0,1],_n,!1)};var El={s:1,g:1,p:1,r:1,e:1};co.scale.log=function(){return aa(co.scale.linear().domain([0,1]),10,!0,[1,10])};var Ll=co.format(".0e"),Sl={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};co.scale.pow=function(){return oa(co.scale.linear(),1,[0,1])},co.scale.sqrt=function(){return co.scale.pow().exponent(.5)},co.scale.ordinal=function(){return la([],{t:"range",a:[[]]})},co.scale.category10=function(){return co.scale.ordinal().range(Cl)},co.scale.category20=function(){return co.scale.ordinal().range(zl)},co.scale.category20b=function(){return co.scale.ordinal().range(Pl)},co.scale.category20c=function(){return co.scale.ordinal().range(Rl)};var Cl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(_t),zl=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(_t),Pl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(_t),Rl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(_t);co.scale.quantile=function(){return ca([],[])},co.scale.quantize=function(){return ua(0,1,[0,1])},co.scale.threshold=function(){return fa([.5],[0,1])},co.scale.identity=function(){return ha([0,1])},co.svg={},co.svg.arc=function(){function t(){var t=Math.max(0,+r.apply(this,arguments)),c=Math.max(0,+n.apply(this,arguments)),u=o.apply(this,arguments)-Ho,f=s.apply(this,arguments)-Ho,h=Math.abs(f-u),d=u>f?0:1;if(t>c&&(p=c,c=t,t=p),h>=qo)return e(c,d)+(t?e(t,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,k,A,M,T=0,E=0,L=[];if((m=(+l.apply(this,arguments)||0)/2)&&(v=a===Ol?Math.sqrt(t*t+c*c):+a.apply(this,arguments),d||(E*=-1),c&&(E=nt(v/c*Math.sin(m))),t&&(T=nt(v/t*Math.sin(m)))),c){y=c*Math.cos(u+E),b=c*Math.sin(u+E),x=c*Math.cos(f-E),_=c*Math.sin(f-E);var S=Math.abs(f-u-2*E)<=Uo?0:1;if(E&&ba(y,b,x,_)===d^S){var C=(u+f)/2;y=c*Math.cos(C),b=c*Math.sin(C),x=_=null}}else y=b=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),A=t*Math.cos(u+T),M=t*Math.sin(u+T);var z=Math.abs(u-f+2*T)<=Uo?0:1;if(T&&ba(w,k,A,M)===1-d^z){ +var P=(u+f)/2;w=t*Math.cos(P),k=t*Math.sin(P),A=M=null}}else w=k=0;if(h>Do&&(p=Math.min(Math.abs(c-t)/2,+i.apply(this,arguments)))>.001){g=c>t^d?0:1;var R=p,O=p;if(Uo>h){var I=null==A?[w,k]:null==x?[y,b]:Ir([y,b],[A,M],[x,_],[w,k]),N=y-I[0],j=b-I[1],F=x-I[0],D=_-I[1],B=1/Math.sin(Math.acos((N*F+j*D)/(Math.sqrt(N*N+j*j)*Math.sqrt(F*F+D*D)))/2),U=Math.sqrt(I[0]*I[0]+I[1]*I[1]);O=Math.min(p,(t-U)/(B-1)),R=Math.min(p,(c-U)/(B+1))}if(null!=x){var V=xa(null==A?[w,k]:[A,M],[y,b],c,R,d),q=xa([x,_],[w,k],c,R,d);p===R?L.push("M",V[0],"A",R,",",R," 0 0,",g," ",V[1],"A",c,",",c," 0 ",1-d^ba(V[1][0],V[1][1],q[1][0],q[1][1]),",",d," ",q[1],"A",R,",",R," 0 0,",g," ",q[0]):L.push("M",V[0],"A",R,",",R," 0 1,",g," ",q[0])}else L.push("M",y,",",b);if(null!=A){var H=xa([y,b],[A,M],t,-O,d),G=xa([w,k],null==x?[y,b]:[x,_],t,-O,d);p===O?L.push("L",G[0],"A",O,",",O," 0 0,",g," ",G[1],"A",t,",",t," 0 ",d^ba(G[1][0],G[1][1],H[1][0],H[1][1]),",",1-d," ",H[1],"A",O,",",O," 0 0,",g," ",H[0]):L.push("L",G[0],"A",O,",",O," 0 0,",g," ",H[0])}else L.push("L",w,",",k)}else L.push("M",y,",",b),null!=x&&L.push("A",c,",",c," 0 ",S,",",d," ",x,",",_),L.push("L",w,",",k),null!=A&&L.push("A",t,",",t," 0 ",z,",",1-d," ",A,",",M);return L.push("Z"),L.join("")}function e(t,e){return"M0,"+t+"A"+t+","+t+" 0 1,"+e+" 0,"+-t+"A"+t+","+t+" 0 1,"+e+" 0,"+t}var r=pa,n=ga,i=da,a=Ol,o=va,s=ma,l=ya;return t.innerRadius=function(e){return arguments.length?(r=Lt(e),t):r},t.outerRadius=function(e){return arguments.length?(n=Lt(e),t):n},t.cornerRadius=function(e){return arguments.length?(i=Lt(e),t):i},t.padRadius=function(e){return arguments.length?(a=e==Ol?Ol:Lt(e),t):a},t.startAngle=function(e){return arguments.length?(o=Lt(e),t):o},t.endAngle=function(e){return arguments.length?(s=Lt(e),t):s},t.padAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.centroid=function(){var t=(+r.apply(this,arguments)+ +n.apply(this,arguments))/2,e=(+o.apply(this,arguments)+ +s.apply(this,arguments))/2-Ho;return[Math.cos(e)*t,Math.sin(e)*t]},t};var Ol="auto";co.svg.line=function(){return _a(x)};var Il=co.map({linear:wa,"linear-closed":ka,step:Aa,"step-before":Ma,"step-after":Ta,basis:Pa,"basis-open":Ra,"basis-closed":Oa,bundle:Ia,cardinal:Sa,"cardinal-open":Ea,"cardinal-closed":La,monotone:Ua});Il.forEach(function(t,e){e.key=t,e.closed=/-closed$/.test(t)});var Nl=[0,2/3,1/3,0],jl=[0,1/3,2/3,0],Fl=[0,1/6,2/3,1/6];co.svg.line.radial=function(){var t=_a(Va);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},Ma.reverse=Ta,Ta.reverse=Ma,co.svg.area=function(){return qa(x)},co.svg.area.radial=function(){var t=qa(Va);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},co.svg.chord=function(){function t(t,s){var l=e(this,a,t,s),c=e(this,o,t,s);return"M"+l.p0+n(l.r,l.p1,l.a1-l.a0)+(r(l,c)?i(l.r,l.p1,l.r,l.p0):i(l.r,l.p1,c.r,c.p0)+n(c.r,c.p1,c.a1-c.a0)+i(c.r,c.p1,l.r,l.p0))+"Z"}function e(t,e,r,n){var i=e.call(t,r,n),a=s.call(t,i,n),o=l.call(t,i,n)-Ho,u=c.call(t,i,n)-Ho;return{r:a,a0:o,a1:u,p0:[a*Math.cos(o),a*Math.sin(o)],p1:[a*Math.cos(u),a*Math.sin(u)]}}function r(t,e){return t.a0==e.a0&&t.a1==e.a1}function n(t,e,r){return"A"+t+","+t+" 0 "+ +(r>Uo)+",1 "+e}function i(t,e,r,n){return"Q 0,0 "+n}var a=xr,o=_r,s=Ha,l=va,c=ma;return t.radius=function(e){return arguments.length?(s=Lt(e),t):s},t.source=function(e){return arguments.length?(a=Lt(e),t):a},t.target=function(e){return arguments.length?(o=Lt(e),t):o},t.startAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.endAngle=function(e){return arguments.length?(c=Lt(e),t):c},t},co.svg.diagonal=function(){function t(t,i){var a=e.call(this,t,i),o=r.call(this,t,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return l=l.map(n),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var e=xr,r=_r,n=Ga;return t.source=function(r){return arguments.length?(e=Lt(r),t):e},t.target=function(e){return arguments.length?(r=Lt(e),t):r},t.projection=function(e){return arguments.length?(n=e,t):n},t},co.svg.diagonal.radial=function(){var t=co.svg.diagonal(),e=Ga,r=t.projection;return t.projection=function(t){return arguments.length?r(Ya(e=t)):e},t},co.svg.symbol=function(){function t(t,n){return(Dl.get(e.call(this,t,n))||Za)(r.call(this,t,n))}var e=Wa,r=Xa;return t.type=function(r){return arguments.length?(e=Lt(r),t):e},t.size=function(e){return arguments.length?(r=Lt(e),t):r},t};var Dl=co.map({circle:Za,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Ul)),r=e*Ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/Bl),r=e*Bl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/Bl),r=e*Bl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});co.svg.symbolTypes=Dl.keys();var Bl=Math.sqrt(3),Ul=Math.tan(30*Go);zo.transition=function(t){for(var e,r,n=Vl||++Yl,i=to(t),a=[],o=ql||{time:Date.now(),ease:Ln,delay:0,duration:250},s=-1,l=this.length;++sa;a++){i.push(e=[]);for(var r=this[a],s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return $a(i,this.namespace,this.id)},Gl.tween=function(t,e){var r=this.id,n=this.namespace;return arguments.length<2?this.node()[n][r].tween.get(t):G(this,null==e?function(e){e[n][r].tween.remove(t)}:function(i){i[n][r].tween.set(t,e)})},Gl.attr=function(t,e){function r(){this.removeAttribute(s)}function n(){this.removeAttributeNS(s.space,s.local)}function i(t){return null==t?r:(t+="",function(){var e,r=this.getAttribute(s);return r!==t&&(e=o(r,t),function(t){this.setAttribute(s,e(t))})})}function a(t){return null==t?n:(t+="",function(){var e,r=this.getAttributeNS(s.space,s.local);return r!==t&&(e=o(r,t),function(t){this.setAttributeNS(s.space,s.local,e(t))})})}if(arguments.length<2){for(e in t)this.attr(e,t[e]);return this}var o="transform"==t?Zn:_n,s=co.ns.qualify(t);return Qa(this,"attr."+t,e,s.local?a:i)},Gl.attrTween=function(t,e){function r(t,r){var n=e.call(this,t,r,this.getAttribute(i));return n&&function(t){this.setAttribute(i,n(t))}}function n(t,r){var n=e.call(this,t,r,this.getAttributeNS(i.space,i.local));return n&&function(t){this.setAttributeNS(i.space,i.local,n(t))}}var i=co.ns.qualify(t);return this.tween("attr."+t,i.local?n:r)},Gl.style=function(t,e,r){function i(){this.style.removeProperty(t)}function a(e){return null==e?i:(e+="",function(){var i,a=n(this).getComputedStyle(this,null).getPropertyValue(t);return a!==e&&(i=_n(a,e),function(e){this.style.setProperty(t,i(e),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof t){2>o&&(e="");for(r in t)this.style(r,t[r],e);return this}r=""}return Qa(this,"style."+t,e,a)},Gl.styleTween=function(t,e,r){function i(i,a){var o=e.call(this,i,a,n(this).getComputedStyle(this,null).getPropertyValue(t));return o&&function(e){this.style.setProperty(t,o(e),r)}}return arguments.length<3&&(r=""),this.tween("style."+t,i)},Gl.text=function(t){return Qa(this,"text",t,Ja)},Gl.remove=function(){var t=this.namespace;return this.each("end.transition",function(){var e;this[t].count<2&&(e=this.parentNode)&&e.removeChild(this)})},Gl.ease=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].ease:("function"!=typeof t&&(t=co.ease.apply(co,arguments)),G(this,function(n){n[r][e].ease=t}))},Gl.delay=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].delay:G(this,"function"==typeof t?function(n,i,a){n[r][e].delay=+t.call(n,n.__data__,i,a)}:(t=+t,function(n){n[r][e].delay=t}))},Gl.duration=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].duration:G(this,"function"==typeof t?function(n,i,a){n[r][e].duration=Math.max(1,t.call(n,n.__data__,i,a))}:(t=Math.max(1,t),function(n){n[r][e].duration=t}))},Gl.each=function(t,e){var r=this.id,n=this.namespace;if(arguments.length<2){var i=ql,a=Vl;try{Vl=r,G(this,function(e,i,a){ql=e[n][r],t.call(e,e.__data__,i,a)})}finally{ql=i,Vl=a}}else G(this,function(i){var a=i[n][r];(a.event||(a.event=co.dispatch("start","end","interrupt"))).on(t,e)});return this},Gl.transition=function(){for(var t,e,r,n,i=this.id,a=++Yl,o=this.namespace,s=[],l=0,c=this.length;c>l;l++){s.push(t=[]);for(var e=this[l],u=0,f=e.length;f>u;u++)(r=e[u])&&(n=r[o][i],eo(r,u,o,a,{time:n.time,ease:n.ease,delay:n.delay+n.duration,duration:n.duration})),t.push(r)}return $a(s,o,a)},co.svg.axis=function(){function t(t){t.each(function(){var t,c=co.select(this),u=this.__chart__||r,f=this.__chart__=r.copy(),h=null==l?f.ticks?f.ticks.apply(f,s):f.domain():l,d=null==e?f.tickFormat?f.tickFormat.apply(f,s):x:e,p=c.selectAll(".tick").data(h,f),g=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Do),v=co.transition(p.exit()).style("opacity",Do).remove(),m=co.transition(p.order()).style("opacity",1),y=Math.max(i,0)+o,b=Yi(f),_=c.selectAll(".domain").data([0]),w=(_.enter().append("path").attr("class","domain"),co.transition(_));g.append("line"),g.append("text");var k,A,M,T,E=g.select("line"),L=m.select("line"),S=p.select("text").text(d),C=g.select("text"),z=m.select("text"),P="top"===n||"left"===n?-1:1;if("bottom"===n||"top"===n?(t=ro,k="x",M="y",A="x2",T="y2",S.attr("dy",0>P?"0em":".71em").style("text-anchor","middle"),w.attr("d","M"+b[0]+","+P*a+"V0H"+b[1]+"V"+P*a)):(t=no,k="y",M="x",A="y2",T="x2",S.attr("dy",".32em").style("text-anchor",0>P?"end":"start"),w.attr("d","M"+P*a+","+b[0]+"H0V"+b[1]+"H"+P*a)),E.attr(T,P*i),C.attr(M,P*y),L.attr(A,0).attr(T,P*i),z.attr(k,0).attr(M,P*y),f.rangeBand){var R=f,O=R.rangeBand()/2;u=f=function(t){return R(t)+O}}else u.rangeBand?u=f:v.call(t,f,u);g.call(t,u,f),m.call(t,f,f)})}var e,r=co.scale.linear(),n=Xl,i=6,a=6,o=3,s=[10],l=null;return t.scale=function(e){return arguments.length?(r=e,t):r},t.orient=function(e){return arguments.length?(n=e in Wl?e+"":Xl,t):n},t.ticks=function(){return arguments.length?(s=fo(arguments),t):s},t.tickValues=function(e){return arguments.length?(l=e,t):l},t.tickFormat=function(r){return arguments.length?(e=r,t):e},t.tickSize=function(e){var r=arguments.length;return r?(i=+e,a=+arguments[r-1],t):i},t.innerTickSize=function(e){return arguments.length?(i=+e,t):i},t.outerTickSize=function(e){return arguments.length?(a=+e,t):a},t.tickPadding=function(e){return arguments.length?(o=+e,t):o},t.tickSubdivide=function(){return arguments.length&&t},t};var Xl="bottom",Wl={top:1,right:1,bottom:1,left:1};co.svg.brush=function(){function t(n){n.each(function(){var n=co.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",a).on("touchstart.brush",a),o=n.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),n.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var s=n.selectAll(".resize").data(g,x);s.exit().remove(),s.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return Zl[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),s.style("display",t.empty()?"none":null);var l,f=co.transition(n),h=co.transition(o);c&&(l=Yi(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(f)),u&&(l=Yi(u),h.attr("y",l[0]).attr("height",l[1]-l[0]),i(f)),e(f)})}function e(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+f[+/e$/.test(t)]+","+h[+/^s/.test(t)]+")"})}function r(t){t.select(".extent").attr("x",f[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function i(t){t.select(".extent").attr("y",h[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function a(){function a(){32==co.event.keyCode&&(S||(b=null,z[0]-=f[1],z[1]-=h[1],S=2),T())}function g(){32==co.event.keyCode&&2==S&&(z[0]+=f[1],z[1]+=h[1],S=0,T())}function v(){var t=co.mouse(_),n=!1;x&&(t[0]+=x[0],t[1]+=x[1]),S||(co.event.altKey?(b||(b=[(f[0]+f[1])/2,(h[0]+h[1])/2]),z[0]=f[+(t[0]u?(i=n,n=u):i=u),g[0]!=n||g[1]!=i?(r?s=null:o=null,g[0]=n,g[1]=i,!0):void 0}function y(){v(),A.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),co.select("body").style("cursor",null),P.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),k({type:"brushend"})}var b,x,_=this,w=co.select(co.event.target),k=l.of(_,arguments),A=co.select(_),M=w.datum(),E=!/^(n|s)$/.test(M)&&c,L=!/^(e|w)$/.test(M)&&u,S=w.classed("extent"),C=$(_),z=co.mouse(_),P=co.select(n(_)).on("keydown.brush",a).on("keyup.brush",g);if(co.event.changedTouches?P.on("touchmove.brush",v).on("touchend.brush",y):P.on("mousemove.brush",v).on("mouseup.brush",y),A.interrupt().selectAll("*").interrupt(),S)z[0]=f[0]-z[0],z[1]=h[0]-z[1];else if(M){var R=+/w$/.test(M),O=+/^n/.test(M);x=[f[1-R]-z[0],h[1-O]-z[1]],z[0]=f[R],z[1]=h[O]}else co.event.altKey&&(b=z.slice());A.style("pointer-events","none").selectAll(".resize").style("display",null),co.select("body").style("cursor",w.style("cursor")),k({type:"brushstart"}),v()}var o,s,l=L(t,"brushstart","brush","brushend"),c=null,u=null,f=[0,0],h=[0,0],d=!0,p=!0,g=Kl[0];return t.event=function(t){t.each(function(){var t=l.of(this,arguments),e={x:f,y:h,i:o,j:s},r=this.__chart__||e;this.__chart__=e,Vl?co.select(this).transition().each("start.brush",function(){o=r.i,s=r.j,f=r.x,h=r.y,t({type:"brushstart"})}).tween("brush:brush",function(){var r=wn(f,e.x),n=wn(h,e.y);return o=s=null,function(i){f=e.x=r(i),h=e.y=n(i),t({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=e.i,s=e.j,t({type:"brush",mode:"resize"}),t({type:"brushend"})}):(t({type:"brushstart"}),t({type:"brush",mode:"resize"}),t({type:"brushend"}))})},t.x=function(e){return arguments.length?(c=e,g=Kl[!c<<1|!u],t):c},t.y=function(e){return arguments.length?(u=e,g=Kl[!c<<1|!u],t):u},t.clamp=function(e){return arguments.length?(c&&u?(d=!!e[0],p=!!e[1]):c?d=!!e:u&&(p=!!e),t):c&&u?[d,p]:c?d:u?p:null},t.extent=function(e){var r,n,i,a,l;return arguments.length?(c&&(r=e[0],n=e[1],u&&(r=r[0],n=n[0]),o=[r,n],c.invert&&(r=c(r),n=c(n)),r>n&&(l=r,r=n,n=l),r==f[0]&&n==f[1]||(f=[r,n])),u&&(i=e[0],a=e[1],c&&(i=i[1],a=a[1]),s=[i,a],u.invert&&(i=u(i),a=u(a)),i>a&&(l=i,i=a,a=l),i==h[0]&&a==h[1]||(h=[i,a])),t):(c&&(o?(r=o[0],n=o[1]):(r=f[0],n=f[1],c.invert&&(r=c.invert(r),n=c.invert(n)),r>n&&(l=r,r=n,n=l))),u&&(s?(i=s[0],a=s[1]):(i=h[0],a=h[1],u.invert&&(i=u.invert(i),a=u.invert(a)),i>a&&(l=i,i=a,a=l))),c&&u?[[r,i],[n,a]]:c?[r,n]:u&&[i,a])},t.clear=function(){return t.empty()||(f=[0,0],h=[0,0],o=s=null),t},t.empty=function(){return!!c&&f[0]==f[1]||!!u&&h[0]==h[1]},co.rebind(t,l,"on")};var Zl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Kl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],$l=vs.format=ws.timeFormat,Ql=$l.utc,Jl=Ql("%Y-%m-%dT%H:%M:%S.%LZ");$l.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?io:Jl,io.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},io.toString=Jl.toString,vs.second=Vt(function(t){return new ms(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),vs.seconds=vs.second.range,vs.seconds.utc=vs.second.utc.range,vs.minute=Vt(function(t){return new ms(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),vs.minutes=vs.minute.range,vs.minutes.utc=vs.minute.utc.range,vs.hour=Vt(function(t){var e=t.getTimezoneOffset()/60;return new ms(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),vs.hours=vs.hour.range,vs.hours.utc=vs.hour.utc.range,vs.month=Vt(function(t){return t=vs.day(t),t.setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),vs.months=vs.month.range,vs.months.utc=vs.month.utc.range;var tc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],ec=[[vs.second,1],[vs.second,5],[vs.second,15],[vs.second,30],[vs.minute,1],[vs.minute,5],[vs.minute,15],[vs.minute,30],[vs.hour,1],[vs.hour,3],[vs.hour,6],[vs.hour,12],[vs.day,1],[vs.day,2],[vs.week,1],[vs.month,1],[vs.month,3],[vs.year,1]],rc=$l.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",ze]]),nc={range:function(t,e,r){return co.range(Math.ceil(t/r)*r,+e,r).map(oo)},floor:x,ceil:x};ec.year=vs.year,vs.scale=function(){return ao(co.scale.linear(),ec,rc)};var ic=ec.map(function(t){return[t[0].utc,t[1]]}),ac=Ql.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",ze]]);ic.year=vs.year.utc,vs.scale.utc=function(){return ao(co.scale.linear(),ic,ac)},co.text=St(function(t){return t.responseText}),co.json=function(t,e){return Ct(t,"application/json",so,e)},co.html=function(t,e){return Ct(t,"text/html",lo,e)},co.xml=St(function(t){return t.responseXML}),"function"==typeof t&&t.amd?(this.d3=co,t(co)):"object"==typeof r&&r.exports?r.exports=co:this.d3=co}()},{}],114:[function(t,e,r){"use strict";function n(t,e){this.point=t,this.index=e}function i(t,e){for(var r=t.point,n=e.point,i=r.length,a=0;i>a;++a){var o=n[a]-r[a];if(o)return o}return 0}function a(t,e,r){if(1===t)return r?[[-1,0]]:[];var n=e.map(function(t,e){return[t[0],e]});n.sort(function(t,e){return t[0]-e[0]});for(var i=new Array(t-1),a=1;t>a;++a){var o=n[a-1],s=n[a];i[a-1]=[o[1],s[1]]}return r&&i.push([-1,i[0][1]],[i[t-1][1],-1]),i}function o(t,e){var r=t.length;if(0===r)return[];var o=t[0].length;if(1>o)return[];if(1===o)return a(r,t,e);for(var c=new Array(r),u=1,f=0;r>f;++f){for(var h=t[f],d=new Array(o+1),p=0,g=0;o>g;++g){var v=h[g];d[g]=v,p+=v*v}d[o]=p,c[f]=new n(d,f),u=Math.max(p,u)}l(c,i),r=c.length;for(var m=new Array(r+o+1),y=new Array(r+o+1),b=(o+1)*(o+1)*u,x=new Array(o+1),f=0;o>=f;++f)x[f]=0;x[o]=b,m[0]=x.slice(),y[0]=-1;for(var f=0;o>=f;++f){var d=x.slice();d[f]=1,m[f+1]=d,y[f+1]=-1}for(var f=0;r>f;++f){var _=c[f];m[f+o+1]=_.point,y[f+o+1]=_.index}var w=s(m,!1);if(w=e?w.filter(function(t){for(var e=0,r=0;o>=r;++r){var n=y[t[r]];if(0>n&&++e>=2)return!1;t[r]=n}return!0}):w.filter(function(t){for(var e=0;o>=e;++e){var r=y[t[e]];if(0>r)return!1;t[e]=r}return!0}),1&o)for(var f=0;f=i)return[];var a,o=new Array(i);if(r===t.length-1)for(a=0;i>a;++a)o[a]=e;else for(a=0;i>a;++a)o[a]=n(t,e,r+1);return o}function i(t,e){var r,n;for(r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return i(0|t,e);break;case"object":if("number"==typeof t.length)return n(t,e,0)}return[]}e.exports=a},{}],116:[function(e,r,n){(function(n,i){(function(){"use strict";function a(t){return"function"==typeof t||"object"==typeof t&&null!==t}function o(t){return"function"==typeof t}function s(t){Y=t}function l(t){K=t}function c(){return function(){n.nextTick(p)}}function u(){return function(){G(p)}}function f(){var t=0,e=new J(p),r=document.createTextNode("");return e.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}function h(){var t=new MessageChannel;return t.port1.onmessage=p,function(){t.port2.postMessage(0)}}function d(){return function(){setTimeout(p,1)}}function p(){for(var t=0;Z>t;t+=2){var e=rt[t],r=rt[t+1];e(r),rt[t]=void 0,rt[t+1]=void 0}Z=0}function g(){try{var t=e,r=t("vertx");return G=r.runOnLoop||r.runOnContext,u()}catch(n){return d()}}function v(t,e){var r=this,n=r._state;if(n===ot&&!t||n===st&&!e)return this;var i=new this.constructor(y),a=r._result;if(n){var o=arguments[n-1];K(function(){O(n,i,o,a)})}else C(r,i,t,e);return i}function m(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var r=new e(y);return T(r,t),r}function y(){}function b(){return new TypeError("You cannot resolve a promise with itself")}function x(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return lt.error=e,lt}}function w(t,e,r,n){try{t.call(e,r,n)}catch(i){return i}}function k(t,e,r){K(function(t){var n=!1,i=w(r,e,function(r){n||(n=!0,e!==r?T(t,r):L(t,r))},function(e){n||(n=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&i&&(n=!0,S(t,i))},t)}function A(t,e){e._state===ot?L(t,e._result):e._state===st?S(t,e._result):C(e,void 0,function(e){T(t,e)},function(e){S(t,e)})}function M(t,e,r){e.constructor===t.constructor&&r===nt&&constructor.resolve===it?A(t,e):r===lt?S(t,lt.error):void 0===r?L(t,e):o(r)?k(t,e,r):L(t,e)}function T(t,e){t===e?S(t,b()):a(e)?M(t,e,_(e)):L(t,e)}function E(t){t._onerror&&t._onerror(t._result),z(t)}function L(t,e){t._state===at&&(t._result=e,t._state=ot,0!==t._subscribers.length&&K(z,t))}function S(t,e){t._state===at&&(t._state=st,t._result=e,K(E,t))}function C(t,e,r,n){var i=t._subscribers,a=i.length;t._onerror=null,i[a]=e,i[a+ot]=r,i[a+st]=n,0===a&&t._state&&K(z,t)}function z(t){var e=t._subscribers,r=t._state;if(0!==e.length){for(var n,i,a=t._result,o=0;oo;o++)C(n.resolve(t[o]),void 0,e,r);return i}function F(t){var e=this,r=new e(y);return S(r,t),r}function D(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function B(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function U(t){this._id=dt++,this._state=void 0,this._result=void 0,this._subscribers=[],y!==t&&("function"!=typeof t&&D(),this instanceof U?I(this,t):B())}function V(t,e){this._instanceConstructor=t,this.promise=new t(y),Array.isArray(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?L(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&L(this.promise,this._result))):S(this.promise,this._validationError())}function q(){var t;if("undefined"!=typeof i)t=i;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var r=t.Promise;r&&"[object Promise]"===Object.prototype.toString.call(r.resolve())&&!r.cast||(t.Promise=pt)}var H;H=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var G,Y,X,W=H,Z=0,K=function(t,e){rt[Z]=t,rt[Z+1]=e,Z+=2,2===Z&&(Y?Y(p):X())},$="undefined"!=typeof window?window:void 0,Q=$||{},J=Q.MutationObserver||Q.WebKitMutationObserver,tt="undefined"!=typeof n&&"[object process]"==={}.toString.call(n),et="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,rt=new Array(1e3);X=tt?c():J?f():et?h():void 0===$&&"function"==typeof e?g():d();var nt=v,it=m,at=void 0,ot=1,st=2,lt=new P,ct=new P,ut=N,ft=j,ht=F,dt=0,pt=U;U.all=ut,U.race=ft,U.resolve=it,U.reject=ht,U._setScheduler=s,U._setAsap=l,U._asap=K,U.prototype={constructor:U,then:nt,"catch":function(t){return this.then(null,t)}};var gt=V;V.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},V.prototype._enumerate=function(){for(var t=this.length,e=this._input,r=0;this._state===at&&t>r;r++)this._eachEntry(e[r],r)},V.prototype._eachEntry=function(t,e){var r=this._instanceConstructor,n=r.resolve;if(n===it){var i=_(t);if(i===nt&&t._state!==at)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(r===pt){var a=new r(y);M(a,t,i),this._willSettleAt(a,e)}else this._willSettleAt(new r(function(e){e(t)}),e)}else this._willSettleAt(n(t),e)},V.prototype._settledAt=function(t,e,r){var n=this.promise;n._state===at&&(this._remaining--,t===st?S(n,r):this._result[e]=r),0===this._remaining&&L(n,this._result)},V.prototype._willSettleAt=function(t,e){var r=this;C(t,void 0,function(t){r._settledAt(ot,e,t)},function(t){r._settledAt(st,e,t)})};var vt=q,mt={Promise:pt,polyfill:vt};"function"==typeof t&&t.amd?t(function(){return mt}):"undefined"!=typeof r&&r.exports?r.exports=mt:"undefined"!=typeof this&&(this.ES6Promise=mt),vt()}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:56}],117:[function(t,e,r){"use strict";function n(t){for(var e,r=t.length,n=0;r>n;n++)if(e=t.charCodeAt(n),(9>e||e>13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(8192>e||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var r=t;if(t=+t,0===t&&n(r))return!1}else if("number"!==e)return!1;return 1>t-t}},{}],118:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.gl=t,this.type=e,this.handle=r,this.length=n,this.usage=i}function i(t,e,r,n,i,a){var o=i.length*i.BYTES_PER_ELEMENT;if(0>a)return t.bufferData(e,i,n),o;if(o+a>r)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function a(t,e){for(var r=l.malloc(t.length,e),n=t.length,i=0;n>i;++i)r[i]=t[i];return r}function o(t,e){for(var r=1,n=e.length-1;n>=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}function s(t,e,r,i){if(r=r||t.ARRAY_BUFFER,i=i||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.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(i!==t.DYNAMIC_DRAW&&i!==t.STATIC_DRAW&&i!==t.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 a=t.createBuffer(),o=new n(t,r,a,0,i);return o.update(e),o}var l=t("typedarray-pool"),c=t("ndarray-ops"),u=t("ndarray"),f=["uint8","uint8_clamped","uint16","uint32","int8","int16","int32","float32"],h=n.prototype;h.bind=function(){this.gl.bindBuffer(this.type,this.handle)},h.unbind=function(){this.gl.bindBuffer(this.type,null)},h.dispose=function(){this.gl.deleteBuffer(this.handle)},h.update=function(t,e){if("number"!=typeof e&&(e=-1),this.bind(),"object"==typeof t&&"undefined"!=typeof t.shape){var r=t.dtype;if(f.indexOf(r)<0&&(r="float32"),this.type===this.gl.ELEMENT_ARRAY_BUFFER){var n=gl.getExtension("OES_element_index_uint");r=n&&"uint16"!==r?"uint32":"uint16"}if(r===t.dtype&&o(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=i(this.gl,this.type,this.length,this.usage,t.data,e):this.length=i(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=l.malloc(t.size,r),h=u(s,t.shape);c.assign(h,t),0>e?this.length=i(this.gl,this.type,this.length,this.usage,s,e):this.length=i(this.gl,this.type,this.length,this.usage,s.subarray(0,t.size),e),l.free(s)}}else if(Array.isArray(t)){var d;d=this.type===this.gl.ELEMENT_ARRAY_BUFFER?a(t,"uint16"):a(t,"float32"),0>e?this.length=i(this.gl,this.type,this.length,this.usage,d,e):this.length=i(this.gl,this.type,this.length,this.usage,d.subarray(0,t.length),e),l.free(d)}else if("object"==typeof t&&"number"==typeof t.length)this.length=i(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");t=0|t,0>=t&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=s},{ndarray:253,"ndarray-ops":252,"typedarray-pool":278}],119:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.shader=e,this.buffer=r,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.color=[0,0,0,1]}function i(t,e){var r=a(t.gl,l.vertex,l.fragment),i=o(t.gl),s=new n(t,r,i);return s.update(e),t.addObject(s),s}var a=t("gl-shader"),o=t("gl-buffer"),s=t("typedarray-pool"),l=t("./lib/shaders");e.exports=i;var c=[[1,0,0,1,0,0],[1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,1,0,0],[1,0,0,1,0,0],[1,0,-1,0,0,1],[1,0,-1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,1],[1,0,-1,0,0,1],[-1,0,-1,0,0,1],[-1,0,-1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,1],[-1,0,-1,0,0,1],[0,1,1,0,0,0],[0,1,-1,0,0,0],[0,-1,-1,0,0,0],[0,-1,-1,0,0,0],[0,1,1,0,0,0],[0,-1,1,0,0,0],[0,1,0,-1,1,0],[0,1,0,-1,-1,0],[0,1,0,1,-1,0],[0,1,0,1,1,0],[0,1,0,-1,1,0],[0,1,0,1,-1,0],[0,-1,0,-1,1,0],[0,-1,0,-1,-1,0],[0,-1,0,1,-1,0],[0,-1,0,1,1,0],[0,-1,0,-1,1,0],[0,-1,0,1,-1,0]],u=n.prototype;u.draw=function(){var t=[1,0,0,0,1,0,0,0,1],e=[1,1];return function(){var r=this.plot,n=this.shader,i=this.buffer,a=this.bounds,o=this.numPoints;if(o){var s=r.gl,l=r.dataBox,u=r.viewBox,f=r.pixelRatio,h=a[2]-a[0],d=a[3]-a[1],p=l[2]-l[0],g=l[3]-l[1];t[0]=2*h/p,t[4]=2*d/g,t[6]=2*(a[0]-l[0])/p-1,t[7]=2*(a[1]-l[1])/g-1;var v=u[2]-u[0],m=u[3]-u[1];e[0]=2*f/v,e[1]=2*f/m,i.bind(),n.bind(),n.uniforms.viewTransform=t, +n.uniforms.pixelScale=e,n.uniforms.color=this.color,n.attributes.position.pointer(s.FLOAT,!1,16,0),n.attributes.pixelOffset.pointer(s.FLOAT,!1,16,8),s.drawArrays(s.TRIANGLES,0,o*c.length)}}}(),u.drawPick=function(t){return t},u.pick=function(t,e){return null},u.update=function(t){t=t||{};var e,r,n,i=t.positions||[],a=t.errors||[],o=1;"lineWidth"in t&&(o=+t.lineWidth);var l=5;"capSize"in t&&(l=+t.capSize),this.color=(t.color||[0,0,0,1]).slice();var u=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=this.numPoints=i.length>>1;for(e=0;f>e;++e)r=i[2*e],n=i[2*e+1],u[0]=Math.min(r,u[0]),u[1]=Math.min(n,u[1]),u[2]=Math.max(r,u[2]),u[3]=Math.max(n,u[3]);u[2]===u[0]&&(u[2]+=1),u[3]===u[1]&&(u[3]+=1);var h=1/(u[2]-u[0]),d=1/(u[3]-u[1]),p=u[0],g=u[1],v=s.mallocFloat32(f*c.length*4),m=0;for(e=0;f>e;++e){r=i[2*e],n=i[2*e+1];for(var y=a[4*e],b=a[4*e+1],x=a[4*e+2],_=a[4*e+3],w=0;wA?A*=y:A>0&&(A*=b),0>M?M*=x:M>0&&(M*=_),v[m++]=h*(r-p+A),v[m++]=d*(n-g+M),v[m++]=o*k[2]+(l+o)*k[4],v[m++]=o*k[3]+(l+o)*k[5]}}this.buffer.update(v),s.free(v)},u.dispose=function(){this.plot.removeObject(this),this.shader.dispose(),this.buffer.dispose()}},{"./lib/shaders":120,"gl-buffer":118,"gl-shader":197,"typedarray-pool":278}],120:[function(t,e,r){e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 pixelOffset;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvoid main() {\n vec3 scrPosition = viewTransform * vec3(position, 1);\n gl_Position = vec4(\n scrPosition.xy + scrPosition.z * pixelScale * pixelOffset,\n 0,\n scrPosition.z);\n}\n",fragment:"precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"}},{}],121:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.shader=n,this.buffer=e,this.vao=r,this.pixelRatio=1,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.lineWidth=[1,1,1],this.capSize=[10,10,10],this.lineCount=[0,0,0],this.lineOffset=[0,0,0],this.opacity=1}function i(t,e){for(var r=0;3>r;++r)t[0][r]=Math.min(t[0][r],e[r]),t[1][r]=Math.max(t[1][r],e[r])}function a(t,e,r,n){for(var i=h[n],a=0;a=1},f.isTransparent=function(){return this.opacity<1},f.drawTransparent=f.draw=function(t){var e=this.gl,r=this.shader.uniforms;this.shader.bind();var n=r.view=t.view||u,i=r.projection=t.projection||u;r.model=t.model||u,r.clipBounds=this.clipBounds,r.opacity=this.opacity;var a=n[12],o=n[13],s=n[14],l=n[15],c=this.pixelRatio*(i[3]*a+i[7]*o+i[11]*s+i[15]*l)/e.drawingBufferHeight;this.vao.bind();for(var f=0;3>f;++f)e.lineWidth(this.lineWidth[f]),r.capSize=this.capSize[f]*c,e.drawArrays(e.LINES,this.lineOffset[f],this.lineCount[f]);this.vao.unbind()};var h=function(){for(var t=new Array(3),e=0;3>e;++e){for(var r=[],n=1;2>=n;++n)for(var i=-1;1>=i;i+=2){var a=(n+e)%3,o=[0,0,0];o[a]=i,r.push(o)}t[e]=r}return t}();f.update=function(t){t=t||{},"lineWidth"in t&&(this.lineWidth=t.lineWidth,Array.isArray(this.lineWidth)||(this.lineWidth=[this.lineWidth,this.lineWidth,this.lineWidth])),"capSize"in t&&(this.capSize=t.capSize,Array.isArray(this.capSize)||(this.capSize=[this.capSize,this.capSize,this.capSize])),"opacity"in t&&(this.opacity=t.opacity);var e=t.color||[[0,0,0],[0,0,0],[0,0,0]],r=t.position,n=t.error;if(Array.isArray(e[0])||(e=[e,e,e]),r&&n){var o=[],s=r.length,l=0;this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.lineCount=[0,0,0];for(var c=0;3>c;++c){this.lineOffset[c]=l;t:for(var u=0;s>u;++u){for(var f=r[u],h=0;3>h;++h)if(isNaN(f[h])||!isFinite(f[h]))continue t;var d=n[u],p=e[c];if(Array.isArray(p[0])&&(p=e[u]),3===p.length&&(p=[p[0],p[1],p[2],1]),!isNaN(d[0][c])&&!isNaN(d[1][c])){if(d[0][c]<0){var g=f.slice();g[c]+=d[0][c],o.push(f[0],f[1],f[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,g),l+=2+a(o,g,p,c)}if(d[1][c]>0){var g=f.slice();g[c]+=d[1][c],o.push(f[0],f[1],f[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,g),l+=2+a(o,g,p,c)}}}this.lineCount[c]=l-this.lineOffset[c]}this.buffer.update(o)}},f.dispose=function(){this.shader.dispose(),this.buffer.dispose(),this.vao.dispose()}},{"./shaders/index":122,"gl-buffer":118,"gl-vao":226}],122:[function(t,e,r){"use strict";var n=t("gl-shader"),i="precision mediump 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}",a="precision mediump float;\n#define GLSLIFY 1\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(fragPosition, clipBounds[0])) || any(greaterThan(fragPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = opacity * fragColor;\n}";e.exports=function(t){return n(t,i,a,null,[{name:"position",type:"vec3"},{name:"offset",type:"vec3"},{name:"color",type:"vec4"}])}},{"gl-shader":197}],123:[function(t,e,r){"use strict";function n(t){var e=t.getParameter(t.FRAMEBUFFER_BINDING),r=t.getParameter(t.RENDERBUFFER_BINDING),n=t.getParameter(t.TEXTURE_BINDING_2D);return[e,r,n]}function i(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function a(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);y=new Array(r+1);for(var n=0;r>=n;++n){for(var i=new Array(r),a=0;n>a;++a)i[a]=t.COLOR_ATTACHMENT0+a;for(var a=n;r>a;++a)i[a]=t.NONE;y[n]=i}}function o(t){switch(t){case p:throw new Error("gl-fbo: Framebuffer unsupported");case g:throw new Error("gl-fbo: Framebuffer incomplete attachment");case v:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case m:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function s(t,e,r,n,i,a){if(!n)return null;var o=d(t,e,r,i,n);return o.magFilter=t.NEAREST,o.minFilter=t.NEAREST,o.mipSamples=1,o.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,a,t.TEXTURE_2D,o.handle,0),o}function l(t,e,r,n,i){var a=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,a),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,a),a}function c(t){var e=n(t.gl),r=t.gl,a=t.handle=r.createFramebuffer(),c=t._shape[0],u=t._shape[1],f=t.color.length,h=t._ext,d=t._useStencil,p=t._useDepth,g=t._colorType;r.bindFramebuffer(r.FRAMEBUFFER,a);for(var v=0;f>v;++v)t.color[v]=s(r,c,u,g,r.RGBA,r.COLOR_ATTACHMENT0+v);0===f?(t._color_rb=l(r,c,u,r.RGBA4,r.COLOR_ATTACHMENT0),h&&h.drawBuffersWEBGL(y[0])):f>1&&h.drawBuffersWEBGL(y[f]);var m=r.getExtension("WEBGL_depth_texture");m?d?t.depth=s(r,c,u,m.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p&&(t.depth=s(r,c,u,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):p&&d?t._depth_rb=l(r,c,u,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p?t._depth_rb=l(r,c,u,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(t._depth_rb=l(r,c,u,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null);for(var v=0;vl;++l)this.color[l]=null;this._color_rb=null,this.depth=null,this._depth_rb=null,this._colorType=n,this._useDepth=a,this._useStencil=o;var u=this,f=[0|e,0|r];Object.defineProperties(f,{0:{get:function(){return u._shape[0]},set:function(t){return u.width=t}},1:{get:function(){return u._shape[1]},set:function(t){return u.height=t}}}),this._shapeVector=f,c(this)}function f(t,e,r){if(t._destroyed)throw new Error("gl-fbo: Can't resize destroyed FBO");if(t._shape[0]!==e||t._shape[1]!==r){var a=t.gl,s=a.getParameter(a.MAX_RENDERBUFFER_SIZE);if(0>e||e>s||0>r||r>s)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var l=n(a),c=0;ce||e>o||0>r||r>o)throw new Error("gl-fbo: Parameters are too large for FBO");n=n||{};var s=1;if("color"in n){if(s=Math.max(0|n.color,0),0>s)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(s>1){if(!i)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(s>t.getParameter(i.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+s+" draw buffers")}}var l=t.UNSIGNED_BYTE,c=t.getExtension("OES_texture_float");if(n.float&&s>0){if(!c)throw new Error("gl-fbo: Context does not support floating point textures");l=t.FLOAT}else n.preferFloat&&s>0&&c&&(l=t.FLOAT);var f=!0;"depth"in n&&(f=!!n.depth);var h=!1;return"stencil"in n&&(h=!!n.stencil),new u(t,e,r,l,s,f,h,i)}var d=t("gl-texture2d");e.exports=h;var p,g,v,m,y=null,b=u.prototype;Object.defineProperties(b,{shape:{get:function(){return this._destroyed?[0,0]:this._shapeVector},set:function(t){if(Array.isArray(t)||(t=[0|t,0|t]),2!==t.length)throw new Error("gl-fbo: Shape vector must be length 2");var e=0|t[0],r=0|t[1];return f(this,e,r),[e,r]},enumerable:!1},width:{get:function(){return this._destroyed?0:this._shape[0]},set:function(t){return t=0|t,f(this,t,this._shape[1]),t},enumerable:!1},height:{get:function(){return this._destroyed?0:this._shape[1]},set:function(t){return t=0|t,f(this,this._shape[0],t),t},enumerable:!1}}),b.bind=function(){if(!this._destroyed){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,this.handle),t.viewport(0,0,this._shape[0],this._shape[1])}},b.dispose=function(){if(!this._destroyed){this._destroyed=!0;var t=this.gl;t.deleteFramebuffer(this.handle),this.handle=null,this.depth&&(this.depth.dispose(),this.depth=null),this._depth_rb&&(t.deleteRenderbuffer(this._depth_rb),this._depth_rb=null);for(var e=0;e2&&!this.usingDashes){var C=this.mitreShader;C.bind();var z=C.uniforms;z.matrix=t,z.color=s,z.screenShape=e,z.radius=l*p,C.attributes.p.pointer(f.FLOAT,!1,48,0),f.drawArrays(f.POINTS,0,u/3|0)}}}}(),h.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0],r=[0,0,0,0];return function(n){var i=this.plot,a=this.pickShader,o=this.lineBuffer,s=this.pickBuffer,l=this.width,c=this.numPoints,u=this.bounds,f=this.vertCount,h=i.gl,d=i.viewBox,p=i.dataBox,g=i.pickPixelRatio,v=u[2]-u[0],m=u[3]-u[1],y=p[2]-p[0],b=p[3]-p[1],x=d[2]-d[0],_=d[3]-d[1];if(this.pickOffset=n,!f)return n+c;t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(u[0]-p[0])/y-1,t[7]=2*(u[1]-p[1])/b-1,e[0]=x,e[1]=_,r[0]=255&n,r[1]=n>>>8&255,r[2]=n>>>16&255,r[3]=n>>>24,a.bind();var w=a.uniforms;w.matrix=t,w.width=l*g,w.pickOffset=r,w.screenShape=e;var k=a.attributes;return o.bind(),k.a.pointer(h.FLOAT,!1,16,0),k.d.pointer(h.FLOAT,!1,16,8),s.bind(),k.pick0.pointer(h.UNSIGNED_BYTE,!1,8,0),k.pick1.pointer(h.UNSIGNED_BYTE,!1,8,4),h.drawArrays(h.TRIANGLES,0,f),n+c}}(),h.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.data;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},h.update=function(t){t=t||{};var e=this.plot.gl;!!t.connectGaps;this.color=(t.color||[0,0,1,1]).slice(),this.width=+(t.width||1),this.fill=(t.fill||[!1,!1,!1,!1]).slice(),this.fillColor=i(t.fillColor||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]);for(var r=t.dashes||[1],n=0,a=0;a1,this.dashPattern=l(e,c(o,[n,1,4],[1,0,0])),this.dashPattern.minFilter=e.NEAREST,this.dashPattern.magFilter=e.NEAREST,this.dashLength=n,u.free(o);var d=t.positions;this.data=d;var p=this.bounds;p[0]=p[1]=1/0,p[2]=p[3]=-(1/0);var g=this.numPoints=d.length>>>1;if(0!==g){for(var a=0;g>a;++a){var v=d[2*a],m=d[2*a+1];isNaN(v)||isNaN(m)||(p[0]=Math.min(p[0],v),p[1]=Math.min(p[1],m),p[2]=Math.max(p[2],v),p[3]=Math.max(p[3],m))}p[0]===p[2]&&(p[2]+=1),p[3]===p[1]&&(p[3]+=1);for(var y=u.mallocFloat32(24*(g-1)),b=u.mallocUint32(12*(g-1)),x=y.length,_=b.length,s=g,w=0;s>1;){var k=--s,v=d[2*s],m=d[2*s+1],A=k-1,M=d[2*A],T=d[2*A+1];if(!(isNaN(v)||isNaN(m)||isNaN(M)||isNaN(T))){w+=1,v=(v-p[0])/(p[2]-p[0]),m=(m-p[1])/(p[3]-p[1]),M=(M-p[0])/(p[2]-p[0]),T=(T-p[1])/(p[3]-p[1]);var E=M-v,L=T-m,S=k|1<<24,C=k-1,z=k,P=k-1|1<<24;y[--x]=-L,y[--x]=-E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=-L,y[--x]=-E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=L,y[--x]=E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=-L,y[--x]=-E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C}}this.vertCount=6*w,this.lineBuffer.update(y.subarray(x)),this.pickBuffer.update(b.subarray(_)),u.free(y),u.free(b)}},h.dispose=function(){this.plot.removeObject(this),this.lineBuffer.dispose(),this.pickBuffer.dispose(),this.lineShader.dispose(),this.mitreShader.dispose(),this.fillShader.dispose(),this.pickShader.dispose(),this.dashPattern.dispose()}},{"./lib/shaders":124,"gl-buffer":118,"gl-shader":197,"gl-texture2d":222,ndarray:253,"typedarray-pool":278}],126:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, nextPosition;\nattribute float arcLength, lineWidth;\nattribute vec4 color;\n\nuniform vec2 screenShape;\nuniform float pixelRatio;\nuniform mat4 model, view, projection;\n\nvarying vec4 fragColor;\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\n\nvoid main() {\n vec4 projected = projection * view * model * vec4(position, 1.0);\n vec4 tangentClip = projection * view * model * vec4(nextPosition - position, 0.0);\n vec2 tangent = normalize(screenShape * tangentClip.xy);\n vec2 offset = 0.5 * pixelRatio * lineWidth * vec2(tangent.y, -tangent.x) / screenShape;\n\n gl_Position = vec4(projected.xy + projected.w * offset, projected.zw);\n\n worldPosition = position;\n pixelArcLength = arcLength;\n fragColor = color;\n}\n",a="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\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",o="precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1_0(highp float v) {\n highp 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 highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp 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 highp 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\n\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId/255.0, encode_float_1_0(pixelArcLength).xyz);\n}",s=[{name:"position",type:"vec3"},{name:"nextPosition",type:"vec3"},{name:"arcLength",type:"float"},{name:"lineWidth",type:"float"},{name:"color",type:"vec4"}];r.createShader=function(t){return n(t,i,a,null,s)},r.createPickShader=function(t){return n(t,i,o,null,s)}},{"gl-shader":197}],127:[function(t,e,r){"use strict";function n(t,e){for(var r=0,n=0;3>n;++n){var i=t[n]-e[n];r+=i*i}return Math.sqrt(r)}function i(t){for(var e=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],r=0;3>r;++r)e[0][r]=Math.max(t[0][r],e[0][r]),e[1][r]=Math.min(t[1][r],e[1][r]);return e}function a(t,e,r,n){this.arcLength=t,this.position=e,this.index=r,this.dataCoordinate=n}function o(t,e,r,n,i,a){this.gl=t,this.shader=e,this.pickShader=r,this.buffer=n,this.vao=i,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.points=[],this.arcLength=[],this.vertexCount=0,this.bounds=[[0,0,0],[0,0,0]],this.pickId=0,this.lineWidth=1,this.texture=a,this.dashScale=1,this.opacity=1,this.dirty=!0,this.pixelRatio=1}function s(t){var e=t.gl||t.scene&&t.scene.gl,r=g(e);r.attributes.position.location=0,r.attributes.nextPosition.location=1,r.attributes.arcLength.location=2,r.attributes.lineWidth.location=3,r.attributes.color.location=4;var n=v(e);n.attributes.position.location=0,n.attributes.nextPosition.location=1,n.attributes.arcLength.location=2,n.attributes.lineWidth.location=3,n.attributes.color.location=4;for(var i=l(e),a=c(e,[{buffer:i,size:3,offset:0,stride:48},{buffer:i,size:3,offset:12,stride:48},{buffer:i,size:1,offset:24,stride:48},{buffer:i,size:1,offset:28,stride:48},{buffer:i,size:4,offset:32,stride:48}]),s=d(new Array(1024),[256,1,4]),f=0;1024>f;++f)s.data[f]=255;var h=u(e,s);h.wrap=e.REPEAT;var p=new o(e,r,n,i,a,h);return p.update(t),p}e.exports=s;var l=t("gl-buffer"),c=t("gl-vao"),u=t("gl-texture2d"),f=t("glsl-read-float"),h=t("binary-search-bounds"),d=t("ndarray"),p=t("./lib/shaders"),g=p.createShader,v=p.createPickShader,m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],y=o.prototype;y.isTransparent=function(){return this.opacity<1},y.isOpaque=function(){return this.opacity>=1},y.pickSlots=1,y.setPickBase=function(t){this.pickId=t},y.drawTransparent=y.draw=function(t){var e=this.gl,r=this.shader,n=this.vao;r.bind(),r.uniforms={model:t.model||m,view:t.view||m,projection:t.projection||m,clipBounds:i(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},y.drawPick=function(t){var e=this.gl,r=this.pickShader,n=this.vao;r.bind(),r.uniforms={model:t.model||m,view:t.view||m,projection:t.projection||m,pickId:this.pickId,clipBounds:i(this.clipBounds),screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},y.update=function(t){var e,r;this.dirty=!0;var i=!!t.connectGaps;"dashScale"in t&&(this.dashScale=t.dashScale),"opacity"in t&&(this.opacity=+t.opacity);var a=t.position||t.positions;if(a){var o=t.color||t.colors||[0,0,0,1],s=t.lineWidth||1,l=[],c=[],u=[],f=0,p=0,g=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],v=!1;t:for(e=1;er;++r){if(isNaN(m[r])||isNaN(y[r])||!isFinite(m[r])||!isFinite(y[r])){if(!i&&l.length>0){for(var b=0;24>b;++b)l.push(l[l.length-12]);p+=2,v=!0}continue t}g[0][r]=Math.min(g[0][r],m[r],y[r]),g[1][r]=Math.max(g[1][r],m[r],y[r])} +var x,_;Array.isArray(o[0])?(x=o[e-1],_=o[e]):x=_=o,3===x.length&&(x=[x[0],x[1],x[2],1]),3===_.length&&(_=[_[0],_[1],_[2],1]);var w;w=Array.isArray(s)?s[e-1]:s;var k=f;if(f+=n(m,y),v){for(r=0;2>r;++r)l.push(m[0],m[1],m[2],y[0],y[1],y[2],k,w,x[0],x[1],x[2],x[3]);p+=2,v=!1}l.push(m[0],m[1],m[2],y[0],y[1],y[2],k,w,x[0],x[1],x[2],x[3],m[0],m[1],m[2],y[0],y[1],y[2],k,-w,x[0],x[1],x[2],x[3],y[0],y[1],y[2],m[0],m[1],m[2],f,-w,_[0],_[1],_[2],_[3],y[0],y[1],y[2],m[0],m[1],m[2],f,w,_[0],_[1],_[2],_[3]),p+=4}if(this.buffer.update(l),c.push(f),u.push(a[a.length-1].slice()),this.bounds=g,this.vertexCount=p,this.points=u,this.arcLength=c,"dashes"in t){var A=t.dashes,M=A.slice();for(M.unshift(0),e=1;ee;++e){for(r=0;4>r;++r)T.set(e,0,r,0);1&h.le(M,M[M.length-1]*e/255)?T.set(e,0,0,0):T.set(e,0,0,255)}this.texture.setPixels(T)}}},y.dispose=function(){this.shader.dispose(),this.vao.dispose(),this.buffer.dispose()},y.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=f(t.value[0],t.value[1],t.value[2],0),r=h.le(this.arcLength,e);if(0>r)return null;if(r===this.arcLength.length-1)return new a(this.arcLength[this.arcLength.length-1],this.points[this.points.length-1].slice(),r);for(var n=this.points[r],i=this.points[Math.min(r+1,this.points.length-1)],o=(e-this.arcLength[r])/(this.arcLength[r+1]-this.arcLength[r]),s=1-o,l=[0,0,0],c=0;3>c;++c)l[c]=s*n[c]+o*i[c];var u=Math.min(.5>o?r:r+1,this.points.length-1);return new a(e,l,u,this.points[u])}},{"./lib/shaders":126,"binary-search-bounds":128,"gl-buffer":118,"gl-texture2d":222,"gl-vao":226,"glsl-read-float":129,ndarray:253}],128:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],129:[function(t,e,r){function n(t,e,r,n){return i[0]=n,i[1]=r,i[2]=e,i[3]=t,a[0]}e.exports=n;var i=new Uint8Array(4),a=new Float32Array(i.buffer)},{}],130:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=u*o-s*c,h=-u*a+s*l,d=c*a-o*l,p=r*f+n*h+i*d;return p?(p=1/p,t[0]=f*p,t[1]=(-u*n+i*c)*p,t[2]=(s*n-i*o)*p,t[3]=h*p,t[4]=(u*r-i*l)*p,t[5]=(-s*r+i*a)*p,t[6]=d*p,t[7]=(-c*r+n*l)*p,t[8]=(o*r-n*a)*p,t):null}e.exports=n},{}],131:[function(t,e,r){function n(t){var e=new Float32Array(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}e.exports=n},{}],132:[function(t,e,r){function n(){var t=new Float32Array(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],133:[function(t,e,r){function n(t){var e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],c=t[8],u=t[9],f=t[10],h=t[11],d=t[12],p=t[13],g=t[14],v=t[15],m=e*o-r*a,y=e*s-n*a,b=e*l-i*a,x=r*s-n*o,_=r*l-i*o,w=n*l-i*s,k=c*p-u*d,A=c*g-f*d,M=c*v-h*d,T=u*g-f*p,E=u*v-h*p,L=f*v-h*g;return m*L-y*E+b*T+x*M-_*A+w*k}e.exports=n},{}],134:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r+r,s=n+n,l=i+i,c=r*o,u=n*o,f=n*s,h=i*o,d=i*s,p=i*l,g=a*o,v=a*s,m=a*l;return t[0]=1-f-p,t[1]=u+m,t[2]=h-v,t[3]=0,t[4]=u-m,t[5]=1-c-p,t[6]=d+g,t[7]=0,t[8]=h+v,t[9]=d-g,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],135:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=n+n,l=i+i,c=a+a,u=n*s,f=n*l,h=n*c,d=i*l,p=i*c,g=a*c,v=o*s,m=o*l,y=o*c;return t[0]=1-(d+g),t[1]=f+y,t[2]=h-m,t[3]=0,t[4]=f-y,t[5]=1-(u+g),t[6]=p+v,t[7]=0,t[8]=h+m,t[9]=p-v,t[10]=1-(u+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}e.exports=n},{}],136:[function(t,e,r){function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],137:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],g=e[13],v=e[14],m=e[15],y=r*s-n*o,b=r*l-i*o,x=r*c-a*o,_=n*l-i*s,w=n*c-a*s,k=i*c-a*l,A=u*g-f*p,M=u*v-h*p,T=u*m-d*p,E=f*v-h*g,L=f*m-d*g,S=h*m-d*v,C=y*S-b*L+x*E+_*T-w*M+k*A;return C?(C=1/C,t[0]=(s*S-l*L+c*E)*C,t[1]=(i*L-n*S-a*E)*C,t[2]=(g*k-v*w+m*_)*C,t[3]=(h*w-f*k-d*_)*C,t[4]=(l*T-o*S-c*M)*C,t[5]=(r*S-i*T+a*M)*C,t[6]=(v*x-p*k-m*b)*C,t[7]=(u*k-h*x+d*b)*C,t[8]=(o*L-s*T+c*A)*C,t[9]=(n*T-r*L-a*A)*C,t[10]=(p*w-g*x+m*y)*C,t[11]=(f*x-u*w-d*y)*C,t[12]=(s*M-o*E-l*A)*C,t[13]=(r*E-n*M+i*A)*C,t[14]=(g*b-p*_-v*y)*C,t[15]=(u*_-f*b+h*y)*C,t):null}e.exports=n},{}],138:[function(t,e,r){function n(t,e,r,n){var a,o,s,l,c,u,f,h,d,p,g=e[0],v=e[1],m=e[2],y=n[0],b=n[1],x=n[2],_=r[0],w=r[1],k=r[2];return Math.abs(g-_)<1e-6&&Math.abs(v-w)<1e-6&&Math.abs(m-k)<1e-6?i(t):(f=g-_,h=v-w,d=m-k,p=1/Math.sqrt(f*f+h*h+d*d),f*=p,h*=p,d*=p,a=b*d-x*h,o=x*f-y*d,s=y*h-b*f,p=Math.sqrt(a*a+o*o+s*s),p?(p=1/p,a*=p,o*=p,s*=p):(a=0,o=0,s=0),l=h*s-d*o,c=d*a-f*s,u=f*o-h*a,p=Math.sqrt(l*l+c*c+u*u),p?(p=1/p,l*=p,c*=p,u*=p):(l=0,c=0,u=0),t[0]=a,t[1]=l,t[2]=f,t[3]=0,t[4]=o,t[5]=c,t[6]=h,t[7]=0,t[8]=s,t[9]=u,t[10]=d,t[11]=0,t[12]=-(a*g+o*v+s*m),t[13]=-(l*g+c*v+u*m),t[14]=-(f*g+h*v+d*m),t[15]=1,t)}var i=t("./identity");e.exports=n},{"./identity":136}],139:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],g=e[12],v=e[13],m=e[14],y=e[15],b=r[0],x=r[1],_=r[2],w=r[3];return t[0]=b*n+x*s+_*f+w*g,t[1]=b*i+x*l+_*h+w*v,t[2]=b*a+x*c+_*d+w*m,t[3]=b*o+x*u+_*p+w*y,b=r[4],x=r[5],_=r[6],w=r[7],t[4]=b*n+x*s+_*f+w*g,t[5]=b*i+x*l+_*h+w*v,t[6]=b*a+x*c+_*d+w*m,t[7]=b*o+x*u+_*p+w*y,b=r[8],x=r[9],_=r[10],w=r[11],t[8]=b*n+x*s+_*f+w*g,t[9]=b*i+x*l+_*h+w*v,t[10]=b*a+x*c+_*d+w*m,t[11]=b*o+x*u+_*p+w*y,b=r[12],x=r[13],_=r[14],w=r[15],t[12]=b*n+x*s+_*f+w*g,t[13]=b*i+x*l+_*h+w*v,t[14]=b*a+x*c+_*d+w*m,t[15]=b*o+x*u+_*p+w*y,t}e.exports=n},{}],140:[function(t,e,r){function n(t,e,r,n,i){var a=1/Math.tan(e/2),o=1/(n-i);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+n)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*n*o,t[15]=0,t}e.exports=n},{}],141:[function(t,e,r){function n(t,e,r,n){var i,a,o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w,k,A,M,T,E,L=n[0],S=n[1],C=n[2],z=Math.sqrt(L*L+S*S+C*C);return Math.abs(z)<1e-6?null:(z=1/z,L*=z,S*=z,C*=z,i=Math.sin(r),a=Math.cos(r),o=1-a,s=e[0],l=e[1],c=e[2],u=e[3],f=e[4],h=e[5],d=e[6],p=e[7],g=e[8],v=e[9],m=e[10],y=e[11],b=L*L*o+a,x=S*L*o+C*i,_=C*L*o-S*i,w=L*S*o-C*i,k=S*S*o+a,A=C*S*o+L*i,M=L*C*o+S*i,T=S*C*o-L*i,E=C*C*o+a,t[0]=s*b+f*x+g*_,t[1]=l*b+h*x+v*_,t[2]=c*b+d*x+m*_,t[3]=u*b+p*x+y*_,t[4]=s*w+f*k+g*A,t[5]=l*w+h*k+v*A,t[6]=c*w+d*k+m*A,t[7]=u*w+p*k+y*A,t[8]=s*M+f*T+g*E,t[9]=l*M+h*T+v*E,t[10]=c*M+d*T+m*E,t[11]=u*M+p*T+y*E,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}e.exports=n},{}],142:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+c*n,t[5]=o*i+u*n,t[6]=s*i+f*n,t[7]=l*i+h*n,t[8]=c*i-a*n,t[9]=u*i-o*n,t[10]=f*i-s*n,t[11]=h*i-l*n,t}e.exports=n},{}],143:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i-c*n,t[1]=o*i-u*n,t[2]=s*i-f*n,t[3]=l*i-h*n,t[8]=a*n+c*i,t[9]=o*n+u*i,t[10]=s*n+f*i,t[11]=l*n+h*i,t}e.exports=n},{}],144:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[4],u=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+c*n,t[1]=o*i+u*n,t[2]=s*i+f*n,t[3]=l*i+h*n,t[4]=c*i-a*n,t[5]=u*i-o*n,t[6]=f*i-s*n,t[7]=h*i-l*n,t}e.exports=n},{}],145:[function(t,e,r){function n(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}e.exports=n},{}],146:[function(t,e,r){function n(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g=r[0],v=r[1],m=r[2];return e===t?(t[12]=e[0]*g+e[4]*v+e[8]*m+e[12],t[13]=e[1]*g+e[5]*v+e[9]*m+e[13],t[14]=e[2]*g+e[6]*v+e[10]*m+e[14],t[15]=e[3]*g+e[7]*v+e[11]*m+e[15]):(n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],t[0]=n,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=c,t[7]=u,t[8]=f,t[9]=h,t[10]=d,t[11]=p,t[12]=n*g+s*v+f*m+e[12],t[13]=i*g+l*v+h*m+e[13],t[14]=a*g+c*v+d*m+e[14],t[15]=o*g+u*v+p*m+e[15]),t}e.exports=n},{}],147:[function(t,e,r){function n(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],a=e[6],o=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=a,t[11]=e[14],t[12]=i,t[13]=o,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}e.exports=n},{}],148:[function(t,e,r){"use strict";function n(t,e){for(var r=[0,0,0,0],n=0;4>n;++n)for(var i=0;4>i;++i)r[i]+=t[4*n+i]*e[n];return r}function i(t,e,r,i,a){for(var o=n(i,n(r,n(e,[t[0],t[1],t[2],1]))),s=0;3>s;++s)o[s]/=o[3];return[.5*a[0]*(1+o[0]),.5*a[1]*(1-o[1])]}function a(t,e){if(2===t.length){for(var r=0,n=0,i=0;2>i;++i)r+=Math.pow(e[i]-t[0][i],2),n+=Math.pow(e[i]-t[1][i],2);return r=Math.sqrt(r),n=Math.sqrt(n),1e-6>r+n?[1,0]:[n/(r+n),r/(n+r)]}if(3===t.length){var a=[0,0];return c(t[0],t[1],t[2],e,a),l(t,a)}return[]}function o(t,e){for(var r=[0,0,0],n=0;no;++o)r[o]+=a*i[o];return r}function s(t,e,r,n,s,l){if(1===t.length)return[0,t[0].slice()];for(var c=new Array(t.length),u=0;up;++p)d+=Math.pow(c[u][p]-e[p],2);h>d&&(h=d,f=u)}for(var g=a(c,e),v=0,u=0;3>u;++u){if(g[u]<-.001||g[u]>1.0001)return null;v+=g[u]}return Math.abs(v-1)>.001?null:[f,o(t,g),g]}var l=t("barycentric"),c=t("polytope-closest-point/lib/closest_point_2d.js");e.exports=s},{barycentric:151,"polytope-closest-point/lib/closest_point_2d.js":153}],149:[function(t,e,r){var n="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\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\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}",i="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(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\n\n\nfloat cookTorranceSpecular_1_1(\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_2_0(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\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\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(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\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 = cookTorranceSpecular_1_1(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}",a="precision mediump 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}",o="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}",s="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(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}",l="precision mediump 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}",c="precision mediump 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}",u="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if(any(lessThan(f_position, clipBounds[0])) || \n any(greaterThan(f_position, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId, f_id.xyz);\n}",f="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(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}",h="precision mediump 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}",d="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n";r.meshShader={vertex:n,fragment:i,attributes:[{name:"position",type:"vec3"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.wireShader={vertex:a,fragment:o,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.pointShader={vertex:s,fragment:l,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]},r.pickShader={vertex:c,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]},r.pointPickShader={vertex:f,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]},r.contourShader={vertex:h,fragment:d,attributes:[{name:"position",type:"vec3"}]}},{}],150:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w,k,A,M,T){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleColors=u,this.triangleNormals=h,this.triangleUVs=f,this.triangleIds=c,this.triangleVAO=d,this.triangleCount=0,this.lineWidth=1,this.edgePositions=p,this.edgeColors=v,this.edgeUVs=m,this.edgeIds=g,this.edgeVAO=y,this.edgeCount=0,this.pointPositions=b,this.pointColors=_,this.pointUVs=w,this.pointSizes=k,this.pointIds=x,this.pointVAO=A,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=M,this.contourVAO=T,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!0,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this._model=I,this._view=I,this._projection=I,this._resolution=[1,1]}function i(t){for(var e=A({colormap:t,nshades:256,format:"rgba"}),r=new Uint8Array(1024),n=0;256>n;++n){for(var i=e[n],a=0;3>a;++a)r[4*n+a]=i[a];r[4*n+3]=255*i[3]}return k(r,[256,256,4],[4,0,1])}function a(t,e,r){for(var n=new Array(e),i=0;e>i;++i)n[i]=0;for(var a=t.length,i=0;a>i;++i)for(var o=t[i],s=0;sn;++n)r[n]=t[n][2];return r}function s(t){var e=v(t,S);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.normal.location=4,e}function l(t){var e=v(t,C);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e}function c(t){var e=v(t,z);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.pointSize.location=4,e}function u(t){var e=v(t,P);return e.attributes.position.location=0,e.attributes.id.location=1,e}function f(t){var e=v(t,R);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.pointSize.location=4,e}function h(t){var e=v(t,O);return e.attributes.position.location=0,e}function d(t){var e=t.gl,r=s(e),i=l(e),a=c(e),o=u(e),d=f(e),p=h(e),g=b(e,k(new Uint8Array([255,255,255,255]),[1,1,4]));g.generateMipmap(),g.minFilter=e.LINEAR_MIPMAP_LINEAR,g.magFilter=e.LINEAR;var v=m(e),x=m(e),_=m(e),w=m(e),A=m(e),M=y(e,[{buffer:v,type:e.FLOAT,size:3},{buffer:A,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:x,type:e.FLOAT,size:4},{buffer:_,type:e.FLOAT,size:2},{buffer:w,type:e.FLOAT,size:3}]),T=m(e),E=m(e),L=m(e),S=m(e),C=y(e,[{buffer:T,type:e.FLOAT,size:3},{buffer:S,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:E,type:e.FLOAT,size:4},{buffer:L,type:e.FLOAT,size:2}]),z=m(e),P=m(e),R=m(e),O=m(e),I=m(e),N=y(e,[{buffer:z,type:e.FLOAT,size:3},{buffer:I,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:P,type:e.FLOAT,size:4},{buffer:R,type:e.FLOAT,size:2},{buffer:O,type:e.FLOAT,size:1}]),j=m(e),F=y(e,[{buffer:j,type:e.FLOAT,size:3}]),D=new n(e,g,r,i,a,o,d,p,v,A,x,_,w,M,T,S,E,L,C,z,I,P,R,O,N,j,F);return D.update(t),D}var p=1e-6,g=1e-6,v=t("gl-shader"),m=t("gl-buffer"),y=t("gl-vao"),b=t("gl-texture2d"),x=t("normals"),_=t("gl-mat4/multiply"),w=t("gl-mat4/invert"),k=t("ndarray"),A=t("colormap"),M=t("simplicial-complex-contour"),T=t("typedarray-pool"),E=t("./lib/shaders"),L=t("./lib/closest-point"),S=E.meshShader,C=E.wireShader,z=E.pointShader,P=E.pickShader,R=E.pointPickShader,O=E.contourShader,I=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],N=n.prototype;N.isOpaque=function(){return this.opacity>=1},N.isTransparent=function(){return this.opacity<1},N.pickSlots=1,N.setPickBase=function(t){this.pickId=t},N.highlight=function(t){if(!t||!this.contourEnable)return void(this.contourCount=0);for(var e=M(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=T.mallocFloat32(6*a),s=0,l=0;a>l;++l)for(var c=r[l],u=0;2>u;++u){var f=c[0];2===c.length&&(f=c[u]);for(var h=n[f][0],d=n[f][1],p=i[f],g=1-p,v=this.positions[h],m=this.positions[d],y=0;3>y;++y)o[s++]=p*v[y]+g*m[y]}this.contourCount=s/3|0,this.contourPositions.update(o.subarray(0,s)),T.free(o)},N.update=function(t){t=t||{};var e=this.gl;this.dirty=!0,"contourEnable"in t&&(this.contourEnable=t.contourEnable),"contourColor"in t&&(this.contourColor=t.contourColor),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"lightPosition"in t&&(this.lightPosition=t.lightPosition),"opacity"in t&&(this.opacity=t.opacity),"ambient"in t&&(this.ambientLight=t.ambient),"diffuse"in t&&(this.diffuseLight=t.diffuse),"specular"in t&&(this.specularLight=t.specular),"roughness"in t&&(this.roughness=t.roughness),"fresnel"in t&&(this.fresnel=t.fresnel),t.texture?(this.texture.dispose(),this.texture=b(e,t.texture)):t.colormap&&(this.texture.shape=[256,256],this.texture.minFilter=e.LINEAR_MIPMAP_LINEAR,this.texture.magFilter=e.LINEAR,this.texture.setPixels(i(t.colormap)),this.texture.generateMipmap());var r=t.cells,n=t.positions;if(n&&r){var s=[],l=[],c=[],u=[],f=[],h=[],d=[],v=[],m=[],y=[],_=[],w=[],k=[],A=[];this.cells=r,this.positions=n;var M=t.vertexNormals,T=t.cellNormals,E=void 0===t.vertexNormalsEpsilon?p:t.vertexNormalsEpsilon,L=void 0===t.faceNormalsEpsilon?g:t.faceNormalsEpsilon;t.useFacetNormals&&!T&&(T=x.faceNormals(r,n,L)),T||M||(M=x.vertexNormals(r,n,E));var S=t.vertexColors,C=t.cellColors,z=t.meshColor||[1,1,1,1],P=t.vertexUVs,R=t.vertexIntensity,O=t.cellUVs,I=t.cellIntensity,N=1/0,j=-(1/0);if(!P&&!O)if(R)for(var F=0;Fq;++q)!isNaN(V[q])&&isFinite(V[q])&&(this.bounds[0][q]=Math.min(this.bounds[0][q],V[q]),this.bounds[1][q]=Math.max(this.bounds[1][q],V[q]));var H=0,G=0,Y=0;t:for(var F=0;Fq;++q)if(isNaN(V[q])||!isFinite(V[q]))continue t;y.push(V[0],V[1],V[2]);var Z;Z=S?S[W]:C?C[F]:z,3===Z.length?_.push(Z[0],Z[1],Z[2],1):_.push(Z[0],Z[1],Z[2],Z[3]);var K;K=P?P[W]:R?[(R[W]-N)/(j-N),0]:O?O[F]:I?[(I[F]-N)/(j-N),0]:[(V[2]-N)/(j-N),0],w.push(K[0],K[1]),B?k.push(B[W]):k.push(U),A.push(F),Y+=1;break;case 2:for(var q=0;2>q;++q)for(var W=X[q],V=n[W],$=0;3>$;++$)if(isNaN(V[$])||!isFinite(V[$]))continue t;for(var q=0;2>q;++q){var W=X[q],V=n[W];h.push(V[0],V[1],V[2]);var Z;Z=S?S[W]:C?C[F]:z,3===Z.length?d.push(Z[0],Z[1],Z[2],1):d.push(Z[0],Z[1],Z[2],Z[3]);var K;K=P?P[W]:R?[(R[W]-N)/(j-N),0]:O?O[F]:I?[(I[F]-N)/(j-N),0]:[(V[2]-N)/(j-N),0],v.push(K[0],K[1]),m.push(F)}G+=1;break;case 3:for(var q=0;3>q;++q)for(var W=X[q],V=n[W],$=0;3>$;++$)if(isNaN(V[$])||!isFinite(V[$]))continue t;for(var q=0;3>q;++q){var W=X[q],V=n[W];s.push(V[0],V[1],V[2]);var Z;Z=S?S[W]:C?C[F]:z,3===Z.length?l.push(Z[0],Z[1],Z[2],1):l.push(Z[0],Z[1],Z[2],Z[3]);var K;K=P?P[W]:R?[(R[W]-N)/(j-N),0]:O?O[F]:I?[(I[F]-N)/(j-N),0]:[(V[2]-N)/(j-N),0],u.push(K[0],K[1]);var Q;Q=M?M[W]:T[F],c.push(Q[0],Q[1],Q[2]),f.push(F)}H+=1}}this.pointCount=Y,this.edgeCount=G,this.triangleCount=H,this.pointPositions.update(y),this.pointColors.update(_),this.pointUVs.update(w),this.pointSizes.update(k),this.pointIds.update(new Uint32Array(A)),this.edgePositions.update(h),this.edgeColors.update(d),this.edgeUVs.update(v),this.edgeIds.update(new Uint32Array(m)),this.trianglePositions.update(s),this.triangleColors.update(l),this.triangleUVs.update(u),this.triangleNormals.update(c),this.triangleIds.update(new Uint32Array(f))}},N.drawTransparent=N.draw=function(t){t=t||{};for(var e=this.gl,r=t.model||I,n=t.view||I,i=t.projection||I,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;3>o;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);var s={model:r,view:n,projection:i,clipBounds:a,kambient:this.ambientLight,kdiffuse:this.diffuseLight,kspecular:this.specularLight,roughness:this.roughness,fresnel:this.fresnel,eyePosition:[0,0,0],lightPosition:[0,0,0],opacity:this.opacity,contourColor:this.contourColor,texture:0};this.texture.bind(0);var l=new Array(16);_(l,s.view,s.model),_(l,s.projection,l),w(l,l);for(var o=0;3>o;++o)s.eyePosition[o]=l[12+o]/l[15];for(var c=l[15],o=0;3>o;++o)c+=this.lightPosition[o]*l[4*o+3];for(var o=0;3>o;++o){for(var u=l[12+o],f=0;3>f;++f)u+=l[4*f+o]*this.lightPosition[f];s.lightPosition[o]=u/c}if(this.triangleCount>0){var h=this.triShader;h.bind(),h.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()}if(this.edgeCount>0&&this.lineWidth>0){var h=this.lineShader;h.bind(),h.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()}if(this.pointCount>0){var h=this.pointShader;h.bind(),h.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}if(this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0){var h=this.contourShader;h.bind(),h.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind()}},N.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||I,n=t.view||I,i=t.projection||I,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;3>o;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s={model:r,view:n,projection:i,clipBounds:a,pickId:this.pickId/255},l=this.pickShader;if(l.bind(),l.uniforms=s,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0){var l=this.pointPickShader;l.bind(),l.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}},N.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;for(var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions,i=new Array(r.length),a=0;ao;++o){for(var s=new Array(r+1),l=0;r>=l;++l)s[l]=t[l][o];i[o]=s}i[r]=new Array(r+1);for(var o=0;r>=o;++o)i[r][o]=1;for(var c=new Array(r+1),o=0;r>o;++o)c[o]=e[o];c[r]=1;var u=a(i,c),f=n(u[r+1]);0===f&&(f=1);for(var h=new Array(r+1),o=0;r>=o;++o)h[o]=n(u[o])/f;return h}e.exports=i;var a=t("robust-linear-solve")},{"robust-linear-solve":256}],152:[function(t,e,r){var n=1e-6,i=1e-6;r.vertexNormals=function(t,e,r){for(var i=e.length,a=new Array(i),o=void 0===r?n:r,s=0;i>s;++s)a[s]=[0,0,0];for(var s=0;sx;++x)v[x]=d[x]-p[x],m+=v[x]*v[x],y[x]=g[x]-p[x],b+=y[x]*y[x];if(m*b>o)for(var _=a[u],w=1/Math.sqrt(m*b),x=0;3>x;++x){var k=(x+1)%3,A=(x+2)%3;_[x]+=w*(y[k]*v[A]-y[A]*v[k])}}for(var s=0;i>s;++s){for(var _=a[s],M=0,x=0;3>x;++x)M+=_[x]*_[x];if(M>o)for(var w=1/Math.sqrt(M),x=0;3>x;++x)_[x]*=w;else for(var x=0;3>x;++x)_[x]=0}return a},r.faceNormals=function(t,e,r){for(var n=t.length,a=new Array(n),o=void 0===r?i:r,s=0;n>s;++s){for(var l=t[s],c=new Array(3),u=0;3>u;++u)c[u]=e[l[u]];for(var f=new Array(3),h=new Array(3),u=0;3>u;++u)f[u]=c[1][u]-c[0][u],h[u]=c[2][u]-c[0][u];for(var d=new Array(3),p=0,u=0;3>u;++u){var g=(u+1)%3,v=(u+2)%3;d[u]=f[g]*h[v]-f[v]*h[g],p+=d[u]*d[u]}p=p>o?1/Math.sqrt(p):0;for(var u=0;3>u;++u)d[u]*=p;a[s]=d}return a}},{}],153:[function(t,e,r){"use strict";function n(t,e,r,n,s){i.length=x+_)if(0>x)0>_&&0>h?(_=0,-h>=c?(x=1,y=c+2*h+p):(x=-h/c,y=h*x+p)):(x=0,d>=0?(_=0,y=p):-d>=f?(_=1,y=f+2*d+p):(_=-d/f,y=d*_+p));else if(0>_)_=0,h>=0?(x=0,y=p):-h>=c?(x=1,y=c+2*h+p):(x=-h/c,y=h*x+p);else{var w=1/b;x*=w,_*=w,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p}else{var k,A,M,T;0>x?(k=u+h,A=f+d,A>k?(M=A-k,T=c-2*u+f,M>=T?(x=1,_=0,y=c+2*h+p):(x=M/T,_=1-x,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)):(x=0,0>=A?(_=1,y=f+2*d+p):d>=0?(_=0,y=p):(_=-d/f,y=d*_+p))):0>_?(k=u+d,A=c+h,A>k?(M=A-k,T=c-2*u+f,M>=T?(_=1,x=0,y=f+2*d+p):(_=M/T,x=1-_,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)):(_=0,0>=A?(x=1,y=c+2*h+p):h>=0?(x=0,y=p):(x=-h/c,y=h*x+p))):(M=f+d-u-h,0>=M?(x=0,_=1,y=f+2*d+p):(T=c-2*u+f,M>=T?(x=1,_=0,y=c+2*h+p):(x=M/T,_=1-x,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)))}for(var E=1-x-_,l=0;ly?0:y}var i=new Float64Array(4),a=new Float64Array(4),o=new Float64Array(4);e.exports=n},{}],154:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=0,n=0;e>n;++n)r=0|Math.max(r,t[n].length);return r-1}function i(t,e){for(var r=t.length,n=f.mallocUint8(r),i=0;r>i;++i)n[i]=t[i]o;++o)for(var s=t[o],e=s.length,l=0;e>l;++l)for(var c=0;l>c;++c){var d=s[c],p=s[l];i[a++]=0|Math.min(d,p),i[a++]=0|Math.max(d,p)}var g=a/2|0;h(u(i,[g,2]));for(var v=2,o=2;a>o;o+=2)i[o-2]===i[o]&&i[o-1]===i[o+1]||(i[v++]=i[o],i[v++]=i[o+1]);return u(i,[v/2|0,2])}function o(t,e,r,n){for(var i=t.data,a=t.shape[0],o=f.mallocDouble(a),s=0,l=0;a>l;++l){var c=i[2*l],h=i[2*l+1];if(r[c]!==r[h]){var d=e[c],p=e[h];i[2*s]=c,i[2*s+1]=h,o[s++]=(p-n)/(p-d)}}return t.shape[0]=s,u(o,[s])}function s(t,e){var r=f.mallocInt32(2*e),n=t.shape[0],i=t.data;r[0]=0;for(var a=0,o=0;n>o;++o){var s=i[2*o];if(s!==a){for(r[2*a+1]=o;++ai;++i)n[i]=[r[2*i],r[2*i+1]];return n}function c(t,e,r,c){r=r||0,"undefined"==typeof c&&(c=n(t));var u=t.length;if(0===u||1>c)return{cells:[],vertexIds:[],vertexWeights:[]};var h=i(e,+r),p=a(t,c),g=o(p,e,h,+r),v=s(p,0|e.length),m=d(c)(t,p.data,v,h),y=l(p),b=[].slice.call(g.data,0,g.shape[0]);return f.free(h),f.free(p.data),f.free(g.data),f.free(v),{cells:m,vertexIds:y,vertexWeights:b}}e.exports=c;var u=t("ndarray"),f=t("typedarray-pool"),h=t("ndarray-sort"),d=t("./lib/codegen")},{"./lib/codegen":155,ndarray:253,"ndarray-sort":158,"typedarray-pool":278}],155:[function(t,e,r){"use strict";function n(t){function e(t){if(!(t.length<=0)){c.push("R.push(");for(var e=0;e0&&c.push(","),c.push("[");for(var n=0;n0&&c.push(","),c.push("B(C,E,c[",i[0],"],c[",i[1],"])")}c.push("]")}c.push(");")}}var r=0,n=new Array(t+1);n[0]=[[]];for(var i=1;t>=i;++i)for(var s=n[i]=o(i),l=0;l>1,v=E[2*m+1];","if(v===b){return m}","if(b1;--i){t+1>i&&c.push("else "),c.push("if(l===",i,"){");for(var u=[],l=0;i>l;++l)u.push("(S[c["+l+"]]<<"+l+")");c.push("var M=",u.join("+"),";if(M===0||M===",(1<i;++i)n[i]=0,i===e&&(n[i]+=.5),i===r&&(n[i]+=.5);return n}function i(t,e){if(0===e||e===(1<=a;++a)if(e&1<=s;++s)~e&1<n;++n)r[n]=i(t,n);return r}e.exports=a;var o=t("convex-hull")},{"convex-hull":102}],157:[function(t,e,r){"use strict";function n(t){switch(t){case"uint8":return[l.mallocUint8,l.freeUint8];case"uint16":return[l.mallocUint16,l.freeUint16];case"uint32":return[l.mallocUint32,l.freeUint32];case"int8":return[l.mallocInt8,l.freeInt8];case"int16":return[l.mallocInt16,l.freeInt16];case"int32":return[l.mallocInt32,l.freeInt32];case"float32":return[l.mallocFloat,l.freeFloat];case"float64":return[l.mallocDouble,l.freeDouble];default:return null}}function i(t){for(var e=[],r=0;t>r;++r)e.push("s"+r);for(var r=0;t>r;++r)e.push("n"+r);for(var r=1;t>r;++r)e.push("d"+r);for(var r=1;t>r;++r)e.push("e"+r);for(var r=1;t>r;++r)e.push("f"+r);return e}function a(t,e){function r(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function a(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}var o=["'use strict'"],s=["ndarrayInsertionSort",t.join("d"),e].join(""),l=["left","right","data","offset"].concat(i(t.length)),c=n(e),u=["i,j,cptr,ptr=left*s0+offset"];if(t.length>1){for(var f=[],h=1;h1){o.push("dptr=0;sptr=ptr");for(var h=t.length-1;h>=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"left){","dptr=0","sptr=cptr-s0");for(var h=1;hb){break __l}"].join(""));for(var h=t.length-1;h>=1;--h)o.push("sptr+=e"+h,"dptr+=f"+h,"}");o.push("dptr=cptr;sptr=cptr-s0");for(var h=t.length-1;h>=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"left)&&("+r("cptr-s0")+">scratch)){",a("cptr",r("cptr-s0")),"cptr-=s0","}",a("cptr","scratch"));if(o.push("}"),t.length>1&&c&&o.push("free(scratch)"),o.push("} return "+s),c){var p=new Function("malloc","free",o.join("\n"));return p(c[0],c[1])}var p=new Function(o.join("\n"));return p()}function o(t,e,r){function a(t){return["(offset+",t,"*s0)"].join("")}function o(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function s(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}function l(e,r,n){if(1===e.length)_.push("ptr0="+a(e[0]));else for(var i=0;i=0;--i){var o=t[i];0!==o&&_.push(["for(i",o,"=0;i",o,"1)for(var i=0;i1?_.push("ptr_shift+=d"+o):_.push("ptr0+=d"+o),_.push("}"))}}function u(e,r,n,i){if(1===r.length)_.push("ptr0="+a(r[0]));else{for(var o=0;o1)for(var o=0;o=1;--o)n&&_.push("pivot_ptr+=f"+o),r.length>1?_.push("ptr_shift+=e"+o):_.push("ptr0+=e"+o),_.push("}")}function f(){t.length>1&&A&&_.push("free(pivot1)","free(pivot2)")}function h(e,r){var n="el"+e,i="el"+r;if(t.length>1){var s="__l"+ ++M;u(s,[n,i],!1,["comp=",o("ptr0"),"-",o("ptr1"),"\n","if(comp>0){tmp0=",n,";",n,"=",i,";",i,"=tmp0;break ",s,"}\n","if(comp<0){break ",s,"}"].join(""))}else _.push(["if(",o(a(n)),">",o(a(i)),"){tmp0=",n,";",n,"=",i,";",i,"=tmp0}"].join(""))}function d(e,r){t.length>1?l([e,r],!1,s("ptr0",o("ptr1"))):_.push(s(a(e),o(a(r))))}function p(e,r,n){if(t.length>1){var i="__l"+ ++M;u(i,[r],!0,[e,"=",o("ptr0"),"-pivot",n,"[pivot_ptr]\n","if(",e,"!==0){break ",i,"}"].join(""))}else _.push([e,"=",o(a(r)),"-pivot",n].join(""))}function g(e,r){t.length>1?l([e,r],!1,["tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1","tmp")].join("")):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1","tmp")].join(""))}function v(e,r,n){t.length>1?(l([e,r,n],!1,["tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1",o("ptr2")),"\n",s("ptr2","tmp")].join("")),_.push("++"+r,"--"+n)):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","ptr2=",a(n),"\n","++",r,"\n","--",n,"\n","tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1",o("ptr2")),"\n",s("ptr2","tmp")].join(""))}function m(t,e){g(t,e),_.push("--"+e)}function y(e,r,n){t.length>1?l([e,r],!0,[s("ptr0",o("ptr1")),"\n",s("ptr1",["pivot",n,"[pivot_ptr]"].join(""))].join("")):_.push(s(a(e),o(a(r))),s(a(r),"pivot"+n))}function b(e,r){_.push(["if((",r,"-",e,")<=",c,"){\n","insertionSort(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}else{\n",w,"(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}"].join(""))}function x(e,r,n){t.length>1?(_.push(["__l",++M,":while(true){"].join("")),l([e],!0,["if(",o("ptr0"),"!==pivot",r,"[pivot_ptr]){break __l",M,"}"].join("")),_.push(n,"}")):_.push(["while(",o(a(e)),"===pivot",r,"){",n,"}"].join(""))}var _=["'use strict'"],w=["ndarrayQuickSort",t.join("d"),e].join(""),k=["left","right","data","offset"].concat(i(t.length)),A=n(e),M=0;_.push(["function ",w,"(",k.join(","),"){"].join(""));var T=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1=0","comp_pivot2=0","comp=0"];if(t.length>1){for(var E=[],L=1;LL;++L)T.push("b_ptr"+L);T.push("ptr3","ptr4","ptr5","ptr6","ptr7","pivot_ptr","ptr_shift","elementSize="+E.join("*")),A?T.push("pivot1=malloc(elementSize)","pivot2=malloc(elementSize)"):T.push("pivot1=new Array(elementSize),pivot2=new Array(elementSize)")}else T.push("pivot1","pivot2");if(_.push("var "+T.join(",")),h(1,2),h(4,5),h(1,3),h(2,3),h(1,4),h(3,4),h(2,5),h(2,3),h(4,5),t.length>1?l(["el1","el2","el3","el4","el5","index1","index3","index5"],!0,["pivot1[pivot_ptr]=",o("ptr1"),"\n","pivot2[pivot_ptr]=",o("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",o("ptr0"),"\n","y=",o("ptr2"),"\n","z=",o("ptr4"),"\n",s("ptr5","x"),"\n",s("ptr6","y"),"\n",s("ptr7","z")].join("")):_.push(["pivot1=",o(a("el2")),"\n","pivot2=",o(a("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",o(a("el1")),"\n","y=",o(a("el3")),"\n","z=",o(a("el5")),"\n",s(a("index1"),"x"),"\n",s(a("index3"),"y"),"\n",s(a("index5"),"z")].join("")),d("index2","left"),d("index4","right"),_.push("if(pivots_are_equal){"),_.push("for(k=less;k<=great;++k){"),p("comp","k",1),_.push("if(comp===0){continue}"),_.push("if(comp<0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),_.push("while(true){"),p("comp","great",1),_.push("if(comp>0){"),_.push("great--"),_.push("}else if(comp<0){"),v("k","less","great"),_.push("break"),_.push("}else{"),m("k","great"),_.push("break"),_.push("}"),_.push("}"),_.push("}"),_.push("}"),_.push("}else{"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1<0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2>0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp>0){"),_.push("if(--greatindex5){"),x("less",1,"++less"),x("great",2,"--great"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1===0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2===0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp===0){"),_.push("if(--great1&&A){var S=new Function("insertionSort","malloc","free",_.join("\n"));return S(r,A[0],A[1])}var S=new Function("insertionSort",_.join("\n"));return S(r)}function s(t,e){var r=["'use strict'"],n=["ndarraySortWrapper",t.join("d"),e].join(""),s=["array"];r.push(["function ",n,"(",s.join(","),"){"].join(""));for(var l=["data=array.data,offset=array.offset|0,shape=array.shape,stride=array.stride"],u=0;u0?l.push(["d",v,"=s",v,"-d",p,"*n",p].join("")):l.push(["d",v,"=s",v].join("")),p=v);var d=t.length-1-u;0!==d&&(g>0?l.push(["e",d,"=s",d,"-e",g,"*n",g,",f",d,"=",f[d],"-f",g,"*n",g].join("")):l.push(["e",d,"=s",d,",f",d,"=",f[d]].join("")),g=d)}r.push("var "+l.join(","));var m=["0","n0-1","data","offset"].concat(i(t.length));r.push(["if(n0<=",c,"){","insertionSort(",m.join(","),")}else{","quickSort(",m.join(","),")}"].join("")),r.push("}return "+n);var y=new Function("insertionSort","quickSort",r.join("\n")),b=a(t,e),x=o(t,e,b);return y(b,x)}var l=t("typedarray-pool"),c=32;e.exports=s},{"typedarray-pool":278}],158:[function(t,e,r){"use strict";function n(t){var e=t.order,r=t.dtype,n=[e,r],o=n.join(":"),s=a[o];return s||(a[o]=s=i(e,r)),s(t),t}var i=t("./lib/compile_sort.js"),a={};e.exports=n},{"./lib/compile_sort.js":157}],159:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[0,0,0,1,1,0,1,1]),i=o(e,s.boxVert,s.lineFrag);return new n(t,r,i)}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawBox=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o){var s=this.plot,l=this.shader,c=s.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,l.uniforms.lo=t,l.uniforms.hi=e,l.uniforms.color=o,c.drawArrays(c.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":162,"gl-buffer":118,"gl-shader":197}],160:[function(t,e,r){"use strict";function n(t,e,r,n){this.plot=t,this.vbo=e,this.shader=r,this.tickShader=n,this.ticks=[[],[]]}function i(t,e){return t-e}function a(t){var e=t.gl,r=o(e),i=s(e,c.gridVert,c.gridFrag),a=s(e,c.tickVert,c.gridFrag),l=new n(t,r,i,a);return l}e.exports=a;var o=t("gl-buffer"),s=t("gl-shader"),l=t("binary-search-bounds"),c=t("./shaders"),u=n.prototype;u.draw=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){for(var n=this.plot,i=this.vbo,a=this.shader,o=this.ticks,s=n.gl,l=n._tickBounds,c=n.dataBox,u=n.viewBox,f=n.gridLineWidth,h=n.gridLineColor,d=n.gridLineEnable,p=n.pixelRatio,g=0;2>g;++g){var v=l[g],m=l[g+2],y=m-v,b=.5*(c[g+2]+c[g]),x=c[g+2]-c[g];e[g]=2*y/x,t[g]=2*(v-b)/x}a.bind(),i.bind(),a.attributes.dataCoord.pointer(),a.uniforms.dataShift=t,a.uniforms.dataScale=e;for(var _=0,g=0;2>g;++g){r[0]=r[1]=0,r[g]=1,a.uniforms.dataAxis=r,a.uniforms.lineWidth=f[g]/(u[g+2]-u[g])*p,a.uniforms.color=h[g];var w=6*o[g].length;d[g]&&w&&s.drawArrays(s.TRIANGLES,_,w),_+=w}}}(),u.drawTickMarks=function(){var t=[0,0],e=[0,0],r=[1,0],n=[0,1],a=[0,0],o=[0,0];return function(){for(var s=this.plot,c=this.vbo,u=this.tickShader,f=this.ticks,h=s.gl,d=s._tickBounds,p=s.dataBox,g=s.viewBox,v=s.pixelRatio,m=s.screenBox,y=m[2]-m[0],b=m[3]-m[1],x=g[2]-g[0],_=g[3]-g[1],w=0;2>w;++w){var k=d[w],A=d[w+2],M=A-k,T=.5*(p[w+2]+p[w]),E=p[w+2]-p[w];e[w]=2*M/E,t[w]=2*(k-T)/E}e[0]*=x/y,t[0]*=x/y,e[1]*=_/b,t[1]*=_/b,u.bind(),c.bind(),u.attributes.dataCoord.pointer();var L=u.uniforms;L.dataShift=t,L.dataScale=e;var S=s.tickMarkLength,C=s.tickMarkWidth,z=s.tickMarkColor,P=0,R=6*f[0].length,O=Math.min(l.ge(f[0],(p[0]-d[0])/(d[2]-d[0]),i),f[0].length),I=Math.min(l.gt(f[0],(p[2]-d[0])/(d[2]-d[0]),i),f[0].length),N=P+6*O,j=6*Math.max(0,I-O),F=Math.min(l.ge(f[1],(p[1]-d[1])/(d[3]-d[1]),i),f[1].length),D=Math.min(l.gt(f[1],(p[3]-d[1])/(d[3]-d[1]),i),f[1].length),B=R+6*F,U=6*Math.max(0,D-F);a[0]=2*(g[0]-S[1])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[1]*v/y,o[1]=C[1]*v/b,U&&(L.color=z[1],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,B,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[1]-S[0])/b-1,o[0]=C[0]*v/y,o[1]=S[0]*v/b,j&&(L.color=z[0],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,N,j)),a[0]=2*(g[2]+S[3])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[3]*v/y,o[1]=C[3]*v/b,U&&(L.color=z[3],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,B,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[3]+S[2])/b-1,o[0]=C[2]*v/y,o[1]=S[2]*v/b,j&&(L.color=z[2],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,N,j))}}(),u.update=function(){var t=[1,1,-1,-1,1,-1],e=[1,-1,1,1,-1,-1];return function(r){for(var n=r.ticks,i=r.bounds,a=new Float32Array(18*(n[0].length+n[1].length)),o=(this.plot.zeroLineEnable,0),s=[[],[]],l=0;2>l;++l)for(var c=s[l],u=n[l],f=i[l],h=i[l+2],d=0;dg;++g)a[o++]=p,a[o++]=t[g],a[o++]=e[g]}this.ticks=s,this.vbo.update(a)}}(),u.dispose=function(){this.vbo.dispose(),this.shader.dispose(),this.tickShader.dispose()}},{"./shaders":162,"binary-search-bounds":164,"gl-buffer":118,"gl-shader":197}],161:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[-1,-1,-1,1,1,-1,1,1]),i=o(e,s.lineVert,s.lineFrag),l=new n(t,r,i);return l}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawLine=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o,s){var l=this.plot,c=this.shader,u=l.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,c.uniforms.start=t,c.uniforms.end=e,c.uniforms.width=o*l.pixelRatio,c.uniforms.color=s,u.drawArrays(u.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":162,"gl-buffer":118,"gl-shader":197}],162:[function(t,e,r){"use strict";var n="precision lowp float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = vec4(color.xyz * color.w, color.w);\n}\n";e.exports={lineVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 start, end;\nuniform float width;\n\nvec2 perp(vec2 v) {\n return vec2(v.y, -v.x);\n}\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n vec2 delta = normalize(perp(start - end));\n vec2 offset = mix(start, end, 0.5 * (coord.y+1.0));\n gl_Position = vec4(screen(offset + 0.5 * width * delta * coord.x), 0, 1);\n}\n",lineFrag:n,textVert:"#define GLSLIFY 1\nattribute vec3 textCoordinate;\n\nuniform vec2 dataScale, dataShift, dataAxis, screenOffset, textScale;\nuniform float angle;\n\nvoid main() {\n float dataOffset = textCoordinate.z;\n vec2 glyphOffset = textCoordinate.xy;\n mat2 glyphMatrix = mat2(cos(angle), sin(angle), -sin(angle), cos(angle));\n vec2 screenCoordinate = dataAxis * (dataScale * dataOffset + dataShift) +\n glyphMatrix * glyphOffset * textScale + screenOffset;\n gl_Position = vec4(screenCoordinate, 0, 1);\n}\n",textFrag:n,gridVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale;\nuniform float lineWidth;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n pos += 10.0 * dataCoord.y * vec2(dataAxis.y, -dataAxis.x) + dataCoord.z * lineWidth;\n gl_Position = vec4(pos, 0, 1);\n}\n",gridFrag:n,boxVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 lo, hi;\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n gl_Position = vec4(screen(mix(lo, hi, coord)), 0, 1);\n}\n",tickVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale, screenOffset, tickScale;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n gl_Position = vec4(pos + tickScale*dataCoord.yz + screenOffset, 0, 1);\n}\n"}},{}],163:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r,this.tickOffset=[[],[]],this.tickX=[[],[]],this.labelOffset=[0,0],this.labelCount=[0,0]}function i(t){var e=t.gl,r=a(e),i=o(e,c.textVert,c.textFrag),s=new n(t,r,i);return s}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("text-cache"),l=t("binary-search-bounds"),c=t("./shaders"),u=n.prototype;u.drawTicks=function(){var t=[0,0],e=[0,0],r=[0,0];return function(n){var i=this.plot,a=this.shader,o=this.tickX[n],s=this.tickOffset[n],c=i.gl,u=i.viewBox,f=i.dataBox,h=i.screenBox,d=i.pixelRatio,p=i.tickEnable,g=i.tickPad,v=i.tickColor,m=i.tickAngle,y=(i.tickMarkLength,i.labelEnable),b=i.labelPad,x=i.labelColor,_=i.labelAngle,w=this.labelOffset[n],k=this.labelCount[n],A=l.lt(o,f[n]),M=l.le(o,f[n+2]);t[0]=t[1]=0,t[n]=1,e[n]=(u[2+n]+u[n])/(h[2+n]-h[n])-1;var T=2/h[2+(1^n)]-h[1^n];e[1^n]=T*u[1^n]-1,p[n]&&(e[1^n]-=T*d*g[n],M>A&&s[M]>s[A]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n],a.uniforms.angle=m[n],c.drawArrays(c.TRIANGLES,s[A],s[M]-s[A]))),y[n]&&k&&(e[1^n]-=T*d*b[n],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n],a.uniforms.angle=_[n],c.drawArrays(c.TRIANGLES,w,k)),e[1^n]=T*u[2+(1^n)]-1,p[n+2]&&(e[1^n]+=T*d*g[n+2],M>A&&s[M]>s[A]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n+2],a.uniforms.angle=m[n+2],c.drawArrays(c.TRIANGLES,s[A],s[M]-s[A]))),y[n+2]&&k&&(e[1^n]+=T*d*b[n+2],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n+2],a.uniforms.angle=_[n+2],c.drawArrays(c.TRIANGLES,w,k))}}(),u.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,i=r.gl,a=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,o=r.titleCenter,c=r.pixelRatio;if(this.titleCount){for(var u=0;2>u;++u)e[u]=2*(o[u]*c-a[u])/(a[2+u]-a[u])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,i.drawArrays(i.TRIANGLES,this.titleOffset,this.titleCount)}}}(),u.bind=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){var n=this.plot,i=this.shader,a=n._tickBounds,o=n.dataBox,s=n.screenBox,l=n.viewBox;i.bind();for(var c=0;2>c;++c){var u=a[c],f=a[c+2],h=f-u,d=.5*(o[c+2]+o[c]),p=o[c+2]-o[c],g=l[c],v=l[c+2],m=v-g,y=s[c],b=s[c+2],x=b-y;e[c]=2*h/p*m/x,t[c]=2*(u-d)/p*m/x}r[1]=2*n.pixelRatio/(s[3]-s[1]),r[0]=r[1]*(s[3]-s[1])/(s[2]-s[0]),i.uniforms.dataScale=e,i.uniforms.dataShift=t,i.uniforms.textScale=r,this.vbo.bind(),i.attributes.textCoordinate.pointer()}}(),u.update=function(t){for(var e=[],r=t.ticks,n=t.bounds,i=0;2>i;++i){for(var a=[Math.floor(e.length/3)],o=[-(1/0)],l=r[i],c=0;ci;++i){this.labelOffset[i]=Math.floor(e.length/3);for(var g=s(t.labelFont[i],t.labels[i]).data,p=t.labelSize[i],c=0;cp;++p)if(f[p]&&n[p]<=0&&n[p+2]>=0){var g=e[p]-n[p]*(e[p+2]-e[p])/(n[p+2]-n[p]);0===p?o.drawLine(g,e[1],g,e[3],d[p],h[p]):o.drawLine(e[0],g,e[2],g,d[p],h[p])}}for(var p=0;pp;++p)s.drawTicks(p);this.titleEnable&&s.drawTitle();for(var b=this.overlays,p=0;pc;++c){var u=s[c].slice(0);0!==u.length&&(u.sort(a),l[c]=Math.min(l[c],u[0].x),l[c+2]=Math.max(l[c+2],u[u.length-1].x))}this.grid.update({bounds:l,ticks:s}),this.text.update({bounds:l,ticks:s,labels:t.labels||["x","y"],labelSize:t.labelSize||[12,12],labelFont:t.labelFont||["sans-serif","sans-serif"],title:t.title||"",titleSize:t.titleSize||18,titleFont:t.titleFont||"sans-serif"}),this.setDirty()},h.dispose=function(){this.box.dispose(),this.grid.dispose(),this.text.dispose(),this.line.dispose();for(var t=this.objects.length-1;t>=0;--t)this.objects[t].dispose();this.objects.length=0;for(var t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},h.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},h.removeObject=function(t){for(var e=this.objects,r=0;rh;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){return n.setMode(t),n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s=1/t.clientHeight,l=s*(r-d),u=s*(a-p),f=h.flipX?1:-1,g=h.flipY?1:-1,v=Math.PI*h.rotateSpeed,m=i();if(1&e)o.shift?n.rotate(m,0,0,-l*v):n.rotate(m,f*v*l,-g*v*u,0);else if(2&e)n.pan(m,-h.translateSpeed*l*c,h.translateSpeed*u*c,0);else if(4&e){var y=h.zoomSpeed*u/window.innerHeight*(m-n.lastT())*50;n.pan(m,0,0,c*(Math.exp(y)-1))}d=r,p=a}),s(t,function(t,e,r){var a=h.flipX?1:-1,o=h.flipY?1:-1,s=i();if(Math.abs(t)>Math.abs(e))n.rotate(s,0,0,-t*a*Math.PI*h.rotateSpeed/window.innerWidth);else{var l=h.zoomSpeed*o*e/window.innerHeight*(s-n.lastT())/100;n.pan(s,0,0,c*(Math.exp(l)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":39,"mouse-change":241,"mouse-wheel":245,"right-now":255}],168:[function(t,e,r){!function(){"use strict";function t(e){e.permitHostObjects___&&e.permitHostObjects___(t)}function r(t){return!(t.substr(0,d.length)==d&&"___"===t.substr(t.length-3))}function n(t){if(t!==Object(t))throw new TypeError("Not an object: "+t);var e=t[p];if(e&&e.key===t)return e;if(h(t)){e={key:t};try{return f(t,p,{value:e,writable:!1,enumerable:!1,configurable:!1}),e}catch(r){return}}}function i(t){return t.prototype=null,Object.freeze(t)}function a(){y||"undefined"==typeof console||(y=!0,console.warn("WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future."))}if("undefined"==typeof ses||!ses.ok||ses.ok()){"undefined"!=typeof ses&&(ses.weakMapPermitHostObjects=t);var o=!1;if("function"==typeof WeakMap){var s=WeakMap;if("undefined"!=typeof navigator&&/Firefox/.test(navigator.userAgent));else{var l=new s,c=Object.freeze({});if(l.set(c,1),1===l.get(c))return void(e.exports=WeakMap);o=!0}}var u=(Object.prototype.hasOwnProperty,Object.getOwnPropertyNames),f=Object.defineProperty,h=Object.isExtensible,d="weakmap:",p=d+"ident:"+Math.random()+"___";if("undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues&&"function"==typeof ArrayBuffer&&"function"==typeof Uint8Array){var g=new ArrayBuffer(25),v=new Uint8Array(g);crypto.getRandomValues(v),p=d+"rand:"+Array.prototype.map.call(v,function(t){return(t%36).toString(36)}).join("")+"___"}if(f(Object,"getOwnPropertyNames",{value:function(t){return u(t).filter(r)}}),"getPropertyNames"in Object){var m=Object.getPropertyNames;f(Object,"getPropertyNames",{value:function(t){return m(t).filter(r)}})}!function(){var t=Object.freeze;f(Object,"freeze",{value:function(e){return n(e),t(e)}});var e=Object.seal;f(Object,"seal",{value:function(t){return n(t),e(t)}});var r=Object.preventExtensions;f(Object,"preventExtensions",{value:function(t){return n(t),r(t)}})}();var y=!1,b=0,x=function(){function t(t,e){var r,i=n(t);return i?c in i?i[c]:e:(r=s.indexOf(t),r>=0?l[r]:e)}function e(t){var e=n(t);return e?c in e:s.indexOf(t)>=0}function r(t,e){var r,i=n(t);return i?i[c]=e:(r=s.indexOf(t),r>=0?l[r]=e:(r=s.length,l[r]=e,s[r]=t)),this}function o(t){var e,r,i=n(t);return i?c in i&&delete i[c]:(e=s.indexOf(t),0>e?!1:(r=s.length-1,s[e]=void 0,l[e]=l[r],s[e]=s[r],s.length=r,l.length=r,!0))}this instanceof x||a();var s=[],l=[],c=b++;return Object.create(x.prototype,{get___:{value:i(t)},has___:{value:i(e)},set___:{value:i(r)},delete___:{value:i(o)}})};x.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},"delete":{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof s?!function(){function r(){function e(t,e){return u?c.has(t)?c.get(t):u.get___(t,e):c.get(t,e)}function r(t){return c.has(t)||(u?u.has___(t):!1)}function n(t){var e=!!c.delete(t);return u?u.delete___(t)||e:e}this instanceof x||a();var l,c=new s,u=void 0,f=!1;return l=o?function(t,e){return c.set(t,e),c.has(t)||(u||(u=new x),u.set(t,e)),this}:function(t,e){if(f)try{c.set(t,e)}catch(r){u||(u=new x),u.set___(t,e)}else c.set(t,e);return this},Object.create(x.prototype,{get___:{value:i(e)},has___:{value:i(r)},set___:{value:i(l)},delete___:{value:i(n)},permitHostObjects___:{value:i(function(e){if(e!==t)throw new Error("bogus call to permitHostObjects___");f=!0})}})}o&&"undefined"!=typeof Proxy&&(Proxy=void 0),r.prototype=x.prototype,e.exports=r,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=x)}}()},{}],169:[function(t,e,r){"use strict";function n(t){var e=s.get(t);if(!e||!t.isBuffer(e._triangleBuffer.buffer)){var r=a(t,new Float32Array([-1,-1,-1,4,4,-1]));e=o(t,[{buffer:r,type:t.FLOAT,size:2}]),e._triangleBuffer=r,s.set(t,e)}e.bind(),t.drawArrays(t.TRIANGLES,0,3),e.unbind()}var i="undefined"==typeof WeakMap?t("weak-map"):WeakMap,a=t("gl-buffer"),o=t("gl-vao"),s=new i;e.exports=n},{"gl-buffer":118,"gl-vao":226,"weak-map":168}],170:[function(t,e,r){"use strict";function n(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function i(t){this.gl=t,this.pixelRatio=1,this.bounds=[[-10,-10,-10],[10,10,10]],this.ticks=[[],[],[]],this.autoTicks=!0,this.tickSpacing=[1,1,1],this.tickEnable=[!0,!0,!0],this.tickFont=["sans-serif","sans-serif","sans-serif"],this.tickSize=[12,12,12],this.tickAngle=[0,0,0],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=[!0,!0,!0],this.labelFont="sans-serif",this.labelSize=[20,20,20],this.labelAngle=[0,0,0],this.labelColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.labelPad=[10,10,10],this.lineEnable=[!0,!0,!0],this.lineMirror=[!1,!1,!1],this.lineWidth=[1,1,1],this.lineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.lineTickEnable=[!0,!0,!0],this.lineTickMirror=[!1,!1,!1],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=[!0,!0,!0],this.gridWidth=[1,1,1],this.gridColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.zeroEnable=[!0,!0,!0],this.zeroLineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.zeroLineWidth=[2,2,2],this.backgroundEnable=[!1,!1,!1],this.backgroundColor=[[.8,.8,.8,.5],[.8,.8,.8,.5],[.8,.8,.8,.5]],this._firstInit=!0,this._text=null,this._lines=null,this._background=u(t)}function a(){this.primalOffset=[0,0,0],this.primalMinor=[0,0,0],this.mirrorOffset=[0,0,0],this.mirrorMinor=[0,0,0]}function o(t,e,r,n,i){for(var a=t.primalOffset,o=t.primalMinor,s=t.mirrorOffset,l=t.mirrorMinor,c=n[e],u=0;3>u;++u)if(e!==u){var f=a,h=s,d=o,p=l;c&1<0?(d[u]=-1,p[u]=0):(d[u]=0,p[u]=1)}}function s(t,e){var r=new i(t);return r.update(e),r}e.exports=s;var l=t("./lib/text.js"),c=t("./lib/lines.js"),u=t("./lib/background.js"),f=t("./lib/cube.js"),h=t("./lib/ticks.js"),d=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),p=i.prototype;p.update=function(t){function e(e,r,n){if(n in t){var i,a=t[n],o=this[n];(e?Array.isArray(a)&&Array.isArray(a[0]):Array.isArray(a))?this[n]=i=[r(a[0]),r(a[1]),r(a[2])]:this[n]=i=[r(a),r(a),r(a)];for(var s=0;3>s;++s)if(i[s]!==o[s])return!0}return!1}t=t||{};var r,n=e.bind(this,!1,Number),i=e.bind(this,!1,Boolean),a=e.bind(this,!1,String),o=e.bind(this,!0,function(t){if(Array.isArray(t)){if(3===t.length)return[+t[0],+t[1],+t[2],1];if(4===t.length)return[+t[0],+t[1],+t[2],+t[3]]}return[0,0,0,1]}),s=!1,u=!1;if("bounds"in t)for(var f=t.bounds,d=0;2>d;++d)for(var p=0;3>p;++p)f[d][p]!==this.bounds[d][p]&&(u=!0),this.bounds[d][p]=f[d][p];if("ticks"in t){r=t.ticks,s=!0,this.autoTicks=!1;for(var d=0;3>d;++d)this.tickSpacing[d]=0}else n("tickSpacing")&&(this.autoTicks=!0,u=!0);if(this._firstInit&&("ticks"in t||"tickSpacing"in t||(this.autoTicks=!0),u=!0,s=!0,this._firstInit=!1),u&&this.autoTicks&&(r=h.create(this.bounds,this.tickSpacing),s=!0),s){for(var d=0;3>d;++d)r[d].sort(function(t,e){return t.x-e.x});h.equal(r,this.ticks)?s=!1:this.ticks=r}i("tickEnable"),a("tickFont")&&(s=!0),n("tickSize"),n("tickAngle"),n("tickPad"),o("tickColor");var g=a("labels");a("labelFont")&&(g=!0),i("labelEnable"),n("labelSize"),n("labelPad"),o("labelColor"),i("lineEnable"),i("lineMirror"),n("lineWidth"),o("lineColor"),i("lineTickEnable"),i("lineTickMirror"),n("lineTickLength"),n("lineTickWidth"),o("lineTickColor"),i("gridEnable"),n("gridWidth"),o("gridColor"),i("zeroEnable"),o("zeroLineColor"),n("zeroLineWidth"),i("backgroundEnable"),o("backgroundColor"),this._text?this._text&&(g||s)&&this._text.update(this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont):this._text=l(this.gl,this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont),this._lines&&s&&(this._lines.dispose(),this._lines=null),this._lines||(this._lines=c(this.gl,this.bounds,this.ticks))};var g=[new a,new a,new a],v=[0,0,0],m={model:d,view:d,projection:d};p.isOpaque=function(){return!0},p.isTransparent=function(){return!1},p.drawTransparent=function(t){};var y=[0,0,0],b=[0,0,0],x=[0,0,0];p.draw=function(t){t=t||m;for(var e=this.gl,r=t.model||d,i=t.view||d,a=t.projection||d,s=this.bounds,l=f(r,i,a,s),c=l.cubeEdges,u=l.axis,h=i[12],p=i[13],_=i[14],w=i[15],k=this.pixelRatio*(a[3]*h+a[7]*p+a[11]*_+a[15]*w)/e.drawingBufferHeight,A=0;3>A;++A)this.lastCubeProps.cubeEdges[A]=c[A],this.lastCubeProps.axis[A]=u[A];for(var M=g,A=0;3>A;++A)o(g[A],A,this.bounds,c,u);for(var e=this.gl,T=v,A=0;3>A;++A)this.backgroundEnable[A]?T[A]=u[A]:T[A]=0;this._background.draw(r,i,a,s,T,this.backgroundColor),this._lines.bind(r,i,a,this);for(var A=0;3>A;++A){var E=[0,0,0];u[A]>0?E[A]=s[1][A]:E[A]=s[0][A];for(var L=0;2>L;++L){var S=(A+1+L)%3,C=(A+1+(1^L))%3;this.gridEnable[S]&&this._lines.drawGrid(S,C,this.bounds,E,this.gridColor[S],this.gridWidth[S]*this.pixelRatio)}for(var L=0;2>L;++L){var S=(A+1+L)%3,C=(A+1+(1^L))%3;this.zeroEnable[C]&&s[0][C]<=0&&s[1][C]>=0&&this._lines.drawZero(S,C,this.bounds,E,this.zeroLineColor[C],this.zeroLineWidth[C]*this.pixelRatio)}}for(var A=0;3>A;++A){this.lineEnable[A]&&this._lines.drawAxisLine(A,this.bounds,M[A].primalOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio),this.lineMirror[A]&&this._lines.drawAxisLine(A,this.bounds,M[A].mirrorOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio);for(var z=n(y,M[A].primalMinor),P=n(b,M[A].mirrorMinor),R=this.lineTickLength,L=0;3>L;++L){var O=k/r[5*L];z[L]*=R[L]*O,P[L]*=R[L]*O}this.lineTickEnable[A]&&this._lines.drawAxisTicks(A,M[A].primalOffset,z,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio),this.lineTickMirror[A]&&this._lines.drawAxisTicks(A,M[A].mirrorOffset,P,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio)}this._text.bind(r,i,a,this.pixelRatio);for(var A=0;3>A;++A){for(var I=M[A].primalMinor,N=n(x,M[A].primalOffset),L=0;3>L;++L)this.lineTickEnable[A]&&(N[L]+=k*I[L]*Math.max(this.lineTickLength[L],0)/r[5*L]);if(this.tickEnable[A]){for(var L=0;3>L;++L)N[L]+=k*I[L]*this.tickPad[L]/r[5*L];this._text.drawTicks(A,this.tickSize[A],this.tickAngle[A],N,this.tickColor[A])}if(this.labelEnable[A]){for(var L=0;3>L;++L)N[L]+=k*I[L]*this.labelPad[L]/r[5*L];N[A]+=.5*(s[0][A]+s[1][A]),this._text.drawLabel(A,this.labelSize[A],this.labelAngle[A],N,this.labelColor[A])}}},p.dispose=function(){this._text.dispose(),this._lines.dispose(),this._background.dispose(),this._lines=null,this._text=null,this._background=null,this.gl=null}},{"./lib/background.js":171,"./lib/cube.js":172,"./lib/lines.js":173,"./lib/text.js":175,"./lib/ticks.js":176}],171:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n}function i(t){for(var e=[],r=[],i=0,l=0;3>l;++l)for(var c=(l+1)%3,u=(l+2)%3,f=[0,0,0],h=[0,0,0],d=-1;1>=d;d+=2){r.push(i,i+2,i+1,i+1,i+2,i+3),f[l]=d,h[l]=d;for(var p=-1;1>=p;p+=2){f[c]=p;for(var g=-1;1>=g;g+=2)f[u]=g,e.push(f[0],f[1],f[2],h[0],h[1],h[2]),i+=1}var v=c;c=u,u=v}var m=a(t,new Float32Array(e)),y=a(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),b=o(t,[{buffer:m,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:m,type:t.FLOAT,size:3,offset:12,stride:24}],y),x=s(t);return x.attributes.position.location=0,x.attributes.normal.location=1,new n(t,m,b,x)}e.exports=i;var a=t("gl-buffer"),o=t("gl-vao"),s=t("./shaders").bg,l=n.prototype;l.draw=function(t,e,r,n,i,a){for(var o=!1,s=0;3>s;++s)o=o||i[s];if(o){var l=this.gl;l.enable(l.POLYGON_OFFSET_FILL),l.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:t,view:e,projection:r,bounds:n,enable:i,colors:a},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),l.disable(l.POLYGON_OFFSET_FILL)}},l.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders":174,"gl-buffer":118,"gl-vao":226}],172:[function(t,e,r){"use strict";function n(t,e,r){for(var n=0;4>n;++n){t[n]=r[12+n];for(var i=0;3>i;++i)t[n]+=e[i]*r[4*i+n]}}function i(t){for(var e=0;eg;++g){d[2]=a[g][2];for(var b=0;2>b;++b){d[1]=a[b][1];for(var x=0;2>x;++x)d[0]=a[x][0],n(f[l],d,u),l+=1}}for(var _=-1,g=0;8>g;++g){for(var w=f[g][3],k=0;3>k;++k)h[g][k]=f[g][k]/w;0>w&&(0>_?_=g:h[g][2]_){_=0;for(var A=0;3>A;++A){for(var M=(A+2)%3,T=(A+1)%3,E=-1,L=-1,S=0;2>S;++S){var C=S<E||0>L)L>E&&(_|=1<S;++S){var C=S<E&&(_|=1<g;++g)g!==_&&g!==O&&(0>I?I=g:h[I][1]>h[g][1]&&(I=g));for(var N=-1,g=0;3>g;++g){var j=I^1<N&&(N=j);var T=h[j];T[0]g;++g){var j=I^1<F&&(F=j);var T=h[j];T[0]>h[F][0]&&(F=j)}}var D=v;D[0]=D[1]=D[2]=0,D[o.log2(N^I)]=I&N,D[o.log2(I^F)]=I&F;var B=7^F;B===_||B===O?(B=7^N,D[o.log2(F^B)]=B&F):D[o.log2(N^B)]=B&N;for(var U=m,V=_,A=0;3>A;++A)V&1<t;++t)f[t]=[1,1,1,1],h[t]=[1,1,1]}();var g=[[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]],v=[1,1,1],m=[0,0,0],y={cubeEdges:v,axis:m}},{"bit-twiddle":50,"gl-mat4/invert":137,"gl-mat4/multiply":139,"robust-orientation":259,"split-polygon":178}],173:[function(t,e,r){"use strict";function n(t){return t[0]=t[1]=t[2]=0,t}function i(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function a(t,e,r,n,i,a,o,s){this.gl=t,this.vertBuffer=e,this.vao=r,this.shader=n,this.tickCount=i,this.tickOffset=a,this.gridCount=o,this.gridOffset=s}function o(t,e,r){var n=[],i=[0,0,0],o=[0,0,0],u=[0,0,0],f=[0,0,0];n.push(0,0,1,0,1,1,0,0,-1,0,0,-1,0,1,1,0,1,-1);for(var h=0;3>h;++h){for(var d=n.length/3|0,p=0;ph;++h)for(var p=u[h],g=2;g>=0;--g){var v=c[p[g]];s.push(l*v[0],-l*v[1],t)}}for(var s=(this.gl,[]),l=[0,0,0],c=[0,0,0],u=[0,0,0],d=[0,0,0],p=0;3>p;++p){u[p]=s.length/h|0,o(.5*(t[0][p]+t[1][p]),e[p],r),d[p]=(s.length/h|0)-u[p],l[p]=s.length/h|0;for(var g=0;g=0&&(i=r.length-n-1);var a=Math.pow(10,i),o=Math.round(t*e*a),s=o+"";if(s.indexOf("e")>=0)return s;var l=o/a,c=o%a;0>o?(l=0|-Math.ceil(l),c=0|-c):(l=0|Math.floor(l),c=0|c);var u=""+l;if(0>o&&(u="-"+u),i){for(var f=""+c;f.lengthi;++i){for(var a=[],o=(.5*(t[0][i]+t[1][i]),0);o*e[i]<=t[1][i];++o)a.push({x:o*e[i],text:n(e[i],o)});for(var o=-1;o*e[i]>=t[0][i];--o)a.push({x:o*e[i],text:n(e[i],o)});r.push(a)}return r}function a(t,e){for(var r=0;3>r;++r){if(t[r].length!==e[r].length)return!1;for(var n=0;na?a=0:a>1&&(a=1);for(var o=1-a,s=t.length,l=new Array(s),c=0;s>c;++c)l[c]=a*t[c]+o*r[c];return l}function a(t,e){for(var r=[],a=[],o=n(t[t.length-1],e),s=t[t.length-1],l=t[0],c=0;co&&u>0||o>0&&0>u){var f=i(s,u,l,o);r.push(f),a.push(f.slice())}0>u?a.push(l.slice()):u>0?r.push(l.slice()):(r.push(l.slice()),a.push(l.slice())),o=u}return{positive:r,negative:a}}function o(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;la&&c>0||a>0&&0>c)&&r.push(i(o,c,s,a)),c>=0&&r.push(s.slice()),a=c}return r}function s(t,e){for(var r=[],a=n(t[t.length-1],e),o=t[t.length-1],s=t[0],l=0;la&&c>0||a>0&&0>c)&&r.push(i(o,c,s,a)),0>=c&&r.push(s.slice()),a=c}return r}var l=t("robust-dot-product"),c=t("robust-sum");e.exports=a,e.exports.positive=o,e.exports.negative=s},{"robust-dot-product":179,"robust-sum":262}],179:[function(t,e,r){"use strict";function n(t,e){for(var r=i(t[0],e[0]),n=1;na;++a){for(var o=p,s=g,l=0;3>l;++l)s[l]=o[l]=r[l];s[3]=o[3]=1,s[a]+=1,f(s,s,e),s[3]<0&&(t[a]=1/0),o[a]-=1,f(o,o,e),o[3]<0&&(t[a]=1/0);var c=(o[0]/o[3]-s[0]/s[3])*n,u=(o[1]/o[3]-s[1]/s[3])*i;t[a]=.25*Math.sqrt(c*c+u*u)}return t}function a(t,e,r,n,a){var f=e.model||h,p=e.view||h,g=e.projection||h,y=t.bounds,a=a||l(f,p,g,y),b=a.axis;a.edges;c(d,p,f),c(d,g,d);for(var x=v,_=0;3>_;++_)x[_].lo=1/0,x[_].hi=-(1/0),x[_].pixelsPerDataUnit=1/0;var w=o(u(d,d));u(d,d);for(var k=0;3>k;++k){var A=(k+1)%3,M=(k+2)%3,T=m;t:for(var _=0;2>_;++_){var E=[];if(b[k]<0!=!!_){T[k]=y[_][k];for(var L=0;2>L;++L){T[A]=y[L^_][A];for(var S=0;2>S;++S)T[M]=y[S^L^_][M],E.push(T.slice())}for(var L=0;LS;++S)x[S].lo=Math.min(x[S].lo,M[S]),x[S].hi=Math.max(x[S].hi,M[S]),S!==k&&(x[S].pixelsPerDataUnit=Math.min(x[S].pixelsPerDataUnit,Math.abs(C[S])))}}}return x}e.exports=a;var o=t("extract-frustum-planes"),s=t("split-polygon"),l=t("./lib/cube.js"),c=t("gl-mat4/multiply"),u=t("gl-mat4/transpose"),f=t("gl-vec4/transformMat4"),h=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),d=new Float32Array(16),p=[0,0,0,1],g=[0,0,0,1],v=[new n(1/0,-(1/0),1/0),new n(1/0,-(1/0),1/0),new n(1/0,-(1/0),1/0)],m=[0,0,0]},{"./lib/cube.js":172,"extract-frustum-planes":177,"gl-mat4/multiply":139,"gl-mat4/transpose":147,"gl-vec4/transformMat4":227,"split-polygon":178}],181:[function(t,e,r){"use strict";var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, color;\nattribute float weight;\n\nuniform mat4 model, view, projection;\nuniform vec3 coordinates[3];\nuniform vec4 colors[3];\nuniform vec2 screenShape;\nuniform float lineWidth;\n\nvarying vec4 fragColor;\n\nvoid main() {\n vec3 vertexPosition = mix(coordinates[0],\n mix(coordinates[2], coordinates[1], 0.5 * (position + 1.0)), abs(position));\n\n vec4 clipPos = projection * view * model * vec4(vertexPosition, 1.0);\n vec2 clipOffset = (projection * view * model * vec4(color, 0.0)).xy;\n vec2 delta = weight * clipOffset * screenShape;\n vec2 lineOffset = normalize(vec2(delta.y, -delta.x)) / screenShape;\n\n gl_Position = vec4(clipPos.xy + clipPos.w * 0.5 * lineWidth * lineOffset, clipPos.z, clipPos.w);\n fragColor = color.x * colors[0] + color.y * colors[1] + color.z * colors[2];\n}\n",a="precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor;\n\nvoid main() {\n gl_FragColor = fragColor;\n}"; +e.exports=function(t){return n(t,i,a,null,[{name:"position",type:"vec3"},{name:"color",type:"vec3"},{name:"weight",type:"float"}])}},{"gl-shader":197}],182:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n,this.pixelRatio=1,this.bounds=[[-1e3,-1e3,-1e3],[1e3,1e3,1e3]],this.position=[0,0,0],this.lineWidth=[2,2,2],this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.enabled=[!0,!0,!0],this.drawSides=[!0,!0,!0],this.axes=null}function i(t,e){function r(t,e,r,n,a,o){var s=[t,e,r,0,0,0,1];s[n+3]=1,s[n]=a,i.push.apply(i,s),s[6]=-1,i.push.apply(i,s),s[n]=o,i.push.apply(i,s),i.push.apply(i,s),s[6]=1,i.push.apply(i,s),s[n]=a,i.push.apply(i,s)}var i=[];r(0,0,0,0,0,1),r(0,0,0,1,0,1),r(0,0,0,2,0,1),r(1,0,0,1,-1,1),r(1,0,0,2,-1,1),r(0,1,0,0,-1,1),r(0,1,0,2,-1,1),r(0,0,1,0,-1,1),r(0,0,1,1,-1,1);var l=a(t,i),c=o(t,[{type:t.FLOAT,buffer:l,size:3,offset:0,stride:28},{type:t.FLOAT,buffer:l,size:3,offset:12,stride:28},{type:t.FLOAT,buffer:l,size:1,offset:24,stride:28}]),u=s(t);u.attributes.position.location=0,u.attributes.color.location=1,u.attributes.weight.location=2;var f=new n(t,l,c,u);return f.update(e),f}var a=t("gl-buffer"),o=t("gl-vao"),s=t("./shaders/index");e.exports=i;var l=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],c=n.prototype,u=[0,0,0],f=[0,0,0],h=[0,0];c.isTransparent=function(){return!1},c.drawTransparent=function(t){},c.draw=function(t){var e=this.gl,r=this.vao,n=this.shader;r.bind(),n.bind();var i,a=t.model||l,o=t.view||l,s=t.projection||l;this.axes&&(i=this.axes.lastCubeProps.axis);for(var c=u,d=f,p=0;3>p;++p)i&&i[p]<0?(c[p]=this.bounds[0][p],d[p]=this.bounds[1][p]):(c[p]=this.bounds[1][p],d[p]=this.bounds[0][p]);h[0]=e.drawingBufferWidth,h[1]=e.drawingBufferHeight,n.uniforms.model=a,n.uniforms.view=o,n.uniforms.projection=s,n.uniforms.coordinates=[this.position,c,d],n.uniforms.colors=this.colors,n.uniforms.screenShape=h;for(var p=0;3>p;++p)n.uniforms.lineWidth=this.lineWidth[p]*this.pixelRatio,this.enabled[p]&&(r.draw(e.TRIANGLES,6,6*p),this.drawSides[p]&&r.draw(e.TRIANGLES,12,18+12*p));r.unbind()},c.update=function(t){t&&("bounds"in t&&(this.bounds=t.bounds),"position"in t&&(this.position=t.position),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"colors"in t&&(this.colors=t.colors),"enabled"in t&&(this.enabled=t.enabled),"drawSides"in t&&(this.drawSides=t.drawSides))},c.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders/index":181,"gl-buffer":118,"gl-vao":226}],183:[function(t,e,r){"use strict";function n(){this.mouse=[-1,-1],this.screen=null,this.distance=1/0,this.index=null,this.dataCoordinate=null,this.dataPosition=null,this.object=null,this.data=null}function i(t,e){var r=null;try{r=t.getContext("webgl",e),r||(r=t.getContext("experimental-webgl",e))}catch(n){return null}return r}function a(t){var e=Math.round(Math.log(Math.abs(t))/Math.log(10));if(0>e){var r=Math.round(Math.pow(10,-e));return Math.ceil(t*r)/r}if(e>0){var r=Math.round(Math.pow(10,e));return Math.ceil(t/r)*r}return Math.ceil(t)}function o(t){return"boolean"==typeof t?t:!0}function s(t){function e(){if(!_&&H.autoResize){var t=w.parentNode,e=1,r=1;t&&t!==document.body?(e=t.clientWidth,r=t.clientHeight):(e=window.innerWidth,r=window.innerHeight);var n=0|Math.ceil(e*H.pixelRatio),i=0|Math.ceil(r*H.pixelRatio);if(n!==w.width||i!==w.height){w.width=n,w.height=i;var a=w.style;a.position=a.position||"absolute",a.left="0px",a.top="0px",a.width=e+"px",a.height=r+"px",F=!0}}}function r(){for(var t=O.length,e=j.length,r=0;e>r;++r)N[r]=0;t:for(var r=0;t>r;++r){var n=O[r],i=n.pickSlots;if(i){for(var a=0;e>a;++a)if(N[a]+i<255){I[r]=a,n.setPickBase(N[a]+1),N[a]+=i;continue t}var o=h(A,q);I[r]=e,j.push(o),N.push(i),n.setPickBase(1),e+=1}else I[r]=-1}for(;e>0&&0===N[e-1];)N.pop(),j.pop().dispose()}function s(){return H.contextLost?!0:void(A.isContextLost()&&(H.contextLost=!0,H.mouseListener.enabled=!1,H.selection.object=null,H.oncontextloss&&H.oncontextloss()))}function y(){if(!s()){A.colorMask(!0,!0,!0,!0),A.depthMask(!0),A.disable(A.BLEND),A.enable(A.DEPTH_TEST);for(var t=O.length,e=j.length,r=0;e>r;++r){var n=j[r];n.shape=G,n.begin();for(var i=0;t>i;++i)if(I[i]===r){var a=O[i];a.drawPick&&(a.pixelRatio=1,a.drawPick(V))}n.end()}}}function b(){if(!s()){e();var t=H.camera.tick();V.view=H.camera.matrix,F=F||t,D=D||t,z.pixelRatio=H.pixelRatio,R.pixelRatio=H.pixelRatio;var r=O.length,n=W[0],i=W[1];n[0]=n[1]=n[2]=1/0,i[0]=i[1]=i[2]=-(1/0);for(var o=0;r>o;++o){var l=O[o];l.pixelRatio=H.pixelRatio,l.axes=H.axes,F=F||!!l.dirty,D=D||!!l.dirty;var c=l.bounds;if(c)for(var f=c[0],h=c[1],d=0;3>d;++d)n[d]=Math.min(n[d],f[d]),i[d]=Math.max(i[d],h[d])}var g=H.bounds;if(H.autoBounds)for(var d=0;3>d;++d){if(i[d]d;++d)b=b||Z[0][d]!==g[0][d]||Z[1][d]!==g[1][d],Z[0][d]=g[0][d],Z[1][d]=g[1][d];if(b){for(var x=[0,0,0],o=0;3>o;++o)x[o]=a((g[1][o]-g[0][o])/10);z.autoTicks?z.update({bounds:g,tickSpacing:x}):z.update({bounds:g})}D=D||b,F=F||b;var _=A.drawingBufferWidth,w=A.drawingBufferHeight;q[0]=_,q[1]=w,G[0]=0|Math.max(_/H.pixelRatio,1),G[1]=0|Math.max(w/H.pixelRatio,1),v(B,H.fovy,_/w,H.zNear,H.zFar);for(var o=0;16>o;++o)U[o]=0;U[15]=1;for(var k=0,o=0;3>o;++o)k=Math.max(k,g[1][o]-g[0][o]);for(var o=0;3>o;++o)H.autoScale?U[5*o]=H.aspect[o]/(g[1][o]-g[0][o]):U[5*o]=1/k,H.autoCenter&&(U[12+o]=.5*-U[5*o]*(g[0][o]+g[1][o]));for(var o=0;r>o;++o){var l=O[o];l.axesBounds=g,H.clipToBounds&&(l.clipBounds=g)}if(T.object&&(H.snapToData?R.position=T.dataCoordinate:R.position=T.dataPosition,R.bounds=g),D&&(D=!1,y()),F){H.axesPixels=u(H.axes,V,_,w),H.onrender&&H.onrender(),A.bindFramebuffer(A.FRAMEBUFFER,null),A.viewport(0,0,_,w);var M=H.clearColor;A.clearColor(M[0],M[1],M[2],M[3]),A.clear(A.COLOR_BUFFER_BIT|A.DEPTH_BUFFER_BIT),A.depthMask(!0),A.colorMask(!0,!0,!0,!0),A.enable(A.DEPTH_TEST),A.depthFunc(A.LEQUAL),A.disable(A.BLEND),A.disable(A.CULL_FACE);var S=!1;z.enable&&(S=S||z.isTransparent(),z.draw(V)),R.axes=z,T.object&&R.draw(V),A.disable(A.CULL_FACE);for(var o=0;r>o;++o){var l=O[o];l.axes=z,l.pixelRatio=H.pixelRatio,l.isOpaque&&l.isOpaque()&&l.draw(V),l.isTransparent&&l.isTransparent()&&(S=!0)}if(S){E.shape=q,E.bind(),A.clear(A.DEPTH_BUFFER_BIT),A.colorMask(!1,!1,!1,!1),A.depthMask(!0),A.depthFunc(A.LESS),z.enable&&z.isTransparent()&&z.drawTransparent(V);for(var o=0;r>o;++o){var l=O[o];l.isOpaque&&l.isOpaque()&&l.draw(V)}A.enable(A.BLEND),A.blendEquation(A.FUNC_ADD),A.blendFunc(A.ONE,A.ONE_MINUS_SRC_ALPHA),A.colorMask(!0,!0,!0,!0),A.depthMask(!1),A.clearColor(0,0,0,0),A.clear(A.COLOR_BUFFER_BIT),z.isTransparent()&&z.drawTransparent(V);for(var o=0;r>o;++o){var l=O[o];l.isTransparent&&l.isTransparent()&&l.drawTransparent(V)}A.bindFramebuffer(A.FRAMEBUFFER,null),A.blendFunc(A.ONE,A.ONE_MINUS_SRC_ALPHA),A.disable(A.DEPTH_TEST),L.bind(),E.color[0].bind(0),L.uniforms.accumBuffer=0,p(A),A.disable(A.BLEND)}F=!1;for(var o=0;r>o;++o)O[o].dirty=!1}}}function x(){_||H.contextLost||(requestAnimationFrame(x),b())}t=t||{};var _=!1,w=(t.pixelRatio||parseFloat(window.devicePixelRatio),t.canvas);if(!w)if(w=document.createElement("canvas"),t.container){var k=t.container;k.appendChild(w)}else document.body.appendChild(w);var A=t.gl;if(A||(A=i(w,t.glOptions||{premultipliedAlpha:!0,antialias:!0})),!A)throw new Error("webgl not supported");var M=t.bounds||[[-10,-10,-10],[10,10,10]],T=new n,E=d(A,[A.drawingBufferWidth,A.drawingBufferHeight],{preferFloat:!0}),L=m(A),S=t.camera||{eye:[2,0,0],center:[0,0,0],up:[0,1,0],zoomMin:.1,zoomMax:100,mode:"turntable"},C=t.axes||{},z=c(A,C);z.enable=!C.disable;var P=t.spikes||{},R=f(A,P),O=[],I=[],N=[],j=[],F=!0,D=!0,B=new Array(16),U=new Array(16),V={view:null,projection:B,model:U},D=!0,q=[A.drawingBufferWidth,A.drawingBufferHeight],H={gl:A,contextLost:!1,pixelRatio:t.pixelRatio||parseFloat(window.devicePixelRatio),canvas:w,selection:T,camera:l(w,S),axes:z,axesPixels:null,spikes:R,bounds:M,objects:O,shape:q,aspect:t.aspectRatio||[1,1,1],pickRadius:t.pickRadius||10,zNear:t.zNear||.01,zFar:t.zFar||1e3,fovy:t.fovy||Math.PI/4,clearColor:t.clearColor||[0,0,0,0],autoResize:o(t.autoResize),autoBounds:o(t.autoBounds),autoScale:!!t.autoScale,autoCenter:o(t.autoCenter),clipToBounds:o(t.clipToBounds),snapToData:!!t.snapToData,onselect:t.onselect||null,onrender:t.onrender||null,onclick:t.onclick||null,cameraParams:V,oncontextloss:null,mouseListener:null},G=[A.drawingBufferWidth/H.pixelRatio|0,A.drawingBufferHeight/H.pixelRatio|0];H.autoResize&&e(),window.addEventListener("resize",e),H.update=function(t){_||(t=t||{},F=!0,D=!0)},H.add=function(t){_||(t.axes=z,O.push(t),I.push(-1),F=!0,D=!0,r())},H.remove=function(t){if(!_){var e=O.indexOf(t);0>e||(O.splice(e,1),I.pop(),F=!0,D=!0,r())}},H.dispose=function(){if(!_&&(_=!0,window.removeEventListener("resize",e),w.removeEventListener("webglcontextlost",s),H.mouseListener.enabled=!1,!H.contextLost)){z.dispose(),R.dispose();for(var t=0;ts;++s){var l=j[s].query(e,G[1]-r-1,H.pickRadius);if(l){if(l.distance>T.distance)continue;for(var c=0;i>c;++c){var u=O[c];if(I[c]===s){var f=u.pick(l);f&&(T.buttons=t,T.screen=l.coord,T.distance=l.distance,T.object=u,T.index=f.distance,T.dataPosition=f.position,T.dataCoordinate=f.dataCoordinate,T.data=f,o=!0)}}}}}a&&a!==T.object&&(a.highlight&&a.highlight(null),F=!0),T.object&&(T.object.highlight&&T.object.highlight(T.data),F=!0),o=o||T.object!==a,o&&H.onselect&&H.onselect(T),1&t&&!(1&X)&&H.onclick&&H.onclick(T),X=t}}),w.addEventListener("webglcontextlost",s);var W=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],Z=[W[0].slice(),W[1].slice()];return x(),H.redraw=function(){_||(F=!0,b())},H}e.exports=s;var l=t("3d-view-controls"),c=t("gl-axes3d"),u=t("gl-axes3d/properties"),f=t("gl-spikes3d"),h=t("gl-select-static"),d=t("gl-fbo"),p=t("a-big-triangle"),g=t("mouse-change"),v=t("gl-mat4/perspective"),m=t("./lib/shader")},{"./lib/shader":166,"3d-view-controls":167,"a-big-triangle":169,"gl-axes3d":170,"gl-axes3d/properties":180,"gl-fbo":123,"gl-mat4/perspective":140,"gl-select-static":196,"gl-spikes3d":182,"mouse-change":241}],184:[function(t,e,r){"use strict";e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n fragColor = color;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n",fragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n}\n",pickVertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 id;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\nuniform vec4 pickOffset;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n vec4 fragId = id + pickOffset;\n\n fragId.y += floor(fragId.x / 256.0);\n fragId.x -= floor(fragId.x / 256.0) * 256.0;\n\n fragId.z += floor(fragId.y / 256.0);\n fragId.y -= floor(fragId.y / 256.0) * 256.0;\n\n fragId.w += floor(fragId.z / 256.0);\n fragId.z -= floor(fragId.z / 256.0) * 256.0;\n\n fragColor = fragId / 255.0;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n",pickFragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = fragColor;\n}\n"}},{}],185:[function(t,e,r){"use strict";function n(t){if(t in h)return h[t];var e=u(t,{polygons:!0,font:"sans-serif",textAlign:"left",textBaseline:"alphabetic"}),r=[],n=[];e.forEach(function(t){t.forEach(function(t){for(var e=0;eo;++o)i[o]=Math.min(i[o],r[a+o]),i[2+o]=Math.max(i[2+o],r[a+o]);return h[t]={coords:r,normals:n,bounds:i}}function i(t,e,r,n,i,a,o){this.plot=t,this.shader=e,this.pickShader=r,this.positionBuffer=n,this.offsetBuffer=i,this.colorBuffer=a,this.idBuffer=o,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.numVertices=0,this.pickOffset=0,this.points=null}function a(t,e){var r=t.gl,n=o(r,f.vertex,f.fragment),a=o(r,f.pickVertex,f.pickFragment),l=s(r),c=s(r),u=s(r),h=s(r),d=new i(t,n,a,l,c,u,h);return d.update(e),t.addObject(d),d}e.exports=a;var o=t("gl-shader"),s=t("gl-buffer"),l=t("text-cache"),c=t("typedarray-pool"),u=t("vectorize-text"),f=t("./lib/shaders"),h={},d=i.prototype;!function(){function t(){var t=this.plot,n=this.bounds,i=t.viewBox,a=t.dataBox,o=t.pixelRatio,s=n[2]-n[0],l=n[3]-n[1],c=a[2]-a[0],u=a[3]-a[1];e[0]=2*s/c,e[4]=2*l/u,e[6]=2*(n[0]-a[0])/c-1,e[7]=2*(n[1]-a[1])/u-1;var f=i[2]-i[0],h=i[3]-i[1];r[0]=2*o/f,r[1]=2*o/h}var e=[1,0,0,0,1,0,0,0,1],r=[1,1];d.draw=function(){var n=this.plot,i=this.shader,a=this.numVertices;if(a){var o=n.gl;t.call(this),i.bind(),i.uniforms.pixelScale=r,i.uniforms.viewTransform=e,this.positionBuffer.bind(),i.attributes.position.pointer(),this.offsetBuffer.bind(),i.attributes.offset.pointer(),this.colorBuffer.bind(),i.attributes.color.pointer(o.UNSIGNED_BYTE,!0),o.drawArrays(o.TRIANGLES,0,a)}};var n=[0,0,0,0];d.drawPick=function(i){var a=this.plot,o=this.pickShader,s=this.numVertices,l=a.gl;if(this.pickOffset=i,!s)return i;for(var c=0;4>c;++c)n[c]=i>>8*c&255;return t.call(this),o.bind(),o.uniforms.pixelScale=r,o.uniforms.viewTransform=e,o.uniforms.pickOffset=n,this.positionBuffer.bind(),o.attributes.position.pointer(),this.offsetBuffer.bind(),o.attributes.offset.pointer(),this.idBuffer.bind(),o.attributes.id.pointer(l.UNSIGNED_BYTE,!1),l.drawArrays(l.TRIANGLES,0,s),i+this.numPoints}}(),d.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},d.update=function(t){t=t||{};var e=t.positions||[],r=t.colors||[],i=t.glyphs||[],a=t.sizes||[],o=t.borderWidths||[],s=t.borderColors||[];this.points=e;for(var u=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=0,h=0;h>1;for(var d=0;2>d;++d)u[d]=Math.min(u[d],e[2*h+d]),u[2+d]=Math.max(u[2+d],e[2*h+d])}u[0]===u[2]&&(u[2]+=1),u[3]===u[1]&&(u[3]+=1);for(var p=1/(u[2]-u[0]),g=1/(u[3]-u[1]),v=u[0],m=u[1],y=c.mallocFloat32(2*f),b=c.mallocFloat32(2*f),x=c.mallocUint8(4*f),_=c.mallocUint32(f),w=0,h=0;h=a?i(0,a-1,t,e,r,n):f(0,a-1,t,e,r,n)}function i(t,e,r,n,i,a){for(var o=t+1;e>=o;++o){for(var s=r[o],l=n[2*o],c=n[2*o+1],u=i[o],f=a[o],h=o;h>t;){var d=r[h-1],p=n[2*(h-1)];if((d-s||l-p)>=0)break;r[h]=d,n[2*h]=p,n[2*h+1]=n[2*h-1],i[h]=i[h-1],a[h]=a[h-1],h-=1}r[h]=s,n[2*h]=l,n[2*h+1]=c,i[h]=u,a[h]=f}}function a(t,e,r,n,i,a){var o=r[t],s=n[2*t],l=n[2*t+1],c=i[t],u=a[t];r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e],r[e]=o,n[2*e]=s,n[2*e+1]=l,i[e]=c,a[e]=u}function o(t,e,r,n,i,a){r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e]}function s(t,e,r,n,i,a,o){var s=n[t],l=i[2*t],c=i[2*t+1],u=a[t],f=o[t];n[t]=n[e],i[2*t]=i[2*e],i[2*t+1]=i[2*e+1],a[t]=a[e],o[t]=o[e],n[e]=n[r],i[2*e]=i[2*r],i[2*e+1]=i[2*r+1],a[e]=a[r],o[e]=o[r],n[r]=s,i[2*r]=l,i[2*r+1]=c,a[r]=u,o[r]=f}function l(t,e,r,n,i,a,o,s,l,c,u){s[t]=s[e],l[2*t]=l[2*e],l[2*t+1]=l[2*e+1],c[t]=c[e],u[t]=u[e],s[e]=r,l[2*e]=n,l[2*e+1]=i,c[e]=a,u[e]=o}function c(t,e,r,n,i){return(r[t]-r[e]||n[2*e]-n[2*t]||i[t]-i[e])<0}function u(t,e,r,n,i,a,o,s){return(e-a[t]||o[2*t]-r||i-s[t])<0}function f(t,e,r,n,d,p){var g=(e-t+1)/6|0,v=t+g,m=e-g,y=t+e>>1,b=y-g,x=y+g,_=v,w=b,k=y,A=x,M=m,T=t+1,E=e-1,L=0;c(_,w,r,n,d,p)&&(L=_,_=w,w=L),c(A,M,r,n,d,p)&&(L=A,A=M,M=L),c(_,k,r,n,d,p)&&(L=_,_=k,k=L),c(w,k,r,n,d,p)&&(L=w,w=k,k=L),c(_,A,r,n,d,p)&&(L=_,_=A,A=L),c(k,A,r,n,d,p)&&(L=k,k=A,A=L),c(w,M,r,n,d,p)&&(L=w,w=M,M=L),c(w,k,r,n,d,p)&&(L=w,w=k,k=L),c(A,M,r,n,d,p)&&(L=A,A=M,M=L);var S=r[w],C=n[2*w],z=n[2*w+1],P=d[w],R=p[w],O=r[A],I=n[2*A],N=n[2*A+1],j=d[A],F=p[A],D=_,B=k,U=M,V=v,q=y,H=m,G=r[D],Y=r[B],X=r[U];r[V]=G,r[q]=Y,r[H]=X;for(var W=0;2>W;++W){var Z=n[2*D+W],K=n[2*B+W],$=n[2*U+W];n[2*V+W]=Z,n[2*q+W]=K,n[2*H+W]=$}var Q=d[D],J=d[B],tt=d[U];d[V]=Q,d[q]=J,d[H]=tt;var et=p[D],rt=p[B],nt=p[U];p[V]=et,p[q]=rt,p[H]=nt,o(b,t,r,n,d,p),o(x,e,r,n,d,p);for(var it=T;E>=it;++it)if(u(it,S,C,z,P,r,n,d))it!==T&&a(it,T,r,n,d,p),++T;else if(!u(it,O,I,N,j,r,n,d))for(;;){if(u(E,O,I,N,j,r,n,d)){u(E,S,C,z,P,r,n,d)?(s(it,T,E,r,n,d,p),++T,--E):(a(it,E,r,n,d,p),--E);break}if(--E=T-2-t?i(t,T-2,r,n,d,p):f(t,T-2,r,n,d,p),h>=e-(E+2)?i(E+2,e,r,n,d,p):f(E+2,e,r,n,d,p),h>=E-T?i(T,E,r,n,d,p):f(T,E,r,n,d,p)}e.exports=n;var h=32},{}],189:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s){for(var l=r,c=r;n>c;++c){var u=t[2*c],f=t[2*c+1],h=e[c];u>=i&&o>=u&&f>=a&&s>=f&&(c===l?l+=1:(t[2*c]=t[2*l],t[2*c+1]=t[2*l+1],e[c]=e[l],t[2*l]=u,t[2*l+1]=f,e[l]=h,l+=1))}return l}function i(t,e,r){this.pixelSize=t,this.offset=e,this.count=r}function a(t,e,r,a){function l(i,a,o,s,c,u){var f=.5*o,h=s+1,d=c-s;r[_]=d,x[_++]=u;for(var p=0;2>p;++p)for(var g=0;2>g;++g){var v=i+p*f,m=a+g*f,y=n(t,e,h,c,v,m,v+f,m+f);if(y!==h){if(y-h>=Math.max(.9*d,32)){var b=c+s>>>1;l(v,m,f,h,b,u+1),h=b}l(v,m,f,h,y,u+1),h=y}}}var c=t.length>>>1;if(1>c)return[];for(var u=1/0,f=1/0,h=-(1/0),d=-(1/0),p=0;c>p;++p){var g=t[2*p],v=t[2*p+1];u=Math.min(u,g),h=Math.max(h,g),f=Math.min(f,v),d=Math.max(d,v),e[p]=p}u===h&&(h+=1+Math.abs(h)),f===d&&(d+=1+Math.abs(h));var m=1/(h-u),y=1/(d-f),b=Math.max(h-u,d-f);a=a||[0,0,0,0],a[0]=u,a[1]=f,a[2]=h,a[3]=d;var x=o.mallocInt32(c),_=0;l(u,f,b,0,c,0),s(x,t,e,r,c);for(var w=[],k=0,A=c,_=c-1;_>=0;--_){t[2*_]=(t[2*_]-u)*m,t[2*_+1]=(t[2*_+1]-f)*y;var M=x[_];M!==k&&(w.push(new i(b*Math.pow(.5,M),_+1,A-(_+1))),A=_+1,k=M)}return w.push(new i(b*Math.pow(.5,M+1),0,A)),o.free(x),w}var o=t("typedarray-pool"),s=t("./lib/sort");e.exports=a},{"./lib/sort":188,"typedarray-pool":278}],190:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.weightBuffer=n,this.shader=i,this.pickShader=a,this.scales=[],this.size=12,this.borderSize=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.pickOffset=0,this.points=null,this.xCoords=null}function i(t,e){var r=t.gl,i=o(r),s=o(r),l=o(r),c=a(r,u.pointVertex,u.pointFragment),f=a(r,u.pickVertex,u.pickFragment),h=new n(t,i,s,l,c,f);return h.update(e),t.addObject(h),h}var a=t("gl-shader"),o=t("gl-buffer"),s=t("binary-search-bounds"),l=t("snap-points-2d"),c=t("typedarray-pool"),u=t("./lib/shader");e.exports=i;var f=n.prototype;f.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.xCoords&&c.free(this.xCoords),this.plot.removeObject(this)},f.update=function(t){function e(e,r){return e in t?t[e]:r}t=t||{},this.size=e("size",12),this.color=e("color",[1,0,0,1]).slice(),this.borderSize=e("borderSize",1),this.borderColor=e("borderColor",[0,0,0,1]).slice(),this.xCoords&&c.free(this.xCoords);var r=t.positions,n=c.mallocFloat32(r.length),i=c.mallocInt32(r.length>>>1);n.set(r);var a=c.mallocFloat32(r.length);this.points=r,this.scales=l(n,i,a,this.bounds),this.offsetBuffer.update(n),this.pickBuffer.update(i),this.weightBuffer.update(a);for(var o=c.mallocFloat32(r.length>>>1),s=0,u=0;s>>1,this.pickOffset=0},f.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0,0,0];return function(r){var n=this.plot,i=this.pickShader,a=this.scales,o=this.offsetBuffer,l=this.pickBuffer,c=this.bounds,u=this.size,f=this.borderSize,h=n.gl,d=n.pickPixelRatio,p=n.viewBox,g=n.dataBox;if(0===this.pointCount)return r;var v=c[2]-c[0],m=c[3]-c[1],y=g[2]-g[0],b=g[3]-g[1],x=(p[2]-p[0])*d/n.pixelRatio,_=(p[3]-p[1])*d/n.pixelRatio,w=Math.min(y/x,b/_);t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(c[0]-g[0])/y-1,t[7]=2*(c[1]-g[1])/b-1,this.pickOffset=r,e[0]=255&r,e[1]=r>>8&255,e[2]=r>>16&255,e[3]=r>>24&255,i.bind(),i.uniforms.matrix=t,i.uniforms.color=this.color,i.uniforms.borderColor=this.borderColor,i.uniforms.pointSize=d*(u+f),i.uniforms.pickOffset=e,0===this.borderSize?i.uniforms.centerFraction=2:i.uniforms.centerFraction=u/(u+f+1.25),o.bind(),i.attributes.position.pointer(),l.bind(),i.attributes.pickId.pointer(h.UNSIGNED_BYTE);for(var k=this.xCoords,A=(g[0]-c[0]-w*u*d)/v,M=(g[2]-c[0]+w*u*d)/v,T=a.length-1;T>=0;--T){var E=a[T];if(!(E.pixelSize1)){var L=E.offset,S=E.count+L,C=s.ge(k,A,L,S-1),z=s.lt(k,M,C,S-1)+1;z>C&&h.drawArrays(h.POINTS,C,z-C)}}return r+this.pointCount}}(),f.draw=function(){var t=[1,0,0,0,1,0,0,0,1];return function(){var e=this.plot,r=this.shader,n=this.scales,i=this.offsetBuffer,a=this.bounds,o=this.size,l=this.borderSize,c=e.gl,u=e.pixelRatio,f=e.viewBox,h=e.dataBox;if(0!==this.pointCount){var d=a[2]-a[0],p=a[3]-a[1],g=h[2]-h[0],v=h[3]-h[1],m=f[2]-f[0],y=f[3]-f[1],b=Math.min(g/m,v/y);t[0]=2*d/g,t[4]=2*p/v,t[6]=2*(a[0]-h[0])/g-1,t[7]=2*(a[1]-h[1])/v-1,r.bind(),r.uniforms.matrix=t,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointSize=u*(o+l),r.uniforms.useWeight=1,0===this.borderSize?r.uniforms.centerFraction=2:r.uniforms.centerFraction=o/(o+l+1.25),i.bind(),r.attributes.position.pointer(),this.weightBuffer.bind(),r.attributes.weight.pointer();for(var x=this.xCoords,_=(h[0]-a[0]-b*o*u)/d,w=(h[2]-a[0]+b*o*u)/d,k=!0,A=n.length-1;A>=0;--A){var M=n[A];if(!(M.pixelSize1)){var T=M.offset,E=M.count+T,L=s.ge(x,_,T,E-1),S=s.lt(x,w,L,E-1)+1;S>L&&c.drawArrays(c.POINTS,L,S-L),k&&(k=!1,r.uniforms.useWeight=0)}}}}}(),f.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}}},{"./lib/shader":186,"binary-search-bounds":187,"gl-buffer":118,"gl-shader":197,"snap-points-2d":189,"typedarray-pool":278}],191:[function(t,e,r){"use strict";function n(t,e){var r=a[e];if(r||(r=a[e]={}),t in r)return r[t];for(var n=i(t,{textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),o=i(t,{triangles:!0,textAlign:"center",textBaseline:"middle",lineHeight:1,font:e}),s=[[1/0,1/0],[-(1/0),-(1/0)]],l=0;lu;++u)s[0][u]=Math.min(s[0][u],c[u]),s[1][u]=Math.max(s[1][u],c[u]);return r[t]=[o,n,s]}var i=t("vectorize-text");e.exports=n;var a={}},{"vectorize-text":280}],192:[function(t,e,r){function n(t,e){var r=i(t,e),n=r.attributes;return n.position.location=0,n.color.location=1,n.glyph.location=2,n.id.location=3,r}var i=t("gl-shader"),a="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\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(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1])) ) {\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}",o="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) || any(greaterThan(position, clipBounds[1]))) {\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}",s="precision mediump float;\n#define GLSLIFY 1\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(any(lessThan(position, clipBounds[0])) ||\n any(greaterThan(position, clipBounds[1])) ) {\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",l="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if(any(lessThan(dataCoordinate, fragClipBounds[0])) ||\n any(greaterThan(dataCoordinate, fragClipBounds[1])) ) {\n discard;\n } else {\n gl_FragColor = interpColor * opacity;\n }\n}\n",c="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if(any(lessThan(dataCoordinate, fragClipBounds[0])) || \n any(greaterThan(dataCoordinate, fragClipBounds[1])) ) {\n discard;\n } else {\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n }\n}",u=[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"glyph",type:"vec2"},{name:"id",type:"vec4"}],f={vertex:a,fragment:l,attributes:u},h={vertex:o,fragment:l,attributes:u},d={vertex:s,fragment:l,attributes:u},p={vertex:a,fragment:c,attributes:u},g={vertex:o,fragment:c,attributes:u},v={vertex:s,fragment:c,attributes:u};r.createPerspective=function(t){return n(t,f)},r.createOrtho=function(t){return n(t,h)},r.createProject=function(t){return n(t,d)},r.createPickPerspective=function(t){return n(t,p)},r.createPickOrtho=function(t){return n(t,g)},r.createPickProject=function(t){return n(t,v)}},{"gl-shader":197}],193:[function(t,e,r){"use strict";function n(t,e){var r=t[0],n=t[1],i=t[2],a=t[3];return t[0]=e[0]*r+e[4]*n+e[8]*i+e[12]*a,t[1]=e[1]*r+e[5]*n+e[9]*i+e[13]*a,t[2]=e[2]*r+e[6]*n+e[10]*i+e[14]*a,t[3]=e[3]*r+e[7]*n+e[11]*i+e[15]*a, +t}function i(t,e,r,i){return n(i,i,r),n(i,i,e),n(i,i,t)}function a(t,e){this.index=t,this.dataCoordinate=this.position=e}function o(t,e,r,n,i,o,s,l,c,u,f,h){this.gl=t,this.pixelRatio=1,this.shader=e,this.orthoShader=r,this.projectShader=n,this.pointBuffer=i,this.colorBuffer=o,this.glyphBuffer=s,this.idBuffer=l,this.vao=c,this.vertexCount=0,this.lineVertexCount=0,this.opacity=1,this.lineWidth=0,this.projectScale=[2/3,2/3,2/3],this.projectOpacity=[1,1,1],this.pickId=0,this.pickPerspectiveShader=u,this.pickOrthoShader=f,this.pickProjectShader=h,this.points=[],this._selectResult=new a(0,[0,0,0]),this.useOrtho=!0,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.axesProject=[!0,!0,!0],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.highlightId=[1,1,1,1],this.highlightScale=2,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.dirty=!0}function s(t){return t[0]=t[1]=t[2]=0,t}function l(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t}function c(t,e,r,n){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[r]=n,t}function u(t){for(var e=S,r=0;2>r;++r)for(var n=0;3>n;++n)e[r][n]=Math.max(Math.min(t[r][n],1e8),-1e8);return e}function f(t,e,r,n,a){var o,f=e.axesProject,h=e.gl,d=t.uniforms,p=r.model||x,g=r.view||x,v=r.projection||x,y=e.axesBounds,b=u(e.clipBounds);o=e.axes?e.axes.lastCubeProps.axis:[1,1,1],w[0]=2/h.drawingBufferWidth,w[1]=2/h.drawingBufferHeight,t.bind(),d.view=g,d.projection=v,d.screenSize=w,d.highlightId=e.highlightId,d.highlightScale=e.highlightScale,d.clipBounds=b,d.pickGroup=e.pickId/255,d.pixelRatio=e.pixelRatio;for(var _=0;3>_;++_)if(f[_]&&e.projectOpacity[_]<1===n){d.scale=e.projectScale[_],d.opacity=e.projectOpacity[_];for(var S=E,C=0;16>C;++C)S[C]=0;for(var C=0;4>C;++C)S[5*C]=1;S[5*_]=0,o[_]<0?S[12+_]=y[0][_]:S[12+_]=y[1][_],m(S,p,S),d.model=S;var z=(_+1)%3,P=(_+2)%3,R=s(k),O=s(A);R[z]=1,O[P]=1;var I=i(v,g,p,l(M,R)),N=i(v,g,p,l(T,O));if(Math.abs(I[1])>Math.abs(N[1])){var j=I;I=N,N=j,j=R,R=O,O=j;var F=z;z=P,P=F}I[0]<0&&(R[z]=-1),N[1]>0&&(O[P]=-1);for(var D=0,B=0,C=0;4>C;++C)D+=Math.pow(p[4*z+C],2),B+=Math.pow(p[4*P+C],2);R[z]/=Math.sqrt(D),O[P]/=Math.sqrt(B),d.axes[0]=R,d.axes[1]=O,d.fragClipBounds[0]=c(L,b[0],_,-1e8),d.fragClipBounds[1]=c(L,b[1],_,1e8),e.vao.draw(h.TRIANGLES,e.vertexCount),e.lineWidth>0&&(h.lineWidth(e.lineWidth),e.vao.draw(h.LINES,e.lineVertexCount,e.vertexCount))}}function h(t,e,r,n,i,a){var o=r.gl;if(r.vao.bind(),i===r.opacity<1||a){t.bind();var s=t.uniforms;s.model=n.model||x,s.view=n.view||x,s.projection=n.projection||x,w[0]=2/o.drawingBufferWidth,w[1]=2/o.drawingBufferHeight,s.screenSize=w,s.highlightId=r.highlightId,s.highlightScale=r.highlightScale,s.fragClipBounds=P,s.clipBounds=r.axes.bounds,s.opacity=r.opacity,s.pickGroup=r.pickId/255,s.pixelRatio=r.pixelRatio,r.vao.draw(o.TRIANGLES,r.vertexCount),r.lineWidth>0&&(o.lineWidth(r.lineWidth),r.vao.draw(o.LINES,r.lineVertexCount,r.vertexCount))}f(e,r,n,i,a),r.vao.unbind()}function d(t){var e=t.gl,r=y.createPerspective(e),n=y.createOrtho(e),i=y.createProject(e),a=y.createPickPerspective(e),s=y.createPickOrtho(e),l=y.createPickProject(e),c=p(e),u=p(e),f=p(e),h=p(e),d=g(e,[{buffer:c,size:3,type:e.FLOAT},{buffer:u,size:4,type:e.FLOAT},{buffer:f,size:2,type:e.FLOAT},{buffer:h,size:4,type:e.UNSIGNED_BYTE,normalized:!0}]),v=new o(e,r,n,i,c,u,f,h,d,a,s,l);return v.update(t),v}var p=t("gl-buffer"),g=t("gl-vao"),v=t("typedarray-pool"),m=t("gl-mat4/multiply"),y=t("./lib/shaders"),b=t("./lib/glyphs"),x=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];e.exports=d;var _=o.prototype;_.pickSlots=1,_.setPickBase=function(t){this.pickId=t},_.isTransparent=function(){if(this.opacity<1)return!0;for(var t=0;3>t;++t)if(this.axesProject[t]&&this.projectOpacity[t]<1)return!0;return!1},_.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;3>t;++t)if(this.axesProject[t]&&this.projectOpacity[t]>=1)return!0;return!1};var w=[0,0],k=[0,0,0],A=[0,0,0],M=[0,0,0,1],T=[0,0,0,1],E=x.slice(),L=[0,0,0],S=[[0,0,0],[0,0,0]],C=[-1e8,-1e8,-1e8],z=[1e8,1e8,1e8],P=[C,z];_.draw=function(t){var e=this.useOrtho?this.orthoShader:this.shader;h(e,this.projectShader,this,t,!1,!1)},_.drawTransparent=function(t){var e=this.useOrtho?this.orthoShader:this.shader;h(e,this.projectShader,this,t,!0,!1)},_.drawPick=function(t){var e=this.useOrtho?this.pickOrthoShader:this.pickPerspectiveShader;h(e,this.pickProjectShader,this,t,!1,!0)},_.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=t.value[2]+(t.value[1]<<8)+(t.value[0]<<16);if(e>=this.pointCount||0>e)return null;var r=this.points[e],n=this._selectResult;n.index=e;for(var i=0;3>i;++i)n.position[i]=n.dataCoordinate[i]=r[i];return n},_.highlight=function(t){if(t){var e=t.index,r=255&e,n=e>>8&255,i=e>>16&255;this.highlightId=[r/255,n/255,i/255,0]}else this.highlightId=[1,1,1,1]},_.update=function(t){if(t=t||{},"perspective"in t&&(this.useOrtho=!t.perspective),"orthographic"in t&&(this.useOrtho=!!t.orthographic),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"project"in t)if(Array.isArray(t.project))this.axesProject=t.project;else{var e=!!t.project;this.axesProject=[e,e,e]}if("projectScale"in t)if(Array.isArray(t.projectScale))this.projectScale=t.projectScale.slice();else{var r=+t.projectScale;this.projectScale=[r,r,r]}if("projectOpacity"in t)if(Array.isArray(t.projectOpacity))this.projectOpacity=t.projectOpacity.slice();else{var r=+t.projectOpacity;this.projectOpacity=[r,r,r]}"opacity"in t&&(this.opacity=t.opacity),this.dirty=!0;var n=t.position;if(n){var i=t.font||"normal",a=t.alignment||[0,0],o=[1/0,1/0,1/0],s=[-(1/0),-(1/0),-(1/0)],l=t.glyph,c=t.color,u=t.size,f=t.angle,h=t.lineColor,d=0,p=0,g=0,m=n.length;t:for(var y=0;m>y;++y){for(var x=n[y],_=0;3>_;++_)if(isNaN(x[_])||!isFinite(x[_]))continue t;var w;w=Array.isArray(l)?b(l[y],i):l?b(l,i):b("\u25cf",i);var k=w[0],A=w[1],M=w[2];p+=3*k.cells.length,g+=2*A.edges.length}var T=p+g,E=v.mallocFloat(3*T),L=v.mallocFloat(4*T),S=v.mallocFloat(2*T),C=v.mallocUint32(T),z=[0,a[1]],P=0,R=p,O=[0,0,0,1],I=[0,0,0,1],N=Array.isArray(c)&&Array.isArray(c[0]),j=Array.isArray(h)&&Array.isArray(h[0]);t:for(var y=0;m>y;++y){for(var x=n[y],_=0;3>_;++_){if(isNaN(x[_])||!isFinite(x[_])){d+=1;continue t}s[_]=Math.max(s[_],x[_]),o[_]=Math.min(o[_],x[_])}var w;w=Array.isArray(l)?b(l[y],i):l?b(l,i):b("\u25cf",i);var k=w[0],A=w[1],M=w[2];if(Array.isArray(c)){var F;if(F=N?c[y]:c,3===F.length){for(var _=0;3>_;++_)O[_]=F[_];O[3]=1}else if(4===F.length)for(var _=0;4>_;++_)O[_]=F[_]}else O[0]=O[1]=O[2]=0,O[3]=1;if(Array.isArray(h)){var F;if(F=j?h[y]:h,3===F.length){for(var _=0;3>_;++_)I[_]=F[_];I[_]=1}else if(4===F.length)for(var _=0;4>_;++_)I[_]=F[_]}else I[0]=I[1]=I[2]=0,I[3]=1;var D=.5;Array.isArray(u)?D=+u[y]:u?D=+u:this.useOrtho&&(D=12);var B=0;Array.isArray(f)?B=+f[y]:f&&(B=+f);for(var U=Math.cos(B),V=Math.sin(B),x=n[y],_=0;3>_;++_)s[_]=Math.max(s[_],x[_]),o[_]=Math.min(o[_],x[_]);a[0]<0?z[0]=a[0]*(1+M[1][0]):a[0]>0&&(z[0]=-a[0]*(1+M[0][0]));for(var q=k.cells,H=k.positions,_=0;_Y;++Y){for(var X=0;3>X;++X)E[3*P+X]=x[X];for(var X=0;4>X;++X)L[4*P+X]=O[X];C[P]=d;var W=H[G[Y]];S[2*P]=D*(U*W[0]-V*W[1]+z[0]),S[2*P+1]=D*(V*W[0]+U*W[1]+z[1]),P+=1}for(var q=A.edges,H=A.positions,_=0;_Y;++Y){for(var X=0;3>X;++X)E[3*R+X]=x[X];for(var X=0;4>X;++X)L[4*R+X]=I[X];C[R]=d;var W=H[G[Y]];S[2*R]=D*(U*W[0]-V*W[1]+z[0]),S[2*R+1]=D*(V*W[0]+U*W[1]+z[1]),R+=1}d+=1}this.vertexCount=p,this.lineVertexCount=g,this.pointBuffer.update(E),this.colorBuffer.update(L),this.glyphBuffer.update(S),this.idBuffer.update(new Uint32Array(C)),v.free(E),v.free(L),v.free(S),v.free(C),this.bounds=[o,s],this.points=n,this.pointCount=n.length}},_.dispose=function(){this.shader.dispose(),this.orthoShader.dispose(),this.pickPerspectiveShader.dispose(),this.pickOrthoShader.dispose(),this.vao.dispose(),this.pointBuffer.dispose(),this.colorBuffer.dispose(),this.glyphBuffer.dispose(),this.idBuffer.dispose()}},{"./lib/glyphs":191,"./lib/shaders":192,"gl-buffer":118,"gl-mat4/multiply":139,"gl-vao":226,"typedarray-pool":278}],194:[function(t,e,r){"use strict";r.boxVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n",r.boxFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"},{}],195:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.boxBuffer=e,this.boxShader=r,this.enabled=!0,this.selectBox=[1/0,1/0,-(1/0),-(1/0)],this.borderColor=[0,0,0,1],this.innerFill=!1,this.innerColor=[0,0,0,.25],this.outerFill=!0,this.outerColor=[0,0,0,.5],this.borderWidth=10}function i(t,e){var r=t.gl,i=o(r,[0,0,0,1,1,0,1,1]),l=a(r,s.boxVertex,s.boxFragment),c=new n(t,i,l);return c.update(e),t.addOverlay(c),c}var a=t("gl-shader"),o=t("gl-buffer"),s=t("./lib/shaders");e.exports=i;var l=n.prototype;l.draw=function(){if(this.enabled){var t=this.plot,e=this.selectBox,r=this.borderWidth,n=(this.innerFill,this.innerColor),i=(this.outerFill,this.outerColor),a=this.borderColor,o=t.box,s=t.screenBox,l=t.dataBox,c=t.viewBox,u=t.pixelRatio,f=(e[0]-l[0])*(c[2]-c[0])/(l[2]-l[0])+c[0],h=(e[1]-l[1])*(c[3]-c[1])/(l[3]-l[1])+c[1],d=(e[2]-l[0])*(c[2]-c[0])/(l[2]-l[0])+c[0],p=(e[3]-l[1])*(c[3]-c[1])/(l[3]-l[1])+c[1];if(f=Math.max(f,c[0]),h=Math.max(h,c[1]),d=Math.min(d,c[2]),p=Math.min(p,c[3]),!(f>d||h>p)){o.bind();var g=s[2]-s[0],v=s[3]-s[1];if(this.outerFill&&(o.drawBox(0,0,g,h,i),o.drawBox(0,h,f,p,i),o.drawBox(0,p,g,v,i),o.drawBox(d,h,g,p,i)),this.innerFill&&o.drawBox(f,h,d,p,n),r>0){var m=r*u;o.drawBox(f-m,h-m,d+m,h+m,a),o.drawBox(f-m,p-m,d+m,p+m,a),o.drawBox(f-m,h-m,f+m,p+m,a),o.drawBox(d-m,h-m,d+m,p+m,a)}}}},l.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},l.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":194,"gl-buffer":118,"gl-shader":197}],196:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.coord=[t,e],this.id=r,this.value=n,this.distance=i}function i(t,e,r){this.gl=t,this.fbo=e,this.buffer=r,this._readTimeout=null;var n=this;this._readCallback=function(){n.gl&&(e.bind(),t.readPixels(0,0,e.shape[0],e.shape[1],t.RGBA,t.UNSIGNED_BYTE,n.buffer),n._readTimeout=null)}}function a(t,e){var r=o(t,e),n=s.mallocUint8(e[0]*e[1]*4);return new i(t,r,n)}e.exports=a;var o=t("gl-fbo"),s=t("typedarray-pool"),l=t("ndarray"),c=t("bit-twiddle").nextPow2,u=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(255>_inline_34_arg0_||255>_inline_34_arg1_||255>_inline_34_arg2_||255>_inline_34_arg3_){var _inline_34_l=_inline_34_arg4_-_inline_34_arg6_[0],_inline_34_a=_inline_34_arg5_-_inline_34_arg6_[1],_inline_34_f=_inline_34_l*_inline_34_l+_inline_34_a*_inline_34_a;_inline_34_fthis.buffer.length){s.free(this.buffer);for(var n=this.buffer=s.mallocUint8(c(r*e*4)),i=0;r*e*4>i;++i)n[i]=255}return t}}}),f.begin=function(){var t=this.gl;this.shape;t&&(this.fbo.bind(),t.clearColor(1,1,1,1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT))},f.end=function(){var t=this.gl;t&&(t.bindFramebuffer(t.FRAMEBUFFER,null),this._readTimeout||clearTimeout(this._readTimeout),this._readTimeout=setTimeout(this._readCallback,1))},f.query=function(t,e,r){if(!this.gl)return null;var i=this.fbo.shape.slice();t=0|t,e=0|e,"number"!=typeof r&&(r=1);var a=0|Math.min(Math.max(t-r,0),i[0]),o=0|Math.min(Math.max(t+r,0),i[0]),s=0|Math.min(Math.max(e-r,0),i[1]),c=0|Math.min(Math.max(e+r,0),i[1]);if(a>=o||s>=c)return null;var f=[o-a,c-s],h=l(this.buffer,[f[0],f[1],4],[4,4*i[0],1],4*(a+i[0]*s)),d=u(h.hi(f[0],f[1],1),r,r),p=d[0],g=d[1];if(0>p||Math.pow(this.radius,2)=0){for(var A=0|k.type.charAt(k.type.length-1),M=new Array(A),T=0;A>T;++T)M[T]=_.length,x.push(k.name+"["+T+"]"),"number"==typeof k.location?_.push(k.location+T):Array.isArray(k.location)&&k.location.length===A&&"number"==typeof k.location[T]?_.push(0|k.location[T]):_.push(-1);b.push({name:k.name,type:k.type,locations:M})}else b.push({name:k.name,type:k.type,locations:[_.length]}),x.push(k.name),"number"==typeof k.location?_.push(0|k.location):_.push(-1)}for(var E=0,w=0;w<_.length;++w)if(_[w]<0){for(;_.indexOf(E)>=0;)E+=1;_[w]=E}var L=new Array(r.length);a(),d._relink=a,d.types={uniforms:l(r),attributes:l(n)},d.attributes=s(p,d,b,_),Object.defineProperty(d,"uniforms",o(p,d,r,L))},e.exports=a},{"./lib/GLError":198,"./lib/create-attributes":199,"./lib/create-uniforms":200,"./lib/reflect":201,"./lib/runtime-reflect":202,"./lib/shader-cache":203}],198:[function(t,e,r){function n(t,e,r){this.shortMessage=e||"",this.longMessage=r||"",this.rawError=t||"",this.message="gl-shader: "+(e||t||"")+(r?"\n"+r:""),this.stack=(new Error).stack}n.prototype=new Error,n.prototype.name="GLError",n.prototype.constructor=n,e.exports=n},{}],199:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}function i(t,e,r,i,a,o,s){for(var l=["gl","v"],c=[],u=0;a>u;++u)l.push("x"+u),c.push("x"+u);l.push("if(x0.length===void 0){return gl.vertexAttrib"+a+"f(v,"+c.join()+")}else{return gl.vertexAttrib"+a+"fv(v,x0)}");var f=Function.apply(null,l),h=new n(t,e,r,i,a,f);Object.defineProperty(o,s,{set:function(e){return t.disableVertexAttribArray(i[r]),f(t,i[r],e),e},get:function(){return h},enumerable:!0})}function a(t,e,r,n,a,o,s){for(var l=new Array(a),c=new Array(a),u=0;a>u;++u)i(t,e,r[u],n,a,l,u),c[u]=l[u];Object.defineProperty(l,"location",{set:function(t){if(Array.isArray(t))for(var e=0;a>e;++e)c[e].location=t[e];else for(var e=0;a>e;++e)c[e].location=t+e;return t},get:function(){for(var t=new Array(a),e=0;a>e;++e)t[e]=n[r[e]];return t},enumerable:!0}),l.pointer=function(e,i,o,s){e=e||t.FLOAT,i=!!i,o=o||a*a,s=s||0;for(var l=0;a>l;++l){var c=n[r[l]];t.vertexAttribPointer(c,a,e,i,o,s+l*a),t.enableVertexAttribArray(c)}};var f=new Array(a),h=t["vertexAttrib"+a+"fv"];Object.defineProperty(o,s,{set:function(e){for(var i=0;a>i;++i){var o=n[r[i]];if(t.disableVertexAttribArray(o),Array.isArray(e[0]))h.call(t,o,e[i]);else{for(var s=0;a>s;++s)f[s]=e[a*i+s];h.call(t,o,f)}}return e},get:function(){return l},enumerable:!0})}function o(t,e,r,n){for(var o={},l=0,c=r.length;c>l;++l){var u=r[l],f=u.name,h=u.type,d=u.locations;switch(h){case"bool":case"int":case"float":i(t,e,d[0],n,1,o,f);break;default:if(h.indexOf("vec")>=0){var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);i(t,e,d[0],n,p,o,f)}else{if(!(h.indexOf("mat")>=0))throw new s("","Unknown data type for attribute "+f+": "+h);var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);a(t,e,d,n,p,o,f)}}}return o}e.exports=o;var s=t("./GLError"),l=n.prototype;l.pointer=function(t,e,r,n){var i=this,a=i._gl,o=i._locations[i._index];a.vertexAttribPointer(o,i._dimension,t||a.FLOAT,!!e,r||0,n||0),a.enableVertexAttribArray(o)},l.set=function(t,e,r,n){return this._constFunc(this._locations[this._index],t,e,r,n)},Object.defineProperty(l,"location",{get:function(){return this._locations[this._index]},set:function(t){return t!==this._locations[this._index]&&(this._locations[this._index]=0|t,this._wrapper.program=null),0|t}})},{"./GLError":198}],200:[function(t,e,r){"use strict";function n(t){var e=new Function("y","return function(){return y}");return e(t)}function i(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e,r,a){function l(r){var n=new Function("gl","wrapper","locations","return function(){return gl.getUniform(wrapper.program,locations["+r+"])}");return n(t,e,a)}function c(t,e,r){switch(r){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+e+"],obj"+t+")";case"float":return"gl.uniform1f(locations["+e+"],obj"+t+")";default:var n=r.indexOf("vec");if(!(n>=0&&1>=n&&r.length===4+n)){if(0===r.indexOf("mat")&&4===r.length){var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+i+"fv(locations["+e+"],false,obj"+t+")"}throw new s("","Unknown uniform data type for "+name+": "+r)}var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+i+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+i+"fv(locations["+e+"],obj"+t+")";default:throw new s("","Unrecognized data type for vector "+name+": "+r)}}}function u(t,e){if("object"!=typeof e)return[[t,e]];var r=[];for(var n in e){var i=e[n],a=t;a+=parseInt(n)+""===n?"["+n+"]":"."+n,"object"==typeof i?r.push.apply(r,u(a,i)):r.push([a,i])}return r}function f(e){for(var n=["return function updateProperty(obj){"],i=u("",e),o=0;o=0&&1>=e&&t.length===4+e){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid data type");return"b"===t.charAt(0)?i(r,!1):i(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+t);return i(r*r,0)}throw new s("","Unknown uniform data type for "+name+": "+t)}}function d(t,e,i){if("object"==typeof i){var o=p(i);Object.defineProperty(t,e,{get:n(o),set:f(i),enumerable:!0,configurable:!1})}else a[i]?Object.defineProperty(t,e,{get:l(i),set:f(i),enumerable:!0,configurable:!1}):t[e]=h(r[i].type)}function p(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var c=1;ca;++a){var o=t.getActiveUniform(e,a);if(o){var s=n(t,o.type);if(o.size>1)for(var l=0;la;++a){var o=t.getActiveAttrib(e,a);o&&i.push({name:o.name,type:n(t,o.type)})}return i}r.uniforms=i,r.attributes=a;var o={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"},s=null},{}],203:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.id=t,this.src=e,this.type=r,this.shader=n,this.count=a,this.programs=[],this.cache=o}function i(t){this.gl=t,this.shaders=[{},{}],this.programs={}}function a(t,e,r){var n=t.createShader(e);if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){var i=t.getShaderInfoLog(n);try{var a=f(i,r,e)}catch(o){throw console.warn("Failed to format compiler error: "+o),new u(i,"Error compiling shader:\n"+i)}throw new u(i,a.short,a.long)}return n}function o(t,e,r,n,i){var a=t.createProgram();t.attachShader(a,e),t.attachShader(a,r);for(var o=0;on;++n){var a=t.programs[r[n]];a&&(delete t.programs[n],e.deleteProgram(a))}e.deleteShader(this.shader),delete t.shaders[this.type===e.FRAGMENT_SHADER|0][this.src]}};var g=i.prototype;g.getShaderReference=function(t,e){var r=this.gl,i=this.shaders[t===r.FRAGMENT_SHADER|0],o=i[e];if(o&&r.isShader(o.shader))o.count+=1;else{var s=a(r,t,e);o=i[e]=new n(p++,e,t,s,[],1,this)}return o},g.getProgram=function(t,e,r,n){var i=[t.id,e.id,r.join(":"),n.join(":")].join("@"),a=this.programs[i];return a&&this.gl.isProgram(a)||(this.programs[i]=a=o(this.gl,t.shader,e.shader,r,n),t.programs.push(i),e.programs.push(i)),a}},{"./GLError":198,"gl-format-compiler-error":204,"weakmap-shim":214}],204:[function(t,e,r){function n(t,e,r){"use strict";var n=o(e)||"of unknown name (see npm glsl-shader-name)",l="unknown type";void 0!==r&&(l=r===a.FRAGMENT_SHADER?"fragment":"vertex");for(var c=i("Error compiling %s shader %s:\n",l,n),u=i("%s%s",c,t),f=t.split("\n"),h={},d=0;ds;s++)if(g=i(t[s]),"string"===g)v[v.length]=t[s];else if("array"===g){if(c=t[s],c[2])for(n=e[d],l=0;l=0),c[8]){case"b":n=n.toString(2);break;case"c":n=String.fromCharCode(n);break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,c[6]?parseInt(c[6]):0);break;case"e":n=c[7]?n.toExponential(c[7]):n.toExponential();break;case"f":n=c[7]?parseFloat(n).toFixed(c[7]):parseFloat(n);break;case"g":n=c[7]?parseFloat(n).toPrecision(c[7]):parseFloat(n);break;case"o":n=n.toString(8);break;case"s":n=(n=String(n))&&c[7]?n.substring(0,c[7]):n;break;case"u":n>>>=0;break;case"x":n=n.toString(16);break;case"X":n=n.toString(16).toUpperCase()}o.json.test(c[8])?v[v.length]=n:(!o.number.test(c[8])||m&&!c[3]?y="":(y=m?"+":"-",n=n.toString().replace(o.sign,"")),f=c[4]?"0"===c[4]?"0":c[4].charAt(1):" ",h=c[6]-(y+n).length,u=c[6]&&h>0?a(f,h):"",v[v.length]=c[5]?y+n+u:"0"===f?y+u+n:u+y+n)}return v.join("")},r.cache={},r.parse=function(t){for(var e=t,r=[],n=[],i=0;e;){if(null!==(r=o.text.exec(e)))n[n.length]=r[0];else if(null!==(r=o.modulo.exec(e)))n[n.length]="%";else{if(null===(r=o.placeholder.exec(e)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){i|=1;var a=[],s=r[2],l=[];if(null===(l=o.key.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(a[a.length]=l[1];""!==(s=s.substring(l[0].length));)if(null!==(l=o.key_access.exec(s)))a[a.length]=l[1];else{if(null===(l=o.index_access.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");a[a.length]=l[1]}r[2]=a}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=r}e=e.substring(r[0].length)}return n};var s=function(t,e,n){return n=(e||[]).slice(0),n.splice(0,0,t),r.apply(null,n)};"undefined"!=typeof n?(n.sprintf=r,n.vsprintf=s):(e.sprintf=r,e.vsprintf=s,"function"==typeof t&&t.amd&&t(function(){return{sprintf:r,vsprintf:s}}))}("undefined"==typeof window?this:window)},{}],212:[function(t,e,r){function n(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:i(e,t)}}var i=t("./hidden-store.js");e.exports=n},{"./hidden-store.js":213}],213:[function(t,e,r){function n(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}e.exports=n},{}],214:[function(t,e,r){function n(){var t=i();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){t(e).value=r},has:function(e){return"value"in t(e)},"delete":function(e){return delete t(e).value}}}var i=t("./create-store.js");e.exports=n},{"./create-store.js":212}],215:[function(t,e,r){"use strict";function n(t){this.plot=t,this.enable=[!0,!0,!1,!1],this.width=[1,1,1,1],this.color=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.center=[1/0,1/0]}function i(t,e){var r=new n(t);return r.update(e),t.addOverlay(r),r}e.exports=i;var a=n.prototype;a.update=function(t){t=t||{},this.enable=(t.enable||[!0,!0,!1,!1]).slice(),this.width=(t.width||[1,1,1,1]).slice(),this.color=(t.color||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]).map(function(t){return t.slice()}),this.center=(t.center||[1/0,1/0]).slice(),this.plot.setOverlayDirty()},a.draw=function(){var t=this.enable,e=this.width,r=this.color,n=this.center,i=this.plot,a=i.line,o=i.dataBox,s=i.viewBox;if(a.bind(),o[0]<=n[0]&&n[0]<=o[2]&&o[1]<=n[1]&&n[1]<=o[3]){var l=s[0]+(n[0]-o[0])/(o[2]-o[0])*(s[2]-s[0]),c=s[1]+(n[1]-o[1])/(o[3]-o[1])*(s[3]-s[1]);t[0]&&a.drawLine(l,c,s[0],c,e[0],r[0]),t[1]&&a.drawLine(l,c,l,s[1],e[1],r[1]),t[2]&&a.drawLine(l,c,s[2],c,e[2],r[2]),t[3]&&a.drawLine(l,c,l,s[3],e[3],r[3])}},a.dispose=function(){this.plot.removeOverlay(this)}},{}],216:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute vec3 f;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 lightPosition, eyePosition;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n worldCoordinate = vec3(uv.zw, f.x);\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 //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",a="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(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\n\n\nfloat beckmannSpecular_1_1(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness) {\n return beckmannDistribution_2_0(dot(surfaceNormal, normalize(lightDirection + viewDirection)), roughness);\n}\n\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;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n if(kill > 0.0 ||\n any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n discard;\n }\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 = beckmannSpecular_1_1(L, V, N, roughness);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(colormap, vec2(value, value));\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",o="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\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",s="precision mediump float;\n#define GLSLIFY 1\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 any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n 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";r.createShader=function(t){var e=n(t,i,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createPickShader=function(t){var e=n(t,i,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"vec3"},{name:"normal",type:"vec3"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e.attributes.normal.location=2,e},r.createContourShader=function(t){var e=n(t,o,a,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e},r.createPickContourShader=function(t){var e=n(t,o,s,null,[{name:"uv",type:"vec4"},{name:"f",type:"float"}]);return e.attributes.uv.location=0,e.attributes.f.location=1,e}},{"gl-shader":197}],217:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],218:[function(t,e,r){"use strict";function n(t){if(t in l)return l[t];for(var e=[],r=0;t>r;++r)e.push("out",r,"s=0.5*(inp",r,"l-inp",r,"r);");for(var n=["array"],i=["junk"],r=0;t>r;++r){n.push("array"),i.push("out"+r+"s");var a=o(t);a[r]=-1,n.push({array:0,offset:a.slice()}),a[r]=1,n.push({array:0,offset:a.slice()}),i.push("inp"+r+"l","inp"+r+"r")}return l[t]=s({args:n,pre:u,post:u,body:{body:e.join(""),args:i.map(function(t){return{name:t,lvalue:0===t.indexOf("out"),rvalue:0===t.indexOf("inp"),count:"junk"!==t|0}}),thisVars:[],localVars:[]},funcName:"fdTemplate"+t})}function i(t){function e(e){for(var r=a-e.length,n=[],i=[],s=[],l=0;a>l;++l)e.indexOf(l+1)>=0?s.push("0"):e.indexOf(-(l+1))>=0?s.push("s["+l+"]-1"):(s.push("-1"),n.push("1"),i.push("s["+l+"]-2"));var c=".lo("+n.join()+").hi("+i.join()+")";if(0===n.length&&(c=""),r>0){o.push("if(1");for(var l=0;a>l;++l)e.indexOf(l+1)>=0||e.indexOf(-(l+1))>=0||o.push("&&s[",l,"]>2");o.push("){grad",r,"(src.pick(",s.join(),")",c);for(var l=0;a>l;++l)e.indexOf(l+1)>=0||e.indexOf(-(l+1))>=0||o.push(",dst.pick(",s.join(),",",l,")",c);o.push(");")}for(var l=0;l1){dst.set(",s.join(),",",u,",0.5*(src.get(",h.join(),")-src.get(",d.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):o.push("if(s[",u,"]>1){diff(",f,",src.pick(",h.join(),")",c,",src.pick(",d.join(),")",c,");}else{zero(",f,");};");break;case"mirror":0===r?o.push("dst.set(",s.join(),",",u,",0);"):o.push("zero(",f,");");break;case"wrap":var p=s.slice(),g=s.slice();e[l]<0?(p[u]="s["+u+"]-2",g[u]="0"):(p[u]="s["+u+"]-1",g[u]="1"),0===r?o.push("if(s[",u,"]>2){dst.set(",s.join(),",",u,",0.5*(src.get(",p.join(),")-src.get(",g.join(),")))}else{dst.set(",s.join(),",",u,",0)};"):o.push("if(s[",u,"]>2){diff(",f,",src.pick(",p.join(),")",c,",src.pick(",g.join(),")",c,");}else{zero(",f,");};");break;default:throw new Error("ndarray-gradient: Invalid boundary condition")}}r>0&&o.push("};")}var r=t.join(),i=c[r];if(i)return i;for(var a=t.length,o=["function gradient(dst,src){var s=src.shape.slice();"],s=0;1<
s;++s){for(var u=[],d=0;a>d;++d)s&1<=s;++s)v.push("grad"+s),m.push(n(s));v.push(o.join(""));var y=Function.apply(void 0,v),i=y.apply(void 0,m);return l[r]=i,i}function a(t,e,r){if(Array.isArray(r)){if(r.length!==e.dimension)throw new Error("ndarray-gradient: invalid boundary conditions")}else r="string"==typeof r?o(e.dimension,r):o(e.dimension,"clamp");if(t.dimension!==e.dimension+1)throw new Error("ndarray-gradient: output dimension must be +1 input dimension");if(t.shape[e.dimension]!==e.dimension)throw new Error("ndarray-gradient: output shape must match input shape");for(var n=0;nr;++r)for(o=o||e.surfaceProject[r],n=0;3>n;++n)s=s||e.contourProject[r][n];for(r=0;3>r;++r){var l=D.projections[r];for(n=0;16>n;++n)l[n]=0;for(n=0;4>n;++n)l[5*n]=1;l[5*r]=0,l[12+r]=e.axesBounds[+(a[r]>0)][r],k(l,t.model,l);var c=D.clipBounds[r];for(i=0;2>i;++i)for(n=0;3>n;++n)c[i][n]=t.clipBounds[i][n];c[0][r]=-1e8,c[1][r]=1e8}return D.showSurface=o,D.showContour=s,D}function s(t,e){t=t||{};var r=this.gl;r.disable(r.CULL_FACE),this._colorMap.bind(0);var n=B;n.model=t.model||R,n.view=t.view||R,n.projection=t.projection||R,n.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]],n.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]],n.contourColor=this.contourColor[0],n.inverseModel=A(n.inverseModel,n.model);for(var i=0;2>i;++i)for(var a=n.clipBounds[i],s=0;3>s;++s)a[s]=Math.min(Math.max(this.clipBounds[i][s],-1e8),1e8);n.kambient=this.ambientLight,n.kdiffuse=this.diffuseLight,n.kspecular=this.specularLight,n.roughness=this.roughness,n.fresnel=this.fresnel,n.opacity=this.opacity,n.height=0,n.permutation=V;var l=U;for(k(l,n.view,n.model),k(l,n.projection,l),A(l,l),i=0;3>i;++i)n.eyePosition[i]=l[12+i]/l[15];var c=l[15];for(i=0;3>i;++i)c+=this.lightPosition[i]*l[4*i+3];for(i=0;3>i;++i){var u=l[12+i];for(s=0;3>s;++s)u+=l[4*s+i]*this.lightPosition[s];n.lightPosition[i]=u/c}var f=o(n,this);if(f.showSurface&&e===this.opacity<1){for(this._shader.bind(),this._shader.uniforms=n,this._vao.bind(),this.showSurface&&this._vertexCount&&this._vao.draw(r.TRIANGLES,this._vertexCount),i=0;3>i;++i)this.surfaceProject[i]&&this.vertexCount&&(this._shader.uniforms.model=f.projections[i],this._shader.uniforms.clipBounds=f.clipBounds[i],this._vao.draw(r.TRIANGLES,this._vertexCount));this._vao.unbind()}if(f.showContour&&!e){var h=this._contourShader;n.kambient=1,n.kdiffuse=0,n.kspecular=0,n.opacity=1,h.bind(),h.uniforms=n;var d=this._contourVAO;for(d.bind(),i=0;3>i;++i)for(h.uniforms.permutation=I[i],r.lineWidth(this.contourWidth[i]),s=0;si;++i)for(h.uniforms.model=f.projections[i],h.uniforms.clipBounds=f.clipBounds[i],s=0;3>s;++s)if(this.contourProject[i][s]){h.uniforms.permutation=I[s],r.lineWidth(this.contourWidth[s]);for(var p=0;pi;++i)if(0!==this._dynamicCounts[i])for(h.uniforms.model=n.model,h.uniforms.clipBounds=n.clipBounds,h.uniforms.permutation=I[i],r.lineWidth(this.dynamicWidth[i]),h.uniforms.contourColor=this.dynamicColor[i],h.uniforms.contourTint=this.dynamicTint[i],h.uniforms.height=this.dynamicLevel[i],d.draw(r.LINES,this._dynamicCounts[i],this._dynamicOffsets[i]),s=0;3>s;++s)this.contourProject[s][i]&&(h.uniforms.model=f.projections[s],h.uniforms.clipBounds=f.clipBounds[s],d.draw(r.LINES,this._dynamicCounts[i],this._dynamicOffsets[i]));d.unbind()}}function l(t,e){var r=e.shape.slice(),n=t.shape.slice();b.assign(t.lo(1,1).hi(r[0],r[1]),e),b.assign(t.lo(1).hi(r[0],1),e.hi(r[0],1)),b.assign(t.lo(1,n[1]-1).hi(r[0],1),e.lo(0,r[1]-1).hi(r[0],1)),b.assign(t.lo(0,1).hi(1,r[1]),e.hi(1)),b.assign(t.lo(n[0]-1,1).hi(1,r[1]),e.lo(r[0]-1)),t.set(0,0,e.get(0,0)),t.set(0,n[1]-1,e.get(0,r[1]-1)),t.set(n[0]-1,0,e.get(r[0]-1,0)),t.set(n[0]-1,n[1]-1,e.get(r[0]-1,r[1]-1))}function c(t,e){return Array.isArray(t)?[e(t[0]),e(t[1]),e(t[2])]:[e(t),e(t),e(t)]}function u(t){return Array.isArray(t)?3===t.length?[t[0],t[1],t[2],1]:[t[0],t[1],t[2],t[3]]:[0,0,0,1]}function f(t){if(Array.isArray(t)){if(Array.isArray(t))return[u(t[0]),u(t[1]),u(t[2])];var e=u(t);return[e.slice(),e.slice(),e.slice()]}}function h(t){var e=t.gl,r=L(e),n=C(e),i=S(e),o=z(e),s=p(e),l=g(e,[{buffer:s,size:4,stride:P,offset:0},{buffer:s,size:3,stride:P,offset:16},{buffer:s,size:3,stride:P,offset:28}]),c=p(e),u=g(e,[{buffer:c,size:4,stride:20,offset:0},{buffer:c,size:1,stride:20,offset:16}]),f=p(e),h=g(e,[{buffer:f,size:2,type:e.FLOAT}]),d=v(e,1,N,e.RGBA,e.UNSIGNED_BYTE);d.minFilter=e.LINEAR,d.magFilter=e.LINEAR;var m=new a(e,[0,0],[[0,0,0],[0,0,0]],r,n,s,l,d,i,o,c,u,f,h),y={levels:[[],[],[]]};for(var b in t)y[b]=t[b];return y.colormap=y.colormap||"jet",m.update(y),m}e.exports=h;var d=t("bit-twiddle"),p=t("gl-buffer"),g=t("gl-vao"),v=t("gl-texture2d"),m=t("typedarray-pool"),y=t("colormap"),b=t("ndarray-ops"),x=t("ndarray-pack"),_=t("ndarray"),w=t("surface-nets"),k=t("gl-mat4/multiply"),A=t("gl-mat4/invert"),M=t("binary-search-bounds"),T=t("ndarray-gradient"),E=t("./lib/shaders"),L=E.createShader,S=E.createContourShader,C=E.createPickShader,z=E.createPickContourShader,P=40,R=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],O=[[0,0],[0,1],[1,0],[1,1],[1,0],[0,1]],I=[[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 t=0;3>t;++t){var e=I[t],r=(t+1)%3,n=(t+2)%3;e[r+0]=1,e[n+3]=1,e[t+6]=1}}();var N=265,j=a.prototype;j.isTransparent=function(){return this.opacity<1},j.isOpaque=function(){if(this.opacity>=1)return!0;for(var t=0;3>t;++t)if(this._contourCounts[t].length>0||this._dynamicCounts[t]>0)return!0;return!1},j.pickSlots=1,j.setPickBase=function(t){this.pickId=t};var F=[0,0,0],D={showSurface:!1,showContour:!1,projections:[R.slice(),R.slice(),R.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]},B={model:R,view:R,projection:R,inverseModel:R.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1e3,1e3,1e3],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1},U=R.slice(),V=[1,0,0,0,1,0,0,0,1];j.draw=function(t){return s.call(this,t,!1)},j.drawTransparent=function(t){return s.call(this,t,!0)};var q={model:R,view:R,projection:R,inverseModel:R,clipBounds:[[0,0,0],[0,0,0]],height:0,shape:[0,0],pickId:0,lowerBound:[0,0,0],upperBound:[0,0,0],zOffset:0,permutation:[1,0,0,0,1,0,0,0,1],lightPosition:[0,0,0],eyePosition:[0,0,0]};j.drawPick=function(t){t=t||{};var e=this.gl;e.disable(e.CULL_FACE);var r=q;r.model=t.model||R,r.view=t.view||R,r.projection=t.projection||R,r.shape=this._field[2].shape,r.pickId=this.pickId/255,r.lowerBound=this.bounds[0],r.upperBound=this.bounds[1],r.permutation=V;for(var n=0;2>n;++n)for(var i=r.clipBounds[n],a=0;3>a;++a)i[a]=Math.min(Math.max(this.clipBounds[n][a],-1e8),1e8);var s=o(r,this);if(s.showSurface){for(this._pickShader.bind(),this._pickShader.uniforms=r,this._vao.bind(),this._vao.draw(e.TRIANGLES,this._vertexCount),n=0;3>n;++n)this.surfaceProject[n]&&(this._pickShader.uniforms.model=s.projections[n],this._pickShader.uniforms.clipBounds=s.clipBounds[n],this._vao.draw(e.TRIANGLES,this._vertexCount));this._vao.unbind()}if(s.showContour){var l=this._contourPickShader;l.bind(),l.uniforms=r;var c=this._contourVAO;for(c.bind(),a=0;3>a;++a)for(e.lineWidth(this.contourWidth[a]),l.uniforms.permutation=I[a],n=0;nn;++n)for(l.uniforms.model=s.projections[n],l.uniforms.clipBounds=s.clipBounds[n],a=0;3>a;++a)if(this.contourProject[n][a]){l.uniforms.permutation=I[a],e.lineWidth(this.contourWidth[a]);for(var u=0;u>4)/16)/255,i=Math.floor(n),a=n-i,o=e[1]*(t.value[1]+(15&t.value[2])/16)/255,s=Math.floor(o),l=o-s;i+=1,s+=1;var c=r.position;c[0]=c[1]=c[2]=0;for(var u=0;2>u;++u)for(var f=u?a:1-a,h=0;2>h;++h)for(var d=h?l:1-l,p=i+u,g=s+h,v=f*d,m=0;3>m;++m)c[m]+=this._field[m].get(p,g)*v;for(var y=this._pickResult.level,b=0;3>b;++b)if(y[b]=M.le(this.contourLevels[b],c[b]),y[b]<0)this.contourLevels[b].length>0&&(y[b]=0);else if(y[b]Math.abs(_-c[b])&&(y[b]+=1)}for(r.index[0]=.5>a?i:i+1,r.index[1]=.5>l?s:s+1,r.uv[0]=n/e[0],r.uv[1]=o/e[1],m=0;3>m;++m)r.dataCoordinate[m]=this._field[m].get(r.index[0],r.index[1]);return r},j.update=function(t){t=t||{},this.dirty=!0,"contourWidth"in t&&(this.contourWidth=c(t.contourWidth,Number)),"showContour"in t&&(this.showContour=c(t.showContour,Boolean)),"showSurface"in t&&(this.showSurface=!!t.showSurface),"contourTint"in t&&(this.contourTint=c(t.contourTint,Boolean)),"contourColor"in t&&(this.contourColor=f(t.contourColor)),"contourProject"in t&&(this.contourProject=c(t.contourProject,function(t){return c(t,Boolean)})),"surfaceProject"in t&&(this.surfaceProject=t.surfaceProject),"dynamicColor"in t&&(this.dynamicColor=f(t.dynamicColor)),"dynamicTint"in t&&(this.dynamicTint=c(t.dynamicTint,Number)),"dynamicWidth"in t&&(this.dynamicWidth=c(t.dynamicWidth,Number)),"opacity"in t&&(this.opacity=t.opacity),"colorBounds"in t&&(this.colorBounds=t.colorBounds);var e=t.field||t.coords&&t.coords[2]||null,r=!1;if(e||(e=this._field[2].shape[0]||this._field[2].shape[2]?this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2):this._field[2].hi(0,0)),"field"in t||"coords"in t){var n=(e.shape[0]+2)*(e.shape[1]+2);n>this._field[2].data.length&&(m.freeFloat(this._field[2].data),this._field[2].data=m.mallocFloat(d.nextPow2(n))),this._field[2]=_(this._field[2].data,[e.shape[0]+2,e.shape[1]+2]),l(this._field[2],e),this.shape=e.shape.slice();for(var a=this.shape,o=0;2>o;++o)this._field[2].size>this._field[o].data.length&&(m.freeFloat(this._field[o].data),this._field[o].data=m.mallocFloat(this._field[2].size)),this._field[o]=_(this._field[o].data,[a[0]+2,a[1]+2]);if(t.coords){var s=t.coords;if(!Array.isArray(s)||3!==s.length)throw new Error("gl-surface: invalid coordinates for x/y");for(o=0;2>o;++o){var u=s[o];for(y=0;2>y;++y)if(u.shape[y]!==a[y])throw new Error("gl-surface: coords have incorrect shape");l(this._field[o],u)}}else if(t.ticks){var h=t.ticks;if(!Array.isArray(h)||2!==h.length)throw new Error("gl-surface: invalid ticks");for(o=0;2>o;++o){var p=h[o];if((Array.isArray(p)||p.length)&&(p=_(p)),p.shape[0]!==a[o])throw new Error("gl-surface: invalid tick length");var g=_(p.data,a);g.stride[o]=p.stride[0],g.stride[1^o]=0,l(this._field[o],g)}}else{for(o=0;2>o;++o){var v=[0,0];v[o]=1,this._field[o]=_(this._field[o].data,[a[0]+2,a[1]+2],v,0)}this._field[0].set(0,0,0);for(var y=0;yo;++o)T(x.pick(o),b[o],"mirror");var k=_(m.mallocFloat(3*b[2].size),[a[0]+2,a[1]+2,3]);for(o=0;oI?(I=Math.max(Math.abs(z),Math.abs(P),Math.abs(R)),1e-8>I?(R=1,P=z=0,I=1):I=1/I):I=1/Math.sqrt(I),k.set(o,y,0,z*I),k.set(o,y,1,P*I),k.set(o,y,2,R*I)}m.free(x.data);var N=[1/0,1/0,1/0],j=[-(1/0),-(1/0),-(1/0)],F=1/0,D=-(1/0),B=(a[0]-1)*(a[1]-1)*6,U=m.mallocFloat(d.nextPow2(10*B)),V=0,q=0;for(o=0;oH;++H)for(var G=0;2>G;++G)for(var Y=0;3>Y;++Y){var X=this._field[Y].get(1+o+H,1+y+G);if(isNaN(X)||!isFinite(X))continue t}for(Y=0;6>Y;++Y){var W=o+O[Y][0],Z=y+O[Y][1],K=this._field[0].get(W+1,Z+1),$=this._field[1].get(W+1,Z+1);X=this._field[2].get(W+1,Z+1);var Q=X;z=k.get(W+1,Z+1,0),P=k.get(W+1,Z+1,1),R=k.get(W+1,Z+1,2),t.intensity&&(Q=t.intensity.get(W,Z)),U[V++]=W,U[V++]=Z,U[V++]=K,U[V++]=$,U[V++]=X,U[V++]=0,U[V++]=Q,U[V++]=z,U[V++]=P,U[V++]=R,N[0]=Math.min(N[0],K),N[1]=Math.min(N[1],$),N[2]=Math.min(N[2],X),F=Math.min(F,Q),j[0]=Math.max(j[0],K),j[1]=Math.max(j[1],$),j[2]=Math.max(j[2],X),D=Math.max(D,Q),q+=1}}for(t.intensityBounds&&(F=+t.intensityBounds[0],D=+t.intensityBounds[1]),o=6;V>o;o+=10)U[o]=(U[o]-F)/(D-F);this._vertexCount=q,this._coordinateBuffer.update(U.subarray(0,V)),m.freeFloat(U),m.free(k.data),this.bounds=[N,j],this.intensity=t.intensity||this._field[2],this.intensityBounds[0]===F&&this.intensityBounds[1]===D||(r=!0),this.intensityBounds=[F,D]}if("levels"in t){var J=t.levels;for(J=Array.isArray(J[0])?J.slice():[[],[],J],o=0;3>o;++o)J[o]=J[o].slice(),J.sort(function(t,e){return t-e});t:for(o=0;3>o;++o){if(J[o].length!==this.contourLevels[o].length){r=!0;break}for(y=0;yet;++et){J=this.contourLevels[et];var rt=[],nt=[],it=[0,0,0];for(o=0;oY;++Y){var st=at.positions[ot[Y]],lt=st[0],ct=0|Math.floor(lt),ut=lt-ct,ft=st[1],ht=0|Math.floor(ft),dt=ft-ht,pt=!1; +e:for(var gt=0;3>gt;++gt){it[gt]=0;var vt=(et+gt+1)%3;for(H=0;2>H;++H){var mt=H?ut:1-ut;for(W=0|Math.min(Math.max(ct+H,0),a[0]),G=0;2>G;++G){var yt=G?dt:1-dt;if(Z=0|Math.min(Math.max(ht+G,0),a[1]),X=2>gt?this._field[vt].get(W,Z):(this.intensity.get(W,Z)-this.intensityBounds[0])/(this.intensityBounds[1]-this.intensityBounds[0]),!isFinite(X)||isNaN(X)){pt=!0;break e}var bt=mt*yt;it[gt]+=bt*X}}}if(pt){if(Y>0){for(var xt=0;5>xt;++xt)tt.pop();q-=1}continue t}tt.push(it[0],it[1],st[0],st[1],it[2]),q+=1}}nt.push(q)}this._contourOffsets[et]=rt,this._contourCounts[et]=nt}var _t=m.mallocFloat(tt.length);for(o=0;ot;++t)m.freeFloat(this._field[t].data)},j.highlight=function(t){if(!t)return this._dynamicCounts=[0,0,0],this.dyanamicLevel=[NaN,NaN,NaN],void(this.highlightLevel=[-1,-1,-1]);for(var e=0;3>e;++e)this.enableHighlight[e]?this.highlightLevel[e]=t.level[e]:this.highlightLevel[e]=-1;var r;if(r=this.snapToData?t.dataCoordinate:t.position,this.enableDynamic[0]&&r[0]!==this.dynamicLevel[0]||this.enableDynamic[1]&&r[1]!==this.dynamicLevel[1]||this.enableDynamic[2]&&r[2]!==this.dynamicLevel[2]){for(var n=0,i=this.shape,a=m.mallocFloat(12*i[0]*i[1]),o=0;3>o;++o)if(this.enableDynamic[o]){this.dynamicLevel[o]=r[o];var s=(o+1)%3,l=(o+2)%3,c=this._field[o],u=this._field[s],f=this._field[l],h=(this.intensity,w(c,r[o])),d=h.cells,p=h.positions;for(this._dynamicOffsets[o]=n,e=0;ev;++v){var y=p[g[v]],b=+y[0],x=0|b,_=0|Math.min(x+1,i[0]),k=b-x,A=1-k,M=+y[1],T=0|M,E=0|Math.min(T+1,i[1]),L=M-T,S=1-L,C=A*S,z=A*L,P=k*S,R=k*L,O=C*u.get(x,T)+z*u.get(x,E)+P*u.get(_,T)+R*u.get(_,E),I=C*f.get(x,T)+z*f.get(x,E)+P*f.get(_,T)+R*f.get(_,E);if(isNaN(O)||isNaN(I)){v&&(n-=1);break}a[2*n+0]=O,a[2*n+1]=I,n+=1}this._dynamicCounts[o]=n-this._dynamicOffsets[o]}else this.dynamicLevel[o]=NaN,this._dynamicCounts[o]=0;this._dynamicBuffer.update(a.subarray(0,2*n)),m.freeFloat(a)}}},{"./lib/shaders":216,"binary-search-bounds":217,"bit-twiddle":50,colormap:100,"gl-buffer":118,"gl-mat4/invert":137,"gl-mat4/multiply":139,"gl-texture2d":222,"gl-vao":226,ndarray:253,"ndarray-gradient":218,"ndarray-ops":252,"ndarray-pack":219,"surface-nets":272,"typedarray-pool":278}],222:[function(t,e,r){"use strict";function n(t){v=[t.LINEAR,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_NEAREST],m=[t.NEAREST,t.LINEAR,t.NEAREST_MIPMAP_NEAREST,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_LINEAR],y=[t.REPEAT,t.CLAMP_TO_EDGE,t.MIRRORED_REPEAT]}function i(t,e,r){var n=t.gl,i=n.getParameter(n.MAX_TEXTURE_SIZE);if(0>e||e>i||0>r||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function a(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}function o(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function s(t,e,r,n,i,a,s,l){var c=l.dtype,u=l.shape.slice();if(u.length<2||u.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var f=0,h=0,v=o(u,l.stride.slice());"float32"===c?f=t.FLOAT:"float64"===c?(f=t.FLOAT,v=!1,c="float32"):"uint8"===c?f=t.UNSIGNED_BYTE:(f=t.UNSIGNED_BYTE,v=!1,c="uint8");var m=1;if(2===u.length)h=t.LUMINANCE,u=[u[0],u[1],1],l=d(l.data,u,[l.stride[0],l.stride[1],1],l.offset);else{if(3!==u.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===u[2])h=t.ALPHA;else if(2===u[2])h=t.LUMINANCE_ALPHA;else if(3===u[2])h=t.RGB;else{if(4!==u[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");h=t.RGBA}m=u[2]}if(h!==t.LUMINANCE&&h!==t.ALPHA||i!==t.LUMINANCE&&i!==t.ALPHA||(h=i),h!==i)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=l.size,x=s.indexOf(n)<0;if(x&&s.push(n),f===a&&v)0===l.offset&&l.data.length===y?x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,l.data):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,l.data):x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,l.data.subarray(l.offset,l.offset+y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,l.data.subarray(l.offset,l.offset+y));else{var _;_=a===t.FLOAT?g.mallocFloat32(y):g.mallocUint8(y);var w=d(_,u,[u[2],u[2]*u[0],1]);f===t.FLOAT&&a===t.UNSIGNED_BYTE?b(w,l):p.assign(w,l),x?t.texImage2D(t.TEXTURE_2D,n,i,u[0],u[1],0,i,a,_.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,u[0],u[1],i,a,_.subarray(0,y)),a===t.FLOAT?g.freeFloat32(_):g.freeUint8(_)}}function l(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function c(t,e,r,n,i){var o=t.getParameter(t.MAX_TEXTURE_SIZE);if(0>e||e>o||0>r||r>o)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var s=l(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new a(t,s,e,r,n,i)}function u(t,e,r,n){var i=l(t);return t.texImage2D(t.TEXTURE_2D,0,r,r,n,e),new a(t,i,0|e.width,0|e.height,r,n)}function f(t,e){var r=e.dtype,n=e.shape.slice(),i=t.getParameter(t.MAX_TEXTURE_SIZE);if(n[0]<0||n[0]>i||n[1]<0||n[1]>i)throw new Error("gl-texture2d: Invalid texture size");var s=o(n,e.stride.slice()),c=0;"float32"===r?c=t.FLOAT:"float64"===r?(c=t.FLOAT,s=!1,r="float32"):"uint8"===r?c=t.UNSIGNED_BYTE:(c=t.UNSIGNED_BYTE,s=!1,r="uint8");var u=0;if(2===n.length)u=t.LUMINANCE,n=[n[0],n[1],1],e=d(e.data,n,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==n.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===n[2])u=t.ALPHA;else if(2===n[2])u=t.LUMINANCE_ALPHA;else if(3===n[2])u=t.RGB;else{if(4!==n[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");u=t.RGBA}}c!==t.FLOAT||t.getExtension("OES_texture_float")||(c=t.UNSIGNED_BYTE,s=!1);var f,h,v=e.size;if(s)f=0===e.offset&&e.data.length===v?e.data:e.data.subarray(e.offset,e.offset+v);else{var m=[n[2],n[2]*n[0],1];h=g.malloc(v,r);var y=d(h,n,m,0);"float32"!==r&&"float64"!==r||c!==t.UNSIGNED_BYTE?p.assign(y,e):b(y,e),f=h.subarray(0,v)}var x=l(t);return t.texImage2D(t.TEXTURE_2D,0,u,n[0],n[1],0,u,c,f),s||g.free(h),new a(t,x,n[0],n[1],u,c)}function h(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");if(v||n(t),"number"==typeof arguments[1])return c(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return c(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1];if(e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof HTMLVideoElement||e instanceof ImageData)return u(t,e,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return f(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")}var d=t("ndarray"),p=t("ndarray-ops"),g=t("typedarray-pool");e.exports=h;var v=null,m=null,y=null,b=function(t,e){p.muls(t,e,255)},x=a.prototype;Object.defineProperties(x,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;2>e;++e)if(y.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return i(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return t=0|t,i(this,t,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t=0|t,i(this,this._shape[0],t),t}}}),x.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},x.dispose=function(){this.gl.deleteTexture(this.handle)},x.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},x.setPixels=function(t,e,r,n){var i=this.gl;if(this.bind(),Array.isArray(e)?(n=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),n=n||0,t instanceof HTMLCanvasElement||t instanceof ImageData||t instanceof HTMLImageElement||t instanceof HTMLVideoElement){var a=this._mipLevels.indexOf(n)<0;a?(i.texImage2D(i.TEXTURE_2D,0,this.format,this.format,this.type,t),this._mipLevels.push(n)):i.texSubImage2D(i.TEXTURE_2D,n,e,r,this.format,this.type,t)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>n||r+t.shape[0]>this._shape[0]>>>n||0>e||0>r)throw new Error("gl-texture2d: Texture dimensions are out of bounds");s(i,e,r,n,this.format,this.type,this._mipLevels,t)}}},{ndarray:253,"ndarray-ops":252,"typedarray-pool":278}],223:[function(t,e,r){"use strict";function n(t,e,r){e?e.bind():t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null);var n=0|t.getParameter(t.MAX_VERTEX_ATTRIBS);if(r){if(r.length>n)throw new Error("gl-vao: Too many vertex attributes");for(var i=0;ii;++i)t.disableVertexAttribArray(i)}else{t.bindBuffer(t.ARRAY_BUFFER,null);for(var i=0;n>i;++i)t.disableVertexAttribArray(i)}}e.exports=n},{}],224:[function(t,e,r){"use strict";function n(t){this.gl=t,this._elements=null,this._attributes=null,this._elementsType=t.UNSIGNED_SHORT}function i(t){return new n(t)}var a=t("./do-bind.js");n.prototype.bind=function(){a(this.gl,this._elements,this._attributes)},n.prototype.update=function(t,e,r){this._elements=e,this._attributes=t,this._elementsType=r||this.gl.UNSIGNED_SHORT},n.prototype.dispose=function(){},n.prototype.unbind=function(){},n.prototype.draw=function(t,e,r){r=r||0;var n=this.gl;this._elements?n.drawElements(t,e,this._elementsType,r):n.drawArrays(t,r,e)},e.exports=i},{"./do-bind.js":223}],225:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.location=t,this.dimension=e,this.a=r,this.b=n,this.c=i,this.d=a}function i(t,e,r){this.gl=t,this._ext=e,this.handle=r,this._attribs=[],this._useElements=!1,this._elementsType=t.UNSIGNED_SHORT}function a(t,e){return new i(t,e,e.createVertexArrayOES())}var o=t("./do-bind.js");n.prototype.bind=function(t){switch(this.dimension){case 1:t.vertexAttrib1f(this.location,this.a);break;case 2:t.vertexAttrib2f(this.location,this.a,this.b);break;case 3:t.vertexAttrib3f(this.location,this.a,this.b,this.c);break;case 4:t.vertexAttrib4f(this.location,this.a,this.b,this.c,this.d)}},i.prototype.bind=function(){this._ext.bindVertexArrayOES(this.handle);for(var t=0;tF;){switch(e=F,B){case f:F=L();break;case h:F=E();break;case d:F=T();break;case p:F=S();break;case g:F=P();break;case w:F=z();break;case v:F=R();break;case u:F=O();break;case x:F=M();break;case c:F=A()}if(e!==F)switch(W[e]){case"\n":H=0,++q;break;default:++H}}return D+=F,W=W.slice(F),V}function n(t){return U.length&&e(U.join("")),B=_,e("(eof)"),V}function A(){return U=U.length?[]:U,"/"===N&&"*"===I?(G=D+F-1,B=f,N=I,F+1):"/"===N&&"/"===I?(G=D+F-1,B=h,N=I,F+1):"#"===I?(B=d,G=D+F,F):/\s/.test(I)?(B=x,G=D+F,F):(Y=/\d/.test(I),X=/[^\w_]/.test(I),G=D+F,B=Y?g:X?p:u,F)}function M(){return/[^\s]/g.test(I)?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function T(){return"\n"===I&&"\\"!==N?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function E(){return T()}function L(){return"/"===I&&"*"===N?(U.push(I),e(U.join("")),B=c,F+1):(U.push(I),N=I,F+1)}function S(){if("."===N&&/\d/.test(I))return B=v,F;if("/"===N&&"*"===I)return B=f,F;if("/"===N&&"/"===I)return B=h,F;if("."===I&&U.length){for(;C(U););return B=v,F}if(";"===I||")"===I||"("===I){if(U.length)for(;C(U););return e(I),B=c,F+1}var t=2===U.length&&"="!==I;if(/[\w_\d\s]/.test(I)||t){for(;C(U););return B=c,F}return U.push(I),N=I,F+1}function C(t){for(var r,n,i=0;;){if(r=a.indexOf(t.slice(0,t.length+i).join("")),n=a[r],-1===r){if(i--+t.length>0)continue;n=t.slice(0,1).join("")}return e(n),G+=n.length,U=U.slice(n.length),U.length}}function z(){return/[^a-fA-F0-9]/.test(I)?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function P(){return"."===I?(U.push(I),B=v,N=I,F+1):/[eE]/.test(I)?(U.push(I),B=v,N=I,F+1):"x"===I&&1===U.length&&"0"===U[0]?(B=w,U.push(I),N=I,F+1):/[^\d]/.test(I)?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function R(){return"f"===I&&(U.push(I),N=I,F+=1),/[eE]/.test(I)?(U.push(I),N=I,F+1):"-"===I&&/[eE]/.test(N)?(U.push(I),N=I,F+1):/[^\d]/.test(I)?(e(U.join("")),B=c,F):(U.push(I),N=I,F+1)}function O(){if(/[^\d\w_]/.test(I)){var t=U.join("");return B=K.indexOf(t)>-1?b:Z.indexOf(t)>-1?y:m,e(U.join("")),B=c,F}return U.push(I),N=I,F+1}var I,N,j,F=0,D=0,B=c,U=[],V=[],q=1,H=0,G=0,Y=!1,X=!1,W="";t=t||{};var Z=o,K=i;return"300 es"===t.version&&(Z=l,K=s),function(t){return V=[],null!==t?r(t):n()}}e.exports=n;var i=t("./lib/literals"),a=t("./lib/operators"),o=t("./lib/builtins"),s=t("./lib/literals-300es"),l=t("./lib/builtins-300es"),c=999,u=9999,f=0,h=1,d=2,p=3,g=4,v=5,m=6,y=7,b=8,x=9,_=10,w=11,k=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":230,"./lib/builtins-300es":229,"./lib/literals":232,"./lib/literals-300es":231,"./lib/operators":233}],229:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["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","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"])},{"./builtins":230}],230:[function(t,e,r){e.exports=["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"]},{}],231:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","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"])},{"./literals":232}],232:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","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","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"]},{}],233:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],234:[function(t,e,r){function n(t,e){var r=i(e),n=[];return n=n.concat(r(t)),n=n.concat(r(null))}var i=t("./index");e.exports=n},{"./index":228}],235:[function(t,e,r){"use strict";function n(t,e,r){this.vertices=t,this.adjacent=e,this.boundary=r,this.lastVisited=-1}function i(t,e,r){this.vertices=t,this.cell=e,this.index=r}function a(t,e){return u(t.vertices,e.vertices)}function o(t){for(var e=["function orient(){var tuple=this.tuple;return test("],r=0;t>=r;++r)r>0&&e.push(","),e.push("tuple[",r,"]");e.push(")}return orient");var n=new Function("test",e.join("")),i=c[t+1];return i||(i=c),n(i)}function s(t,e,r){this.dimension=t,this.vertices=e,this.simplices=r,this.interior=r.filter(function(t){return!t.boundary}),this.tuple=new Array(t+1);for(var n=0;t>=n;++n)this.tuple[n]=this.vertices[n];var i=f[t];i||(i=f[t]=o(t)),this.orient=i}function l(t,e){var r=t.length;if(0===r)throw new Error("Must have at least d+1 points");var i=t[0].length;if(i>=r)throw new Error("Must input at least d+1 points");var a=t.slice(0,i+1),o=c.apply(void 0,a);if(0===o)throw new Error("Input not in general position");for(var l=new Array(i+1),u=0;i>=u;++u)l[u]=u;0>o&&(l[0]=1,l[1]=0);for(var f=new n(l,new Array(i+1),!1),h=f.adjacent,d=new Array(i+2),u=0;i>=u;++u){for(var p=l.slice(),g=0;i>=g;++g)g===u&&(p[g]=-1);var v=p[0];p[0]=p[1],p[1]=v;var m=new n(p,new Array(i+1),!0);h[u]=m,d[u]=m}d[i+1]=f;for(var u=0;i>=u;++u)for(var p=h[u].vertices,y=h[u].adjacent,g=0;i>=g;++g){var b=p[g];if(0>b)y[g]=f;else for(var x=0;i>=x;++x)h[x].vertices.indexOf(b)<0&&(y[g]=h[x])}for(var _=new s(i,a,d),w=!!e,u=i+1;r>u;++u)_.insert(t[u],w);return _.boundary()}e.exports=l;var c=t("robust-orientation"),u=t("simplicial-complex").compareCells;n.prototype.flip=function(){var t=this.vertices[0];this.vertices[0]=this.vertices[1],this.vertices[1]=t;var e=this.adjacent[0];this.adjacent[0]=this.adjacent[1],this.adjacent[1]=e};var f=[],h=s.prototype;h.handleBoundaryDegeneracy=function(t,e){var r=this.dimension,n=this.vertices.length-1,i=this.tuple,a=this.vertices,o=[t];for(t.lastVisited=-n;o.length>0;){t=o.pop();for(var s=(t.vertices,t.adjacent),l=0;r>=l;++l){var c=s[l];if(c.boundary&&!(c.lastVisited<=-n)){for(var u=c.vertices,f=0;r>=f;++f){var h=u[f];0>h?i[f]=e:i[f]=a[h]}var d=this.orient();if(d>0)return c;c.lastVisited=-n,0===d&&o.push(c)}}}return null},h.walk=function(t,e){var r=this.vertices.length-1,n=this.dimension,i=this.vertices,a=this.tuple,o=e?this.interior.length*Math.random()|0:this.interior.length-1,s=this.interior[o];t:for(;!s.boundary;){for(var l=s.vertices,c=s.adjacent,u=0;n>=u;++u)a[u]=i[l[u]];s.lastVisited=r;for(var u=0;n>=u;++u){var f=c[u];if(!(f.lastVisited>=r)){var h=a[u];a[u]=t;var d=this.orient();if(a[u]=h,0>d){s=f;continue t}f.boundary?f.lastVisited=-r:f.lastVisited=r}}return}return s},h.addPeaks=function(t,e){var r=this.vertices.length-1,o=this.dimension,s=this.vertices,l=this.tuple,c=this.interior,u=this.simplices,f=[e];e.lastVisited=r,e.vertices[e.vertices.indexOf(-1)]=r,e.boundary=!1,c.push(e);for(var h=[];f.length>0;){var e=f.pop(),d=e.vertices,p=e.adjacent,g=d.indexOf(r);if(!(0>g))for(var v=0;o>=v;++v)if(v!==g){var m=p[v];if(m.boundary&&!(m.lastVisited>=r)){var y=m.vertices;if(m.lastVisited!==-r){for(var b=0,x=0;o>=x;++x)y[x]<0?(b=x,l[x]=t):l[x]=s[y[x]];var _=this.orient();if(_>0){y[b]=r,m.boundary=!1,c.push(m),f.push(m),m.lastVisited=r;continue}m.lastVisited=-r}var w=m.adjacent,k=d.slice(),A=p.slice(),M=new n(k,A,!0);u.push(M);var T=w.indexOf(e);if(!(0>T)){w[T]=M,A[g]=m,k[v]=-1,A[v]=e,p[v]=M,M.flip();for(var x=0;o>=x;++x){var E=k[x];if(!(0>E||E===r)){for(var L=new Array(o-1),S=0,C=0;o>=C;++C){var z=k[C];0>z||C===x||(L[S++]=z)}h.push(new i(L,M,x))}}}}}}h.sort(a);for(var v=0;v+1O||0>I||(P.cell.adjacent[P.index]=R.cell,R.cell.adjacent[R.index]=P.cell)}},h.insert=function(t,e){var r=this.vertices;r.push(t);var n=this.walk(t,e);if(n){for(var i=this.dimension,a=this.tuple,o=0;i>=o;++o){var s=n.vertices[o];0>s?a[o]=t:a[o]=r[s]}var l=this.orient(a);0>l||(0!==l||(n=this.handleBoundaryDegeneracy(n,t)))&&this.addPeaks(t,n)}},h.boundary=function(){for(var t=this.dimension,e=[],r=this.simplices,n=r.length,i=0;n>i;++i){var a=r[i];if(a.boundary){for(var o=new Array(t),s=a.vertices,l=0,c=0,u=0;t>=u;++u)s[u]>=0?o[l++]=s[u]:c=1&u;if(c===(1&t)){var f=o[0];o[0]=o[1],o[1]=f}e.push(o)}}return e}},{"robust-orientation":259,"simplicial-complex":238}],236:[function(t,e,r){arguments[4][50][0].apply(r,arguments)},{dup:50}],237:[function(t,e,r){arguments[4][97][0].apply(r,arguments)},{dup:97}],238:[function(t,e,r){"use strict";"use restrict";function n(t){for(var e=0,r=Math.max,n=0,i=t.length;i>n;++n)e=r(e,t[n].length);return e-1}function i(t){for(var e=-1,r=Math.max,n=0,i=t.length;i>n;++n)for(var a=t[n],o=0,s=a.length;s>o;++o)e=r(e,a[o]);return e+1}function a(t){for(var e=new Array(t.length),r=0,n=t.length;n>r;++r)e[r]=t[r].slice(0);return e}function o(t,e){var r=t.length,n=t.length-e.length,i=Math.min;if(n)return n;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:var a=t[0]+t[1]-e[0]-e[1];return a?a:i(t[0],t[1])-i(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(a=o+t[2]-(s+e[2]))return a;var l=i(t[0],t[1]),c=i(e[0],e[1]),a=i(l,t[2])-i(c,e[2]);return a?a:i(l+t[2],o)-i(c+e[2],s);default:var u=t.slice(0);u.sort();var f=e.slice(0);f.sort();for(var h=0;r>h;++h)if(n=u[h]-f[h])return n;return 0}}function s(t,e){return o(t[0],e[0])}function l(t,e){if(e){for(var r=t.length,n=new Array(r),i=0;r>i;++i)n[i]=[t[i],e[i]];n.sort(s);for(var i=0;r>i;++i)t[i]=n[i][0],e[i]=n[i][1];return t}return t.sort(o),t}function c(t){if(0===t.length)return[];for(var e=1,r=t.length,n=1;r>n;++n){var i=t[n];if(o(i,t[n-1])){if(n===e){e++;continue}t[e++]=i}}return t.length=e,t}function u(t,e){for(var r=0,n=t.length-1,i=-1;n>=r;){var a=r+n>>1,s=o(t[a],e);0>=s?(0===s&&(i=a),r=a+1):s>0&&(n=a-1)}return i}function f(t,e){for(var r=new Array(t.length),n=0,i=r.length;i>n;++n)r[n]=[];for(var a=[],n=0,s=e.length;s>n;++n)for(var l=e[n],c=l.length,f=1,h=1<f;++f){a.length=b.popCount(f);for(var d=0,p=0;c>p;++p)f&1<g))for(;;)if(r[g++].push(n),g>=t.length||0!==o(t[g],a))break}return r}function h(t,e){if(!e)return f(c(p(t,0)),t,0);for(var r=new Array(e),n=0;e>n;++n)r[n]=[];for(var n=0,i=t.length;i>n;++n)for(var a=t[n],o=0,s=a.length;s>o;++o)r[a[o]].push(n);return r}function d(t){for(var e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0|i.length,o=1,s=1<o;++o){for(var c=[],u=0;a>u;++u)o>>>u&1&&c.push(i[u]);e.push(c)}return l(e)}function p(t,e){if(0>e)return[];for(var r=[],n=(1<r;++r)for(var i=t[r],a=0,o=i.length;o>a;++a){for(var s=new Array(i.length-1),c=0,u=0;o>c;++c)c!==a&&(s[u++]=i[c]);e.push(s)}return l(e)}function v(t,e){for(var r=new x(e),n=0;nr;++r)e[r]=r;return e}e.exports=n},{}],240:[function(t,e,r){e.exports=function(t){return!(null==t||!(t._isBuffer||t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)))}},{}],241:[function(t,e,r){"use strict";function n(t,e){function r(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==g.alt,g.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==g.shift,g.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==g.control,g.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==g.meta,g.meta=!!t.metaKey),e}function n(t,n){var a=i.x(n),o=i.y(n);"buttons"in n&&(t=0|n.buttons),(t!==h||a!==d||o!==p||r(n))&&(h=0|t,d=a||0,p=o||0,e(h,d,p,g))}function a(t){n(0,t)}function o(){(h||d||p||g.shift||g.alt||g.meta||g.control)&&(d=p=0,h=0,g.shift=g.alt=g.control=g.meta=!1,e(0,0,0,g))}function s(t){r(t)&&e(h,d,p,g)}function l(t){0===i.buttons(t)?n(0,t):n(h,t)}function c(t){n(h|i.buttons(t),t)}function u(t){n(h&~i.buttons(t),t)}function f(){v||(v=!0,t.addEventListener("mousemove",l),t.addEventListener("mousedown",c),t.addEventListener("mouseup",u),t.addEventListener("mouseleave",a),t.addEventListener("mouseenter",a),t.addEventListener("mouseout",a),t.addEventListener("mouseover",a),t.addEventListener("blur",o),t.addEventListener("keyup",s),t.addEventListener("keydown",s),t.addEventListener("keypress",s),t!==window&&(window.addEventListener("blur",o),window.addEventListener("keyup",s),window.addEventListener("keydown",s),window.addEventListener("keypress",s)))}e||(e=t,t=window);var h=0,d=0,p=0,g={shift:!1,alt:!1,control:!1,meta:!1},v=!1;f();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return v},set:function(t){t&&f()},enumerable:!0},buttons:{get:function(){return h},enumerable:!0},x:{get:function(){return d},enumerable:!0},y:{get:function(){return p},enumerable:!0},mods:{get:function(){return g},enumerable:!0}}),m}e.exports=n;var i=t("mouse-event")},{"mouse-event":242}],242:[function(t,e,r){"use strict";function n(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<=0&&r=0&&r+1=0&&n=0&&n+1=0&&s=0&&s+1=0&&i=0&&i+1=0&&l=0&&l+1=0&&h=0&&h+1e;++e)r=+arguments[e+1],i[e]=Math.floor(r),a[e]=r-i[e],o[e]=0<=i[e]&&i[e]e;++e){for(c=1,u=t.offset,l=0;n>l;++l)if(e&1<r;++r){t[r]=o[(n+1)*n+r];for(var i=0;n>i;++i)t[r]+=o[(n+1)*i+r]*e[i]}for(var a=o[(n+1)*(n+1)-1],i=0;n>i;++i)a+=o[(n+1)*i+n]*e[i];for(var s=1/a,r=0;n>r;++r)t[r]*=s;return t}),t}var i=t("ndarray-warp"),a=t("gl-matrix-invert");e.exports=n},{"gl-matrix-invert":247,"ndarray-warp":250}],252:[function(t,e,r){"use strict";function n(t){if(!t)return s;for(var e=0;e>",rrshift:">>>"};!function(){for(var t in l){var e=l[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var c={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in c){var e=c[t];r[t]=a({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var u={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in u){var e=u[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var f=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=o({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=o({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=o({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":109}],253:[function(t,e,r){function n(t,e){return t[0]-e[0]}function i(){var t,e=this.stride,r=new Array(e.length);for(t=0;te&&(r="View_Nil"+t);var n="generic"===t;if(-1===e){var a="function "+r+"(a){this.data=a;};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+r+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+r+"(a){return new "+r+"(a);}",o=new Function(a);return o()}if(0===e){var a="function "+r+"(a,d) {this.data = a;this.offset = d};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+r+"_copy() {return new "+r+"(this.data,this.offset)};proto.pick=function "+r+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+r+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+r+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+r+"(a,b,c,d){return new "+r+"(a,d)}",o=new Function("TrivialArray",a);return o(f[t][0])}var a=["'use strict'"],s=l(e),c=s.map(function(t){return"i"+t}),u="this.offset+"+s.map(function(t){return"this.stride["+t+"]*i"+t}).join("+"),h=s.map(function(t){return"b"+t}).join(","),d=s.map(function(t){return"c"+t}).join(",");a.push("function "+r+"(a,"+h+","+d+",d){this.data=a","this.shape=["+h+"]","this.stride=["+d+"]","this.offset=d|0}","var proto="+r+".prototype","proto.dtype='"+t+"'","proto.dimension="+e),a.push("Object.defineProperty(proto,'size',{get:function "+r+"_size(){return "+s.map(function(t){return"this.shape["+t+"]"}).join("*"),"}})"),1===e?a.push("proto.order=[0]"):(a.push("Object.defineProperty(proto,'order',{get:"),4>e?(a.push("function "+r+"_order(){"),2===e?a.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+c.join(",")+",v){"),n?a.push("return this.data.set("+u+",v)}"):a.push("return this.data["+u+"]=v}"),a.push("proto.get=function "+r+"_get("+c.join(",")+"){"),n?a.push("return this.data.get("+u+")}"):a.push("return this.data["+u+"]}"),a.push("proto.index=function "+r+"_index(",c.join(),"){return "+u+"}"),a.push("proto.hi=function "+r+"_hi("+c.join(",")+"){return new "+r+"(this.data,"+s.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+s.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=s.map(function(t){return"a"+t+"=this.shape["+t+"]"}),g=s.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+c.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+g.join(","));for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){d=i"+v+"|0;b+=c"+v+"*d;a"+v+"-=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+c.join(",")+"){var "+s.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+s.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'){d=i"+v+"|0;if(d<0){c+=b"+v+"*(a"+v+"-1);a"+v+"=ceil(-a"+v+"/d)}else{a"+v+"=ceil(a"+v+"/d)}b"+v+"*=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"b"+t}).join(",")+",c)}");for(var m=new Array(e),y=new Array(e),v=0;e>v;++v)m[v]="a[i"+v+"]",y[v]="b[i"+v+"]";a.push("proto.transpose=function "+r+"_transpose("+c+"){"+c.map(function(t,e){return t+"=("+t+"===undefined?"+e+":"+t+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+r+"(this.data,"+m.join(",")+","+y.join(",")+",this.offset)}"),a.push("proto.pick=function "+r+"_pick("+c+"){var a=[],b=[],c=this.offset");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+s.map(function(t){return"shape["+t+"]"}).join(",")+","+s.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}");var o=new Function("CTOR_LIST","ORDER",a.join("\n"));return o(f[t],i)}function o(t){if(c(t))return"buffer";if(u)switch(Object.prototype.toString.call(t)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(t)?"array":"generic"}function s(t,e,r,n){if(void 0===t){var i=f.array[0];return i([])}"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var s=e.length;if(void 0===r){r=new Array(s);for(var l=s-1,c=1;l>=0;--l)r[l]=c,c*=e[l]}if(void 0===n){n=0;for(var l=0;s>l;++l)r[l]<0&&(n-=(e[l]-1)*r[l])}for(var u=o(t),h=f[u];h.length<=s+1;)h.push(a(u,h.length-1));var i=h[s+1];return i(t,e,r,n)}var l=t("iota-array"),c=t("is-buffer"),u="undefined"!=typeof Float64Array,f={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=s},{"iota-array":239,"is-buffer":240}],254:[function(t,e,r){"use strict";function n(t,e){if("string"!=typeof t)throw new TypeError("repeat-string expects a string.");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;for(i===t&&"undefined"!=typeof i||(i=t,a="");r>a.length&&e>0&&(1&e&&(a+=t),e>>=1);)t+=t;return a.substr(0,r)}var i,a="";e.exports=n},{}],255:[function(t,e,r){(function(t){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],256:[function(t,e,r){"use strict";function n(t){for(var e="robustLinearSolve"+t+"d",r=["function ",e,"(A,b){return ["],n=0;t>n;++n){r.push("det([");for(var i=0;t>i;++i){i>0&&r.push(","),r.push("[");for(var a=0;t>a;++a)a>0&&r.push(","),a===n?r.push("+b[",i,"]"):r.push("+A[",i,"][",a,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var o=new Function("det",r.join(""));return o(6>t?s[t]:s)}function i(){return[0]}function a(t,e){return[[e[0]],[t[0][0]]]}function o(){for(;c.lengthi;++i)t.push("s"+i),r.push("case ",i,":return s",i,"(A,b);");r.push("}var s=CACHE[A.length];if(!s)s=CACHE[A.length]=g(A.length);return s(A,b)}return dispatchLinearSolve"),t.push("CACHE","g",r.join(""));var a=Function.apply(void 0,t);e.exports=a.apply(void 0,c.concat([c,n]));for(var i=0;l>i;++i)e.exports[i]=c[i]}var s=t("robust-determinant"),l=6,c=[i,a];o()},{"robust-determinant":258}],257:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i];r=a+o;var s=r-a,l=o-s;l&&(t[--n]=r,r=l)}for(var c=0,i=n;e>i;++i){var a=t[i],o=r;r=a+o;var s=r-a,l=o-s;l&&(t[c++]=l)}return t[c++]=r,t.length=c,t}e.exports=n},{}],258:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m[",r,"][",n,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("");for(var e=[],r=0;rn;++n)t.push("det"+n),r.push("case ",n,":return det",n,"(m);");r.push("}var det=CACHE[m.length];if(!det)det=CACHE[m.length]=gen(m.length);return det(m);}return robustDeterminant"),t.push("CACHE","gen",r.join(""));var i=Function.apply(void 0,t);e.exports=i.apply(void 0,g.concat([g,l]));for(var n=0;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-1,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;rc;++c)0===(1&c)?e.push.apply(e,s(n(a,c))):r.push.apply(r,s(n(a,c))),l.push("m"+c);var u=o(e),g=o(r),v="orientation"+t+"Exact",m=["function ",v,"(",l.join(),"){var p=",u,",n=",g,",d=sub(p,n);return d[d.length-1];};return ",v].join(""),y=new Function("sum","prod","scale","sub",m);return y(h,f,d,p)}function c(t){var e=_[t.length];return e||(e=_[t.length]=l(t.length)),e.apply(void 0,t)}function u(){for(;_.length<=g;)_.push(l(_.length));for(var t=[],r=["slow"],n=0;g>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;g>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var f=t("two-product"),h=t("robust-sum"),d=t("robust-scale"),p=t("robust-subtract"),g=5,v=1.1102230246251565e-16,m=(3+16*v)*v,y=(7+56*v)*v,b=l(3),x=l(4),_=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,r){var n,i=(t[1]-r[1])*(e[0]-r[0]),a=(t[0]-r[0])*(e[1]-r[1]),o=i-a;if(i>0){if(0>=a)return o;n=i+a}else{if(!(0>i))return o;if(a>=0)return o;n=-(i+a)}var s=m*n;return o>=s||-s>=o?o:b(t,e,r)},function(t,e,r,n){ +var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],d=a*c,p=o*l,g=o*s,v=i*c,m=i*l,b=a*s,_=u*(d-p)+f*(g-v)+h*(m-b),w=(Math.abs(d)+Math.abs(p))*Math.abs(u)+(Math.abs(g)+Math.abs(v))*Math.abs(f)+(Math.abs(m)+Math.abs(b))*Math.abs(h),k=y*w;return _>k||-_>k?_:x(t,e,r,n)}];u()},{"robust-scale":260,"robust-subtract":261,"robust-sum":262,"two-product":276}],260:[function(t,e,r){"use strict";function n(t,e){var r=t.length;if(1===r){var n=i(t[0],e);return n[0]?n:[n[1]]}var o=new Array(2*r),s=[.1,.1],l=[.1,.1],c=0;i(t[0],e,s),s[0]&&(o[c++]=s[0]);for(var u=1;r>u;++u){i(t[u],e,l);var f=s[1];a(f,l[0],s),s[0]&&(o[c++]=s[0]);var h=l[1],d=s[1],p=h+d,g=p-h,v=d-g;s[1]=p,v&&(o[c++]=v)}return s[1]&&(o[c++]=s[1]),0===c&&(o[c++]=0),o.length=c,o}var i=t("two-product"),a=t("two-sum");e.exports=n},{"two-product":276,"two-sum":277}],261:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],-e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=-e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=-e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=-e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],262:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],263:[function(t,e,r){"use strict";function n(t){return t.split("").map(function(t){return t in i?i[t]:""}).join("")}e.exports=n;var i={" ":" ",0:"\u2070",1:"\xb9",2:"\xb2",3:"\xb3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079","+":"\u207a","-":"\u207b",a:"\u1d43",b:"\u1d47",c:"\u1d9c",d:"\u1d48",e:"\u1d49",f:"\u1da0",g:"\u1d4d",h:"\u02b0",i:"\u2071",j:"\u02b2",k:"\u1d4f",l:"\u02e1",m:"\u1d50",n:"\u207f",o:"\u1d52",p:"\u1d56",r:"\u02b3",s:"\u02e2",t:"\u1d57",u:"\u1d58",v:"\u1d5b",w:"\u02b7",x:"\u02e3",y:"\u02b8",z:"\u1dbb"}},{}],264:[function(t,e,r){"use strict";function n(t){return"a"+t}function i(t){return"d"+t}function a(t,e){return"c"+t+"_"+e}function o(t){return"s"+t}function s(t,e){return"t"+t+"_"+e}function l(t){return"o"+t}function c(t){return"x"+t}function u(t){return"p"+t}function f(t,e){return"d"+t+"_"+e}function h(t){return"i"+t}function d(t,e){return"u"+t+"_"+e}function p(t){return"b"+t}function g(t){return"y"+t}function v(t){return"e"+t}function m(t){return"v"+t}function y(t,e,r){for(var n=0,i=0;t>i;++i)e&1<e;++e)F.push(u(e),"+=",d(e,x[t]),";");F.push("}")}function z(t){for(var e=t-1;e>=0;--e)S(e,0);for(var r=[],e=0;I>e;++e)L[e]?r.push(i(e)+".get("+u(e)+")"):r.push(i(e)+"["+u(e)+"]");for(var e=0;b>e;++e)r.push(c(e));F.push(k,"[",T,"++]=phase(",r.join(),");");for(var e=0;t>e;++e)C(e);for(var n=0;I>n;++n)F.push(u(n),"+=",d(n,x[t]),";")}function P(t){for(var e=0;I>e;++e)L[e]?F.push(a(e,0),"=",i(e),".get(",u(e),");"):F.push(a(e,0),"=",i(e),"[",u(e),"];");for(var r=[],e=0;I>e;++e)r.push(a(e,0));for(var e=0;b>e;++e)r.push(c(e));F.push(p(0),"=",k,"[",T,"]=phase(",r.join(),");");for(var n=1;1<n;++n)F.push(p(n),"=",k,"[",T,"+",v(n),"];");for(var o=[],n=1;1<n;++n)o.push("("+p(0)+"!=="+p(n)+")");F.push("if(",o.join("||"),"){");for(var s=[],e=0;N>e;++e)s.push(h(e));for(var e=0;I>e;++e){s.push(a(e,0));for(var n=1;1<n;++n)L[e]?F.push(a(e,n),"=",i(e),".get(",u(e),"+",f(e,n),");"):F.push(a(e,n),"=",i(e),"[",u(e),"+",f(e,n),"];"),s.push(a(e,n))}for(var e=0;1<e;++e)s.push(p(e));for(var e=0;b>e;++e)s.push(c(e));F.push("vertex(",s.join(),");",m(0),"=",w,"[",T,"]=",A,"++;");for(var l=(1<n;++n)if(0===(t&~(1<0;_=_-1&g)x.push(w+"["+T+"+"+v(_)+"]");x.push(m(0));for(var _=0;I>_;++_)1&n?x.push(a(_,l),a(_,g)):x.push(a(_,g),a(_,l));1&n?x.push(d,y):x.push(y,d);for(var _=0;b>_;++_)x.push(c(_));F.push("if(",d,"!==",y,"){","face(",x.join(),")}")}F.push("}",T,"+=1;")}function R(){for(var t=1;1<t;++t)F.push(E,"=",v(t),";",v(t),"=",g(t),";",g(t),"=",E,";")}function O(t,e){if(0>t)return void P(e);z(t),F.push("if(",o(x[t]),">0){",h(x[t]),"=1;"),O(t-1,e|1<r;++r)F.push(u(r),"+=",d(r,x[t]),";");t===N-1&&(F.push(T,"=0;"),R()),S(t,2),O(t-1,e),t===N-1&&(F.push("if(",h(x[N-1]),"&1){",T,"=0;}"),R()),C(t),F.push("}")}var I=L.length,N=x.length;if(2>N)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var j="extractContour"+x.join("_"),F=[],D=[],B=[],U=0;I>U;++U)B.push(n(U));for(var U=0;b>U;++U)B.push(c(U));for(var U=0;N>U;++U)D.push(o(U)+"="+n(0)+".shape["+U+"]|0");for(var U=0;I>U;++U){D.push(i(U)+"="+n(U)+".data",l(U)+"="+n(U)+".offset|0");for(var V=0;N>V;++V)D.push(s(U,V)+"="+n(U)+".stride["+V+"]|0")}for(var U=0;I>U;++U){D.push(u(U)+"="+l(U)),D.push(a(U,0));for(var V=1;1<V;++V){for(var q=[],H=0;N>H;++H)V&1<U;++U)for(var V=0;N>V;++V){var G=[s(U,x[V])];V>0&&G.push(s(U,x[V-1])+"*"+o(x[V-1])),D.push(d(U,x[V])+"=("+G.join("-")+")|0")}for(var U=0;N>U;++U)D.push(h(U)+"=0");D.push(A+"=0");for(var Y=["2"],U=N-2;U>=0;--U)Y.push(o(x[U]));D.push(M+"=("+Y.join("*")+")|0",k+"=mallocUint32("+M+")",w+"=mallocUint32("+M+")",T+"=0"),D.push(p(0)+"=0");for(var V=1;1<V;++V){for(var X=[],W=[],H=0;N>H;++H)V&1<n&&e("Must have at least one array argument");var i=t.scalarArguments||0;0>i&&e("Scalar arg count must be > 0"),"function"!=typeof t.vertex&&e("Must specify vertex creation function"),"function"!=typeof t.cell&&e("Must specify cell creation function"),"function"!=typeof t.phase&&e("Must specify phase function");for(var a=t.getters||[],o=new Array(n),s=0;n>s;++s)a.indexOf(s)>=0?o[s]=!0:o[s]=!1;return b(t.vertex,t.cell,t.phase,i,r,o)}var _=t("typedarray-pool");e.exports=x;var w="V",k="P",A="N",M="Q",T="X",E="T"},{"typedarray-pool":278}],265:[function(t,e,r){function n(t){if(0>t)return Number("0/0");for(var e=s[0],r=s.length-1;r>0;--r)e+=s[r]/(t+r);var n=t+o+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}var i=7,a=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],o=607/128,s=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];e.exports=function l(t){if(.5>t)return Math.PI/(Math.sin(Math.PI*t)*l(1-t));if(t>100)return Math.exp(n(t));t-=1;for(var e=a[0],r=1;i+2>r;r++)e+=a[r]/(t+r);var o=t+i+.5;return Math.sqrt(2*Math.PI)*Math.pow(o,t+.5)*Math.exp(-o)*e},e.exports.log=n},{}],266:[function(t,e,r){"use strict";function n(t){var e=t.length;if(i>e){for(var r=1,n=0;e>n;++n)for(var o=0;n>o;++o)if(t[n]n;++n)s[n]=0;for(var r=1,n=0;e>n;++n)if(!s[n]){var l=1;s[n]=1;for(var o=t[n];o!==n;o=t[o]){if(s[o])return a.freeUint8(s),0;l+=1,s[o]=1}1&l||(r=-r)}return a.freeUint8(s),r}e.exports=n;var i=32,a=t("typedarray-pool")},{"typedarray-pool":278}],267:[function(t,e,r){"use strict";function n(t){var e=t.length;switch(e){case 0:case 1:return 0;case 2:return t[1]}var r,n,i,s=a.mallocUint32(e),l=a.mallocUint32(e),c=0;for(o(t,l),i=0;e>i;++i)s[i]=t[i];for(i=e-1;i>0;--i)n=l[i],r=s[i],s[i]=s[n],s[n]=r,l[i]=l[r],l[r]=n,c=(c+r)*i;return a.freeUint32(l),a.freeUint32(s),c}function i(t,e,r){switch(t){case 0:return r?r:[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}r=r||new Array(t);var n,i,a,o=1;for(r[0]=0,a=1;t>a;++a)r[a]=a,o=o*a|0;for(a=t-1;a>0;--a)n=e/o|0,e=e-n*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}var a=t("typedarray-pool"),o=t("invert-permutation");r.rank=n,r.unrank=i},{"invert-permutation":268,"typedarray-pool":278}],268:[function(t,e,r){"use strict";function n(t,e){e=e||new Array(t.length);for(var r=0;rt)return[];if(0===t)return[[0]];for(var e=0|Math.round(o(t+1)),r=[],n=0;e>n;++n){for(var s=i.unrank(t,n),l=[0],c=0,u=0;u= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":109}],271:[function(t,e,r){"use strict";function n(t,e){var r=[];return e=+e||0,i(t.hi(t.shape[0]-1),r,e),r}e.exports=n;var i=t("./lib/zc-core")},{"./lib/zc-core":270}],272:[function(t,e,r){"use strict";function n(t,e){var r=t.length,n=["'use strict';"],i="surfaceNets"+t.join("_")+"d"+e;n.push("var contour=genContour({","order:[",t.join(),"],","scalarArguments: 3,","phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },"),"generic"===e&&n.push("getters:[0],");for(var a=[],l=[],c=0;r>c;++c)a.push("d"+c),l.push("d"+c);for(var c=0;1<c;++c)a.push("v"+c),l.push("v"+c);for(var c=0;1<c;++c)a.push("p"+c),l.push("p"+c);a.push("a","b","c"),l.push("a","c"),n.push("vertex:function vertexFunc(",a.join(),"){");for(var u=[],c=0;1<c;++c)u.push("(p"+c+"<<"+c+")");n.push("var m=(",u.join("+"),")|0;if(m===0||m===",(1<<(1<=1<<(1<>>7){");for(var c=0;1<<(1<c;++c){if(1<<(1<128&&c%128===0){f.length>0&&h.push("}}");var d="vExtra"+f.length;n.push("case ",c>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&c,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;r>b;++b)p[b]=[],g[b]=[],v[b]=0,m[b]=0;for(var b=0;1<b;++b)for(var x=0;r>x;++x){var _=b^1<b)&&!(c&1<<_)!=!(c&1<w?(p[x].push("-v"+b+"-v"+_),v[x]+=2):(p[x].push("v"+b+"+v"+_),v[x]-=2),y+=1;for(var k=0;r>k;++k)k!==x&&(_&1<x;++x)if(0===p[x].length)A.push("d"+x+"-0.5");else{var M="";v[x]<0?M=v[x]+"*c":v[x]>0&&(M="+"+v[x]+"*c");var T=.5*(p[x].length/y),E=.5+.5*(m[x]/y);A.push("d"+x+"-"+E+"-"+T+"*("+p[x].join("+")+M+")/("+g[x].join("+")+")")}h.push("a.push([",A.join(),"]);","break;")}n.push("}},"),f.length>0&&h.push("}}");for(var L=[],c=0;1<c;++c)L.push("v"+c);L.push("c0","c1","p0","p1","a","b","c"),n.push("cell:function cellFunc(",L.join(),"){");var S=s(r-1);n.push("if(p0){b.push(",S.map(function(t){return"["+t.map(function(t){return"v"+t})+"]"}).join(),")}else{b.push(",S.map(function(t){var e=t.slice();return e.reverse(),"["+e.map(function(t){return"v"+t})+"]"}).join(),")}}});function ",i,"(array,level){var verts=[],cells=[];contour(array,verts,cells,level);return {positions:verts,cells:cells};} return ",i,";");for(var c=0;co;++o)i[o]=[r[o]],a[o]=[o];return{positions:i,cells:a}}function a(t,e){if(t.dimension<=0)return{positions:[],cells:[]};if(1===t.dimension)return i(t,e);var r=t.order.join()+"-"+t.dtype,a=c[r],e=+e||0;return a||(a=c[r]=n(t.order,t.dtype)),a(t,e)}e.exports=a;var o=t("ndarray-extract-contour"),s=t("triangulate-hypercube"),l=t("zero-crossings"),c={}},{"ndarray-extract-contour":264,"triangulate-hypercube":269,"zero-crossings":271}],273:[function(t,e,r){(function(r){"use strict";function n(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;ol;++l){var c=r[s[l]];n[i++]=c[0],n[i++]=c[1]+1.4,a=Math.max(c[0],a)}return{data:n,shape:a}}function i(t,e){var r=s[t];r||(r=s[t]={" ":{data:new Float32Array(0),shape:.2}});var o=r[e];if(!o)if(e.length<=1||!/\d/.test(e))o=r[e]=n(a(e,{triangles:!0,font:t,textAlign:"left",textBaseline:"alphabetic"}));else{for(var l=e.split(/(\d|\s)/),c=new Array(l.length),u=0,f=0,h=0;h0&&(f+=.02);for(var d=new Float32Array(u),p=0,g=-.5*f,h=0;h.5?l/(2-a-o):l/(a+o),a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,l:s}}function o(t,e,r){function n(t,e,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?t+6*(e-t)*r:.5>r?e:2/3>r?t+(e-t)*(2/3-r)*6:t}var i,a,o;if(t=T(t,360),e=T(e,100),r=T(r,100),0===e)i=a=o=r;else{var s=.5>r?r*(1+e):r+e-r*e,l=2*r-s;i=n(l,s,t+1/3),a=n(l,s,t),o=n(l,s,t-1/3)}return{r:255*i,g:255*a,b:255*o}}function s(t,e,r){t=T(t,255),e=T(e,255),r=T(r,255);var n,i,a=q(t,e,r),o=V(t,e,r),s=a,l=a-o;if(i=0===a?0:l/a,a==o)n=0;else{switch(a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,v:s}}function l(t,e,r){t=6*T(t,360),e=T(e,100),r=T(r,100);var n=B.floor(t),i=t-n,a=r*(1-e),o=r*(1-i*e),s=r*(1-(1-i)*e),l=n%6,c=[r,o,a,a,s,r][l],u=[s,r,r,o,a,a][l],f=[a,a,s,r,r,o][l];return{r:255*c,g:255*u,b:255*f}}function c(t,e,r,n){var i=[z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function u(t,e,r,n){var i=[z(R(n)),z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return i.join("")}function f(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s-=r/100,n.s=E(n.s),e(n)}function h(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s+=r/100,n.s=E(n.s),e(n)}function d(t){return e(t).desaturate(100)}function p(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l+=r/100,n.l=E(n.l),e(n)}function g(t,r){r=0===r?0:r||10;var n=e(t).toRgb();return n.r=q(0,V(255,n.r-U(255*-(r/100)))),n.g=q(0,V(255,n.g-U(255*-(r/100)))),n.b=q(0,V(255,n.b-U(255*-(r/100)))),e(n)}function v(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l-=r/100,n.l=E(n.l),e(n)}function m(t,r){var n=e(t).toHsl(),i=(U(n.h)+r)%360;return n.h=0>i?360+i:i,e(n)}function y(t){var r=e(t).toHsl();return r.h=(r.h+180)%360,e(r)}function b(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+120)%360,s:r.s,l:r.l}),e({h:(n+240)%360,s:r.s,l:r.l})]}function x(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+90)%360,s:r.s,l:r.l}),e({h:(n+180)%360,s:r.s,l:r.l}),e({h:(n+270)%360,s:r.s,l:r.l})]}function _(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+72)%360,s:r.s,l:r.l}),e({h:(n+216)%360,s:r.s,l:r.l})]}function w(t,r,n){r=r||6,n=n||30;var i=e(t).toHsl(),a=360/n,o=[e(t)];for(i.h=(i.h-(a*r>>1)+720)%360;--r;)i.h=(i.h+a)%360,o.push(e(i));return o}function k(t,r){r=r||6;for(var n=e(t).toHsv(),i=n.h,a=n.s,o=n.v,s=[],l=1/r;r--;)s.push(e({h:i,s:a,v:o})),o=(o+l)%1;return s}function A(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}function M(t){return t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=1),t}function T(t,e){S(t)&&(t="100%");var r=C(t);return t=V(e,q(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),B.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function E(t){return V(1,q(0,t))}function L(t){return parseInt(t,16)}function S(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function C(t){return"string"==typeof t&&-1!=t.indexOf("%")}function z(t){return 1==t.length?"0"+t:""+t}function P(t){return 1>=t&&(t=100*t+"%"),t}function R(t){return Math.round(255*parseFloat(t)).toString(16)}function O(t){return L(t)/255}function I(t){t=t.replace(j,"").replace(F,"").toLowerCase();var e=!1;if(G[t])t=G[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=X.rgb.exec(t))?{r:r[1],g:r[2],b:r[3]}:(r=X.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=X.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=X.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=X.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=X.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=X.hex8.exec(t))?{a:O(r[1]),r:L(r[2]),g:L(r[3]),b:L(r[4]),format:e?"name":"hex8"}:(r=X.hex6.exec(t))?{r:L(r[1]),g:L(r[2]),b:L(r[3]),format:e?"name":"hex"}:(r=X.hex3.exec(t))?{r:L(r[1]+""+r[1]),g:L(r[2]+""+r[2]),b:L(r[3]+""+r[3]),format:e?"name":"hex"}:!1}function N(t){var e,r;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==r&&"large"!==r&&(r="small"),{level:e,size:r}}var j=/^\s+/,F=/\s+$/,D=0,B=Math,U=B.round,V=B.min,q=B.max,H=B.random;e.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,r,n,i,a,o=this.toRgb();return t=o.r/255,e=o.g/255,r=o.b/255,n=.03928>=t?t/12.92:Math.pow((t+.055)/1.055,2.4),i=.03928>=e?e/12.92:Math.pow((e+.055)/1.055,2.4),a=.03928>=r?r/12.92:Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*i+.0722*a},setAlpha:function(t){return this._a=M(t),this._roundA=U(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=a(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=a(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return u(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:U(this._r),g:U(this._g),b:U(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+U(this._r)+", "+U(this._g)+", "+U(this._b)+")":"rgba("+U(this._r)+", "+U(this._g)+", "+U(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:U(100*T(this._r,255))+"%",g:U(100*T(this._g,255))+"%",b:U(100*T(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%)":"rgba("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:Y[c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+u(this._r,this._g,this._b,this._a),n=r,i=this._gradientType?"GradientType = 1, ":"";if(t){var a=e(t);n=a.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+r+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0,i=!e&&n&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return i?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return e(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(p,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(v,arguments)},desaturate:function(){return this._applyModification(f,arguments)},saturate:function(){return this._applyModification(h,arguments)},greyscale:function(){return this._applyModification(d,arguments)},spin:function(){return this._applyModification(m,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(w,arguments)},complement:function(){return this._applyCombination(y,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(_,arguments)},triad:function(){return this._applyCombination(b,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},e.fromRatio=function(t,r){if("object"==typeof t){var n={};for(var i in t)t.hasOwnProperty(i)&&("a"===i?n[i]=t[i]:n[i]=P(t[i]));t=n}return e(t,r)},e.equals=function(t,r){return t&&r?e(t).toRgbString()==e(r).toRgbString():!1},e.random=function(){return e.fromRatio({r:H(),g:H(),b:H()})},e.mix=function(t,r,n){n=0===n?0:n||50;var i,a=e(t).toRgb(),o=e(r).toRgb(),s=n/100,l=2*s-1,c=o.a-a.a;i=l*c==-1?l:(l+c)/(1+l*c),i=(i+1)/2;var u=1-i,f={r:o.r*i+a.r*u,g:o.g*i+a.g*u,b:o.b*i+a.b*u,a:o.a*s+a.a*(1-s)};return e(f)},e.readability=function(t,r){var n=e(t),i=e(r);return(Math.max(n.getLuminance(),i.getLuminance())+.05)/(Math.min(n.getLuminance(),i.getLuminance())+.05)},e.isReadable=function(t,r,n){var i,a,o=e.readability(t,r);switch(a=!1,i=N(n),i.level+i.size){case"AAsmall":case"AAAlarge":a=o>=4.5;break;case"AAlarge":a=o>=3;break;case"AAAsmall":a=o>=7}return a},e.mostReadable=function(t,r,n){var i,a,o,s,l=null,c=0;n=n||{},a=n.includeFallbackColors,o=n.level,s=n.size;for(var u=0;uc&&(c=i,l=e(r[u]));return e.isReadable(t,l,{level:o,size:s})||!a?l:(n.includeFallbackColors=!1,e.mostReadable(t,["#fff","#000"],n))};var G=e.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Y=e.hexNames=A(G),X=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",r="(?:"+e+")|(?:"+t+")",n="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",i="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof r&&r.exports?r.exports=e:"function"==typeof t&&t.amd?t(function(){return e}):window.tinycolor=e}()},{}],275:[function(e,r,n){!function(e,i){"object"==typeof n&&"undefined"!=typeof r?i(n):"function"==typeof t&&t.amd?t(["exports"],i):i(e.topojson={})}(this,function(t){"use strict";function e(){}function r(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0),t[0]=(r+=t[0])*i+o,t[1]=(n+=t[1])*a+s}}function n(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0);var l=(t[0]-o)/i|0,c=(t[1]-s)/a|0;t[0]=l-r,t[1]=c-n,r=l,n=c}}function i(t,e){for(var r,n=t.length,i=n-e;i<--n;)r=t[i],t[i++]=t[n],t[n]=r}function a(t,e){for(var r=0,n=t.length;n>r;){var i=r+n>>>1;t[i]t?~t:t],a=0,o=n.length;o>a;++a)e.push(r=n[a].slice()),u(r,a);0>t&&i(e,o)}function a(t){return t=t.slice(),u(t,0),t}function o(t){for(var e=[],r=0,i=t.length;i>r;++r)n(t[r],e);return e.length<2&&e.push(e[0].slice()),e}function s(t){for(var e=o(t);e.length<4;)e.push(e[0].slice());return e}function l(t){return t.map(s)}function c(t){var e=t.type;return"GeometryCollection"===e?{type:e,geometries:t.geometries.map(c)}:e in h?{type:e,coordinates:h[e](t)}:null}var u=r(t.transform),f=t.arcs,h={Point:function(t){return a(t.coordinates)},MultiPoint:function(t){return t.coordinates.map(a)},LineString:function(t){return o(t.arcs)},MultiLineString:function(t){return t.arcs.map(o)},Polygon:function(t){return l(t.arcs)},MultiPolygon:function(t){return t.arcs.map(l)}};return c(e)}function c(t,e){function r(e){var r,n=t.arcs[0>e?~e:e],i=n[0];return t.transform?(r=[0,0],n.forEach(function(t){r[0]+=t[0],r[1]+=t[1]})):r=n[n.length-1],0>e?[r,i]:[i,r]}function n(t,e){for(var r in t){var n=t[r];delete e[n.start],delete n.start,delete n.end,n.forEach(function(t){i[0>t?~t:t]=1}),s.push(n)}}var i={},a={},o={},s=[],l=-1;return e.forEach(function(r,n){ +var i,a=t.arcs[0>r?~r:r];a.length<3&&!a[1][0]&&!a[1][1]&&(i=e[++l],e[l]=r,e[n]=i)}),e.forEach(function(t){var e,n,i=r(t),s=i[0],l=i[1];if(e=o[s])if(delete o[e.end],e.push(t),e.end=l,n=a[l]){delete a[n.start];var c=n===e?e:e.concat(n);a[c.start=e.start]=o[c.end=n.end]=c}else a[e.start]=o[e.end]=e;else if(e=a[l])if(delete a[e.start],e.unshift(t),e.start=s,n=o[s]){delete o[n.end];var u=n===e?e:n.concat(e);a[u.start=n.start]=o[u.end=e.end]=u}else a[e.start]=o[e.end]=e;else e=[t],a[e.start=s]=o[e.end=l]=e}),n(o,a),n(a,o),e.forEach(function(t){i[0>t?~t:t]||s.push([t])}),s}function u(t){return l(t,f.apply(this,arguments))}function f(t,e,r){function n(t){var e=0>t?~t:t;(u[e]||(u[e]=[])).push({i:t,g:l})}function i(t){t.forEach(n)}function a(t){t.forEach(i)}function o(t){"GeometryCollection"===t.type?t.geometries.forEach(o):t.type in f&&(l=t,f[t.type](t.arcs))}var s=[];if(arguments.length>1){var l,u=[],f={LineString:i,MultiLineString:a,Polygon:a,MultiPolygon:function(t){t.forEach(a)}};o(e),u.forEach(arguments.length<3?function(t){s.push(t[0].i)}:function(t){r(t[0].g,t[t.length-1].g)&&s.push(t[0].i)})}else for(var h=0,d=t.arcs.length;d>h;++h)s.push(h);return{type:"MultiLineString",arcs:c(t,s)}}function h(t){var e=t[0],r=t[1],n=t[2];return Math.abs((e[0]-n[0])*(r[1]-e[1])-(e[0]-r[0])*(n[1]-e[1]))}function d(t){for(var e,r=-1,n=t.length,i=t[n-1],a=0;++re?~e:e]||(i[e]=[])).push(t)})}),a.push(t)}function n(e){return d(l(t,{type:"Polygon",arcs:[e]}).coordinates[0])>0}var i={},a=[],o=[];return e.forEach(function(t){"Polygon"===t.type?r(t.arcs):"MultiPolygon"===t.type&&t.arcs.forEach(r)}),a.forEach(function(t){if(!t._){var e=[],r=[t];for(t._=1,o.push(e);t=r.pop();)e.push(t),t.forEach(function(t){t.forEach(function(t){i[0>t?~t:t].forEach(function(t){t._||(t._=1,r.push(t))})})})}}),a.forEach(function(t){delete t._}),{type:"MultiPolygon",arcs:o.map(function(e){var r,a=[];if(e.forEach(function(t){t.forEach(function(t){t.forEach(function(t){i[0>t?~t:t].length<2&&a.push(t)})})}),a=c(t,a),(r=a.length)>1)for(var o,s=n(e[0][0]),l=0;r>l;++l)if(s===n(a[l])){o=a[0],a[0]=a[l],a[l]=o;break}return a})}}function v(t){function e(t,e){t.forEach(function(t){0>t&&(t=~t);var r=i[t];r?r.push(e):i[t]=[e]})}function r(t,r){t.forEach(function(t){e(t,r)})}function n(t,e){"GeometryCollection"===t.type?t.geometries.forEach(function(t){n(t,e)}):t.type in s&&s[t.type](t.arcs,e)}var i={},o=t.map(function(){return[]}),s={LineString:e,MultiLineString:r,Polygon:r,MultiPolygon:function(t,e){t.forEach(function(t){r(t,e)})}};t.forEach(n);for(var l in i)for(var c=i[l],u=c.length,f=0;u>f;++f)for(var h=f+1;u>h;++h){var d,p=c[f],g=c[h];(d=o[p])[l=a(d,g)]!==g&&d.splice(l,0,g),(d=o[g])[l=a(d,p)]!==p&&d.splice(l,0,p)}return o}function m(t,e){return t[1][2]-e[1][2]}function y(){function t(t,e){for(;e>0;){var r=(e+1>>1)-1,i=n[r];if(m(t,i)>=0)break;n[i._=e]=i,n[t._=e=r]=t}}function e(t,e){for(;;){var r=e+1<<1,a=r-1,o=e,s=n[o];if(i>a&&m(n[a],s)<0&&(s=n[o=a]),i>r&&m(n[r],s)<0&&(s=n[o=r]),o===e)break;n[s._=e]=s,n[t._=e=o]=t}}var r={},n=[],i=0;return r.push=function(e){return t(n[e._=i]=e,i++),i},r.pop=function(){if(!(0>=i)){var t,r=n[0];return--i>0&&(t=n[i],e(n[t._=0]=t,0)),r}},r.remove=function(r){var a,o=r._;if(n[o]===r)return o!==--i&&(a=n[i],(m(a,r)<0?t:e)(n[a._=o]=a,o)),o},r}function b(t,e){function i(t){s.remove(t),t[1][2]=e(t),s.push(t)}var a=r(t.transform),o=n(t.transform),s=y();return e||(e=h),t.arcs.forEach(function(t){var r,n,l,c,u=[],f=0;for(n=0,l=t.length;l>n;++n)c=t[n],a(t[n]=[c[0],c[1],1/0],n);for(n=1,l=t.length-1;l>n;++n)r=t.slice(n-1,n+2),r[1][2]=e(r),u.push(r),s.push(r);for(n=0,l=u.length;l>n;++n)r=u[n],r.previous=u[n-1],r.next=u[n+1];for(;r=s.pop();){var h=r.previous,d=r.next;r[1][2]0?r.pop():new ArrayBuffer(t)}function s(t){return new Uint8Array(o(t),0,t)}function l(t){return new Uint16Array(o(2*t),0,t)}function c(t){return new Uint32Array(o(4*t),0,t)}function u(t){return new Int8Array(o(t),0,t)}function f(t){return new Int16Array(o(2*t),0,t)}function h(t){return new Int32Array(o(4*t),0,t)}function d(t){return new Float32Array(o(4*t),0,t)}function p(t){return new Float64Array(o(8*t),0,t)}function g(t){return x?new Uint8ClampedArray(o(t),0,t):s(t)}function v(t){return new DataView(o(t),0,t)}function m(t){t=y.nextPow2(t);var e=y.log2(t),r=k[e];return r.length>0?r.pop():new n(t)}var y=t("bit-twiddle"),b=t("dup");e.__TYPEDARRAY_POOL||(e.__TYPEDARRAY_POOL={UINT8:b([32,0]),UINT16:b([32,0]),UINT32:b([32,0]),INT8:b([32,0]),INT16:b([32,0]),INT32:b([32,0]),FLOAT:b([32,0]),DOUBLE:b([32,0]),DATA:b([32,0]),UINT8C:b([32,0]),BUFFER:b([32,0])});var x="undefined"!=typeof Uint8ClampedArray,_=e.__TYPEDARRAY_POOL;_.UINT8C||(_.UINT8C=b([32,0])),_.BUFFER||(_.BUFFER=b([32,0]));var w=_.DATA,k=_.BUFFER;r.free=function(t){if(n.isBuffer(t))k[y.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|y.log2(e);w[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=a,r.freeArrayBuffer=i,r.freeBuffer=function(t){k[y.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return o(t);switch(e){case"uint8":return s(t);case"uint16":return l(t);case"uint32":return c(t);case"int8":return u(t);case"int16":return f(t);case"int32":return h(t);case"float":case"float32":return d(t);case"double":case"float64":return p(t);case"uint8_clamped":return g(t);case"buffer":return m(t);case"data":case"dataview":return v(t);default:return null}return null},r.mallocArrayBuffer=o,r.mallocUint8=s,r.mallocUint16=l,r.mallocUint32=c,r.mallocInt8=u,r.mallocInt16=f,r.mallocInt32=h,r.mallocFloat32=r.mallocFloat=d,r.mallocFloat64=r.mallocDouble=p,r.mallocUint8Clamped=g,r.mallocDataView=v,r.mallocBuffer=m,r.clearCache=function(){for(var t=0;32>t;++t)_.UINT8[t].length=0,_.UINT16[t].length=0,_.UINT32[t].length=0,_.INT8[t].length=0,_.INT16[t].length=0,_.INT32[t].length=0,_.FLOAT[t].length=0,_.DOUBLE[t].length=0,_.UINT8C[t].length=0,w[t].length=0,k[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":50,buffer:51,dup:115}],279:[function(t,e,r){"use strict";function n(t,e){for(var r=1,n=t.length,i=t[0],a=t[0],o=1;n>o;++o)if(a=i,i=t[o],e(i,a)){if(o===r){r++;continue}t[r++]=i}return t.length=r,t}function i(t){for(var e=1,r=t.length,n=t[0],i=t[0],a=1;r>a;++a,i=n)if(i=n,n=t[a],n!==i){if(a===e){e++;continue}t[e++]=n}return t.length=e,t}function a(t,e,r){return 0===t.length?t:e?(r||t.sort(e),n(t,e)):(r||t.sort(),i(t))}e.exports=a},{}],280:[function(t,e,r){"use strict";function n(t,e){return"object"==typeof e&&null!==e||(e={}),i(t,e.canvas||a,e.context||o,e)}e.exports=n;var i=t("./lib/vtext"),a=null,o=null;"undefined"!=typeof document&&(a=document.createElement("canvas"),a.width=8192,a.height=1024,o=a.getContext("2d"))},{"./lib/vtext":281}],281:[function(t,e,r){"use strict";function n(t,e,r){for(var n=e.textAlign||"start",i=e.textBaseline||"alphabetic",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;s>l;++l)for(var c=t[l],u=0;2>u;++u)a[u]=0|Math.min(a[u],c[u]),o[u]=0|Math.max(o[u],c[u]);var f=0;switch(n){case"center":f=-.5*(a[0]+o[0]);break;case"right":case"end":f=-o[0];break;case"left":case"start":f=-a[0];break;default:throw new Error("vectorize-text: Unrecognized textAlign: '"+n+"'")}var h=0;switch(i){case"hanging":case"top":h=-a[1];break;case"middle":h=-.5*(a[1]+o[1]);break;case"alphabetic":case"ideographic":h=-3*r;break;case"bottom":h=-o[1];break;default:throw new Error("vectorize-text: Unrecoginized textBaseline: '"+i+"'")}var d=1/r;return"lineHeight"in e?d*=+e.lineHeight:"width"in e?d=e.width/(o[0]-a[0]):"height"in e&&(d=e.height/(o[1]-a[1])),t.map(function(t){return[d*(t[0]+f),d*(t[1]+h)]})}function i(t,e,r,n){var i=0|Math.ceil(e.measureText(r).width+2*n);if(i>8192)throw new Error("vectorize-text: String too long (sorry, this will get fixed later)");var a=3*n;t.height=l&&o.push(s)}for(;o.length>0;){var c=o.pop();n[c]=!1;for(var u=r[c],s=0;sn;++n){var a=t[n];e=Math.max(e,a[0],a[1])}e=(0|e)+1}e=0|e;for(var o=new Array(e),n=0;e>n;++n)o[n]=[];for(var n=0;r>n;++n){var a=t[n];o[a[0]].push(a[1]),o[a[1]].push(a[0])}for(var s=0;e>s;++s)i(o[s],function(t,e){return t-e});return o}e.exports=n;var i=t("uniq")},{uniq:279}],284:[function(t,e,r){"use strict";function n(t,e){function r(t,e){var r=c[e][t[e]];r.splice(r.indexOf(t),1)}function n(t,n,a){for(var o,s,l,u=0;2>u;++u)if(c[u][n].length>0){o=c[u][n][0],l=u;break}s=o[1^l];for(var f=0;2>f;++f)for(var h=c[f][n],d=0;d0&&(o=p,s=g,l=f)}return a?s:(o&&r(o,l),s)}function a(t,a){var o=c[a][t][0],s=[t];r(o,a);for(var l=o[1^a];;){for(;l!==t;)s.push(l),l=n(s[s.length-2],l,!1);if(c[0][t].length+c[1][t].length===0)break;var u=s[s.length-1],f=t,h=s[1],d=n(u,f,!0);if(i(e[u],e[f],e[h],e[d])<0)break;s.push(t),l=n(u,f)}return s}function o(t,e){return e[1]===e[e.length-1]}for(var s=0|e.length,l=t.length,c=[new Array(s),new Array(s)],u=0;s>u;++u)c[0][u]=[],c[1][u]=[];for(var u=0;l>u;++u){var f=t[u];c[0][f[0]].push(f),c[1][f[1]].push(f)}for(var h=[],u=0;s>u;++u)c[0][u].length+c[1][u].length===0&&h.push([u]);for(var u=0;s>u;++u)for(var d=0;2>d;++d){for(var p=[];c[d][u].length>0;){var g=(c[0][u].length,a(u,d));o(p,g)?p.push.apply(p,g):(p.length>0&&h.push(p),p=g)}p.length>0&&h.push(p)}return h}e.exports=n;var i=t("compare-angle")},{"compare-angle":285}],285:[function(t,e,r){"use strict";function n(t,e,r){var n=s(t[0],-e[0]),i=s(t[1],-e[1]),a=s(r[0],-e[0]),o=s(r[1],-e[1]),u=c(l(n,a),l(i,o));return u[u.length-1]>=0}function i(t,e,r,i){var s=a(e,r,i);if(0===s){var l=o(a(t,e,r)),c=o(a(t,e,i));if(l===c){if(0===l){var u=n(t,e,r),f=n(t,e,i);return u===f?0:u?1:-1}return 0}return 0===c?l>0?-1:n(t,e,i)?-1:1:0===l?c>0?1:n(t,e,r)?1:-1:o(c-l)}var h=a(t,e,r);if(h>0)return s>0&&a(t,e,i)>0?1:-1;if(0>h)return s>0||a(t,e,i)>0?1:-1;var d=a(t,e,i);return d>0?1:n(t,e,r)?1:-1}e.exports=i;var a=t("robust-orientation"),o=t("signum"),s=t("two-sum"),l=t("robust-product"),c=t("robust-sum")},{"robust-orientation":259,"robust-product":286,"robust-sum":262,signum:287,"two-sum":277}],286:[function(t,e,r){"use strict";function n(t,e){if(1===t.length)return a(e,t[0]);if(1===e.length)return a(t,e[0]);if(0===t.length||0===e.length)return[0];var r=[0];if(t.lengtht?-1:t>0?1:0}},{}],288:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],289:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}function i(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function a(t,e){var r=p(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function o(t,e){var r=t.intervals([]);r.push(e),a(t,r)}function s(t,e){var r=t.intervals([]),n=r.indexOf(e);return 0>n?y:(r.splice(n,1),a(t,r),b)}function l(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function u(t,e){for(var r=0;r>1],a=[],o=[],s=[],r=0;r3*(e+1)?o(this,t):this.left.insert(t):this.left=p([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?o(this,t):this.right.insert(t):this.right=p([t]);else{var r=m.ge(this.leftPoints,t,h),n=m.ge(this.rightPoints,t,d);this.leftPoints.splice(r,0,t),this.rightPoints.splice(n,0,t)}},_.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1))return s(this,t);var n=this.left.remove(t);return n===x?(this.left=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(t[0]>this.mid){if(!this.right)return y;var a=this.left?this.left.count:0;if(4*a>3*(e-1))return s(this,t);var n=this.right.remove(t);return n===x?(this.right=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(1===this.count)return this.leftPoints[0]===t?x:y;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var o=this,l=this.left;l.right;)o=l,l=l.right;if(o===this)l.right=this.right;else{var c=this.left,n=this.right;o.count-=l.count,o.right=l.left,l.left=c,l.right=n}i(this,l),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?i(this,this.left):i(this,this.right);return b}for(var c=m.ge(this.leftPoints,t,h);cthis.mid){if(this.right){var r=this.right.queryPoint(t,e);if(r)return r}return c(this.rightPoints,t,e)}return u(this.leftPoints,e)},_.queryInterval=function(t,e,r){if(tthis.mid&&this.right){var n=this.right.queryInterval(t,e,r);if(n)return n}return ethis.mid?c(this.rightPoints,t,r):u(this.leftPoints,r)};var w=g.prototype;w.insert=function(t){this.root?this.root.insert(t):this.root=new n(t[0],null,null,[t],[t])},w.remove=function(t){if(this.root){var e=this.root.remove(t);return e===x&&(this.root=null),e!==y}return!1},w.queryPoint=function(t,e){return this.root?this.root.queryPoint(t,e):void 0},w.queryInterval=function(t,e,r){return e>=t&&this.root?this.root.queryInterval(t,e,r):void 0},Object.defineProperty(w,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(w,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":288}],290:[function(t,e,r){"use strict";function n(t,e){var r,n;if(e[0][0]e[1][0])){var i=Math.min(t[0][1],t[1][1]),o=Math.max(t[0][1],t[1][1]),s=Math.min(e[0][1],e[1][1]),l=Math.max(e[0][1],e[1][1]);return s>o?o-s:i>l?i-l:o-l}r=e[1],n=e[0]}var c,u;t[0][1]e[1][0]))return n(e,t);r=e[1],i=e[0]}var o,s;if(t[0][0]t[1][0]))return-n(t,e);o=t[1],s=t[0]}var l=a(r,i,s),c=a(r,i,o);if(0>l){if(0>=c)return l}else if(l>0){if(c>=0)return l}else if(c)return c;if(l=a(s,o,i),c=a(s,o,r),0>l){if(0>=c)return l}else if(l>0){if(c>=0)return l}else if(c)return c;return i[0]-s[0]}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":259}],291:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function i(t){return new n(t._color,t.key,t.value,t.left,t.right,t._count)}function a(t,e){return new n(t,e.key,e.value,e.left,e.right,e._count)}function o(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function s(t,e){this._compare=t,this.root=e}function l(t,e){if(e.left){var r=l(t,e.left);if(r)return r}var r=t(e.key,e.value);return r?r:e.right?l(t,e.right):void 0}function c(t,e,r,n){var i=e(t,n.key);if(0>=i){if(n.left){var a=c(t,e,r,n.left);if(a)return a}var a=r(n.key,n.value);if(a)return a}return n.right?c(t,e,r,n.right):void 0}function u(t,e,r,n,i){var a,o=r(t,i.key),s=r(e,i.key);if(0>=o){if(i.left&&(a=u(t,e,r,n,i.left)))return a;if(s>0&&(a=n(i.key,i.value)))return a}return s>0&&i.right?u(t,e,r,n,i.right):void 0}function f(t,e){this.tree=t,this._stack=e}function h(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function d(t){for(var e,r,n,s,l=t.length-1;l>=0;--l){if(e=t[l],0===l)return void(e._color=m);if(r=t[l-1],r.left===e){if(n=r.right,n.right&&n.right._color===v){if(n=r.right=i(n),s=n.right=i(n.right),r.right=n.left,n.left=r,n.right=s,n._color=r._color,e._color=m,r._color=m,s._color=m,o(r),o(n),l>1){var c=t[l-2];c.left===r?c.left=n:c.right=n}return void(t[l-1]=n)}if(n.left&&n.left._color===v){if(n=r.right=i(n),s=n.left=i(n.left),r.right=s.left,n.left=s.right,s.left=r,s.right=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var c=t[l-2];c.left===r?c.left=s:c.right=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.right=a(v,n));r.right=a(v,n);continue}if(n=i(n),r.right=n.left,n.left=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var c=t[l-2];c.left===r?c.left=n:c.right=n}t[l-1]=n,t[l]=r,l+11){var c=t[l-2];c.right===r?c.right=n:c.left=n}return void(t[l-1]=n)}if(n.right&&n.right._color===v){if(n=r.left=i(n),s=n.right=i(n.right),r.left=s.right,n.right=s.left,s.right=r,s.left=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var c=t[l-2];c.right===r?c.right=s:c.left=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.left=a(v,n));r.left=a(v,n);continue}if(n=i(n),r.left=n.right,n.right=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var c=t[l-2];c.right===r?c.right=n:c.left=n}t[l-1]=n,t[l]=r,l+1t?-1:t>e?1:0}function g(t){return new s(t||p,null)}e.exports=g;var v=0,m=1,y=s.prototype;Object.defineProperty(y,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(y,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(y,"length",{get:function(){return this.root?this.root._count:0}}),y.insert=function(t,e){for(var r=this._compare,i=this.root,l=[],c=[];i;){var u=r(t,i.key);l.push(i),c.push(u),i=0>=u?i.left:i.right}l.push(new n(v,t,e,null,null,1));for(var f=l.length-2;f>=0;--f){var i=l[f];c[f]<=0?l[f]=new n(i._color,i.key,i.value,l[f+1],i.right,i._count+1):l[f]=new n(i._color,i.key,i.value,i.left,l[f+1],i._count+1)}for(var f=l.length-1;f>1;--f){var h=l[f-1],i=l[f];if(h._color===m||i._color===m)break;var d=l[f-2];if(d.left===h)if(h.left===i){var p=d.right;if(!p||p._color!==v){if(d._color=v,d.left=h.right,h._color=m,h.right=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.left===d?g.left=h:g.right=h}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else{var p=d.right;if(!p||p._color!==v){if(h.right=i.left,d._color=v,d.left=i.right,i._color=m,i.left=h,i.right=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.left===d?g.left=i:g.right=i}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else if(h.right===i){var p=d.left;if(!p||p._color!==v){if(d._color=v,d.right=h.left,h._color=m,h.left=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.right===d?g.right=h:g.left=h}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}else{var p=d.left;if(!p||p._color!==v){if(h.left=i.right,d._color=v,d.right=i.left,i._color=m,i.right=h,i.left=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.right===d?g.right=i:g.left=i}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}}return l[0]._color=m,new s(r,l[0])},y.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return l(t,this.root);case 2:return c(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return u(e,r,this._compare,t,this.root)}},Object.defineProperty(y,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(y,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),y.at=function(t){if(0>t)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},y.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>=a&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>a&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new f(this,n);r=0>=i?r.left:r.right}return new f(this,[])},y.remove=function(t){var e=this.find(t);return e?e.remove():this},y.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=0>=n?r.left:r.right}};var b=f.prototype;Object.defineProperty(b,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(b,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),b.clone=function(){return new f(this.tree,this._stack.slice())},b.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new n(r._color,r.key,r.value,r.left,r.right,r._count);for(var i=t.length-2;i>=0;--i){var r=t[i];r.left===t[i+1]?e[i]=new n(r._color,r.key,r.value,e[i+1],r.right,r._count):e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count)}if(r=e[e.length-1],r.left&&r.right){var a=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var o=e[a-1];e.push(new n(r._color,o.key,o.value,r.left,r.right,r._count)),e[a-1].key=r.key,e[a-1].value=r.value;for(var i=e.length-2;i>=a;--i)r=e[i],e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count);e[a-1].left=e[a]}if(r=e[e.length-1],r._color===v){var l=e[e.length-2];l.left===r?l.left=null:l.right===r&&(l.right=null),e.pop();for(var i=0;i0?this._stack[this._stack.length-1].key:void 0},enumerable:!0}),Object.defineProperty(b,"value",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1].value:void 0},enumerable:!0}),Object.defineProperty(b,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),b.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),b.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),i=e[e.length-1];r[r.length-1]=new n(i._color,i.key,t,i.left,i.right,i._count);for(var a=e.length-2;a>=0;--a)i=e[a],i.left===e[a+1]?r[a]=new n(i._color,i.key,i.value,r[a+1],i.right,i._count):r[a]=new n(i._color,i.key,i.value,i.left,r[a+1],i._count);return new s(this.tree._compare,r[0])},b.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],292:[function(t,e,r){"use strict";function n(t,e,r){this.slabs=t,this.coordinates=e,this.horizontal=r}function i(t,e){return t.y-e}function a(t,e){for(var r=null;t;){var n,i,o=t.key;o[0][0]s)t=t.left;else if(s>0)if(e[0]!==o[1][0])r=t,t=t.right;else{var l=a(t.right,e);if(l)return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l=a(t.right,e);if(l)return l;t=t.left}}return r}function o(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function s(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}function l(t){for(var e=t.length,r=2*e,i=new Array(r),a=0;e>a;++a){var l=t[a],c=l[0][0]a;){for(var v=i[a].x,m=[];r>a;){var y=i[a];if(y.x!==v)break;a+=1,y.segment[0][0]===y.x&&y.segment[1][0]===y.x?y.create&&(y.segment[0][1]e)return-1;var r=(this.slabs[e],a(this.slabs[e],t)),n=-1;if(r&&(n=r.value),this.coordinates[e]===t[0]){var o=null;if(r&&(o=r.key),e>0){var s=a(this.slabs[e-1],t);s&&(o?h(s.key,o)>0&&(o=s.key,n=s.value):(n=s.value,o=s.key))}var l=this.horizontal[e];if(l.length>0){var u=c.ge(l,t[1],i);if(u=l.length)return n;d=l[u]}}if(d.start)if(o){var p=f(o[0],o[1],[t[0],d.y]);o[0][0]>o[1][0]&&(p=-p),p>0&&(n=d.index)}else n=d.index;else d.y!==t[1]&&(n=d.index)}}}return n}},{"./lib/order-segments":290,"binary-search-bounds":288,"functional-red-black-tree":291,"robust-orientation":259}],293:[function(t,e,r){function n(){return!0}function i(t){return function(e,r){var i=t[e];return i?!!i.queryPoint(r,n):!1}}function a(t){for(var e={},r=0;rn)return 1;var i=t[n];if(!i){if(!(n>0&&e[n]===r[0]))return 1;i=t[n-1]}for(var a=1;i;){var o=i.key,s=f(r,o[0],o[1]);if(o[0][0]s)i=i.left;else{if(!(s>0))return 0;a=-1,i=i.right}else if(s>0)i=i.left;else{if(!(0>s))return 0;a=1,i=i.right}}return a}}function s(t){return 1}function l(t){return function(e){return t(e[0],e[1])?0:1}}function c(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}function u(t){for(var e=t.length,r=[],n=[],i=0;e>i;++i)for(var u=t[i],f=u.length,d=f-1,p=0;f>p;d=p++){var g=u[d],v=u[p];g[0]===v[0]?n.push([g,v]):r.push([g,v]); +}if(0===r.length)return 0===n.length?s:l(a(n));var m=h(r),y=o(m.slabs,m.coordinates);return 0===n.length?y:c(a(n),y)}e.exports=u;var f=t("robust-orientation")[3],h=t("slab-decomposition"),d=t("interval-tree-1d"),p=t("binary-search-bounds")},{"binary-search-bounds":288,"interval-tree-1d":289,"robust-orientation":259,"slab-decomposition":292}],294:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function i(t){for(var e=new Array(t),r=0;t>r;++r)e[r]=[];return e}function a(t,e){function r(t){for(var r=t.length,n=[0],i=0;r>i;++i){var a=e[t[i]],o=e[t[(i+1)%r]],s=c(-a[0],a[1]),l=c(-a[0],o[1]),f=c(o[0],a[1]),h=c(o[0],o[1]);n=u(n,u(u(s,l),u(f,h)))}return n[n.length-1]>0}function a(t){for(var e=t.length,r=0;e>r;++r)if(!O[t[r]])return!1;return!0}var d=h(t,e);t=d[0],e=d[1];for(var p=e.length,g=(t.length,o(t,e.length)),v=0;p>v;++v)if(g[v].length%2===1)throw new Error("planar-graph-to-polyline: graph must be manifold");var m=s(t,e);m=m.filter(r);for(var y=m.length,b=new Array(y),x=new Array(y),v=0;y>v;++v){b[v]=v;var _=new Array(y),w=m[v].map(function(t){return e[t]}),k=l([w]),A=0;t:for(var M=0;y>M;++M)if(_[M]=0,v!==M){for(var T=m[M],E=T.length,L=0;E>L;++L){var S=k(e[T[L]]);if(0!==S){0>S&&(_[M]=1,A+=1);continue t}}_[M]=1,A+=1}x[v]=[A,v,_]}x.sort(function(t,e){return e[0]-t[0]});for(var v=0;y>v;++v)for(var _=x[v],C=_[1],z=_[2],M=0;y>M;++M)z[M]&&(b[M]=C);for(var P=i(y),v=0;y>v;++v)P[v].push(b[v]),P[b[v]].push(v);for(var R={},O=n(p,!1),v=0;y>v;++v)for(var T=m[v],E=T.length,M=0;E>M;++M){var I=T[M],N=T[(M+1)%E],j=Math.min(I,N)+":"+Math.max(I,N);if(j in R){var F=R[j];P[F].push(v),P[v].push(F),O[I]=O[N]=!0}else R[j]=v}for(var D=[],B=n(y,-1),v=0;y>v;++v)b[v]!==v||a(m[v])?B[v]=-1:(D.push(v),B[v]=0);for(var d=[];D.length>0;){var U=D.pop(),V=P[U];f(V,function(t,e){return t-e});var q,H=V.length,G=B[U];if(0===G){var T=m[U];q=[T]}for(var v=0;H>v;++v){var Y=V[v];if(!(B[Y]>=0)&&(B[Y]=1^G,D.push(Y),0===G)){var T=m[Y];a(T)||(T.reverse(),q.push(T))}}0===G&&d.push(q)}return d}e.exports=a;var o=t("edges-to-adjacency-list"),s=t("planar-dual"),l=t("point-in-big-polygon"),c=t("two-product"),u=t("robust-sum"),f=t("uniq"),h=t("./lib/trim-leaves")},{"./lib/trim-leaves":282,"edges-to-adjacency-list":283,"planar-dual":284,"point-in-big-polygon":293,"robust-sum":262,"two-product":276,uniq:279}],295:[function(t,e,r){arguments[4][50][0].apply(r,arguments)},{dup:50}],296:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;t>e;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n,n.prototype.length=function(){return this.roots.length},n.prototype.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},n.prototype.find=function(t){for(var e=this.roots;e[t]!==t;){var r=e[t];e[t]=e[r],t=r}return t},n.prototype.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],297:[function(t,e,r){arguments[4][238][0].apply(r,arguments)},{"bit-twiddle":295,dup:238,"union-find":296}],298:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.abs(a(t,e,r)),i=Math.sqrt(Math.pow(e[0]-r[0],2)+Math.pow(e[1]-r[1],2));return n/i}function i(t,e,r){function i(t){if(x[t])return 1/0;var r=m[t],i=y[t];return 0>r||0>i?1/0:n(e[t],e[r],e[i])}function a(t,e){var r=M[t],n=M[e];M[t]=n,M[e]=r,T[r]=e,T[n]=t}function s(t){return b[M[t]]}function l(t){return 1&t?t-1>>1:(t>>1)-1}function c(t){for(var e=s(t);;){var r=e,n=2*t+1,i=2*(t+1),o=t;if(L>n){var l=s(n);r>l&&(o=n,r=l)}if(L>i){var c=s(i);r>c&&(o=i)}if(o===t)return t;a(t,o),t=o}}function u(t){for(var e=s(t);t>0;){var r=l(t);if(r>=0){var n=s(r);if(n>e){a(t,r),t=r;continue}}return t}}function f(){if(L>0){var t=M[0];return a(0,L-1),L-=1,c(0),t}return-1}function h(t,e){var r=M[t];return b[r]===e?t:(b[r]=-(1/0),u(t),f(),b[r]=e,L+=1,u(L-1))}function d(t){if(!x[t]){x[t]=!0;var e=m[t],r=y[t];m[r]>=0&&(m[r]=e),y[e]>=0&&(y[e]=r),T[e]>=0&&h(T[e],i(e)),T[r]>=0&&h(T[r],i(r))}}function p(t,e){if(t[e]<0)return e;var r=e,n=e;do{var i=t[n];if(!x[n]||0>i||i===n)break;if(n=i,i=t[n],!x[n]||0>i||i===n)break;n=i,r=t[r]}while(r!==n);for(var a=e;a!==n;a=t[a])t[a]=n;return n}for(var g=e.length,v=t.length,m=new Array(g),y=new Array(g),b=new Array(g),x=new Array(g),_=0;g>_;++_)m[_]=y[_]=-1,b[_]=1/0,x[_]=!1;for(var _=0;v>_;++_){var w=t[_];if(2!==w.length)throw new Error("Input must be a graph");var k=w[1],A=w[0];-1!==y[A]?y[A]=-2:y[A]=k,-1!==m[k]?m[k]=-2:m[k]=A}for(var M=[],T=new Array(g),_=0;g>_;++_){var E=b[_]=i(_);1/0>E?(T[_]=M.length,M.push(_)):T[_]=-1}for(var L=M.length,_=L>>1;_>=0;--_)c(_);for(;;){var S=f();if(0>S||b[S]>r)break;d(S)}for(var C=[],_=0;g>_;++_)x[_]||(T[_]=C.length,C.push(e[_].slice()));var z=(C.length,[]);return t.forEach(function(t){var e=p(m,t[0]),r=p(y,t[1]);if(e>=0&&r>=0&&e!==r){var n=T[e],i=T[r];n!==i&&z.push([n,i])}}),o.unique(o.normalize(z)),{positions:C,edges:z}}e.exports=i;var a=t("robust-orientation"),o=t("simplicial-complex")},{"robust-orientation":259,"simplicial-complex":297}],299:[function(t,e,r){"use strict";e.exports=["",{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],300:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:o({},i,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":377,"../../plots/cartesian/constants":410,"../../plots/font_attributes":423,"./arrow_paths":299}],301:[function(t,e,r){"use strict";function n(t,e){function r(e,r){return c.coerce(t,n,v.layoutAttributes,e,r)}var n={};r("opacity"),r("align"),r("bgcolor");var i=r("bordercolor"),a=f.opacity(i);r("borderpad");var o=r("borderwidth"),s=r("showarrow");s&&(r("arrowcolor",a?n.bordercolor:f.defaultLine),r("arrowhead"),r("arrowsize"),r("arrowwidth",2*(a&&o||1)),r("ax"),r("ay"),c.noneOrAll(t,n,["ax","ay"])),r("text",s?" ":"new text"),r("textangle"),c.coerceFont(r,"font",e.font);for(var l=["x","y"],h=0;2>h;h++){var d=l[h],p={_fullLayout:e},g=u.coerceRef(t,n,p,d),m=.5;if("paper"!==g){var y=u.getFromId(p,g);if(m=y.range[0]+m*(y.range[1]-y.range[0]),-1!==["date","category"].indexOf(y.type)&&"string"==typeof t[d]){var b;"date"===y.type?(b=c.dateTime2ms(t[d]),b!==!1&&(t[d]=b)):(y._categories||[]).length&&(b=y._categories.indexOf(t[d]),-1!==b&&(t[d]=b))}}r(d,m),s||r(d+"anchor")}return c.noneOrAll(t,n,["x","y"]),n}function i(t){var e=t._fullLayout;e.annotations.forEach(function(e){var r=u.getFromId(t,e.xref),n=u.getFromId(t,e.yref);if(r||n){var i=(e._xsize||0)/2,a=e._xshift||0,o=(e._ysize||0)/2,s=e._yshift||0,l=i-a,c=i+a,f=o-s,h=o+s;if(e.showarrow){var d=3*e.arrowsize*e.arrowwidth;l=Math.max(l,d),c=Math.max(c,d),f=Math.max(f,d),h=Math.max(h,d)}r&&r.autorange&&u.expand(r,[r.l2c(e.x)],{ppadplus:c,ppadminus:l}),n&&n.autorange&&u.expand(n,[n.l2c(e.y)],{ppadplus:h,ppadminus:f})}})}function a(t,e,r,n,i,a,o,s){var l=r-t,c=i-t,u=o-i,f=n-e,h=a-e,d=s-a,p=l*d-u*f;if(0===p)return null;var g=(c*d-u*h)/p,v=(c*f-l*h)/p;return 0>v||v>1||0>g||g>1?null:{x:t+l*g,y:e+f*g}}var o=t("d3"),s=t("fast-isnumeric"),l=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),h=t("../drawing"),d=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var r=t.annotations||[],i=e.annotations=[],a=0;at?"left":t>2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var n=W.select(".annotation-math-group"),i=!n.empty(),s=h.bBox((i?n:tt).node()),d=s.width,m=s.height,y=Math.round(d+2*$),b=Math.round(m+2*$);U._w=d,U._h=m;var x=!1;if(["x","y"].forEach(function(e){var n,i=u.getFromId(t,U[e+"ref"]||e),a=(G+("x"===e?0:90))*Math.PI/180,o=y*Math.abs(Math.cos(a))+b*Math.abs(Math.sin(a)),s=U[e+"anchor"];if(i){if(!i.autorange&&(U[e]-i.range[0])*(U[e]-i.range[1])>0)return void(x=!0);H[e]=i._offset+i.l2p(U[e]),n=.5}else n=U[e],"y"===e&&(n=1-n),H[e]="x"===e?S.l+S.w*n:S.t+S.h*n;var l=0;l=U.showarrow?U["a"+e]:o*r(n,s),H[e]+=l,U["_"+e+"type"]=i&&i.type,U["_"+e+"size"]=o,U["_"+e+"shift"]=l}),x)return void W.remove();var w,k;U.showarrow&&(w=c.constrain(H.x-U.ax,1,_.width-1),k=c.constrain(H.y-U.ay,1,_.height-1)),H.x=c.constrain(H.x,1,_.width-1),H.y=c.constrain(H.y,1,_.height-1);var A=$-s.top,M=$-s.left;i?n.select("svg").attr({x:$-1,y:$}):(tt.attr({x:M,y:A}),tt.selectAll("tspan.line").attr({y:A,x:M})),Q.call(h.setRect,Z/2,Z/2,y-Z,b-Z);var T=Math.round(H.x-y/2),E=Math.round(H.y-b/2);W.call(c.setTranslate,T,E);var L="annotations["+e+"]",C=function(r,n){o.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var i=H.x+r,s=H.y+n,u=c.rotationXYMatrix(G,i,s),h=c.apply2DTransform(u),d=c.apply2DTransform2(u),p=Q.attr("width")/2,m=Q.attr("height")/2,y=[[i-p,s-m,i-p,s+m],[i-p,s+m,i+p,s+m],[i+p,s+m,i+p,s-m],[i+p,s-m,i-p,s-m]].map(d);if(!y.reduce(function(t,e){return t^!!a(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=a(i,s,w,k,t[0],t[1],t[2],t[3]);e&&(i=e.x,s=e.y)});var b=U.arrowwidth,x=U.arrowcolor,_=Y.append("g").style({opacity:f.opacity(x)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),A=_.append("path").attr("d","M"+i+","+s+"L"+w+","+k).style("stroke-width",b+"px").call(f.stroke,f.rgb(x));v.arrowhead(A,U.arrowhead,"end",U.arrowsize);var M=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(i-w)+","+(s-k),transform:"translate("+w+","+k+")"}).style("stroke-width",b+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var T,E,C;g.init({element:M.node(),prepFn:function(){var t=c.getTranslate(W);E=t.x,C=t.y,T={},V&&V.autorange&&(T[V._name+".autorange"]=!0),q&&q.autorange&&(T[q._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var r=h(E,C),n=r[0]+t,i=r[1]+e;W.call(c.setTranslate,n,i),T[L+".x"]=V?U.x+t/V._m:(w+t-S.l)/S.w,T[L+".y"]=q?U.y+e/q._m:1-(k+e-S.t)/S.h,X.attr({transform:"rotate("+G+","+n+","+i+")"})},doneFn:function(e){if(e){l.relayout(t,T);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}};U.showarrow&&C(0,0);var z=c.rotationXYMatrix(G,H.x,H.y),P=c.apply2DTransform(z);if(t._context.editable){var R,O,I;g.init({element:W.node(),prepFn:function(){var t=c.getTranslate(W);R=t.x,O=t.y,I={}},moveFn:function(t,e){W.call(c.setTranslate,R+t,O+e);var r="pointer";if(U.showarrow)I[L+".ax"]=U.ax+t,I[L+".ay"]=U.ay+e,C(t,e);else{if(V)I[L+".x"]=U.x+t/V._m;else{var n=U._xsize/S.w,i=U.x+U._xshift/S.w-n/2;I[L+".x"]=g.align(i+t/S.w,n,0,1,U.xanchor)}if(q)I[L+".y"]=U.y+e/q._m;else{var a=U._ysize/S.h,o=U.y-U._yshift/S.h-a/2;I[L+".y"]=g.align(o-e/S.h,a,0,1,U.yanchor)}V&&q||(r=g.getCursor(V?.5:I[L+".x"],q?.5:I[L+".y"],U.xanchor,U.yanchor))}var s=P(R,O),l=s[0]+t,u=s[1]+e;W.call(c.setTranslate,R+t,O+e),X.attr({transform:"rotate("+G+","+l+","+u+")"}),p(W,r)},doneFn:function(e){if(p(W),e){l.relayout(t,I);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}var b,x=t.layout,_=t._fullLayout;if(!s(e)||-1===e){if(!e&&Array.isArray(i))return x.annotations=i,v.supplyLayoutDefaults(x,_),void v.drawAll(t);if("remove"===i)return delete x.annotations,_.annotations=[],void v.drawAll(t);if(r&&"add"!==i){for(b=0;b<_.annotations.length;b++)v.draw(t,b,r,i);return}e=_.annotations.length,_.annotations.push({})}if(!r&&i){if("remove"===i){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),x.annotations.splice(e,1),b=e;b<_.annotations.length;b++)_._infolayer.selectAll('.annotation[data-index="'+(b+1)+'"]').attr("data-index",String(b)),v.draw(t,b);return}if("add"===i||c.isPlainObject(i)){_.annotations.splice(e,0,{});var w=c.isPlainObject(i)?c.extendFlat({},i):{text:"New text"};for(x.annotations?x.annotations.splice(e,0,w):x.annotations=[w],b=_.annotations.length-1;b>e;b--)_._infolayer.selectAll('.annotation[data-index="'+(b-1)+'"]').attr("data-index",String(b)),v.draw(t,b)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=x.annotations[e],A=_.annotations[e];if(k){var M={xref:k.xref,yref:k.yref},T={};"string"==typeof r&&r?T[r]=i:c.isPlainObject(r)&&(T=r);var E=Object.keys(T);for(b=0;bb;b++){var z=C[b];if(void 0===T[z]&&void 0!==k[z]){var P=u.getFromId(t,u.coerceRef(M,{},t,z)),R=u.getFromId(t,u.coerceRef(k,{},t,z)),O=k[z],I=A["_"+z+"type"];if(void 0!==T[z+"ref"]){var N="auto"===k[z+"anchor"],j="x"===z?S.w:S.h,F=(A["_"+z+"size"]||0)/(2*j);if(P&&R)O=(O-P.range[0])/(P.range[1]-P.range[0]),O=R.range[0]+O*(R.range[1]-R.range[0]);else if(P){if(O=(O-P.range[0])/(P.range[1]-P.range[0]),O=P.domain[0]+O*(P.domain[1]-P.domain[0]),N){var D=O+F,B=O-F;2/3>O+B?O=B:O+D>4/3&&(O=D)}}else R&&(N&&(1/3>O?O+=F:O>2/3&&(O-=F)),O=(O-R.domain[0])/(R.domain[1]-R.domain[0]),O=R.range[0]+O*(R.range[1]-R.range[0]))}R&&R===P&&I&&("log"===I&&"log"!==R.type?O=Math.pow(10,O):"log"!==I&&"log"===R.type&&(O=O>0?Math.log(O)/Math.LN10:void 0)),k[z]=O}}var U=n(k,_);_.annotations[e]=U;var V=u.getFromId(t,U.xref),q=u.getFromId(t,U.yref),H={x:0,y:0},G=+U.textangle||0,Y=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",U.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:U})}),X=Y.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),W=X.append("g"),Z=U.borderwidth,K=U.borderpad,$=Z+K,Q=W.append("rect").attr("class","bg").style("stroke-width",Z+"px").call(f.stroke,U.bordercolor).call(f.fill,U.bgcolor),J=U.font,tt=W.append("text").classed("annotation",!0).attr("data-unformatted",U.text).text(U.text);t._context.editable?tt.call(d.makeEditable,W).call(m).on("edit",function(r){U.text=r,this.attr({"data-unformatted":U.text}),this.call(m);var n={};n["annotations["+e+"].text"]=U.text,V&&V.autorange&&(n[V._name+".autorange"]=!0),q&&q.autorange&&(n[q._name+".autorange"]=!0),l.relayout(t,n)}):tt.call(m),X.attr({transform:"rotate("+G+","+H.x+","+H.y+")"}).call(h.setPosition,H.x,H.y)}},v.arrowhead=function(t,e,r,n){s(n)||(n=1);var i=t.node(),a=v.ARROWPATHS[e||0];if(a){"string"==typeof r&&r||(r="end");var l,c,u,d,p=(h.getPx(t,"stroke-width")||1)*n,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=r.indexOf("start")>=0,b=r.indexOf("end")>=0,x=a.backoff*p;if("line"===i.nodeName){if(l={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(l.y-c.y,l.x-c.x),d=u+Math.PI,x){var _=x*Math.cos(u),w=x*Math.sin(u);y&&(l.x-=_,l.y-=w,t.attr({x1:l.x,y1:l.y})),b&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===i.nodeName){var k=i.getTotalLength(),A="";if(y){var M=i.getPointAtLength(0),T=i.getPointAtLength(.1);u=Math.atan2(M.y-T.y,M.x-T.x),l=i.getPointAtLength(Math.min(x,k)),x&&(A="0px,"+x+"px,")}if(b){var E=i.getPointAtLength(k),L=i.getPointAtLength(k-.1);if(d=Math.atan2(E.y-L.y,E.x-L.x),c=i.getPointAtLength(Math.max(0,k-x)),x){var S=A?2*x:x;A+=k-S+"px,"+k+"px"}}else A&&(A+=k+"px");A&&t.style("stroke-dasharray",A)}var C=function(r,n){e>5&&(n=0),o.select(i.parentElement).append("path").attr({"class":t.attr("class"),d:a.path,transform:"translate("+r.x+","+r.y+")rotate("+180*n/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(l,u),b&&C(c,d)}},v.calcAutorange=function(t){var e=t._fullLayout,r=e.annotations;if(r.length&&t._fullData.length){var n={};r.forEach(function(t){n[t.xref]=!0,n[t.yref]=!0});var a=u.list(t).filter(function(t){return t.autorange&&n[t._id]});if(a.length)return c.syncOrAsync([v.drawAll,i],t)}}},{"../../lib":382,"../../lib/setcursor":391,"../../lib/svg_text_utils":395,"../../plotly":402,"../../plots/cartesian/axes":405,"../color":303,"../dragelement":324,"../drawing":326,"./arrow_paths":299,"./attributes":300,d3:113,"fast-isnumeric":117}],302:[function(t,e,r){"use strict";r.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],r.defaultLine="#444",r.lightLine="#eee",r.background="#fff",r.lightFraction=1e3/11},{}],303:[function(t,e,r){"use strict";function n(t){if(a(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var r=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!r)return t;var n=r[1].trim().split(/\s*[\s,]\s*/),i="a"===e.charAt(3)&&4===n.length;if(!i&&3!==n.length)return t;for(var o=0;o=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}var i=t("tinycolor2"),a=t("fast-isnumeric"),o=e.exports={},s=t("./attributes");o.defaults=s.defaults,o.defaultLine=s.defaultLine,o.lightLine=s.lightLine,o.background=s.background,o.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},o.rgb=function(t){return o.tinyRGB(i(t))},o.opacity=function(t){return t?i(t).getAlpha():0},o.addOpacity=function(t,e){var r=i(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},o.combine=function(t,e){var r=i(t).toRgb();if(1===r.a)return i(t).toRgbString();var n=i(e||o.background).toRgb(),a=1===n.a?n:{r:255*(1-n.a)+n.r*n.a,g:255*(1-n.a)+n.g*n.a,b:255*(1-n.a)+n.b*n.a},s={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return i(s).toRgbString()},o.stroke=function(t,e){var r=i(e);t.style({stroke:o.tinyRGB(r),"stroke-opacity":r.getAlpha()})},o.fill=function(t,e){var r=i(e);t.style({fill:o.tinyRGB(r),"fill-opacity":r.getAlpha()})},o.clean=function(t){if(t&&"object"==typeof t){var e,r,i,a,s=Object.keys(t);for(e=0;el&&(a[1]-=(ot-l)/2)):r.node()&&!r.classed("js-placeholder")&&(ot=h.bBox(e.node()).height),ot){if(ot+=5,"top"===x.titleside)Q.domain[1]-=ot/M.h,a[1]*=-1;else{Q.domain[0]+=ot/M.h;var u=Math.max(1,r.selectAll("tspan.line").size());a[1]+=(1-u)*l}e.attr("transform","translate("+a+")"),Q.setScale()}}it.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(M.h*(1-Q.domain[1]))+")");var f=it.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var r=[0===e?E[0]:(S[e]+S[e-1])/2,e===S.length-1?E[1]:(S[e]+S[e+1])/2].map(Q.c2p).map(Math.round);e!==S.length-1&&(r[1]+=r[1]>r[0]?1:-1);var a=z(t).replace("e-",""),o=i(a).toHexString();n.select(this).attr({x:Y,width:Math.max(D,2),y:n.min(r),height:Math.max(n.max(r)-n.min(r),2),fill:o})});var d=it.select(".cblines").selectAll("path.cbline").data(x.line.color&&x.line.width?L:[]);return d.enter().append("path").classed("cbline",!0),d.exit().remove(),d.each(function(t){n.select(this).attr("d","M"+Y+","+(Math.round(Q.c2p(t))+x.line.width/2%1)+"h"+D).call(h.lineGroupStyle,x.line.width,C(t),x.line.dash)}),Q._axislayer.selectAll("g."+Q._id+"tick,path").remove(),Q._pos=Y+D+(x.outlinewidth||0)/2-("outside"===x.ticks?1:0),Q.side="right",c.syncOrAsync([function(){return s.doTicks(t,Q,!0)},function(){if(-1===["top","bottom"].indexOf(x.titleside)){var e=Q.titlefont.size,r=Q._offset+Q._length/2,i=M.l+(Q.position||0)*M.w+("right"===Q.side?10+e*(Q.showticklabels?1:.5):-10-e*(Q.showticklabels?.5:0));w("h"+Q._id+"title",{avoid:{selection:n.select(t).selectAll("g."+Q._id+"tick"),side:x.titleside,offsetLeft:M.l,offsetTop:M.t,maxShift:A.width},attributes:{x:i,y:r,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,r){var n,i=b();n=o.traceIs(i,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var a={propContainer:Q,propName:n,traceIndex:i.index,dfltName:"colorscale",containerGroup:it.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;it.selectAll("."+s+",."+s+"-math-group").remove(),p.draw(t,e,u(a,r||{}))}function k(){var r=D+x.outlinewidth/2+h.bBox(Q._axislayer.node()).width;if(N=at.select("text"),N.node()&&!N.classed("js-placeholder")){var n,i=at.select(".h"+Q._id+"title-math-group").node();n=i&&-1!==["top","bottom"].indexOf(x.titleside)?h.bBox(i).width:h.bBox(at.node()).right-Y-M.l,r=Math.max(r,n)}var a=2*x.xpad+r+x.borderwidth+x.outlinewidth/2,s=Z-K;it.select(".cbbg").attr({x:Y-x.xpad-(x.borderwidth+x.outlinewidth)/2,y:K-H,width:Math.max(a,2),height:Math.max(s+2*H,2)}).call(d.fill,x.bgcolor).call(d.stroke,x.bordercolor).style({"stroke-width":x.borderwidth}),it.selectAll(".cboutline").attr({x:Y,y:K+x.ypad+("top"===x.titleside?ot:0),width:Math.max(D,2),height:Math.max(s-2*x.ypad-ot,2)}).call(d.stroke,x.outlinecolor).style({fill:"None","stroke-width":x.outlinewidth});var l=({center:.5,right:1}[x.xanchor]||0)*a;it.attr("transform","translate("+(M.l-l)+","+M.t+")"),o.autoMargin(t,e,{x:x.x,y:x.y,l:a*({right:1,center:.5}[x.xanchor]||0),r:a*({left:1,center:.5}[x.xanchor]||0),t:s*({bottom:1,middle:.5}[x.yanchor]||0),b:s*({top:1,middle:.5}[x.yanchor]||0)})}var A=t._fullLayout,M=A._size;if("function"!=typeof x.fillcolor&&"function"!=typeof x.line.color)return void A._infolayer.selectAll("g."+e).remove();var T,E=n.extent(("function"==typeof x.fillcolor?x.fillcolor:x.line.color).domain()),L=[],S=[],C="function"==typeof x.line.color?x.line.color:function(){return x.line.color},z="function"==typeof x.fillcolor?x.fillcolor:function(){return x.fillcolor},P=x.levels.end+x.levels.size/100,R=x.levels.size,O=1.001*E[0]-.001*E[1],I=1.001*E[1]-.001*E[0];for(T=x.levels.start;0>(T-P)*R;T+=R)T>O&&I>T&&L.push(T);if("function"==typeof x.fillcolor)if(x.filllevels)for(P=x.filllevels.end+x.filllevels.size/100,R=x.filllevels.size,T=x.filllevels.start;0>(T-P)*R;T+=R)T>E[0]&&T1){var nt=Math.pow(10,Math.floor(Math.log(rt)/Math.LN10));tt*=nt*c.roundUp(rt/nt,[2,5,10]),(Math.abs(x.levels.start)/x.levels.size+1e-6)%1<2e-6&&(Q.tick0=0)}Q.dtick=tt}Q.domain=[W+G,W+V-G],Q.setScale();var it=A._infolayer.selectAll("g."+e).data([0]);it.enter().append("g").classed(e,!0).each(function(){var t=n.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),it.attr("transform","translate("+Math.round(M.l)+","+Math.round(M.t)+")");var at=it.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(M.l)+",-"+Math.round(M.t)+")");Q._axislayer=it.select(".cbaxis");var ot=0;if(-1!==["top","bottom"].indexOf(x.titleside)){var st,lt=M.l+(x.x+q)*M.w,ct=Q.titlefont.size;st="top"===x.titleside?(1-(W+V-G))*M.h+M.t+3+.75*ct:(1-(W+G))*M.h+M.t-3-.25*ct,w(Q._id+"title",{attributes:{x:lt,y:st,"text-anchor":"start"}})}var ut=c.syncOrAsync([o.previousPromises,_,o.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,ht,dt;l.init({element:it.node(),prepFn:function(){ft=it.attr("transform"),f(it)},moveFn:function(t,e){it.attr("transform",ft+" translate("+t+","+e+")"),ht=l.align(X+t/M.w,B,0,1,x.xanchor),dt=l.align(W-e/M.h,V,0,1,x.yanchor);var r=l.getCursor(ht,dt,x.xanchor,x.yanchor);f(it,r)},doneFn:function(e){f(it),e&&void 0!==ht&&void 0!==dt&&a.restyle(t,{"colorbar.x":ht,"colorbar.y":dt},b().index)}})}return ut}function b(){var r,n,i=e.substr(2);for(r=0;ru*f?i.RdBu:u>=0?i.Reds:i.Blues,l.colorscale=h,s.reversescale&&(h=a(h)),s.colorscale=h)}},{"../../lib":382,"./flip_scale":314,"./scales":321}],311:[function(t,e,r){"use strict";var n=t("./attributes"),i=t("../../lib/extend").extendDeep;e.exports=function(t){return{color:{valType:"color",arrayOk:!0},colorscale:i({},n.colorscale,{}),cauto:i({},n.zauto,{}),cmax:i({},n.zmax,{}),cmin:i({},n.zmin,{}),autocolorscale:i({},n.autocolorscale,{}),reversescale:i({},n.reversescale,{})}}},{"../../lib/extend":377,"./attributes":309}],312:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":321}],313:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,c,u){var f=u.prefix,h=u.cLetter,d=f.slice(0,f.length-1),p=f?i.nestedProperty(t,d).get()||{}:t,g=f?i.nestedProperty(e,d).get()||{}:e,v=p[h+"min"],m=p[h+"max"],y=p.colorscale,b=n(v)&&n(m)&&m>v;c(f+h+"auto",!b),c(f+h+"min"),c(f+h+"max");var x;void 0!==y&&(x=!s(y)),c(f+"autocolorscale",x);var _=c(f+"colorscale"),w=c(f+"reversescale");if(w&&(g.colorscale=l(_)),"marker.line."!==f){var k;f&&(k=a(p));var A=c(f+"showscale",k);A&&o(p,g,r)}}},{"../../lib":382,"../colorbar/defaults":305,"../colorbar/has_colorbar":307,"./flip_scale":314,"./is_valid_scale":318,"fast-isnumeric":117}],314:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=t.length,n=new Array(r),i=r-1,a=0;i>=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],315:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return e||(e=i),t?("string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e):e}},{"./default_scale":312,"./is_valid_scale_array":319,"./scales":321}],316:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(Array.isArray(o))for(var l=0;lh;h++)l=t[h],u[h]=e+l[0]*(r-e),f[h]=i(l[1]).toRgb();var d=n.scale.linear().domain(u).interpolate(n.interpolateObject).range(f);return function(t){if(a(t)){var n=o.constrain(t,e,r),l=d(n);return i(l).toRgbString()}return i(t).isValid()?t:s.defaultLine}}},{"../../lib":382,"../color":303,d3:113,"fast-isnumeric":117,tinycolor2:274}],321:[function(t,e,r){"use strict";e.exports={Greys:[[0,"rgb(0,0,0)"],[1,"rgb(255,255,255)"]],YlGnBu:[[0,"rgb(8,29,88)"],[.125,"rgb(37,52,148)"],[.25,"rgb(34,94,168)"],[.375,"rgb(29,145,192)"],[.5,"rgb(65,182,196)"],[.625,"rgb(127,205,187)"],[.75,"rgb(199,233,180)"],[.875,"rgb(237,248,217)"],[1,"rgb(255,255,217)"]],Greens:[[0,"rgb(0,68,27)"],[.125,"rgb(0,109,44)"],[.25,"rgb(35,139,69)"],[.375,"rgb(65,171,93)"],[.5,"rgb(116,196,118)"],[.625,"rgb(161,217,155)"],[.75,"rgb(199,233,192)"],[.875,"rgb(229,245,224)"],[1,"rgb(247,252,245)"]],YlOrRd:[[0,"rgb(128,0,38)"],[.125,"rgb(189,0,38)"],[.25,"rgb(227,26,28)"],[.375,"rgb(252,78,42)"],[.5,"rgb(253,141,60)"],[.625,"rgb(254,178,76)"],[.75,"rgb(254,217,118)"],[.875,"rgb(255,237,160)"],[1,"rgb(255,255,204)"]],Bluered:[[0,"rgb(0,0,255)"],[1,"rgb(255,0,0)"]],RdBu:[[0,"rgb(5,10,172)"],[.35,"rgb(106,137,247)"],[.5,"rgb(190,190,190)"],[.6,"rgb(220,170,132)"],[.7,"rgb(230,145,90)"],[1,"rgb(178,10,28)"]],Reds:[[0,"rgb(220,220,220)"],[.2,"rgb(245,195,157)"],[.4,"rgb(245,160,105)"],[1,"rgb(178,10,28)"]],Blues:[[0,"rgb(5,10,172)"],[.35,"rgb(40,60,190)"],[.5,"rgb(70,100,245)"],[.6,"rgb(90,120,245)"],[.7,"rgb(106,137,247)"],[1,"rgb(220,220,220)"]],Picnic:[[0,"rgb(0,0,255)"],[.1,"rgb(51,153,255)"],[.2,"rgb(102,204,255)"],[.3,"rgb(153,204,255)"],[.4,"rgb(204,204,255)"],[.5,"rgb(255,255,255)"],[.6,"rgb(255,204,255)"],[.7,"rgb(255,153,255)"],[.8,"rgb(255,102,204)"],[.9,"rgb(255,102,102)"],[1,"rgb(255,0,0)"]],Rainbow:[[0,"rgb(150,0,90)"],[.125,"rgb(0,0,200)"],[.25,"rgb(0,25,255)"],[.375,"rgb(0,152,255)"],[.5,"rgb(44,255,150)"],[.625,"rgb(151,255,0)"],[.75,"rgb(255,234,0)"],[.875,"rgb(255,111,0)"],[1,"rgb(255,0,0)"]],Portland:[[0,"rgb(12,51,131)"],[.25,"rgb(10,136,186)"],[.5,"rgb(242,211,56)"],[.75,"rgb(242,143,56)"],[1,"rgb(217,30,30)"]],Jet:[[0,"rgb(0,0,131)"],[.125,"rgb(0,60,170)"],[.375,"rgb(5,255,255)"],[.625,"rgb(255,255,0)"],[.875,"rgb(250,0,0)"],[1,"rgb(128,0,0)"]],Hot:[[0,"rgb(0,0,0)"],[.3,"rgb(230,0,0)"],[.6,"rgb(255,210,0)"],[1,"rgb(255,255,255)"]],Blackbody:[[0,"rgb(0,0,0)"],[.2,"rgb(230,0,0)"],[.4,"rgb(230,210,0)"],[.7,"rgb(255,255,255)"],[1,"rgb(160,200,255)"]],Earth:[[0,"rgb(0,0,130)"],[.1,"rgb(0,180,180)"],[.2,"rgb(40,210,40)"],[.4,"rgb(230,230,50)"],[.6,"rgb(120,70,20)"],[1,"rgb(255,255,255)"]],Electric:[[0,"rgb(0,0,0)"],[.15,"rgb(30,0,100)"],[.4,"rgb(120,0,100)"],[.6,"rgb(160,90,0)"],[.8,"rgb(230,200,0)"],[1,"rgb(255,250,220)"]],Viridis:[[0,"#440154"],[.06274509803921569,"#48186a"],[.12549019607843137,"#472d7b"],[.18823529411764706,"#424086"],[.25098039215686274,"#3b528b"],[.3137254901960784,"#33638d"],[.3764705882352941,"#2c728e"],[.4392156862745098,"#26828e"],[.5019607843137255,"#21918c"],[.5647058823529412,"#1fa088"],[.6274509803921569,"#28ae80"],[.6901960784313725,"#3fbc73"],[.7529411764705882,"#5ec962"],[.8156862745098039,"#84d44b"],[.8784313725490196,"#addc30"],[.9411764705882353,"#d8e219"],[1,"#fde725"]]}},{}],322:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i){var a=(t-r)/(n-r),o=a+e/(n-r),s=(a+o)/2;return"left"===i||"bottom"===i?a:"center"===i||"middle"===i?s:"right"===i||"top"===i?o:2/3-s>a?a:o>4/3-s?o:s}},{}],323:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":382}],324:[function(t,e,r){"use strict";function n(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function i(t){t._dragging=!1,t._replotPending&&a.plot(t)}var a=t("../../plotly"),o=t("../../lib"),s=t("../../plots/cartesian/constants"),l=e.exports={};l.align=t("./align"),l.getCursor=t("./cursor");var c=t("./unhover");l.unhover=c.wrapped,l.unhoverRaw=c.raw,l.init=function(t){function e(e){return p._dragged=!1,p._dragging=!0,c=e.clientX,u=e.clientY,d=e.target,f=(new Date).getTime(),f-p._mouseDownTimev&&(g=Math.max(g-1,1)),t.doneFn&&t.doneFn(p._dragged,g),!p._dragged){var r=document.createEvent("MouseEvents");r.initEvent("click",!0,!0),d.dispatchEvent(r)}return i(p),p._dragged=!1,o.pauseEvent(e)}var c,u,f,h,d,p=o.getPlotDiv(t.element)||{},g=1,v=s.DBLCLICKDELAY;p._mouseDownTime||(p._mouseDownTime=0),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":382,"../../plotly":402,"../../plots/cartesian/constants":410,"./align":322,"./cursor":323,"./unhover":325}],325:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=e.exports={};i.wrapped=function(t,e,r){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),i.raw(t,e,r)},i.raw=function(t,e){var r=t._fullLayout;e||(e={}),e.target&&n.triggerHandler(t,"plotly_beforehover",e)===!1||(r._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":376}],326:[function(t,e,r){"use strict";function n(t,e,r,n){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],c=Math.pow(a*a+o*o,x/2),u=Math.pow(s*s+l*l,x/2),f=(u*u*a-c*c*s)*n,h=(u*u*o-c*c*l)*n,d=3*u*(c+u),p=3*c*(c+u);return[[i.round(e[0]+(d&&f/d),2),i.round(e[1]+(d&&h/d),2)],[i.round(e[0]-(p&&f/p),2),i.round(e[1]-(p&&h/p),2)]]}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../plots/plots"),s=t("../color"),l=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../traces/scatter/subtypes"),d=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,r,n){e&&e.family&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},p.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},p.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},p.setRect=function(t,e,r,n,i){t.call(p.setPosition,e,r).call(p.setSize,n,i)},p.translatePoints=function(t,e,r){t.each(function(t){var n=t.xp||e.c2p(t.x),o=t.yp||r.c2p(t.y),s=i.select(this);a(n)&&a(o)?"text"===this.nodeName?s.attr("x",n).attr("y",o):s.attr("transform","translate("+n+","+o+")"):s.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:1>e?1:Math.round(e):r||0},p.lineGroupStyle=function(t,e,r,n){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=n||a.dash||"";i.select(this).call(s.stroke,r||a.color).call(p.dashLine,l,o)})},p.dashLine=function(t,e,r){var n=Math.max(r,3);"solid"===e?e="":"dot"===e?e=n+"px,"+n+"px":"dash"===e?e=3*n+"px,"+3*n+"px":"longdash"===e?e=5*n+"px,"+5*n+"px":"dashdot"===e?e=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===e&&(e=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var r=i.select(this);try{r.call(s.fill,e[0].trace.fillcolor)}catch(n){c.error(n,t),r.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var r=e.marker,n=r.line;if(o.traceIs(e,"symbols")){var a=d(e);t.attr("d",function(t){var n;n="various"===t.ms||"various"===r.size?3:h.isBubble(e)?a(t.ms):(r.size||6)/2,t.mrc=n;var i=p.symbolNumber(t.mx||r.symbol)||0,o=i%100;return t.om=i%200>=100,p.symbolFuncs[o](n)+(i>=200?m:"")}).style("opacity",function(t){return(t.mo+1||r.opacity+1)-1})}var l=(e._input||{}).marker||{},c=p.tryColorscale(r,l,""),u=p.tryColorscale(r,l,"line.");t.each(function(t){var e,a,o;t.so?(o=n.outlierwidth,a=n.outliercolor,e=r.outliercolor):(o=(t.mlw+1||n.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,a="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(n.color)?s.defaultLine:n.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(r.color)?s.defaultLine:r.color||"rgba(0,0,0,0)");var l=i.select(this);t.om?l.call(s.stroke,e).style({"stroke-width":(o||1)+"px",fill:"none"}):(l.style("stroke-width",o+"px").call(s.fill,e),o&&l.call(s.stroke,a))})}},p.tryColorscale=function(t,e,r){var n=c.nestedProperty(t,r+"color").get(),i=c.nestedProperty(t,r+"colorscale").get(),o=c.nestedProperty(t,r+"cauto").get(),s=c.nestedProperty(t,r+"cmin"),u=c.nestedProperty(t,r+"cmax"),f=s.get(),h=u.get();return i&&Array.isArray(n)?(!o&&a(f)&&a(h)||(f=1/0,h=-(1/0),n.forEach(function(t){a(t)&&(f>t&&(f=+t),t>h&&(h=+t))}),f>h&&(f=0,h=1),s.set(f),u.set(h),c.nestedProperty(e,r+"cmin").set(f),c.nestedProperty(e,r+"cmax").set(h)),l.makeScaleFunction(i,f,h)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},b=1.3;p.textPointStyle=function(t,e){t.each(function(t){var r=i.select(this),n=t.tx||e.text;if(!n||Array.isArray(n))return void r.remove();var o=t.tp||e.textposition,s=-1!==o.indexOf("top")?"top":-1!==o.indexOf("bottom")?"bottom":"middle",l=-1!==o.indexOf("left")?"end":-1!==o.indexOf("right")?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=a(c)&&c>0?c:0,r.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",l).text(n).call(u.convertToTspans);var h=i.select(this.parentNode),d=r.selectAll("tspan.line"),g=((d[0].length||1)-1)*b+1,v=y[l]*f,m=.75*c+y[s]*f+(y[s]-1)*g*c/2;h.attr("transform","translate("+v+","+m+")"),g>1&&d.attr({x:r.attr("x"),y:r.attr("y")})})};var x=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,i="M"+t[0],a=[];for(r=1;rr;r++)o.push(n(t[r-1],t[r],t[r+1],e));for(o.push(n(t[a-1],t[a],t[0],e)),r=1;a>=r;r++)i+="C"+o[r-1][1]+" "+o[r][0]+" "+t[r];return i+="C"+o[a][1]+" "+o[0][0]+" "+t[0]+"Z"};var _={hv:function(t,e){return"H"+i.round(e[0],2)+"V"+i.round(e[1],2)},vh:function(t,e){return"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},hvh:function(t,e){return"H"+i.round((t[0]+e[0])/2,2)+"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},vhv:function(t,e){return"V"+i.round((t[1]+e[1])/2,2)+"H"+i.round(e[0],2)+"V"+i.round(e[1],2)}},w=function(t,e){return"L"+i.round(e[0],2)+","+i.round(e[1],2)};p.steps=function(t){var e=_[t]||w;return function(t){for(var r="M"+i.round(t[0][0],2)+","+i.round(t[0][1],2),n=1;n=A&&(i.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(l),c.extendFlat({},l)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var r="#"+e,n=i.select("base");n.size()&&n.attr("href")&&(r=window.location.href+r),t.attr("clip-path","url("+r+")")}},{"../../constants/xmlns_namespaces":370,"../../lib":382,"../../lib/svg_text_utils":395,"../../plots/plots":454,"../../traces/scatter/make_bubble_size_func":569,"../../traces/scatter/subtypes":575,"../color":303,"../colorscale":317,"./symbol_defs":327,d3:113,"fast-isnumeric":117}],327:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+","+r+"H"+e+"L0,-"+i+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+",-"+r+"H"+e+"L0,"+i+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M"+r+",-"+e+"V"+e+"L-"+i+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+r+",-"+e+"V"+e+"L"+i+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(t*-.309,2),o=n.round(.809*t,2);return"M"+e+","+a+"L"+r+","+o+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(e*-.309,2),c=n.round(.118*e,2),u=n.round(.809*e,2),f=n.round(.382*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+c+"L"+o+","+u+"L0,"+f+"L-"+o+","+u+"L-"+a+","+c+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:113}],328:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],329:[function(t,e,r){"use strict";function n(t,e,r,n){var a=e["error_"+n]||{},l=a.visible&&-1!==["linear","log"].indexOf(r.type),c=[];if(l){for(var u=s(a),f=0;fs;s++)o[s]={x:r[s],y:i[s]};return o[0].trace=t,n.calc({calcdata:[o],_fullLayout:e}),o},n.plot=t("./plot"),n.style=t("./style"),n.hoverInfo=function(t,e,r){(e.error_y||{}).visible&&(r.yerr=t.yh-t.y,e.error_y.symmetric||(r.yerrneg=t.y-t.ys)),(e.error_x||{}).visible&&(r.xerr=t.xh-t.x,e.error_x.symmetric||(r.xerrneg=t.x-t.xs))}},{"./attributes":328,"./calc":329,"./defaults":331,"./plot":333,"./style":334}],333:[function(t,e,r){"use strict";function n(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};return void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0))),void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0))),n}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),s=t("../../traces/scatter/subtypes");e.exports=function(t,e){var r=e.x(),l=e.y();t.each(function(t){var e=t[0].trace,c=e.error_x||{},u=e.error_y||{},f=s.hasMarkers(e)&&e.marker.maxdisplayed>0;if(u.visible||c.visible){var h=i.select(this).selectAll("g.errorbar").data(o.identity);h.enter().append("g").classed("errorbar",!0),h.each(function(t){var e=i.select(this),o=n(t,r,l);if(!f||t.vis){var s;if(u.visible&&a(o.x)&&a(o.yh)&&a(o.ys)){var h=u.width;s="M"+(o.x-h)+","+o.yh+"h"+2*h+"m-"+h+",0V"+o.ys,o.noYS||(s+="m-"+h+",0h"+2*h),e.append("path").classed("yerror",!0).attr("d",s)}if(c.visible&&a(o.y)&&a(o.xh)&&a(o.xs)){var d=(c.copy_ystyle?u:c).width;s="M"+o.xh+","+(o.y-d)+"v"+2*d+"m0,-"+d+"H"+o.xs,o.noXS||(s+="m0,-"+d+"v"+2*d),e.append("path").classed("xerror",!0).attr("d",s)}}})}})}},{"../../lib":382,"../../traces/scatter/subtypes":575,d3:113,"fast-isnumeric":117}],334:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":303,d3:113}],335:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",n.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",n.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":410}],336:[function(t,e,r){"use strict";function n(t,e,r){function n(r,n){return a.coerce(t,e,o,r,n)}e=e||{},n("source"),n("layer"),n("x"),n("y"),n("xanchor"),n("yanchor"),n("sizex"),n("sizey"),n("sizing"),n("opacity");for(var s=0;2>s;s++){var l={_fullLayout:r},c=["x","y"][s];i.coerceRef(t,e,l,c,"paper")}return e}var i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var r=t.images,i=e.images=[],a=0;a=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],340:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:a({},n,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":377,"../../plots/font_attributes":423,"../color/attributes":302}],341:[function(t,e,r){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],342:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/plots"),a=t("./attributes"),o=t("./helpers");e.exports=function(t,e,r){function s(t,e){return n.coerce(h,d,a,t,e)}for(var l,c,u,f,h=t.legend||{},d=e.legend={},p=0,g="normal",v=0;v1);if(y!==!1){if(s("bgcolor",e.paper_bgcolor),s("bordercolor"),s("borderwidth"),n.coerceFont(s,"font",e.font),s("orientation"),"h"===d.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(l=0,u="left",c=1.1,f="bottom"):(l=0,u="left",c=-.1,f="top")}s("traceorder",g),o.isGrouped(e.legend)&&s("tracegroupgap"),s("x",l),s("xanchor",u),s("y",c),s("yanchor",f),n.noneOrAll(h,d,["x","y"])}}},{"../../lib":382,"../../plots/plots":454,"./attributes":340,"./helpers":345}],343:[function(t,e,r){"use strict";function n(t,e){function r(r){u.util.convertToTspans(r,function(){r.selectAll("tspan.line").attr({x:r.attr("x")}),t.call(a,e)})}var n=t.data()[0][0],i=e._fullLayout,o=n.trace,s=h.traceIs(o,"pie"),l=o.index,c=s?n.label:o.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":c}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,i.legend.font).text(c),e._context.editable&&!s?f.call(u.util.makeEditable).call(r).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(r),this.text()||(t=" "),u.restyle(e,"name",t,l)}):f.call(r)}function i(t,e){var r=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],n=t.selectAll("rect").data([0]);n.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"),n.on("click",function(){if(!e._dragged){var n,i,a=t.data()[0][0],o=e._fullData,s=a.trace,l=s.legendgroup,c=[];if(h.traceIs(s,"pie")){var f=a.label,d=r.indexOf(f);-1===d?r.push(f):r.splice(d,1),u.relayout(e,"hiddenlabels",r)}else{if(""===l)c=[s.index];else for(var p=0;ptspan"),d=h[0].length||1;r=l*d,n=u.node()&&p.bBox(u.node()).width;var g=l*(.3+(1-d)/2);u.attr("y",g),h.attr("y",g)}r=Math.max(r,16)+3,a.attr({x:0,y:-r/2,height:r}),i.height=r,i.width=n}function o(t,e,r){var n=t._fullLayout,i=n.legend,a=i.borderwidth,o=b.isGrouped(i);if(b.isVertical(i))o&&e.each(function(t,e){f.setTranslate(this,0,e*i.tracegroupgap)}),i.width=0,i.height=0,r.each(function(t){var e=t[0],r=e.height,n=e.width;f.setTranslate(this,a,5+a+i.height+r/2),i.height+=r,i.width=Math.max(i.width,n)}),i.width+=45+2*a,i.height+=10+2*a,o&&(i.height+=(i._lgroupsLength-1)*i.tracegroupgap),r.selectAll(".legendtoggle").attr("width",(t._context.editable?0:i.width)+40),i.width=Math.ceil(i.width),i.height=Math.ceil(i.height);else if(o){i.width=0,i.height=0;for(var s=[i.width],l=e.data(),u=0,h=l.length;h>u;u++){var d=l[u].map(function(t){return t[0].width}),p=40+Math.max.apply(null,d);i.width+=i.tracegroupgap+p,s.push(i.width)}e.each(function(t,e){f.setTranslate(this,s[e],0)}),e.each(function(){var t=c.select(this),e=t.selectAll("g.traces"),r=0;e.each(function(t){var e=t[0],n=e.height;f.setTranslate(this,0,5+a+r+n/2),r+=n}),i.height=Math.max(i.height,r)}),i.height+=10+2*a,i.width+=2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}else i.width=0,i.height=0,r.each(function(t){var e=t[0],r=40+e.width,n=i.tracegroupgap||5;f.setTranslate(this,a+i.width,5+a+e.height/2),i.width+=n+r,i.height=Math.max(i.height,e.height)}),i.width+=2*a,i.height+=10+2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}function s(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center");var i="top";x.isBottomAnchor(r)?i="bottom":x.isMiddleAnchor(r)&&(i="middle"),h.autoMargin(t,"legend",{x:r.x,y:r.y,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:r.height*({top:1,middle:.5}[i]||0),t:r.height*({bottom:1,middle:.5}[i]||0)})}function l(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center"),h.autoMargin(t,"legend",{x:r.x,y:.5,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:0,t:0})}var c=t("d3"),u=t("../../plotly"),f=t("../../lib"),h=t("../../plots/plots"),d=t("../dragelement"),p=t("../drawing"),g=t("../color"),v=t("./constants"),m=t("./get_legend_data"),y=t("./style"),b=t("./helpers"),x=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e).call(f.setTranslate,0,e),E.call(p.setRect,F,t,v.scrollBarWidth,v.scrollBarHeight),A.select("rect").attr({y:b.borderwidth-e})}var r=t._fullLayout,a="legend"+r._uid;if(r._infolayer&&t.calcdata){var b=r.legend,_=r.showlegend&&m(t.calcdata,b),w=r.hiddenlabels||[];if(!r.showlegend||!_.length)return r._infolayer.selectAll(".legend").remove(),r._topdefs.select("#"+a).remove(),void h.autoMargin(t,"legend");var k=r._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({"class":"legend","pointer-events":"all"});var A=r._topdefs.selectAll("#"+a).data([0]);A.enter().append("clipPath").attr("id",a).append("rect");var M=k.selectAll("rect.bg").data([0]);M.enter().append("rect").attr({"class":"bg","shape-rendering":"crispEdges"}).call(g.stroke,b.bordercolor).call(g.fill,b.bgcolor).style("stroke-width",b.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var E=k.selectAll("rect.scrollbar").data([0]);E.enter().append("rect").attr({"class":"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var L=T.selectAll("g.groups").data(_);L.enter().append("g").attr("class","groups"),L.exit().remove();var S=L.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return h.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(){c.select(this).call(n,t).call(i,t)});var C=0!==k.enter().size();C&&(o(t,L,S),s(t));var z=0,P=r.width,R=0,O=r.height;o(t,L,S),b.height>O?l(t):s(t);var I=r._size,N=I.l+I.w*b.x,j=I.t+I.h*(1-b.y);x.isRightAnchor(b)?N-=b.width:x.isCenterAnchor(b)&&(N-=b.width/2),x.isBottomAnchor(b)?j-=b.height:x.isMiddleAnchor(b)&&(j-=b.height/2);var F=b.width,D=I.w;F>D?(N=I.l,F=D):(N+F>P&&(N=P-F),z>N&&(N=z),F=Math.min(P-N,b.width));var B=b.height,U=I.h;B>U?(j=I.t,B=U):(j+B>O&&(j=O-B),R>j&&(j=R),B=Math.min(O-j,b.height)),f.setTranslate(k,N,j);var V,q,H=B-v.scrollBarHeight-2*v.scrollBarMargin,G=b.height-B;if(b.height<=B||t._context.staticPlot)M.attr({width:F-b.borderwidth,height:B-b.borderwidth,x:b.borderwidth/2,y:b.borderwidth/2}),f.setTranslate(T,0,0),A.select("rect").attr({width:F-2*b.borderwidth,height:B-2*b.borderwidth,x:b.borderwidth,y:b.borderwidth}),T.call(p.setClipUrl,a);else{V=v.scrollBarMargin,q=T.attr("data-scroll")||0,M.attr({width:F-2*b.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:B-b.borderwidth,x:b.borderwidth/2,y:b.borderwidth/2}),A.select("rect").attr({width:F-2*b.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:B-2*b.borderwidth,x:b.borderwidth,y:b.borderwidth-q}),T.call(p.setClipUrl,a),C&&e(V,q),k.on("wheel",null),k.on("wheel",function(){q=f.constrain(T.attr("data-scroll")-c.event.deltaY/H*G,-G,0),V=v.scrollBarMargin-q/G*H,e(V,q),c.event.preventDefault()}),E.on(".drag",null),T.on(".drag",null);var Y=c.behavior.drag().on("drag",function(){V=f.constrain(c.event.y-v.scrollBarHeight/2,v.scrollBarMargin,v.scrollBarMargin+H),q=-(V-v.scrollBarMargin)/H*G,e(V,q)});E.call(Y),T.call(Y)}if(t._context.editable){var X,W,Z,K;k.classed("cursor-move",!0),d.init({element:k.node(),prepFn:function(){var t=f.getTranslate(k);Z=t.x,K=t.y},moveFn:function(t,e){var r=Z+t,n=K+e;f.setTranslate(k,r,n),X=d.align(r,0,I.l,I.l+I.w,b.xanchor),W=d.align(n,0,I.t+I.h,I.t,b.yanchor)},doneFn:function(e){e&&void 0!==X&&void 0!==W&&u.relayout(t,{"legend.x":X,"legend.y":W})}})}}}},{"../../lib":382,"../../plotly":402,"../../plots/plots":454,"../color":303,"../dragelement":324,"../drawing":326,"./anchor_utils":339,"./constants":341,"./get_legend_data":344,"./helpers":345,"./style":347,d3:113}],344:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("./helpers");e.exports=function(t,e){function r(t,r){if(""!==t&&i.isGrouped(e))-1===l.indexOf(t)?(l.push(t),c=!0,s[t]=[[r]]):s[t].push([r]);else{var n="~~i"+f;l.push(n),s[n]=[[r]],f++}}var a,o,s={},l=[],c=!1,u={},f=0;for(a=0;aa;a++)m=s[l[a]],y[a]=i.isReversed(e)?m.reverse():m;else{for(y=[new Array(b)],a=0;b>a;a++)m=s[l[a]][0],y[0][i.isReversed(e)?b-a-1:a]=m;b=1}return e._lgroupsLength=b,y}},{"../../plots/plots":454,"./helpers":345}],345:[function(t,e,r){"use strict";var n=t("../../plots/plots");r.legendGetsTrace=function(t){return t.visible&&n.traceIs(t,"showLegend")},r.isGrouped=function(t){return-1!==(t.traceorder||"").indexOf("grouped")},r.isVertical=function(t){return"h"!==t.orientation},r.isReversed=function(t){return-1!==(t.traceorder||"").indexOf("reversed")}},{"../../plots/plots":454}],346:[function(t,e,r){"use strict";var n=e.exports={};n.layoutAttributes=t("./attributes"),n.supplyLayoutDefaults=t("./defaults"),n.draw=t("./draw"),n.style=t("./style")},{"./attributes":340,"./defaults":342,"./draw":343,"./style":347}],347:[function(t,e,r){"use strict";function n(t){var e=t[0].trace,r=e.visible&&e.fill&&"none"!==e.fill,n=d.hasLines(e),i=l.select(this).select(".legendfill").selectAll("path").data(r?[t]:[]);i.enter().append("path").classed("js-fill",!0),i.exit().remove(),i.attr("d","M5,0h30v6h-30z").call(f.fillGroupStyle);var a=l.select(this).select(".legendlines").selectAll("path").data(n?[t]:[]);a.enter().append("path").classed("js-line",!0).attr("d","M5,0h30"),a.exit().remove(),a.call(f.lineGroupStyle)}function i(t){function e(t,e,r){var n=c.nestedProperty(o,t).get(),i=Array.isArray(n)&&e?e(n):n;if(r){if(ir[1])return r[1]}return i}function r(t){return t[0]}var n,i,a=t[0],o=a.trace,s=d.hasMarkers(o),u=d.hasText(o),h=d.hasLines(o);if(s||u||h){var p={},g={};s&&(p.mc=e("marker.color",r),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",r),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),h&&(g.line={width:e("line.width",r,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",r),p.ts=10,p.tc=e("textfont.color",r),p.tf=e("textfont.family",r)),n=[c.minExtend(a,p)],i=c.minExtend(o,g)}var v=l.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(s?n:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,i),s&&(n[0].mrc=3);var y=v.selectAll("g.pointtext").data(u?n:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,i)}function a(t){var e=t[0].trace,r=e.marker||{},n=r.line||{},i=l.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);i.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),i.exit().remove(),i.each(function(t){var e=(t.mlw+1||n.width+1)-1,i=l.select(this);i.style("stroke-width",e+"px").call(h.fill,t.mc||r.color),e&&i.call(h.stroke,t.mlc||n.color)})}function o(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);r.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.each(function(t){var r=(t.lw+1||e.line.width+1)-1,n=l.select(this);n.style("stroke-width",r+"px").call(h.fill,t.fc||e.fillcolor),r&&n.call(h.stroke,t.lc||e.line.color)})}function s(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);r.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.size()&&r.call(p,t[0],e)}var l=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),h=t("../color"),d=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=l.select(this),r=e.selectAll("g.legendfill").data([t]);r.enter().append("g").classed("legendfill",!0);var n=e.selectAll("g.legendlines").data([t]);n.enter().append("g").classed("legendlines",!0);var i=e.selectAll("g.legendsymbols").data([t]);i.enter().append("g").classed("legendsymbols",!0),i.style("opacity",t[0].trace.opacity),i.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(a).each(o).each(s).each(n).each(i)}},{"../../lib":382,"../../plots/plots":454,"../../traces/pie/style_one":554,"../../traces/scatter/subtypes":575,"../color":303,"../drawing":326,d3:113}],348:[function(t,e,r){"use strict";function n(t,e){var r=e.currentTarget,n=r.getAttribute("data-attr"),i=r.getAttribute("data-val")||!0,a=t._fullLayout,o={};if("zoom"===n){for(var s,l,u="in"===i?.5:2,h=(1+u)/2,d=(1-u)/2,p=c.Axes.list(t,null,!0),v=0;vy;y++){var b=s[y];h=m[b]={};for(var x=0;x1)return n(["resetViews","toggleHover"]),o(v,r);u&&(n(["zoom3d","pan3d","orbitRotation","tableRotation"]),n(["resetCameraDefault3d","resetCameraLastSave3d"]),n(["hoverClosest3d"])),h&&(n(["zoomInGeo","zoomOutGeo","resetGeo"]),n(["hoverClosestGeo"]));var m=i(s),y=[];return((c||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(c||g)&&a(l)&&(y.push("select2d"),y.push("lasso2d")),y.length&&n(y),!c&&!p||m||g||n(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&d?n(["toggleHover"]):p?n(["hoverClosestGl2d"]):c?n(["hoverClosestCartesian","hoverCompareCartesian"]):d&&n(["hoverClosestPie"]),o(v,r)}function i(t){for(var e=l.Axes.list({_fullLayout:t},null,!0),r=!0,n=0;n0);if(h){var d=i(e,r,s);l("x",d[0]),l("y",d[1]),a.noneOrAll(t,e,["x","y"]),l("xanchor"),l("yanchor"),a.coerceFont(l,"font",r.font),l("bgcolor"),l("bordercolor"),l("borderwidth")}}},{"../../lib":382,"./attributes":351,"./button_attributes":352,"./constants":353}],355:[function(t,e,r){"use strict";function n(t){for(var e=m.list(t,"x",!0),r=[],n=0;ne){var r=e;e=t,t=r}s.setAttributes(w,{"data-min":t,"data-max":e}),s.setAttributes(R,{x:t,width:e-t}),s.setAttributes(M,{width:t}),s.setAttributes(T,{x:e,width:p-e}),s.setAttributes(E,{transform:"translate("+(t-v-1)+")"}),s.setAttributes(C,{transform:"translate("+e+")"})}var f=t._fullLayout,h=f._infolayer.selectAll("g.range-slider"),d=f.xaxis.rangeslider,p=f._size.w,g=(f.height-f.margin.b-f.margin.t)*d.thickness,v=2,m=Math.floor(d.borderwidth/2),y=f.margin.l,b=f.height-g-f.margin.b,x=0,_=p,w=document.createElementNS(o,"g");s.setAttributes(w,{"class":"range-slider","data-min":x,"data-max":_,"pointer-events":"all",transform:"translate("+y+","+b+")"});var k=document.createElementNS(o,"rect"),A=d.borderwidth%2===0?d.borderwidth:d.borderwidth-1;s.setAttributes(k,{fill:d.bgcolor,stroke:d.bordercolor,"stroke-width":d.borderwidth,height:g+A,width:p+A,transform:"translate(-"+m+", -"+m+")","shape-rendering":"crispEdges"});var M=document.createElementNS(o,"rect");s.setAttributes(M,{x:0,width:x,height:g,fill:"rgba(0,0,0,0.4)"});var T=document.createElementNS(o,"rect");s.setAttributes(T,{x:_,width:p-_,height:g,fill:"rgba(0,0,0,0.4)"});var E=document.createElementNS(o,"g"),L=document.createElementNS(o,"rect"),S=document.createElementNS(o,"rect");s.setAttributes(E,{transform:"translate("+(x-v-1)+")"}),s.setAttributes(L,{width:10,height:g,x:-6,fill:"transparent",cursor:"col-resize"}),s.setAttributes(S,{width:v,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(E,[S,L]);var C=document.createElementNS(o,"g"),z=document.createElementNS(o,"rect"),P=document.createElementNS(o,"rect");s.setAttributes(C,{transform:"translate("+_+")"}),s.setAttributes(z,{width:10,height:g,x:-2,fill:"transparent",cursor:"col-resize"}),s.setAttributes(P,{width:v,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(C,[P,z]);var R=document.createElementNS(o,"rect");s.setAttributes(R,{x:x,width:_-x,height:g,cursor:"ew-resize",fill:"transparent"}),w.addEventListener("mousedown",function(t){function r(t){var r,n,f=+t.clientX-a;switch(i){case R:w.style.cursor="ew-resize",r=+s+f,n=+l+f,u(r,n),c(e(r),e(n));break;case L:w.style.cursor="col-resize",r=+s+f,n=+l,u(r,n),c(e(r),e(n));break;case z:w.style.cursor="col-resize",r=+s,n=+l+f,u(r,n),c(e(r),e(n));break;default:w.style.cursor="ew-resize",r=o,n=o+f,u(r,n),c(e(r),e(n))}}function n(){window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",n),w.style.cursor="auto"}var i=t.target,a=t.clientX,o=a-w.getBoundingClientRect().left,s=w.getAttribute("data-min"),l=w.getAttribute("data-max");window.addEventListener("mousemove",r),window.addEventListener("mouseup",n)}),d.range||(d.range=i.getAutoRange(f.xaxis));var O=l(t,p,g);s.appendChildren(w,[k,O,M,T,R,E,C]),r(f.xaxis.range[0],f.xaxis.range[1]),h.data([0]).enter().append(function(){return d.setRange=r,w})}},{"../../constants/xmlns_namespaces":370,"../../lib":382,"../../plotly":402,"../../plots/cartesian/axes":405,"./helpers":361,"./range_plot":363}],360:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(t,e){return n.coerce(s,l,i,t,e)}if(t[r].rangeslider){var s="object"==typeof t[r].rangeslider?t[r].rangeslider:{},l=e[r].rangeslider={};if(o("bgcolor"),o("bordercolor"),o("borderwidth"),o("thickness"),o("visible"),o("range"),l.range&&!e[r].autorange){var c=l.range,u=e[r].range;c[0]=Math.min(c[0],u[0]),c[1]=Math.max(c[1],u[1])}else e[r]._needsExpand=!0;l.visible&&a.forEach(function(t){var r=e[t]||{};r.fixedrange=!0,e[t]=r})}}},{"../../lib":382,"./attributes":358}],361:[function(t,e,r){"use strict";r.setAttributes=function(t,e){for(var r in e)t.setAttribute(r,e[r])},r.appendChildren=function(t,e){for(var r=0;rl;l++){var c=s[l],u={_fullLayout:e},f=x.coerceRef(t,n,u,c);if("path"!==o){var h=.25,d=.75;if("paper"!==f){var p=x.getFromId(u,f),g=a(p);h=g(p.range[0]+h*(p.range[1]-p.range[0])),d=g(p.range[0]+d*(p.range[1]-p.range[0]))}r(c+"0",h),r(c+"1",d)}}return"path"===o?r("path"):b.noneOrAll(t,n,["x0","x1","y0","y1"]),n}function i(t){return"category"===t.type?t.c2l:t.d2l}function a(t){return"category"===t.type?t.l2c:t.l2d}function o(t,e){t.layout.shapes=e,k.supplyLayoutDefaults(t.layout,t._fullLayout),k.drawAll(t)}function s(t){delete t.layout.shapes,t._fullLayout.shapes=[],k.drawAll(t)}function l(t,e,r){for(var n=0;ne;i--)h(t,i).selectAll('[data-index="'+(i-1)+'"]').attr("data-index",i),k.draw(t,i)}function f(t,e,r,o){function s(e){var r=e.append("path").attr(z).style("opacity",S.opacity).call(_.stroke,P).call(_.fill,S.fillcolor).call(w.dashLine,S.line.dash,S.line.width);C&&r.call(w.setClipUrl,"clip"+t._fullLayout._uid+C)}var l,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},p={};"string"==typeof r&&r?p[r]=o:b.isPlainObject(r)&&(p=r);var v=Object.keys(p);for(l=0;ll;l++){var k=y[l];if(void 0===p[k]&&void 0!==u[k]){var A,M=k.charAt(0),T=x.getFromId(t,x.coerceRef(f,{},t,M)),E=x.getFromId(t,x.coerceRef(u,{},t,M)),L=u[k];void 0!==p[M+"ref"]&&(T?(A=i(T)(L),L=(A-T.range[0])/(T.range[1]-T.range[0])):L=(L-E.domain[0])/(E.domain[1]-E.domain[0]),E?(A=E.range[0]+L*(E.range[1]-E.range[0]),L=a(E)(A)):L=T.domain[0]+L*(T.domain[1]-T.domain[0])),u[k]=L}}var S=n(u,t._fullLayout);t._fullLayout.shapes[e]=S;var C,z={"data-index":e,"fill-rule":"evenodd",d:g(t,S)},P=S.line.width?S.line.color:"rgba(0,0,0,0)";if("below"!==S.layer)C=(S.xref+S.yref).replace(/paper/g,""),s(t._fullLayout._shapeUpperLayer);else if("paper"===S.xref&&"paper"===S.yref)C="",s(t._fullLayout._shapeLowerLayer);else{var R,O=t._fullLayout._plots||{},I=Object.keys(O);for(l=0,c=I.length;c>l;l++)R=O[I[l]],C=I[l],d(t,S,R)&&s(R.shapelayer)}}}function h(t,e){var r=t._fullLayout.shapes[e],n=t._fullLayout._shapeUpperLayer;return r?"below"===r.layer&&(n="paper"===r.xref&&"paper"===r.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):b.log("getShapeLayer: undefined shape: index",e),n}function d(t,e,r){var n=y.Axes.getFromId(t,r.id,"x")._id,i=y.Axes.getFromId(t,r.id,"y")._id,a="below"===e.layer,o=n===e.xref||i===e.yref,s=!!r.shapelayer;return a&&o&&s}function p(t){return function(e){return t(e.replace("_"," "))}}function g(t,e){var r,n,a,o,s=e.type,l=x.getFromId(t,e.xref),c=x.getFromId(t,e.yref),u=t._fullLayout._size;if(l?(r=i(l),n=function(t){return l._offset+l.l2p(r(t,!0))}):n=function(t){return u.l+u.w*t},c?(a=i(c),o=function(t){return c._offset+c.l2p(a(t,!0))}):o=function(t){return u.t+u.h*(1-t)},"path"===s)return l&&"date"===l.type&&(n=p(n)),c&&"date"===c.type&&(o=p(o)),k.convertPath(e.path,n,o);var f=n(e.x0),h=n(e.x1),d=o(e.y0),g=o(e.y1);if("line"===s)return"M"+f+","+d+"L"+h+","+g;if("rect"===s)return"M"+f+","+d+"H"+h+"V"+g+"H"+f+"Z";var v=(f+h)/2,m=(d+g)/2,y=Math.abs(v-f),b=Math.abs(m-d),_="A"+y+","+b,w=v+y+","+m,A=v+","+(m-b);return"M"+w+_+" 0 1,1 "+A+_+" 0 0,1 "+w+"Z"}function v(t,e,r,n,i){var a="category"===t.type?Number:t.d2c;if(void 0!==e)return[a(e),a(r)];if(n){var o,s,l,c,u,f=1/0,h=-(1/0),d=n.match(A);for("date"===t.type&&(a=p(a)),o=0;ou&&(f=u),u>h&&(h=u)));return h>=f?[f,h]:void 0}}var m=t("fast-isnumeric"),y=t("../../plotly"),b=t("../../lib"),x=t("../../plots/cartesian/axes"),_=t("../color"),w=t("../drawing"),k=e.exports={};k.layoutAttributes=t("./attributes"),k.supplyLayoutDefaults=function(t,e){for(var r=t.shapes||[],i=e.shapes=[],a=0;as&&(t="X"),t});return n>s&&(l=l.replace(/[\s,]*X.*/,""),b.log("Ignoring extra params in segment "+t)),i+l})},k.calcAutorange=function(t){var e,r,n,i,a,o=t._fullLayout,s=o.shapes;if(s.length&&t._fullData.length)for(e=0;eh?r=h:(u.left-=b.offsetLeft,u.right-=b.offsetLeft,u.top-=b.offsetTop,u.bottom-=b.offsetTop,b.selection.each(function(){var t=l.bBox(this);s.bBoxIntersect(u,t,c)&&(r=Math.max(r,o*(t[b.side]-u[a])+c))}),r=Math.min(h,r)),r>0||0>h){var d={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[b.side];e.attr("transform","translate("+d+")")}}}function p(){E=0,L=!0,S=z,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)})}var g=r.propContainer,v=r.propName,m=r.traceIndex,y=r.dfltName,b=r.avoid||{},x=r.attributes,_=r.transform,w=r.containerGroup,k=t._fullLayout,A=g.titlefont.family,M=g.titlefont.size,T=g.titlefont.color,E=1,L=!1,S=g.title.trim();""===S&&(E=0),S.match(/Click to enter .+ title/)&&(E=.2,L=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var z="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==m?a.restyle(t,v,e,m):a.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(x).selectAll("tspan.line").attr(x)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",L)}},{"../../lib":382,"../../lib/svg_text_utils":395,"../../plotly":402,"../../plots/plots":454,"../color":303,"../drawing":326,d3:113,"fast-isnumeric":117}],367:[function(t,e,r){"use strict";e.exports={solid:[1],dot:[1,1],dash:[4,1],longdash:[8,1],dashdot:[4,1,1,1],longdashdot:[8,1,1,1]}},{}],368:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],369:[function(t,e,r){"use strict";e.exports={circle:"\u25cf","circle-open":"\u25cb",square:"\u25a0","square-open":"\u25a1",diamond:"\u25c6","diamond-open":"\u25c7",cross:"+",x:"\u274c"}},{}],370:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],371:[function(t,e,r){"use strict";var n=t("./plotly");r.version="1.13.0",r.plot=n.plot,r.newPlot=n.newPlot,r.restyle=n.restyle,r.relayout=n.relayout,r.redraw=n.redraw,r.extendTraces=n.extendTraces,r.prependTraces=n.prependTraces,r.addTraces=n.addTraces,r.deleteTraces=n.deleteTraces,r.moveTraces=n.moveTraces,r.purge=n.purge,r.setPlotConfig=t("./plot_api/set_plot_config"),r.register=n.register,r.toImage=t("./plot_api/to_image"),r.downloadImage=t("./snapshot/download"),r.Icons=t("../build/ploticon"),r.Plots=n.Plots,r.Fx=n.Fx,r.Snapshot=n.Snapshot,r.PlotSchema=n.PlotSchema,r.Queue=n.Queue,r.d3=t("d3")},{"../build/ploticon":2,"./plot_api/set_plot_config":400,"./plot_api/to_image":401,"./plotly":402,"./snapshot/download":469,d3:113}],372:[function(t,e,r){"use strict";"undefined"!=typeof MathJax?(r.MathJax=!0,MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:!0,displayAlign:"left",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]}}),MathJax.Hub.Configured()):r.MathJax=!1},{}],373:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){Array.isArray(t)&&(e[r]=t[n])}},{}],374:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("./nested_property"),o=t("../components/colorscale/get_scale"),s=(Object.keys(t("../components/colorscale/scales")),/^([2-9]|[1-9][0-9]+)$/);r.valObjects={data_array:{coerceFunction:function(t,e,r){Array.isArray(t)?e.set(t):void 0!==r&&e.set(r)}},enumerated:{coerceFunction:function(t,e,r,n){n.coerceNumber&&(t=+t),-1===n.values.indexOf(t)?e.set(r):e.set(t)}},"boolean":{coerceFunction:function(t,e,r){t===!0||t===!1?e.set(t):e.set(r)}},number:{coerceFunction:function(t,e,r,i){!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if(n.strict===!0&&"string"!=typeof t)return void e.set(r);var i=String(t);void 0===t||n.noBlank===!0&&!i?e.set(r):e.set(i)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r){var n=r.length;return"string"==typeof t&&t.substr(0,n)===r&&s.test(t.substr(n))?void e.set(t):void e.set(r)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"!=typeof t)return void e.set(r);if(-1!==n.extras.indexOf(t))return void e.set(t);for(var i=t.split("+"),a=0;a2)return!1;var l=o[0].split("-");if(l.length>3||3!==l.length&&o[1])return!1;if(4===l[0].length)r=Number(l[0]);else{if(2!==l[0].length)return!1;var c=(new Date).getFullYear();r=((Number(l[0])-c+70)%100+200)%100+c-70}return s(r)?1===l.length?new Date(r,0,1).getTime():(n=Number(l[1])-1,l[1].length>2||!(n>=0&&11>=n)?!1:2===l.length?new Date(r,n,1).getTime():(i=Number(l[2]),l[2].length>2||!(i>=1&&31>=i)?!1:(i=new Date(r,n,i).getTime(),o[1]?(l=o[1].split(":"),l.length>3?!1:(a=Number(l[0]),l[0].length>2||!(a>=0&&23>=a)?!1:(i+=36e5*a,1===l.length?i:(n=Number(l[1]),l[1].length>2||!(n>=0&&59>=n)?!1:(i+=6e4*n,2===l.length?i:(t=Number(l[2]),t>=0&&60>t?i+1e3*t:!1)))))):i))):!1},r.isDateTime=function(t){return r.dateTime2ms(t)!==!1},r.ms2DateTime=function(t,e){if("undefined"==typeof o)return void l.error("d3 is not defined.");e||(e=0);var r=new Date(t),i=o.time.format("%Y-%m-%d")(r);return 7776e6>e?(i+=" "+n(r.getHours(),2),432e6>e&&(i+=":"+n(r.getMinutes(),2),108e5>e&&(i+=":"+n(r.getSeconds(),2),3e5>e&&(i+="."+n(r.getMilliseconds(),3)))),i.replace(/([:\s]00)*\.?[0]*$/,"")):i};var c={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},u={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},f=o.time.format.utc,h={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(f),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(f)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(f)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){u[t].forEach(function(e){h[t].D.push(f(e)),["H","I","D"].forEach(function(r){c[r].forEach(function(n){var i=h[t][r];i.push(f(e+"~"+n)),i.push(f(n+"~"+e))})})})});var d=/[a-z]*/g,p=function(t){return t.substr(0,3)},g=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,v=/[\s,\/\-\.\(\)]+/g,m=/~?([ap])~?m(~|$)/,y=function(t,e){return e+"m "},b=/\d\d\d\d/,x=/(^|~)[a-z]{3}/,_=/[ap]m/,w=/:/,k=/q([1-4])/,A=["31~mar","30~jun","30~sep","31~dec"],M=function(t,e){return A[e-1]},T=/ ?([+\-]\d\d:?\d\d|Z)$/;r.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(d,p).replace(g,"").replace(v,"~").replace(m,y).replace(k,M).trim().replace(T,"");var e,r,n=null,o=i(t),s=a(t);e=h[o][s],r=e.length;for(var l=0;r>l&&!(n=e[l].parse(t));l++);if(!(n instanceof Date))return!1;var c=n.getTimezoneOffset();return n.setTime(n.getTime()+60*c*1e3),n}},{"../lib":382,d3:113,"fast-isnumeric":117}],376:[function(t,e,r){"use strict";var n=t("events").EventEmitter,i={init:function(t){if(t._ev instanceof n)return t;var e=new n;return t._ev=e,t.on=e.on.bind(e),t.once=e.once.bind(e),t.removeListener=e.removeListener.bind(e),t.removeAllListeners=e.removeAllListeners.bind(e),t.emit=function(r,n){"undefined"!=typeof jQuery&&jQuery(t).trigger(r,n),e.emit(r,n)},t},triggerHandler:function(t,e,r){var n,i;"undefined"!=typeof jQuery&&(n=jQuery(t).triggerHandler(e,r));var a=t._ev;if(!a)return n;var o=a._events[e];if(!o)return n;"function"==typeof o&&(o=[o]);for(var s=o.pop(),l=0;lp;p++){o=t[p];for(s in o)l=h[s],c=o[s],e&&c&&(i(c)||(u=a(c)))?(u?(u=!1,f=l&&a(l)?l:[]):f=l&&i(l)?l:{},h[s]=n([f,c],e,r)):("undefined"!=typeof c||r)&&(h[s]=c)}return h}var i=t("./is_plain_object.js"),a=Array.isArray;r.extendFlat=function(){return n(arguments,!1,!1)},r.extendDeep=function(){return n(arguments,!0,!1)},r.extendDeepAll=function(){return n(arguments,!0,!0)}},{"./is_plain_object.js":383}],378:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=0;ry;y++)f=s(p,y),d=l(e,y),m[y]=n(f,d);else m=n(p,e);return m}var s=t("tinycolor2"),l=t("fast-isnumeric"),c=t("../components/colorscale/make_scale_function"),u=t("../components/color/attributes").defaultLine,f=t("./str2rgbarray"),h=1;e.exports=o},{"../components/color/attributes":302,"../components/colorscale/make_scale_function":320,"./str2rgbarray":394,"fast-isnumeric":117,tinycolor2:274}],381:[function(t,e,r){"use strict";function n(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(e>r)break;t=t.slice(0,e)+l(t.slice(e+5,r))+t.slice(r+6); +}return t}function i(t){return t.replace(/\/g,"\n")}function a(t){return t.replace(/\<.*\>/g,"")}function o(t){for(var e=0;(e=t.indexOf("&",e))>=0;){var r=t.indexOf(";",e);if(e>r)e+=1;else{var n=c[t.slice(e+1,r)];t=n?t.slice(0,e)+n+t.slice(r+1):t.slice(0,e)+t.slice(r+1)}}return t}function s(t){return""+o(a(n(i(t))))}var l=t("superscript-text"),c={mu:"\u03bc",amp:"&",lt:"<",gt:">"};e.exports=s},{"superscript-text":263}],382:[function(t,e,r){"use strict";var n=t("d3"),i=e.exports={};i.nestedProperty=t("./nested_property"),i.isPlainObject=t("./is_plain_object");var a=t("./coerce");i.valObjects=a.valObjects,i.coerce=a.coerce,i.coerce2=a.coerce2,i.coerceFont=a.coerceFont;var o=t("./dates");i.dateTime2ms=o.dateTime2ms,i.isDateTime=o.isDateTime,i.ms2DateTime=o.ms2DateTime,i.parseDate=o.parseDate;var s=t("./search");i.findBin=s.findBin,i.sorterAsc=s.sorterAsc,i.sorterDes=s.sorterDes,i.distinctVals=s.distinctVals,i.roundUp=s.roundUp;var l=t("./stats");i.aggNums=l.aggNums,i.len=l.len,i.mean=l.mean,i.variance=l.variance,i.stdev=l.stdev,i.interp=l.interp;var c=t("./matrix");i.init2dArray=c.init2dArray,i.transposeRagged=c.transposeRagged,i.dot=c.dot,i.translationMatrix=c.translationMatrix,i.rotationMatrix=c.rotationMatrix,i.rotationXYMatrix=c.rotationXYMatrix,i.apply2DTransform=c.apply2DTransform,i.apply2DTransform2=c.apply2DTransform2;var u=t("./extend");i.extendFlat=u.extendFlat,i.extendDeep=u.extendDeep,i.extendDeepAll=u.extendDeepAll;var f=t("./loggers");i.log=f.log,i.warn=f.warn,i.error=f.error,i.notifier=t("./notifier"),i.swapAttrs=function(t,e,r,n){r||(r="x"),n||(n="y");for(var a=0;ar?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},i.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},i.identity=function(t){return t},i.randstr=function h(t,e,r){if(r||(r=16),void 0===e&&(e=24),0>=e)return"0";var n,i,a,o=Math.log(Math.pow(2,e))/Math.log(r),s="";for(n=2;o===1/0;n*=2)o=Math.log(Math.pow(2,e/n))/Math.log(r)*n;var l=o-Math.floor(o);for(n=0;n-1||c!==1/0&&c>=Math.pow(2,e)?h(t,e,r):s},i.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={};return r.optionList=[],r._newoption=function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)},r["_"+e]=t,r},i.smooth=function(t,e){if(e=Math.round(e)||0,2>e)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,c=new Array(l),u=new Array(o);for(r=0;l>r;r++)c[r]=(1-Math.cos(Math.PI*(r+1)/e))/(2*e);for(r=0;o>r;r++){for(a=0,n=0;l>n;n++)i=r+n+1-e,-o>i?i-=s*Math.round(i/s):i>=s&&(i-=s*Math.floor(i/s)),0>i?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*c[n];u[r]=a}return u},i.syncOrAsync=function(t,e,r){function n(){return i.syncOrAsync(t,e,r)}for(var a,o;t.length;)if(o=t.splice(0,1)[0],a=o(e),a&&a.then)return a.then(n).then(void 0,i.promiseError);return r&&r(e)},i.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},i.noneOrAll=function(t,e,r){if(t){var n,i,a=!1,o=!0;for(n=0;ni;i++)e[i][r]=t[i]},i.minExtend=function(t,e){var r={};"object"!=typeof e&&(e={});var n,a,o,s=3,l=Object.keys(t);for(n=0;n1?n+a[1]:"";if(i&&(a.length>1||o.length>4))for(;r.test(o);)o=o.replace(r,"$1"+i+"$2");return o+s}},{"./coerce":374,"./dates":375,"./extend":377,"./is_plain_object":383,"./loggers":384,"./matrix":385,"./nested_property":386,"./notifier":387,"./search":390,"./stats":393,d3:113}],383:[function(t,e,r){"use strict";e.exports=function(t){return"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],384:[function(t,e,r){"use strict";var n=t("../plot_api/plot_config"),i=e.exports={};i.log=function(){if(n.logging>1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;en;n++)r[n]=new Array(e);return r},r.transposeRagged=function(t){var e,r,n=0,i=t.length;for(e=0;i>e;e++)n=Math.max(n,t[e].length);var a=new Array(n);for(e=0;n>e;e++)for(a[e]=new Array(i),r=0;i>r;r++)a[e][r]=t[r][e];return a},r.dot=function(t,e){if(!t.length||!e.length||t.length!==e.length)return null;var n,i,a=t.length;if(t[0].length)for(n=new Array(a),i=0;a>i;i++)n[i]=r.dot(t[i],e);else if(e[0].length){var o=r.transposeRagged(e);for(n=new Array(o.length),i=0;ii;i++)n+=t[i]*e[i];return n},r.translationMatrix=function(t,e){return[[1,0,t],[0,1,e],[0,0,1]]},r.rotationMatrix=function(t){var e=t*Math.PI/180;return[[Math.cos(e),-Math.sin(e),0],[Math.sin(e),Math.cos(e),0],[0,0,1]]},r.rotationXYMatrix=function(t,e,n){return r.dot(r.dot(r.translationMatrix(e,n),r.rotationMatrix(t)),r.translationMatrix(-e,-n))},r.apply2DTransform=function(t){return function(){var e=arguments;3===e.length&&(e=e[0]);var n=1===arguments.length?e[0]:[e[0],e[1]];return r.dot(t,[n[0],n[1],1]).slice(0,2)}},r.apply2DTransform2=function(t){var e=r.apply2DTransform(t);return function(t){return e(t.slice(0,2)).concat(e(t.slice(2,4)))}}},{}],386:[function(t,e,r){"use strict";function n(t,e){return function(){var r,i,a,o,s,l=t;for(o=0;o=0;e--){if(n=t[e],o=!1,Array.isArray(n))for(r=n.length-1;r>=0;r--)c(n[r])?o?n[r]=void 0:n.pop():o=!0;else if("object"==typeof n&&null!==n)for(a=Object.keys(n),o=!1,r=a.length-1;r>=0;r--)c(n[a[r]])&&!i(n[a[r]],a[r])?delete n[a[r]]:o=!0;if(o)return}}function c(t){return void 0===t||null===t?!0:"object"!=typeof t?!1:Array.isArray(t)?!t.length:!Object.keys(t).length}function u(t,e,r){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:r,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,l=e.split(".");sr||r>a||o>n||n>s?!1:!e||!c(t)}function r(t,e){var r=t[0],l=t[1];if(i>r||r>a||o>l||l>s)return!1;var c,u,f,h,d,p=n.length,g=n[0][0],v=n[0][1],m=0;for(c=1;p>c;c++)if(u=g,f=v,g=n[c][0],v=n[c][1],h=Math.min(u,g),!(h>r||r>Math.max(u,g)||l>Math.max(f,v)))if(l=l&&r!==h&&m++}return m%2===1}var n=t.slice(),i=n[0][0],a=i,o=n[0][1],s=o;n.push(n[0]);for(var l=1;la;a++)if(o=[t[a][0]-l[0],t[a][1]-l[1]],s=n(o,c),0>s||s>u||Math.abs(n(o,h))>i)return!0;return!1};i.filter=function(t,e){function r(r){t.push(r);var s=n.length,l=i;n.splice(o+1);for(var c=l+1;c1){var s=t.pop();r(s)}return{addPt:r,raw:t,filtered:n}}},{"./matrix":385}],389:[function(t,e,r){"use strict";function n(t,e){for(var r,n=[],a=0;a=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;rt}function i(t,e){return e>=t}function a(t,e){return t>e}function o(t,e){return t>=e}var s=t("fast-isnumeric"),l=t("../lib");r.findBin=function(t,e,r){if(s(e.start))return r?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var c,u,f=0,h=e.length,d=0;for(u=e[e.length-1]>=e[0]?r?n:i:r?o:a;h>f&&d++<100;)c=Math.floor((f+h)/2),u(e[c],t)?f=c+1:h=c;return d>90&&l.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;n>s;s++)e[s+1]>e[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,c=r?Math.ceil:Math.floor;a>i&&o++<100;)n=c((i+a)/2),e[n]<=t?i=n+s:a=n-l;return e[i]}},{"../lib":382,"fast-isnumeric":117}],391:[function(t,e,r){"use strict";e.exports=function(t,e){(t.attr("class")||"").split(" ").forEach(function(e){0===e.indexOf("cursor-")&&t.classed(e,!1)}),e&&t.classed("cursor-"+e,!0)}},{}],392:[function(t,e,r){"use strict";var n=t("../components/color"),i=function(){};e.exports=function(t){for(var e in t)"function"==typeof t[e]&&(t[e]=i);t.destroy=function(){t.container.parentNode.removeChild(t.container)};var r=document.createElement("div");return r.textContent="Webgl is not supported by your browser - visit http://get.webgl.org for more info",r.style.cursor="pointer",r.style.fontSize="24px",r.style.color=n.defaults[0],t.container.appendChild(r),t.container.style.background="#FFFFFF",t.container.onclick=function(){window.open("http://get.webgl.org")},!1}},{"../components/color":303}],393:[function(t,e,r){"use strict";var n=t("fast-isnumeric");r.aggNums=function(t,e,i,a){var o,s;if(a||(a=i.length),n(e)||(e=!1),Array.isArray(i[0])){for(s=new Array(a),o=0;a>o;o++)s[o]=r.aggNums(t,e,i[o]);i=s}for(o=0;a>o;o++)n(e)?n(i[o])&&(e=t(+e,+i[o])):e=i[o];return e},r.len=function(t){return r.aggNums(function(t){return t+1},0,t)},r.mean=function(t,e){return e||(e=r.len(t)),r.aggNums(function(t,e){return t+e},0,t)/e},r.variance=function(t,e,i){return e||(e=r.len(t)),n(i)||(i=r.mean(t,e)),r.aggNums(function(t,e){return t+Math.pow(e-i,2)},0,t)/e},r.stdev=function(t,e,n){return Math.sqrt(r.variance(t,e,n))},r.interp=function(t,e){if(!n(e))throw"n should be a finite number";if(e=e*t.length-.5,0>e)return t[0];if(e>t.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"fast-isnumeric":117}],394:[function(t,e,r){"use strict";function n(t){return t=i(t),a.str2RgbaArray(t.toRgbString())}var i=t("tinycolor2"),a=t("arraytools");e.exports=n},{arraytools:49,tinycolor2:274}],395:[function(t,e,r){"use strict";function n(t,e){return t.node().getBoundingClientRect()[e]}function i(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function a(t,e,r){var n="math-output-"+l.Lib.randstr([],64),a=c.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(i(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,a.node()],function(){var e=c.select("body").select("#MathJax_SVG_glyphs");if(a.select(".MathJax_SVG").empty()||!a.select("svg").node())u.log("There was an error in the tex syntax.",t),r();else{var n=a.select("svg").node().getBoundingClientRect();r(a.select(".MathJax_SVG"),e,n)}a.remove()})}function o(t){for(var e=l.util.html_entity_decode(t),r=e.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),r=e&&e[2].toLowerCase(),n=d[r];if(void 0!==n){var i=e[1],a=e[3],o=a.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===r){if(i)return"";if("href"!==a.substr(0,4).toLowerCase())return"";var s=document.createElement("a");return s.href=a.substr(4).replace(/["'=]/g,""),-1===p.indexOf(s.protocol)?"":'"}if("br"===r)return"
";if(i)return"sup"===r?'':"sub"===r?'':"";var c=""}return l.util.xml_entity_encode(t).replace(/");i>0;i=r.indexOf("
",i+1))n.push(i);var a=0;n.forEach(function(t){for(var e=t+a,n=r.slice(0,e),i="",o=n.length-1;o>=0;o--){var s=n[o].match(/<(\/?).*>/i);if(s&&"
"!==n[o]){s[1]||(i=n[o]);break}}i&&(r.splice(e+1,0,i),r.splice(e,0,""),a+=2)});var o=r.join(""),s=o.split(/
/gi);return s.length>1&&(r=s.map(function(t,e){return''+t+""})),r.join("")}function s(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-c.top+"px",left:a()-c.left+"px","z-index":1e3}),this}}var l=t("../plotly"),c=t("d3"),u=t("../lib"),f=t("../constants/xmlns_namespaces"),h=e.exports={};c.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),r=(new DOMParser).parseFromString(e,"application/xml"),n=r.documentElement.firstChild;n;)this.node().appendChild(this.node().ownerDocument.importNode(n,!0)),n=n.nextSibling;return r.querySelector("parsererror")?(u.log(r.querySelector("parsererror div").textContent),null):c.select(this.node().lastChild)},h.html_entity_decode=function(t){var e=c.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),r},h.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},h.convertToTspans=function(t,e){function r(){d.empty()||(p=u.attr("class")+"-math",d.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),h=t.appendSVG(s),h||t.text(i),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(u)}var i=t.text(),s=o(i),u=t,f=!u.attr("data-notex")&&s.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),h=i,d=c.select(u.node().parentNode);if(!d.empty()){var p=u.attr("class")?u.attr("class").split(" ")[0]:"text";p+="-math",d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=l.Lib.getPlotDiv(u.node());(v&&v._promises||[]).push(new Promise(function(t){u.style({visibility:"hidden"});var i={fontSize:parseInt(u.style("font-size"),10)};a(f[2],i,function(i,a,o){d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove();var s=i&&i.select("svg");if(!s||!s.node())return r(),void t();var l=d.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});l.node().appendChild(s.node()),a&&a.node()&&s.node().insertBefore(a.node().cloneNode(!0),s.node().firstChild),s.attr({"class":p,height:o.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=u.style("fill")||"black";s.select("g").attr({fill:c,stroke:c});var f=n(s,"width"),h=n(s,"height"),g=+u.attr("x")-f*{start:0,middle:.5,end:1}[u.attr("text-anchor")||"start"],v=parseInt(u.style("font-size"),10)||n(u,"height"),m=-v/4;"y"===p[0]?(l.attr({transform:"rotate("+[-90,+u.attr("x"),+u.attr("y")]+") translate("+[-f/2,m-h/2]+")"}),s.attr({x:+u.attr("x"),y:+u.attr("y")})):"l"===p[0]?s.attr({x:u.attr("x"),y:m-h/2}):"a"===p[0]?s.attr({x:0,y:m}):s.attr({x:g,y:+u.attr("y")+m-h/2}),e&&e.call(u,l),t(l)})}))}else r();return t}};var d={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},p=["http:","https:","mailto:"],g=new RegExp("]*)?/?>","g");h.plainText=function(t){return(t||"").replace(g," ")},h.makeEditable=function(t,e,r){function n(){a(),o.style({opacity:0});var t,e=h.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0})}function i(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}function a(){var t=c.select(l.Lib.getPlotDiv(o.node())),e=t.select(".svg-container"),n=e.append("div");n.classed("plugin-editable editable",!0).style({position:"absolute","font-family":o.style("font-family")||"Arial","font-size":o.style("font-size")||12,color:r.fill||o.style("fill")||"black",opacity:1,"background-color":r.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(o.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(r.text||o.attr("data-unformatted")).call(s(o,e,r)).on("blur",function(){o.text(this.textContent).style({opacity:1});var t,e=c.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0});var r=this.textContent;c.select(this).transition().duration(0).remove(),c.select(document).on("mouseup",null),u.edit.call(o,r)}).on("focus",function(){var t=this;c.select(document).on("mouseup",function(){return c.event.target===t?!1:void(document.activeElement===n.node()&&n.node().blur())})}).on("keyup",function(){27===c.event.which?(o.style({opacity:1}),c.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),u.cancel.call(o,this.textContent)):(u.input.call(o,this.textContent),c.select(this).call(s(o,e,r)))}).on("keydown",function(){13===c.event.which&&this.blur()}).call(i)}r||(r={});var o=this,u=c.dispatch("edit","input","cancel"),f=c.select(this.node()).style({"pointer-events":"all"}),h=e||f;return e&&f.style({"pointer-events":"none"}),r.immediate?n():h.on("click",n),c.rebind(this,u,"on")}},{"../constants/xmlns_namespaces":370,"../lib":382,"../plotly":402,d3:113}],396:[function(t,e,r){"use strict";var n=e.exports={},i=t("../plots/geo/constants").locationmodeToLayer,a=t("topojson").feature;n.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},n.getTopojsonPath=function(t,e){return t+e+".json"},n.getTopojsonFeatures=function(t,e){var r=i[t.locationmode],n=e.objects[r];return a(e,n).features}},{"../plots/geo/constants":424,topojson:275}],397:[function(t,e,r){"use strict";function n(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function i(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function a(t,e){t._context||(t._context=R.extendFlat({},P.defaultConfig));var r=t._context;e&&(Object.keys(e).forEach(function(t){t in r&&("setBackground"===t&&"opaque"===e[t]?r[t]=i:r[t]=e[t])}),e.plot3dPixelRatio&&!r.plotGlPixelRatio&&(r.plotGlPixelRatio=r.plot3dPixelRatio)),r.staticPlot&&(r.editable=!1,r.autosizable=!1,r.scrollZoom=!1,r.doubleClick=!1,r.showTips=!1,r.showLink=!1,r.displayModeBar=!1)}function o(t,e,r){var n=S.select(t).selectAll(".plot-container").data([0]);n.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=n.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e),r&&(t.layout=r),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(w(t,{}),t._fullLayout.autosize=r.autosize=!0),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var a=t.framework.svg(),o=1,s=t._fullLayout.title;""!==s&&s||(o=0);var l="Click to enter title",c=function(){this.call(P.util.convertToTspans)},u=a.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":s}),s&&s!==l||(o=.2,u.attr({"data-unformatted":l}).text(l).style({opacity:o}).on("mouseover.opacity",function(){S.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){S.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),N.addLinks(t),Promise.resolve()}function s(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var n=P.Axes.list({_fullLayout:t});for(e=0;ee;e++){var o=t.annotations[e];o.ref&&("paper"===o.ref?(o.xref="paper",o.yref="paper"):"data"===o.ref&&(o.xref="x",o.yref="y"),delete o.ref),l(o,"xref"),l(o,"yref")}void 0===t.shapes||Array.isArray(t.shapes)||(R.warn("Shapes must be an array."),delete t.shapes);var s=(t.shapes||[]).length;for(e=0;s>e;e++){var c=t.shapes[e];l(c,"xref"),l(c,"yref")}var u=t.legend;u&&(u.x>3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var h=N.getSubplotIds(t,"gl3d");for(e=0;er;++r)b[r]=v[e]+m*y[2+4*r];d.camera={eye:{x:b[0],y:b[1],z:b[2]},center:{x:v[0],y:v[1],z:v[2]},up:{x:y[1],y:y[5],z:y[9]}},delete d.cameraposition}}return F.clean(t),t}function l(t,e){var r=t[e],n=e.charAt(0);r&&"paper"!==r&&(t[e]=P.Axes.cleanId(r,n))}function c(t,e){for(var r=[],n=(t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid})),i=0;ia&&(s=R.randstr(n),-1!==r.indexOf(s));a++);o.uid=R.randstr(n),n.push(o.uid)}if(r.push(o.uid),"histogramy"===o.type&&"xbins"in o&&!("ybins"in o)&&(o.ybins=o.xbins,delete o.xbins),o.error_y&&"opacity"in o.error_y){var l=F.defaults,c=o.error_y.color||(N.traceIs(o,"bar")?F.defaultLine:l[i%l.length]);o.error_y.color=F.addOpacity(F.rgb(c),F.opacity(c)*o.error_y.opacity),delete o.error_y.opacity}if("bardir"in o&&("h"!==o.bardir||!N.traceIs(o,"bar")&&"histogram"!==o.type.substr(0,9)||(o.orientation="h",x(o)),delete o.bardir),"histogramy"===o.type&&x(o),"histogramx"!==o.type&&"histogramy"!==o.type||(o.type="histogram"),"scl"in o&&(o.colorscale=o.scl,delete o.scl),"reversescl"in o&&(o.reversescale=o.reversescl,delete o.reversescl),o.xaxis&&(o.xaxis=P.Axes.cleanId(o.xaxis,"x")),o.yaxis&&(o.yaxis=P.Axes.cleanId(o.yaxis,"y")),N.traceIs(o,"gl3d")&&o.scene&&(o.scene=N.subplotsRegistry.gl3d.cleanId(o.scene)),N.traceIs(o,"pie")||(Array.isArray(o.textposition)?o.textposition=o.textposition.map(u):o.textposition&&(o.textposition=u(o.textposition))),N.traceIs(o,"2dMap")&&("YIGnBu"===o.colorscale&&(o.colorscale="YlGnBu"),"YIOrRd"===o.colorscale&&(o.colorscale="YlOrRd")),N.traceIs(o,"markerColorscale")&&o.marker){var h=o.marker;"YIGnBu"===h.colorscale&&(h.colorscale="YlGnBu"),"YIOrRd"===h.colorscale&&(h.colorscale="YlOrRd")}if("surface"===o.type&&R.isPlainObject(o.contours)){var d=["x","y","z"];for(a=0;an?a.push(i+n):a.push(n);return a}function p(t,e,r){var n,i;for(n=0;n=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||0>i&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function g(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),p(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&p(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function v(t,e,r){var n,i;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),n=0;n=0&&l0){var s=_(t._boundingBoxMargins),l=s.left+s.right,c=s.bottom+s.top,u=a._container.node().getBoundingClientRect(),f=1-2*o.frameMargins;i=Math.round(f*(u.width-l)),n=Math.round(f*(u.height-c))}else r=window.getComputedStyle(t),n=parseFloat(r.height)||a.height,i=parseFloat(r.width)||a.width;return Math.abs(a.width-i)>1||Math.abs(a.height-n)>1?(a.height=t.layout.height=n,a.width=t.layout.width=i):"initial"!==a.autosize&&(delete e.autosize,a.autosize=t.layout.autosize=!0),N.sanitizeMargins(a),e}function k(t){var e=S.select(t),r=t._fullLayout;if(r._container=e.selectAll(".plot-container").data([0]),r._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),r._paperdiv=r._container.selectAll(".svg-container").data([0]),r._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===r.autosize&&(w(t,{}),r.autosize=!0,t.layout.autosize=!0),r._glcontainer=r._paperdiv.selectAll(".gl-container").data([0]),r._glcontainer.enter().append("div").classed("gl-container",!0),r._geocontainer=r._paperdiv.selectAll(".geo-container").data([0]),r._geocontainer.enter().append("div").classed("geo-container",!0),r._paperdiv.selectAll(".main-svg").remove(),r._paper=r._paperdiv.insert("svg",":first-child").classed("main-svg",!0),r._toppaper=r._paperdiv.append("svg").classed("main-svg",!0),!r._uid){var n=[];S.selectAll("defs").each(function(){this.id&&n.push(this.id.split("-")[1])}),r._uid=R.randstr(n)}r._paperdiv.selectAll(".main-svg").attr(W.svgAttrs),r._defs=r._paper.append("defs").attr("id","defs-"+r._uid),r._topdefs=r._toppaper.append("defs").attr("id","topdefs-"+r._uid),r._draggers=r._paper.append("g").classed("draglayer",!0);var i=r._paper.append("g").classed("layer-below",!0);r._imageLowerLayer=i.append("g").classed("imagelayer",!0),r._shapeLowerLayer=i.append("g").classed("shapelayer",!0);var a=P.Axes.getSubplots(t);a.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,a),r._has("cartesian")&&M(t,a),r._ternarylayer=r._paper.append("g").classed("ternarylayer",!0);var o=r._paper.selectAll(".layer-subplot");r._imageSubplotLayer=o.selectAll(".imagelayer"),r._shapeSubplotLayer=o.selectAll(".shapelayer");var s=r._paper.append("g").classed("layer-above",!0);r._imageUpperLayer=s.append("g").classed("imagelayer",!0),r._shapeUpperLayer=s.append("g").classed("shapelayer",!0),r._pielayer=r._paper.append("g").classed("pielayer",!0),r._glimages=r._paper.append("g").classed("glimages",!0),r._geoimages=r._paper.append("g").classed("geoimages",!0),r._infolayer=r._toppaper.append("g").classed("infolayer",!0),r._zoomlayer=r._toppaper.append("g").classed("zoomlayer",!0),r._hoverlayer=r._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var l=R.syncOrAsync([T,function(){return P.Axes.doTicks(t,"redraw")},j.init],t);return l&&l.then&&t._promises.push(l),l}function A(t,e){function r(e,r){return function(){return P.Axes.getFromId(t,e,r)}}for(var n,i,a=t._fullLayout._plots={},o=0;o0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),A=w===_;x?t.framework===k&&!b&&A||(t.framework=k,k(t)):A?b&&k(t):(t.framework=k,k(t)),b&&P.Axes.saveRangeInitial(t);var M=t._fullLayout,E=!t.calcdata||t.calcdata.length!==(t.data||[]).length;E&&h(t);for(var L=0;LY.range[0]?[1,2]:[2,1]);else{var W=Y.range[0],Z=Y.range[1];"log"===O?(0>=W&&0>=Z&&i(q+".autorange",!0),0>=W?W=Z/1e6:0>=Z&&(Z=W/1e6),i(q+".range[0]",Math.log(W)/Math.LN10),i(q+".range[1]",Math.log(Z)/Math.LN10)):(i(q+".range[0]",Math.pow(10,W)),i(q+".range[1]",Math.pow(10,Z)))}else i(q+".autorange",!0)}if("reverse"===D)H.range?H.range.reverse():(i(q+".autorange",!0),H.range=[1,0]),G.autorange?_=!0:x=!0;else if("annotations"===z.parts[0]||"shapes"===z.parts[0]){var K=z.parts[1],$=z.parts[0],Q=p[$]||[],J=P[R.titleCase($)],tt=Q[K]||{};2===z.parts.length&&("add"===v[C]||R.isPlainObject(v[C])?E[C]="remove":"remove"===v[C]?-1===K?(E[$]=Q,delete E[C]):E[C]=tt:R.log("???",v)),!a(tt,"x")&&!a(tt,"y")||R.containsAny(C,["color","opacity","align","dash"])||(_=!0),J.draw(t,K,z.parts.slice(2).join("."),v[C]),delete v[C]}else if("images"===z.parts[0]){var rt=R.objectFromPath(C,O);R.extendDeepAll(t.layout,rt),U.supplyLayoutDefaults(t.layout,t._fullLayout),U.draw(t)}else if("mapbox"===z.parts[0]&&"layers"===z.parts[1]){R.extendDeepAll(t.layout,R.objectFromPath(C,O));var nt=(t._fullLayout.mapbox||{}).layers||[],it=z.parts[2]+1-nt.length;for(d=0;it>d;d++)nt.push({});x=!0}else 0===z.parts[0].indexOf("scene")?x=!0:0===z.parts[0].indexOf("geo")?x=!0:0===z.parts[0].indexOf("ternary")?x=!0:!g._has("gl2d")||-1===C.indexOf("axis")&&"plot_bgcolor"!==z.parts[0]?"hiddenlabels"===C?_=!0:-1!==z.parts[0].indexOf("legend")?m=!0:-1!==C.indexOf("title")?y=!0:-1!==z.parts[0].indexOf("bgcolor")?b=!0:z.parts.length>1&&R.containsAny(z.parts[1],["tick","exponent","grid","zeroline"])?y=!0:-1!==C.indexOf(".linewidth")&&-1!==C.indexOf("axis")?y=b=!0:z.parts.length>1&&-1!==z.parts[1].indexOf("line")?b=!0:z.parts.length>1&&"mirror"===z.parts[1]?y=b=!0:"margin.pad"===C?y=b=!0:"margin"===z.parts[0]||"autorange"===z.parts[1]||"rangemode"===z.parts[1]||"type"===z.parts[1]||"domain"===z.parts[1]||C.match(/^(bar|box|font)/)?_=!0:-1!==["hovermode","dragmode"].indexOf(C)?k=!0:-1===["hovermode","dragmode","height","width","autosize"].indexOf(C)&&(x=!0):x=!0,z.set(O)}I&&I.add(t,et,[t,E],et,[t,M]),v.autosize&&(v=w(t,v)),(v.height||v.width||v.autosize)&&(_=!0);var at=Object.keys(v),ot=[N.previousPromises];if(x||_)ot.push(function(){return t.layout=void 0,_&&(t.calcdata=void 0),P.plot(t,"",p)});else if(at.length&&(N.supplyDefaults(t),g=t._fullLayout,m&&ot.push(function(){return V.draw(t),N.previousPromises(t)}),b&&ot.push(T),y&&ot.push(function(){return P.Axes.doTicks(t,"redraw"),L(t),N.previousPromises(t)}),k)){var st;for(X(t),st=N.getSubplotIds(g,"gl3d"),d=0;d1)};c(r.width)&&c(r.height)||s(new Error("Height and width should be pixel values."));var u=n.clone(e,{format:"png",height:r.height,width:r.width}),f=u.td;f.style.position="absolute",f.style.left="-5000px",document.body.appendChild(f);var h=n.getRedrawFunc(f);a.plot(f,u.data,u.layout,u.config).then(h).then(l).then(function(e){t(e)}).catch(function(t){s(t)})});return s}var i=t("fast-isnumeric"),a=t("../plotly"),o=t("../lib");e.exports=n},{"../lib":382,"../plotly":402,"../snapshot":471,"fast-isnumeric":117}],402:[function(t,e,r){"use strict";t("es6-promise").polyfill(),r.Lib=t("./lib"),r.util=t("./lib/svg_text_utils"),r.Queue=t("./lib/queue"),t("../build/plotcss"),r.MathJaxConfig=t("./fonts/mathjax_config"),r.defaultConfig=t("./plot_api/plot_config");var n=r.Plots=t("./plots/plots");r.Axes=t("./plots/cartesian/axes"),r.Fx=t("./plots/cartesian/graph_interact"),r.micropolar=t("./plots/polar/micropolar"),r.Color=t("./components/color"),r.Drawing=t("./components/drawing"),r.Colorscale=t("./components/colorscale"),r.Colorbar=t("./components/colorbar"),r.ErrorBars=t("./components/errorbars"),r.Annotations=t("./components/annotations"),r.Shapes=t("./components/shapes"),r.Legend=t("./components/legend"),r.Images=t("./components/images"),r.ModeBar=t("./components/modebar"),r.register=function(t){if(!t)throw new Error("No argument passed to Plotly.register.");t&&!Array.isArray(t)&&(t=[t]);for(var e=0;ec&&u>e&&(void 0===i[r]?a[f]=T.tickText(t,e):a[f]=s(t,e,String(i[r])),f++);return f=864e5?t._tickround="d":r>=36e5?t._tickround="H":r>=6e4?t._tickround="M":r>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(r/2)/Math.LN10);else{b(r)||(r=Number(r.substr(1))),t._tickround=2-Math.floor(Math.log(r)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var n=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(n)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((n-1)/3):t._tickexponent=n)}else"M"===r.charAt(0)?t._tickround=2===r.length?"m":"y":t._tickround=null}function o(t,e){var r=t.match(U),n=new Date(e);if(r){var i=Math.min(+r[1]||6,6),a=String(e/1e3%1+2.0000005).substr(2,i).replace(/0+$/,"")||"0";return y.time.format(t.replace(U,a))(n)}return y.time.format(t)(n)}function s(t,e,r){var n=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}function l(t,e,r,n){var i,a=e.x,s=t._tickround,l=new Date(a),c="";r&&t.hoverformat?i=o(t.hoverformat,a):t.tickformat?i=o(t.tickformat,a):(n&&(b(s)?s+=2:s={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[s]),"y"===s?i=I(l):"m"===s?i=N(l):(a!==t._tmin||r||(c="
"+I(l)),"d"===s?i=j(l):"H"===s?i=F(l):(a!==t._tmin||r||(c="
"+j(l)+", "+I(l)),i=D(l),"M"!==s&&(i+=B(l),"S"!==s&&(i+=h(m(a/1e3,1),t,"none",r).substr(1)))))),e.text=i+c}function c(t,e,r,n,i){var a=t.dtick,o=e.x;if(!n||"string"==typeof a&&"L"===a.charAt(0)||(a="L3"),t.tickformat||"string"==typeof a&&"L"===a.charAt(0))e.text=h(Math.pow(10,o),t,i,n);else if(b(a)||"D"===a.charAt(0)&&m(o+.01,1)<.1)if(-1!==["e","E","power"].indexOf(t.exponentformat)){var s=Math.round(o);0===s?e.text=1:1===s?e.text="10":s>1?e.text="10"+s+"":e.text="10\u2212"+-s+"",e.fontSize*=1.25}else e.text=h(Math.pow(10,o),t,"","fakehover"),"D1"===a&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==a.charAt(0))throw"unrecognized dtick "+String(a);e.text=String(Math.round(Math.pow(10,m(o,1)))),e.fontSize*=.75}if("D1"===t.dtick){var l=String(e.text).charAt(0);"0"!==l&&"1"!==l||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(0>o?.5:.25)))}}function u(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r=""),e.text=String(r)}function f(t,e,r,n,i){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide"),e.text=h(e.x,t,i,n)}function h(t,e,r,n){var i=0>t,o=e._tickround,s=r||e.exponentformat||"B",l=e._tickexponent,c=e.tickformat;if(n){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:b(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};a(u),o=(Number(u._tickround)||0)+4,l=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return y.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-o)/2;if("none"===s&&(l=0),t=Math.abs(t),f>t)t="0",i=!1;else{if(t+=f,l&&(t*=Math.pow(10,-l),o+=l),0===o)t=String(Math.floor(t));else if(0>o){t=String(Math.round(t)),t=t.substr(0,t.length+o);for(var h=o;0>h;h++)t+="0"}else{t=String(t);var d=t.indexOf(".")+1;d&&(t=t.substr(0,d+o).replace(/\.?0+$/,""))}t=_.numSeparate(t,e._gd._fullLayout.separators)}if(l&&"hide"!==s){var p;p=0>l?"\u2212"+-l:"power"!==s?"+"+l:String(l),"e"===s||("SI"===s||"B"===s)&&(l>12||-15>l)?t+="e"+p:"E"===s?t+="E"+p:"power"===s?t+="×10"+p+"":"B"===s&&9===l?t+="B":"SI"!==s&&"B"!==s||(t+=V[l/3+5])}return i?"\u2212"+t:t}function d(t,e){var r,n,i=[];for(r=0;r1)for(n=1;n2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.getAutoRange=function(t){var e,r=[],n=t._min[0].val,i=t._max[0].val;for(e=1;e0&&u>0&&f/u>h&&(l=o,c=s,h=f/u);return n===i?r=d?[n+1,"normal"!==t.rangemode?0:n-1]:["normal"!==t.rangemode?0:n-1,n+1]:h&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode&&l.val>=0?l={val:0,pad:0}:"nonnegative"===t.rangemode&&(l.val-h*l.pad<0&&(l={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),h=(c.val-l.val)/(t._length-l.pad-c.pad)),r=[l.val-h*l.pad,c.val+h*c.pad],r[0]===r[1]&&(r=[r[0]-1,r[0]+1]),d&&r.reverse()),r},T.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=T.getAutoRange(t);var r=t._gd.layout[t._name];r||(t._gd.layout[t._name]=r={}),r!==t&&(r.range=t.range.slice(),r.autorange=t.autorange)}},T.saveRangeInitial=function(t,e){for(var r=T.list(t,"",!0),n=!1,i=0;ip&&(p=g/10),c=t.c2l(p),u=t.c2l(g),y&&(c=Math.min(0,c),u=Math.max(0,u)),n(c)){for(d=!0,o=0;o=h?d=!1:s.val>=c&&s.pad<=h&&(t._min.splice(o,1),o--);d&&t._min.push({val:c,pad:y&&0===c?0:h})}if(n(u)){for(d=!0,o=0;o=u&&s.pad>=f?d=!1:s.val<=u&&s.pad<=f&&(t._max.splice(o,1),o--);d&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),r||(r={}),t._m||t.setScale();var a,o,s,l,c,u,f,h,d,p,g,v=e.length,m=r.padded?.05*t._length:0,y=r.tozero&&("linear"===t.type||"-"===t.type),x=n((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),_=n((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),w=n(r.vpadplus||r.vpad),k=n(r.vpadminus||r.vpad);for(a=0;6>a;a++)i(a);for(a=v-1;a>5;a--)i(a)}},T.autoBin=function(t,e,r,n){function i(t){return(1+100*(t-d)/f.dtick)%100<2}var a=_.aggNums(Math.min,null,t),o=_.aggNums(Math.max,null,t);if("category"===e.type)return{start:a-.5,end:o+.5,size:1};var s;if(r)s=(o-a)/r;else{var l=_.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(l.minDiff)/Math.LN10)),u=c*_.roundUp(l.minDiff/c,[.9,1.9,4.9,9.9],!0);s=Math.max(u,2*_.stdev(t)/Math.pow(t.length,n?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[a,o]};T.autoTicks(f,s);var h,d=T.tickIncrement(T.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;yg&&(p>.3*x||i(a)||i(o))){var w=f.dtick/2;d+=a>d+w?w:-w}var k=1+Math.floor((o-d)/f.dtick);h=d+k*f.dtick}else for(h=d;o>=h;)h=T.tickIncrement(h,f.dtick);return{start:d,end:h,size:f.dtick}},T.calcTicks=function(t){if("array"===t.tickmode)return n(t);if("auto"===t.tickmode||!t.dtick){var e,r=t.nticks;r||("category"===t.type?(e=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/e):(e="y"===t._id.charAt(0)?40:80,r=_.constrain(t._length/e,4,9)+1)),T.autoTicks(t,Math.abs(t.range[1]-t.range[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),a(t),t._tmin=T.tickFirst(t);var i=t.range[1]=s:s>=l)&&(o.push(l),!(o.length>1e3));l=T.tickIncrement(l,t.dtick,i));t._tmax=o[o.length-1];for(var c=new Array(o.length),u=0;u157788e5?(e/=315576e5,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*i(e,r,S)):e>12096e5?(e/=26298e5,t.dtick="M"+i(e,1,C)):e>432e5?(t.dtick=i(e,864e5,P),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=i(e,36e5,C):e>3e4?t.dtick=i(e,6e4,z):e>500?t.dtick=i(e,1e3,z):(r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,S));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var n=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/n,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+i(e,r,S)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,S));if(0===t.dtick&&(t.dtick=1),!b(t.dtick)&&"string"!=typeof t.dtick){var a=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(a)}},T.tickIncrement=function(t,e,r){var n=r?-1:1;if(b(e))return t+n*e;var i=e.charAt(0),a=n*Number(e.substr(1));if("M"===i){var o=new Date(t);return o.setMonth(o.getMonth()+a)}if("L"===i)return Math.log(Math.pow(10,t)+a)/Math.LN10;if("D"===i){var s="D2"===e?O:R,l=t+.01*n,c=_.roundUp(m(l,1),s,r);return Math.floor(l)+Math.log(y.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.range[1]n:n>c;)c=T.tickIncrement(c,i,e);return c}if("L"===u)return Math.log(r((Math.pow(10,n)-a)/f)*f+a)/Math.LN10;if("D"===u){var h="D2"===i?O:R,d=_.roundUp(m(n,1),h,e);return Math.floor(n)+Math.log(y.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(i)};var I=y.time.format("%Y"),N=y.time.format("%b %Y"),j=y.time.format("%b %-d"),F=y.time.format("%b %-d %Hh"),D=y.time.format("%H:%M"),B=y.time.format(":%S"),U=/%(\d?)f/g;T.tickText=function(t,e,r){function n(n){var i;return void 0===n?!0:r?"none"===n:(i={first:t._tmin,last:t._tmax}[n],"all"!==n&&e!==i)}var i,a,o=s(t,e),h="array"===t.tickmode,d=r||h;if(h&&Array.isArray(t.ticktext)){var p=Math.abs(t.range[1]-t.range[0])/1e4;for(a=0;a1&&er&&(A=90),i(u,A)}c._lastangle=A}return o(e),e+" done"}function l(){c._boundingBox=r.node().getBoundingClientRect()}var u=r.selectAll("g."+C).data(L,S);if(!c.showticklabels||!b(n))return u.remove(),void o(e);var f,h,p,m,x;"x"===v?(x="bottom"===B?1:-1,f=function(t){return t.dx+I*x},m=n+(O+R)*x,h=function(t){return t.dy+m+t.fontSize*("bottom"===B?1:-.5)},p=function(t){return b(t)&&0!==t&&180!==t?0>t*x?"end":"start":"middle"}):(x="right"===B?1:-1,h=function(t){return t.dy+t.fontSize/2-I*x},f=function(t){return t.dx+n+(O+R+(90===Math.abs(c.tickangle)?t.fontSize/2:0))*x},p=function(t){return b(t)&&90===Math.abs(t)?"middle":"right"===B?"start":"end"});var k=0,A=0,T=[];u.enter().append("g").classed(C,1).append("text").attr("text-anchor","middle").each(function(e){var r=y.select(this),n=t._promises.length;r.call(M.setPosition,f(e),h(e)).call(M.font,e.font,e.fontSize,e.fontColor).text(e.text).call(w.convertToTspans),n=t._promises[n],n?T.push(t._promises.pop().then(function(){i(r,c.tickangle)})):i(r,c.tickangle)}),u.exit().remove(),u.each(function(t){k=Math.max(k,t.fontSize)}),i(u,c._lastangle||c.tickangle);var E=_.syncOrAsync([a,s,l]);return E&&E.then&&t._promises.push(E),E}function o(e){if(!r){var n,i,a,o,s=E.getFromId(t,e),l=y.select(t).selectAll("g."+e+"tick"),c={selection:l,side:s.side},f=e.charAt(0),h=t._fullLayout._size,d=1.5,p=s.titlefont.size;if(l.size()){var g=y.select(l.node().parentNode).attr("transform").match(/translate\(([-\.\d]+),([-\.\d]+)\)/);g&&(c.offsetLeft=+g[1],c.offsetTop=+g[2])}"x"===f?(i="free"===s.anchor?{_offset:h.t+(1-(s.position||0))*h.h,_length:0}:E.getFromId(t,s.anchor),a=s._offset+s._length/2,o=i._offset+("top"===s.side?-10-p*(d+(s.showticklabels?1:0)):i._length+10+p*(d+(s.showticklabels?1.5:.5))),s.rangeslider&&s.rangeslider.visible&&s._boundingBox&&(o+=(u.height-u.margin.b-u.margin.t)*s.rangeslider.thickness+s._boundingBox.height),c.side||(c.side="bottom")):(i="free"===s.anchor?{_offset:h.l+(s.position||0)*h.w,_length:0}:E.getFromId(t,s.anchor),o=s._offset+s._length/2,a=i._offset+("right"===s.side?i._length+10+p*(d+(s.showticklabels?1:.5)):-10-p*(d+(s.showticklabels?.5:0))),n={rotate:"-90",offset:0},c.side||(c.side="left")),k.draw(t,e+"title",{propContainer:s,propName:s._name+".title",dfltName:f.toUpperCase()+" axis",avoid:c,transform:n,attributes:{x:a,y:o,"text-anchor":"middle"}})}}function s(t,e){return t.visible!==!0||t.xaxis+t.yaxis!==e?!1:x.Plots.traceIs(t,"bar")&&t.orientation==={x:"h",y:"v"}[v]?!0:t.fill&&t.fill.charAt(t.fill.length-1)===v}function l(e,r,i){var a=e.gridlayer,o=e.zerolinelayer,l=e["hidegrid"+v]?[]:V,u=c._gridpath||"M0,0"+("x"===v?"v":"h")+r._length,f=a.selectAll("path."+z).data(c.showgrid===!1?[]:l,S);if(f.enter().append("path").classed(z,1).classed("crisp",1).attr("d",u).each(function(t){c.zeroline&&("linear"===c.type||"-"===c.type)&&Math.abs(t.x)g;g++){var y=c.mirrors[o._id+h[g]];"ticks"!==y&&"labels"!==y||(f[g]=!0)}return void 0!==n[2]&&(f[2]=!0),f.forEach(function(t,e){var r=n[e],i=U[e];t&&b(r)&&(d+=p(r+R*i,i*c.ticklen))}),i(r,d),l(e,o,t),a(r,n[3])}}).filter(function(t){return t&&t.then});return H.length?Promise.all(H):0},T.swap=function(t,e){for(var r=d(t,e),n=0;n2*n; +}function u(t){for(var e,r=Math.max(1,(t.length-1)/1e3),n=0,i=0,a=0;a2*n}var f=t("fast-isnumeric"),h=t("tinycolor2").mix,d=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),b=t("./tick_label_defaults"),x=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),A=t("./axis_ids");e.exports=function(t,e,r,i){function a(r,n){return d.coerce2(t,e,v,r,n)}var o=i.letter,s=i.font||{},l="Click to enter "+(i.title||o.toUpperCase()+" axis")+" title";i.name&&(e._name=i.name,e._id=A.name2id(i.name));var c=r("type");"-"===c&&(n(e,i.data),"-"===e.type?e.type="linear":c=t.type=e.type),_(e);var u=r("color"),p=u===t.color?u:s.color;r("title",l),d.coerceFont(r,"titlefont",{family:s.family,size:Math.round(1.2*s.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),M=r("autorange",!k);M&&r("rangemode");var T=r("range",[-1,"x"===o?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),d.noneOrAll(t.range,e.range,[0,1]),r("fixedrange"),m(t,e,r,c),b(t,e,r,c,i),y(t,e,r,i),x(t,e,r);var E=a("linecolor",u),L=a("linewidth"),S=r("showline",!!E||!!L);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&r("mirror");var C=a("gridcolor",h(u,i.bgColor,g).toRgbString()),z=a("gridwidth"),P=r("showgrid",i.showGrid||!!C||!!z);P||(delete e.gridcolor,delete e.gridwidth);var R=a("zerolinecolor",u),O=a("zerolinewidth"),I=r("zeroline",i.showGrid||!!R||!!O);return I||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===c?w(o,e.categoryorder,e.categoryarray,i.data):[],e}},{"../../components/color/attributes":302,"../../lib":382,"../plots":454,"./axis_ids":407,"./category_order_defaults":408,"./clean_datum":409,"./layout_attributes":414,"./ordered_categories":416,"./set_convert":419,"./tick_label_defaults":420,"./tick_mark_defaults":421,"./tick_value_defaults":422,"fast-isnumeric":117,tinycolor2:274}],407:[function(t,e,r){"use strict";function n(t,e,r){function n(t,r){for(var n=Object.keys(t),i=/^[xyz]axis[0-9]*/,a=[],o=0;o0;a&&(n="array");var o=r("categoryorder",n);"array"===o&&r("categoryarray"),a||"array"!==o||(e.categoryorder="trace")}}},{}],409:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return i.ms2DateTime(t);if("string"!=typeof t&&!n(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){i.error(e,t)}return t}},{"../../lib":382,"fast-isnumeric":117}],410:[function(t,e,r){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5,REDRAWDELAY:50}},{}],411:[function(t,e,r){"use strict";function n(t,e){var r,n=t.range[e],i=Math.abs(n-t.range[1-e]);return"date"===t.type?c.ms2DateTime(n,i):"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,o.format("."+r+"g")(Math.pow(10,n))):(r=Math.floor(Math.log(Math.abs(n))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,o.format("."+String(r)+"g")(n))}function i(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function a(t){o.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var o=t("d3"),s=t("tinycolor2"),l=t("../../plotly"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../components/color"),h=t("../../components/drawing"),d=t("../../lib/setcursor"),p=t("../../components/dragelement"),g=t("./axes"),v=t("./select"),m=t("./constants"),y=!0;e.exports=function(t,e,r,o,b,x,_,w){function k(t,e){for(var r=0;r.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+ht+", "+dt+")").attr("d",ot+"Z"),ut=ft.append("path").attr("class","zoombox-corners").style({fill:f.background,stroke:f.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+ht+", "+dt+")").attr("d","M0,0Z"),T();for(var a=0;ai?(lt="",it.r=it.l,it.t=it.b,ut.attr("d","M0,0Z")):(it.t=0,it.b=V,lt="x",ut.attr("d","M"+(it.l-.5)+","+(nt-H-.5)+"h-3v"+(2*H+1)+"h3ZM"+(it.r+.5)+","+(nt-H-.5)+"h3v"+(2*H+1)+"h-3Z")):!Z||i.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),ut.transition().style("opacity",1).duration(200),st=!0)}function L(t,e,r){var n,i,a;for(n=0;nzoom back out","long"),y=!1)))}function C(e,r){var i=1===(_+w).length;if(e)I();else if(2!==r||i){if(1===r&&i){var a=_?B[0]:D[0],o="s"===_||"w"===w?0:1,s=a._name+".range["+o+"]",c=n(a,o),f="left",h="middle";if(a.fixedrange)return;_?(h="n"===_?"top":"bottom","right"===a.side&&(f="right")):"e"===w&&(f="right"),J.call(u.makeEditable,null,{immediate:!0,background:j.paper_bgcolor,text:String(c),fill:a.tickfont?a.tickfont.color:"#444",horizontalAlign:f,verticalAlign:h}).on("edit",function(e){var r="category"===a.type?a.c2l(e):a.d2l(e);void 0!==r&&l.relayout(t,s,r)})}}else O()}function z(e){function r(t,e,r){if(!t.fixedrange){A(t.range);var n=t.range,i=n[0]+(n[1]-n[0])*e;t.range=[i+(n[0]-i)*r,i+(n[1]-i)*r]}}if(t._context.scrollZoom||j._enablescrollzoom){var n=t.querySelector(".plotly");if(!(n.scrollHeight-n.clientHeight>10||n.scrollWidth-n.clientWidth>10)){clearTimeout(gt);var i=-e.deltaY;if(isFinite(i)||(i=e.wheelDelta/10),!isFinite(i))return void c.log("Did not find wheel motion attributes: ",e);var a,o=Math.exp(-Math.min(Math.max(i,-20),20)/100),s=mt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-s.left)/s.width,u=pt[0]+pt[2]*l,f=(s.bottom-e.clientY)/s.height,h=pt[1]+pt[3]*(1-f);if(w){for(a=0;a=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function i(t,e,r){for(var i=1-e,a=0,o=0;o0;n--)r.push(e);return r}function i(t,e){for(var r=[],n=0;nT;T++){var E=a[T],L=d[E];if(L)A[T]=w.getFromId(t,L.xaxis._id),M[T]=w.getFromId(t,L.yaxis._id);else{var S=o[E]._subplot;A[T]=S.xaxis,M[T]=S.yaxis}}var C=e.hovermode||o.hovermode;if(-1===["x","y","closest"].indexOf(C)||!t.calcdata||t.querySelector(".zoombox")||t._dragging)return _.unhoverRaw(t,e);var z,P,R,O,I,N,j,F,D,B,U,V,q=[],H=[];if(Array.isArray(e))for(C="array",R=0;RG||G>X.width||0>Y||Y>X.height)return _.unhoverRaw(t,e)}else G="xpx"in e?e.xpx:A[0]._length/2,Y="ypx"in e?e.ypx:M[0]._length/2;if(z="xval"in e?n(a,e.xval):i(A,G),P="yval"in e?n(a,e.yval):i(M,Y),!g(z[0])||!g(P[0]))return v.warn("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var W=1/0;for(O=0;O1||-1!==N.hoverinfo.indexOf("name")?N.name:void 0,index:!1,distance:Math.min(W,k.MAXDIST),color:b.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},V=q.length,"array"===F){var Z=e[O];"pointNumber"in Z?(U.index=Z.pointNumber,F="closest"):(F="","xval"in Z&&(D=Z.xval,F="x"),"yval"in Z&&(B=Z.yval,F=F?"closest":"y"))}else D=z[j],B=P[j];if(N._module&&N._module.hoverPoints){var K=N._module.hoverPoints(U,D,B,F);if(K)for(var $,Q=0;QV&&(q.splice(0,V),W=q[0].distance)}if(0===q.length)return _.unhoverRaw(t,e);var J="y"===C&&H.length>1;q.sort(function(t,e){return t.distance-e.distance});var tt=b.combine(o.plot_bgcolor||b.background,o.paper_bgcolor),et={hovermode:C,rotateLabels:J,bgColor:tt,container:o._hoverlayer,outerContainer:o._paperdiv},rt=c(q,et);u(q,J?"xa":"ya"),f(rt,J);var nt=t._hoverdata,it=[];for(R=0;R128?"#000":b.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,r=u.textContent||"",r.length>15&&(r=r.substr(0,12)+"...")}void 0!==t.extraText&&(n+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(n+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(n+="y: "+t.yLabel+"
"),n+=(n?"z: ":"")+t.zLabel):M&&t[i+"Label"]===g?n=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(n=t.yLabel):n=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(n+=(n?"
":"")+t.text),""===n&&(""===r&&e.remove(),n=r);var f=e.select("text.nums").style("fill",c).call(x.setPosition,0,0).text(n).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(x.setPosition,0,0);var h=e.select("text.name"),v=0;r&&r!==n?(h.style("fill",l).text(r).call(x.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),h.selectAll("tspan.line").call(x.setPosition,0,0),v=h.node().getBoundingClientRect().width+2*P):(h.remove(),e.select("rect").remove()),e.select("path").style({fill:l,stroke:c});var m,k,E=f.node().getBoundingClientRect(),L=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),R=Math.abs(t.y1-t.y0),O=E.width+z+P+v;t.ty0=_-E.top,t.bx=E.width+2*P,t.by=E.height+2*P,t.anchor="start",t.txwidth=E.width,t.tx2width=v,t.offset=0,a?(t.pos=L,m=A>=S+R/2+O,k=S-R/2-O>=0,"top"!==t.idealAlign&&m||!k?m?(S+=R/2,t.anchor="start"):t.anchor="middle":(S-=R/2,t.anchor="end")):(t.pos=S,m=w>=L+C/2+O,k=L-C/2-O>=0,"left"!==t.idealAlign&&m||!k?m?(L+=C/2,t.anchor="start"):t.anchor="middle":(L-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&h.attr("text-anchor",t.anchor),e.attr("transform","translate("+L+","+S+")"+(a?"rotate("+T+")":""))}),S}function u(t,e){function r(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(.01>a)){if(-.01>i){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos>e.pmax-1&&(l.del=!0,c--);for(o=0;o=c);o++)if(l=t[o],l.pos=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos+l.dp+l.size>e.pmax&&(l.del=!0,c--)}}}for(var n,i,a,o,s,l,c,u=0,f=t.map(function(t,r){var n=t[e];return[{i:r,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===n._id.charAt(0)?L:1)/2,pmin:n._offset,pmax:n._offset+n._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(s=d.length-1;s>=0;s--)d[s].dp+=i;for(h.push.apply(h,d),f.splice(o+1,1),c=0,s=h.length-1;s>=0;s--)c+=h[s].dp;for(a=c/h.length,s=h.length-1;s>=0;s--)h[s].dp-=a;n=!1}else o++}f.forEach(r)}for(o=f.length-1;o>=0;o--){var v=f[o];for(s=v.length-1;s>=0;s--){var m=v[s],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var r=d.select(this);if(t.del)return void r.remove();var n="end"===t.anchor?-1:1,i=r.select("text.nums"),a={start:1,end:-1,middle:0}[t.anchor],o=a*(z+P),s=o+a*(t.txwidth+P),l=0,c=t.offset;"middle"===t.anchor&&(o-=t.tx2width/2,s-=t.tx2width/2),e&&(c*=-C,l=t.offset*S),r.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(n*z+l)+","+(z+c)+"v"+(t.by/2-z)+"h"+n*t.bx+"v-"+t.by+"H"+(n*z+l)+"V"+(c-z)+"Z"),i.call(x.setPosition,o+l,c+t.ty0-t.by/2+P).selectAll("tspan.line").attr({x:i.attr("x"),y:i.attr("y")}),t.tx2width&&(r.select("text.name, text.name tspan.line").call(x.setPosition,s+a*P+l,c+t.ty0-t.by/2+P),r.select("rect").call(x.setRect,s+(a-1)*t.tx2width/2+l,c-t.by/2-1,t.tx2width,t.by+2))})}function h(t,e,r){if(!e.target)return!1;if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}var d=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),b=t("../../components/color"),x=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),A=t("./dragbox"),M=e.exports={};M.unhover=_.unhover,M.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},M.supplyLayoutDefaults=function(t,e,r){function n(r,n){return v.coerce(t,e,M.layoutAttributes,r,n)}n("dragmode");var i;if(e._has("cartesian")){var a=e._isHoriz=M.isHoriz(r);i=a?"y":"x"}else i="closest";n("hovermode",i)},M.isHoriz=function(t){for(var e=!0,r=0;rt._lastHoverTime+k.HOVERMINTIME?(o(t,e,r),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){o(t,e,r),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},M.getDistanceFunction=function(t,e,r,n){return"closest"===t?n||a(e,r):"x"===t?e:r},M.getClosest=function(t,e,r){if(r.index!==!1)r.index>=0&&r.indext*e||0===t?k.MAXDIST*(.6-.3/Math.max(3,Math.abs(t-e))):1/0}},{"../../components/color":303,"../../components/dragelement":324,"../../components/drawing":326,"../../lib":382,"../../lib/events":376,"../../lib/svg_text_utils":395,"./axes":405,"./constants":410,"./dragbox":411,d3:113,"fast-isnumeric":117,tinycolor2:274}],413:[function(t,e,r){"use strict";var n=t("../plots"),i=t("./constants");r.name="cartesian",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex=i.idRegex,r.attrRegex=i.attrRegex,r.attributes=t("./attributes"),r.plot=function(t){function e(t,e){for(var r=[],n=0;nf[1]-.01&&(e.domain=[0,1]),i.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":382,"fast-isnumeric":117}],418:[function(t,e,r){"use strict";function n(t){return t._id}var i=t("../../lib/polygon"),a=t("../../components/color"),o=t("./axes"),s=t("./constants"),l=i.filter,c=i.tester,u=s.MINSELECT;e.exports=function(t,e,r,i,f){function h(t){var e="y"===t._id.charAt(0)?1:0;return function(r){return t.p2d(r[e])}}function d(t,e){return t-e}var p,g=i.gd._fullLayout._zoomlayer,v=i.element.getBoundingClientRect(),m=i.plotinfo.x()._offset,y=i.plotinfo.y()._offset,b=e-v.left,x=r-v.top,_=b,w=x,k="M"+b+","+x,A=i.xaxes[0]._length,M=i.yaxes[0]._length,T=i.xaxes.map(n),E=i.yaxes.map(n),L=i.xaxes.concat(i.yaxes);"lasso"===f&&(p=l([[b,x]],s.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",k+"Z");var C,z,P,R,O,I=g.append("path").attr("class","zoombox-corners").style({fill:a.background,stroke:a.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),N=[],j=i.gd,F=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(0>=e&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-3*u*Math.abs(n-i))}return o.BADNUM}function r(t){return Math.pow(10,t)}function c(t){return i(t)?Number(t):o.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?r:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,r=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var n=l.getFromId(t._gd,t.overlaying);t.domain=n.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;2>e;e++)i(t.range[e])||(t.range[e]=i(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=r.t+(1-t.domain[1])*r.h,t._length=r.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=r.l+t.domain[0]*r.w,t._length=r.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw a.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return i(e)?n.round(t._b+t._m*e,2):o.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,r){return t.l2p(t.c2l(e,r))},t.p2c=function(e){return t.l2c(t.p2l(e))},-1!==["linear","log","-"].indexOf(t.type))t.c2d=c,t.d2c=function(t){return t=s(t),i(t)?Number(t):o.BADNUM},t.d2l=function(e,r){return"log"===t.type?t.c2l(t.d2c(e),r):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return i(t)?a.ms2DateTime(t):o.BADNUM},t.d2c=function(t){return i(t)?Number(t):a.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(a.dateTime2ms);!i(t.range[0])&&i(f[0])&&(t.range[0]=f[0]),!i(t.range[1])&&i(f[1])&&(t.range[1]=f[1])}catch(h){a.error(h,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&-1===t._categories.indexOf(e)&&t._categories.push(e);var r=t._categories.indexOf(e);return-1===r?o.BADNUM:r},t.d2l=t.d2c);t.makeCalcdata=function(e,r){var n,i,a;if(r in e)for(n=e[r],i=new Array(n.length),a=0;an?"0":"1.0"}var r=this.framework,n=r.select("g.choroplethlayer"),i=r.select("g.scattergeolayer"),a=this.projection,o=this.path,s=this.clipAngle;r.selectAll("path.basepath").attr("d",o),r.selectAll("path.graticulepath").attr("d",o),n.selectAll("path.choroplethlocation").attr("d",o),n.selectAll("path.basepath").attr("d",o),i.selectAll("path.js-line").attr("d",o),null!==s?(i.selectAll("path.point").style("opacity",e).attr("transform",t),i.selectAll("text").style("opacity",e).attr("transform",t)):(i.selectAll("path.point").attr("transform",t),i.selectAll("text").attr("transform",t))}},{"../../components/color":303,"../../components/drawing":326,"../../constants/xmlns_namespaces":370,"../../lib/filter_visible":378,"../../lib/topojson_utils":396,"../../plots/cartesian/axes":405,"./constants":424,"./projections":432,"./set_scale":433,"./zoom":434,"./zoom_reset":435,d3:113,topojson:275}],426:[function(t,e,r){"use strict";var n=t("./geo"),i=t("../../plots/plots");r.name="geo",r.attr="geo",r.idRoot="geo",r.idRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"geo");void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var o=0;o=n}function a(t,e){for(var r=e[0],n=e[1],i=!1,a=0,o=t.length,s=o-1;o>a;s=a++){var l=t[a],c=l[0],u=l[1],f=t[s],h=f[0],d=f[1];u>n^d>n&&(h-c)*(n-u)/(d-u)+c>r&&(i=!i)}return i}function o(t){return t?t/Math.sin(t):1}function s(t){return t>1?P:-1>t?-P:Math.asin(t)}function l(t){return t>1?0:-1>t?z:Math.acos(t)}function c(t,e){var r=(2+P)*Math.sin(e);e/=2;for(var n=0,i=1/0;10>n&&Math.abs(i)>S;n++){var a=Math.cos(e);e-=i=(e+Math.sin(e)*(a+2)-r)/(2*a*(1+a))}return[2/Math.sqrt(z*(4+z))*t*(1+Math.cos(e)),2*Math.sqrt(z/(4+z))*Math.sin(e)]}function u(t,e){function r(r,n){var i=j(r/e,n);return i[0]*=t,i}return arguments.length<2&&(e=t),1===e?j:e===1/0?h:(r.invert=function(r,n){var i=j.invert(r/t,n);return i[0]*=e,i},r)}function f(){var t=2,e=N(u),r=e(t);return r.coefficient=function(r){return arguments.length?e(t=+r):t},r}function h(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function d(t,e){return[3*t/(2*z)*Math.sqrt(z*z/3-e*e),e]}function p(t,e){return[t,1.25*Math.log(Math.tan(z/4+.4*e))]}function g(t){return function(e){var r,n=t*Math.sin(e),i=30;do e-=r=(e+Math.sin(e)-n)/(1+Math.cos(e));while(Math.abs(r)>S&&--i>0);return e/2}}function v(t,e,r){function n(r,n){return[t*r*Math.cos(n=i(n)),e*Math.sin(n)]}var i=g(r);return n.invert=function(n,i){var a=s(i/e);return[n/(t*Math.cos(a)),s((2*a+Math.sin(2*a))/r)]},n}function m(t,e){var r=e*e,n=r*r;return[t*(.8707-.131979*r+n*(-.013791+n*(.003971*r-.001529*n))),e*(1.007226+r*(.015085+n*(-.044475+.028874*r-.005916*n)))]}function y(t,e){var r,n=Math.min(18,36*Math.abs(e)/z),i=Math.floor(n),a=n-i,o=(r=D[i])[0],s=r[1],l=(r=D[++i])[0],c=r[1],u=(r=D[Math.min(19,++i)])[0],f=r[1];return[t*(l+a*(u-o)/2+a*a*(u-2*l+o)/2),(e>0?P:-P)*(c+a*(f-s)/2+a*a*(f-2*c+s)/2)]}function b(t,e){return[t*Math.cos(e),e]}function x(t,e){var r=Math.cos(e),n=o(l(r*Math.cos(t/=2)));return[2*r*Math.sin(t)*n,Math.sin(e)*n]}function _(t,e){var r=x(t,e);return[(r[0]+t/P)/2,(r[1]+e)/2]}t.geo.project=function(t,e){var n=e.stream;if(!n)throw new Error("not yet supported");return(t&&w.hasOwnProperty(t.type)?w[t.type]:r)(t,n)};var w={Feature:e,FeatureCollection:function(t,r){return{type:"FeatureCollection",features:t.features.map(function(t){return e(t,r)})}}},k=[],A=[],M={point:function(t,e){k.push([t,e])},result:function(){var t=k.length?k.length<2?{type:"Point",coordinates:k[0]}:{type:"MultiPoint",coordinates:k}:null;return k=[],t}},T={lineStart:n,point:function(t,e){k.push([t,e])},lineEnd:function(){k.length&&(A.push(k),k=[])},result:function(){var t=A.length?A.length<2?{type:"LineString",coordinates:A[0]}:{type:"MultiLineString",coordinates:A}:null;return A=[],t}},E={polygonStart:n,lineStart:n,point:function(t,e){k.push([t,e])},lineEnd:function(){var t=k.length;if(t){do k.push(k[0].slice());while(++t<4);A.push(k),k=[]}},polygonEnd:n,result:function(){if(!A.length)return null;var t=[],e=[];return A.forEach(function(r){i(r)?t.push([r]):e.push(r)}),e.forEach(function(e){var r=e[0];t.some(function(t){return a(t[0],r)?(t.push(e),!0):void 0})||t.push([e])}),A=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},L={Point:M,MultiPoint:M,LineString:T,MultiLineString:T,Polygon:E,MultiPolygon:E,Sphere:E},S=1e-6,C=S*S,z=Math.PI,P=z/2,R=(Math.sqrt(z),z/180),O=180/z,I=t.geo.projection,N=t.geo.projectionMutator;t.geo.interrupt=function(e){function r(t,r){for(var n=0>r?-1:1,i=l[+(0>r)],a=0,o=i.length-1;o>a&&t>i[a][2][0];++a);var s=e(t-i[a][1][0],r);return s[0]+=e(i[a][1][0],n*r>n*i[a][0][1]?i[a][0][1]:r)[0],s}function n(){s=l.map(function(t){return t.map(function(t){var r,n=e(t[0][0],t[0][1])[0],i=e(t[2][0],t[2][1])[0],a=e(t[1][0],t[0][1])[1],o=e(t[1][0],t[1][1])[1];return a>o&&(r=a,a=o,o=r),[[n,a],[i,o]]})})}function i(){for(var e=1e-6,r=[],n=0,i=l[0].length;i>n;++n){var o=l[0][n],s=180*o[0][0]/z,c=180*o[0][1]/z,u=180*o[1][1]/z,f=180*o[2][0]/z,h=180*o[2][1]/z;r.push(a([[s+e,c+e],[s+e,u-e],[f-e,u-e],[f-e,h+e]],30))}for(var n=l[1].length-1;n>=0;--n){var o=l[1][n],s=180*o[0][0]/z,c=180*o[0][1]/z,u=180*o[1][1]/z,f=180*o[2][0]/z,h=180*o[2][1]/z;r.push(a([[f-e,h-e],[f-e,u+e],[s+e,u+e],[s+e,c-e]],30))}return{type:"Polygon",coordinates:[t.merge(r)]}}function a(t,e){for(var r,n,i,a=-1,o=t.length,s=t[0],l=[];++ac;++c)l.push([s[0]+c*n,s[1]+c*i]);s=r}return l.push(r),l}function o(t,e){return Math.abs(t[0]-e[0])n)],a=l[+(0>n)],c=0,u=i.length;u>c;++c){var f=i[c];if(f[0][0]<=t&&tS&&--i>0);return[t/(.8707+(a=n*n)*(-.131979+a*(-.013791+a*a*a*(.003971-.001529*a)))),n]},(t.geo.naturalEarth=function(){return I(m)}).raw=m;var D=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];D.forEach(function(t){t[1]*=1.0144}),y.invert=function(t,e){var r=e/P,n=90*r,i=Math.min(18,Math.abs(n/5)),a=Math.max(0,Math.floor(i));do{var o=D[a][1],s=D[a+1][1],l=D[Math.min(19,a+2)][1],c=l-o,u=l-2*s+o,f=2*(Math.abs(r)-s)/c,h=u/c,d=f*(1-h*f*(1-2*h*f));if(d>=0||1===a){n=(e>=0?5:-5)*(d+i);var p,g=50;do i=Math.min(18,Math.abs(n)/5),a=Math.floor(i),d=i-a,o=D[a][1],s=D[a+1][1],l=D[Math.min(19,a+2)][1],n-=(p=(e>=0?P:-P)*(s+d*(l-o)/2+d*d*(l-2*s+o)/2)-e)*O;while(Math.abs(p)>C&&--g>0);break}}while(--a>=0);var v=D[a][0],m=D[a+1][0],y=D[Math.min(19,a+2)][0];return[t/(m+d*(y-v)/2+d*d*(y-2*m+v)/2),n*R]},(t.geo.robinson=function(){return I(y)}).raw=y,b.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return I(b)}).raw=b,x.invert=function(t,e){if(!(t*t+4*e*e>z*z+S)){var r=t,n=e,i=25;do{var a,o=Math.sin(r),s=Math.sin(r/2),c=Math.cos(r/2),u=Math.sin(n),f=Math.cos(n),h=Math.sin(2*n),d=u*u,p=f*f,g=s*s,v=1-p*c*c,m=v?l(f*c)*Math.sqrt(a=1/v):a=0,y=2*m*f*s-t,b=m*u-e,x=a*(p*g+m*f*c*d),_=a*(.5*o*h-2*m*u*s),w=.25*a*(h*s-m*u*p*o),k=a*(d*c+m*g*f),A=_*w-k*x;if(!A)break;var M=(b*_-y*k)/A,T=(y*w-b*x)/A;r-=M,n-=T}while((Math.abs(M)>S||Math.abs(T)>S)&&--i>0);return[r,n]}},(t.geo.aitoff=function(){return I(x)}).raw=x,_.invert=function(t,e){var r=t,n=e,i=25;do{var a,o=Math.cos(n),s=Math.sin(n),c=Math.sin(2*n),u=s*s,f=o*o,h=Math.sin(r),d=Math.cos(r/2),p=Math.sin(r/2),g=p*p,v=1-f*d*d,m=v?l(o*d)*Math.sqrt(a=1/v):a=0,y=.5*(2*m*o*p+r/P)-t,b=.5*(m*s+n)-e,x=.5*a*(f*g+m*o*d*u)+.5/P,_=a*(h*c/4-m*s*p),w=.125*a*(c*p-m*s*f*h),k=.5*a*(u*d+m*g*o)+.5,A=_*w-k*x,M=(b*_-y*k)/A,T=(y*w-b*x)/A;r-=M,n-=T}while((Math.abs(M)>S||Math.abs(T)>S)&&--i>0);return[r,n]},(t.geo.winkel3=function(){return I(_)}).raw=_}e.exports=n},{}],433:[function(t,e,r){"use strict";function n(t,e){var r=t.projection,n=t.lonaxis,o=t.lataxis,l=t.domain,c=t.framewidth||0,u=e.w*(l.x[1]-l.x[0]),f=e.h*(l.y[1]-l.y[0]),h=n.range[0]+s,d=n.range[1]-s,p=o.range[0]+s,g=o.range[1]-s,v=n._fullRange[0]+s,m=n._fullRange[1]-s,y=o._fullRange[0]+s,b=o._fullRange[1]-s;r._translate0=[e.l+u/2,e.t+f/2];var x=d-h,_=g-p,w=[h+x/2,p+_/2],k=r._rotate;r._center=[w[0]+k[0],w[1]+k[1]];var A=function(e){function n(t){return Math.min(_*u/(t[1][0]-t[0][0]),_*f/(t[1][1]-t[0][1]))}var o,s,l,x,_=e.scale(),w=r._translate0,k=i(h,p,d,g),A=i(v,y,m,b);l=a(e,k),o=n(l),x=a(e,A),r._fullScale=n(x),e.scale(o),l=a(e,k),s=[w[0]-l[0][0]+c,w[1]-l[0][1]+c],r._translate=s,e.translate(s),l=a(e,k),t._isAlbersUsa||e.clipExtent(l),o=r.scale*o,r._scale=o,t._width=Math.round(l[1][0])+c,t._height=Math.round(l[1][1])+c,t._marginX=(u-Math.round(l[1][0]))/2,t._marginY=(f-Math.round(l[1][1]))/2};return A}function i(t,e,r,n){var i=(r-t)/4;return{type:"Polygon",coordinates:[[[t,e],[t,n],[t+i,n],[t+2*i,n],[t+3*i,n],[r,n],[r,e],[r-i,e],[r-2*i,e],[r-3*i,e],[t,e]]]}}function a(t,e){return o.geo.path().projection(t).bounds(e)}var o=t("d3"),s=t("./constants").clipPad;e.exports=n},{"./constants":424,d3:113}],434:[function(t,e,r){"use strict";function n(t,e){var r;return(r=e._isScoped?a:e._clipAngle?s:o)(t,e.projection)}function i(t,e){var r=e._fullScale;return _.behavior.zoom().translate(t.translate()).scale(t.scale()).scaleExtent([.5*r,100*r])}function a(t,e){function r(){_.select(this).style(A)}function n(){o.scale(_.event.scale).translate(_.event.translate),t.render()}function a(){_.select(this).style(M)}var o=t.projection,s=i(o,e);return s.on("zoomstart",r).on("zoom",n).on("zoomend",a),s}function o(t,e){function r(t){return v.invert(t)}function n(t){var e=v(r(t));return Math.abs(e[0]-t[0])>y||Math.abs(e[1]-t[1])>y}function a(){_.select(this).style(A),l=_.mouse(this),c=v.rotate(),u=v.translate(),f=c,h=r(l)}function o(){return d=_.mouse(this),n(l)?(m.scale(v.scale()),void m.translate(v.translate())):(v.scale(_.event.scale),v.translate([u[0],_.event.translate[1]]),h?r(d)&&(g=r(d),p=[f[0]+(g[0]-h[0]),c[1],c[2]],v.rotate(p),f=p):(l=d,h=r(l)),void t.render())}function s(){_.select(this).style(M)}var l,c,u,f,h,d,p,g,v=t.projection,m=i(v,e),y=2;return m.on("zoomstart",a).on("zoom",o).on("zoomend",s),m}function s(t,e){function r(t){m++||t({type:"zoomstart"})}function n(t){t({type:"zoom"})}function a(t){--m||t({type:"zoomend"})}var o,s=t.projection,d={r:s.rotate(),k:s.scale()},p=i(s,e),g=x(p,"zoomstart","zoom","zoomend"),m=0,y=p.on;return p.on("zoomstart",function(){_.select(this).style(A);var t=_.mouse(this),e=s.rotate(),i=e,a=s.translate(),m=c(e);o=l(s,t),y.call(p,"zoom",function(){var r=_.mouse(this);if(s.scale(d.k=_.event.scale),o){if(l(s,r)){s.rotate(e).translate(a);var c=l(s,r),p=f(o,c),y=v(u(m,p)),b=d.r=h(y,o,i);isFinite(b[0])&&isFinite(b[1])&&isFinite(b[2])||(b=i),s.rotate(b),i=b}}else t=r,o=l(s,t);n(g.of(this,arguments))}),r(g.of(this,arguments))}).on("zoomend",function(){_.select(this).style(M),y.call(p,"zoom",null),a(g.of(this,arguments))}).on("zoom.redraw",function(){t.render()}),_.rebind(p,g,"on")}function l(t,e){var r=t.invert(e);return r&&isFinite(r[0])&&isFinite(r[1])&&m(r)}function c(t){var e=.5*t[0]*w,r=.5*t[1]*w,n=.5*t[2]*w,i=Math.sin(e),a=Math.cos(e),o=Math.sin(r),s=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return[a*s*c+i*o*l,i*s*c-a*o*l,a*o*c+i*s*l,a*s*l-i*o*c]}function u(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=e[0],s=e[1],l=e[2],c=e[3];return[r*o-n*s-i*l-a*c,r*s+n*o+i*c-a*l,r*l-n*c+i*o+a*s,r*c+n*l-i*s+a*o]}function f(t,e){if(t&&e){var r=b(t,e),n=Math.sqrt(y(r,r)),i=.5*Math.acos(Math.max(-1,Math.min(1,y(t,e)))),a=Math.sin(i)/n;return n&&[Math.cos(i),r[2]*a,-r[1]*a,r[0]*a]}}function h(t,e,r){var n=g(e,2,t[0]);n=g(n,1,t[1]),n=g(n,0,t[2]-r[2]);var i,a,o=e[0],s=e[1],l=e[2],c=n[0],u=n[1],f=n[2],h=Math.atan2(s,o)*k,p=Math.sqrt(o*o+s*s);Math.abs(u)>p?(a=(u>0?90:-90)-h,i=0):(a=Math.asin(u/p)*k-h,i=Math.sqrt(p*p-u*u));var v=180-a-2*h,m=(Math.atan2(f,c)-Math.atan2(l,i))*k,y=(Math.atan2(f,c)-Math.atan2(l,-i))*k,b=d(r[0],r[1],a,m),x=d(r[0],r[1],v,y);return x>=b?[a,m,r[2]]:[v,y,r[2]]}function d(t,e,r,n){var i=p(r-t),a=p(n-e);return Math.sqrt(i*i+a*a)}function p(t){return(t%360+540)%360-180}function g(t,e,r){var n=r*w,i=t.slice(),a=0===e?1:0,o=2===e?1:2,s=Math.cos(n),l=Math.sin(n);return i[a]=t[a]*s-t[o]*l,i[o]=t[o]*s+t[a]*l,i}function v(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*k,Math.asin(Math.max(-1,Math.min(1,2*(t[0]*t[2]-t[3]*t[1]))))*k,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*k]}function m(t){var e=t[0]*w,r=t[1]*w,n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function y(t,e){for(var r=0,n=0,i=t.length;i>n;++n)r+=t[n]*e[n];return r}function b(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function x(t){for(var e=0,r=arguments.length,n=[];++ed;++d){for(e=c[d],r=t[this.scene[e]._name],n=/Click to enter .+ title/.test(r.title)?"":r.title,p=0;2>=p;p+=2)this.labelEnable[d+p]=!1,this.labels[d+p]=o(n),this.labelColor[d+p]=s(r.titlefont.color),this.labelFont[d+p]=r.titlefont.family,this.labelSize[d+p]=r.titlefont.size,this.labelPad[d+p]=this.getLabelPad(e,r),this.tickEnable[d+p]=!1,this.tickColor[d+p]=s((r.tickfont||{}).color),this.tickAngle[d+p]="auto"===r.tickangle?0:Math.PI*-r.tickangle/180,this.tickPad[d+p]=this.getTickPad(r),this.tickMarkLength[d+p]=0,this.tickMarkWidth[d+p]=r.tickwidth||0,this.tickMarkColor[d+p]=s(r.tickcolor),this.borderLineEnable[d+p]=!1,this.borderLineColor[d+p]=s(r.linecolor),this.borderLineWidth[d+p]=r.linewidth||0;u=this.hasSharedAxis(r),a=this.hasAxisInDfltPos(e,r)&&!u,l=this.hasAxisInAltrPos(e,r)&&!u,i=r.mirror||!1,f=u?-1!==String(i).indexOf("all"):!!i,h=u?"allticks"===i:-1!==String(i).indexOf("ticks"),a?this.labelEnable[d]=!0:l&&(this.labelEnable[d+2]=!0),a?this.tickEnable[d]=r.showticklabels:l&&(this.tickEnable[d+2]=r.showticklabels),(a||f)&&(this.borderLineEnable[d]=r.showline),(l||f)&&(this.borderLineEnable[d+2]=r.showline),(a||h)&&(this.tickMarkLength[d]=this.getTickMarkLength(r)),(l||h)&&(this.tickMarkLength[d+2]=this.getTickMarkLength(r)),this.gridLineEnable[d]=r.showgrid,this.gridLineColor[d]=s(r.gridcolor),this.gridLineWidth[d]=r.gridwidth,this.zeroLineEnable[d]=r.zeroline,this.zeroLineColor[d]=s(r.zerolinecolor),this.zeroLineWidth[d]=r.zerolinewidth}},l.hasSharedAxis=function(t){var e=this.scene,r=a.Plots.getSubplotIds(e.fullLayout,"gl2d"),n=a.Axes.findSubplotsWithAxis(r,t);return 0!==n.indexOf(e.id)},l.hasAxisInDfltPos=function(t,e){var r=e.side;return"xaxis"===t?"bottom"===r:"yaxis"===t?"left"===r:void 0},l.hasAxisInAltrPos=function(t,e){var r=e.side;return"xaxis"===t?"top"===r:"yaxis"===t?"right"===r:void 0},l.getLabelPad=function(t,e){var r=1.5,n=e.titlefont.size,i=e.showticklabels;return"xaxis"===t?"top"===e.side?-10+n*(r+(i?1:0)):-10+n*(r+(i?.5:0)):"yaxis"===t?"right"===e.side?10+n*(r+(i?1:.5)):10+n*(r+(i?.5:0)):void 0},l.getTickPad=function(t){return"outside"===t.ticks?10+t.ticklen:15},l.getTickMarkLength=function(t){if(!t.ticks)return 0;var e=t.ticklen;return"inside"===t.ticks?-e:e},e.exports=i},{"../../lib/html2unicode":381,"../../lib/str2rgbarray":394,"../../plotly":402}],438:[function(t,e,r){"use strict";var n=t("./scene2d"),i=t("../plots"),a=t("../../constants/xmlns_namespaces");r.name="gl2d",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex={x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},r.attrRegex={x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},r.attributes=t("../cartesian/attributes"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"gl2d"),o=0;or;++r){var n=t[r],i=e[r];if(n.length!==i.length)return!0;for(var a=0;ao;++o,--s)for(var l=0;r>l;++l)for(var c=0;4>c;++c){var u=i[4*(r*o+l)+c];i[4*(r*o+l)+c]=i[4*(r*s+l)+c],i[4*(r*s+l)+c]=u}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticPlot&&this.container.removeChild(a),p},m.computeTickMarks=function(){this.xaxis._length=this.glplot.viewBox[2]-this.glplot.viewBox[0],this.yaxis._length=this.glplot.viewBox[3]-this.glplot.viewBox[1];for(var t=[s.calcTicks(this.xaxis),s.calcTicks(this.yaxis)],e=0;2>e;++e)for(var r=0;rk;++k)w[k]=Math.min(w[k],a.bounds[k]),w[k+2]=Math.max(w[k+2],a.bounds[k+2])}var A;for(n=0;2>n;++n)w[n]>w[n+2]&&(w[n]=-1,w[n+2]=1),A=this[v[n]],A._length=y.viewBox[n+2]-y.viewBox[n],s.doAutoRange(A);y.ticks=this.computeTickMarks();var M=this.xaxis.range,T=this.yaxis.range;y.dataBox=[M[0],T[0],M[1],T[1]],y.merge(r),o.update(y),this.glplot.draw()},m.draw=function(){if(!this.stopped){requestAnimationFrame(this.redraw);var t=this.glplot,e=this.camera,r=e.mouseListener,n=this.fullLayout;this.cameraChanged();var i=r.x*t.pixelRatio,a=this.canvas.height-t.pixelRatio*r.y;if(e.boxEnabled&&"zoom"===n.dragmode)this.selectBox.enabled=!0,this.selectBox.selectBox=[Math.min(e.boxStart[0],e.boxEnd[0]),Math.min(e.boxStart[1],e.boxEnd[1]),Math.max(e.boxStart[0],e.boxEnd[0]),Math.max(e.boxStart[1],e.boxEnd[1])],t.setDirty();else{this.selectBox.enabled=!1;var o=n._size,s=this.xaxis.domain,c=this.yaxis.domain,u=t.pick(i/t.pixelRatio+o.l+s[0]*o.w,a/t.pixelRatio-(o.t+(1-c[1])*o.h));if(u&&n.hovermode){var f=u.object._trace.handlePick(u);if(f&&(!this.lastPickResult||this.lastPickResult.trace!==f.trace||this.lastPickResult.dataCoord[0]!==f.dataCoord[0]||this.lastPickResult.dataCoord[1]!==f.dataCoord[1])){var h=this.lastPickResult=f;this.spikes.update({center:u.dataCoord}),h.screenCoord=[((t.viewBox[2]-t.viewBox[0])*(u.dataCoord[0]-t.dataBox[0])/(t.dataBox[2]-t.dataBox[0])+t.viewBox[0])/t.pixelRatio,(this.canvas.height-(t.viewBox[3]-t.viewBox[1])*(u.dataCoord[1]-t.dataBox[1])/(t.dataBox[3]-t.dataBox[1])-t.viewBox[1])/t.pixelRatio];var d=h.hoverinfo;if("all"!==d){var p=d.split("+");-1===p.indexOf("x")&&(h.traceCoord[0]=void 0),-1===p.indexOf("y")&&(h.traceCoord[1]=void 0),-1===p.indexOf("z")&&(h.traceCoord[2]=void 0),-1===p.indexOf("text")&&(h.textLabel=void 0),-1===p.indexOf("name")&&(h.name=void 0)}l.loneHover({x:h.screenCoord[0],y:h.screenCoord[1],xLabel:this.hoverFormatter("xaxis",h.traceCoord[0]),yLabel:this.hoverFormatter("yaxis",h.traceCoord[1]),zLabel:h.traceCoord[2],text:h.textLabel,name:h.name,color:h.color},{container:this.svgContainer}),this.lastPickResult={dataCoord:u.dataCoord}}}else!u&&this.lastPickResult&&(this.spikes.update({}),this.lastPickResult=null,l.loneUnhover(this.svgContainer))}t.draw()}},m.hoverFormatter=function(t,e){if(void 0!==e){var r=this[t];return s.tickText(r,r.c2l(e),"hover").text}}},{"../../lib/html2unicode":381,"../../lib/show_no_webgl_msg":392,"../../plots/cartesian/axes":405,"../../plots/cartesian/graph_interact":412,"./camera":436,"./convert":437,"gl-plot2d":165,"gl-select-box":195,"gl-spikes2d":215}],440:[function(t,e,r){"use strict";function n(t,e){t=t||document.body,e=e||{};var r=[.01,1/0];"distanceLimits"in e&&(r[0]=e.distanceLimits[0],r[1]=e.distanceLimits[1]),"zoomMin"in e&&(r[0]=e.zoomMin),"zoomMax"in e&&(r[1]=e.zoomMax);var n=a({center:e.center||[0,0,0],up:e.up||[0,1,0],eye:e.eye||[0,0,10],mode:e.mode||"orbit",distanceLimits:r}),l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0,u=t.clientWidth,f=t.clientHeight,h={keyBindingMode:"rotate",view:n,element:t,delay:e.delay||16,rotateSpeed:e.rotateSpeed||1,zoomSpeed:e.zoomSpeed||1,translateSpeed:e.translateSpeed||1,flipX:!!e.flipX,flipY:!!e.flipY,modes:n.modes,tick:function(){var e=i(),r=this.delay,a=e-2*r;n.idle(e-r),n.recalcMatrix(a),n.flush(e-(100+2*r));for(var o=!0,s=n.computedMatrix,h=0;16>h;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){var e=n.computedUp.slice(),r=n.computedEye.slice(),a=n.computedCenter.slice();if(n.setMode(t),"turntable"===t){var o=i();n._active.lookAt(o,r,a,e),n._active.lookAt(o+500,r,a,[0,0,1]),n._active.flush(o)}return n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s="rotate"===h.keyBindingMode,l="pan"===h.keyBindingMode,u="zoom"===h.keyBindingMode,f=!!o.control,g=!!o.alt,v=!!o.shift,m=!!(1&e),y=!!(2&e),b=!!(4&e),x=1/t.clientHeight,_=x*(r-d),w=x*(a-p),k=h.flipX?1:-1,A=h.flipY?1:-1,M=i(),T=Math.PI*h.rotateSpeed;if((s&&m&&!f&&!g&&!v||m&&!f&&!g&&v)&&n.rotate(M,k*T*_,-A*T*w,0),(l&&m&&!f&&!g&&!v||y||m&&f&&!g&&!v)&&n.pan(M,-h.translateSpeed*_*c,h.translateSpeed*w*c,0),u&&m&&!f&&!g&&!v||b||m&&!f&&g&&!v){var E=-h.zoomSpeed*w/window.innerHeight*(M-n.lastT())*100;n.pan(M,0,0,c*(Math.exp(E)-1))}return d=r,p=a,!0}),s(t,function(t,e){var r=h.flipX?1:-1,a=h.flipY?1:-1,o=i();if(Math.abs(t)>Math.abs(e))n.rotate(o,0,0,-t*r*Math.PI*h.rotateSpeed/window.innerWidth);else{var s=-h.zoomSpeed*a*e/window.innerHeight*(o-n.lastT())/100;n.pan(o,0,0,c*(Math.exp(s)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":39,"mouse-change":241,"mouse-wheel":245,"right-now":255}],441:[function(t,e,r){"use strict";function n(t,e){for(var r=0;3>r;++r){var n=s[r];e[n]._gd=t}}var i=t("./scene"),a=t("../plots"),o=t("../../constants/xmlns_namespaces"),s=["xaxis","yaxis","zaxis"];r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,o=a.getSubplotIds(e,"gl3d");e._paperdiv.style({width:e.width+"px",height:e.height+"px"}),t._context.setBackground(t,e.paper_bgcolor);for(var s=0;sr;++r){var n=t[c[r]];e.labels[r]=o(n.title),"titlefont"in n&&(n.titlefont.color&&(e.labelColor[r]=s(n.titlefont.color)),n.titlefont.family&&(e.labelFont[r]=n.titlefont.family),n.titlefont.size&&(e.labelSize[r]=n.titlefont.size)),"showline"in n&&(e.lineEnable[r]=n.showline),"linecolor"in n&&(e.lineColor[r]=s(n.linecolor)),"linewidth"in n&&(e.lineWidth[r]=n.linewidth),"showgrid"in n&&(e.gridEnable[r]=n.showgrid),"gridcolor"in n&&(e.gridColor[r]=s(n.gridcolor)),"gridwidth"in n&&(e.gridWidth[r]=n.gridwidth), +"log"===n.type?e.zeroEnable[r]=!1:"zeroline"in n&&(e.zeroEnable[r]=n.zeroline),"zerolinecolor"in n&&(e.zeroLineColor[r]=s(n.zerolinecolor)),"zerolinewidth"in n&&(e.zeroLineWidth[r]=n.zerolinewidth),"ticks"in n&&n.ticks?e.lineTickEnable[r]=!0:e.lineTickEnable[r]=!1,"ticklen"in n&&(e.lineTickLength[r]=e._defaultLineTickLength[r]=n.ticklen),"tickcolor"in n&&(e.lineTickColor[r]=s(n.tickcolor)),"tickwidth"in n&&(e.lineTickWidth[r]=n.tickwidth),"tickangle"in n&&(e.tickAngle[r]="auto"===n.tickangle?0:Math.PI*-n.tickangle/180),"showticklabels"in n&&(e.tickEnable[r]=n.showticklabels),"tickfont"in n&&(n.tickfont.color&&(e.tickColor[r]=s(n.tickfont.color)),n.tickfont.family&&(e.tickFont[r]=n.tickfont.family),n.tickfont.size&&(e.tickSize[r]=n.tickfont.size)),"mirror"in n?-1!==["ticks","all","allticks"].indexOf(n.mirror)?(e.lineTickMirror[r]=!0,e.lineMirror[r]=!0):n.mirror===!0?(e.lineTickMirror[r]=!1,e.lineMirror[r]=!0):(e.lineTickMirror[r]=!1,e.lineMirror[r]=!1):e.lineMirror[r]=!1,"showbackground"in n&&n.showbackground!==!1?(e.backgroundEnable[r]=!0,e.backgroundColor[r]=s(n.backgroundcolor)):e.backgroundEnable[r]=!1}},e.exports=i},{"../../../lib/html2unicode":381,"../../../lib/str2rgbarray":394,arraytools:49}],446:[function(t,e,r){"use strict";function n(t,e,r,n){for(var a=r("bgcolor"),l=i.combine(a,n.paper_bgcolor),c=Object.keys(o.camera),u=0;ue;++e){var r=t[o[e]];this.enabled[e]=r.showspikes,this.colors[e]=a(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness}},e.exports=i},{"../../../lib/str2rgbarray":394}],449:[function(t,e,r){"use strict";function n(t){for(var e=new Array(3),r=0;3>r;++r){for(var n=t[r],i=new Array(n.length),a=0;au;++u){var f=i[s[u]];if(f._length=(r[u].hi-r[u].lo)*r[u].pixelsPerDataUnit/t.dataScale[u],Math.abs(f._length)===1/0)c[u]=[];else{f.range[0]=r[u].lo/t.dataScale[u],f.range[1]=r[u].hi/t.dataScale[u],f._m=1/(t.dataScale[u]*r[u].pixelsPerDataUnit),f.range[0]===f.range[1]&&(f.range[0]-=1,f.range[1]+=1);var h=f.tickmode;if("auto"===f.tickmode){f.tickmode="linear";var d=f.nticks||a.Lib.constrain(f._length/40,4,9);a.Axes.autoTicks(f,Math.abs(f.range[1]-f.range[0])/d)}for(var p=a.Axes.calcTicks(f),g=0;gu;++u){l[u]=.5*(t.glplot.bounds[0][u]+t.glplot.bounds[1][u]);for(var g=0;2>g;++g)e.bounds[g][u]=t.glplot.bounds[g][u]}t.contourLevels=n(c)}e.exports=i;var a=t("../../../plotly"),o=t("../../../lib/html2unicode"),s=["xaxis","yaxis","zaxis"],l=[0,0,0]},{"../../../lib/html2unicode":381,"../../../plotly":402}],450:[function(t,e,r){"use strict";function n(t,e){var r,n,i=[0,0,0,0];for(r=0;4>r;++r)for(n=0;4>n;++n)i[n]+=t[4*r+n]*e[r];return i}function i(t,e){var r=n(t.projection,n(t.view,n(t.model,[e[0],e[1],e[2],1])));return r}e.exports=i},{}],451:[function(t,e,r){"use strict";function n(t){function e(e,r){if("string"==typeof r)return r;var n=t.fullSceneLayout[e];return g.tickText(n,n.c2l(r),"hover").text}var r,n=t.svgContainer,i=t.container.getBoundingClientRect(),a=i.width,o=i.height;n.setAttributeNS(null,"viewBox","0 0 "+a+" "+o),n.setAttributeNS(null,"width",a),n.setAttributeNS(null,"height",o),A(t),t.glplot.axes.update(t.axesOptions);for(var s=Object.keys(t.traces),l=null,c=t.glplot.selection,u=0;ua;++a)l=u[T[a]],_(l);t?Array.isArray(t)||(t=[t]):t=[];var h=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]];for(a=0;ao;++o)h[0][o]>h[1][o]?d[o]=1:h[1][o]===h[0][o]?d[o]=1:d[o]=1/(h[1][o]-h[0][o]);for(this.dataScale=d,a=0;aa;++a){if(l=u[T[a]],c=l.type,c in x?(x[c].acc*=d[a],x[c].count+=1):x[c]={acc:d[a],count:1},l.autorange){for(y[0][a]=1/0,y[1][a]=-(1/0),o=0;oy[1][a])y[0][a]=-1,y[1][a]=1;else{var k=y[1][a]-y[0][a];y[0][a]-=k/32,y[1][a]+=k/32}}else{var A=u[T[a]].range;y[0][a]=A[0],y[1][a]=A[1]}y[0][a]===y[1][a]&&(y[0][a]-=1,y[1][a]+=1),b[a]=y[1][a]-y[0][a],this.glplot.bounds[0][a]=y[0][a]*d[a],this.glplot.bounds[1][a]=y[1][a]*d[a]}var M=[1,1,1];for(a=0;3>a;++a){l=u[T[a]],c=l.type;var E=x[c];M[a]=Math.pow(E.acc,1/E.count)/d[a]}var L,S=4;if("auto"===u.aspectmode)L=Math.max.apply(null,M)/Math.min.apply(null,M)<=S?M:[1,1,1];else if("cube"===u.aspectmode)L=[1,1,1];else if("data"===u.aspectmode)L=M;else{if("manual"!==u.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var C=u.aspectratio;L=[C.x,C.y,C.z]}u.aspectratio.x=f.aspectratio.x=L[0],u.aspectratio.y=f.aspectratio.y=L[1],u.aspectratio.z=f.aspectratio.z=L[2],this.glplot.aspect=L;var z=u.domain||null,P=e._size||null;if(z&&P){var R=this.container.style;R.position="absolute",R.left=P.l+z.x[0]*P.w+"px",R.top=P.t+(1-z.y[1])*P.h+"px",R.width=P.w*(z.x[1]-z.x[0])+"px",R.height=P.h*(z.y[1]-z.y[0])+"px"}this.glplot.redraw()}},M.destroy=function(){this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null},M.setCameraToDefault=function(){this.setCamera({eye:{x:1.25,y:1.25,z:1.25},center:{x:0,y:0,z:0},up:{x:0,y:0,z:1}})},M.getCamera=function(){return this.glplot.camera.view.recalcMatrix(this.camera.view.lastT()),c(this.glplot.camera)},M.setCamera=function(t){var e={};e[this.id]=t,this.glplot.camera.lookAt.apply(this,l(t)),this.graphDiv.emit("plotly_relayout",e)},M.saveCamera=function(t){function e(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return e[i[r]]&&t[i[r]][a[n]]===e[i[r]][a[n]]}var r=this.getCamera(),n=d.nestedProperty(t,this.id+".camera"),i=n.get(),a=!1;if(void 0===i)a=!0;else for(var o=0;3>o;o++)for(var s=0;3>s;s++)if(!e(r,i,o,s)){a=!0;break}return a&&n.set(r),a},M.updateFx=function(t,e){var r=this.camera;r&&("orbit"===t?(r.mode="orbit",r.keyBindingMode="rotate"):"turntable"===t?(r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate"):r.keyBindingMode=t),this.fullSceneLayout.hovermode=e},M.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(u),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,n=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var i=new Uint8Array(r*n*4);e.readPixels(0,0,r,n,e.RGBA,e.UNSIGNED_BYTE,i);for(var a=0,o=n-1;o>a;++a,--o)for(var s=0;r>s;++s)for(var l=0;4>l;++l){var c=i[4*(r*a+s)+l];i[4*(r*a+s)+l]=i[4*(r*o+s)+l],i[4*(r*o+s)+l]=c}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticMode&&this.container.removeChild(u),p},e.exports=a},{"../../lib":382,"../../lib/show_no_webgl_msg":392,"../../lib/str2rgbarray":394,"../../plots/cartesian/axes":405,"../../plots/cartesian/graph_interact":412,"../../plots/plots":454,"./camera":440,"./layout/convert":445,"./layout/spikes":448,"./layout/tick_marks":449,"./project":450,"./set_convert":452,"gl-plot3d":183}],452:[function(t,e,r){"use strict";var n=t("../cartesian/axes"),i=function(){};e.exports=function(t){n.setConvert(t),t.setScale=i}},{"../cartesian/axes":405}],453:[function(t,e,r){"use strict";var n=t("../plotly"),i=t("./font_attributes"),a=t("../components/color/attributes"),o=n.Lib.extendFlat;e.exports={font:{family:o({},i.family,{dflt:'"Open Sans", verdana, arial, sans-serif'}),size:o({},i.size,{dflt:12}),color:o({},i.color,{dflt:a.defaultLine})},title:{valType:"string",dflt:"Click to enter Plot title"},titlefont:o({},i,{}),autosize:{valType:"enumerated",values:[!0,!1,"initial"]},width:{valType:"number",min:10,dflt:700},height:{valType:"number",min:10,dflt:450},margin:{l:{valType:"number",min:0,dflt:80},r:{valType:"number",min:0,dflt:80},t:{valType:"number",min:0,dflt:100},b:{valType:"number",min:0,dflt:80},pad:{valType:"number",min:0,dflt:0},autoexpand:{valType:"boolean",dflt:!0}},paper_bgcolor:{valType:"color",dflt:a.background},plot_bgcolor:{valType:"color",dflt:a.background},separators:{valType:"string",dflt:".,"},hidesources:{valType:"boolean",dflt:!1},smith:{valType:"enumerated",values:[!1],dflt:!1},showlegend:{valType:"boolean"},_composedModules:{"*":"Fx"},_nestedModules:{xaxis:"Axes",yaxis:"Axes",scene:"gl3d",geo:"geo",legend:"Legend",annotations:"Annotations",shapes:"Shapes",images:"Images",ternary:"ternary",mapbox:"mapbox"}}},{"../components/color/attributes":302,"../plotly":402,"./font_attributes":423}],454:[function(t,e,r){"use strict";function n(t){return"object"==typeof t&&(t=t.type),t}function i(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#","class":"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){f.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}function a(t,e){for(var r,n=Object.keys(e),i=0;i=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var s=r.select(".js-link-to-tool"),l=r.select(".js-link-spacer"),c=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&i(t,s),l.text(s.text()&&c.text()?" - ":"")},f.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",r=o.select(t).append("div").attr("id","hiddenform").style("display","none"),n=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),i=n.append("input").attr({type:"text",name:"data"});return i.node().value=f.graphJson(t,!1,"keepdata"),n.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1},f.supplyDefaults=function(t){var e,r,n=t._fullLayout||{},i=t._fullLayout={},o=t.layout||{},s=t._fullData||[],u=t._fullData=[],h=t.data||[],d=i._modules=[],p=i._basePlotModules=[];for(f.supplyLayoutGlobalDefaults(o,i),i._dataLength=h.length,e=0;ea&&(e=(r-1)/(i.l+i.r),i.l=Math.floor(e*i.l),i.r=Math.floor(e*i.r)),0>o&&(e=(n-1)/(i.t+i.b),i.t=Math.floor(e*i.t),i.b=Math.floor(e*i.b))}},f.autoMargin=function(t,e,r){var n=t._fullLayout;if(n._pushmargin||(n._pushmargin={}),n.margin.autoexpand!==!1){if(r){var i=void 0===r.pad?12:r.pad;r.l+r.r>.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0),n._pushmargin[e]={l:{val:r.x,size:r.l+i},r:{val:r.x,size:r.r+i},b:{val:r.y,size:r.b+i},t:{val:r.y,size:r.t+i}}}else delete n._pushmargin[e];t._replotting||f.doAutoMargin(t)}},f.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var r=e._size,n=JSON.stringify(r),i=Math.max(e.margin.l||0,0),a=Math.max(e.margin.r||0,0),o=Math.max(e.margin.t||0,0),c=Math.max(e.margin.b||0,0),u=e._pushmargin;return e.margin.autoexpand!==!1&&(u.base={l:{val:0,size:i},r:{val:1,size:a},t:{val:1,size:o},b:{val:0,size:c}},Object.keys(u).forEach(function(t){var r=u[t].l||{},n=u[t].b||{},l=r.val,f=r.size,h=n.val,d=n.size;Object.keys(u).forEach(function(t){if(s(f)&&u[t].r){var r=u[t].r.val,n=u[t].r.size;if(r>l){var p=(f*r+(n-e.width)*l)/(r-l),g=(n*(1-l)+(f-e.width)*(1-r))/(r-l);p>=0&&g>=0&&p+g>i+a&&(i=p,a=g)}}if(s(d)&&u[t].t){var v=u[t].t.val,m=u[t].t.size;if(v>h){var y=(d*v+(m-e.height)*h)/(v-h),b=(m*(1-h)+(d-e.height)*(1-v))/(v-h);y>=0&&b>=0&&y+b>c+o&&(c=y,o=b)}}})})),r.l=Math.round(i),r.r=Math.round(a),r.t=Math.round(o),r.b=Math.round(c),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,t._replotting||"{}"===n||n===JSON.stringify(e._size)?void 0:l.plot(t)},f.graphJson=function(t,e,r,n,i){function a(t){if("function"==typeof t)return null;if(c.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0&&!c.isPlainObject(t.stream))continue}else if("keepall"!==r&&(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0))continue;i[e]=a(t[e])}return i}return Array.isArray(t)?t.map(a):t&&t.getTime?c.ms2DateTime(t):t}(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&f.supplyDefaults(t);var o=i?t._fullData:t.data,s=i?t._fullLayout:t.layout,l={data:(o||[]).map(function(t){var r=a(t);return e&&delete r.fit,r})};return e||(l.layout=a(s)),t.framework&&t.framework.isPolar&&(l=t.framework.getConfig()),"object"===n?l:JSON.stringify(l)}},{"../components/color":303,"../lib":382,"../plotly":402,"./attributes":403,"./font_attributes":423,"./layout_attributes":453,d3:113,"fast-isnumeric":117}],455:[function(t,e,r){"use strict";var n=t("../../traces/scatter/attributes"),i=n.marker;e.exports={r:n.r,t:n.t,marker:{color:i.color,size:i.size,symbol:i.symbol,opacity:i.opacity}}},{"../../traces/scatter/attributes":556}],456:[function(t,e,r){"use strict";function n(t,e){var r={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return a({},e,r)}var i=t("../cartesian/layout_attributes"),a=t("../../lib/extend").extendFlat,o=a({},i.domain,{});e.exports={radialaxis:n("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:o,orientation:{valType:"number"}}),angularaxis:n("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:o}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":377,"../cartesian/layout_attributes":414}],457:[function(t,e,r){var n=t("../../plotly"),i=t("d3"),a=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},o=n.Lib.extendDeepAll;a.Axis=function(){function t(t){r=t||r;var c=l.data,f=l.layout;return("string"==typeof r||r.nodeName)&&(r=i.select(r)),r.datum(c).each(function(t,r){function l(t,e){return s(t)%360+f.orientation}var c=t.slice();u={data:a.util.cloneJson(c),layout:a.util.cloneJson(f)};var h=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[h],h=(h+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:i.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var d=c.filter(function(t,e){var r=t.visible;return"undefined"==typeof r||r===!0}),p=!1,g=d.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=i.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var r=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,n){t.yStack=[r],m.push(r),r=a.util.sumArrays(t.r,r)}),t.values});d=i.merge(y)}d.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var b=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;b=Math.max(10,b);var x,_=[f.margin.left+b,f.margin.top+b];if(p){var w=i.max(a.util.sumArrays(a.util.arrayLast(d).r[0],a.util.arrayLast(m)));x=[0,w]}else x=i.extent(a.util.flattenArray(d.map(function(t,e){return t.r})));f.radialAxis.domain!=a.DATAEXTENT&&(x[0]=0),n=i.scale.linear().domain(f.radialAxis.domain!=a.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:x).range([0,b]),u.layout.radialAxis.domain=n.domain();var k,A=a.util.flattenArray(d.map(function(t,e){return t.t})),M="string"==typeof A[0];M&&(A=a.util.deduplicate(A),k=A.slice(),A=i.range(A.length),d=d.map(function(t,e){var r=t;return t.t=[A],p&&(r.yStack=t.yStack),r}));var T=d.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===d.length,E=null===f.needsEndSpacing?M||!T:f.needsEndSpacing,L=f.angularAxis.domain&&f.angularAxis.domain!=a.DATAEXTENT&&!M&&f.angularAxis.domain[0]>=0,S=L?f.angularAxis.domain:i.extent(A),C=Math.abs(A[1]-A[0]);T&&!M&&(C=0);var z=S.slice();E&&M&&(z[1]+=C);var P=f.angularAxis.ticksCount||4;P>8&&(P=P/(P/8)+P%8),f.angularAxis.ticksStep&&(P=(z[1]-z[0])/P);var R=f.angularAxis.ticksStep||(z[1]-z[0])/(P*(f.minorTicks+1));k&&(R=Math.max(Math.round(R),1)),z[2]||(z[2]=R);var O=i.range.apply(this,z);if(O=O.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=i.scale.linear().domain(z.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=s.domain(),u.layout.angularAxis.endPadding=E?C:0,e=i.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var I="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",N=(new DOMParser).parseFromString(I,"application/xml"),j=this.appendChild(this.ownerDocument.importNode(N.documentElement,!0)); +e=i.select(j)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var F,D=e.select(".chart-group"),B={fill:"none",stroke:f.tickColor},U={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){F=e.select(".legend-group").attr({transform:"translate("+[b,f.margin.top]+")"}).style({display:"block"});var V=d.map(function(t,e){var r=a.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});a.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:o({},a.Legend.defaultConfig().legendConfig,{container:F,elements:V,reverseOrder:f.legend.reverseOrder})})();var q=F.node().getBBox();b=Math.min(f.width-q.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,b=Math.max(10,b),_=[f.margin.left+b,f.margin.top+b],n.range([0,b]),u.layout.radialAxis.domain=n.domain(),F.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else F=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),D.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(f.width-(f.margin.left+f.margin.right+2*b+(q?q.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*b))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),e.select(".outer-group").attr("transform","translate("+H+")"),f.title){var G=e.select("g.title-group text").style(U).text(f.title),Y=G.node().getBBox();G.attr({x:_[0]-Y.width/2,y:_[1]-b-20})}var X=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var W=X.selectAll("circle.grid-circle").data(n.ticks(5));W.enter().append("circle").attr({"class":"grid-circle"}).style(B),W.attr("r",n),W.exit().remove()}X.select("circle.outside-circle").attr({r:b}).style(B);var Z=e.select("circle.background-circle").attr({r:b}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var K=i.svg.axis().scale(n).ticks(5).tickSize(5);X.call(K).attr({transform:"rotate("+f.radialAxis.orientation+")"}),X.selectAll(".domain").style(B),X.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(U).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,U["font-size"]]+")":"translate("+[0,U["font-size"]]+")"}}),X.selectAll("g>line").style({stroke:"black"})}var $=e.select(".angular.axis-group").selectAll("g.angular-tick").data(O),Q=$.enter().append("g").classed("angular-tick",!0);$.attr({transform:function(t,e){return"rotate("+l(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),$.exit().remove(),Q.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(B),Q.selectAll(".minor").style({stroke:f.minorTickColor}),$.select("line.grid-line").attr({x1:f.tickLength?b-f.tickLength:0,x2:b}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),Q.append("text").classed("axis-text",!0).style(U);var J=$.select("text.axis-text").attr({x:b+f.labelOffset,dy:".35em",transform:function(t,e){var r=l(t,e),n=b+f.labelOffset,i=f.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?270>r&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(180>=r&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(U);f.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=i.max(D.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));F.attr({transform:"translate("+[b+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,rt=e.select("g.geometry-group").selectAll("g.geometry").data(d);if(rt.enter().append("g").attr({"class":function(t,e){return"geometry geometry"+e}}),rt.exit().remove(),d[0]||et){var nt=[];d.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=s,r.container=rt.filter(function(t,r){return r==e}),r.geometry=t.geometry,r.orientation=f.orientation,r.direction=f.direction,r.index=e,nt.push({data:t,geometryConfig:r})});var it=i.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(nt),at=[];it.forEach(function(t,e){"unstacked"===t.key?at=at.concat(t.values.map(function(t,e){return[t]})):at.push(t.values)}),at.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return o(a[r].defaultConfig(),t)});a[r]().config(n)()})}var ot,st,lt=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=a.tooltipPanel().config({container:ct,fontSize:8})(),ft=a.tooltipPanel().config({container:ct,fontSize:8})(),ht=a.tooltipPanel().config({container:ct,hasTick:!0})();if(!M){var dt=lt.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});D.on("mousemove.angular-guide",function(t,e){var r=a.util.getMousePos(Z).angle;dt.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-f.orientation)%360;ot=s.invert(n);var i=a.util.convertToCartesian(b+12,r+180);ut.text(a.util.round(ot)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){lt.select("line").style({opacity:0})})}var pt=lt.select("circle").style({stroke:"grey",fill:"none"});D.on("mousemove.radial-guide",function(t,e){var r=a.util.getMousePos(Z).radius;pt.attr({r:r}).style({opacity:.5}),st=n.invert(a.util.getMousePos(Z).radius);var i=a.util.convertToCartesian(r,f.radialAxis.orientation);ft.text(a.util.round(st)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),ht.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,r){var n=i.select(this),o=n.style("fill"),s="black",l=n.style("opacity")||1;if(n.attr({"data-opacity":l}),"none"!=o){n.attr({"data-fill":o}),s=i.hsl(o).darker().toString(),n.style({fill:s,opacity:1});var c={t:a.util.round(t[0]),r:a.util.round(t[1])};M&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),h=e.node().getBoundingClientRect(),d=[f.left+f.width/2-H[0]-h.left,f.top+f.height/2-H[1]-h.top];ht.config({color:s}).text(u),ht.move(d)}else o=n.style("stroke"),n.attr({"data-stroke":o}),s=i.hsl(o).darker().toString(),n.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0!=i.event.which?!1:void(i.select(this).attr("data-fill")&&ht.show())}).on("mouseout.tooltip",function(t,e){ht.hide();var r=i.select(this),n=r.attr("data-fill");n?r.style({fill:n,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})}),h}var e,r,n,s,l={data:[],layout:{}},c={},u={},f=i.dispatch("hover"),h={};return h.render=function(e){return t(e),this},h.config=function(t){if(!arguments.length)return l;var e=a.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),o(l.data[e],a.Axis.defaultConfig().data[0]),o(l.data[e],t)}),o(l.layout,a.Axis.defaultConfig().layout),o(l.layout,e.layout),this},h.getLiveConfig=function(){return u},h.getinputConfig=function(){return c},h.radialScale=function(t){return n},h.angularScale=function(t){return s},h.svg=function(){return e},i.rebind(h,f,"on"),h},a.Axis.defaultConfig=function(t,e){var r={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:i.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return r},a.util={},a.DATAEXTENT="dataExtent",a.AREA="AreaChart",a.LINE="LinePlot",a.DOT="DotPlot",a.BAR="BarChart",a.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},a.util._extend=function(t,e){for(var r in t)e[r]=t[r]},a.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},a.util.dataFromEquation2=function(t,e){var r=e||6,n=i.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180,i=t(n);return[e,i]});return n},a.util.dataFromEquation=function(t,e,r){var n=e||6,a=[],o=[];i.range(0,360+n,n).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},a.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return i.range(e).map(function(t,e){return r[e]||r[0]})},a.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=a.util.ensureArray(t[e],r)}),t},a.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},a.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},a.util.sumArrays=function(t,e){return i.zip(t,e).map(function(t,e){return i.sum(t)})},a.util.arrayLast=function(t){return t[t.length-1]},a.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},a.util.flattenArray=function(t){for(var e=[];!a.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},a.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},a.util.convertToCartesian=function(t,e){var r=e*Math.PI/180,n=t*Math.cos(r),i=t*Math.sin(r);return[n,i]},a.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},a.util.getMousePos=function(t){var e=i.mouse(t.node()),r=e[0],n=e[1],a={};return a.x=r,a.y=n,a.pos=e,a.angle=180*(Math.atan2(n,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+n*n),a},a.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;a>i;i++)e=t[i],e in r?(r[e]++,n[e]=r[e]):r[e]=1;return n},a.util.duplicates=function(t){return Object.keys(a.util.duplicatesCount(t))},a.util.translator=function(t,e,r,n){if(n){var i=r.slice();r=e,e=i}var a=e.reduce(function(t,e){return"undefined"!=typeof t?t[e]:void 0},t);"undefined"!=typeof a&&(e.reduce(function(t,r,n){return"undefined"!=typeof t?(n===e.length-1&&delete t[r],t[r]):void 0},t),r.reduce(function(t,e,n){return"undefined"==typeof t[e]&&(t[e]={}),n===r.length-1&&(t[e]=a),t[e]},t))},a.PolyChart=function(){function t(){var t=r[0].geometryConfig,e=t.container;"string"==typeof e&&(e=i.select(e)),e.datum(r).each(function(e,r){function n(e,r){var n=t.radialScale(e[1]),i=(t.angularScale(e[0])+t.orientation)*Math.PI/180;return{r:n,t:i}}function a(t){var e=t.r*Math.cos(t.t),r=t.r*Math.sin(t.t);return{x:e,y:r}}var o=!!e[0].data.yStack,l=e.map(function(t,e){return o?i.zip(t.data.t[0],t.data.r[0],t.data.yStack[0]):i.zip(t.data.t[0],t.data.r[0])}),c=t.angularScale,u=t.radialScale.domain()[0],f={};f.bar=function(r,n,a){var o=e[a].data,s=t.radialScale(r[1])-t.radialScale(0),l=t.radialScale(r[2]||0),u=o.barWidth;i.select(this).attr({"class":"mark bar",d:"M"+[[s+l,-u/2],[s+l,u/2],[l,u/2],[l,-u/2]].join("L")+"Z",transform:function(e,r){return"rotate("+(t.orientation+c(e[0]))+")"}})},f.dot=function(t,r,o){var s=t[2]?[t[0],t[1]+t[2]]:t,l=i.svg.symbol().size(e[o].data.dotSize).type(e[o].data.dotType)(t,r);i.select(this).attr({"class":"mark dot",d:l,transform:function(t,e){var r=a(n(s));return"translate("+[r.x,r.y]+")"}})};var h=i.svg.line.radial().interpolate(e[0].data.lineInterpolation).radius(function(e){return t.radialScale(e[1])}).angle(function(e){return t.angularScale(e[0])*Math.PI/180});f.line=function(r,n,a){var o=r[2]?l[a].map(function(t,e){return[t[0],t[1]+t[2]]}):l[a];if(i.select(this).each(f.dot).style({opacity:function(t,r){return+e[a].data.dotVisible},fill:v.stroke(r,n,a)}).attr({"class":"mark dot"}),!(n>0)){var s=i.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({"class":"line",d:h(o),transform:function(e,r){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(r,n,a)},"fill-opacity":0,stroke:function(t,e){return v.stroke(r,n,a)},"stroke-width":function(t,e){return v["stroke-width"](r,n,a)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](r,n,a)},opacity:function(t,e){return v.opacity(r,n,a)},display:function(t,e){return v.display(r,n,a)}})}};var d=t.angularScale.range(),p=Math.abs(d[1]-d[0])/l[0].length*Math.PI/180,g=i.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,r,n){i.select(this).attr({"class":"mark arc",d:g,transform:function(e,r){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var v={fill:function(t,r,n){return e[n].data.color},stroke:function(t,r,n){return e[n].data.strokeColor},"stroke-width":function(t,r,n){return e[n].data.strokeSize+"px"},"stroke-dasharray":function(t,r,n){return s[e[n].data.strokeDash]},opacity:function(t,r,n){return e[n].data.opacity},display:function(t,r,n){return"undefined"==typeof e[n].data.visible||e[n].data.visible?"block":"none"}},m=i.select(this).selectAll("g.layer").data(l);m.enter().append("g").attr({"class":"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({"class":"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,r=[a.PolyChart.defaultConfig()],n=i.dispatch("hover"),s={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){r[e]||(r[e]={}),o(r[e],a.PolyChart.defaultConfig()),o(r[e],t)}),this):r},t.getColorScale=function(){return e},i.rebind(t,n,"on"),t},a.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:i.scale.category20()}};return t},a.BarChart=function(){return a.PolyChart()},a.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},a.AreaChart=function(){return a.PolyChart()},a.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},a.DotPlot=function(){return a.PolyChart()},a.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},a.LinePlot=function(){return a.PolyChart()},a.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},a.Legend=function(){function t(){var r=e.legendConfig,n=e.data.map(function(t,e){return[].concat(t).map(function(t,n){var i=o({},r.elements[e]);return i.name=t,i.color=[].concat(r.elements[e].color)[n],i})}),a=i.merge(n);a=a.filter(function(t,e){return r.elements[e]&&(r.elements[e].visibleInLegend||"undefined"==typeof r.elements[e].visibleInLegend)}),r.reverseOrder&&(a=a.reverse());var s=r.container;("string"==typeof s||s.nodeName)&&(s=i.select(s));var l=a.map(function(t,e){return t.color}),c=r.fontSize,u=null==r.isContinuous?"number"==typeof a[0]:r.isContinuous,f=u?r.height:c*a.length,h=s.classed("legend-group",!0),d=h.selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=i.range(a.length),v=i.scale[u?"linear":"ordinal"]().domain(g).range(l),m=i.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var r=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=i.svg.symbolTypes.indexOf(t)?i.svg.symbol().type(t).size(r)():i.svg.symbol().type("square").size(r)()};if(u){var b=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);b.enter().append("stop"),b.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:r.height,width:r.colorBandWidth,fill:"url(#grad1)"})}else{var x=d.select(".legend-marks").selectAll("path.legend-mark").data(a);x.enter().append("path").classed("legend-mark",!0),x.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var r=t.symbol;return y(r,c)},fill:function(t,e){return v(e)}}),x.exit().remove()}var _=i.svg.axis().scale(m).orient("right"),w=d.select("g.legend-axis").attr({transform:"translate("+[u?r.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?r.textColor:"none"}),w.selectAll("text").style({fill:r.textColor,"font-size":r.fontSize}).text(function(t,e){return a[e].name}),t}var e=a.Legend.defaultConfig(),r=i.dispatch("hover");return t.config=function(t){return arguments.length?(o(e,t),this):e},i.rebind(t,r,"on"),t},a.Legend.defaultConfig=function(t,e){var r={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return r},a.tooltipPanel=function(){var t,e,r,n={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+a.tooltipPanel.uid++,l=10,c=function(){t=n.container.selectAll("g."+s).data([0]);var i=t.enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=i.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=i.append("text").attr({dx:n.padding+l,dy:.3*+n.fontSize}),c};return c.text=function(a){var o=i.hsl(n.color).l,s=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":n.fontSize+"px"}).text(f);var h=n.padding,d=e.node().getBBox(),p={fill:n.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[n.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),c},c.move=function(e){return t?(t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c):void 0},c.hide=function(){return t?(t.style({display:"none"}),c):void 0},c.show=function(){return t?(t.style({display:"block"}),c):void 0},c.config=function(t){return o(n,t),c},c},a.tooltipPanel.uid=1,a.adapter={},a.adapter.plotly=function(){var t={};return t.convert=function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=o({},t),i=[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]];return i.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",n.dotVisible===!0?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var n=a.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var i=n.indexOf(t.geometry);-1!=i&&(r.data[e].groupId=i)})}if(t.layout){var s=o({},t.layout),l=[[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]];if(l.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};i.entries(s.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),s.margin=f}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r},t}},{"../../plotly":402,"./micropolar_manager":458,d3:113}],458:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("d3"),a=t("./undo_manager"),o=e.exports={},s=n.Lib.extendDeepAll;o.framework=function(t){function e(e,a){return a&&(f=a),i.select(i.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),r=r?s(r,e):e,c||(c=n.micropolar.Axis()),u=n.micropolar.adapter.plotly().convert(r),c.config(u).render(f),t.data=r.data,t.layout=r.layout,o.fillLayout(t),r}var r,l,c,u,f,h=new a;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return r},e.getLiveConfig=function(){return n.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=n.micropolar.util.cloneJson(r);!function(e,r){h.add({undo:function(){r&&t(r)},redo:function(){t(e)}})}(e,l),l=n.micropolar.util.cloneJson(e)},e.undo=function(){h.undo()},e.redo=function(){h.redo()},e},o.fillLayout=function(t){var e=i.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:n.Color.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../plotly":402,"./undo_manager":459,d3:113}],459:[function(t,e,r){"use strict";e.exports=function(){function t(t,e){return t?(i=!0,t[e](),i=!1,this):this}var e,r=[],n=-1,i=!1;return{add:function(t){return i?this:(r.splice(n+1,r.length-n),r.push(t),n=r.length-1,this)},setCallback:function(t){e=t},undo:function(){var i=r[n];return i?(t(i,"undo"),n-=1,e&&e(i.undo),this):this},redo:function(){var i=r[n+1];return i?(t(i,"redo"),n+=1,e&&e(i.redo),this):this},clear:function(){r=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return ng;g++){var v=d[g];s=t[v]?t[v]:t[v]={},e[v]=l={},o("domain."+h,[g/p,(g+1)/p]),o("domain."+{x:"y",y:"x"}[h]),a.id=v,f(s,l,o,a)}}},{"../lib":382,"./plots":454}],461:[function(t,e,r){"use strict";var n=t("./ternary"),i=t("../../plots/plots");r.name="ternary",r.attr="subplot",r.idRoot="ternary",r.idRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"ternary"),o=0;o=o&&(d.min=0,p.min=0,g.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}var i=t("../../../components/color"),a=t("../../subplot_defaults"),o=t("./layout_attributes"),s=t("./axis_defaults"),l=["aaxis","baxis","caxis"];e.exports=function(t,e,r){a(t,e,r,{type:"ternary",attributes:o,handleDefaults:n,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../../components/color":303,"../../subplot_defaults":460,"./axis_defaults":464,"./layout_attributes":466}],466:[function(t,e,r){"use strict";var n=t("../../../components/color/attributes"),i=t("./axis_attributes");e.exports={domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},bgcolor:{valType:"color",dflt:n.background},sum:{valType:"number",dflt:1,min:0},aaxis:i,baxis:i,caxis:i}},{"../../../components/color/attributes":302,"./axis_attributes":463}],467:[function(t,e,r){"use strict";function n(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework()}function i(t){a.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var a=t("d3"),o=t("tinycolor2"),s=t("../../plotly"),l=t("../../lib"),c=t("../../components/color"),u=t("../../components/drawing"),f=t("../cartesian/set_convert"),h=t("../../lib/extend").extendFlat,d=t("../cartesian/axes"),p=t("../../lib/filter_visible"),g=t("../../components/dragelement"),v=t("../../components/titles"),m=t("../cartesian/select"),y=t("../cartesian/constants"),b=t("../cartesian/graph_interact");e.exports=n;var x=n.prototype;x.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={}},x.plot=function(t,e){var r,n=this,i=e[n.id],a=e._size;l.getPlotDiv(n.plotContainer.node())!==n.graphDiv&&(n.init(n.graphDiv._fullLayout),n.makeFramework()),n.adjustLayout(i,a);var o=n.traceHash,s={};for(r=0;r_*y?(a=y,i=a*_):(i=m,a=i/_),o=g*i/m,s=v*a/y,r=e.l+e.w*d-i/2,n=e.t+e.h*(1-p)-a/2,l.x0=r,l.y0=n,l.w=i,l.h=a,l.sum=b,l.xaxis={type:"linear",range:[x+2*k-b,b-x-2*w],domain:[d-o/2,d+o/2],_id:"x",_gd:l.graphDiv},f(l.xaxis),l.xaxis.setScale(),l.yaxis={type:"linear",range:[x,b-w-k],domain:[p-s/2,p+s/2],_id:"y",_gd:l.graphDiv},f(l.yaxis),l.yaxis.setScale();var A=l.yaxis.domain[0],M=l.aaxis=h({},t.aaxis,{range:[x,b-w-k],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[A,A+s*_],_axislayer:l.layers.aaxis,_gridlayer:l.layers.agrid,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l"+a+",-"+i/2});f(M);var T=l.baxis=h({},t.baxis,{range:[b-x-k,w],side:"bottom",_counterangle:30,domain:l.xaxis.domain,_axislayer:l.layers.baxis,_gridlayer:l.layers.bgrid,_counteraxis:l.aaxis,_pos:0,_gd:l.graphDiv,_id:"x",_length:i,_gridpath:"M0,0l-"+i/2+",-"+a});f(T),M._counteraxis=T;var E=l.caxis=h({},t.caxis,{range:[b-x-w,k],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[A,A+s*_],_axislayer:l.layers.caxis,_gridlayer:l.layers.cgrid,_counteraxis:l.baxis,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l-"+a+","+i/2});f(E);var L="M"+r+","+(n+a)+"h"+i+"l-"+i/2+",-"+a+"Z";l.clipDef.select("path").attr("d",L),l.layers.plotbg.select("path").attr("d",L);var S="translate("+r+","+n+")";l.plotContainer.selectAll(".scatterlayer,.maplayer,.zoom").attr("transform",S);var C="translate("+r+","+(n+a)+")";l.layers.baxis.attr("transform",C),l.layers.bgrid.attr("transform",C);var z="translate("+(r+i/2)+","+n+")rotate(30)";l.layers.aaxis.attr("transform",z),l.layers.agrid.attr("transform",z);var P="translate("+(r+i/2)+","+n+")rotate(-30)";l.layers.caxis.attr("transform",P),l.layers.cgrid.attr("transform",P),l.drawAxes(!0),l.plotContainer.selectAll(".crisp").classed("crisp",!1);var R=l.layers.axlines;R.select(".aline").attr("d",M.showline?"M"+r+","+(n+a)+"l"+i/2+",-"+a:"M0,0").call(c.stroke,M.linecolor||"#000").style("stroke-width",(M.linewidth||0)+"px"),R.select(".bline").attr("d",T.showline?"M"+r+","+(n+a)+"h"+i:"M0,0").call(c.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),R.select(".cline").attr("d",E.showline?"M"+(r+i/2)+","+n+"l"+i/2+","+a:"M0,0").call(c.stroke,E.linecolor||"#000").style("stroke-width",(E.linewidth||0)+"px")},x.drawAxes=function(t){var e=this,r=e.graphDiv,n=e.id.substr(7)+"title",i=e.aaxis,a=e.baxis,o=e.caxis;if(d.doTicks(r,i,!0),d.doTicks(r,a,!0),d.doTicks(r,o,!0),t){var s=Math.max(i.showticklabels?i.tickfont.size/2:0,(o.showticklabels?.75*o.tickfont.size:0)+("outside"===o.ticks?.87*o.ticklen:0));v.draw(r,"a"+n,{propContainer:i,propName:e.id+".aaxis.title",dfltName:"Component A",attributes:{x:e.x0+e.w/2,y:e.y0-i.titlefont.size/3-s,"text-anchor":"middle"}});var l=(a.showticklabels?a.tickfont.size:0)+("outside"===a.ticks?a.ticklen:0)+3;v.draw(r,"b"+n,{propContainer:a,propName:e.id+".baxis.title",dfltName:"Component B",attributes:{x:e.x0-l,y:e.y0+e.h+.83*a.titlefont.size+l,"text-anchor":"middle"}}),v.draw(r,"c"+n,{propContainer:o,propName:e.id+".caxis.title",dfltName:"Component C",attributes:{x:e.x0+e.w+l,y:e.y0+e.h+.83*o.titlefont.size+l,"text-anchor":"middle"}})}};var w=y.MINZOOM/2+.87,k="m-0.87,.5h"+w+"v3h-"+(w+5.2)+"l"+(w/2+2.6)+",-"+(.87*w+4.5)+"l2.6,1.5l-"+w/2+","+.87*w+"Z",A="m0.87,.5h-"+w+"v3h"+(w+5.2)+"l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-2.6,1.5l"+w/2+","+.87*w+"Z",M="m0,1l"+w/2+","+.87*w+"l2.6,-1.5l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-"+(w/2+2.6)+","+(.87*w+4.5)+"l2.6,1.5l"+w/2+",-"+.87*w+"Z",T="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",E=!0;x.initInteractions=function(){function t(t,e,r){var n=j.getBoundingClientRect();x=e-n.left,w=r-n.top,L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L,S=N.aaxis.range[1]-L.a,z=o(N.graphDiv._fullLayout[N.id].bgcolor).getLuminance(),P="M0,"+N.h+"L"+N.w/2+", 0L"+N.w+","+N.h+"Z",R=!1,O=D.append("path").attr("class","zoombox").style({fill:z>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",P),I=D.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),p()}function e(t,e){return 1-e/N.h}function r(t,e){return 1-(t+(N.h-e)/Math.sqrt(3))/N.w}function n(t,e){return(t-(N.h-e)/Math.sqrt(3))/N.w}function a(t,i){var a=x+t,o=w+i,s=Math.max(0,Math.min(1,e(x,w),e(a,o))),l=Math.max(0,Math.min(1,r(x,w),r(a,o))),c=Math.max(0,Math.min(1,n(x,w),n(a,o))),u=(s/2+c)*N.w,f=(1-s/2-l)*N.w,h=(u+f)/2,d=f-u,p=(1-s)*N.h,g=p-d/_;d.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),I.transition().style("opacity",1).duration(200),R=!0)}function u(t,e){if(C===L)return 2===e&&v(),i(F);i(F);var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r),E&&F.data&&F._context.showTips&&(l.notifier("Double-click to
zoom back out","long"),E=!1)}function f(){L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L}function h(t,e){var r=t/N.xaxis._m,n=e/N.yaxis._m;C={a:L.a-n,b:L.b+(r+n)/2,c:L.c-(r-n)/2};var i=[C.a,C.b,C.c].sort(),a={a:i.indexOf(C.a),b:i.indexOf(C.b),c:i.indexOf(C.c)};i[0]<0&&(i[1]+i[0]/2<0?(i[2]+=i[0]+i[1],i[0]=i[1]=0):(i[2]+=i[0]/2,i[1]+=i[0]/2,i[0]=0),C={a:i[a.a],b:i[a.b],c:i[a.c]},e=(L.a-C.a)*N.yaxis._m,t=(L.c-C.c-L.b+C.b)*N.xaxis._m);var o="translate("+(N.x0+t)+","+(N.y0+e)+")";N.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",o),N.aaxis.range=[C.a,N.sum-C.b-C.c],N.baxis.range=[N.sum-C.a-C.c,C.b],N.caxis.range=[N.sum-C.a-C.b,C.c],N.drawAxes(!1),N.plotContainer.selectAll(".crisp").classed("crisp",!1)}function d(t,e){if(t){var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r)}else 2===e&&v()}function p(){N.plotContainer.selectAll(".select-outline").remove()}function v(){var t={};t[N.id+".aaxis.min"]=0,t[N.id+".baxis.min"]=0,t[N.id+".caxis.min"]=0,F.emit("plotly_doubleclick",null),s.relayout(F,t)}var x,w,L,S,C,z,P,R,O,I,N=this,j=N.layers.plotbg.select("path").node(),F=N.graphDiv,D=N.layers.zoom,B={element:j,gd:F,plotinfo:{plot:D},doubleclick:v,subplot:N.id,prepFn:function(e,r,n){B.xaxes=[N.xaxis],B.yaxes=[N.yaxis];var i=F._fullLayout.dragmode;e.shiftKey&&(i="pan"===i?"zoom":"pan"),"lasso"===i?B.minDrag=1:B.minDrag=void 0,"zoom"===i?(B.moveFn=a,B.doneFn=u,t(e,r,n)):"pan"===i?(B.moveFn=h,B.doneFn=d,f(),p()):"select"!==i&&"lasso"!==i||m(e,r,n,B,i)}};g.init(B),j.onmousemove=function(t){b.hover(F,t,N.id),F._fullLayout._lasthover=j,F._fullLayout._hoversubplot=N.id},j.onmouseout=function(t){F._dragging||g.unhover(F,t)},j.onclick=function(t){b.click(F,t)}}},{"../../components/color":303,"../../components/dragelement":324,"../../components/drawing":326,"../../components/titles":366,"../../lib":382,"../../lib/extend":377,"../../lib/filter_visible":378,"../../plotly":402,"../cartesian/axes":405,"../cartesian/constants":410,"../cartesian/graph_interact":412,"../cartesian/select":418,"../cartesian/set_convert":419,d3:113,tinycolor2:274}],468:[function(t,e,r){"use strict";function n(t){var e;switch(t){case"themes__thumb":e={autosize:!0,width:150,height:150,title:"",showlegend:!1,margin:{l:5,r:5,t:5,b:5,pad:0},annotations:[]};break;case"thumbnail":e={title:"",hidesources:!0,showlegend:!1,borderwidth:0,bordercolor:"",margin:{l:1,r:1,t:1,b:1,pad:0},annotations:[]};break;default:e={}}return e}function i(t){var e=["xaxis","yaxis","zaxis"];return e.indexOf(t.slice(0,5))>-1}var a=t("../plotly"),o=a.Lib.extendFlat,s=a.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var r,l=t.data,c=t.layout,u=s([],l),f=s({},c,n(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var h=Object.keys(f);for(r=0;rl;l++)n(r[l])&&d.push({p:r[l],s:s[l],b:0});return a(e,"marker")&&o(e,e.marker.color,"marker","c"),a(e,"marker.line")&&o(e,e.marker.line.color,"marker.line","c"),d}},{"../../components/colorscale/calc":310,"../../components/colorscale/has_colorscale":316,"../../plots/cartesian/axes":405,"fast-isnumeric":117}],478:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("../scatter/xy_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=a(t,e,u);return f?(u("orientation",e.x&&!e.y?"h":"v"),u("text"),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),void s(t,e,i.defaultLine,{axis:"x",inherit:"y"})):void(e.visible=!1)}},{"../../components/color":303,"../../components/errorbars/defaults":331,"../../lib":382,"../bar/style_defaults":486,"../scatter/xy_defaults":577,"./attributes":476}],479:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../components/errorbars"),a=t("../../components/color");e.exports=function(t,e,r,o){var s,l=t.cd,c=l[0].trace,u=l[0].t,f=t.xa,h=t.ya,d="closest"===o?u.barwidth/2:u.dbar*(1-f._gd._fullLayout.bargap)/2;s="closest"!==o?function(t){return t.p}:"h"===c.orientation?function(t){return t.y}:function(t){return t.x};var p,g;"h"===c.orientation?(p=function(t){return n.inbox(t.b-e,t.x-e)+(t.x-e)/(t.x-t.b)},g=function(t){var e=s(t)-r;return n.inbox(e-d,e+d)}):(g=function(t){return n.inbox(t.b-r,t.y-r)+(t.y-r)/(t.y-t.b)},p=function(t){var r=s(t)-e;return n.inbox(r-d,r+d)});var v=n.getDistanceFunction(o,p,g);if(n.getClosest(l,v,t),t.index!==!1){var m=l[t.index],y=m.mcc||c.marker.color,b=m.mlcc||c.marker.line.color,x=m.mlw||c.marker.line.width;return a.opacity(y)?t.color=y:a.opacity(b)&&x&&(t.color=b),"h"===c.orientation?(t.x0=t.x1=f.c2p(m.x,!0),t.xLabelVal=m.s,t.y0=h.c2p(s(m)-d,!0),t.y1=h.c2p(s(m)+d,!0),t.yLabelVal=m.p):(t.y0=t.y1=h.c2p(m.y,!0),t.yLabelVal=m.s,t.x0=f.c2p(s(m)-d,!0),t.x1=f.c2p(s(m)+d,!0),t.xLabelVal=m.p),m.tx&&(t.text=m.tx),i.hoverInfo(m,c,t),[t]}}},{"../../components/color":303,"../../components/errorbars":332,"../../plots/cartesian/graph_interact":412}],480:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("./layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.calc=t("./calc"),n.setPositions=t("./set_positions"),n.colorbar=t("../scatter/colorbar"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.moduleType="trace",n.name="bar",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","oriented","markerColorscale","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"../scatter/colorbar":559,"./arrays_to_calcdata":475,"./attributes":476,"./calc":477,"./defaults":478,"./hover":479,"./layout_attributes":481,"./layout_defaults":482,"./plot":483,"./set_positions":484,"./style":485}],481:[function(t,e,r){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","group","overlay","relative"],dflt:"group"},barnorm:{valType:"enumerated",values:["","fraction","percent"],dflt:""},bargap:{valType:"number",min:0,max:1},bargroupgap:{valType:"number",min:0,max:1,dflt:0}}},{}],482:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./layout_attributes");e.exports=function(t,e,r){function s(r,n){return a.coerce(t,e,o,r,n)}for(var l=!1,c=!1,u=!1,f={},h=0;h=2?a(t):t>e?Math.ceil(t):Math.floor(t)}var h,d,p,g;if("h"===s.orientation?(p=u.c2p(r.poffset+e.p,!0),g=u.c2p(r.poffset+e.p+r.barwidth,!0),h=c.c2p(e.b,!0),d=c.c2p(e.s+e.b,!0)):(h=c.c2p(r.poffset+e.p,!0),d=c.c2p(r.poffset+e.p+r.barwidth,!0),g=u.c2p(e.s+e.b,!0),p=u.c2p(e.b,!0)),!(i(h)&&i(d)&&i(p)&&i(g)&&h!==d&&p!==g))return void n.select(this).remove();var v=(e.mlw+1||s.marker.line.width+1||(e.trace?e.trace.marker.line.width:0)+1)-1,m=n.round(v/2%1,2);if(!t._context.staticPlot){var y=o.opacity(e.mc||s.marker.color),b=1>y||v>.01?a:l;h=b(h,d),d=b(d,h),p=b(p,g),g=b(g,p)}n.select(this).attr("d","M"+h+","+p+"V"+g+"H"+d+"V"+p+"Z")})}),h.call(s.plot,e)}},{"../../components/color":303,"../../components/errorbars":332,"../../lib":382,"./arrays_to_calcdata":475,d3:113,"fast-isnumeric":117}],484:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axes"),o=t("../../lib");e.exports=function(t,e){var r,s,l=t._fullLayout,c=e.x(),u=e.y();["v","h"].forEach(function(f){function h(e){function r(t){t[p]=t.p+h}var n=[];e.forEach(function(e){t.calcdata[e].forEach(function(t){n.push(t.p)})});var i=o.distinctVals(n),s=i.vals,c=i.minDiff,u=!1,f=[];"group"===l.barmode&&e.forEach(function(e){u||(t.calcdata[e].forEach(function(t){u||f.forEach(function(e){Math.abs(t.p-e)_&&(S=!0,M=_),_>A+R&&(S=!0,A=_))}a.expand(m,[M,A],{tozero:!0,padded:S})}else{var O=function(t){return t[g]=t.s,t.s};for(r=0;r1||0===s.bargap&&0===s.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),e.selectAll("g.points").each(function(t){var e=t[0].trace,r=e.marker,o=r.line,s=(e._input||{}).marker||{},l=a.tryColorscale(r,s,""),c=a.tryColorscale(r,s,"line.");n.select(this).selectAll("path").each(function(t){var e,a,s=(t.mlw+1||o.width+1)-1,u=n.select(this);e="mc"in t?t.mcc=l(t.mc):Array.isArray(r.color)?i.defaultLine:r.color,u.style("stroke-width",s+"px").call(i.fill,e),s&&(a="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(o.color)?i.defaultLine:o.color,u.call(i.stroke,a))})}),e.call(o.style)}},{"../../components/color":303,"../../components/drawing":326,"../../components/errorbars":332,d3:113}],486:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s){r("marker.color",o),i(t,"marker")&&a(t,e,s,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),i(t,"marker.line")&&a(t,e,s,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width")}},{"../../components/color":303,"../../components/colorscale/defaults":313,"../../components/colorscale/has_colorscale":316}],487:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/color/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=o.line;e.exports={y:{valType:"data_array"},x:{valType:"data_array"},x0:{valType:"any"},y0:{valType:"any"},whiskerwidth:{valType:"number",min:0,max:1,dflt:.5},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1},jitter:{valType:"number",min:0,max:1},pointpos:{valType:"number",min:-2,max:2},orientation:{valType:"enumerated",values:["v","h"]},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)"},symbol:a({},o.symbol,{arrayOk:!1}),opacity:a({},o.opacity,{arrayOk:!1,dflt:1}),size:a({},o.size,{arrayOk:!1}),color:a({},o.color,{arrayOk:!1}),line:{color:a({},s.color,{arrayOk:!1,dflt:i.defaultLine}),width:a({},s.width,{arrayOk:!1,dflt:0}),outliercolor:{valType:"color"},outlierwidth:{valType:"number",min:0,dflt:1}}},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2}},fillcolor:n.fillcolor}},{"../../components/color/attributes":302,"../../lib/extend":377,"../scatter/attributes":556}],488:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../../plots/cartesian/axes");e.exports=function(t,e){function r(t,e,r,a,o){var s;return r in e?p=a.makeCalcdata(e,r):(s=r+"0"in e?e[r+"0"]:"name"in e&&("category"===a.type||n(e.name)&&-1!==["linear","log"].indexOf(a.type)||i.isDateTime(e.name)&&"date"===a.type)?e.name:t.numboxes,s=a.d2c(s),p=o.map(function(){return s})),p}function o(t,e,r,a,o){var s,l,c,u,f=a.length,h=e.length,d=[],p=[];for(s=0;f>s;++s)l=a[s],t[s]={pos:l},p[s]=l-o,d[s]=[];for(p.push(a[f-1]+o),s=0;h>s;++s)u=e[s],n(u)&&(c=i.findBin(r[s],p),c>=0&&h>c&&d[c].push(u));return d}function s(t,e){var r,n,a,o;for(o=0;o1,m=r.dPos*(1-h.boxgap)*(1-h.boxgroupgap)/(v?t.numboxes:1),y=v?2*r.dPos*(-.5+(r.boxnum+.5)/t.numboxes)*(1-h.boxgap):0,b=m*g.whiskerwidth;return g.visible!==!0||r.emptybox?void a.select(this).remove():("h"===g.orientation?(l=p,f=d):(l=d,f=p),r.bPos=y,r.bdPos=m,n(),a.select(this).selectAll("path.box").data(o.identity).enter().append("path").attr("class","box").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=l.c2p(t.pos+y-b,!0),s=l.c2p(t.pos+y+b,!0),c=f.c2p(t.q1,!0),u=f.c2p(t.q3,!0),h=o.constrain(f.c2p(t.med,!0),Math.min(c,u)+1,Math.max(c,u)-1),d=f.c2p(g.boxpoints===!1?t.min:t.lf,!0),p=f.c2p(g.boxpoints===!1?t.max:t.uf,!0);"h"===g.orientation?a.select(this).attr("d","M"+h+","+r+"V"+n+"M"+c+","+r+"V"+n+"H"+u+"V"+r+"ZM"+c+","+e+"H"+d+"M"+u+","+e+"H"+p+(0===g.whiskerwidth?"":"M"+d+","+i+"V"+s+"M"+p+","+i+"V"+s)):a.select(this).attr("d","M"+r+","+h+"H"+n+"M"+r+","+c+"H"+n+"V"+u+"H"+r+"ZM"+e+","+c+"V"+d+"M"+e+","+u+"V"+p+(0===g.whiskerwidth?"":"M"+i+","+d+"H"+s+"M"+i+","+p+"H"+s))}),g.boxpoints&&a.select(this).selectAll("g.points").data(function(t){return t.forEach(function(t){t.t=r,t.trace=g}),t}).enter().append("g").attr("class","points").selectAll("path").data(function(t){var e,r,n,a,s,l,f,h="all"===g.boxpoints?t.val:t.val.filter(function(e){return et.uf}),d=(t.q3-t.q1)*u,p=[],v=0;if(g.jitter){for(e=0;et.lo&&(n.so=!0),n})}).enter().append("path").call(s.translatePoints,d,p),void(g.boxmean&&a.select(this).selectAll("path.mean").data(o.identity).enter().append("path").attr("class","mean").style("fill","none").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=f.c2p(t.mean,!0),o=f.c2p(t.mean-t.sd,!0),s=f.c2p(t.mean+t.sd,!0);"h"===g.orientation?a.select(this).attr("d","M"+i+","+r+"V"+n+("sd"!==g.boxmean?"":"m0,0L"+o+","+e+"L"+i+","+r+"L"+s+","+e+"Z")):a.select(this).attr("d","M"+r+","+i+"H"+n+("sd"!==g.boxmean?"":"m0,0L"+e+","+o+"L"+r+","+i+"L"+e+","+s+"Z"))})))})}},{"../../components/drawing":326,"../../lib":382,d3:113}],495:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib");e.exports=function(t,e){var r,o,s,l,c=t._fullLayout,u=e.x(),f=e.y(),h=["v","h"];for(o=0;ol&&(e.z=u.slice(0,l)),s("locationmode"),s("text"),s("marker.line.color"),s("marker.line.width"),i(t,e,o,s,{prefix:"",cLetter:"z"}),void s("hoverinfo",1===o._dataLength?"location+z+text":void 0)):void(e.visible=!1)}},{"../../components/colorscale/defaults":313,"../../lib":382,"./attributes":497}],500:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../heatmap/colorbar"),n.calc=t("./calc"),n.plot=t("./plot").plot,n.moduleType="trace",n.name="choropleth",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","noOpacity"],n.meta={},e.exports=n},{"../../plots/geo":426,"../heatmap/colorbar":514,"./attributes":497,"./calc":498,"./defaults":499,"./plot":501}],501:[function(t,e,r){"use strict";function n(t,e){function r(e){var r=t.mockAxis;return o.tickText(r,r.c2l(e),"hover").text}var n=e.hoverinfo;if("none"===n)return function(t){delete t.nameLabel,delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("name"),s=-1!==i.indexOf("location"),l=-1!==i.indexOf("z"),c=-1!==i.indexOf("text"),u=!a&&s;return function(t){var n=[];u?t.nameLabel=t.id:(a&&(t.nameLabel=e.name),s&&n.push(t.id)),l&&n.push(r(t.z)),c&&n.push(t.tx),t.textLabel=n.join("
")}}function i(t){return function(e,r){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:r,location:e.id,z:e.z}]}}}var a=t("d3"),o=t("../../plots/cartesian/axes"),s=t("../../plots/cartesian/graph_interact"),l=t("../../components/color"),c=t("../../components/drawing"),u=t("../../components/colorscale/get_scale"),f=t("../../components/colorscale/make_scale_function"),h=t("../../lib/topojson_utils").getTopojsonFeatures,d=t("../../lib/geo_location_utils").locationToFeature,p=t("../../lib/array_to_calc_item"),g=t("../../plots/geo/constants"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){for(var r,n=[],i=t.locations,a=i.length,o=h(t,e),s=(t.marker||{}).line||{},l=0;a>l;l++)r=d(t.locationmode,i[l],o),void 0!==r&&(r.z=t.z[l],void 0!==t.text&&(r.tx=t.text[l]),p(s.color,r,"mlc",l),p(s.width,r,"mlw",l),n.push(r));return n.length>0&&(n[0].trace=t),n},m.plot=function(t,e,r){var o,l=t.framework,c=l.select("g.choroplethlayer"),u=l.select("g.baselayer"),f=l.select("g.baselayeroverchoropleth"),h=g.baseLayersOverChoropleth,d=c.selectAll("g.trace.choropleth").data(e,function(t){return t.uid});d.enter().append("g").attr("class","trace choropleth"),d.exit().remove(),d.each(function(e){function r(e,r){if(t.showHover){var n=t.projection(e.properties.ct);c(e),s.loneHover({x:n[0],y:n[1],name:e.nameLabel,text:e.textLabel},{container:t.hoverContainer.node()}),f=u(e,r),t.graphDiv.emit("plotly_hover",f)}}function o(e,r){t.graphDiv.emit("plotly_click",u(e,r))}var l=m.calcGeoJSON(e,t.topojson),c=n(t,e),u=i(e),f=null,h=a.select(this).selectAll("path.choroplethlocation").data(l);h.enter().append("path").classed("choroplethlocation",!0).on("mouseover",r).on("click",o).on("mouseout",function(){s.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",f)}).on("mousedown",function(){s.loneUnhover(t.hoverContainer)}).on("mouseup",r),h.exit().remove()}),f.selectAll("*").remove();for(var p=0;pr;r++)e=f[r],d[r]=e[0]*(t.zmax-t.zmin)+t.zmin,p[r]=e[1];var g=n.extent([t.zmin,t.zmax,a.start,a.start+l*(c-1)]),v=g[t.zminr;r++)e=f[r],d[r]=(e[0]*(c+u-1)-u/2)*l+o,p[r]=e[1];var y=n.scale.linear().interpolate(n.interpolateRgb).domain(d).range(p);return y}},{"../../components/colorscale/get_scale":315,d3:113}],509:[function(t,e,r){"use strict";function n(t,e,r){var n=r[0].trace,a=r[0].x,s=r[0].y,c=n.contours,u=n.uid,f=e.x(),h=e.y(),v=t._fullLayout,b="contour"+u,x=i(c,e,r[0]);if(n.visible!==!0)return v._paper.selectAll("."+b+",.hm"+u).remove(),void v._infolayer.selectAll(".cb"+u).remove();"heatmap"===c.coloring?(n.zauto&&n.autocontour===!1&&(n._input.zmin=n.zmin=c.start-c.size/2,n._input.zmax=n.zmax=n.zmin+x.length*c.size),k(t,e,[r])):v._paper.selectAll(".hm"+u).remove(),o(x),l(x);var _=f.c2p(a[0],!0),w=f.c2p(a[a.length-1],!0),A=h.c2p(s[0],!0),M=h.c2p(s[s.length-1],!0),T=[[_,M],[w,M],[w,A],[_,A]],E=d(e,r,b);p(E,T,c),g(E,x,T,c),m(E,x,c),y(E,e,r[0],T)}function i(t,e,r){for(var n=t.size||1,i=[],a=t.start;at?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);if(5===r||10===r){var n=(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4;return t>n?5===r?713:1114:5===r?104:208}return 15===r?0:r}function o(t){var e,r,n,i,o,s,l,c,u,f=t[0].z,h=f.length,d=f[0].length,p=2===h||2===d;for(r=0;h-1>r;r++)for(i=[],0===r&&(i=i.concat(A)),r===h-2&&(i=i.concat(M)),e=0;d-1>e;e++)for(n=i.slice(),0===e&&(n=n.concat(T)),e===d-2&&(n=n.concat(E)),o=e+","+r,s=[[f[r][e],f[r][e+1]],[f[r+1][e],f[r+1][e+1]]],u=0;ui;i++){if(s>20?(s=S[s][(l[0]||l[1])<0?0:1],t.crossings[o]=C[s]):delete t.crossings[o],l=L[s],!l){_.log("Found bad marching index:",s,e,t.level);break}if(d.push(h(t,e,l)),e[0]+=l[0],e[1]+=l[1],u(d[d.length-1],d[d.length-2])&&d.pop(),o=e.join(","),o===a&&l.join(",")===p||r&&(l[0]&&(e[0]<0||e[0]>v-2)||l[1]&&(e[1]<0||e[1]>g-2)))break;s=t.crossings[o]}1e4===i&&_.log("Infinite loop in contour?");var m,y,b,x,w,k,A,M=u(d[0],d[d.length-1]),T=0,E=.2*t.smoothing,z=[],P=0;for(i=1;i=P;i--)if(m=z[i],R>m){for(b=0,y=i-1;y>=P&&m+z[y]b&&m+z[b]e;)e++,r=Object.keys(i.crossings)[0].split(",").map(Number),s(i,r);1e4===e&&_.log("Infinite loop in contour?")}}function c(t,e,r){var n=0,i=0;return t>20&&e?208===t||1114===t?n=0===r[0]?1:-1:i=0===r[1]?1:-1:-1!==A.indexOf(t)?i=1:-1!==T.indexOf(t)?n=1:-1!==M.indexOf(t)?i=-1:n=-1,[n,i]}function u(t,e){return Math.abs(t[0]-e[0])<.01&&Math.abs(t[1]-e[1])<.01}function f(t,e){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function h(t,e,r){var n=e[0]+Math.max(r[0],0),i=e[1]+Math.max(r[1],0),a=t.z[i][n],o=t.xaxis,s=t.yaxis;if(r[1]){var l=(t.level-a)/(t.z[i][n+1]-a);return[o.c2p((1-l)*t.x[n]+l*t.x[n+1],!0),s.c2p(t.y[i],!0)]}var c=(t.level-a)/(t.z[i+1][n]-a);return[o.c2p(t.x[n],!0),s.c2p((1-c)*t.y[i]+c*t.y[i+1],!0)]}function d(t,e,r){var n=t.plot.select(".maplayer").selectAll("g.contour."+r).data(e);return n.enter().append("g").classed("contour",!0).classed(r,!0),n.exit().remove(),n}function p(t,e,r){var n=t.selectAll("g.contourbg").data([0]);n.enter().append("g").classed("contourbg",!0);var i=n.selectAll("path").data("fill"===r.coloring?[0]:[]);i.enter().append("path"),i.exit().remove(),i.attr("d","M"+e.join("L")+"Z").style("stroke","none")}function g(t,e,r,n){var i=t.selectAll("g.contourfill").data([0]);i.enter().append("g").classed("contourfill",!0);var a=i.selectAll("path").data("fill"===n.coloring?e:[]);a.enter().append("path"),a.exit().remove(),a.each(function(t){var e=v(t,r);e?x.select(this).attr("d",e).style("stroke","none"):x.select(this).remove()})}function v(t,e){function r(t){return Math.abs(t[1]-e[0][1])<.01}function n(t){return Math.abs(t[1]-e[2][1])<.01}function i(t){return Math.abs(t[0]-e[0][0])<.01}function a(t){return Math.abs(t[0]-e[2][0])<.01}for(var o,s,l,c,u,f,h=t.edgepaths.length||t.z[0][0]l;l++){if(!o){_.log("Missing end?",d,t);break}for(r(o)&&!a(o)?s=e[1]:i(o)?s=e[0]:n(o)?s=e[3]:a(o)&&(s=e[2]),u=0;u=0&&(s=v,c=u):Math.abs(o[1]-s[1])<.01?Math.abs(o[1]-v[1])<.01&&(v[0]-o[0])*(s[0]-v[0])>=0&&(s=v,c=u):_.log("endpt to newendpt is not vert. or horz.",o,s,v)}if(o=s,c>=0)break;h+="L"+s}if(c===t.edgepaths.length){_.log("unclosed perimeter path");break}d=c,g=-1===p.indexOf(d),g&&(d=p[0],h+="Z")}for(d=0;de;e++)s.push(1);for(e=0;a>e;e++)i.push(s.slice());for(e=0;eo;o++)for(n=i(l,o),u[o]=new Array(n),s=0;n>s;s++)u[o][s]=e(a(l,o,s));return u}function i(t,e,r,n,i,a){var o,s,l,c=[],u=h.traceIs(t,"contour"),f=h.traceIs(t,"histogram"),d=h.traceIs(t,"gl2d");if(Array.isArray(e)&&!f&&"category"!==a.type){e=e.map(a.d2c);var p=e.length;if(!(i>=p))return u?e.slice(0,i):e.slice(0,i+1);if(u||d)c=e.slice(0,i);else if(1===i)c=[e[0]-.5,e[0]+.5];else{for(c=[1.5*e[0]-.5*e[1]],l=1;p>l;l++)c.push(.5*(e[l-1]+e[l]));c.push(1.5*e[p-1]-.5*e[p-2])}if(i>p){var g=c[c.length-1],v=g-c[c.length-2];for(l=p;i>l;l++)g+=v,c.push(g)}}else for(s=n||1,o=void 0===r?0:f||"category"===a.type?r:a.d2c(r),l=u||d?0:-.5;i>l;l++)c.push(o+s*l);return c}function a(t){return.5-.25*Math.min(1,.5*t)}function o(t,e,r){var n,i,o=1;if(Array.isArray(r))for(n=0;nn&&o>y;n++)o=l(t,e,a(o));return o>y&&u.log("interp2d didn't converge quickly",o),t}function s(t){var e,r,n,i,a,o,s,l,c=[],u={},f=[],h=t[0],d=[],p=[0,0,0],g=m(t);for(r=0;rn;n++)void 0===d[n]&&(o=(void 0!==d[n-1]?1:0)+(void 0!==d[n+1]?1:0)+(void 0!==e[n]?1:0)+(void 0!==h[n]?1:0),o?(0===r&&o++,0===n&&o++,r===t.length-1&&o++,n===d.length-1&&o++,4>o&&(u[[r,n]]=[r,n,o]),c.push([r,n,o])):f.push([r,n]));for(;f.length;){for(s={},l=!1,a=f.length-1;a>=0;a--)i=f[a],r=i[0],n=i[1],o=((u[[r-1,n]]||p)[2]+(u[[r+1,n]]||p)[2]+(u[[r,n-1]]||p)[2]+(u[[r,n+1]]||p)[2])/20,o&&(s[i]=[r,n,o],f.splice(a,1),l=!0);if(!l)throw"findEmpties iterated with no new neighbors";for(i in s)u[i]=s[i],c.push(s[i])}return c.sort(function(t,e){return e[2]-t[2]})}function l(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g,v=0;for(o=0;os;s++)l=b[s],c=t[i+l[0]],c&&(u=c[a+l[1]],void 0!==u&&(0===h?p=g=u:(p=Math.min(p,u),g=Math.max(g,u)),f++,h+=u));if(0===f)throw"iterateInterp2d order is wrong: no defined neighbors";t[i][a]=h/f,void 0===d?4>f&&(v=1):(t[i][a]=(1+r)*t[i][a]-r*d,g>p&&(v=Math.max(v,Math.abs(t[i][a]-d)/(g-p))))}return v}var c=t("fast-isnumeric"),u=t("../../lib"),f=t("../../plots/cartesian/axes"),h=t("../../plots/plots"),d=t("../histogram2d/calc"),p=t("../../components/colorscale/calc"),g=t("./has_columns"),v=t("./convert_column_xyz"),m=t("./max_row_length");e.exports=function(t,e){function r(t){E=e._input.zsmooth=e.zsmooth=!1,u.notifier("cannot fast-zsmooth: "+t)}var a,l,c,y,b,x,_,w,k=f.getFromId(t,e.xaxis||"x"),A=f.getFromId(t,e.yaxis||"y"),M=h.traceIs(e,"contour"),T=h.traceIs(e,"histogram"),E=M?"best":e.zsmooth;if(k._minDtick=0,A._minDtick=0,T){var L=d(t,e);a=L.x,l=L.x0,c=L.dx,y=L.y,b=L.y0,x=L.dy,_=L.z}else g(e)&&v(e,k,A),a=e.x?k.makeCalcdata(e,"x"):[],y=e.y?A.makeCalcdata(e,"y"):[],l=e.x0||0,c=e.dx||1,b=e.y0||0,x=e.dy||1,_=n(e),(M||e.connectgaps)&&(e._emptypoints=s(_),e._interpz=o(_,e._emptypoints,e._interpz));if("fast"===E)if("log"===k.type||"log"===A.type)r("log axis found");else if(!T){if(a.length){var S=(a[a.length-1]-a[0])/(a.length-1),C=Math.abs(S/100);for(w=0;wC){r("x scale is not linear");break}}if(y.length&&"fast"===E){var z=(y[y.length-1]-y[0])/(y.length-1),P=Math.abs(z/100);for(w=0;wP){r("y scale is not linear");break}}}var R=m(_),O="scaled"===e.xtype?"":e.x,I=i(e,O,l,c,R,k),N="scaled"===e.ytype?"":e.y,j=i(e,N,b,x,_.length,A);f.expand(k,I),f.expand(A,j);var F={x:I,y:j,z:_};if(p(e,_,"","z"),M&&e.contours&&"heatmap"===e.contours.coloring){var D="contour"===e.type?"heatmap":"histogram2d";F.xfill=i(D,O,l,c,R,k),F.yfill=i(D,N,b,x,_.length,A)}return[F]};var y=.01,b=[[-1,0],[1,0],[0,-1],[0,1]]},{"../../components/colorscale/calc":310,"../../lib":382,"../../plots/cartesian/axes":405,"../../plots/plots":454,"../histogram2d/calc":533,"./convert_column_xyz":515,"./has_columns":517,"./max_row_length":520,"fast-isnumeric":117}],514:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c="cb"+r.uid,u=s(r.colorscale),f=r.zmin,h=r.zmax;if(i(f)||(f=a.aggNums(Math.min,null,r.z)),i(h)||(h=a.aggNums(Math.max,null,r.z)),t._fullLayout._infolayer.selectAll("."+c).remove(),!r.showscale)return void o.autoMargin(t,c);var d=e[0].t.cb=l(t,c);d.fillcolor(n.scale.linear().domain(u.map(function(t){return f+t[0]*(h-f)})).range(u.map(function(t){return t[1]}))).filllevels({start:f,end:h,size:(h-f)/254}).options(r.colorbar)()}},{"../../components/colorbar/draw":306,"../../components/colorscale/get_scale":315,"../../lib":382,"../../plots/plots":454,d3:113,"fast-isnumeric":117}],515:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a=t.x.slice(),o=t.y.slice(),s=t.z,l=t.text,c=Math.min(a.length,o.length,s.length),u=void 0!==l&&!Array.isArray(l[0]);for(ci;i++)a[i]=e.d2c(a[i]),o[i]=r.d2c(o[i]);var f,h,d,p=n.distinctVals(a),g=p.vals,v=n.distinctVals(o),m=v.vals,y=n.init2dArray(m.length,g.length);for(u&&(d=n.init2dArray(m.length,g.length)),i=0;c>i;i++)f=n.findBin(a[i]+p.minDiff/2,g),h=n.findBin(o[i]+v.minDiff/2,m),y[h][f]=s[i],u&&(d[h][f]=l[i]);t.x=g,t.y=m,t.z=y,u&&(t.text=d)}},{"../../lib":382}],516:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./has_columns"),a=t("./xyz_defaults"),o=t("../../components/colorscale/defaults"),s=t("./attributes");e.exports=function(t,e,r,l){function c(r,i){return n.coerce(t,e,s,r,i)}var u=a(t,e,c);return u?(c("text"),c("zsmooth"),c("connectgaps",i(e)&&e.zsmooth!==!1),void o(t,e,l,c,{prefix:"",cLetter:"z"})):void(e.visible=!1)}},{"../../components/colorscale/defaults":313,"../../lib":382,"./attributes":512,"./has_columns":517,"./xyz_defaults":523}],517:[function(t,e,r){"use strict";e.exports=function(t){return!Array.isArray(t.z[0])}},{}],518:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../lib");e.exports=function(t,e,r,a,o){if(!(t.distancec||c>=m[0].length||0>u||u>m.length)return}else{if(n.inbox(e-g[0],e-g[g.length-1])>n.MAXDIST||n.inbox(r-v[0],r-v[v.length-1])>n.MAXDIST)return;if(o){var w;for(b=[2*g[0]-g[1]],w=1;w0;)_=v.c2p(C[M]),M--;for(x>_&&(w=_,_=x,x=w,N=!0),M=0;void 0===k&&M0;)A=m.c2p(z[M]),M--;if(k>A&&(w=k,k=A,A=w,j=!0),P&&(C=r[0].xfill,z=r[0].yfill),"fast"!==R){var F="best"===R?0:.5;x=Math.max(-F*v._length,x),_=Math.min((1+F)*v._length,_),k=Math.max(-F*m._length,k),A=Math.min((1+F)*m._length,A)}var D=Math.round(_-x),B=Math.round(A-k);if(!(0>=D||0>=B)){var U,V;"fast"===R?(U=I,V=O):(U=D,V=B);var q=document.createElement("canvas");q.width=U,q.height=V;var H,G,Y=q.getContext("2d"),X=i.scale.linear().domain(S.map(function(t){return t[0]})).range(S.map(function(t){var e=a(t[1]).toRgb();return[e.r,e.g,e.b,e.a]})).clamp(!0);"fast"===R?(H=N?function(t){return I-1-t}:o.identity,G=j?function(t){return O-1-t}:o.identity):(H=function(t){return o.constrain(Math.round(v.c2p(C[t])-x),0,D)},G=function(t){return o.constrain(Math.round(m.c2p(z[t])-k),0,B)});var W,Z,K,$,Q,J,tt=G(0),et=[tt,tt],rt=N?0:1,nt=j?0:1,it=0,at=0,ot=0,st=0;if(R){var lt=0,ct=new Uint8Array(D*B*4);if("best"===R){var ut,ft,ht,dt=new Array(C.length),pt=new Array(z.length),gt=new Array(D);for(M=0;MM;M++)gt[M]=n(M,dt);for(Z=0;B>Z;Z++)for(ut=n(Z,pt),ft=T[ut.bin0],ht=T[ut.bin1],M=0;D>M;M++,lt+=4)J=d(ft,ht,gt[M],ut),h(ct,lt,J)}else for(Z=0;O>Z;Z++)for(Q=T[Z],et=G(Z),M=0;D>M;M++)J=f(Q[M],1),lt=4*(et*D+H(M)),h(ct,lt,J);var vt=Y.createImageData(D,B);vt.data.set(ct),Y.putImageData(vt,0,0)}else for(Z=0;O>Z;Z++)if(Q=T[Z],et.reverse(),et[nt]=G(Z+1),et[0]!==et[1]&&void 0!==et[0]&&void 0!==et[1])for(K=H(0),W=[K,K],M=0;I>M;M++)W.reverse(),W[rt]=H(M+1),W[0]!==W[1]&&void 0!==W[0]&&void 0!==W[1]&&($=Q[M],J=f($,(W[1]-W[0])*(et[1]-et[0])),Y.fillStyle="rgba("+J.join(",")+")",Y.fillRect(W[0],et[0],W[1]-W[0],et[1]-et[0]));at=Math.round(at/it),ot=Math.round(ot/it),st=Math.round(st/it);var mt=a("rgb("+at+","+ot+","+st+")");t._hmpixcount=(t._hmpixcount||0)+it,t._hmlumcount=(t._hmlumcount||0)+it*mt.getLuminance();var yt=e.plot.select(".imagelayer").selectAll("g.hm."+b).data([0]);yt.enter().append("g").classed("hm",!0).classed(b,!0),yt.exit().remove();var bt=yt.selectAll("image").data(r);bt.enter().append("svg:image"),bt.exit().remove(),bt.attr({xmlns:c.svg,"xlink:href":q.toDataURL("image/png"),height:B,width:D,x:x,y:k,preserveAspectRatio:"none"})}}var i=t("d3"),a=t("tinycolor2"),o=t("../../lib"),s=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),c=t("../../constants/xmlns_namespaces"),u=t("./max_row_length");e.exports=function(t,e,r){for(var i=0;i0&&(n=!0);for(var s=0;si;i++)e[i]?(t[i]/=e[i],n+=t[i]):t[i]=null;return n}},{}],526:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){return r("histnorm"),n.forEach(function(t){var e=r(t+"bins.start"),n=r(t+"bins.end"),i=r("autobin"+t,!(e&&n));r(i?"nbins"+t:t+"bins.size")}),e}},{}],527:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports={count:function(t,e,r){return r[t]++,1},sum:function(t,e,r,i){var a=i[e];return n(a)?(a=Number(a),r[t]+=a,a):0},avg:function(t,e,r,i,a){var o=i[e];return n(o)&&(o=Number(o),r[t]+=o,a[t]++),0},min:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]>a)return r[t]=a,a-r[t]}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]r&&c.length<5e3;)g=a.tickIncrement(r,b.size),c.push((r+g)/2),u.push(S),x&&_.push(r),E&&w.push(1/(g-r)),P&&k.push(0),r=g;var R=u.length;for(r=0;r=0&&R>m&&(A+=C(m,r,u,y,k));P&&(A=l(u,k)),z&&z(u,A,w);var O=Math.min(c.length,u.length),I=[],N=0,j=O-1;for(r=0;O>r;r++)if(u[r]){N=r;break}for(r=O-1;r>N;r--)if(u[r]){j=r;break}for(r=N;j>=r;r++)n(c[r])&&n(u[r])&&I.push({p:c[r],s:u[r],b:0});return I}}},{"../../lib":382,"../../plots/cartesian/axes":405,"./average":525,"./bin_functions":527,"./norm_functions":531,"fast-isnumeric":117}],529:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("./bin_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=u("x"),h=u("y");u("text");var d=u("orientation",h&&!f?"h":"v"),p=e["v"===d?"x":"y"];if(!p||!p.length)return void(e.visible=!1);var g=e["h"===d?"x":"y"];g&&u("histfunc");var v="h"===d?["y"]:["x"];a(t,e,u,v),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),s(t,e,i.defaultLine,{axis:"x",inherit:"y"})}},{"../../components/color":303,"../../components/errorbars/defaults":331,"../../lib":382,"../bar/style_defaults":486,"./attributes":524,"./bin_defaults":526}],530:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("../bar/layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("../bar/layout_defaults"),n.calc=t("./calc"),n.setPositions=t("../bar/set_positions"),n.plot=t("../bar/plot"),n.style=t("../bar/style"),n.colorbar=t("../scatter/colorbar"),n.hoverPoints=t("../bar/hover"),n.moduleType="trace",n.name="histogram",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","histogram","oriented","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"../bar/hover":479,"../bar/layout_attributes":481,"../bar/layout_defaults":482,"../bar/plot":483,"../bar/set_positions":484,"../bar/style":485,"../scatter/colorbar":559,"./attributes":524,"./calc":528,"./defaults":529}],531:[function(t,e,r){"use strict";e.exports={percent:function(t,e){for(var r=t.length,n=100/e,i=0;r>i;i++)t[i]*=n},probability:function(t,e){for(var r=t.length,n=0;r>n;n++)t[n]/=e},density:function(t,e,r,n){var i=t.length;n=n||1;for(var a=0;i>a;a++)t[a]*=r[a]*n},"probability density":function(t,e,r,n){var i=t.length;n&&(e/=n);for(var a=0;i>a;a++)t[a]*=r[a]/e}}},{}],532:[function(t,e,r){"use strict";var n=t("../histogram/attributes"),i=t("../heatmap/attributes"),a=t("../../components/colorscale/attributes"),o=t("../../lib/extend").extendFlat;e.exports=o({},{x:n.x,y:n.y,z:{valType:"data_array"},marker:{color:{valType:"data_array"}},histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zsmooth:i.zsmooth,_nestedModules:{colorbar:"Colorbar"}},a,{autocolorscale:o({},a.autocolorscale,{dflt:!1})})},{"../../components/colorscale/attributes":309,"../../lib/extend":377,"../heatmap/attributes":512,"../histogram/attributes":524}],533:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("../histogram/bin_functions"),o=t("../histogram/norm_functions"),s=t("../histogram/average");e.exports=function(t,e){var r,l,c,u,f,h,d=i.getFromId(t,e.xaxis||"x"),p=e.x?d.makeCalcdata(e,"x"):[],g=i.getFromId(t,e.yaxis||"y"),v=e.y?g.makeCalcdata(e,"y"):[],m=Math.min(p.length,v.length);p.length>m&&p.splice(m,p.length-m),v.length>m&&v.splice(m,v.length-m),!e.autobinx&&"xbins"in e||(e.xbins=i.autoBin(p,d,e.nbinsx,"2d"),"histogram2dcontour"===e.type&&(e.xbins.start-=e.xbins.size,e.xbins.end+=e.xbins.size),e._input.xbins=e.xbins),!e.autobiny&&"ybins"in e||(e.ybins=i.autoBin(v,g,e.nbinsy,"2d"),"histogram2dcontour"===e.type&&(e.ybins.start-=e.ybins.size,e.ybins.end+=e.ybins.size),e._input.ybins=e.ybins),f=[];var y,b,x=[],_=[],w="string"==typeof e.xbins.size?[]:e.xbins,k="string"==typeof e.xbins.size?[]:e.ybins,A=0,M=[],T=e.histnorm,E=e.histfunc,L=-1!==T.indexOf("density"),S="max"===E||"min"===E,C=S?null:0,z=a.count,P=o[T],R=!1,O=[],I=[],N="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";N&&"count"!==E&&(R="avg"===E,z=a[E]);var j=e.xbins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6;for(h=j.start;F>h;h=i.tickIncrement(h,j.size))x.push(C),Array.isArray(w)&&w.push(h),R&&_.push(0);Array.isArray(w)&&w.push(h);var D=x.length;for(r=e.xbins.start,l=(h-r)/D,r+=l/2,j=e.ybins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6,h=j.start;F>h;h=i.tickIncrement(h,j.size))f.push(x.concat()),Array.isArray(k)&&k.push(h),R&&M.push(_.concat());Array.isArray(k)&&k.push(h);var B=f.length;for(c=e.ybins.start,u=(h-c)/B,c+=u/2,L&&(O=x.map(function(t,e){return Array.isArray(w)?1/(w[e+1]-w[e]):1/l}),I=f.map(function(t,e){return Array.isArray(k)?1/(k[e+1]-k[e]):1/u})),h=0;m>h;h++)y=n.findBin(p[h],w),b=n.findBin(v[h],k),y>=0&&D>y&&b>=0&&B>b&&(A+=z(y,h,f[b],N,M[b]));if(R)for(b=0;B>b;b++)A+=s(f[b],M[b]);if(P)for(b=0;B>b;b++)P(f[b],A,O,I[b]);return{x:p,x0:r,dx:l,y:v,y0:c,dy:u,z:f}}},{"../../lib":382,"../../plots/cartesian/axes":405,"../histogram/average":525,"../histogram/bin_functions":527,"../histogram/norm_functions":531}],534:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./sample_defaults"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r){function s(r,i){return n.coerce(t,e,o,r,i)}i(t,e,s),s("zsmooth"),a(t,e,r,s,{prefix:"",cLetter:"z"})}},{"../../components/colorscale/defaults":313,"../../lib":382,"./attributes":532,"./sample_defaults":536}],535:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../heatmap/calc"),n.plot=t("../heatmap/plot"),n.colorbar=t("../heatmap/colorbar"),n.style=t("../heatmap/style"),n.hoverPoints=t("../heatmap/hover"),n.moduleType="trace",n.name="histogram2d",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"../heatmap/calc":513,"../heatmap/colorbar":514,"../heatmap/hover":518,"../heatmap/plot":521,"../heatmap/style":522,"./attributes":532,"./defaults":534}],536:[function(t,e,r){"use strict";var n=t("../histogram/bin_defaults");e.exports=function(t,e,r){var i=r("x"),a=r("y");if(!(i&&i.length&&a&&a.length))return void(e.visible=!1);var o=r("z")||r("marker.color");o&&r("histfunc");var s=["x","y"];n(t,e,r,s)}},{"../histogram/bin_defaults":526}],537:[function(t,e,r){"use strict";var n=t("../histogram2d/attributes"),i=t("../contour/attributes"),a=t("../../components/colorscale/attributes"),o=t("../../lib/extend").extendFlat;e.exports=o({},{x:n.x,y:n.y,z:n.z,marker:n.marker,histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,autocontour:i.autocontour,ncontours:i.ncontours,contours:i.contours,line:i.line,_nestedModules:{colorbar:"Colorbar"}},a)},{"../../components/colorscale/attributes":309,"../../lib/extend":377,"../contour/attributes":502,"../histogram2d/attributes":532}],538:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../histogram2d/sample_defaults"),a=t("../contour/style_defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,i){return n.coerce(t,e,o,r,i)}i(t,e,l);var c=n.coerce2(t,e,o,"contours.start"),u=n.coerce2(t,e,o,"contours.end"),f=l("autocontour",!(c&&u));l(f?"ncontours":"contours.size"),a(t,e,l,s)}},{"../../lib":382,"../contour/style_defaults":511,"../histogram2d/sample_defaults":536,"./attributes":537}],539:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../contour/calc"),n.plot=t("../contour/plot"),n.style=t("../contour/style"),n.colorbar=t("../contour/colorbar"),n.hoverPoints=t("../contour/hover"),n.moduleType="trace",n.name="histogram2dcontour",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","contour","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"../contour/calc":503,"../contour/colorbar":504,"../contour/hover":506,"../contour/plot":509,"../contour/style":510,"./attributes":537,"./defaults":538}],540:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../surface/attributes"),a=t("../../lib/extend").extendFlat;e.exports={x:{valType:"data_array"},y:{valType:"data_array"},z:{valType:"data_array"},i:{valType:"data_array"},j:{valType:"data_array"},k:{valType:"data_array"},delaunayaxis:{valType:"enumerated",values:["x","y","z"],dflt:"z"},alphahull:{valType:"number",dflt:-1},intensity:{valType:"data_array"},color:{valType:"color"},vertexcolor:{valType:"data_array"},facecolor:{valType:"data_array"},opacity:a({},i.opacity),flatshading:{valType:"boolean",dflt:!1},contour:{show:a({},i.contours.x.show,{}),color:a({},i.contours.x.color),width:a({},i.contours.x.width)},colorscale:n.colorscale,reversescale:n.reversescale,showscale:n.showscale,lightposition:{x:a({},i.lightposition.x,{dflt:1e5}),y:a({},i.lightposition.y,{dflt:1e5}),z:a({},i.lightposition.z,{dflt:0})},lighting:a({},{vertexnormalsepsilon:{valType:"number",min:0,max:1,dflt:1e-12},facenormalsepsilon:{valType:"number",min:0,max:1,dflt:1e-6}},i.lighting),_nestedModules:{colorbar:"Colorbar"}}},{"../../components/colorscale/attributes":309,"../../lib/extend":377,"../surface/attributes":601}],541:[function(t,e,r){"use strict";function n(t,e,r){this.scene=t,this.uid=r,this.mesh=e,this.name="",this.color="#fff",this.data=null,this.showContour=!1}function i(t){return t.map(function(t){var e=t[0],r=c(t[1]),n=r.toRgb();return{index:e,rgb:[n.r,n.g,n.b,1]}})}function a(t){return t.map(d)}function o(t,e,r){for(var n=new Array(t.length),i=0;i0)s=f(t.alphahull,l);else{var c=["x","y","z"].indexOf(t.delaunayaxis);s=u(l.map(function(t){return[t[(c+1)%3],t[(c+2)%3]]}))}var p={positions:l,cells:s,lightPosition:[t.lightposition.x,t.lightposition.y,t.lightposition.z],ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,vertexNormalsEpsilon:t.lighting.vertexnormalsepsilon,faceNormalsEpsilon:t.lighting.facenormalsepsilon,opacity:t.opacity,contourEnable:t.contour.show,contourColor:d(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",p.vertexIntensity=t.intensity,p.colormap=i(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolors[0],p.vertexColors=a(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],p.cellColors=a(t.facecolor)):(this.color=t.color,p.meshColor=d(t.color)),this.mesh.update(p)},p.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=s},{"../../lib/str2rgbarray":394,"alpha-shape":40,"convex-hull":102,"delaunay-triangulate":114,"gl-mesh3d":150,tinycolor2:274}],542:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/colorbar/defaults"),a=t("./attributes");e.exports=function(t,e,r,o){function s(r,i){return n.coerce(t,e,a,r,i)}function l(t){var e=t.map(function(t){var e=s(t);return e&&Array.isArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var c=l(["x","y","z"]),u=l(["i","j","k"]);return c?(u&&u.forEach(function(t){for(var e=0;el||(c=p[r],void 0!==c&&""!==c||(c=r),c=String(c),void 0===y[c]&&(y[c]=!0,u=a(e.marker.colors[r]),u.isValid()?(u=o.addOpacity(u,u.getAlpha()),m[c]||(m[c]=u)):m[c]?u=m[c]:(u=!1,b=!0),f=-1!==_.indexOf(c),f||(x+=l),g.push({v:l,label:c,color:u,i:r,hidden:f}))));if(e.sort&&g.sort(function(t,e){return e.v-t.v}),b)for(r=0;r")}return g};var l},{"../../components/color":303,"./helpers":548,"fast-isnumeric":117,tinycolor2:274}],547:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(r,a){return n.coerce(t,e,i,r,a)}var s=n.coerceFont,l=o("values");if(!Array.isArray(l)||!l.length)return void(e.visible=!1);var c=o("labels");Array.isArray(c)||(o("label0"),o("dlabel"));var u=o("marker.line.width");u&&o("marker.line.color");var f=o("marker.colors");Array.isArray(f)||(e.marker.colors=[]),o("scalegroup");var h=o("text"),d=o("textinfo",Array.isArray(h)?"text+percent":"percent");if(o("hoverinfo",1===a._dataLength?"label+text+value+percent":void 0),d&&"none"!==d){var p=o("textposition"),g=Array.isArray(p)||"auto"===p,v=g||"inside"===p,m=g||"outside"===p;if(v||m){var y=s(o,"textfont",a.font);v&&s(o,"insidetextfont",y),m&&s(o,"outsidetextfont",y)}}o("domain.x"),o("domain.y"),o("hole"),o("sort"),o("direction"),o("rotation"),o("pull")}},{"../../lib":382,"./attributes":544}],548:[function(t,e,r){"use strict";var n=t("../../lib");r.formatPiePercent=function(t,e){var r=(100*t).toPrecision(3);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)+"%"},r.formatPieValue=function(t,e){var r=t.toPrecision(10);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)}},{"../../lib":382}],549:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.layoutAttributes=t("./layout_attributes"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.styleOne=t("./style_one"),n.moduleType="trace",n.name="pie",n.basePlotModule=t("./base_plot"),n.categories=["pie","showLegend"],n.meta={},e.exports=n},{"./attributes":544,"./base_plot":545,"./calc":546,"./defaults":547,"./layout_attributes":550,"./layout_defaults":551,"./plot":552,"./style":553,"./style_one":554}],550:[function(t,e,r){"use strict";e.exports={hiddenlabels:{valType:"data_array"}}},{}],551:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e){function r(r,a){return n.coerce(t,e,i,r,a)}r("hiddenlabels")}},{"../../lib":382,"./layout_attributes":550}],552:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,o=Math.PI*Math.min(e.v/r.vTotal,.5),s=1-r.trace.hole,l=i(e,r),c={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(c.scale>=1)return c;var u=a+1/(2*Math.tan(o)),f=r.r*Math.min(1/(Math.sqrt(u*u+.5)+u),s/(Math.sqrt(a*a+s/2)+a)),h={scale:2*f/t.height,rCenter:Math.cos(f/r.r)-f*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},d=1/a,p=d+1/(2*Math.tan(o)),g=r.r*Math.min(1/(Math.sqrt(p*p+.5)+p),s/(Math.sqrt(d*d+s/2)+d)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},m=v.scale>h.scale?v:h;return c.scale<1&&m.scale>c.scale?m:c}function i(t,e){if(t.v===e.vTotal&&!e.trace.hole)return 1;var r=Math.PI*Math.min(t.v/e.vTotal,.5);return Math.min(1/(1+1/Math.sin(r)),(1-e.trace.hole)/2)}function a(t,e){var r=e.pxmid[0],n=e.pxmid[1],i=t.width/2,a=t.height/2;return 0>r&&(i*=-1),0>n&&(a*=-1),{scale:1,rCenter:1,rotate:0,x:i+Math.abs(a)*(i>0?1:-1)/2,y:a/(1+r*r/(n*n)),outside:!0}}function o(t,e){function r(t,e){return t.pxmid[1]-e.pxmid[1]}function n(t,e){return e.pxmid[1]-t.pxmid[1]}function i(t,r){r||(r={});var n,i,a,s,h,d,g=r.labelExtraY+(o?r.yLabelMax:r.yLabelMin),v=o?t.yLabelMin:t.yLabelMax,m=o?t.yLabelMax:t.yLabelMin,y=t.cyFinal+c(t.px0[1],t.px1[1]),b=g-v;if(b*f>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(i=0;i=e.pull[a.i]||((t.pxmid[1]-a.pxmid[1])*f>0?(s=a.cyFinal+c(a.px0[1],a.px1[1]),b=s-v-t.labelExtraY,b*f>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-y)*f>0&&(n=3*u*Math.abs(i-p.indexOf(t)),h=a.cxFinal+l(a.px0[0],a.px1[0]),d=h+n-(t.cxFinal+t.pxmid[0])-t.labelExtraX,d*u>0&&(t.labelExtraX+=d)))}var a,o,s,l,c,u,f,h,d,p,g,v,m;for(o=0;2>o;o++)for(s=o?r:n,c=o?Math.max:Math.min,f=o?1:-1,a=0;2>a;a++){for(l=a?Math.max:Math.min,u=a?1:-1,h=t[o][a],h.sort(s),d=t[1-o][a],p=d.concat(h),v=[],g=0;gu&&(u=s.pull[a]);o.r=Math.min(r/c(s.tilt,Math.sin(l),s.depth),n/c(s.tilt,Math.cos(l),s.depth))/(2+2*u),o.cx=e.l+e.w*(s.domain.x[1]+s.domain.x[0])/2,o.cy=e.t+e.h*(2-s.domain.y[1]-s.domain.y[0])/2,s.scalegroup&&-1===d.indexOf(s.scalegroup)&&d.push(s.scalegroup)}for(a=0;af.vTotal/2?1:0)}function c(t,e,r){if(!t)return 1;var n=Math.sin(t*Math.PI/180);return Math.max(.01,r*n*Math.abs(e)+2*Math.sqrt(1-n*n*e*e))}var u=t("d3"),f=t("../../plots/cartesian/graph_interact"),h=t("../../components/color"),d=t("../../components/drawing"),p=t("../../lib/svg_text_utils"),g=t("./helpers");e.exports=function(t,e){var r=t._fullLayout;s(e,r._size);var c=r._pielayer.selectAll("g.trace").data(e);c.enter().append("g").attr({"stroke-linejoin":"round","class":"trace"}),c.exit().remove(),c.order(),c.each(function(e){var s=u.select(this),c=e[0],v=c.trace,m=0,y=(v.depth||0)*c.r*Math.sin(m)/2,b=v.tiltaxis||0,x=b*Math.PI/180,_=[y*Math.sin(x),y*Math.cos(x)],w=c.r*Math.cos(m),k=s.selectAll("g.part").data(v.tilt?["top","sides"]:["top"]);k.enter().append("g").attr("class",function(t){return t+" part"}),k.exit().remove(),k.order(),l(e),s.selectAll(".top").each(function(){var s=u.select(this).selectAll("g.slice").data(e);s.enter().append("g").classed("slice",!0),s.exit().remove();var l=[[[],[]],[[],[]]],m=!1;s.each(function(o){function s(e){var n=t._fullLayout,a=t._fullData[v.index],s=a.hoverinfo;if("all"===s&&(s="label+text+value+percent+name"),!t._dragging&&n.hovermode!==!1&&"none"!==s&&s){var l=i(o,c),u=k+o.pxmid[0]*(1-l),h=A+o.pxmid[1]*(1-l),d=r.separators,p=[];-1!==s.indexOf("label")&&p.push(o.label),a.text&&a.text[o.i]&&-1!==s.indexOf("text")&&p.push(a.text[o.i]),-1!==s.indexOf("value")&&p.push(g.formatPieValue(o.v,d)),-1!==s.indexOf("percent")&&p.push(g.formatPiePercent(o.v/c.vTotal,d)),f.loneHover({x0:u-l*c.r,x1:u+l*c.r,y:h,text:p.join("
"),name:-1!==s.indexOf("name")?a.name:void 0,color:o.color,idealAlign:o.pxmid[0]<0?"left":"right"},{container:n._hoverlayer.node(), +outerContainer:n._paper.node()}),f.hover(t,e,"pie"),E=!0}}function h(e){t.emit("plotly_unhover",{points:[e]}),E&&(f.loneUnhover(r._hoverlayer.node()),E=!1)}function y(){t._hoverdata=[o],t._hoverdata.trace=e.trace,f.click(t,{target:!0})}function x(t,e,r,n){return"a"+n*c.r+","+n*w+" "+b+" "+o.largeArc+(r?" 1 ":" 0 ")+n*(e[0]-t[0])+","+n*(e[1]-t[1])}if(o.hidden)return void u.select(this).selectAll("path,g").remove();l[o.pxmid[1]<0?0:1][o.pxmid[0]<0?0:1].push(o);var k=c.cx+_[0],A=c.cy+_[1],M=u.select(this),T=M.selectAll("path.surface").data([o]),E=!1;if(T.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),M.select("path.textline").remove(),M.on("mouseover",s).on("mouseout",h).on("click",y),v.pull){var L=+(Array.isArray(v.pull)?v.pull[o.i]:v.pull)||0;L>0&&(k+=L*o.pxmid[0],A+=L*o.pxmid[1])}o.cxFinal=k,o.cyFinal=A;var S=v.hole;if(o.v===c.vTotal){var C="M"+(k+o.px0[0])+","+(A+o.px0[1])+x(o.px0,o.pxmid,!0,1)+x(o.pxmid,o.px0,!0,1)+"Z";S?T.attr("d","M"+(k+S*o.px0[0])+","+(A+S*o.px0[1])+x(o.px0,o.pxmid,!1,S)+x(o.pxmid,o.px0,!1,S)+"Z"+C):T.attr("d",C)}else{var z=x(o.px0,o.px1,!0,1);if(S){var P=1-S;T.attr("d","M"+(k+S*o.px1[0])+","+(A+S*o.px1[1])+x(o.px1,o.px0,!1,S)+"l"+P*o.px0[0]+","+P*o.px0[1]+z+"Z")}else T.attr("d","M"+k+","+A+"l"+o.px0[0]+","+o.px0[1]+z+"Z")}var R=Array.isArray(v.textposition)?v.textposition[o.i]:v.textposition,O=M.selectAll("g.slicetext").data(o.text&&"none"!==R?[0]:[]);O.enter().append("g").classed("slicetext",!0),O.exit().remove(),O.each(function(){var t=u.select(this).selectAll("text").data([0]);t.enter().append("text").attr("data-notex",1),t.exit().remove(),t.text(o.text).attr({"class":"slicetext",transform:"","data-bb":"","text-anchor":"middle",x:0,y:0}).call(d.font,"outside"===R?v.outsidetextfont:v.insidetextfont).call(p.convertToTspans),t.selectAll("tspan.line").attr({x:0,y:0});var e,r=d.bBox(t.node());"outside"===R?e=a(r,o):(e=n(r,o,c),"auto"===R&&e.scale<1&&(t.call(d.font,v.outsidetextfont),v.outsidetextfont.family===v.insidetextfont.family&&v.outsidetextfont.size===v.insidetextfont.size||(t.attr({"data-bb":""}),r=d.bBox(t.node())),e=a(r,o)));var i=k+o.pxmid[0]*e.rCenter+(e.x||0),s=A+o.pxmid[1]*e.rCenter+(e.y||0);e.outside&&(o.yLabelMin=s-r.height/2,o.yLabelMid=s,o.yLabelMax=s+r.height/2,o.labelExtraX=0,o.labelExtraY=0,m=!0),t.attr("transform","translate("+i+","+s+")"+(e.scale<1?"scale("+e.scale+")":"")+(e.rotate?"rotate("+e.rotate+")":"")+"translate("+-(r.left+r.right)/2+","+-(r.top+r.bottom)/2+")")})}),m&&o(l,v),s.each(function(t){if(t.labelExtraX||t.labelExtraY){var e=u.select(this),r=e.select("g.slicetext text");r.attr("transform","translate("+t.labelExtraX+","+t.labelExtraY+")"+r.attr("transform"));var n=t.cxFinal+t.pxmid[0],i=t.cyFinal+t.pxmid[1],a="M"+n+","+i,o=(t.yLabelMax-t.yLabelMin)*(t.pxmid[0]<0?-1:1)/4;if(t.labelExtraX){var s=t.labelExtraX*t.pxmid[1]/t.pxmid[0],l=t.yLabelMid+t.labelExtraY-(t.cyFinal+t.pxmid[1]);a+=Math.abs(s)>Math.abs(l)?"l"+l*t.pxmid[0]/t.pxmid[1]+","+l+"H"+(n+t.labelExtraX+o):"l"+t.labelExtraX+","+s+"v"+(l-s)+"h"+o}else a+="V"+(t.yLabelMid+t.labelExtraY)+"h"+o;e.append("path").classed("textline",!0).call(h.stroke,v.outsidetextfont.color).attr({"stroke-width":Math.min(2,v.outsidetextfont.size/8),d:a,fill:"none"})}})})}),setTimeout(function(){c.selectAll("tspan").each(function(){var t=u.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":303,"../../components/drawing":326,"../../lib/svg_text_utils":395,"../../plots/cartesian/graph_interact":412,"./helpers":548,d3:113}],553:[function(t,e,r){"use strict";var n=t("d3"),i=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0],r=e.trace,a=n.select(this);a.style({opacity:r.opacity}),a.selectAll(".top path.surface").each(function(t){n.select(this).call(i,t,r)})})}},{"./style_one":554,d3:113}],554:[function(t,e,r){"use strict";var n=t("../../components/color");e.exports=function(t,e,r){var i=r.marker.line.color;Array.isArray(i)&&(i=i[e.i]||n.defaultLine);var a=r.marker.line.width||0;Array.isArray(a)&&(a=a[e.i]||0),t.style({"stroke-width":a,fill:e.color}).call(n.stroke,i)}},{"../../components/color":303}],555:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t){var e=t[0].trace,r=e.marker;if(n.mergeArray(e.text,t,"tx"),n.mergeArray(e.textposition,t,"tp"),e.textfont&&(n.mergeArray(e.textfont.size,t,"ts"),n.mergeArray(e.textfont.color,t,"tc"),n.mergeArray(e.textfont.family,t,"tf")),r&&r.line){var i=r.line;n.mergeArray(r.opacity,t,"mo"),n.mergeArray(r.symbol,t,"mx"),n.mergeArray(r.color,t,"mc"),n.mergeArray(i.color,t,"mlc"),n.mergeArray(i.width,t,"mlw")}}},{"../../lib":382}],556:[function(t,e,r){"use strict";var n=t("../../components/colorscale/color_attributes"),i=t("../../components/drawing"),a=(t("./constants"),t("../../lib/extend").extendFlat);e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number",min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:a({},{symbol:{valType:"enumerated",values:i.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number",dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},showscale:{valType:"boolean",dflt:!1},line:a({},{width:{valType:"number",min:0,arrayOk:!0}},n("marker.line"))},n("marker")),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:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":311,"../../components/drawing":326,"../../lib/extend":377,"./constants":560}],557:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./subtypes"),s=t("./marker_colorscale_calc");e.exports=function(t,e){var r,l,c,u=i.getFromId(t,e.xaxis||"x"),f=i.getFromId(t,e.yaxis||"y"),h=u.makeCalcdata(e,"x"),d=f.makeCalcdata(e,"y"),p=Math.min(h.length,d.length);u._minDtick=0,f._minDtick=0,h.length>p&&h.splice(p,h.length-p),d.length>p&&d.splice(p,d.length-p);var g={padded:!0},v={padded:!0};if(o.hasMarkers(e)){if(r=e.marker,l=r.size,Array.isArray(l)){var m={type:"linear"};i.setConvert(m),l=m.makeCalcdata(e.marker,"size"),l.length>p&&l.splice(p,l.length-p)}var y,b=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/b),3)}:function(t){return Math.max((t||0)/b,3)},g.ppad=v.ppad=Array.isArray(l)?l.map(y):y(l)}s(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||h[0]===h[p-1]&&d[0]===d[p-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(o.hasMarkers(e)||o.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||h[0]===h[p-1]&&d[0]===d[p-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(v.padded=!1):v.tozero=!0,i.expand(u,h,g),i.expand(f,d,v);var x=new Array(p);for(c=0;p>c;c++)x[c]=n(h[c])&&n(d[c])?{x:h[c],y:d[c]}:{x:!1,y:!1};return void 0!==typeof l&&a.mergeArray(l,x,"ms"),t.firstscatter=!1,x}},{"../../lib":382,"../../plots/cartesian/axes":405,"./marker_colorscale_calc":570,"./subtypes":575,"fast-isnumeric":117}],558:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i,a;for(e=0;e=0;i--)if(a=t[i],"scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}},{}],559:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c=r.marker,u="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void o.autoMargin(t,u);var f=s(c.colorscale),h=c.color,d=c.cmin,p=c.cmax;i(d)||(d=a.aggNums(Math.min,null,h)),i(p)||(p=a.aggNums(Math.max,null,h));var g=e[0].t.cb=l(t,u);g.fillcolor(n.scale.linear().domain(f.map(function(t){return d+t[0]*(p-d)})).range(f.map(function(t){return t[1]}))).filllevels({start:d,end:p,size:(p-d)/254}).options(c.colorbar)()}},{"../../components/colorbar/draw":306,"../../components/colorscale/get_scale":315,"../../lib":382,"../../plots/plots":454,d3:113,"fast-isnumeric":117}],560:[function(t,e,r){"use strict";e.exports={PTS_LINESONLY:20}},{}],561:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("./constants"),o=t("./subtypes"),s=t("./xy_defaults"),l=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),h=t("./fillcolor_defaults"),d=t("../../components/errorbars/defaults");e.exports=function(t,e,r,p){function g(r,a){return n.coerce(t,e,i,r,a)}var v=s(t,e,g),m=vi(f))break;l=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,c=f,d=!1):m>y&&(m=y,u=f,d=!0)}if(d?(C[z++]=c,l!==u&&(C[z++]=u)):(u!==s&&(C[z++]=u),l!==c&&(C[z++]=c)),C[z++]=l,o>=t.length||!f)break;C[z++]=f,s=f}}else C[z++]=c}E.push(C.slice(0,z))}return E}},{"../../plots/cartesian/axes":405}],568:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=r("line.shape");"spline"===n&&r("line.smoothing")}},{}],569:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t){var e=t.marker,r=e.sizeref||1,i=e.sizemin||0,a="area"===e.sizemode?function(t){return Math.sqrt(t/r)}:function(t){return t/r};return function(t){var e=a(t/2);return n(e)&&e>0?Math.max(e,i):0}}},{"fast-isnumeric":117}],570:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("./subtypes");e.exports=function(t){if(a.hasMarkers(t)){var e=t.marker;n(t,"marker")&&i(t,e.color,"marker","c"),n(t,"marker.line")&&i(t,e.line.color,"marker.line","c")}}},{"../../components/colorscale/calc":310,"../../components/colorscale/has_colorscale":316,"./subtypes":575}],571:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l){var c,u=o.isBubble(t),f=(t.line||{}).color;f&&(r=f),l("marker.symbol"),l("marker.opacity",u?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),c=f&&e.marker.color!==f?f:u?n.background:n.defaultLine,l("marker.line.color",c),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",u?1:0),u&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode"))}},{"../../components/color":303,"../../components/colorscale/defaults":313,"../../components/colorscale/has_colorscale":316,"./subtypes":575}],572:[function(t,e,r){"use strict";function n(t,e,r){var n=e.x(),a=e.y(),o=i.extent(n.range.map(n.l2c)),s=i.extent(a.range.map(a.l2c));r.forEach(function(t,e){var n=t[0].trace;if(l.hasMarkers(n)){var i=n.marker.maxdisplayed;if(0!==i){var a=t.filter(function(t){return t.x>=o[0]&&t.x<=o[1]&&t.y>=s[0]&&t.y<=s[1]}),c=Math.ceil(a.length/i),u=0;r.forEach(function(t,r){var n=t[0].trace;l.hasMarkers(n)&&n.marker.maxdisplayed>0&&e>r&&u++});var f=Math.round(u*c/3+Math.floor(u/3)*c/7.1);t.forEach(function(t){delete t.vis}),a.forEach(function(t,e){0===Math.round((e+f)%c)&&(t.vis=!0)})}}})}var i=t("d3"),a=t("../../lib"),o=t("../../components/drawing"),s=t("../../components/errorbars"),l=t("./subtypes"),c=t("./arrays_to_calcdata"),u=t("./line_points");e.exports=function(t,e,r){function f(t){return t.filter(function(t){return t.vis})}n(t,e,r);var h=e.x(),d=e.y(),p=e.plot.select(".scatterlayer").selectAll("g.trace.scatter").data(r);p.enter().append("g").attr("class","trace scatter").style("stroke-miterlimit",2),p.call(s.plot,e);var g,v,m,y,b="";p.each(function(t){var e=t[0].trace,r=e.line,n=i.select(this);if(e.visible===!0&&(v=e.fill.charAt(e.fill.length-1),"x"!==v&&"y"!==v&&(v=""),t[0].node3=n,c(t),l.hasLines(e)||"none"!==e.fill)){var a,s,f,p,x,_="",w="";g="tozero"===e.fill.substr(0,6)||"toself"===e.fill||"to"===e.fill.substr(0,2)&&!b?n.append("path").classed("js-fill",!0):null,y&&(m=y.datum(t)),y=n.append("path").classed("js-fill",!0),-1!==["hv","vh","hvh","vhv"].indexOf(r.shape)?(f=o.steps(r.shape),p=o.steps(r.shape.split("").reverse().join(""))):f=p="spline"===r.shape?function(t){var e=t[t.length-1];return t[0][0]===e[0]&&t[0][1]===e[1]?o.smoothclosed(t.slice(1),r.smoothing):o.smoothopen(t,r.smoothing)}:function(t){return"M"+t.join("L")},x=function(t){return p(t.reverse())};var k=u(t,{xaxis:h,yaxis:d,connectGaps:e.connectgaps,baseTolerance:Math.max(r.width||1,3)/4,linear:"linear"===r.shape});if(k.length){for(var A=k[0][0],M=k[k.length-1],T=M[M.length-1],E=0;E1&&n.append("path").classed("js-line",!0).attr("d",a)}g?A&&T&&(v?("y"===v?A[1]=T[1]=d.c2p(0,!0):"x"===v&&(A[0]=T[0]=h.c2p(0,!0)),g.attr("d",_+"L"+T+"L"+A+"Z")):g.attr("d",_+"Z")):"tonext"===e.fill.substr(0,6)&&_&&b&&("tonext"===e.fill?m.attr("d",_+"Z"+b+"Z"):m.attr("d",_+"L"+b.substr(1)+"Z")),b=w}}}),p.selectAll("path:not([d])").remove(),p.append("g").attr("class","points").each(function(t){var e=t[0].trace,r=i.select(this),n=l.hasMarkers(e),s=l.hasText(e);!n&&!s||e.visible!==!0?r.remove():(n&&r.selectAll("path.point").data(e.marker.maxdisplayed?f:a.identity).enter().append("path").classed("point",!0).call(o.translatePoints,h,d),s&&r.selectAll("g").data(e.marker.maxdisplayed?f:a.identity).enter().append("g").append("text").call(o.translatePoints,h,d))})}},{"../../components/drawing":326,"../../components/errorbars":332,"../../lib":382,"./arrays_to_calcdata":555,"./line_points":567,"./subtypes":575,d3:113}],573:[function(t,e,r){"use strict";var n=t("./subtypes"),i=.2;e.exports=function(t,e){var r,a,o,s,l=t.cd,c=t.xaxis,u=t.yaxis,f=[],h=l[0].trace,d=h.index,p=h.marker;if(n.hasMarkers(h)||n.hasText(h)){var g=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(r=0;rs;s++){for(var l=[[0,0,0],[0,0,0]],c=0;3>c;c++)if(r[c])for(var u=0;2>u;u++)l[u][c]=r[c][s][u];o[s]=l}return o}var o=t("../../components/errorbars/compute_error");e.exports=a},{"../../components/errorbars/compute_error":330}],581:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.linePlot=null,this.scatterPlot=null,this.errorBars=null,this.textMarkers=null,this.delaunayMesh=null,this.color=null,this.mode="",this.dataPoints=[],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.textLabels=null,this.data=null}function i(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],s=[];for(n=0;ni;i++){var a=t[i];a&&a.copy_zstyle!==!1&&(a=t[2]),a&&(e[i]=a.width/2,r[i]=b(a.color),n=a.thickness)}return{capSize:e,color:r,lineWidth:n}}function o(t){var e=[0,0];return Array.isArray(t)?[0,-1]:(t.indexOf("bottom")>=0&&(e[1]+=1),t.indexOf("top")>=0&&(e[1]-=1),t.indexOf("left")>=0&&(e[0]-=1),t.indexOf("right")>=0&&(e[0]+=1),e)}function s(t,e){return e(4*t)}function l(t){return k[t]}function c(t,e,r,n,i){var a=null;if(Array.isArray(t)){a=[];for(var o=0;e>o;o++)void 0===t[o]?a[o]=n:a[o]=r(t[o],i)}else a=r(t,y.identity);return a}function u(t,e){var r,n,i,u,f,h,d=[],p=t.fullSceneLayout,g=t.dataScale,v=p.xaxis,m=p.yaxis,w=p.zaxis,k=e.marker,M=e.line,T=e.x||[],E=e.y||[],L=e.z||[],S=T.length;for(n=0;S>n;n++)i=v.d2l(T[n])*g[0],u=m.d2l(E[n])*g[1],f=w.d2l(L[n])*g[2],d[n]=[i,u,f];if(Array.isArray(e.text))h=e.text;else if(void 0!==e.text)for(h=new Array(S),n=0;S>n;n++)h[n]=e.text;if(r={position:d,mode:e.mode,text:h},"line"in e&&(r.lineColor=b(M.color),r.lineWidth=M.width,r.lineDashes=M.dash),"marker"in e){var C=_(e);r.scatterColor=x(k,1,S),r.scatterSize=c(k.size,S,s,20,C),r.scatterMarker=c(k.symbol,S,l,"\u25cf"),r.scatterLineWidth=k.line.width,r.scatterLineColor=x(k.line,1,S),r.scatterAngle=0}"textposition"in e&&(r.textOffset=o(e.textposition),r.textColor=x(e.textfont,1,S),r.textSize=c(e.textfont.size,S,y.identity,12),r.textFont=e.textfont.family,r.textAngle=0);var z=["x","y","z"];for(r.project=[!1,!1,!1],r.projectScale=[1,1,1],r.projectOpacity=[1,1,1],n=0;3>n;++n){var P=e.projection[z[n]];(r.project[n]=P.show)&&(r.projectOpacity[n]=P.opacity,r.projectScale[n]=P.scale)}r.errorBounds=A(e,g);var R=a([e.error_x,e.error_y,e.error_z]);return r.errorColor=R.color,r.errorLineWidth=R.lineWidth,r.errorCapSize=R.capSize,r.delaunayAxis=e.surfaceaxis,r.delaunayColor=b(e.surfacecolor),r}function f(t){if(Array.isArray(t)){var e=t[0];return Array.isArray(e)&&(t=e),"rgb("+t.slice(0,3).map(function(t){return Math.round(255*t)})+")"}return null}function h(t,e){var r=new n(t,e.uid);return r.update(e),r}var d=t("gl-line3d"),p=t("gl-scatter3d"),g=t("gl-error3d"),v=t("gl-mesh3d"),m=t("delaunay-triangulate"),y=t("../../lib"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/make_bubble_size_func"),w=t("../../constants/gl3d_dashes"),k=t("../../constants/gl_markers"),A=t("./calc_errors"),M=n.prototype;M.handlePick=function(t){if(t.object&&(t.object===this.linePlot||t.object===this.delaunayMesh||t.object===this.textMarkers||t.object===this.scatterPlot)){t.object.highlight&&t.object.highlight(null),this.scatterPlot&&(t.object=this.scatterPlot,this.scatterPlot.highlight(t.data)),this.textLabels&&void 0!==this.textLabels[t.data.index]?t.textLabel=this.textLabels[t.data.index]:t.textLabel="";var e=t.data.index;return t.traceCoordinate=[this.data.x[e],this.data.y[e],this.data.z[e]],!0}},M.update=function(t){var e,r,n,a,o=this.scene.glplot.gl,s=w.solid;this.data=t;var l=u(this.scene,t);"mode"in l&&(this.mode=l.mode),"lineDashes"in l&&l.lineDashes in w&&(s=w[l.lineDashes]),this.color=f(l.scatterColor)||f(l.lineColor),this.dataPoints=l.position,e={gl:o,position:l.position,color:l.lineColor,lineWidth:l.lineWidth||1,dashes:s[0],dashScale:s[1],opacity:t.opacity,connectGaps:t.connectgaps},-1!==this.mode.indexOf("lines")?this.linePlot?this.linePlot.update(e):(this.linePlot=d(e),this.scene.glplot.add(this.linePlot)):this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose(),this.linePlot=null);var c=t.opacity;if(t.marker&&t.marker.opacity&&(c*=t.marker.opacity),r={gl:o,position:l.position,color:l.scatterColor,size:l.scatterSize,glyph:l.scatterMarker,opacity:c,orthographic:!0,lineWidth:l.scatterLineWidth,lineColor:l.scatterLineColor,project:l.project,projectScale:l.projectScale,projectOpacity:l.projectOpacity},-1!==this.mode.indexOf("markers")?this.scatterPlot?this.scatterPlot.update(r):(this.scatterPlot=p(r),this.scatterPlot.highlightScale=1,this.scene.glplot.add(this.scatterPlot)):this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose(),this.scatterPlot=null),a={gl:o,position:l.position,glyph:l.text,color:l.textColor,size:l.textSize,angle:l.textAngle,alignment:l.textOffset,font:l.textFont,orthographic:!0,lineWidth:0,project:!1,opacity:t.opacity},this.textLabels=l.text,-1!==this.mode.indexOf("text")?this.textMarkers?this.textMarkers.update(a):(this.textMarkers=p(a),this.textMarkers.highlightScale=1,this.scene.glplot.add(this.textMarkers)):this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose(),this.textMarkers=null),n={gl:o,position:l.position,color:l.errorColor,error:l.errorBounds,lineWidth:l.errorLineWidth,capSize:l.errorCapSize,opacity:t.opacity},this.errorBars?l.errorBounds?this.errorBars.update(n):(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose(),this.errorBars=null):l.errorBounds&&(this.errorBars=g(n),this.scene.glplot.add(this.errorBars)),l.delaunayAxis>=0){var h=i(l.position,l.delaunayColor,l.delaunayAxis);h.opacity=t.opacity,this.delaunayMesh?this.delaunayMesh.update(h):(h.gl=o,this.delaunayMesh=v(h),this.scene.glplot.add(this.delaunayMesh))}else this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose(),this.delaunayMesh=null)},M.dispose=function(){this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose()),this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose()),this.errorBars&&(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose()),this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose()),this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose())},e.exports=h},{"../../constants/gl3d_dashes":368,"../../constants/gl_markers":369,"../../lib":382,"../../lib/gl_format_color":380,"../../lib/str2rgbarray":394,"../scatter/make_bubble_size_func":569,"./calc_errors":580,"delaunay-triangulate":114,"gl-error3d":121,"gl-line3d":127,"gl-mesh3d":150,"gl-scatter3d":193}],582:[function(t,e,r){"use strict";function n(t,e,r){var n=0,i=r("x"),a=r("y"),o=r("z");return i&&a&&o&&(n=Math.min(i.length,a.length,o.length),n=0&&h("surfacecolor",p||g);for(var v=["x","y","z"],m=0;3>m;++m){var y="projection."+v[m];h(y+".show")&&(h(y+".opacity"),h(y+".scale"))}c(t,e,r,{axis:"z"}),c(t,e,r,{axis:"y",inherit:"z"}),c(t,e,r,{axis:"x",inherit:"z"})}},{"../../components/errorbars/defaults":331,"../../lib":382,"../scatter/line_defaults":566,"../scatter/marker_defaults":571,"../scatter/subtypes":575,"../scatter/text_defaults":576,"./attributes":578}],583:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../constants/gl_markers":369,"../../plots/gl3d":441,"../scatter/colorbar":559,"./attributes":578,"./calc":579,"./convert":581,"./defaults":582}],584:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../components/colorscale/color_attributes"),o=t("../../lib/extend").extendFlat,s=n.marker,l=n.line,c=s.line; +e.exports={lon:{valType:"data_array"},lat:{valType:"data_array"},locations:{valType:"data_array"},locationmode:{valType:"enumerated",values:["ISO-3","USA-states","country names"],dflt:"ISO-3"},mode:o({},n.mode,{dflt:"markers"}),text:o({},n.text,{}),line:{color:l.color,width:l.width,dash:l.dash},marker:o({},{symbol:s.symbol,opacity:s.opacity,size:s.size,sizeref:s.sizeref,sizemin:s.sizemin,sizemode:s.sizemode,showscale:s.showscale,line:o({},{width:c.width},a("marker.line"))},a("marker")),textfont:n.textfont,textposition:n.textposition,hoverinfo:o({},i.hoverinfo,{flags:["lon","lat","location","text","name"]}),_nestedModules:{"marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":311,"../../lib/extend":377,"../../plots/attributes":403,"../scatter/attributes":556}],585:[function(t,e,r){"use strict";var n=t("../scatter/marker_colorscale_calc");e.exports=function(t,e){var r=[{x:!1,y:!1,trace:e,t:{}}];return n(e),r}},{"../scatter/marker_colorscale_calc":570}],586:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=0,o=r("locations");return o?(r("locationmode"),a=o.length):(n=r("lon")||[],i=r("lat")||[],a=Math.min(n.length,i.length),an;n++)r[n]=[t.lon[n],t.lat[n]];return{type:"LineString",coordinates:r,trace:t}}function a(t,e){function r(e){var r=t.mockAxis;return c.tickText(r,r.c2l(e),"hover").text+"\xb0"}var n=e.hoverinfo;if("none"===n)return function(t){delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("location")&&Array.isArray(e.locations),o=-1!==i.indexOf("lon"),s=-1!==i.indexOf("lat"),l=-1!==i.indexOf("text");return function(t){var n=[];a?n.push(t.location):o&&s?n.push("("+r(t.lon)+", "+r(t.lat)+")"):o?n.push("lon: "+r(t.lon)):s&&n.push("lat: "+r(t.lat)),l&&n.push(t.tx||e.text),t.textLabel=n.join("
")}}function o(t){var e=Array.isArray(t.locations);return function(r,n){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:n,lon:r.lon,lat:r.lat,location:e?r.location:null}]}}}var s=t("d3"),l=t("../../plots/cartesian/graph_interact"),c=t("../../plots/cartesian/axes"),u=t("../../lib/topojson_utils").getTopojsonFeatures,f=t("../../lib/geo_location_utils").locationToFeature,h=t("../../lib/array_to_calc_item"),d=t("../../components/color"),p=t("../../components/drawing"),g=t("../scatter/subtypes"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){var r,i,a,o,s=[],l=Array.isArray(t.locations);l?(o=t.locations,r=o.length,i=u(t,e),a=function(t,e){var r=f(t.locationmode,o[e],i);return void 0!==r?r.properties.ct:void 0}):(r=t.lon.length,a=function(t,e){return[t.lon[e],t.lat[e]]});for(var c=0;r>c;c++){var h=a(t,c);if(h){var d={lon:h[0],lat:h[1],location:l?t.locations[c]:null};n(t,d,c),s.push(d)}}return s.length>0&&(s[0].trace=t),s},m.plot=function(t,e){var r=t.framework.select(".scattergeolayer").selectAll("g.trace.scattergeo").data(e,function(t){return t.uid});r.enter().append("g").attr("class","trace scattergeo"),r.exit().remove(),r.selectAll("*").remove(),r.each(function(t){var e=s.select(this);g.hasLines(t)&&e.selectAll("path.js-line").data([i(t)]).enter().append("path").classed("js-line",!0)}),r.each(function(e){function r(r,n){if(t.showHover){var i=t.projection([r.lon,r.lat]);h(r),l.loneHover({x:i[0],y:i[1],name:v?e.name:void 0,text:r.textLabel,color:r.mc||(e.marker||{}).color},{container:t.hoverContainer.node()}),y=d(r,n),t.graphDiv.emit("plotly_hover",y)}}function n(e,r){t.graphDiv.emit("plotly_click",d(e,r))}var i=s.select(this),c=g.hasMarkers(e),u=g.hasText(e);if(c||u){var f=m.calcGeoJSON(e,t.topojson),h=a(t,e),d=o(e),p=e.hoverinfo,v="all"===p||-1!==p.indexOf("name"),y=null;c&&i.selectAll("path.point").data(f).enter().append("path").classed("point",!0).on("mouseover",r).on("click",n).on("mouseout",function(){l.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",y)}).on("mousedown",function(){l.loneUnhover(t.hoverContainer)}).on("mouseup",r),u&&i.selectAll("g").data(f).enter().append("g").append("text")}}),m.style(t)},m.style=function(t){var e=t.framework.selectAll("g.trace.scattergeo");e.style("opacity",function(t){return t.opacity}),e.each(function(t){s.select(this).selectAll("path.point").call(p.pointStyle,t),s.select(this).selectAll("text").call(p.textPointStyle,t)}),e.selectAll("path.js-line").style("fill","none").each(function(t){var e=t.trace,r=e.line||{};s.select(this).call(d.stroke,r.color).call(p.dashLine,r.dash||"",r.width||0)})}},{"../../components/color":303,"../../components/drawing":326,"../../lib/array_to_calc_item":373,"../../lib/geo_location_utils":379,"../../lib/topojson_utils":396,"../../plots/cartesian/axes":405,"../../plots/cartesian/graph_interact":412,"../scatter/subtypes":575,"./attributes":584,d3:113}],589:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/colorscale/color_attributes"),a=t("../../constants/gl2d_dashes"),o=t("../../constants/gl_markers"),s=t("../../lib/extend").extendFlat,l=t("../../lib/extend").extendDeep,c=n.line,u=n.marker,f=u.line;e.exports={x:n.x,x0:n.x0,dx:n.dx,y:n.y,y0:n.y0,dy:n.dy,text:s({},n.text,{}),mode:{valType:"flaglist",flags:["lines","markers"],extras:["none"]},line:{color:c.color,width:c.width,dash:{valType:"enumerated",values:Object.keys(a),dflt:"solid"}},marker:l({},i("marker"),{symbol:{valType:"enumerated",values:Object.keys(o),dflt:"circle",arrayOk:!0},size:u.size,sizeref:u.sizeref,sizemin:u.sizemin,sizemode:u.sizemode,opacity:u.opacity,showscale:u.showscale,line:l({},i("marker.line"),{width:f.width})}),connectgaps:n.connectgaps,fill:s({},n.fill,{values:["none","tozeroy","tozerox"]}),fillcolor:n.fillcolor,_nestedModules:{error_x:"ErrorBars",error_y:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":311,"../../constants/gl2d_dashes":367,"../../constants/gl_markers":369,"../../lib/extend":377,"../scatter/attributes":556}],590:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.pickXData=[],this.pickYData=[],this.xData=[],this.yData=[],this.textLabels=[],this.color="rgb(0, 0, 0)",this.name="",this.hoverinfo="all",this.connectgaps=!0,this.idToIndex=[],this.bounds=[0,0,0,0],this.hasLines=!1,this.lineOptions={positions:new Float32Array(0),color:[0,0,0,1],width:1,fill:[!1,!1,!1,!1],fillColor:[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],dashes:[1]},this.line=d(t.glplot,this.lineOptions),this.line._trace=this,this.hasErrorX=!1,this.errorXOptions={positions:new Float32Array(0),errors:new Float32Array(0),lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorX=p(t.glplot,this.errorXOptions),this.errorX._trace=this,this.hasErrorY=!1,this.errorYOptions={positions:new Float32Array(0),errors:new Float32Array(0),lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorY=p(t.glplot,this.errorYOptions),this.errorY._trace=this,this.hasMarkers=!1,this.scatterOptions={positions:new Float32Array(0),sizes:[],colors:[],glyphs:[],borderWidths:[],borderColors:[],size:12,color:[0,0,0,1],borderSize:1,borderColor:[0,0,0,1]},this.scatter=f(t.glplot,this.scatterOptions),this.scatter._trace=this,this.fancyScatter=h(t.glplot,this.scatterOptions),this.fancyScatter._trace=this}function i(t,e,r){return Array.isArray(e)||(e=[e]),a(t,e,r)}function a(t,e,r){for(var n=new Array(r),i=e[0],a=0;r>a;++a)n[a]=t(a>=e.length?i:e[a]);return n}function o(t,e,r){return l(S(t,r),L(e,r),r)}function s(t,e,r,n){var i=x(t,e,n);return i=Array.isArray(i[0])?i:a(v.identity,[i],n),l(i,L(r,n),n)}function l(t,e,r){for(var n=new Array(4*r),i=0;r>i;++i){for(var a=0;3>a;++a)n[4*i+a]=t[i][a];n[4*i+3]=t[i][3]*e[i]}return n}function c(t,e){if(void 0===Float32Array.slice){for(var r=new Float32Array(e),n=0;e>n;n++)r[n]=t[n];return r}return t.slice(0,e)}function u(t,e){var r=new n(t,e.uid);return r.update(e),r}var f=t("gl-scatter2d"),h=t("gl-scatter2d-fancy"),d=t("gl-line2d"),p=t("gl-error2d"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../plots/cartesian/axes"),y=t("../../components/errorbars"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/subtypes"),w=t("../scatter/make_bubble_size_func"),k=t("../scatter/get_trace_color"),A=t("../../constants/gl_markers"),M=t("../../constants/gl2d_dashes"),T=["xaxis","yaxis"],E=n.prototype;E.handlePick=function(t){var e=t.pointId;return(t.object!==this.line||this.connectgaps)&&(e=this.idToIndex[t.pointId]),{trace:this,dataCoord:t.dataCoord,traceCoord:[this.pickXData[e],this.pickYData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:Array.isArray(this.color)?this.color[e]:this.color,name:this.name,hoverinfo:this.hoverinfo}},E.isFancy=function(t){if("linear"!==this.scene.xaxis.type)return!0;if("linear"!==this.scene.yaxis.type)return!0;if(!t.x||!t.y)return!0;if(this.hasMarkers){var e=t.marker||{};if(Array.isArray(e.symbol)||"circle"!==e.symbol||Array.isArray(e.size)||Array.isArray(e.color)||Array.isArray(e.line.width)||Array.isArray(e.line.color)||Array.isArray(e.opacity))return!0}return this.hasLines&&!this.connectgaps?!0:this.hasErrorX?!0:!!this.hasErrorY};var L=i.bind(null,function(t){return+t}),S=i.bind(null,b),C=i.bind(null,function(t){return A[t]||"\u25cf"});E.update=function(t){t.visible!==!0?(this.hasLines=!1,this.hasErrorX=!1,this.hasErrorY=!1,this.hasMarkers=!1):(this.hasLines=_.hasLines(t),this.hasErrorX=t.error_x.visible===!0,this.hasErrorY=t.error_y.visible===!0,this.hasMarkers=_.hasMarkers(t)),this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.connectgaps=!!t.connectgaps,this.isFancy(t)?this.updateFancy(t):this.updateFast(t),this.color=k(t,{})},E.updateFast=function(t){for(var e,r,n=this.xData=this.pickXData=t.x,i=this.yData=this.pickYData=t.y,a=n.length,o=new Array(a),s=new Float32Array(2*a),l=this.bounds,u=0,f=0,h=0;a>h;++h)e=n[h],r=i[h],g(e)&&g(r)&&(o[u++]=h,s[f++]=e,s[f++]=r,l[0]=Math.min(l[0],e),l[1]=Math.min(l[1],r),l[2]=Math.max(l[2],e),l[3]=Math.max(l[3],r));s=c(s,f),this.idToIndex=o,this.updateLines(t,s),this.updateError("X",t),this.updateError("Y",t);var d;if(this.hasMarkers){this.scatterOptions.positions=s;var p=b(t.marker.color),v=b(t.marker.line.color),m=t.opacity*t.marker.opacity;p[3]*=m,this.scatterOptions.color=p,v[3]*=m,this.scatterOptions.borderColor=v,d=t.marker.size,this.scatterOptions.size=d,this.scatterOptions.borderSize=t.marker.line.width,this.scatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions),this.expandAxesFast(l,d)},E.updateFancy=function(t){var e=this.scene,r=e.xaxis,n=e.yaxis,a=this.bounds,o=this.pickXData=r.makeCalcdata(t,"x").slice(),l=this.pickYData=n.makeCalcdata(t,"y").slice();this.xData=o.slice(),this.yData=l.slice();var u,f,h,d,p,g,v,m,b=y.calcFromTrace(t,e.fullLayout),x=o.length,_=new Array(x),k=new Float32Array(2*x),A=new Float32Array(4*x),M=new Float32Array(4*x),T=0,E=0,S=0,z=0,P="log"===r.type?function(t){return r.d2l(t)}:function(t){return t},R="log"===n.type?function(t){return n.d2l(t)}:function(t){return t};for(u=0;x>u;++u)this.xData[u]=h=P(o[u]),this.yData[u]=d=R(l[u]),isNaN(h)||isNaN(d)||(_[T++]=u,k[E++]=h,k[E++]=d,p=A[S++]=h-b[u].xs||0,g=A[S++]=b[u].xh-h||0,A[S++]=0,A[S++]=0,M[z++]=0,M[z++]=0,v=M[z++]=d-b[u].ys||0,m=M[z++]=b[u].yh-d||0,a[0]=Math.min(a[0],h-p),a[1]=Math.min(a[1],d-v),a[2]=Math.max(a[2],h+g),a[3]=Math.max(a[3],d+m));k=c(k,E),this.idToIndex=_,this.updateLines(t,k),this.updateError("X",t,k,A),this.updateError("Y",t,k,M);var O;if(this.hasMarkers){this.scatterOptions.positions=k,this.scatterOptions.sizes=new Array(T),this.scatterOptions.glyphs=new Array(T),this.scatterOptions.borderWidths=new Array(T),this.scatterOptions.colors=new Array(4*T),this.scatterOptions.borderColors=new Array(4*T);var I,N=w(t),j=t.marker,F=j.opacity,D=t.opacity,B=s(j,F,D,x),U=C(j.symbol,x),V=L(j.line.width,x),q=s(j.line,F,D,x);for(O=i(N,j.size,x),u=0;T>u;++u)for(I=_[u],this.scatterOptions.sizes[u]=4*O[I],this.scatterOptions.glyphs[u]=U[I],this.scatterOptions.borderWidths[u]=.5*V[I],f=0;4>f;++f)this.scatterOptions.colors[4*u+f]=B[4*I+f],this.scatterOptions.borderColors[4*u+f]=q[4*I+f];this.fancyScatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions),this.expandAxesFancy(o,l,O)},E.updateLines=function(t,e){var r;if(this.hasLines){var n=e;if(!t.connectgaps){var i=0,a=this.xData,s=this.yData;for(n=new Float32Array(2*a.length),r=0;ro;o++)r=this.scene[T[o]],n=r._min,n||(n=[]),n.push({val:t[o],pad:a}),i=r._max,i||(i=[]),i.push({val:t[o+2],pad:a})},E.expandAxesFancy=function(t,e,r){var n=this.scene,i={padded:!0,ppad:r};m.expand(n.xaxis,t,i),m.expand(n.yaxis,e,i)},E.dispose=function(){this.line.dispose(),this.errorX.dispose(),this.errorY.dispose(),this.scatter.dispose(),this.fancyScatter.dispose()},e.exports=u},{"../../components/errorbars":332,"../../constants/gl2d_dashes":367,"../../constants/gl_markers":369,"../../lib":382,"../../lib/gl_format_color":380,"../../lib/str2rgbarray":394,"../../plots/cartesian/axes":405,"../scatter/get_trace_color":563,"../scatter/make_bubble_size_func":569,"../scatter/subtypes":575,"fast-isnumeric":117,"gl-error2d":119,"gl-line2d":125,"gl-scatter2d":190,"gl-scatter2d-fancy":185}],591:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/xy_defaults"),s=t("../scatter/marker_defaults"),l=t("../scatter/line_defaults"),c=t("../scatter/fillcolor_defaults"),u=t("../../components/errorbars/defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p=o(t,e,d);return p?(d("text"),d("mode",pr;r++)y=e.a[r],b=e.b[r],x=e.c[r],n(y)&&n(b)&&n(x)?(y=+y,b=+b,x=+x,_=v/(y+b+x),1!==_&&(y*=_,b*=_,x*=_),k=y,w=x-b,M[r]={x:w,y:k,a:y,b:b,c:x}):M[r]={x:!1,y:!1};var T,E;if(o.hasMarkers(e)&&(T=e.marker,E=T.size,Array.isArray(E))){var L={type:"linear"};i.setConvert(L),E=L.makeCalcdata(e.marker,"size"),E.length>A&&E.splice(A,E.length-A)}return s(e),void 0!==typeof E&&a.mergeArray(E,M,"ms"),M}},{"../../lib":382,"../../plots/cartesian/axes":405,"../scatter/marker_colorscale_calc":570,"../scatter/subtypes":575,"fast-isnumeric":117}],595:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/marker_defaults"),s=t("../scatter/line_defaults"),l=t("../scatter/line_shape_defaults"),c=t("../scatter/text_defaults"),u=t("../scatter/fillcolor_defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p,g=d("a"),v=d("b"),m=d("c");if(g?(p=g.length,v?(p=Math.min(p,v.length),m&&(p=Math.min(p,m.length))):p=m?Math.min(p,m.length):0):v&&m&&(p=Math.min(v.length,m.length)),!p)return void(e.visible=!1);g&&p"),s}}},{"../../plots/cartesian/axes":405,"../scatter/hover":564}],597:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../plots/ternary":461,"../scatter/colorbar":559,"./attributes":593,"./calc":594,"./defaults":595,"./hover":596,"./plot":598,"./select":599,"./style":600}],598:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e){var r=t.plotContainer;r.select(".scatterlayer").selectAll("*").remove();for(var i={x:function(){return t.xaxis},y:function(){return t.yaxis},plot:r},a=new Array(e.length),o=t.graphDiv.calcdata,s=0;se){for(var r=g/e,n=[0|Math.floor(t[0].shape[0]*r+1),0|Math.floor(t[0].shape[1]*r+1)],i=n[0]*n[1],o=0;or;++r)this.showContour[r]&&(e=!0,t[r]=this.scene.contourLevels[r]);e&&this.surface.update({levels:t})},v.update=function(t){var e,r=this.scene,n=r.fullSceneLayout,a=this.surface,s=t.opacity,l=i(t.colorscale,s),u=t.z,h=t.x,d=t.y,g=n.xaxis,v=n.yaxis,m=n.zaxis,y=r.dataScale,b=u[0].length,x=u.length,_=[c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x])],w=_[0],k=_[1],A=r.contourLevels;this.data=t,f(_[2],function(t,e){return m.d2l(u[e][t])*y[2]}),Array.isArray(h[0])?f(w,function(t,e){return g.d2l(h[e][t])*y[0]}):f(w,function(t){return g.d2l(h[t])*y[0]}),Array.isArray(d[0])?f(k,function(t,e){return v.d2l(d[e][t])*y[1]}):f(k,function(t,e){return v.d2l(d[e])*y[1]});var M={colormap:l,levels:[[],[],[]],showContour:[!0,!0,!0],showSurface:!t.hidesurface,contourProject:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],contourWidth:[1,1,1],contourColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],contourTint:[1,1,1],dynamicColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],dynamicWidth:[1,1,1],dynamicTint:[1,1,1],opacity:1};if(M.intensityBounds=[t.cmin,t.cmax],t.surfacecolor){var T=c(new Float32Array(b*x),[b,x]);f(T,function(e,r){return t.surfacecolor[r][e]}),_.push(T)}else M.intensityBounds[0]*=y[2],M.intensityBounds[1]*=y[2];this.dataScale=o(_),t.surfacecolor&&(M.intensity=_.pop()),"opacity"in t&&t.opacity<1&&(M.opacity=.25*t.opacity);var E=[!0,!0,!0],L=["x","y","z"];for(e=0;3>e;++e){var S=t.contours[L[e]];E[e]=S.highlight,M.showContour[e]=S.show||S.highlight,M.showContour[e]&&(M.contourProject[e]=[S.project.x,S.project.y,S.project.z],S.show?(this.showContour[e]=!0,M.levels[e]=A[e],a.highlightColor[e]=M.contourColor[e]=p(S.color),S.usecolormap?a.highlightTint[e]=M.contourTint[e]=0:a.highlightTint[e]=M.contourTint[e]=1,M.contourWidth[e]=S.width):this.showContour[e]=!1,S.highlight&&(M.dynamicColor[e]=p(S.highlightcolor),M.dynamicWidth[e]=S.highlightwidth))}M.coords=_,a.update(M),a.visible=t.visible,a.enableDynamic=E,a.snapToData=!0,"lighting"in t&&(a.ambientLight=t.lighting.ambient,a.diffuseLight=t.lighting.diffuse,a.specularLight=t.lighting.specular,a.roughness=t.lighting.roughness,a.fresnel=t.lighting.fresnel),"lightposition"in t&&(a.lightPosition=[t.lightposition.x,t.lightposition.y,t.lightposition.z]),s&&1>s&&(a.supportsTransparency=!0)},v.dispose=function(){this.scene.glplot.remove(this.surface),this.surface.dispose()},e.exports=s},{"../../lib/str2rgbarray":394,"gl-surface3d":221,ndarray:253,"ndarray-fill":246,"ndarray-homography":251,"ndarray-ops":252,tinycolor2:274}],605:[function(t,e,r){"use strict";function n(t,e,r){e in t&&!(r in t)&&(t[r]=t[e])}var i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}var c,u,f=l("z");if(!f)return void(e.visible=!1);var h=f[0].length,d=f.length;if(l("x"),l("y"),!Array.isArray(e.x))for(e.x=[],c=0;h>c;++c)e.x[c]=c;if(l("text"),!Array.isArray(e.y))for(e.y=[],c=0;d>c;++c)e.y[c]=c;["lighting.ambient","lighting.diffuse","lighting.specular","lighting.roughness","lighting.fresnel","lightposition.x","lightposition.y","lightposition.z","hidesurface","opacity"].forEach(function(t){l(t)});var p=l("surfacecolor");l("colorscale");var g=["x","y","z"];for(c=0;3>c;++c){var v="contours."+g[c],m=l(v+".show"),y=l(v+".highlight");if(m||y)for(u=0;3>u;++u)l(v+".project."+g[u]);m&&(l(v+".color"),l(v+".width"),l(v+".usecolormap")),y&&(l(v+".highlightcolor"),l(v+".highlightwidth"))}p||(n(t,"zmin","cmin"),n(t,"zmax","cmax"),n(t,"zauto","cauto")),a(t,e,s,l,{prefix:"",cLetter:"c"})}},{"../../components/colorscale/defaults":313,"../../lib":382,"./attributes":601}],606:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("./colorbar"),n.calc=t("./calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="surface",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","noOpacity"],n.meta={},e.exports=n},{"../../plots/gl3d":441,"./attributes":601,"./calc":602,"./colorbar":603,"./convert":604,"./defaults":605}]},{},[12])(12)}); \ No newline at end of file diff --git a/inst/plotlyjs.R b/inst/plotlyjs.R index 6f9d4adb45..01145f6f36 100644 --- a/inst/plotlyjs.R +++ b/inst/plotlyjs.R @@ -36,12 +36,8 @@ update_attributes <- function(path = ".") { remDr$open(silent = TRUE) htmlwidgets::saveWidget(plotly::plot_ly(), "index.html") remDr$navigate(file.path(getwd(), "index.html")) - traces <- remDr$executeScript("return Plotly.PlotSchema.get().traces") - devtools::use_data(traces, overwrite = TRUE, internal = TRUE) + Schema <- remDr$executeScript("return Plotly.PlotSchema.get()") + devtools::use_data(Schema, overwrite = TRUE, internal = TRUE) } - update_attributes() - - - diff --git a/man/add_chull.Rd b/man/add_chull.Rd deleted file mode 100644 index 2aed49d33c..0000000000 --- a/man/add_chull.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add.R -\name{add_chull} -\alias{add_chull} -\usage{ -add_chull(p, ...) -} -\examples{ - -x <- rnorm(10) -plot_ly(x = ~x) \%>\% - add_chull() -} - diff --git a/man/add_lines.Rd b/man/add_lines.Rd new file mode 100644 index 0000000000..297ddeb890 --- /dev/null +++ b/man/add_lines.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add.R +\name{add_lines} +\alias{add_lines} +\title{Add lines to a plotly vis} +\usage{ +add_lines(p, ...) +} +\description{ +Add lines to a plotly vis +} + diff --git a/man/add_points.Rd b/man/add_points.Rd new file mode 100644 index 0000000000..95881b810d --- /dev/null +++ b/man/add_points.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add.R +\name{add_points} +\alias{add_points} +\title{Add points to a plotly vis} +\usage{ +add_points(p, ...) +} +\description{ +Add points to a plotly vis +} + diff --git a/man/add_polygons.Rd b/man/add_polygons.Rd index 11c2df88be..1fd7019747 100644 --- a/man/add_polygons.Rd +++ b/man/add_polygons.Rd @@ -2,9 +2,13 @@ % Please edit documentation in R/add.R \name{add_polygons} \alias{add_polygons} +\title{Add polygons to a plotly vis} \usage{ add_polygons(p, ...) } +\description{ +Add polygons to a plotly vis +} \examples{ library(dplyr) diff --git a/man/add_ribbons.Rd b/man/add_ribbons.Rd new file mode 100644 index 0000000000..32f5084b57 --- /dev/null +++ b/man/add_ribbons.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add.R +\name{add_ribbons} +\alias{add_ribbons} +\title{Add ribbons to a plotly vis} +\usage{ +add_ribbons(p, ...) +} +\description{ +Ribbons are a special case of polygons. +} + diff --git a/man/add_text.Rd b/man/add_text.Rd new file mode 100644 index 0000000000..71c4f3e142 --- /dev/null +++ b/man/add_text.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add.R +\name{add_text} +\alias{add_text} +\title{Add text to a plotly vis} +\usage{ +add_text(p, ...) +} +\description{ +Add text to a plotly vis +} + diff --git a/man/add_trace.Rd b/man/add_trace.Rd index ec99bd8529..09e7296dc5 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -5,7 +5,7 @@ \title{Add a trace to a plotly visualization} \usage{ add_trace(p, ..., color, colors = NULL, symbol, symbols = NULL, size, - data = NULL) + linetype, linetypes = NULL, data = NULL) } \arguments{ \item{p}{a plotly or ggplot object.} diff --git a/man/explain_attrs.Rd b/man/explain_attrs.Rd index af8bd62185..f9462c0396 100644 --- a/man/explain_attrs.Rd +++ b/man/explain_attrs.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helpers.R +% Please edit documentation in R/debug.R \name{explain_attrs} \alias{explain_attrs} \title{Show information about attribute(s) of a given trace type} diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index 0fb5e7f4de..7eb47b2835 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -5,8 +5,8 @@ \title{Initiate a plotly visualization} \usage{ plot_ly(data = data.frame(), ..., type = NULL, color, colors = NULL, - symbol, symbols = NULL, size, width = NULL, height = NULL, - source = "A") + symbol, symbols = NULL, size, linetype, linetypes = NULL, width = NULL, + height = NULL, source = "A") } \arguments{ \item{data}{A data frame (optional).} @@ -24,11 +24,14 @@ or a color interpolation function like \code{colorRamp()}.} \item{symbol}{Either a variable name or a (discrete) vector to use for symbol encoding.} -\item{symbols}{A character vector of symbol types. Possible values: -'dot', 'cross', 'diamond', 'square', 'triangle-down', 'triangle-left', 'triangle-right', 'triangle-up'} +\item{symbols}{A character vector of symbol types. For possible values, see \link{schema}.} \item{size}{A variable name or numeric vector to encode the size of markers.} +\item{linetype}{Either a variable name or a (discrete) vector to use for linetype encoding.} + +\item{linetypes}{A character vector of line types. For possible values, see \link{schema}.} + \item{width}{Width in pixels (optional, defaults to automatic sizing).} \item{height}{Height in pixels (optional, defaults to automatic sizing).} @@ -57,6 +60,7 @@ layout(p3, font = list(family = "Courier New, monospace")) # using the color argument plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, mode = "markers") +# smooth gradient between 5 colors plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, colors = terrain.colors(5), mode = "markers") @@ -66,6 +70,8 @@ decade <- function(x) { } plot_ly(economics, x = ~unemploy / pop, color = ~decade(date), type = "box") +plot_ly(economics, x = ~date, y = ~unemploy / pop, linetype = ~decade(date)) + # sometimes, a data frame isn't fit for the use case... # for 3D surface plots, a numeric matrix is more natural plot_ly(z = volcano, type = "surface") diff --git a/man/plotly_empty.Rd b/man/plotly_empty.Rd index 481a37677d..bdfbc56830 100644 --- a/man/plotly_empty.Rd +++ b/man/plotly_empty.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helpers.R +% Please edit documentation in R/plotly.R \name{plotly_empty} \alias{plotly_empty} \title{Create a complete empty plotly graph.} diff --git a/man/plotly_json.Rd b/man/plotly_json.Rd new file mode 100644 index 0000000000..babe997b00 --- /dev/null +++ b/man/plotly_json.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dev.R +\name{plotly_json} +\alias{plotly_json} +\title{Inspect JSON sent to plotly.js} +\usage{ +plotly_json(p = plot_ly(), jsonedit = interactive(), ...) +} +\arguments{ +\item{p}{a plotly or ggplot object.} + +\item{jsonedit}{use \code{listviewer::jsonedit} to view the JSON?} + +\item{...}{other options passed onto \code{listviewer::jsonedit}} +} +\description{ +This function is useful for obtaining/viewing/debugging JSON +sent to plotly.js. +} +\examples{ + +plotly_json(plot_ly()) +plotly_json(plot_ly(), F) +} + diff --git a/man/plotly_spec.Rd b/man/plotly_spec.Rd index 944f46ba7b..21775de2ef 100644 --- a/man/plotly_spec.Rd +++ b/man/plotly_spec.Rd @@ -1,20 +1,15 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helpers.R +% Please edit documentation in R/debug.R \name{plotly_spec} \alias{plotly_spec} \title{Obtain JSON sent to plotly.js} \usage{ -plotly_spec(p = plot_ly(), attr = NULL, as = c("json", "plain"), - pretty = TRUE) +plotly_spec(p = plot_ly(), ...) } \arguments{ \item{p}{a plotly or ggplot object.} -\item{attr}{focus on a particular attribute in the spec.} - -\item{as}{in what format should the spec be printed?} - -\item{pretty}{adds indentation whitespace to JSON output.} +\item{...}{other options passed onto \code{listviewer::jsonedit}} } \description{ This function returns the JSON sent to plotly.js which can be useful for @@ -22,6 +17,6 @@ debugging. } \examples{ -plotly_spec(plot_ly(), "data") +plotly_spec(plot_ly()) } diff --git a/man/schema.Rd b/man/schema.Rd new file mode 100644 index 0000000000..f5d8cbc578 --- /dev/null +++ b/man/schema.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/debug.R, R/dev.R +\name{schema} +\alias{schema} +\title{Display plot schema} +\usage{ +schema() + +schema() +} +\description{ +Display plot schema + +The schema contains valid attributes names, their value type, +default values (if any), and min/max values (if applicable). +} +\examples{ + +schema() +schema() +} + diff --git a/man/toWebGL.Rd b/man/toWebGL.Rd index 082fb79e09..901504b427 100644 --- a/man/toWebGL.Rd +++ b/man/toWebGL.Rd @@ -13,7 +13,7 @@ toWebGL(p, warn = TRUE) a WebGL equivalent?} } \description{ -This function will also build +Convert trace types to WebGL } \examples{ From 3a9ae7a075572bbb150f18a451cdf14580e63c67 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 15 Jun 2016 15:32:11 -0500 Subject: [PATCH 16/73] fix trace layering logic; avoid hard-coding data_array boxing logic --- NEWS | 4 +- R/add.R | 44 +++++++----- R/ggplotly.R | 2 +- R/helpers.R | 23 +++++++ R/plotly.R | 11 ++- R/plotly_build.R | 30 ++++++--- R/process.R | 3 +- R/utils.R | 157 +++++++++++++++++++++---------------------- man/add_trace.Rd | 20 +++++- man/hide_colorbar.Rd | 15 +++++ 10 files changed, 191 insertions(+), 118 deletions(-) create mode 100644 man/hide_colorbar.Rd diff --git a/NEWS b/NEWS index 252cb8a5e1..fdce699e8f 100644 --- a/NEWS +++ b/NEWS @@ -3,8 +3,8 @@ MAJOR CHANGES & IMPROVEMENTS: * Formulas (instead of plain expressions) are now required when referring to variable names. For example, `plot_ly(mtcars, x = wt, y = mpg, color = vs)` should now be `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~vs)`. This is a major breaking change, but it is necessary to ensure that evaluation is correct in all contexts (as a result, `evaluate` argument is now deprecated). It also has the benefit of being easier to program with (i.e., writing your own custom functions that wrap `plot_ly()`). For more details, see the [lazyeval vignette](https://github.com/hadley/lazyeval/blob/master/vignettes/lazyeval.Rmd) -* The central object (i.e., the return value and first argument to functions) is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, plotly objects can now be serialized across R sessions and avoid [memory leak issues](https://github.com/rstudio/shiny/issues/1151). This also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `help("plotly-data")` for more details). -* The `group` argument is deprecated. Groups should be added to the data via `dplyr::group_by()`. Also, groupings will no longer create multiple traces (fixes #418, #381, #577). +* The data structure used to represent plotly objects is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, plotly objects can now be serialized across R sessions and avoid [memory leak issues](https://github.com/rstudio/shiny/issues/1151). This also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `help("plotly-data")` for more details). +* The `group` argument is deprecated. Groups should be added to the data via `dplyr::group_by()` (see `help("plotly-data")` for examples). Also, groupings will no longer create multiple traces (fixes #418, #381, #577). * The `inherit` argument is deprecated. Any arguments/attributes specified in `plot_ly()` will automatically be passed along to additional traces added via `add_trace()` (or any of it's `add_*()` siblings). Traces created via `add_trace()` (or, more generally, by any `add_*()` function), will inherit _required_ attributes from parent traces. diff --git a/R/add.R b/R/add.R index cb0f230440..398932cc8c 100644 --- a/R/add.R +++ b/R/add.R @@ -19,7 +19,7 @@ add_data <- function(p, data = NULL) { p } -#' Add a trace to a plotly visualization +#' Add trace(s) to a plotly visualization #' #' @param p a plotly or ggplot object. #' @param ... These arguments are documented in the references section below. @@ -32,6 +32,8 @@ add_data <- function(p, data = NULL) { #' @param symbols A character vector of symbol types. Possible values: #' 'dot', 'cross', 'diamond', 'square', 'triangle-down', 'triangle-left', 'triangle-right', 'triangle-up' #' @param size A variable name or numeric vector to encode the size of markers. +#' @param linetype Either a variable name or a (discrete) vector to use for linetype encoding. +#' @param linetypes A character vector of line types. For possible values, see \link{schema}. #' @param data A data frame to associate with this trace (optional). If not #' provided, arguments are evaluated using the data frame in \code{\link{plot_ly}()}. #' @seealso \code{\link{plot_ly}()} @@ -41,6 +43,18 @@ add_data <- function(p, data = NULL) { #' @examples #' #' p <- plot_ly(economics, x = ~date, y = ~uempmed) +#' p +#' p %>% add_points() +#' p %>% add_lines() +#' p %>% add_text(text = ".") +#' +#' # attributes declared in plot_ly() carry over to downstream traces +#' plot_ly(economics, x = ~date, y = ~uempmed) %>% +#' add_points(color = ~pop) %>% +#' add_lines(line = list(color = "red")) +#' +#' +#' #' # add a loess smoother #' p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) #' @@ -48,28 +62,27 @@ add_trace <- function(p, ..., color, colors = NULL, symbol, symbols = NULL, size, linetype, linetypes = NULL, data = NULL) { # "native" plotly arguments - argz <- list(...) + attrs <- list(...) + + # tack on "special" arguments + attrs$color <- verify_arg(color) + attrs$symbol <- verify_arg(symbol) + attrs$size <- verify_arg(size) - argz$type <- verify_type(argz$type %||% p$x$attrs[[1]]$type) + attrs$colors <- colors + attrs$symbols <- symbols - if (!is.null(argz[["group"]])) { + if (!is.null(attrs[["group"]])) { warning("The group argument has been deprecated. Use group_by() instead.") } - # tack on "special" arguments - argz$color <- verify_arg(color) - argz$symbol <- verify_arg(symbol) - argz$size <- verify_arg(size) - - argz$colors <- colors - argz$colors <- symbols - p <- add_data(p, data) - # inherit arguments from the "first layer" - new_attrs <- modifyList(p$x$attrs[[1]] %||% list(), argz) + # inherit attributes from the "first layer" + new_attrs <- modifyList(p$x$attrs[[1]] %||% list(), attrs) + p$x$attrs <- c( - p$x$attrs %||% list(), + p$x$attrs %||% list(), setNames(list(new_attrs), p$x$cur_data) ) @@ -94,6 +107,7 @@ add_lines <- function(p, ...) { #' #' @export add_text <- function(p, ...) { + # TODO: throw error if no text attribute is found add_trace(p, type = "scatter", mode = "text", ...) } diff --git a/R/ggplotly.R b/R/ggplotly.R index c4a2050cda..804c47eae5 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -700,7 +700,7 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A source = source ) # ensure properties are boxed correctly - add_boxed(rm_asis(l)) + rm_asis(l) } diff --git a/R/helpers.R b/R/helpers.R index 5850d53d60..3b35ed14ca 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -1,3 +1,26 @@ +#' Hide a color bar +#' +#' @param p a plotly object. +#' @export +#' +#' plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop) %>% +#' add_points() %>% +#' hide_colorbar() +hide_colorbar <- function(p) { + idx <- vapply(p$x$data, is.colorbar, logical(1)) + browser() + for (i in which(idx)) { + p$x$data[[i]]$marker$colorbar$showscale <- FALSE + } + p +} + +hide_legend <- function(p) { + layout(p, showlegend = FALSE) +} + + + #' Convert trace types to WebGL #' #' @param p a plotly or ggplot object. diff --git a/R/plotly.R b/R/plotly.R index 2335182aef..d8b21abc11 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -8,7 +8,8 @@ #' @param data A data frame (optional). #' @param ... These arguments are documented at \url{https://plot.ly/r/reference/} #' Note that acceptable arguments depend on the value of \code{type}. -#' @param type A character string describing the type of trace. +#' @param type A character string describing the type of trace. If \code{NULL} +#' (the default), the initial trace type is determined by \code{add_trace} #' @param color Either a variable name or a vector to use for color mapping. #' @param colors Either a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"), #' or a vector of colors to interpolate in hexadecimal "#RRGGBB" format, @@ -66,11 +67,14 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, # warn about old arguments that are no longer supported for (i in c("filename", "fileopt", "world_readable")) { if (is.null(attrs[[i]])) next - warning("Ignoring ", i, ". Use plotly_POST() if you want to post figures to plotly.") + warning("Ignoring ", i, ". Use `plotly_POST()` if you want to post figures to plotly.") attrs[[i]] <- NULL } if (!is.null(attrs[["group"]])) { - warning("The group argument has been deprecated. Use group_by() instead.") + warning( + "The group argument has been deprecated. Use `group_by()` instead.\n", + "See `help('plotly-data')` for examples" + ) attrs[["group"]] <- NULL } if (!is.null(attrs[["inherit"]])) { @@ -87,6 +91,7 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, attrs$colors <- colors attrs$symbols <- symbols attrs$linetypes <- linetypes + attrs$type <- type # id for tracking attribute mappings and finding the most current data id <- new_id() diff --git a/R/plotly_build.R b/R/plotly_build.R index 18cedcaa1d..c754a1a389 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -48,8 +48,16 @@ plotly_build.plotly <- function(p) { p$x$layoutAttrs <- NULL p$x$layout <- modifyList(p$x$layout %||% list(), Reduce(modifyList, layouts) %||% list()) + # If type was not specified in plot_ly(), it doesn't create a trace unless + # there are no other traces + if (length(p$x$attrs) > 1 && is.null(p$x$attrs[[1]][["type"]])) { + p$x$attrs[[1]] <- NULL + } + dats <- Map(function(x, y) { + x$type <- verify_type(x$type) + is_formula <- vapply(x, is.formula, logical(1)) fl <- lazyeval::as_f_list(x[is_formula] %||% list()) d <- plotly_data(p, y) @@ -72,8 +80,6 @@ plotly_build.plotly <- function(p) { } } - x$type <- verify_type(x$type) - x[lengths(x) > 0] }, p$x$attrs, names(p$x$attrs)) @@ -126,7 +132,8 @@ plotly_build.plotly <- function(p) { # verify plot attributes are legal according to the plotly.js spec # (and box attributes data_array attributes where appropriate) - verify_plot(p) + verify_attr_names(p) + verify_boxed(p) } # appends a new (empty) trace to generate (plot-wide) colorbar/colorscale @@ -137,6 +144,10 @@ mapColor <- function(traces, title = "", na.color = "transparent") { if (all(nColors == 0)) { return(traces) } + isNumeric <- vapply(color, is.numeric, logical(1)) + isDiscrete <- vapply(color, is.discrete, logical(1)) + colors <- lapply(traces, "[[", "colors") + # color/colorscale/colorbar attribute placement depends on trace type and marker mode types <- vapply(traces, function(tr) tr$type, character(1)) modes <- vapply(traces, function(tr) { @@ -148,9 +159,6 @@ mapColor <- function(traces, title = "", na.color = "transparent") { hasZ <- !grepl("scatter", types) & any(vapply(traces, function(tr) !is.null(tr$z), logical(1))) - isNumeric <- vapply(color, is.numeric, logical(1)) - colors <- lapply(traces, "[[", "colors") - if (any(isNumeric)) { palette <- compact(colors[isNumeric]) %||% viridisLite::viridis(10) if (is.list(palette) && length(palette) > 1) { @@ -205,11 +213,12 @@ mapColor <- function(traces, title = "", na.color = "transparent") { traces[[length(traces) + 1]] <- structure(colorBarTrace, class = "plotly_colorbar") } - if (any(!isNumeric)) { - allColor <- unlist(color[!isNumeric]) + if (any(isDiscrete)) { + browser() + allColor <- unlist(color[isDiscrete]) lvls <- unique(allColor) N <- length(lvls) - palette <- compact(colors[!isNumeric]) %||% + palette <- compact(colors[isDiscrete]) %||% if (is.ordered(allColor)) viridisLite::viridis(N) else RColorBrewer::brewer.pal(N, "Set2") if (is.list(palette) && length(palette) > 1) { stop("Multiple numeric color palettes specified (via the colors argument).\n", @@ -217,7 +226,7 @@ mapColor <- function(traces, title = "", na.color = "transparent") { call. = FALSE) } colScale <- scales::col_factor(palette, levels = lvls, na.color = na.color) - for (i in which(!isNumeric)) { + for (i in which(isDiscrete)) { if (hasLine[[i]]) { traces[[i]]$line$color <- colScale(color[[i]]) } @@ -227,7 +236,6 @@ mapColor <- function(traces, title = "", na.color = "transparent") { if (hasText[[i]]) { traces[[i]]$textfont$color <- colScale(color[[i]]) } - } } diff --git a/R/process.R b/R/process.R index 864e709c06..c3c4dbfbb7 100644 --- a/R/process.R +++ b/R/process.R @@ -31,8 +31,7 @@ process.plotly_figure <- function(resp) { fig$url <- sub("apigetfile/", "~", resp$url) # make sure that we always return a HTTPS link con$url <- sub("^http[s]?:", "https:", con$url) - fig <- add_boxed(fig) - fig$data[[1]]$inherit <- FALSE + fig <- verify_boxed(fig) as.widget(fig) } diff --git a/R/utils.R b/R/utils.R index 0a8dd55f8f..cddb519ede 100644 --- a/R/utils.R +++ b/R/utils.R @@ -6,6 +6,10 @@ is.formula <- function(f) { inherits(f, "formula") } +is.colorbar <- function(tr) { + inherits(tr, "plotly_colorbar") +} + "%||%" <- function(x, y) { if (length(x) > 0 || is_blank(x)) x else y } @@ -35,38 +39,86 @@ verify_arg <- function(arg) { arg } -# make sure plot attributes are valid according to the plotly.js schema -verify_plot <- function(p) { +# make sure plot attributes adhere to the plotly.js schema +verify_attr_names <- function(p) { # some layout attributes (e.g., [x-y]axis can have trailing numbers) - layoutAttrs <- sub("[0-9]+$", "", names(p$x$layout)) - validLayoutAttrs <- names(Schema$layout$layoutAttributes) - illegalLayoutAttrs <- setdiff(layoutAttrs, validLayoutAttrs) - if (length(illegalLayoutAttrs)) { - stop("The following layout attributes don't exist:\n'", - paste(illegalLayoutAttrs, collapse = "', '"), "'\n", - "Valid layout attributes include:\n'", - paste(validLayoutNames, collapse = "', '"), "'\n", - call. = FALSE) + check_attrs( + sub("[0-9]+$", "", names(p$x$layout)), + names(Schema$layout$layoutAttributes) + ) + for (tr in seq_along(p$x$data)) { + thisTrace <- p$x$data[[tr]] + validAttrs <- Schema$traces[[thisTrace$type]]$attributes + check_attrs(names(thisTrace), names(validAttrs)) } - - traceTypes <- unlist(lapply(p$x$data, "[[", "type")) - validTraceTypes <- names(Schema$traces) - illegalTraceTypes <- setdiff(traceTypes, validTraceTypes) - if (length(illegalTraceTypes)) { - stop("The following trace types don't exist:\n'", - paste(illegalTraceTypes, collapse = "', '"), "'\n", - "Valid layout attributes include:\n'", - paste(validTraceTypes, collapse = "', '"), "'\n", + invisible(p) +} + +check_attrs <- function(proposedAttrs, validAttrs) { + illegalAttrs <- setdiff(proposedAttrs, validAttrs) + if (length(illegalAttrs)) { + stop("The following attributes don't exist:\n'", + paste(illegalAttrs, collapse = "', '"), "'\n", + "Valid options include:\n'", + paste(validAttrs, collapse = "', '"), "'\n", call. = FALSE) } - invisible(p) + invisible(proposedAttrs) +} + +# ensure both the layout and trace attributes are sent to plotly.js +# as data_arrays +verify_boxed <- function(p) { + layoutNames <- names(p$x$layout) + layoutNew <- verify_box( + setNames(p$x$layout, sub("[0-9]+$", "", layoutNames)), + Schema$layout$layoutAttributes + ) + p$x$layout <- setNames(layoutNew, layoutNames) + for (tr in seq_along(p$x$data)) { + thisTrace <- p$x$data[[tr]] + validAttrs <- Schema$traces[[thisTrace$type]]$attributes + p$x$data[[tr]] <- verify_box(thisTrace, validAttrs) + } + p +} + +verify_box <- function(proposed, schema) { + for (attr in names(proposed)) { + attrVal <- proposed[[attr]] + attrSchema <- schema[[attr]] + isArray <- tryCatch( + identical(attrSchema[["valType"]], "data_array"), + error = function(e) FALSE + ) + isObject <- tryCatch( + identical(attrSchema[["role"]], "object"), + error = function(e) FALSE + ) + if (isArray) { + proposed[[attr]] <- i(attrVal) + } + # we don't have to go more than two-levels, right? + if (isObject) { + for (attr2 in names(attrVal)) { + isArray2 <- tryCatch( + identical(attrSchema[[attr2]][["valType"]], "data_array"), + error = function(e) FALSE + ) + if (isArray2) { + proposed[[attr]][[attr2]] <- i(attrVal[[attr2]]) + } + } + } + } + proposed } # make sure trace type is valid # TODO: add an argument to verify trace properties are valid (https://github.com/ropensci/plotly/issues/540) verify_type <- function(type = NULL) { if (is.null(type)) { - message("No trace type specified. Guessing you want a 'scatter' trace") + message("No trace type specified. Using the default 'scatter'") type <- "scatter" } if (!is.character(type) || length(type) != 1) { @@ -81,20 +133,6 @@ verify_type <- function(type = NULL) { type } -# verify_attrs <- function(type = NULL, attributes = NULL) { -# type <- verify_type(type) -# attrs <- traces[[type]]$attributes -# idx <- attributes %in% names(attrs) -# if (any(!idx)) { -# stop( -# "The '", type, "' trace type doesn't have attribute(s) named: '", -# paste(attributes[!idx], collapse = "', '"), "'", call. = FALSE -# ) -# } -# attrs[attributes] -# } - - has_marker <- function(types, modes) { is_scatter <- grepl("scatter", types) ifelse(is_scatter, grepl("marker", modes), has_attr(types, "marker")) @@ -128,7 +166,7 @@ has_legend <- function(p) { has_colorbar <- function(p) { isVisibleBar <- function(tr) { - inherits(tr, "plotly_colorbar") && isTRUE(tr$showscale %||% TRUE) + is.colorbar(tr) && isTRUE(tr$showscale %||% TRUE) } any(vapply(p$x$data, isVisibleBar, logical(1))) } @@ -186,51 +224,6 @@ from_JSON <- function(x, ...) { jsonlite::fromJSON(x, simplifyDataFrame = FALSE, simplifyMatrix = FALSE, ...) } -add_boxed <- function(x) { - for (i in seq_along(x$data)) { - # some object keys require an array, even if length one - # one way to ensure atomic vectors of length 1 are not automatically unboxed, - # by to_JSON(), is to attach a class of AsIs (via I()) - d <- x$data[[i]] - idx <- names(d) %in% get_boxed(d$type %||% "scatter") & sapply(d, length) == 1 - if (any(idx)) x$data[[i]][idx] <- lapply(d[idx], I) - # (safely) mark individual nested properties - x$data[[i]]$error_x$array <- i(d$error_x$array) - x$data[[i]]$error_y$array <- i(d$error_y$array) - x$data[[i]]$error_x$arrayminus <- i(d$error_x$arrayminus) - x$data[[i]]$error_y$arrayminus <- i(d$error_y$arrayminus) - } - axes <- grep("^[x-y]axis", names(x$layout)) - for (ax in axes) { - x$layout[[ax]]$ticktext <- i(x$layout[[ax]]$ticktext) - x$layout[[ax]]$tickvals <- i(x$layout[[ax]]$tickvals) - } - x -} - -# plotlyjs properties that must _always_ be an array (even if length 1) -get_boxed <- function(type = "scatter") { - # if the trace type isn't found, provide some sensible defaults - boxers[[type]] %||% c("x", "y", "z", "lat", "lon", "text", "locations") -} - -# if this ever needs updating see -# https://github.com/ropensci/plotly/issues/415#issuecomment-173353138 -boxers <- list( - choropleth = c("locations", "z", "text"), - box = c("x", "y"), - heatmap = c("z", "text"), - histogram = c("x", "y"), - histogram2d = c("z", "color"), - mesh3d = c("x", "y", "z", "i", "j", "k", "intensity", "vertexcolor", "facecolor"), - # TODO: what to do about marker.colors? - pie = c("labels", "values", "text"), - scatter = c("x", "y", "r", "t"), - scatter3d = c("x", "y", "z"), - scattergeo = c("lon", "lat", "locations"), - surface = c("x", "y", "z", "text") -) - i <- function(x) { if (is.null(x)) { return(NULL) diff --git a/man/add_trace.Rd b/man/add_trace.Rd index 09e7296dc5..a9762c8cf6 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/add.R \name{add_trace} \alias{add_trace} -\title{Add a trace to a plotly visualization} +\title{Add trace(s) to a plotly visualization} \usage{ add_trace(p, ..., color, colors = NULL, symbol, symbols = NULL, size, linetype, linetypes = NULL, data = NULL) @@ -26,15 +26,31 @@ or a color interpolation function like \code{colorRamp}.} \item{size}{A variable name or numeric vector to encode the size of markers.} +\item{linetype}{Either a variable name or a (discrete) vector to use for linetype encoding.} + +\item{linetypes}{A character vector of line types. For possible values, see \link{schema}.} + \item{data}{A data frame to associate with this trace (optional). If not provided, arguments are evaluated using the data frame in \code{\link{plot_ly}()}.} } \description{ -Add a trace to a plotly visualization +Add trace(s) to a plotly visualization } \examples{ p <- plot_ly(economics, x = ~date, y = ~uempmed) +p +p \%>\% add_points() +p \%>\% add_lines() +p \%>\% add_text(text = ".") + +# attributes declared in plot_ly() carry over to downstream traces +plot_ly(economics, x = ~date, y = ~uempmed) \%>\% + add_points(color = ~pop) \%>\% + add_lines(line = list(color = "red")) + + + # add a loess smoother p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) diff --git a/man/hide_colorbar.Rd b/man/hide_colorbar.Rd new file mode 100644 index 0000000000..14ddffe2b6 --- /dev/null +++ b/man/hide_colorbar.Rd @@ -0,0 +1,15 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helpers.R +\name{hide_colorbar} +\alias{hide_colorbar} +\title{Hide a color bar} +\usage{ +hide_colorbar(p) +} +\arguments{ +\item{p}{a plotly object.} +} +\description{ +Hide a color bar +} + From bdc27d1bb200993752ecf16b3922af717e58dd44 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 16 Jun 2016 16:25:25 -0500 Subject: [PATCH 17/73] Use rapply to evaluate formulas of arbitrary depth --- R/plotly_build.R | 138 +++++++++++++++++++++++++++-------------------- 1 file changed, 79 insertions(+), 59 deletions(-) diff --git a/R/plotly_build.R b/R/plotly_build.R index c754a1a389..cb75c1ac35 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -20,8 +20,8 @@ plotly_build <- function(p) { } #' @export -plotly_build.default <- function(p) { - p +plotly_build.list <- function(p) { + as.widget(p) } #' @export @@ -34,11 +34,9 @@ plotly_build.plotly <- function(p) { layouts <- Map(function(x, y) { - is_formula <- vapply(x, is.formula, logical(1)) - fl <- lazyeval::as_f_list(x[is_formula] %||% list()) - for (var in names(fl)) { - x[[var]] <- lazyeval::f_eval(fl[[var]], plotly_data(p, y)) - } + d <- plotly_data(p, y) + + x <- rapply(x, eval_attr, data = d, how = "list") x[lengths(x) > 0] }, p$x$layoutAttrs, names(p$x$layoutAttrs)) @@ -46,7 +44,7 @@ plotly_build.plotly <- function(p) { # get rid of the data -> layout mapping and merge all the layouts # into a single layout (more recent layouts will override older ones) p$x$layoutAttrs <- NULL - p$x$layout <- modifyList(p$x$layout %||% list(), Reduce(modifyList, layouts) %||% list()) + p$x$layout <- modify_list(p$x$layout, Reduce(modify_list, layouts)) # If type was not specified in plot_ly(), it doesn't create a trace unless # there are no other traces @@ -58,29 +56,33 @@ plotly_build.plotly <- function(p) { x$type <- verify_type(x$type) - is_formula <- vapply(x, is.formula, logical(1)) - fl <- lazyeval::as_f_list(x[is_formula] %||% list()) d <- plotly_data(p, y) - grps <- dplyr::groups(d) - # insert missing values to differentiate groups - if (length(grps) > 0) { - d <- group2NA(d, groupNames = as.character(grps)) - } - # perform the evaluation - for (var in names(fl)) { - x[[var]] <- lazyeval::f_eval(fl[[var]], d) - varname <- sub("^~", "", deparse2(fl[[var]])) - # deparse axis names and add to layout - if (any(c("x", "y", "z") %in% var)) { + + # add sensible axis names to layout + for (i in c("x", "y", "z")) { + nm <- paste0(i, "axis") + idx <- which(names(x) %in% i) + if (length(idx) == 1) { + title <- sub("^~", "", deparse2(x[[idx]])) if (is3d(x$type)) { - p$x$layout$scene[[paste0(var, "axis")]]$title <<- varname + p$x$layout$scene[[nm]]$title <- title } else { - p$x$layout[[paste0(var, "axis")]]$title <<- varname + p$x$layout[[nm]]$title <- title } } } - x[lengths(x) > 0] + # perform the evaluation + x <- rapply(x, eval_attr, data = d, how = "list") + + attrLengths <- lengths(x) + + # if appropriate, set the mode now since we need to reference it later + if (grepl("scatter", x$type)) { + x$mode <- if (any(attrLengths > 20)) "lines" else "markers+lines" + } + + x[attrLengths > 0] }, p$x$attrs, names(p$x$attrs)) @@ -95,6 +97,10 @@ plotly_build.plotly <- function(p) { traces <- list() for (i in seq_along(dats)) { d <- dats[[i]] + # no longer need these special variable mapping attributes + for (j in c("color", "colors", "symbol", "symbols", "linetype", "linetypes")) { + dats[[i]][[j]] <- NULL + } params <- list( if (is.discrete(d[["color"]])) d[["color"]], d[["symbol"]], @@ -102,8 +108,6 @@ plotly_build.plotly <- function(p) { ) params <- compact(params) %||% list(NULL) idx <- do.call("interaction", params) - dats[[i]][["color"]] <- NULL - dats[[i]][["symbol"]] <- NULL traces <- c(traces, traceify(dats[[i]], idx)) } @@ -114,26 +118,35 @@ plotly_build.plotly <- function(p) { # get rid of data -> vis mapping stuff p$x[c("visdat", "cur_data", "attrs")] <- NULL - if (has_legend(p) && has_colorbar(p)) { - # shrink the colorbar - idx <- which(vapply(p$x$data, function(x) inherits(x, "plotly_colorbar"), logical(1))) - p$x$data[[idx]]$marker$colorbar <- modifyList( - p$x$data[[idx]]$marker$colorbar %||% list(), - list(len = 1/2, lenmode = "fraction", y = 1, yanchor = "top") - ) - p$x$layout$legend <- modifyList( - p$x$layout$legend %||% list(), - list(y = 1/2, yanchor = "top") - ) + if (has_colorbar(p) && has_legend(p)) { + if (length(p$x$data) <= 2) { + p$x$layout$showlegend <- FALSE + } else { + # shrink the colorbar + idx <- which(vapply(p$x$data, function(x) inherits(x, "plotly_colorbar"), logical(1))) + p$x$data[[idx]]$marker$colorbar <- modify_list( + list(len = 1/2, lenmode = "fraction", y = 1, yanchor = "top"), + p$x$data[[idx]]$marker$colorbar + ) + p$x$layout$legend <- modify_list( + list(y = 1/2, yanchor = "top"), + p$x$layout$legend + ) + } } # traces can't have names p$x$data <- setNames(p$x$data, NULL) # verify plot attributes are legal according to the plotly.js spec - # (and box attributes data_array attributes where appropriate) verify_attr_names(p) + # box up 'data_array' attributes where appropriate verify_boxed(p) + # if it makes sense, add markers/lines/text to mode + verify_mode(p) + # annotations & shapes must be an array of objects + # TODO: should we add anything else to this? + verify_arrays(p) } # appends a new (empty) trace to generate (plot-wide) colorbar/colorscale @@ -146,13 +159,10 @@ mapColor <- function(traces, title = "", na.color = "transparent") { } isNumeric <- vapply(color, is.numeric, logical(1)) isDiscrete <- vapply(color, is.discrete, logical(1)) - colors <- lapply(traces, "[[", "colors") # color/colorscale/colorbar attribute placement depends on trace type and marker mode types <- vapply(traces, function(tr) tr$type, character(1)) - modes <- vapply(traces, function(tr) { - tr$mode %||% if (any(lengths(tr) > 20)) "lines" else "markers+lines" - }, character(1)) + modes <- vapply(traces, function(tr) tr$mode, character(1)) hasMarker <- has_marker(types, modes) hasLine <- has_line(types, modes) hasText <- has_text(types, modes) @@ -160,12 +170,7 @@ mapColor <- function(traces, title = "", na.color = "transparent") { any(vapply(traces, function(tr) !is.null(tr$z), logical(1))) if (any(isNumeric)) { - palette <- compact(colors[isNumeric]) %||% viridisLite::viridis(10) - if (is.list(palette) && length(palette) > 1) { - stop("Multiple numeric color palettes specified (via the colors argument).\n", - "When using the color/colors arguments, only one palette is allowed.", - call. = FALSE) - } + palette <- traces[[1]]$colors %||% viridisLite::viridis(10) # TODO: use ggstat::frange() when it's on CRAN? allColor <- unlist(color[isNumeric]) rng <- range(allColor, na.rm = TRUE) @@ -183,13 +188,18 @@ mapColor <- function(traces, title = "", na.color = "transparent") { for (i in which(isNumeric)) { colorObj$color <- color[[i]] if (hasLine[[i]]) { - traces[[i]]$line <- modifyList(traces[[i]]$line %||% list(), colorObj) + if (types[[i]] %in% c("scatter", "scattergl")) { + warning("Numeric color variables cannot (yet) be mapped to lines.\n", + " when the trace type is 'scatter' or 'scattergl'.\n", call. = FALSE) + traces[[i]]$mode <- "markers" + hasMarker[[i]] <- TRUE + } } if (hasMarker[[i]]) { - traces[[i]]$marker <- modifyList(traces[[i]]$marker %||% list(), colorObj) + traces[[i]]$marker <- modify_list(colorObj, traces[[i]]$marker) } if (hasZ[[i]]) { - traces[[i]] <- modifyList(traces[[i]] %||% list(), colorObj) + traces[[i]] <- modify_list(colorObj, traces[[i]]) } if (hasText[[i]]) { warning("Numeric color variables cannot (yet) be mapped to text.\n", @@ -214,11 +224,10 @@ mapColor <- function(traces, title = "", na.color = "transparent") { } if (any(isDiscrete)) { - browser() allColor <- unlist(color[isDiscrete]) lvls <- unique(allColor) N <- length(lvls) - palette <- compact(colors[isDiscrete]) %||% + palette <- traces[[1]]$colors %||% if (is.ordered(allColor)) viridisLite::viridis(N) else RColorBrewer::brewer.pal(N, "Set2") if (is.list(palette) && length(palette) > 1) { stop("Multiple numeric color palettes specified (via the colors argument).\n", @@ -228,13 +237,22 @@ mapColor <- function(traces, title = "", na.color = "transparent") { colScale <- scales::col_factor(palette, levels = lvls, na.color = na.color) for (i in which(isDiscrete)) { if (hasLine[[i]]) { - traces[[i]]$line$color <- colScale(color[[i]]) + traces[[i]]$line <- modify_list( + list(color = colScale(color[[i]])), + traces[[i]]$line + ) } if (hasMarker[[i]]) { - traces[[i]]$marker$color <- colScale(color[[i]]) + traces[[i]]$marker <- modify_list( + list(color = colScale(color[[i]])), + traces[[i]]$marker + ) } if (hasText[[i]]) { - traces[[i]]$textfont$color <- colScale(color[[i]]) + traces[[i]]$textfont <- modify_list( + list(color = colScale(color[[i]])), + traces[[i]]$textfont + ) } } } @@ -285,8 +303,6 @@ mapSymbol <- function(traces) { traces } - - mapLinetype <- function(traces) { linetypeList <- lapply(traces, "[[", "linetype") nLinetypes <- lengths(linetypeList) @@ -325,7 +341,6 @@ mapLinetype <- function(traces) { message("Adding lines to mode; otherwise linetype would have no effect.") traces[[i]]$mode <- paste0(traces[[i]]$mode, "+lines") } - } traces } @@ -351,3 +366,8 @@ traceify <- function(dat, x = NULL) { } return(new_dat) } + + +eval_attr <- function(x, data = NULL) { + if (lazyeval::is_formula(x)) lazyeval::f_eval(x, data) else x +} From 7688a57283757902b511e8758ab0c3ab73ed66fa Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 16 Jun 2016 16:26:08 -0500 Subject: [PATCH 18/73] export group_by --- R/plotly_data.R | 17 +++++++++++++++-- man/group_by.Rd | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 man/group_by.Rd diff --git a/R/plotly_data.R b/R/plotly_data.R index 3333369e82..cc87a8f564 100644 --- a/R/plotly_data.R +++ b/R/plotly_data.R @@ -1,3 +1,16 @@ +#' Divide data into groups. +#' +#' @param x a visualisation +#' @param ... variables to group by. +#' @param add By default, when \code{add = FALSE}, \code{group_by} will +#' override existing groups. To instead add to the existing groups, +#' use \code{add = TRUE} +#' @importFrom dplyr group_by +#' @name group_by +#' @export +NULL + + #' View and manipulate data associated with a plotly graph #' #' \code{plotly_data()} returns the data associated with @@ -156,8 +169,8 @@ group2NA <- function(data, groupNames = "group", nested = NULL, } else { dplyr::do(d, rbind(., NA)) } - d <- tidyr::unnest(d) + d <- tidyr::unnest(d, groupNames) n <- nrow(d) - if (all(is.na(d[n, ]))) d <- d[-n, ] + if (all(is.na(d[n, !groupNames %in% names(d)]))) d <- d[-n, ] structure(d, class = unique(class(data), class(d))) } diff --git a/man/group_by.Rd b/man/group_by.Rd new file mode 100644 index 0000000000..c2cb5f39e0 --- /dev/null +++ b/man/group_by.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plotly_data.R +\name{group_by} +\alias{group_by} +\title{Divide data into groups.} +\arguments{ +\item{x}{a visualisation} + +\item{...}{variables to group by.} + +\item{add}{By default, when \code{add = FALSE}, \code{group_by} will +override existing groups. To instead add to the existing groups, +use \code{add = TRUE}} +} +\description{ +Divide data into groups. +} + From ed1e4fc17fc27c03b24c28a6a34e15772d3b6d09 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 16 Jun 2016 16:27:27 -0500 Subject: [PATCH 19/73] various bug fixes; updates to docs/tests --- NAMESPACE | 4 ++- NEWS | 15 ++++---- R/add.R | 17 ++------- R/ggplotly.R | 7 ++-- R/helpers.R | 4 +-- R/layers2traces.R | 3 +- R/layout.R | 8 ++++- R/plotly_POST.R | 1 + R/subplots.R | 4 +-- R/toRGB.R | 3 +- R/utils.R | 50 ++++++++++++++++++++++++-- inst/examples/onRenderHover/index.Rmd | 17 ++++----- man/add_trace.Rd | 18 ++-------- man/plot_ly.Rd | 3 +- tests/testthat/test-cookbook-lines.R | 1 + tests/testthat/test-ggplot-area.R | 2 +- tests/testthat/test-ggplot-density2d.R | 2 +- tests/testthat/test-ggplot-errorbar.R | 4 +-- tests/testthat/test-ggplot-point.R | 9 ----- tests/testthat/test-ggplot-violin.R | 2 +- 20 files changed, 97 insertions(+), 77 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 0e294e6bea..bada3d039e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,8 +18,8 @@ S3method(ggplotly,ggplot) S3method(group_by_,plotly) S3method(layout,matrix) S3method(layout,plotly) -S3method(plotly_build,default) S3method(plotly_build,gg) +S3method(plotly_build,list) S3method(plotly_build,plotly) S3method(print,plotly_figure) S3method(to_basic,GeomAbline) @@ -66,6 +66,7 @@ export(geom2trace) export(get_figure) export(gg2list) export(ggplotly) +export(group_by) export(groups.plotly) export(knit_print.plotly_figure) export(layout) @@ -100,6 +101,7 @@ importFrom(base64enc,base64encode) importFrom(dplyr,arrange_) importFrom(dplyr,distinct_) importFrom(dplyr,do) +importFrom(dplyr,group_by) importFrom(dplyr,group_by_) importFrom(grDevices,col2rgb) importFrom(graphics,layout) diff --git a/NEWS b/NEWS index fdce699e8f..2bd7302f48 100644 --- a/NEWS +++ b/NEWS @@ -1,19 +1,18 @@ 4.0.0 -MAJOR CHANGES & IMPROVEMENTS: +BREAKING CHANGES & IMPROVEMENTS: -* Formulas (instead of plain expressions) are now required when referring to variable names. For example, `plot_ly(mtcars, x = wt, y = mpg, color = vs)` should now be `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~vs)`. This is a major breaking change, but it is necessary to ensure that evaluation is correct in all contexts (as a result, `evaluate` argument is now deprecated). It also has the benefit of being easier to program with (i.e., writing your own custom functions that wrap `plot_ly()`). For more details, see the [lazyeval vignette](https://github.com/hadley/lazyeval/blob/master/vignettes/lazyeval.Rmd) +* Formulas (instead of plain expressions) are now required when using variable mappings. For example, `plot_ly(mtcars, x = wt, y = mpg, color = vs)` should now be `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~vs)`. This is a major breaking change, but it is necessary to ensure that evaluation is correct in all contexts (as a result, `evaluate` argument is now deprecated as it is no longer needed). It also has the benefit of being easier to program with (i.e., writing your own custom functions that wrap `plot_ly()`). For more details, see the [lazyeval vignette](https://github.com/hadley/lazyeval/blob/master/vignettes/lazyeval.Rmd) * The data structure used to represent plotly objects is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, plotly objects can now be serialized across R sessions and avoid [memory leak issues](https://github.com/rstudio/shiny/issues/1151). This also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `help("plotly-data")` for more details). -* The `group` argument is deprecated. Groups should be added to the data via `dplyr::group_by()` (see `help("plotly-data")` for examples). Also, groupings will no longer create multiple traces (fixes #418, #381, #577). +* The `group` variable mapping no longer create multiple traces, but instead defines "gaps" within a trace (fixes #418, #381, #577). Groupings should be declared via the new `group_by()` function (for examples, see `help("plotly-data")`) instead of the `group` argument (which is now deprecated). +* Scales for variable mappings (such as `color`, `symbol`, `linetype`) are now applied at the plot-level instead of the trace level. As a result, the `colors`/`symbols` arguments have been removed from `add_trace()`. * The `inherit` argument is deprecated. Any arguments/attributes specified in `plot_ly()` will automatically be passed along to additional traces added via `add_trace()` (or any of it's `add_*()` siblings). -Traces created via `add_trace()` (or, more generally, by any `add_*()` function), will inherit _required_ attributes from parent traces. - - NEW FEATURES & IMPROVEMENTS: -* Error checking for trace types and their attributes. Also added a `explain_attrs()` function to obtain information about trace attributes. -* New `add_points()`/`add_lines()`/`add_text()` functions provide a shorthand for common plots. +* Error checking for trace and layout attributes. +* Added `linetype`/`linetypes` arguments for mapping discrete variables to line types (this works very much like the `symbol`/`symbols`). +* New `add_points()`/`add_lines()`/`add_text()`/`add_polygon`/`add_ribbon()` functions provide a shorthand for common plots. * New `toWebGL()` function for easy conversion from SVG to WebGL. * New `export()` function makes it easy to save plots as png/jpeg/pdf (fixes #311). * `layout()` is now a generic function and uses method dispatch to avoid conflicts with `graphics:layout()` (fixes #464). diff --git a/R/add.R b/R/add.R index 398932cc8c..3c0884739c 100644 --- a/R/add.R +++ b/R/add.R @@ -25,15 +25,9 @@ add_data <- function(p, data = NULL) { #' @param ... These arguments are documented in the references section below. #' Note that acceptable arguments depend on the trace type. #' @param color Either a variable name or a vector to use for color mapping. -#' @param colors Either a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"), -#' or a vector of colors to interpolate in hexadecimal "#RRGGBB" format, -#' or a color interpolation function like \code{colorRamp}. #' @param symbol Either a variable name or a (discrete) vector to use for symbol encoding. -#' @param symbols A character vector of symbol types. Possible values: -#' 'dot', 'cross', 'diamond', 'square', 'triangle-down', 'triangle-left', 'triangle-right', 'triangle-up' #' @param size A variable name or numeric vector to encode the size of markers. #' @param linetype Either a variable name or a (discrete) vector to use for linetype encoding. -#' @param linetypes A character vector of line types. For possible values, see \link{schema}. #' @param data A data frame to associate with this trace (optional). If not #' provided, arguments are evaluated using the data frame in \code{\link{plot_ly}()}. #' @seealso \code{\link{plot_ly}()} @@ -52,15 +46,10 @@ add_data <- function(p, data = NULL) { #' plot_ly(economics, x = ~date, y = ~uempmed) %>% #' add_points(color = ~pop) %>% #' add_lines(line = list(color = "red")) -#' -#' -#' -#' # add a loess smoother -#' p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) +#' #' add_trace <- function(p, ..., - color, colors = NULL, symbol, symbols = NULL, size, - linetype, linetypes = NULL, data = NULL) { + color, symbol, size, linetype, data = NULL) { # "native" plotly arguments attrs <- list(...) @@ -79,7 +68,7 @@ add_trace <- function(p, ..., p <- add_data(p, data) # inherit attributes from the "first layer" - new_attrs <- modifyList(p$x$attrs[[1]] %||% list(), attrs) + new_attrs <- modify_list(p$x$attrs[[1]], attrs) p$x$attrs <- c( p$x$attrs %||% list(), diff --git a/R/ggplotly.R b/R/ggplotly.R index 804c47eae5..6d7ade9027 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -258,7 +258,7 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A varName <- y[[i]] # by default assume the values don't need any formatting forMat <- function(x) if (is.numeric(x)) round(x, 2) else x - if (aesName %in% c("x", "y")) { + if (isTRUE(aesName %in% c("x", "y"))) { scaleName <- scales$get_scales(aesName)$scale_name # convert "milliseconds from the UNIX epoch" to a date/datetime # http://stackoverflow.com/questions/13456241/convert-unix-epoch-to-date-object-in-r @@ -668,7 +668,7 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A idx <- which(hashes %in% i) # for now we just merge markers and lines -- I can't imagine text being worthwhile if (all(modes[idx] %in% c("lines", "markers"))) { - mergedTraces[[i]] <- Reduce(modifyList, traces[idx]) + mergedTraces[[i]] <- Reduce(modify_list, traces[idx]) mergedTraces[[i]]$mode <- "markers+lines" if (any(sapply(traces[idx], "[[", "showlegend"))) { mergedTraces[[i]]$showlegend <- TRUE @@ -847,8 +847,7 @@ bold <- function(x) paste("", x, "") italic <- function(x) paste("", x, "") # if a vector has one unique value, return that value -uniq <- function(x, na.rm = TRUE) { - if (na.rm) x <- x[!is.na(x)] +uniq <- function(x) { u <- unique(x) if (length(u) == 1) u else x } diff --git a/R/helpers.R b/R/helpers.R index 3b35ed14ca..a62259d168 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -7,10 +7,10 @@ #' add_points() %>% #' hide_colorbar() hide_colorbar <- function(p) { + p <- plotly_build(p) idx <- vapply(p$x$data, is.colorbar, logical(1)) - browser() for (i in which(idx)) { - p$x$data[[i]]$marker$colorbar$showscale <- FALSE + p$x$data[[i]]$marker$showscale <- FALSE } p } diff --git a/R/layers2traces.R b/R/layers2traces.R index 7a48d70b74..fc47d573d5 100644 --- a/R/layers2traces.R +++ b/R/layers2traces.R @@ -461,7 +461,6 @@ geom2trace.GeomPolygon <- function(data, params, p) { type = "scatter", mode = "lines", line = list( - # NOTE: line attributes must be constant on a polygon width = aes2plotly(data, params, "size"), color = toRGB( aes2plotly(data, params, "colour"), @@ -640,7 +639,7 @@ ribbon_dat <- function(dat) { n <- nrow(dat) o <- order(dat$x) o2 <- order(dat$x, decreasing = TRUE) - used <- c("x", "ymin", "ymax") + used <- c("x", "ymin", "ymax", "y") not_used <- setdiff(names(dat), used) # top-half of ribbon tmp <- dat[o, ] diff --git a/R/layout.R b/R/layout.R index f1b3ef6417..4e7a5150b7 100644 --- a/R/layout.R +++ b/R/layout.R @@ -21,7 +21,13 @@ layout.matrix <- function(p, ..., data = NULL) { #' @export layout.plotly <- function(p, ..., data = NULL) { p <- add_data(p, data) - p$x$layoutAttrs[[p$x$cur_data]] <- list(...) + attrs <- list(...) + if (is.null(p$x$cur_data)) { + nlayouts <- length(p$x$layout) + p$x$layout <- c(p$x$layout, attrs) + } else { + p$x$layoutAttrs[[p$x$cur_data]] <- attrs + } p } diff --git a/R/plotly_POST.R b/R/plotly_POST.R index b455db22a9..0ad09e9a33 100644 --- a/R/plotly_POST.R +++ b/R/plotly_POST.R @@ -38,6 +38,7 @@ plotly_POST <- function(x, filename = NULL, fileopt = "overwrite", sharing = c("public", "private", "secret")) { x <- plotly_build(x) + if (inherits(x, "htmlwidget")) x <- x$x # try our damndest to assign a sensible filename x$filename <- filename %||% x$filename %||% as.character(x$layout$title) %||% paste(c(x$layout$xaxis$title, x$layout$yaxis$title, x$layout$zaxis$title), diff --git a/R/subplots.R b/R/subplots.R index 2dd988b941..bf81364189 100644 --- a/R/subplots.R +++ b/R/subplots.R @@ -218,7 +218,7 @@ subplot <- function(..., nrows = 1, widths = NULL, heights = NULL, margin = 0.02 # start merging the plots into a single subplot p <- list( data = Reduce(c, traces), - layout = Reduce(modifyList, c(xAxes, rev(yAxes))) + layout = Reduce(modify_list, c(xAxes, rev(yAxes))) ) # reposition shapes and annotations annotations <- Map(reposition, annotations, split(domainInfo, seq_along(plots))) @@ -235,7 +235,7 @@ subplot <- function(..., nrows = 1, widths = NULL, heights = NULL, margin = 0.02 } layouts <- layouts[which_layout] } - p$layout <- c(p$layout, Reduce(modifyList, layouts)) + p$layout <- c(p$layout, Reduce(modify_list, layouts)) as.widget(p) } diff --git a/R/toRGB.R b/R/toRGB.R index f99fb82bb6..2049b7df64 100644 --- a/R/toRGB.R +++ b/R/toRGB.R @@ -4,7 +4,7 @@ #' @return hexadecimal colour value (if is.na(x), return "transparent" for compatibility with Plotly) #' @export toRGB <- function(x, alpha = 1) { - if (is.null(x)) return(x) + if (length(x) == 0) return(x) if (any(x %in% "transparent")) return(x) # add alpha to already converted "rgb(x,y,z)" codes idx <- grepl("^rgba\\(", x) & alpha <= 1 & 0 <= alpha @@ -24,6 +24,7 @@ toRGB <- function(x, alpha = 1) { ) rgb_matrix["alpha", ] <- round(rgb_matrix["alpha", ], 4) rgba <- sprintf("rgba(%s)", apply(rgb_matrix, 2, paste, collapse = ",")) + rgba[is.na(x)] <- "transparent" rgba } diff --git a/R/utils.R b/R/utils.R index cddb519ede..c39bbfad09 100644 --- a/R/utils.R +++ b/R/utils.R @@ -18,6 +18,10 @@ compact <- function(x) { Filter(Negate(is.null), x) } +modify_list <- function(x, y, ...) { + modifyList(x %||% list(), y %||% list(), ...) +} + is.discrete <- function(x) { is.factor(x) || is.character(x) || is.logical(x) } @@ -44,12 +48,12 @@ verify_attr_names <- function(p) { # some layout attributes (e.g., [x-y]axis can have trailing numbers) check_attrs( sub("[0-9]+$", "", names(p$x$layout)), - names(Schema$layout$layoutAttributes) + c(names(Schema$layout$layoutAttributes), c("barmode", "bargap")) ) for (tr in seq_along(p$x$data)) { thisTrace <- p$x$data[[tr]] validAttrs <- Schema$traces[[thisTrace$type]]$attributes - check_attrs(names(thisTrace), names(validAttrs)) + check_attrs(names(thisTrace), c(names(validAttrs), "key")) } invisible(p) } @@ -118,7 +122,7 @@ verify_box <- function(proposed, schema) { # TODO: add an argument to verify trace properties are valid (https://github.com/ropensci/plotly/issues/540) verify_type <- function(type = NULL) { if (is.null(type)) { - message("No trace type specified. Using the default 'scatter'") + message("No trace type specified. Using the 'scatter' default.") type <- "scatter" } if (!is.character(type) || length(type) != 1) { @@ -133,6 +137,46 @@ verify_type <- function(type = NULL) { type } +verify_mode <- function(p) { + for (tr in seq_along(p$x$data)) { + trace <- p$x$data[[tr]] + if (grepl("scatter", trace$type %||% "scatter")) { + if (!is.null(trace$marker) && !grepl("markers", trace$mode)) { + message( + "A marker object has been specified, but markers is not in the mode\n", + "Adding markers to the mode..." + ) + p$x$data[[tr]]$mode <- paste0(p$x$data[[tr]]$mode, "+markers") + } + if (!is.null(trace$line) && !grepl("lines", trace$mode)) { + message( + "A line object has been specified, but lines is not in the mode\n", + "Adding lines to the mode..." + ) + p$x$data[[tr]]$mode <- paste0(p$x$data[[tr]]$mode, "+lines") + } + if (!is.null(trace$textfont) && !grepl("text", trace$mode)) { + warning( + "A textfont object has been specified, but text is not in the mode\n", + "Adding text to the mode..." + ) + p$x$data[[tr]]$mode <- paste0(p$x$data[[tr]]$mode, "+text") + } + } + } + p +} + +verify_arrays <- function(p) { + for (i in c("annotations", "shapes")) { + thing <- p$x$layout[[i]] + if (is.list(thing) && !is.null(names(thing))) { + p$x$layout[[i]] <- list(thing) + } + } + p +} + has_marker <- function(types, modes) { is_scatter <- grepl("scatter", types) ifelse(is_scatter, grepl("marker", modes), has_attr(types, "marker")) diff --git a/inst/examples/onRenderHover/index.Rmd b/inst/examples/onRenderHover/index.Rmd index 72265585c9..70647eb329 100644 --- a/inst/examples/onRenderHover/index.Rmd +++ b/inst/examples/onRenderHover/index.Rmd @@ -11,7 +11,7 @@ library(htmlwidgets) set.seed(1056) -nPatients <- 100 +nPatients <- 50 nVisits <- 10 df <- data.frame( @@ -21,14 +21,15 @@ df <- data.frame( ) c1 <- list(color = toRGB("steelblue", 0.5)) c2 <- list(color = toRGB("orange", 0.5)) -# `color=factor(uin)`` is here just to ensure we get one trace -# for each value of uin -p <- plot_ly( - df, x = visit, y = fev1_perc, color = factor(uin), - mode = "markers+lines", marker = c1, line = c2 -) %>% layout(hovermode = "closest", showlegend = FALSE) -as.widget(p) %>% +# The color mapping is used only to generate multiple traces +# (which makes it easier to highlight lines on the JS side) +# TODO: maybe provide a split_by() function to avoid this sort of hack? +df %>% + plot_ly( + x = ~visit, y = ~fev1_perc, color = ~factor(uin), marker = c1, line = c2 + ) %>% + layout(hovermode = "closest", showlegend = FALSE) %>% onRender(' function(el, x) { var graphDiv = document.getElementById(el.id); diff --git a/man/add_trace.Rd b/man/add_trace.Rd index a9762c8cf6..fea654ee46 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -4,8 +4,7 @@ \alias{add_trace} \title{Add trace(s) to a plotly visualization} \usage{ -add_trace(p, ..., color, colors = NULL, symbol, symbols = NULL, size, - linetype, linetypes = NULL, data = NULL) +add_trace(p, ..., color, symbol, size, linetype, data = NULL) } \arguments{ \item{p}{a plotly or ggplot object.} @@ -15,21 +14,12 @@ Note that acceptable arguments depend on the trace type.} \item{color}{Either a variable name or a vector to use for color mapping.} -\item{colors}{Either a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"), -or a vector of colors to interpolate in hexadecimal "#RRGGBB" format, -or a color interpolation function like \code{colorRamp}.} - \item{symbol}{Either a variable name or a (discrete) vector to use for symbol encoding.} -\item{symbols}{A character vector of symbol types. Possible values: -'dot', 'cross', 'diamond', 'square', 'triangle-down', 'triangle-left', 'triangle-right', 'triangle-up'} - \item{size}{A variable name or numeric vector to encode the size of markers.} \item{linetype}{Either a variable name or a (discrete) vector to use for linetype encoding.} -\item{linetypes}{A character vector of line types. For possible values, see \link{schema}.} - \item{data}{A data frame to associate with this trace (optional). If not provided, arguments are evaluated using the data frame in \code{\link{plot_ly}()}.} } @@ -48,11 +38,7 @@ p \%>\% add_text(text = ".") plot_ly(economics, x = ~date, y = ~uempmed) \%>\% add_points(color = ~pop) \%>\% add_lines(line = list(color = "red")) - - - -# add a loess smoother -p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) + } \author{ diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index 7eb47b2835..2ef04fecde 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -14,7 +14,8 @@ plot_ly(data = data.frame(), ..., type = NULL, color, colors = NULL, \item{...}{These arguments are documented at \url{https://plot.ly/r/reference/} Note that acceptable arguments depend on the value of \code{type}.} -\item{type}{A character string describing the type of trace.} +\item{type}{A character string describing the type of trace. If \code{NULL} +(the default), the initial trace type is determined by \code{add_trace}} \item{color}{Either a variable name or a vector to use for color mapping.} diff --git a/tests/testthat/test-cookbook-lines.R b/tests/testthat/test-cookbook-lines.R index 4cb4ffff71..865c7c06ae 100644 --- a/tests/testthat/test-cookbook-lines.R +++ b/tests/testthat/test-cookbook-lines.R @@ -184,6 +184,7 @@ test_that("scatter facet -> 2 traces", { temp <- spf + geom_hline(aes(yintercept=10)) test_that("geom_hline -> 2 more traces", { info <- expect_traces(temp, 4, "scatter-facet-hline") + expect_true(info$layout$showlegend) has.name <- sapply(info$data, function(tr) nchar(tr$name) > 0) expect_equal(sum(has.name), 2) diff --git a/tests/testthat/test-ggplot-area.R b/tests/testthat/test-ggplot-area.R index ecacd93471..c11c58c94a 100644 --- a/tests/testthat/test-ggplot-area.R +++ b/tests/testthat/test-ggplot-area.R @@ -26,7 +26,7 @@ test_that("sanity check for geom_area", { L <- expect_traces(ar, 1, "simple") expect_identical(L$data[[1]]$type, "scatter") expect_identical(L$data[[1]]$mode, "lines") - expect_identical(L$data[[1]]$fill, "tozerox") + expect_identical(L$data[[1]]$fill, "toself") expect_true( L$data[[1]]$fillcolor == toRGB(GeomArea$default_aes$fill, GeomArea$default_aes$alpha) diff --git a/tests/testthat/test-ggplot-density2d.R b/tests/testthat/test-ggplot-density2d.R index 60dce56040..8cae56c522 100644 --- a/tests/testthat/test-ggplot-density2d.R +++ b/tests/testthat/test-ggplot-density2d.R @@ -43,7 +43,7 @@ test_that("StatDensity2d with GeomPolygon translates to filled path(s)", { unique(unlist(lapply(polygons, "[[", "mode"))), "lines" ) expect_identical( - unique(unlist(lapply(polygons, "[[", "fill"))), "tozerox" + unique(unlist(lapply(polygons, "[[", "fill"))), "toself" ) # split on fill for polygons # (you can't have two polygons with different fill in a single trace) diff --git a/tests/testthat/test-ggplot-errorbar.R b/tests/testthat/test-ggplot-errorbar.R index 51622e69d7..fbcc65eb69 100644 --- a/tests/testthat/test-ggplot-errorbar.R +++ b/tests/testthat/test-ggplot-errorbar.R @@ -29,8 +29,8 @@ g <- p + geom_errorbar(aes(ymin = lower, ymax = upper)) test_that("geom_errorbar boxes an array of length 1", { L <- save_outputs(g, "errorbar-unique-groups") - expect_true(inherits(L$data[[1]]$error_y$array, "AsIs")) - expect_true(inherits(L$data[[1]]$error_y$arrayminus, "AsIs")) + expect_equal(L$data[[1]]$error_y$array, 0.1) + expect_equal(L$data[[1]]$error_y$arrayminus, 0.2) }) # TODO fix and add a test for width of errorbars diff --git a/tests/testthat/test-ggplot-point.R b/tests/testthat/test-ggplot-point.R index 8a4e2b27a2..32c23e5061 100644 --- a/tests/testthat/test-ggplot-point.R +++ b/tests/testthat/test-ggplot-point.R @@ -58,12 +58,3 @@ test_that("can plot on sub-second time scale", { info <- save_outputs(g, "point-size-alpha2") expect_equivalent(info$data[[1]]$x, as.numeric(d$x)) }) - - -test_that("tickvals/ticktext are appropriately boxed", { - d <- data.frame(x = factor(75), y = 10) - p <- qplot(x, y, data = d) - info <- save_outputs(p, "point-box") - expect_true(plotly:::to_JSON(info$layout$xaxis$tickvals) == '[1]') - expect_true(plotly:::to_JSON(info$layout$xaxis$ticktext) == '["75"]') -}) diff --git a/tests/testthat/test-ggplot-violin.R b/tests/testthat/test-ggplot-violin.R index 7b6dc38105..d10ba9d1c6 100644 --- a/tests/testthat/test-ggplot-violin.R +++ b/tests/testthat/test-ggplot-violin.R @@ -7,7 +7,7 @@ test_that("basic geom_violin works", { expect_equal(length(L$data), 1) tr <- L$data[[1]] expect_identical(tr$type, "scatter") - expect_true(tr$fill == "tozerox") + expect_true(tr$fill == "toself") expect_false(tr$showlegend) expect_true(all(grepl("density", tr$text[!is.na(tr$text)]))) expect_true(tr$hoverinfo == "text") From 5e3f01143d44bb8d95f3c42fbab1211c569ba132 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 16 Jun 2016 16:34:01 -0500 Subject: [PATCH 20/73] more documentation --- inst/htmlwidgets/plotly.js | 1 - vignettes/intro.Rmd | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/inst/htmlwidgets/plotly.js b/inst/htmlwidgets/plotly.js index b406d6759f..3df60ef50d 100644 --- a/inst/htmlwidgets/plotly.js +++ b/inst/htmlwidgets/plotly.js @@ -27,7 +27,6 @@ HTMLWidgets.widget({ // if no plot exists yet, create one with a particular configuration if (!instance.plotly) { - console.log(x); var plot = Plotly.plot(graphDiv, x.data, x.layout, x.config); instance.plotly = true; instance.autosize = x.layout.autosize; diff --git a/vignettes/intro.Rmd b/vignettes/intro.Rmd index 2dbee86595..efc8923a71 100644 --- a/vignettes/intro.Rmd +++ b/vignettes/intro.Rmd @@ -22,14 +22,14 @@ To create a plotly visualization, start with `plot_ly()`. ```{r} library(plotly) -plot_ly(economics, x = date, y = unemploy / pop) +plot_ly(economics, x = ~date, y = ~unemploy / pop) ``` A plotly visualization is composed of one (or more) trace(s), and every trace has a `type` (the default type is 'scatter'). The arguments/properties that a trace will respect ([documented here](https://plot.ly/r/reference)) depend on it's type. A scatter trace respects `mode`, which can be any combination of "lines", "markers", "text" joined with a "+": ```{r} library(plotly) -plot_ly(economics, x = date, y = unemploy / pop, +plot_ly(economics, x = ~date, y = ~unemploy / pop, type = "scatter", mode = "markers+lines") ``` @@ -37,29 +37,30 @@ You can manually add a trace to an existing plot with `add_trace()`. In that cas ```{r} m <- loess(unemploy / pop ~ as.numeric(date), data = economics) -p <- plot_ly(economics, x = date, y = unemploy / pop, name = "raw") -add_trace(p, x = date, y = fitted(m), name = "loess") +p <- plot_ly(economics, x = ~date, y = ~unemploy / pop, name = "raw") +add_lines(p, y = ~fitted(m), name = "loess") ``` __plotly__ was designed with a [pure, predictable, and pipeable interface](https://dl.dropboxusercontent.com/u/41902/pipe-dsls.pdf) in mind, so you can also use the `%>%` operator to create a visualization pipeline: ```{r} economics %>% - plot_ly(x = date, y = unemploy / pop) %>% - add_trace(x = date, y = fitted(m)) %>% + plot_ly(x = ~date, y = ~unemploy / pop) %>% + add_lines(y = ~fitted(m)) %>% layout(showlegend = F) ``` -Furthermore, `plot_ly()`, `add_trace()`, and `layout()`, all accept a data frame as their first argument and output a data frame. As a result, we can inter-weave data manipulations and visual mappings in a single pipeline. +TODO: talk about dplyr verbs! ```{r} +library(dplyr) economics %>% - transform(rate = unemploy / pop) %>% - plot_ly(x = date, y = rate) %>% - subset(rate == max(rate)) %>% + mutate(rate = unemploy / pop) %>% + plot_ly(x = ~date, y = ~rate) %>% + filter(rate == max(rate)) %>% layout( showlegend = F, - annotations = list(x = date, y = rate, text = "Peak", showarrow = T) + annotations = list(x = ~date, y = ~rate, text = "Peak", showarrow = T) ) ``` From f94645ce8eed9df3a705ba10eaaf241f42ccd102 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 17 Jun 2016 12:02:05 -0500 Subject: [PATCH 21/73] trace type inference --- R/plotly_build.R | 9 ++++----- R/utils.R | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/R/plotly_build.R b/R/plotly_build.R index cb75c1ac35..4f9d389954 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -54,10 +54,6 @@ plotly_build.plotly <- function(p) { dats <- Map(function(x, y) { - x$type <- verify_type(x$type) - - d <- plotly_data(p, y) - # add sensible axis names to layout for (i in c("x", "y", "z")) { nm <- paste0(i, "axis") @@ -73,12 +69,15 @@ plotly_build.plotly <- function(p) { } # perform the evaluation + d <- plotly_data(p, y) x <- rapply(x, eval_attr, data = d, how = "list") + x <- verify_type(x) + attrLengths <- lengths(x) # if appropriate, set the mode now since we need to reference it later - if (grepl("scatter", x$type)) { + if (grepl("scatter", x$type) && is.null(x$mode)) { x$mode <- if (any(attrLengths > 20)) "lines" else "markers+lines" } diff --git a/R/utils.R b/R/utils.R index c39bbfad09..bcbccaac29 100644 --- a/R/utils.R +++ b/R/utils.R @@ -118,22 +118,50 @@ verify_box <- function(proposed, schema) { proposed } + # make sure trace type is valid # TODO: add an argument to verify trace properties are valid (https://github.com/ropensci/plotly/issues/540) -verify_type <- function(type = NULL) { - if (is.null(type)) { - message("No trace type specified. Using the 'scatter' default.") - type <- "scatter" +verify_type <- function(trace) { + if (is.null(trace$type)) { + attrs <- names(trace) + attrLengths <- lengths(trace) + if (all(c("x", "y", "z") %in% attrs)) { + trace$type <- if (all(c("i", "j", "k") %in% attrs)) relay_type("mesh3d") else relay_type("scatter3d") + } else if (all(c("x", "y") %in% attrs)) { + if (is.numeric(trace$x) && is.numeric(trace$y)) { + trace$type <- if (any(attrLengths) > 15000) relay_type("scattergl") else relay_type("scatter") + } else if (is.numeric(trace$x)) { + trace$type <- relay_type("bar") + trace$orientation <- "h" + } else if (is.numeric(trace$y)) { + trace$type <- relay_type("bar") + } else { + trace$type <- relay_type("histogram2d") + } + } else if ("y" %in% attrs || "x" %in% attrs) { + trace$type <- relay_type("histogram") + } else { + warning("No trace type specified and no positional attributes specified", call. = FALSE) + trace$type <- relay_type("scatter") + } } - if (!is.character(type) || length(type) != 1) { + if (!is.character(trace$type) || length(trace$type) != 1) { stop("The trace type must be a character vector of length 1.\n", call. = FALSE) } - if (!type %in% names(Schema$traces)) { + if (!trace$type %in% names(Schema$traces)) { stop("Trace type must be one of the following: \n", "'", paste(names(Schema$traces), collapse = "', '"), "'", call. = FALSE) } + trace +} + +relay_type <- function(type) { + message( + "No trace type specified. Inferring a type of '", type, "'.\n", + "Read more about this trace type here -> https://plot.ly/r/reference/#", type + ) type } From ea7e09706580b3c9e3659dd1603d732e2e449d25 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 17 Jun 2016 12:56:52 -0500 Subject: [PATCH 22/73] better docs; plotly_spec -> plotly_json; bug fixes --- NAMESPACE | 2 -- NEWS | 2 +- R/debug.R | 43 ------------------------------------ R/plotly.R | 18 +++++++++++++-- R/utils.R | 10 +++++---- inst/htmlwidgets/plotly.yaml | 2 +- man/explain_attrs.Rd | 21 ------------------ man/plot_ly.Rd | 18 +++++++++++++-- man/plotly_spec.Rd | 22 ------------------ man/schema.Rd | 10 ++------- 10 files changed, 42 insertions(+), 106 deletions(-) delete mode 100644 R/debug.R delete mode 100644 man/explain_attrs.Rd delete mode 100644 man/plotly_spec.Rd diff --git a/NAMESPACE b/NAMESPACE index bada3d039e..a4237cfd1b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -59,7 +59,6 @@ export(as.widget) export(config) export(embed_notebook) export(event_data) -export(explain_attrs) export(export) export(filter_.plotly) export(geom2trace) @@ -81,7 +80,6 @@ export(plotly_build) export(plotly_data) export(plotly_empty) export(plotly_json) -export(plotly_spec) export(rename_.plotly) export(renderPlotly) export(schema) diff --git a/NEWS b/NEWS index 2bd7302f48..a6398778ad 100644 --- a/NEWS +++ b/NEWS @@ -16,7 +16,7 @@ NEW FEATURES & IMPROVEMENTS: * New `toWebGL()` function for easy conversion from SVG to WebGL. * New `export()` function makes it easy to save plots as png/jpeg/pdf (fixes #311). * `layout()` is now a generic function and uses method dispatch to avoid conflicts with `graphics:layout()` (fixes #464). -* Added a `plotly_spec()` function for inspecting the data sent to plotly.js (as an R list or JSON). +* Added a `plotly_json()` function for inspecting the data sent to plotly.js (as an R list or JSON). OTHER CHANGES: diff --git a/R/debug.R b/R/debug.R deleted file mode 100644 index 89f81eba9c..0000000000 --- a/R/debug.R +++ /dev/null @@ -1,43 +0,0 @@ -#' Obtain JSON sent to plotly.js -#' -#' This function returns the JSON sent to plotly.js which can be useful for -#' debugging. -#' -#' @param p a plotly or ggplot object. -#' @param ... other options passed onto \code{listviewer::jsonedit} -#' @export -#' @examples -#' -#' plotly_spec(plot_ly()) - -plotly_spec <- function(p = plot_ly(), ...) { - if (system.file(package = "listviewer") == "") { - stop("This function requires the listviewer package:\n", - "install.packages('listviewer')", call. = FALSE) - } - listviewer::jsonedit(to_JSON(plotly_build(p)$x), mode = "form", ...) -} - - -#' Display plot schema -#' -#' @export -#' @examples -#' -#' schema() - -schema <- function() { - listviewer::jsonedit(Schema, mode = "form") -} - -#' Show information about attribute(s) of a given trace type -#' -#' @export -#' @param type a trace type -#' @param attrs attributes for the race type -#' @examples -#' -#' explain_attrs() -explain_attrs <- function(type = "scatter", attrs = c("x", "y")) { - jsonlite::toJSON(verify_attrs(type, attrs), pretty = TRUE) -} diff --git a/R/plotly.R b/R/plotly.R index d8b21abc11..33679f7969 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -27,8 +27,22 @@ #' @export #' @examples #' \dontrun{ -#' data(economics, package = "ggplot2") -#' # basic time-series plot +#' +#' # If you don't explicitly add a trace, via add_trace() or similar, +#' # plot_ly() will add one for you, and infer an appropriate trace type +#' plot_ly(economics, x = ~pop) +#' plot_ly(economics, x = ~date, y = ~pop) +#' +#' # Attributes set in plot_ly() define 'global' attributes that +#' # are carried onto subsequent traces +#' plot_ly(economics, x = ~date, line = list(color = "black")) %>% +#' add_trace(y = ~uempmed, mode = "markers+lines") %>% +#' add_lines(y = ~psavert) +#' +#' plot_ly(economics, x = ~date) %>% +#' add_lines(y = ~uempmed) %>% +#' add_lines(y = ~fitted(loess(uempmed ~ as.numeric(date)))) +#' #' p <- plot_ly(economics, x = ~date, y = ~uempmed) #' # add a loess smoother #' p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) diff --git a/R/utils.R b/R/utils.R index bcbccaac29..de4fe1427f 100644 --- a/R/utils.R +++ b/R/utils.R @@ -128,18 +128,20 @@ verify_type <- function(trace) { if (all(c("x", "y", "z") %in% attrs)) { trace$type <- if (all(c("i", "j", "k") %in% attrs)) relay_type("mesh3d") else relay_type("scatter3d") } else if (all(c("x", "y") %in% attrs)) { - if (is.numeric(trace$x) && is.numeric(trace$y)) { + if (!is.discrete(trace$x) && !is.discrete(trace$y)) { trace$type <- if (any(attrLengths) > 15000) relay_type("scattergl") else relay_type("scatter") - } else if (is.numeric(trace$x)) { + } else if (!is.discrete(trace$x)) { trace$type <- relay_type("bar") trace$orientation <- "h" - } else if (is.numeric(trace$y)) { + } else if (!is.discrete(trace$y)) { trace$type <- relay_type("bar") } else { trace$type <- relay_type("histogram2d") } } else if ("y" %in% attrs || "x" %in% attrs) { - trace$type <- relay_type("histogram") + trace$type <- relay_type("histogram") + } else if ("z" %in% attrs) { + trace$type <- relay_type("heatmap") } else { warning("No trace type specified and no positional attributes specified", call. = FALSE) trace$type <- relay_type("scatter") diff --git a/inst/htmlwidgets/plotly.yaml b/inst/htmlwidgets/plotly.yaml index b8704579d1..01777e0659 100644 --- a/inst/htmlwidgets/plotly.yaml +++ b/inst/htmlwidgets/plotly.yaml @@ -1,6 +1,6 @@ dependencies: - name: plotlyjs - version: 1.11.0 + version: 1.13.0 src: "htmlwidgets/lib/plotlyjs" script: plotly-latest.min.js stylesheet: plotly-htmlwidgets.css diff --git a/man/explain_attrs.Rd b/man/explain_attrs.Rd deleted file mode 100644 index f9462c0396..0000000000 --- a/man/explain_attrs.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/debug.R -\name{explain_attrs} -\alias{explain_attrs} -\title{Show information about attribute(s) of a given trace type} -\usage{ -explain_attrs(type = "scatter", attrs = c("x", "y")) -} -\arguments{ -\item{type}{a trace type} - -\item{attrs}{attributes for the race type} -} -\description{ -Show information about attribute(s) of a given trace type -} -\examples{ - -explain_attrs() -} - diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index 2ef04fecde..cdf7486b85 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -48,8 +48,22 @@ Reference section (see below). } \examples{ \dontrun{ -data(economics, package = "ggplot2") -# basic time-series plot + +# If you don't explicitly add a trace, via add_trace() or similar, +# plot_ly() will add one for you, and infer an appropriate trace type +plot_ly(economics, x = ~pop) +plot_ly(economics, x = ~date, y = ~pop) + +# Attributes set in plot_ly() define 'global' attributes that +# are carried onto subsequent traces +plot_ly(economics, x = ~date, line = list(color = "black")) \%>\% + add_trace(y = ~uempmed, mode = "markers+lines") \%>\% + add_lines(y = ~psavert) + +plot_ly(economics, x = ~date) \%>\% + add_lines(y = ~uempmed) \%>\% + add_lines(y = ~fitted(loess(uempmed ~ as.numeric(date)))) + p <- plot_ly(economics, x = ~date, y = ~uempmed) # add a loess smoother p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) diff --git a/man/plotly_spec.Rd b/man/plotly_spec.Rd deleted file mode 100644 index 21775de2ef..0000000000 --- a/man/plotly_spec.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/debug.R -\name{plotly_spec} -\alias{plotly_spec} -\title{Obtain JSON sent to plotly.js} -\usage{ -plotly_spec(p = plot_ly(), ...) -} -\arguments{ -\item{p}{a plotly or ggplot object.} - -\item{...}{other options passed onto \code{listviewer::jsonedit}} -} -\description{ -This function returns the JSON sent to plotly.js which can be useful for -debugging. -} -\examples{ - -plotly_spec(plot_ly()) -} - diff --git a/man/schema.Rd b/man/schema.Rd index f5d8cbc578..d933ebf277 100644 --- a/man/schema.Rd +++ b/man/schema.Rd @@ -1,22 +1,16 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/debug.R, R/dev.R +% Please edit documentation in R/dev.R \name{schema} \alias{schema} -\title{Display plot schema} +\title{Display plotly's plot schema} \usage{ -schema() - schema() } \description{ -Display plot schema - The schema contains valid attributes names, their value type, default values (if any), and min/max values (if applicable). } \examples{ - -schema() schema() } From c00299180fb305df8fa7c36104b4a2f48979333a Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 17 Jun 2016 12:57:26 -0500 Subject: [PATCH 23/73] fix layout bug identified by @timelyportfolio --- R/layout.R | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/R/layout.R b/R/layout.R index 4e7a5150b7..bbfa66a716 100644 --- a/R/layout.R +++ b/R/layout.R @@ -22,12 +22,11 @@ layout.matrix <- function(p, ..., data = NULL) { layout.plotly <- function(p, ..., data = NULL) { p <- add_data(p, data) attrs <- list(...) - if (is.null(p$x$cur_data)) { - nlayouts <- length(p$x$layout) - p$x$layout <- c(p$x$layout, attrs) - } else { - p$x$layoutAttrs[[p$x$cur_data]] <- attrs - } + # similar to add_trace() + p$x$layoutAttrs <- c( + p$x$layoutAttrs %||% list(), + setNames(list(attrs), p$x$cur_data) + ) p } From dc2669bb128dbd06a9cdbf751f1f89145eed8b21 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 17 Jun 2016 13:02:02 -0500 Subject: [PATCH 24/73] for consistency in naming; add_points -> add_markers --- NAMESPACE | 2 +- NEWS | 3 ++- R/add.R | 8 ++++---- R/dplyr.R | 2 +- R/helpers.R | 2 +- R/plotly_data.R | 2 +- man/{add_points.Rd => add_markers.Rd} | 6 +++--- man/add_polygons.Rd | 2 +- man/add_trace.Rd | 4 ++-- man/plotly-data.Rd | 2 +- man/plotly_data.Rd | 2 +- 11 files changed, 18 insertions(+), 17 deletions(-) rename man/{add_points.Rd => add_markers.Rd} (74%) diff --git a/NAMESPACE b/NAMESPACE index a4237cfd1b..ad2258b214 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -50,7 +50,7 @@ S3method(to_basic,default) export("%>%") export(add_data) export(add_lines) -export(add_points) +export(add_markers) export(add_polygons) export(add_ribbons) export(add_text) diff --git a/NEWS b/NEWS index a6398778ad..be19fa59d2 100644 --- a/NEWS +++ b/NEWS @@ -11,8 +11,9 @@ BREAKING CHANGES & IMPROVEMENTS: NEW FEATURES & IMPROVEMENTS: * Error checking for trace and layout attributes. +* Trace type inference based on specified attributes. * Added `linetype`/`linetypes` arguments for mapping discrete variables to line types (this works very much like the `symbol`/`symbols`). -* New `add_points()`/`add_lines()`/`add_text()`/`add_polygon`/`add_ribbon()` functions provide a shorthand for common plots. +* New `add_markers()`/`add_lines()`/`add_text()`/`add_polygon`/`add_ribbon()` functions provide a shorthand for common plots. * New `toWebGL()` function for easy conversion from SVG to WebGL. * New `export()` function makes it easy to save plots as png/jpeg/pdf (fixes #311). * `layout()` is now a generic function and uses method dispatch to avoid conflicts with `graphics:layout()` (fixes #464). diff --git a/R/add.R b/R/add.R index 3c0884739c..73e226c7e9 100644 --- a/R/add.R +++ b/R/add.R @@ -38,13 +38,13 @@ add_data <- function(p, data = NULL) { #' #' p <- plot_ly(economics, x = ~date, y = ~uempmed) #' p -#' p %>% add_points() +#' p %>% add_markers() #' p %>% add_lines() #' p %>% add_text(text = ".") #' #' # attributes declared in plot_ly() carry over to downstream traces #' plot_ly(economics, x = ~date, y = ~uempmed) %>% -#' add_points(color = ~pop) %>% +#' add_markers(color = ~pop) %>% #' add_lines(line = list(color = "red")) #' #' @@ -81,7 +81,7 @@ add_trace <- function(p, ..., #' Add points to a plotly vis #' #' @export -add_points <- function(p, ...) { +add_markers <- function(p, ...) { add_trace(p, type = "scatter", mode = "markers", ...) } @@ -111,7 +111,7 @@ add_text <- function(p, ...) { #' ggplot2::map_data("world", "canada") %>% #' group_by(group) %>% #' plot_ly(x = ~long, y = ~lat, hoverinfo = "none") %>% -#' add_points(text = ~paste(name, "
", pop), hoverinfo = "text", +#' add_markers(text = ~paste(name, "
", pop), hoverinfo = "text", #' data = canada.cities) %>% #' layout(showlegend = FALSE) add_polygons <- function(p, ...) { diff --git a/R/dplyr.R b/R/dplyr.R index 0bc3c7af97..ad78661202 100644 --- a/R/dplyr.R +++ b/R/dplyr.R @@ -10,7 +10,7 @@ #' mtcars %>% #' plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") %>% #' filter(cyl == 4) %>% -#' add_points(x = ~wt, y = ~mpg, name = "filtered points", +#' add_markers(x = ~wt, y = ~mpg, name = "filtered points", #' marker = list(color = "red")) #' #' library(tidyr) diff --git a/R/helpers.R b/R/helpers.R index a62259d168..c4d4992ebe 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -4,7 +4,7 @@ #' @export #' #' plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop) %>% -#' add_points() %>% +#' add_markers() %>% #' hide_colorbar() hide_colorbar <- function(p) { p <- plotly_build(p) diff --git a/R/plotly_data.R b/R/plotly_data.R index cc87a8f564..3b1f6e71dd 100644 --- a/R/plotly_data.R +++ b/R/plotly_data.R @@ -28,7 +28,7 @@ NULL #' mtcars %>% #' plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") %>% #' filter(cyl == 4) %>% -#' add_points(x = ~wt, y = ~mpg, name = "filtered points", +#' add_markers(x = ~wt, y = ~mpg, name = "filtered points", #' marker = list(color = "red")) #' #' library(tidyr) diff --git a/man/add_points.Rd b/man/add_markers.Rd similarity index 74% rename from man/add_points.Rd rename to man/add_markers.Rd index 95881b810d..db0fcb9ab5 100644 --- a/man/add_points.Rd +++ b/man/add_markers.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/add.R -\name{add_points} -\alias{add_points} +\name{add_markers} +\alias{add_markers} \title{Add points to a plotly vis} \usage{ -add_points(p, ...) +add_markers(p, ...) } \description{ Add points to a plotly vis diff --git a/man/add_polygons.Rd b/man/add_polygons.Rd index 1fd7019747..1851766bd3 100644 --- a/man/add_polygons.Rd +++ b/man/add_polygons.Rd @@ -17,7 +17,7 @@ data(canada.cities, package = "maps") ggplot2::map_data("world", "canada") \%>\% group_by(group) \%>\% plot_ly(x = ~long, y = ~lat, hoverinfo = "none") \%>\% - add_points(text = ~paste(name, "
", pop), hoverinfo = "text", + add_markers(text = ~paste(name, "
", pop), hoverinfo = "text", data = canada.cities) \%>\% layout(showlegend = FALSE) } diff --git a/man/add_trace.Rd b/man/add_trace.Rd index fea654ee46..6d37f36ba5 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -30,13 +30,13 @@ Add trace(s) to a plotly visualization p <- plot_ly(economics, x = ~date, y = ~uempmed) p -p \%>\% add_points() +p \%>\% add_markers() p \%>\% add_lines() p \%>\% add_text(text = ".") # attributes declared in plot_ly() carry over to downstream traces plot_ly(economics, x = ~date, y = ~uempmed) \%>\% - add_points(color = ~pop) \%>\% + add_markers(color = ~pop) \%>\% add_lines(line = list(color = "red")) diff --git a/man/plotly-data.Rd b/man/plotly-data.Rd index 18dae2a24d..404692fc59 100644 --- a/man/plotly-data.Rd +++ b/man/plotly-data.Rd @@ -51,7 +51,7 @@ library(dplyr) mtcars \%>\% plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") \%>\% filter(cyl == 4) \%>\% - add_points(x = ~wt, y = ~mpg, name = "filtered points", + add_markers(x = ~wt, y = ~mpg, name = "filtered points", marker = list(color = "red")) library(tidyr) diff --git a/man/plotly_data.Rd b/man/plotly_data.Rd index cd415daaa8..b8087dff52 100644 --- a/man/plotly_data.Rd +++ b/man/plotly_data.Rd @@ -55,7 +55,7 @@ library(dplyr) mtcars \%>\% plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") \%>\% filter(cyl == 4) \%>\% - add_points(x = ~wt, y = ~mpg, name = "filtered points", + add_markers(x = ~wt, y = ~mpg, name = "filtered points", marker = list(color = "red")) library(tidyr) From 823e1baea45a352f58683517c486d7a4b6bcacf6 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 17 Jun 2016 15:18:34 -0500 Subject: [PATCH 25/73] implement size/sizes; fix symbols; better docs --- NAMESPACE | 19 ++++++----- NEWS | 3 +- R/add.R | 12 +++++-- R/helpers.R | 6 ---- R/plotly.R | 66 ++++++++++++++++-------------------- R/plotly_build.R | 60 +++++++++++++++++++++++++++++--- man/add_lines.Rd | 2 +- man/add_paths.Rd | 12 +++++++ man/plot_ly.Rd | 60 +++++++++++++++++++------------- man/plotly-data.Rd | 18 +++++----- man/plotly_data.Rd | 18 +++++----- tests/testthat/test-plotly.R | 23 +++++++------ 12 files changed, 186 insertions(+), 113 deletions(-) create mode 100644 man/add_paths.Rd diff --git a/NAMESPACE b/NAMESPACE index ad2258b214..78cf0d3f44 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ S3method(arrange_,plotly) S3method(distinct_,plotly) +S3method(filter_,plotly) S3method(geom2trace,GeomBar) S3method(geom2trace,GeomBlank) S3method(geom2trace,GeomBoxplot) @@ -16,12 +17,18 @@ S3method(geom2trace,default) S3method(ggplotly,ggmatrix) S3method(ggplotly,ggplot) S3method(group_by_,plotly) +S3method(groups,plotly) S3method(layout,matrix) S3method(layout,plotly) +S3method(mutate_,plotly) S3method(plotly_build,gg) S3method(plotly_build,list) S3method(plotly_build,plotly) S3method(print,plotly_figure) +S3method(rename_,plotly) +S3method(select_,plotly) +S3method(slice_,plotly) +S3method(summarise_,plotly) S3method(to_basic,GeomAbline) S3method(to_basic,GeomArea) S3method(to_basic,GeomBoxplot) @@ -47,10 +54,13 @@ S3method(to_basic,GeomTile) S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) S3method(to_basic,default) +S3method(transmute_,plotly) +S3method(ungroup,plotly) export("%>%") export(add_data) export(add_lines) export(add_markers) +export(add_paths) export(add_polygons) export(add_ribbons) export(add_text) @@ -60,16 +70,13 @@ export(config) export(embed_notebook) export(event_data) export(export) -export(filter_.plotly) export(geom2trace) export(get_figure) export(gg2list) export(ggplotly) export(group_by) -export(groups.plotly) export(knit_print.plotly_figure) export(layout) -export(mutate_.plotly) export(offline) export(plot_ly) export(plotly) @@ -80,20 +87,14 @@ export(plotly_build) export(plotly_data) export(plotly_empty) export(plotly_json) -export(rename_.plotly) export(renderPlotly) export(schema) -export(select_.plotly) export(signup) -export(slice_.plotly) export(style) export(subplot) -export(summarise_.plotly) export(toRGB) export(toWebGL) export(to_basic) -export(transmute_.plotly) -export(ungroup.plotly) import(ggplot2) importFrom(base64enc,base64encode) importFrom(dplyr,arrange_) diff --git a/NEWS b/NEWS index be19fa59d2..afd11aae89 100644 --- a/NEWS +++ b/NEWS @@ -12,8 +12,9 @@ NEW FEATURES & IMPROVEMENTS: * Error checking for trace and layout attributes. * Trace type inference based on specified attributes. -* Added `linetype`/`linetypes` arguments for mapping discrete variables to line types (this works very much like the `symbol`/`symbols`). * New `add_markers()`/`add_lines()`/`add_text()`/`add_polygon`/`add_ribbon()` functions provide a shorthand for common plots. +* Added `linetype`/`linetypes` arguments for mapping discrete variables to line types (this works very much like the `symbol`/`symbols`). +* Added a `sizes` argument for controlling the range of marker size scaling. * New `toWebGL()` function for easy conversion from SVG to WebGL. * New `export()` function makes it easy to save plots as png/jpeg/pdf (fixes #311). * `layout()` is now a generic function and uses method dispatch to avoid conflicts with `graphics:layout()` (fixes #464). diff --git a/R/add.R b/R/add.R index 73e226c7e9..3126bf39de 100644 --- a/R/add.R +++ b/R/add.R @@ -58,9 +58,6 @@ add_trace <- function(p, ..., attrs$symbol <- verify_arg(symbol) attrs$size <- verify_arg(size) - attrs$colors <- colors - attrs$symbols <- symbols - if (!is.null(attrs[["group"]])) { warning("The group argument has been deprecated. Use group_by() instead.") } @@ -85,8 +82,17 @@ add_markers <- function(p, ...) { add_trace(p, type = "scatter", mode = "markers", ...) } +#' Add paths to a plotly vis +#' +#' @export +add_paths <- function(p, ...) { + add_trace(p, type = "scatter", mode = "lines", ...) +} + #' Add lines to a plotly vis #' +#' Equivalent to \code{add_paths}, but with the x-values sorted. +#' #' @export add_lines <- function(p, ...) { add_trace(p, type = "scatter", mode = "lines", ...) diff --git a/R/helpers.R b/R/helpers.R index c4d4992ebe..c74ad37f4b 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -15,12 +15,6 @@ hide_colorbar <- function(p) { p } -hide_legend <- function(p) { - layout(p, showlegend = FALSE) -} - - - #' Convert trace types to WebGL #' #' @param p a plotly or ggplot object. diff --git a/R/plotly.R b/R/plotly.R index 33679f7969..6d5b30a79f 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -19,6 +19,7 @@ #' @param linetype Either a variable name or a (discrete) vector to use for linetype encoding. #' @param linetypes A character vector of line types. For possible values, see \link{schema}. #' @param size A variable name or numeric vector to encode the size of markers. +#' @param sizes a numeric vector of length 2 used to scale sizes to pixels. #' @param width Width in pixels (optional, defaults to automatic sizing). #' @param height Height in pixels (optional, defaults to automatic sizing). #' @param source Only relevant for \link{event_data}. @@ -28,53 +29,45 @@ #' @examples #' \dontrun{ #' -#' # If you don't explicitly add a trace, via add_trace() or similar, -#' # plot_ly() will add one for you, and infer an appropriate trace type +#' # plot_ly() tries to create a sensible plot based on the information you +#' # give it. If you don't provide a trace type, plot_ly() will infer one. #' plot_ly(economics, x = ~pop) #' plot_ly(economics, x = ~date, y = ~pop) +#' # plot_ly() doesn't require data frame(s), which allows one to take +#' # advantage of trace type(s) designed specifically for numeric matrices +#' plot_ly(z = volcano) +#' plot_ly(z = volcano, type = "surface") +#' +#' # plotly has a functional interface: every plotly function takes a plotly +#' # object as it's first input argument and returns a modified plotly object +#' add_points(plot_ly(economics, x = ~date, y = ~unemploy/pop)) +#' +#' # To make code more readable, plotly imports the pipe operator from magrittr +#' economics %>% plot_ly(x = ~date, y = ~unemploy/pop) %>% add_points() #' -#' # Attributes set in plot_ly() define 'global' attributes that +#' # Attributes defined via plot_ly() set 'global' attributes that #' # are carried onto subsequent traces #' plot_ly(economics, x = ~date, line = list(color = "black")) %>% #' add_trace(y = ~uempmed, mode = "markers+lines") %>% -#' add_lines(y = ~psavert) -#' -#' plot_ly(economics, x = ~date) %>% -#' add_lines(y = ~uempmed) %>% -#' add_lines(y = ~fitted(loess(uempmed ~ as.numeric(date)))) -#' -#' p <- plot_ly(economics, x = ~date, y = ~uempmed) -#' # add a loess smoother -#' p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) -#' # add a title -#' p3 <- layout(p2, title = "Median duration of unemployment (in weeks)") -#' # change the font -#' layout(p3, font = list(family = "Courier New, monospace")) -#' +#' add_lines(y = ~psavert) %>% +#' layout(title = "Setting global trace attributes") #' -#' # using the color argument -#' plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, mode = "markers") -#' # smooth gradient between 5 colors -#' plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, -#' colors = terrain.colors(5), mode = "markers") -#' -#' # function to extract the decade of a given date -#' decade <- function(x) { -#' factor(floor(as.numeric(format(x, "%Y")) / 10) * 10) -#' } -#' plot_ly(economics, x = ~unemploy / pop, color = ~decade(date), type = "box") -#' -#' plot_ly(economics, x = ~date, y = ~unemploy / pop, linetype = ~decade(date)) -#' -#' # sometimes, a data frame isn't fit for the use case... -#' # for 3D surface plots, a numeric matrix is more natural -#' plot_ly(z = volcano, type = "surface") +#' # Attributes are documented in the figure reference -> https://plot.ly/r/reference +#' # You might notice plot_ly() has named arguments that aren't in the figure +#' # reference. These arguments make it easier to map abstract data values to +#' # visual attributes. +#' p <- plot_ly(iris, x = ~Sepal.Width, y = ~Sepal.Length) +#' add_markers(p, color = ~Petal.Length, size = ~Petal.Length) +#' add_markers(p, color = ~Species) +#' add_markers(p, color = ~Species, colors = "Set1") +#' add_markers(p, symbol = ~Species) +#' add_paths(p, linetype = ~Species) #' #' } #' plot_ly <- function(data = data.frame(), ..., type = NULL, - color, colors = NULL, symbol, symbols = NULL, size, - linetype, linetypes = NULL, + color, colors = NULL, symbol, symbols = NULL, + size, sizes = c(10, 100), linetype, linetypes = NULL, width = NULL, height = NULL, source = "A") { # "native" plotly arguments attrs <- list(...) @@ -105,6 +98,7 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, attrs$colors <- colors attrs$symbols <- symbols attrs$linetypes <- linetypes + attrs$sizes <- sizes attrs$type <- type # id for tracking attribute mappings and finding the most current data diff --git a/R/plotly_build.R b/R/plotly_build.R index 4f9d389954..789ab58b40 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -89,6 +89,7 @@ plotly_build.plotly <- function(p) { # TODO: should non-formula object names populate titles? colorTitle <- unlist(lapply(p$x$attrs, "[[", "color"))[[1]] dats <- mapColor(dats, title = sub("^~", "", deparse2(colorTitle))) + dats <- mapSize(dats) dats <- mapSymbol(dats) dats <- mapLinetype(dats) @@ -97,7 +98,11 @@ plotly_build.plotly <- function(p) { for (i in seq_along(dats)) { d <- dats[[i]] # no longer need these special variable mapping attributes - for (j in c("color", "colors", "symbol", "symbols", "linetype", "linetypes")) { + specialAttrs <- c( + "color", "colors", "symbol", "symbols", + "linetype", "linetypes", "size", "sizes" + ) + for (j in specialAttrs) { dats[[i]][[j]] <- NULL } params <- list( @@ -148,6 +153,49 @@ plotly_build.plotly <- function(p) { verify_arrays(p) } + +mapSize <- function(traces) { + sizeList <- lapply(traces, "[[", "size") + nSizes <- lengths(sizeList) + # if no "top-level" color is present, return traces untouched + if (all(nSizes == 0)) { + return(traces) + } + allSize <- unlist(compact(sizeList)) + if (!is.null(allSize) && is.discrete(allSize)) { + stop("Size must be mapped to a numeric variable", + "symbols only make sense for discrete variables", call. = FALSE) + } + sizeRange <- range(allSize, na.rm = TRUE) + + types <- vapply(traces, function(tr) tr$type, character(1)) + modes <- vapply(traces, function(tr) tr$mode, character(1)) + hasMarker <- has_marker(types, modes) + hasLine <- has_line(types, modes) + hasText <- has_text(types, modes) + + for (i in which(nSizes > 0)) { + sizeI <- scales::rescale(sizeList[[i]], from = sizeRange, to = traces[[1]]$sizes) + traces[[i]]$marker <- modify_list( + list(size = sizeI, sizemode = "area"), + traces[[i]]$marker + ) + if (hasLine[[i]]) { + warning( + "Can't map size to lines since plotly.js doesn't yet support line.width arrays", + call. = FALSE + ) + } + if (hasText[[i]]) { + warning( + "Can't map size to text since plotly.js doesn't yet support textfont.size arrays", + call. = FALSE + ) + } + } + traces +} + # appends a new (empty) trace to generate (plot-wide) colorbar/colorscale mapColor <- function(traces, title = "", na.color = "transparent") { color <- lapply(traces, "[[", "color") @@ -158,7 +206,6 @@ mapColor <- function(traces, title = "", na.color = "transparent") { } isNumeric <- vapply(color, is.numeric, logical(1)) isDiscrete <- vapply(color, is.discrete, logical(1)) - # color/colorscale/colorbar attribute placement depends on trace type and marker mode types <- vapply(traces, function(tr) tr$type, character(1)) modes <- vapply(traces, function(tr) tr$mode, character(1)) @@ -280,8 +327,13 @@ mapSymbol <- function(traces) { } # symbol values are duplicated (there is a valid numeric and character string for each symbol) validSymbols <- as.character(Schema$traces$scatter$attributes$marker$symbol$values) - symbols <- unique(unlist(lapply(traces, "[[", "symbols"))) %||% - grep("[0-9]", validSymbols, invert = TRUE, value = TRUE) + # give a sensible ordering the valid symbols so that we map + # to a palette that can be easily perceived + symbolPalette <- c( + 'circle', 'cross', 'diamond', 'square', 'triangle-down', + 'triangle-left', 'triangle-right', 'triangle-up' + ) + symbols <- unique(unlist(traces[[1]]$symbols)) %||% symbolPalette illegalSymbols <- setdiff(symbols, validSymbols) if (length(illegalSymbols)) { stop("The following are not valid symbol codes:\n", diff --git a/man/add_lines.Rd b/man/add_lines.Rd index 297ddeb890..5fa1907ae9 100644 --- a/man/add_lines.Rd +++ b/man/add_lines.Rd @@ -7,6 +7,6 @@ add_lines(p, ...) } \description{ -Add lines to a plotly vis +Equivalent to \code{add_paths}, but with the x-values sorted. } diff --git a/man/add_paths.Rd b/man/add_paths.Rd new file mode 100644 index 0000000000..a85e143124 --- /dev/null +++ b/man/add_paths.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add.R +\name{add_paths} +\alias{add_paths} +\title{Add paths to a plotly vis} +\usage{ +add_paths(p, ...) +} +\description{ +Add paths to a plotly vis +} + diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index cdf7486b85..3109651a53 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -5,8 +5,8 @@ \title{Initiate a plotly visualization} \usage{ plot_ly(data = data.frame(), ..., type = NULL, color, colors = NULL, - symbol, symbols = NULL, size, linetype, linetypes = NULL, width = NULL, - height = NULL, source = "A") + symbol, symbols = NULL, size, sizes = c(10, 100), linetype, + linetypes = NULL, width = NULL, height = NULL, source = "A") } \arguments{ \item{data}{A data frame (optional).} @@ -29,6 +29,8 @@ or a color interpolation function like \code{colorRamp()}.} \item{size}{A variable name or numeric vector to encode the size of markers.} +\item{sizes}{a numeric vector of length 2 used to scale sizes to pixels.} + \item{linetype}{Either a variable name or a (discrete) vector to use for linetype encoding.} \item{linetypes}{A character vector of line types. For possible values, see \link{schema}.} @@ -49,32 +51,46 @@ Reference section (see below). \examples{ \dontrun{ -# If you don't explicitly add a trace, via add_trace() or similar, -# plot_ly() will add one for you, and infer an appropriate trace type +# plot_ly() tries to create a sensible plot based on the information you +# give it. If you don't provide a trace type, plot_ly() will infer one. plot_ly(economics, x = ~pop) plot_ly(economics, x = ~date, y = ~pop) +# plot_ly() doesn't require data frame(s), which allows one to take +# advantage of trace type(s) designed specifically for numeric matrices +plot_ly(z = volcano) +plot_ly(z = volcano, type = "surface") + +# plotly has a functional interface: every plotly function takes a plotly +# object as it's first input argument and returns a modified plotly object +add_points(plot_ly(economics, x = ~date, y = ~unemploy/pop)) -# Attributes set in plot_ly() define 'global' attributes that +# To make code more readable, plotly imports the pipe operator from magrittr +economics \%>\% plot_ly(x = ~date, y = ~unemploy/pop) \%>\% add_points() + +# Attributes defined via plot_ly() set 'global' attributes that # are carried onto subsequent traces plot_ly(economics, x = ~date, line = list(color = "black")) \%>\% add_trace(y = ~uempmed, mode = "markers+lines") \%>\% - add_lines(y = ~psavert) - -plot_ly(economics, x = ~date) \%>\% - add_lines(y = ~uempmed) \%>\% - add_lines(y = ~fitted(loess(uempmed ~ as.numeric(date)))) + add_lines(y = ~psavert) \%>\% + layout(title = "Setting global trace attributes") + +# Attributes are documented in the figure reference -> https://plot.ly/r/reference +# You might notice plot_ly() has named arguments that aren't in the figure +# reference. These arguments make it easier to map abstract data values to +# visual attributes. +p <- plot_ly(iris, x = ~Sepal.Width, y = ~Sepal.Length) +add_markers(p, color = ~Petal.Length) +add_markers(p, color = ~Species) +add_markers(p, color = ~Species, colors = "Set1") +add_paths(p, line = ~Species) -p <- plot_ly(economics, x = ~date, y = ~uempmed) -# add a loess smoother -p2 <- add_trace(p, y = ~fitted(loess(uempmed ~ as.numeric(date)))) -# add a title -p3 <- layout(p2, title = "Median duration of unemployment (in weeks)") -# change the font -layout(p3, font = list(family = "Courier New, monospace")) - + + + plot_ly(economics, x = ~date) \%>\% + add_lines(y = ~uempmed) \%>\% + add_lines(y = ~fitted(loess(uempmed ~ as.numeric(date)))) \%>\% + layout(title = "Median duration of unemployment (in weeks)") -# using the color argument -plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, mode = "markers") # smooth gradient between 5 colors plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, colors = terrain.colors(5), mode = "markers") @@ -87,10 +103,6 @@ plot_ly(economics, x = ~unemploy / pop, color = ~decade(date), type = "box") plot_ly(economics, x = ~date, y = ~unemploy / pop, linetype = ~decade(date)) -# sometimes, a data frame isn't fit for the use case... -# for 3D surface plots, a numeric matrix is more natural -plot_ly(z = volcano, type = "surface") - } } diff --git a/man/plotly-data.Rd b/man/plotly-data.Rd index 404692fc59..11f11aa837 100644 --- a/man/plotly-data.Rd +++ b/man/plotly-data.Rd @@ -16,29 +16,29 @@ \alias{ungroup.plotly} \title{Data manipulation verbs for plotly.} \usage{ -groups.plotly(x) +\method{groups}{plotly}(x) \method{group_by_}{plotly}(.data, ..., .dots, add = FALSE) -ungroup.plotly(x) +\method{ungroup}{plotly}(x) -summarise_.plotly(.data, ..., .dots) +\method{summarise_}{plotly}(.data, ..., .dots) -mutate_.plotly(.data, ..., .dots) +\method{mutate_}{plotly}(.data, ..., .dots) \method{arrange_}{plotly}(.data, ..., .dots) -select_.plotly(.data, ..., .dots) +\method{select_}{plotly}(.data, ..., .dots) -filter_.plotly(.data, ..., .dots) +\method{filter_}{plotly}(.data, ..., .dots) \method{distinct_}{plotly}(.data, ..., .dots) -slice_.plotly(.data, ..., .dots) +\method{slice_}{plotly}(.data, ..., .dots) -rename_.plotly(.data, ..., .dots) +\method{rename_}{plotly}(.data, ..., .dots) -transmute_.plotly(.data, ..., .dots) +\method{transmute_}{plotly}(.data, ..., .dots) } \description{ Data manipulation verbs for plotly. diff --git a/man/plotly_data.Rd b/man/plotly_data.Rd index b8087dff52..f7879f36bd 100644 --- a/man/plotly_data.Rd +++ b/man/plotly_data.Rd @@ -18,29 +18,29 @@ \usage{ plotly_data(p, id = p$x$cur_data) -groups.plotly(x) +\method{groups}{plotly}(x) \method{group_by_}{plotly}(.data, ..., .dots, add = FALSE) -ungroup.plotly(x) +\method{ungroup}{plotly}(x) -summarise_.plotly(.data, ..., .dots) +\method{summarise_}{plotly}(.data, ..., .dots) -mutate_.plotly(.data, ..., .dots) +\method{mutate_}{plotly}(.data, ..., .dots) \method{arrange_}{plotly}(.data, ..., .dots) -select_.plotly(.data, ..., .dots) +\method{select_}{plotly}(.data, ..., .dots) -filter_.plotly(.data, ..., .dots) +\method{filter_}{plotly}(.data, ..., .dots) \method{distinct_}{plotly}(.data, ..., .dots) -slice_.plotly(.data, ..., .dots) +\method{slice_}{plotly}(.data, ..., .dots) -rename_.plotly(.data, ..., .dots) +\method{rename_}{plotly}(.data, ..., .dots) -transmute_.plotly(.data, ..., .dots) +\method{transmute_}{plotly}(.data, ..., .dots) } \description{ \code{plotly_data()} returns the data associated with diff --git a/tests/testthat/test-plotly.R b/tests/testthat/test-plotly.R index 2039433bc0..fb3387c616 100644 --- a/tests/testthat/test-plotly.R +++ b/tests/testthat/test-plotly.R @@ -93,17 +93,18 @@ test_that("axis titles get attached to scene object for 3D plots", { expect_identical(scene$zaxis$title, "Sepal.Width") }) -test_that("inheriting properties works as expected", { - library(dplyr) - p <- iris %>% - count(Species) %>% - plot_ly(x = ~Species, y = ~n, opacity = 0.5, type = "bar") %>% - layout(barmode = "overlay", showlegend = FALSE) - s <- count(iris[sample(nrow(iris), 10), ], Species) - p2 <- add_trace(p, data = s) - l <- plotly_build(p2) - expect_equal(l$data[[2]]$opacity, 0.5) - expect_true(all(l$data[[1]]$y > l$data[[2]]$y)) +test_that("type inference + add_data + layering works as expected", { +p <- plot_ly(iris, x = ~Species) %>% + add_trace(opacity = 0.3) %>% + add_data(iris[sample(nrow(iris), 10), ]) %>% + add_trace() %>% + layout(barmode = "overlay") + l <- expect_traces(p, 2, "bar-inference") + types <- unique(unlist(lapply(l$data, "[[", "type"))) + expect_equal(types, "histogram") + expect_equal(l$data[[1]]$opacity, 0.3) + expect_equal(l$layout$barmode, "overlay") + expect_true(length(l$data[[1]]$x) > length(l$data[[2]]$x)) }) test_that("x/y/z properties have a class of AsIs", { From b4d482d2f4a3627f197da365dc2c24066b74220d Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 17 Jun 2016 15:19:16 -0500 Subject: [PATCH 26/73] fix NAMESPACE --- NAMESPACE | 24 ++++++++++++------------ man/plot_ly.Rd | 24 +++--------------------- man/plotly-data.Rd | 24 ++++++++++++------------ man/plotly_data.Rd | 24 ++++++++++++------------ 4 files changed, 39 insertions(+), 57 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 78cf0d3f44..4d00ceaa02 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,8 +1,5 @@ # Generated by roxygen2: do not edit by hand -S3method(arrange_,plotly) -S3method(distinct_,plotly) -S3method(filter_,plotly) S3method(geom2trace,GeomBar) S3method(geom2trace,GeomBlank) S3method(geom2trace,GeomBoxplot) @@ -16,19 +13,12 @@ S3method(geom2trace,GeomTile) S3method(geom2trace,default) S3method(ggplotly,ggmatrix) S3method(ggplotly,ggplot) -S3method(group_by_,plotly) -S3method(groups,plotly) S3method(layout,matrix) S3method(layout,plotly) -S3method(mutate_,plotly) S3method(plotly_build,gg) S3method(plotly_build,list) S3method(plotly_build,plotly) S3method(print,plotly_figure) -S3method(rename_,plotly) -S3method(select_,plotly) -S3method(slice_,plotly) -S3method(summarise_,plotly) S3method(to_basic,GeomAbline) S3method(to_basic,GeomArea) S3method(to_basic,GeomBoxplot) @@ -54,8 +44,6 @@ S3method(to_basic,GeomTile) S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) S3method(to_basic,default) -S3method(transmute_,plotly) -S3method(ungroup,plotly) export("%>%") export(add_data) export(add_lines) @@ -65,18 +53,24 @@ export(add_polygons) export(add_ribbons) export(add_text) export(add_trace) +export(arrange_.plotly) export(as.widget) export(config) +export(distinct_.plotly) export(embed_notebook) export(event_data) export(export) +export(filter_.plotly) export(geom2trace) export(get_figure) export(gg2list) export(ggplotly) export(group_by) +export(group_by_.plotly) +export(groups.plotly) export(knit_print.plotly_figure) export(layout) +export(mutate_.plotly) export(offline) export(plot_ly) export(plotly) @@ -87,14 +81,20 @@ export(plotly_build) export(plotly_data) export(plotly_empty) export(plotly_json) +export(rename_.plotly) export(renderPlotly) export(schema) +export(select_.plotly) export(signup) +export(slice_.plotly) export(style) export(subplot) +export(summarise_.plotly) export(toRGB) export(toWebGL) export(to_basic) +export(transmute_.plotly) +export(ungroup.plotly) import(ggplot2) importFrom(base64enc,base64encode) importFrom(dplyr,arrange_) diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index 3109651a53..d43ee9f7b7 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -79,29 +79,11 @@ plot_ly(economics, x = ~date, line = list(color = "black")) \%>\% # reference. These arguments make it easier to map abstract data values to # visual attributes. p <- plot_ly(iris, x = ~Sepal.Width, y = ~Sepal.Length) -add_markers(p, color = ~Petal.Length) +add_markers(p, color = ~Petal.Length, size = ~Petal.Length) add_markers(p, color = ~Species) add_markers(p, color = ~Species, colors = "Set1") -add_paths(p, line = ~Species) - - - - plot_ly(economics, x = ~date) \%>\% - add_lines(y = ~uempmed) \%>\% - add_lines(y = ~fitted(loess(uempmed ~ as.numeric(date)))) \%>\% - layout(title = "Median duration of unemployment (in weeks)") - -# smooth gradient between 5 colors -plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop, - colors = terrain.colors(5), mode = "markers") - -# function to extract the decade of a given date -decade <- function(x) { - factor(floor(as.numeric(format(x, "\%Y")) / 10) * 10) -} -plot_ly(economics, x = ~unemploy / pop, color = ~decade(date), type = "box") - -plot_ly(economics, x = ~date, y = ~unemploy / pop, linetype = ~decade(date)) +add_markers(p, symbol = ~Species) +add_paths(p, linetype = ~Species) } diff --git a/man/plotly-data.Rd b/man/plotly-data.Rd index 11f11aa837..15472f78f6 100644 --- a/man/plotly-data.Rd +++ b/man/plotly-data.Rd @@ -16,29 +16,29 @@ \alias{ungroup.plotly} \title{Data manipulation verbs for plotly.} \usage{ -\method{groups}{plotly}(x) +groups.plotly(x) -\method{group_by_}{plotly}(.data, ..., .dots, add = FALSE) +group_by_.plotly(.data, ..., .dots, add = FALSE) -\method{ungroup}{plotly}(x) +ungroup.plotly(x) -\method{summarise_}{plotly}(.data, ..., .dots) +summarise_.plotly(.data, ..., .dots) -\method{mutate_}{plotly}(.data, ..., .dots) +mutate_.plotly(.data, ..., .dots) -\method{arrange_}{plotly}(.data, ..., .dots) +arrange_.plotly(.data, ..., .dots) -\method{select_}{plotly}(.data, ..., .dots) +select_.plotly(.data, ..., .dots) -\method{filter_}{plotly}(.data, ..., .dots) +filter_.plotly(.data, ..., .dots) -\method{distinct_}{plotly}(.data, ..., .dots) +distinct_.plotly(.data, ..., .dots) -\method{slice_}{plotly}(.data, ..., .dots) +slice_.plotly(.data, ..., .dots) -\method{rename_}{plotly}(.data, ..., .dots) +rename_.plotly(.data, ..., .dots) -\method{transmute_}{plotly}(.data, ..., .dots) +transmute_.plotly(.data, ..., .dots) } \description{ Data manipulation verbs for plotly. diff --git a/man/plotly_data.Rd b/man/plotly_data.Rd index f7879f36bd..d45f8732ac 100644 --- a/man/plotly_data.Rd +++ b/man/plotly_data.Rd @@ -18,29 +18,29 @@ \usage{ plotly_data(p, id = p$x$cur_data) -\method{groups}{plotly}(x) +groups.plotly(x) -\method{group_by_}{plotly}(.data, ..., .dots, add = FALSE) +group_by_.plotly(.data, ..., .dots, add = FALSE) -\method{ungroup}{plotly}(x) +ungroup.plotly(x) -\method{summarise_}{plotly}(.data, ..., .dots) +summarise_.plotly(.data, ..., .dots) -\method{mutate_}{plotly}(.data, ..., .dots) +mutate_.plotly(.data, ..., .dots) -\method{arrange_}{plotly}(.data, ..., .dots) +arrange_.plotly(.data, ..., .dots) -\method{select_}{plotly}(.data, ..., .dots) +select_.plotly(.data, ..., .dots) -\method{filter_}{plotly}(.data, ..., .dots) +filter_.plotly(.data, ..., .dots) -\method{distinct_}{plotly}(.data, ..., .dots) +distinct_.plotly(.data, ..., .dots) -\method{slice_}{plotly}(.data, ..., .dots) +slice_.plotly(.data, ..., .dots) -\method{rename_}{plotly}(.data, ..., .dots) +rename_.plotly(.data, ..., .dots) -\method{transmute_}{plotly}(.data, ..., .dots) +transmute_.plotly(.data, ..., .dots) } \description{ \code{plotly_data()} returns the data associated with From f201bcc7d12428fbc089b1b5afa45eaab83c6c22 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 08:40:44 -0500 Subject: [PATCH 27/73] remove redundant R/dplyr.R --- R/dplyr.R | 155 ------------------------------------------------------ 1 file changed, 155 deletions(-) delete mode 100644 R/dplyr.R diff --git a/R/dplyr.R b/R/dplyr.R deleted file mode 100644 index ad78661202..0000000000 --- a/R/dplyr.R +++ /dev/null @@ -1,155 +0,0 @@ -#' Data manipulation verbs for plotly. -#' -#' @name plotly-data -#' @keywords internal -#' @examples -#' -#' # loading dplyr is super important! -#' library(dplyr) -#' -#' mtcars %>% -#' plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") %>% -#' filter(cyl == 4) %>% -#' add_markers(x = ~wt, y = ~mpg, name = "filtered points", -#' marker = list(color = "red")) -#' -#' library(tidyr) -#' economics %>% -#' gather(variable, value, -date) %>% -#' group_by(variable) %>% -#' plot_ly(x = ~date, y = ~value) -#' -#' -#' -#' -NULL - -#' @export -#' @rdname plotly-data -groups.plotly <- function(x) { - dplyr::groups(plotly_data(x)) -} - -#' @export -#' @rdname plotly-data -group_by_.plotly <- function(.data, ..., .dots, add = FALSE) { - d <- plotly_data(.data) - d <- dplyr::group_by_(d, .dots = lazyeval::all_dots(.dots, ...), add = add) - # TODO: where to use group2NA? In plotly_build() - add_data(.data, d) -} - -#' @export -#' @rdname plotly-data -ungroup.plotly <- function(x) { - dplyr::ungroup(plotly_data(x)) -} - -#' @rdname plotly-data -#' @export -summarise_.plotly <- function(.data, ..., .dots) { - d <- plotly_data(.data) - d <- dplyr::summarise_(d, .dots = lazyeval::all_dots(.dots, ...)) - add_data(.data, d) -} - -#' @rdname plotly-data -#' @export -mutate_.plotly <- function(.data, ..., .dots) { - d <- plotly_data(.data) - d <- dplyr::mutate_(d, .dots = lazyeval::all_dots(.dots, ...)) - add_data(.data, d) -} - -#' @rdname plotly-data -#' @export -arrange_.plotly <- function(.data, ..., .dots) { - d <- plotly_data(.data) - d <- dplyr::arrange_(d, .dots = lazyeval::all_dots(.dots, ...)) - add_data(.data, d) -} - -#' @rdname plotly-data -#' @export -select_.plotly <- function(.data, ..., .dots) { - d <- plotly_data(.data) - d <- dplyr::select_(d, .dots = lazyeval::all_dots(.dots, ...)) - add_data(.data, d) -} - -#' @rdname plotly-data -#' @export -filter_.plotly <- function(.data, ..., .dots) { - d <- plotly_data(.data) - d <- dplyr::filter_(d, .dots = lazyeval::all_dots(.dots, ...)) - add_data(.data, d) -} - -#' @rdname plotly-data -#' @export -distinct_.plotly <- function(.data, ..., .dots) { - d <- plotly_data(.data) - d <- dplyr::distinct_(d, ..., .dots, add = add) - add_data(.data, d) -} - -#' @rdname plotly-data -#' @export -slice_.plotly <- function(.data, ..., .dots) { - d <- plotly_data(.data) - d <- dplyr::slice_(d, ..., .dots, add = add) - add_data(.data, d) -} - -#' @rdname plotly-data -#' @export -rename_.plotly <- function(.data, ..., .dots) { - d <- plotly_data(.data) - d <- dplyr::rename_(d, ..., .dots, add = add) - add_data(.data, d) -} - -#' @rdname plotly-data -#' @export -transmute_.plotly <- function(.data, ..., .dots) { - d <- plotly_data(.data) - d <- dplyr::transmute_(d, ..., .dots, add = add) - add_data(.data, d) -} - -#' Insert missing values to create trace groupings -#' -#' If a group of traces share the same non-positional characteristics (i.e., -#' color, fill, etc), it is more efficient to draw them as a single trace -#' with missing values that separate the groups (instead of multiple traces). -#' This is a helper function for inserting missing values into a data set -#' -#' @param data a data frame. -#' @param groupNames name(s) of the grouping variable(s) as a character vector -#' @param nested other variables that group should be nested -#' (i.e., ordered) within. -#' @param retrace.first should the first row of each group be appended to the -#' last row? This is useful for enclosing polygons with lines. -#' @examples -#' elong <- tidyr::gather(economics, variable, value, -date) -#' plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) -#' - -group2NA <- function(data, groupNames = "group", nested = NULL, - retrace.first = inherits(data, "GeomPolygon")) { - if (nrow(data) == 0) return(data) - nested <- nested[nested %in% names(data)] - if (length(nested)) { - data <- dplyr::arrange_(data, nested) - } - d <- dplyr::group_by_(data, groupNames) - d <- if (retrace.first) { - dplyr::do(d, rbind(., .[1,], NA)) - } else { - dplyr::do(d, rbind(., NA)) - } - d <- tidyr::unnest(d) - n <- nrow(d) - if (all(is.na(d[n, ]))) d <- d[-n, ] - structure(d, class = unique(class(data), class(d))) -} From 653a58468234482d7244f004acd564f2d604d615 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 10:04:04 -0500 Subject: [PATCH 28/73] fix grouping within multiple traces; fix axis titles; fix hovermode defaults --- R/plotly_build.R | 63 ++++++++++++++++++++++++++++++++---------------- R/plotly_data.R | 23 +++++++++++------- R/utils.R | 12 +++++++++ 3 files changed, 68 insertions(+), 30 deletions(-) diff --git a/R/plotly_build.R b/R/plotly_build.R index 789ab58b40..85a786f8e3 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -61,21 +61,36 @@ plotly_build.plotly <- function(p) { if (length(idx) == 1) { title <- sub("^~", "", deparse2(x[[idx]])) if (is3d(x$type)) { - p$x$layout$scene[[nm]]$title <- title + p$x$layout$scene[[nm]]$title <<- title } else { - p$x$layout[[nm]]$title <- title + p$x$layout[[nm]]$title <<- title } } } # perform the evaluation d <- plotly_data(p, y) + grps <- dplyr::groups(d) + if (length(grps)) { + # in order to do grouping _within trace_ correctly, we need to know about + # variables that transform one trace into multiple traces + nestedVars <- list() + for (i in c("symbol", "linetype", "color")) { + newVar <- eval_attr(x[[i]], d) + if (is.null(newVar) || i == "color" && !is.discrete(newVar)) next + id <- paste0("x", new_id()) + nestedVars[[id]] <- i + d[[id]] <- newVar + } + d <- group2NA(d, as.character(grps), names(nestedVars)) + } + x <- rapply(x, eval_attr, data = d, how = "list") + # ensure we have a trace type x <- verify_type(x) attrLengths <- lengths(x) - # if appropriate, set the mode now since we need to reference it later if (grepl("scatter", x$type) && is.null(x$mode)) { x$mode <- if (any(attrLengths > 20)) "lines" else "markers+lines" @@ -85,24 +100,25 @@ plotly_build.plotly <- function(p) { }, p$x$attrs, names(p$x$attrs)) - # "transforms" (i.e., apply scaling to) for special arguments - # TODO: should non-formula object names populate titles? + # "transforms" of (i.e., apply scaling to) special arguments + # IMPORTANT: these should be applied at the plot-level colorTitle <- unlist(lapply(p$x$attrs, "[[", "color"))[[1]] - dats <- mapColor(dats, title = sub("^~", "", deparse2(colorTitle))) - dats <- mapSize(dats) - dats <- mapSymbol(dats) - dats <- mapLinetype(dats) + dats <- map_color(dats, title = sub("^~", "", deparse2(colorTitle))) + dats <- map_size(dats) + dats <- map_symbol(dats) + dats <- map_linetype(dats) # traceify by the interaction of discrete variables + # although I hate this programming pattern, it seems necessary since we don't + # know how many traces we need traces <- list() for (i in seq_along(dats)) { d <- dats[[i]] - # no longer need these special variable mapping attributes - specialAttrs <- c( + mappingAttrs <- c( "color", "colors", "symbol", "symbols", "linetype", "linetypes", "size", "sizes" ) - for (j in specialAttrs) { + for (j in mappingAttrs) { dats[[i]][[j]] <- NULL } params <- list( @@ -151,10 +167,11 @@ plotly_build.plotly <- function(p) { # annotations & shapes must be an array of objects # TODO: should we add anything else to this? verify_arrays(p) + # set a sensible hovermode if it hasn't been specified already + verify_hovermode(p) } - -mapSize <- function(traces) { +map_size <- function(traces) { sizeList <- lapply(traces, "[[", "size") nSizes <- lengths(sizeList) # if no "top-level" color is present, return traces untouched @@ -169,7 +186,7 @@ mapSize <- function(traces) { sizeRange <- range(allSize, na.rm = TRUE) types <- vapply(traces, function(tr) tr$type, character(1)) - modes <- vapply(traces, function(tr) tr$mode, character(1)) + modes <- vapply(traces, function(tr) tr$mode %||% "lines", character(1)) hasMarker <- has_marker(types, modes) hasLine <- has_line(types, modes) hasText <- has_text(types, modes) @@ -197,7 +214,7 @@ mapSize <- function(traces) { } # appends a new (empty) trace to generate (plot-wide) colorbar/colorscale -mapColor <- function(traces, title = "", na.color = "transparent") { +map_color <- function(traces, title = "", na.color = "transparent") { color <- lapply(traces, "[[", "color") nColors <- lengths(color) # if no "top-level" color is present, return traces untouched @@ -206,9 +223,12 @@ mapColor <- function(traces, title = "", na.color = "transparent") { } isNumeric <- vapply(color, is.numeric, logical(1)) isDiscrete <- vapply(color, is.discrete, logical(1)) + if (any(isNumeric & isDiscrete)) { + stop("Can't have both discrete and numeric color mappings", call. = FALSE) + } # color/colorscale/colorbar attribute placement depends on trace type and marker mode types <- vapply(traces, function(tr) tr$type, character(1)) - modes <- vapply(traces, function(tr) tr$mode, character(1)) + modes <- vapply(traces, function(tr) tr$mode %||% "lines", character(1)) hasMarker <- has_marker(types, modes) hasLine <- has_line(types, modes) hasText <- has_text(types, modes) @@ -222,7 +242,7 @@ mapColor <- function(traces, title = "", na.color = "transparent") { rng <- range(allColor, na.rm = TRUE) colScale <- scales::col_numeric(palette, rng, na.color = na.color) # generate the colorscale to be shared across traces - vals <- if (diff(rng) > 0) as.numeric(quantile(allColor)) else c(0, 1) + vals <- if (diff(rng) > 0) as.numeric(quantile(allColor, na.rm = TRUE)) else c(0, 1) colorScale <- matrix(c(scales::rescale(vals), colScale(vals)), ncol = 2) colorObj <- list( colorbar = list(title = as.character(title), ticklen = 2), @@ -306,7 +326,7 @@ mapColor <- function(traces, title = "", na.color = "transparent") { traces } -mapSymbol <- function(traces) { +map_symbol <- function(traces) { symbolList <- lapply(traces, "[[", "symbol") nSymbols <- lengths(symbolList) # if no "top-level" symbol is present, return traces untouched @@ -354,7 +374,7 @@ mapSymbol <- function(traces) { traces } -mapLinetype <- function(traces) { +map_linetype <- function(traces) { linetypeList <- lapply(traces, "[[", "linetype") nLinetypes <- lengths(linetypeList) # if no "top-level" linetype is present, return traces untouched @@ -401,10 +421,11 @@ mapLinetype <- function(traces) { # a particular key name traceify <- function(dat, x = NULL) { if (length(x) == 0) return(list(dat)) + lvls <- if (is.factor(x)) levels(x) else unique(x) # the order of lvls determines the order in which traces are drawn # for ordered factors at least, it makes sense to draw the highest level first # since that _should_ be the darkest color in a sequential pallette - lvls <- if (is.factor(x)) rev(levels(x)) else unique(x) + if (is.ordered(x)) lvls <- rev(lvls) n <- length(x) # recursively search for a non-list of appropriate length (if it is, subset it) recurse <- function(z, n, idx) { diff --git a/R/plotly_data.R b/R/plotly_data.R index 3b1f6e71dd..0e4cb33d05 100644 --- a/R/plotly_data.R +++ b/R/plotly_data.R @@ -152,6 +152,9 @@ transmute_.plotly <- function(.data, ..., .dots) { #' @param retrace.first should the first row of each group be appended to the #' last row? This is useful for enclosing polygons with lines. #' @examples +#' +#' group2NA(mtcars, "vs", "cyl") +#' #' elong <- tidyr::gather(economics, variable, value, -date) #' plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) #' @@ -159,18 +162,20 @@ transmute_.plotly <- function(.data, ..., .dots) { group2NA <- function(data, groupNames = "group", nested = NULL, retrace.first = inherits(data, "GeomPolygon")) { if (nrow(data) == 0) return(data) - nested <- nested[nested %in% names(data)] - if (length(nested)) { - data <- dplyr::arrange_(data, nested) + # arrange + group_by + vars <- c(nested, groupNames) + data <- data[do.call(order, data[, vars]), ] + for (i in vars) { + data <- dplyr::group_by_(data, i, add = TRUE) } - d <- dplyr::group_by_(data, groupNames) d <- if (retrace.first) { - dplyr::do(d, rbind(., .[1,], NA)) + dplyr::do(data, rbind(., .[1,], NA)) } else { - dplyr::do(d, rbind(., NA)) + dplyr::do(data, rbind(., NA)) } - d <- tidyr::unnest(d, groupNames) - n <- nrow(d) - if (all(is.na(d[n, !groupNames %in% names(d)]))) d <- d[-n, ] + #d <- tidyr::unnest(d, vars) + d <- d[, names(d) %in% names(data)] + n <- NROW(d) + if (all(is.na(d[n, ]))) d <- d[-n, ] structure(d, class = unique(class(data), class(d))) } diff --git a/R/utils.R b/R/utils.R index de4fe1427f..fea74694a2 100644 --- a/R/utils.R +++ b/R/utils.R @@ -207,6 +207,18 @@ verify_arrays <- function(p) { p } +verify_hovermode <- function(p) { + if (!is.null(p$x$layout$hovermode)) { + return(p) + } + types <- vapply(p$x$data, function(tr) tr$type, character(1)) + modes <- vapply(p$x$data, function(tr) tr$mode %||% "lines", character(1)) + if (any(grepl("markers", modes) & types == "scatter")) { + p$x$layout$hovermode <- "closest" + } + p +} + has_marker <- function(types, modes) { is_scatter <- grepl("scatter", types) ifelse(is_scatter, grepl("marker", modes), has_attr(types, "marker")) From 2d3f36894932f3d8d395a36f8b5073f3c3175c1f Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 13:11:54 -0500 Subject: [PATCH 29/73] fix has_attr --- R/utils.R | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/R/utils.R b/R/utils.R index fea74694a2..41893c4443 100644 --- a/R/utils.R +++ b/R/utils.R @@ -99,6 +99,7 @@ verify_box <- function(proposed, schema) { identical(attrSchema[["role"]], "object"), error = function(e) FALSE ) + if (isArray) { proposed[[attr]] <- i(attrVal) } @@ -234,12 +235,9 @@ has_text <- function(types, modes) { ifelse(is_scatter, grepl("text", modes), has_attr(types, "textfont")) } -has_attr <- function(types, attr) { - isMissing <- function(x) { - e <- try(verify_attrs(x, attr), silent = TRUE) - inherits(e, "try-error") - } - !vapply(types, isMissing, logical(1), USE.NAMES = FALSE) +has_attr <- function(types, attr = "marker") { + if (length(attr) != 1) stop("attr must be of length 1") + vapply(types, function(x) attr %in% names(Schema$traces[[x]]$attributes), logical(1)) } has_legend <- function(p) { From ec48625d2d7ebb0beb8b0937fca5981170e3c805 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 13:12:15 -0500 Subject: [PATCH 30/73] fix uniq --- R/ggplotly.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/R/ggplotly.R b/R/ggplotly.R index 6d7ade9027..06e898e9b3 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -846,9 +846,11 @@ faced <- function(txt, face = "plain") { bold <- function(x) paste("", x, "") italic <- function(x) paste("", x, "") -# if a vector has one unique value, return that value +# if a vector that has one unique value (ignoring missings), return that value uniq <- function(x) { u <- unique(x) + if (identical(u, NA) || length(u) == 0) return(u) + u <- u[!is.na(u)] if (length(u) == 1) u else x } @@ -902,7 +904,9 @@ rect2shape <- function(rekt = ggplot2::element_rect()) { # We need access to internal ggplot2 functions in several places # this helps us import functions in a way that R CMD check won't cry about -ggfun <- function(x) getFromNamespace(x, "ggplot2") +ggfun <- function(x) { + tryCatch(getFromNamespace(x, "ggplot2"), error = function(e) NULL) +} ggtype <- function(x, y = "geom") { sub(y, "", tolower(class(x[[y]])[1])) From 3d618ba55061da2f769debd5f8ceb79c4f4ad89a Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 13:13:43 -0500 Subject: [PATCH 31/73] improve group2NA; fix zcolor bugs; improve tests --- R/plotly_build.R | 37 ++++++++++++++++++---------- R/plotly_data.R | 23 +++++++++++++---- tests/testthat/test-plotly-subplot.R | 2 +- tests/testthat/test-plotly.R | 31 ++++++++++++++--------- 4 files changed, 62 insertions(+), 31 deletions(-) diff --git a/R/plotly_build.R b/R/plotly_build.R index 85a786f8e3..16e649d614 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -53,14 +53,13 @@ plotly_build.plotly <- function(p) { } dats <- Map(function(x, y) { - # add sensible axis names to layout for (i in c("x", "y", "z")) { nm <- paste0(i, "axis") idx <- which(names(x) %in% i) if (length(idx) == 1) { title <- sub("^~", "", deparse2(x[[idx]])) - if (is3d(x$type)) { + if (is3d(x$type) || i == "z") { p$x$layout$scene[[nm]]$title <<- title } else { p$x$layout[[nm]]$title <<- title @@ -68,10 +67,13 @@ plotly_build.plotly <- function(p) { } } - # perform the evaluation d <- plotly_data(p, y) + # if the data has groups, insert missing values to introduce gaps grps <- dplyr::groups(d) if (length(grps)) { + if (isTRUE(x$connectgaps)) { + stop("Can't set connectgaps=T in a trace that has 1 or more groups.", call. = FALSE) + } # in order to do grouping _within trace_ correctly, we need to know about # variables that transform one trace into multiple traces nestedVars <- list() @@ -85,9 +87,10 @@ plotly_build.plotly <- function(p) { d <- group2NA(d, as.character(grps), names(nestedVars)) } + # perform the evaluation x <- rapply(x, eval_attr, data = d, how = "list") - # ensure we have a trace type + # ensure we have a trace type (depends on the # of data points) x <- verify_type(x) attrLengths <- lengths(x) @@ -102,7 +105,7 @@ plotly_build.plotly <- function(p) { # "transforms" of (i.e., apply scaling to) special arguments # IMPORTANT: these should be applied at the plot-level - colorTitle <- unlist(lapply(p$x$attrs, "[[", "color"))[[1]] + colorTitle <- unlist(lapply(p$x$attrs, function(x) x$color %||% x$z))[[1]] dats <- map_color(dats, title = sub("^~", "", deparse2(colorTitle))) dats <- map_size(dats) dats <- map_symbol(dats) @@ -159,16 +162,16 @@ plotly_build.plotly <- function(p) { p$x$data <- setNames(p$x$data, NULL) # verify plot attributes are legal according to the plotly.js spec - verify_attr_names(p) + p <- verify_attr_names(p) # box up 'data_array' attributes where appropriate - verify_boxed(p) + p <- verify_boxed(p) # if it makes sense, add markers/lines/text to mode - verify_mode(p) + p <- verify_mode(p) # annotations & shapes must be an array of objects # TODO: should we add anything else to this? - verify_arrays(p) + p <- verify_arrays(p) # set a sensible hovermode if it hasn't been specified already - verify_hovermode(p) + p <- verify_hovermode(p) } map_size <- function(traces) { @@ -215,7 +218,7 @@ map_size <- function(traces) { # appends a new (empty) trace to generate (plot-wide) colorbar/colorscale map_color <- function(traces, title = "", na.color = "transparent") { - color <- lapply(traces, "[[", "color") + color <- lapply(traces, function(x) x$color %||% if (has_attr(x$type, "zmin")) x$z else NULL) nColors <- lengths(color) # if no "top-level" color is present, return traces untouched if (all(nColors == 0)) { @@ -232,7 +235,7 @@ map_color <- function(traces, title = "", na.color = "transparent") { hasMarker <- has_marker(types, modes) hasLine <- has_line(types, modes) hasText <- has_text(types, modes) - hasZ <- !grepl("scatter", types) & + hasZ <- has_attr(types, "zmin") & any(vapply(traces, function(tr) !is.null(tr$z), logical(1))) if (any(isNumeric)) { @@ -242,7 +245,11 @@ map_color <- function(traces, title = "", na.color = "transparent") { rng <- range(allColor, na.rm = TRUE) colScale <- scales::col_numeric(palette, rng, na.color = na.color) # generate the colorscale to be shared across traces - vals <- if (diff(rng) > 0) as.numeric(quantile(allColor, na.rm = TRUE)) else c(0, 1) + vals <- if (diff(rng) > 0) { + as.numeric(quantile(allColor, probs = seq(0, 1, length.out = 25), na.rm = TRUE)) + } else { + c(0, 1) + } colorScale <- matrix(c(scales::rescale(vals), colScale(vals)), ncol = 2) colorObj <- list( colorbar = list(title = as.character(title), ticklen = 2), @@ -265,6 +272,9 @@ map_color <- function(traces, title = "", na.color = "transparent") { traces[[i]]$marker <- modify_list(colorObj, traces[[i]]$marker) } if (hasZ[[i]]) { + colorObj[c("zmin", "zmax")] <- colorObj[c("cmin", "cmax")] + colorObj[c("cmin", "cmax")] <- NULL + colorObj$showscale <- TRUE traces[[i]] <- modify_list(colorObj, traces[[i]]) } if (hasText[[i]]) { @@ -273,6 +283,7 @@ map_color <- function(traces, title = "", na.color = "transparent") { "https://github.com/plotly/plotly.js", call. = FALSE) } } + if (any(hasZ)) return(traces) # add an "empty" trace with the colorbar colorObj$color <- rng colorObj$showscale <- TRUE diff --git a/R/plotly_data.R b/R/plotly_data.R index 0e4cb33d05..2b04201f77 100644 --- a/R/plotly_data.R +++ b/R/plotly_data.R @@ -162,9 +162,18 @@ transmute_.plotly <- function(.data, ..., .dots) { group2NA <- function(data, groupNames = "group", nested = NULL, retrace.first = inherits(data, "GeomPolygon")) { if (nrow(data) == 0) return(data) - # arrange + group_by + # a few workarounds since dplyr clobbers classes that we rely on in ggplotly + retrace <- force(retrace.first) + datClass <- class(data) + # sanitize variable names + groupNames <- groupNames[groupNames %in% names(data)] + nested <- nested[nested %in% names(data)] + # nothing to do if the group var doesn't exist + if (!length(groupNames)) return(data) + # arrange + group_by, ignoring any already existing groups vars <- c(nested, groupNames) - data <- data[do.call(order, data[, vars]), ] + data <- data[do.call(order, data[, vars, drop = FALSE]), ] + data <- dplyr::ungroup(data) for (i in vars) { data <- dplyr::group_by_(data, i, add = TRUE) } @@ -173,9 +182,13 @@ group2NA <- function(data, groupNames = "group", nested = NULL, } else { dplyr::do(data, rbind(., NA)) } - #d <- tidyr::unnest(d, vars) - d <- d[, names(d) %in% names(data)] + # TODO: how to drop the NAs separating the nested values? + # d <- dplyr::ungroup(d) + # for (i in nested) { + # d <- dplyr::group_by_(dplyr::ungroup(d), i, add = TRUE) + # } + # d <- dplyr::do(d, .[seq_len(NROW(.)),]) n <- NROW(d) if (all(is.na(d[n, ]))) d <- d[-n, ] - structure(d, class = unique(class(data), class(d))) + structure(d, class = datClass) } diff --git a/tests/testthat/test-plotly-subplot.R b/tests/testthat/test-plotly-subplot.R index ed1e858dfc..b1f98a80b4 100644 --- a/tests/testthat/test-plotly-subplot.R +++ b/tests/testthat/test-plotly-subplot.R @@ -146,7 +146,7 @@ test_that("geo+cartesian behaves", { # create a map of population density density <- state.x77[, "Population"] / state.x77[, "Area"] map <- plot_ly( - z = density, + z = ~density, text = state.name, locations = state.abb, type = 'choropleth', locationmode = 'USA-states', geo = "geo" ) %>% layout(geo = g) diff --git a/tests/testthat/test-plotly.R b/tests/testthat/test-plotly.R index fb3387c616..0b96b12394 100644 --- a/tests/testthat/test-plotly.R +++ b/tests/testthat/test-plotly.R @@ -1,5 +1,9 @@ context("plot_ly") +test_that("uniq works as expected", { + expect_equal(uniq(c("red", "red", NA)), "red") +}) + expect_traces <- function(p, n.traces, name){ stopifnot(is.numeric(n.traces)) L <- save_outputs(p, paste0("plotly-", name)) @@ -20,10 +24,11 @@ test_that("plot_ly() handles a simple scatterplot", { test_that("Mapping a variable to symbol works", { p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, symbol = ~Species) + expect_message(plotly_build(p), "Adding markers to mode") l <- expect_traces(p, 3, "scatterplot-symbol") markers <- lapply(l$data, "[[", "marker") syms <- unlist(lapply(markers, "[[", "symbol")) - expect_identical(syms, c("dot", "cross", "diamond")) + expect_identical(syms, c("circle", "cross", "diamond")) }) test_that("Mapping a factor variable to color works", { @@ -66,21 +71,23 @@ test_that("Passing hex codes to colors argument works", { test_that("Mapping a numeric variable to color works", { p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, color = ~Petal.Width, mode = "markers") - l <- expect_traces(p, 1, "scatterplot-color-numeric") - marker <- l$data[[1]]$marker - expect_identical(marker$colorbar$title, "Petal.Width") - expect_identical(marker$color, iris$Petal.Width) - expect_true(all(0 <= marker$colorscale[,1] & marker$colorscale[,1] <= 1)) + # one trace is for the colorbar + l <- expect_traces(p, 2, "scatterplot-color-numeric") + idx <- vapply(l$data, is.colorbar, logical(1)) + markerScale <- l$data[[which(idx)]]$marker + markerDat <- l$data[[which(!idx)]]$marker + expect_identical(markerDat$color, iris$Petal.Width) + expect_identical(markerScale$colorbar$title, "Petal.Width") + expect_equal(min(iris$Petal.Width), markerScale$cmin) + expect_equal(max(iris$Petal.Width), markerScale$cmax) + expect_true(all(0 <= markerScale$colorscale[,1] & markerScale$colorscale[,1] <= 1)) }) test_that("Custom RColorBrewer pallette works for numeric variable", { p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, color = ~Petal.Width, colors = "Greens", mode = "markers") - l <- expect_traces(p, 1, "scatterplot-color-numeric-custom") - marker <- l$data[[1]]$marker - expect_identical(marker$colorbar$title, "Petal.Width") - expect_identical(marker$color, iris$Petal.Width) - expect_true(all(0 <= marker$colorscale[,1] & marker$colorscale[,1] <= 1)) + # one trace is for the colorbar + l <- expect_traces(p, 2, "scatterplot-color-numeric-custom") }) test_that("axis titles get attached to scene object for 3D plots", { @@ -109,7 +116,7 @@ p <- plot_ly(iris, x = ~Species) %>% test_that("x/y/z properties have a class of AsIs", { p <- plot_ly(x = 1, y = 1, z = 1, type = "scatter3d") - l <- plotly_build(p) + l <- expect_traces(p, 1, "box-data-array") tr <- l$data[[1]] expect_true(inherits(tr$x, "AsIs")) expect_true(inherits(tr$y, "AsIs")) From 7eafaa7fa6c0bc7113b900e083650a6c05de15f4 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 13:47:58 -0500 Subject: [PATCH 32/73] update subplot vignette; safer data referencing --- R/plotly_build.R | 5 ++--- R/plotly_data.R | 6 +++++- R/utils.R | 4 ++++ vignettes/subplot.Rmd | 11 ++++------- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/R/plotly_build.R b/R/plotly_build.R index 16e649d614..bc5ce8ebd2 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -35,11 +35,10 @@ plotly_build.plotly <- function(p) { layouts <- Map(function(x, y) { d <- plotly_data(p, y) - x <- rapply(x, eval_attr, data = d, how = "list") x[lengths(x) > 0] - }, p$x$layoutAttrs, names(p$x$layoutAttrs)) + }, p$x$layoutAttrs, names2(p$x$layoutAttrs)) # get rid of the data -> layout mapping and merge all the layouts # into a single layout (more recent layouts will override older ones) @@ -101,7 +100,7 @@ plotly_build.plotly <- function(p) { x[attrLengths > 0] - }, p$x$attrs, names(p$x$attrs)) + }, p$x$attrs, names2(p$x$attrs)) # "transforms" of (i.e., apply scaling to) special arguments # IMPORTANT: these should be applied at the plot-level diff --git a/R/plotly_data.R b/R/plotly_data.R index 2b04201f77..90d2f5d1e1 100644 --- a/R/plotly_data.R +++ b/R/plotly_data.R @@ -42,7 +42,11 @@ NULL #' @export #' @rdname plotly_data plotly_data <- function(p, id = p$x$cur_data) { - p$x$visdat[[id]]() %||% data.frame() + f <- p$x$visdat[[id]] + # if data has been specified, this should be a closure that, when called + # returns data + if (is.function(f)) return(f()) + data.frame() } #' @export diff --git a/R/utils.R b/R/utils.R index 41893c4443..7a97f0ec6d 100644 --- a/R/utils.R +++ b/R/utils.R @@ -35,6 +35,10 @@ new_id <- function() { basename(tempfile("")) } +names2 <- function(x) { + names(x) %||% rep("", length(x)) +} + verify_arg <- function(arg) { if (missing(arg)) return(NULL) if (!is.formula(arg)) { diff --git a/vignettes/subplot.Rmd b/vignettes/subplot.Rmd index a22cfa8db0..91aa1e0459 100644 --- a/vignettes/subplot.Rmd +++ b/vignettes/subplot.Rmd @@ -36,8 +36,8 @@ The `subplot()` function provides a flexible interface for arranging multiple ** ```{r} library(plotly) -p1 <- plot_ly(economics, x = date, y = unemploy, name = "unemploy") -p2 <- plot_ly(economics, x = date, y = uempmed, name = "uempmed") +p1 <- plot_ly(economics, x = ~date, y = ~unemploy, name = "unemploy") +p2 <- plot_ly(economics, x = ~date, y = ~uempmed, name = "uempmed") subplot(p1, p2) ``` @@ -55,7 +55,7 @@ subplot(plots, nrows = length(plots), shareX = TRUE, titleX = FALSE) # this works too, but I'm not sure we should advertise... elong <- tidyr::gather(economics, variable, value, -date) elong$id <- as.integer(factor(elong$variable)) -p <- plot_ly(elong, x = date, y = value, group = variable, yaxis = paste0("y", id)) +p <- plot_ly(elong, x = ~date, y = ~value, group = ~variable, yaxis = ~paste0("y", id)) subplot(p, nrows = 5, shareX = TRUE) ``` @@ -114,7 +114,7 @@ g <- list( # create a map of population density density <- state.x77[, "Population"] / state.x77[, "Area"] map <- plot_ly( - z = density, + z = ~density, text = state.name, locations = state.abb, type = 'choropleth', locationmode = 'USA-states', geo = "geo" ) %>% layout(geo = g) @@ -155,6 +155,3 @@ pm <- GGally::ggpairs(iris) ggplotly(pm) ``` - - - From a63ff71a6bb18cf4ad01c5f07b1b046ea2020677 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 14:01:32 -0500 Subject: [PATCH 33/73] import/namespace updates --- DESCRIPTION | 3 +- NAMESPACE | 15 ++++++++-- R/imports.R | 8 +++--- man/group2NA.Rd | 24 ++-------------- man/plotly-data.Rd | 68 ---------------------------------------------- 5 files changed, 21 insertions(+), 97 deletions(-) delete mode 100644 man/plotly-data.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 0504faa5f0..19138d50d6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,7 +32,8 @@ Imports: htmlwidgets, tidyr, dplyr, - hexbin + hexbin, + lazyeval (>= 0.2.0) Suggests: maps, ggthemes, diff --git a/NAMESPACE b/NAMESPACE index 4d00ceaa02..2c9b46014f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -102,6 +102,14 @@ importFrom(dplyr,distinct_) importFrom(dplyr,do) importFrom(dplyr,group_by) importFrom(dplyr,group_by_) +importFrom(dplyr,groups) +importFrom(dplyr,mutate_) +importFrom(dplyr,rename_) +importFrom(dplyr,select_) +importFrom(dplyr,slice_) +importFrom(dplyr,summarise_) +importFrom(dplyr,transmute_) +importFrom(dplyr,ungroup) importFrom(grDevices,col2rgb) importFrom(graphics,layout) importFrom(htmlwidgets,createWidget) @@ -118,17 +126,18 @@ importFrom(httr,content) importFrom(httr,stop_for_status) importFrom(jsonlite,fromJSON) importFrom(jsonlite,toJSON) -importFrom(lazyeval,dots_capture) +importFrom(lazyeval,all_dots) importFrom(lazyeval,f_eval) -importFrom(lazyeval,f_list) +importFrom(lazyeval,is_formula) importFrom(magrittr,"%>%") importFrom(stats,complete.cases) importFrom(stats,setNames) importFrom(tidyr,gather) +importFrom(tidyr,gather_) importFrom(tidyr,unnest) importFrom(utils,browseURL) importFrom(utils,data) importFrom(utils,getFromNamespace) importFrom(utils,modifyList) importFrom(utils,packageVersion) -importFrom(viridis,viridis) +importFrom(viridisLite,viridis) diff --git a/R/imports.R b/R/imports.R index 3fa6eeb216..fef971ec7f 100644 --- a/R/imports.R +++ b/R/imports.R @@ -3,11 +3,11 @@ #' @importFrom graphics layout #' @importFrom utils getFromNamespace modifyList data packageVersion browseURL #' @importFrom stats setNames complete.cases -#' @importFrom tidyr gather unnest -#' @importFrom dplyr distinct_ arrange_ group_by_ do -#' @importFrom viridis viridis +#' @importFrom tidyr gather gather_ unnest +#' @importFrom dplyr mutate_ summarise_ select_ arrange_ group_by_ distinct_ slice_ rename_ transmute_ do groups ungroup +#' @importFrom viridisLite viridis #' @importFrom jsonlite toJSON fromJSON #' @importFrom httr GET POST PATCH content config add_headers stop_for_status #' @importFrom htmlwidgets createWidget sizingPolicy saveWidget -#' @importFrom lazyeval f_eval f_list dots_capture +#' @importFrom lazyeval f_eval is_formula all_dots NULL diff --git a/man/group2NA.Rd b/man/group2NA.Rd index 52ed2ef3b7..93baaa40b2 100644 --- a/man/group2NA.Rd +++ b/man/group2NA.Rd @@ -1,12 +1,9 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/dplyr.R, R/plotly_data.R +% Please edit documentation in R/plotly_data.R \name{group2NA} \alias{group2NA} \title{Insert missing values to create trace groupings} \usage{ -group2NA(data, groupNames = "group", nested = NULL, - retrace.first = inherits(data, "GeomPolygon")) - group2NA(data, groupNames = "group", nested = NULL, retrace.first = inherits(data, "GeomPolygon")) } @@ -18,33 +15,18 @@ group2NA(data, groupNames = "group", nested = NULL, \item{nested}{other variables that group should be nested (i.e., ordered) within.} -\item{retrace.first}{should the first row of each group be appended to the -last row? This is useful for enclosing polygons with lines.} - -\item{data}{a data frame.} - -\item{groupNames}{name(s) of the grouping variable(s) as a character vector} - -\item{nested}{other variables that group should be nested -(i.e., ordered) within.} - \item{retrace.first}{should the first row of each group be appended to the last row? This is useful for enclosing polygons with lines.} } \description{ -If a group of traces share the same non-positional characteristics (i.e., -color, fill, etc), it is more efficient to draw them as a single trace -with missing values that separate the groups (instead of multiple traces). -This is a helper function for inserting missing values into a data set - If a group of traces share the same non-positional characteristics (i.e., color, fill, etc), it is more efficient to draw them as a single trace with missing values that separate the groups (instead of multiple traces). This is a helper function for inserting missing values into a data set } \examples{ -elong <- tidyr::gather(economics, variable, value, -date) -plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) + +group2NA(mtcars, "vs", "cyl") elong <- tidyr::gather(economics, variable, value, -date) plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) diff --git a/man/plotly-data.Rd b/man/plotly-data.Rd deleted file mode 100644 index 15472f78f6..0000000000 --- a/man/plotly-data.Rd +++ /dev/null @@ -1,68 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/dplyr.R -\name{plotly-data} -\alias{arrange_.plotly} -\alias{distinct_.plotly} -\alias{filter_.plotly} -\alias{group_by_.plotly} -\alias{groups.plotly} -\alias{mutate_.plotly} -\alias{plotly-data} -\alias{rename_.plotly} -\alias{select_.plotly} -\alias{slice_.plotly} -\alias{summarise_.plotly} -\alias{transmute_.plotly} -\alias{ungroup.plotly} -\title{Data manipulation verbs for plotly.} -\usage{ -groups.plotly(x) - -group_by_.plotly(.data, ..., .dots, add = FALSE) - -ungroup.plotly(x) - -summarise_.plotly(.data, ..., .dots) - -mutate_.plotly(.data, ..., .dots) - -arrange_.plotly(.data, ..., .dots) - -select_.plotly(.data, ..., .dots) - -filter_.plotly(.data, ..., .dots) - -distinct_.plotly(.data, ..., .dots) - -slice_.plotly(.data, ..., .dots) - -rename_.plotly(.data, ..., .dots) - -transmute_.plotly(.data, ..., .dots) -} -\description{ -Data manipulation verbs for plotly. -} -\examples{ - -# loading dplyr is super important! -library(dplyr) - -mtcars \%>\% - plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") \%>\% - filter(cyl == 4) \%>\% - add_markers(x = ~wt, y = ~mpg, name = "filtered points", - marker = list(color = "red")) - -library(tidyr) -economics \%>\% - gather(variable, value, -date) \%>\% - group_by(variable) \%>\% - plot_ly(x = ~date, y = ~value) - - - - -} -\keyword{internal} - From d23ff3c2aee61782d429d974ef8f58b57b044aa6 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 14:20:39 -0500 Subject: [PATCH 34/73] travis tests no longer need envir hacks --- tests/testthat.R | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/testthat.R b/tests/testthat.R index 31fe3cc1a7..ccae55ab7e 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -84,14 +84,7 @@ save_outputs <- function(gg, name) { !isTRUE(plot_hash == test_info$hash) } else FALSE if (has_diff || build_table) { - # hack to transfer workspace to the other R session - rs_assign <- function(obj, name) RSassign(conn, obj, name) - res <- mapply(rs_assign, mget(ls()), ls()) - # also need to transfer over the plotly environment to enable NSE - res <- RSassign(conn, plotly:::plotlyEnv, "plotlyEnv") - res <- RSeval(conn, "unlockBinding('plotlyEnv', asNamespace('plotly'))") - res <- RSeval(conn, "assign('plotlyEnv', plotlyEnv, pos = asNamespace('plotly'))") - pm <- RSeval(conn, "tryCatch(plotly::plotly_build(gg), error = function(e) 'plotly build error')") + pm <- RSeval(conn, "tryCatch(plotly::plotly_build(gg)$x, error = function(e) 'plotly build error')") if (build_table) { # save pngs of ggplot filename <- paste0(gsub("\\s+", "-", name), ".png") From d025989f154e879bac2ee99ba9e4e5c64cfd5271 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 14:55:27 -0500 Subject: [PATCH 35/73] fixes for plotly figures; don't document group2NA --- R/plotly_POST.R | 3 +- R/plotly_data.R | 40 +++++++++++++------------- R/process.R | 1 + R/utils.R | 18 ++++++------ man/group2NA.Rd | 35 ---------------------- tests/testthat/test-plotly-filename.R | 2 +- tests/testthat/test-plotly-getfigure.R | 2 +- 7 files changed, 35 insertions(+), 66 deletions(-) delete mode 100644 man/group2NA.Rd diff --git a/R/plotly_POST.R b/R/plotly_POST.R index 0ad09e9a33..de643b83fd 100644 --- a/R/plotly_POST.R +++ b/R/plotly_POST.R @@ -42,7 +42,8 @@ plotly_POST <- function(x, filename = NULL, fileopt = "overwrite", # try our damndest to assign a sensible filename x$filename <- filename %||% x$filename %||% as.character(x$layout$title) %||% paste(c(x$layout$xaxis$title, x$layout$yaxis$title, x$layout$zaxis$title), - collapse = " vs. ") %||% paste("Created at", Sys.time()) + collapse = " vs. ") + if (nchar(x$filename) == 0) x$filename <- paste("Created at", Sys.time()) if (!is.null(x$fileopt)) { warning("fileopt was specified in the wrong place.", "Please specify in plotly_POST()") diff --git a/R/plotly_data.R b/R/plotly_data.R index 90d2f5d1e1..97c204eb95 100644 --- a/R/plotly_data.R +++ b/R/plotly_data.R @@ -142,26 +142,26 @@ transmute_.plotly <- function(.data, ..., .dots) { add_data(.data, d) } -#' Insert missing values to create trace groupings -#' -#' If a group of traces share the same non-positional characteristics (i.e., -#' color, fill, etc), it is more efficient to draw them as a single trace -#' with missing values that separate the groups (instead of multiple traces). -#' This is a helper function for inserting missing values into a data set -#' -#' @param data a data frame. -#' @param groupNames name(s) of the grouping variable(s) as a character vector -#' @param nested other variables that group should be nested -#' (i.e., ordered) within. -#' @param retrace.first should the first row of each group be appended to the -#' last row? This is useful for enclosing polygons with lines. -#' @examples -#' -#' group2NA(mtcars, "vs", "cyl") -#' -#' elong <- tidyr::gather(economics, variable, value, -date) -#' plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) -#' +# Insert missing values to create trace groupings +# +# If a group of traces share the same non-positional characteristics (i.e., +# color, fill, etc), it is more efficient to draw them as a single trace +# with missing values that separate the groups (instead of multiple traces). +# This is a helper function for inserting missing values into a data set +# +# @param data a data frame. +# @param groupNames name(s) of the grouping variable(s) as a character vector +# @param nested other variables that group should be nested +# (i.e., ordered) within. +# @param retrace.first should the first row of each group be appended to the +# last row? This is useful for enclosing polygons with lines. +# @examples +# +# group2NA(mtcars, "vs", "cyl") +# +# elong <- tidyr::gather(economics, variable, value, -date) +# plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) +# group2NA <- function(data, groupNames = "group", nested = NULL, retrace.first = inherits(data, "GeomPolygon")) { diff --git a/R/process.R b/R/process.R index c3c4dbfbb7..73a11e3a4a 100644 --- a/R/process.R +++ b/R/process.R @@ -32,6 +32,7 @@ process.plotly_figure <- function(resp) { # make sure that we always return a HTTPS link con$url <- sub("^http[s]?:", "https:", con$url) fig <- verify_boxed(fig) + fig$data <- lapply(fig$data, verify_type) as.widget(fig) } diff --git a/R/utils.R b/R/utils.R index 7a97f0ec6d..666da36cde 100644 --- a/R/utils.R +++ b/R/utils.R @@ -56,7 +56,7 @@ verify_attr_names <- function(p) { ) for (tr in seq_along(p$x$data)) { thisTrace <- p$x$data[[tr]] - validAttrs <- Schema$traces[[thisTrace$type]]$attributes + validAttrs <- Schema$traces[[thisTrace$type %||% "scatter"]]$attributes check_attrs(names(thisTrace), c(names(validAttrs), "key")) } invisible(p) @@ -65,7 +65,7 @@ verify_attr_names <- function(p) { check_attrs <- function(proposedAttrs, validAttrs) { illegalAttrs <- setdiff(proposedAttrs, validAttrs) if (length(illegalAttrs)) { - stop("The following attributes don't exist:\n'", + warning("The following attributes don't exist:\n'", paste(illegalAttrs, collapse = "', '"), "'\n", "Valid options include:\n'", paste(validAttrs, collapse = "', '"), "'\n", @@ -77,12 +77,14 @@ check_attrs <- function(proposedAttrs, validAttrs) { # ensure both the layout and trace attributes are sent to plotly.js # as data_arrays verify_boxed <- function(p) { - layoutNames <- names(p$x$layout) - layoutNew <- verify_box( - setNames(p$x$layout, sub("[0-9]+$", "", layoutNames)), - Schema$layout$layoutAttributes - ) - p$x$layout <- setNames(layoutNew, layoutNames) + if (!is.null(p$x$layout)) { + layoutNames <- names(p$x$layout) + layoutNew <- verify_box( + setNames(p$x$layout, sub("[0-9]+$", "", layoutNames)), + Schema$layout$layoutAttributes + ) + p$x$layout <- setNames(layoutNew, layoutNames) + } for (tr in seq_along(p$x$data)) { thisTrace <- p$x$data[[tr]] validAttrs <- Schema$traces[[thisTrace$type]]$attributes diff --git a/man/group2NA.Rd b/man/group2NA.Rd deleted file mode 100644 index 93baaa40b2..0000000000 --- a/man/group2NA.Rd +++ /dev/null @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotly_data.R -\name{group2NA} -\alias{group2NA} -\title{Insert missing values to create trace groupings} -\usage{ -group2NA(data, groupNames = "group", nested = NULL, - retrace.first = inherits(data, "GeomPolygon")) -} -\arguments{ -\item{data}{a data frame.} - -\item{groupNames}{name(s) of the grouping variable(s) as a character vector} - -\item{nested}{other variables that group should be nested -(i.e., ordered) within.} - -\item{retrace.first}{should the first row of each group be appended to the -last row? This is useful for enclosing polygons with lines.} -} -\description{ -If a group of traces share the same non-positional characteristics (i.e., -color, fill, etc), it is more efficient to draw them as a single trace -with missing values that separate the groups (instead of multiple traces). -This is a helper function for inserting missing values into a data set -} -\examples{ - -group2NA(mtcars, "vs", "cyl") - -elong <- tidyr::gather(economics, variable, value, -date) -plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) - -} - diff --git a/tests/testthat/test-plotly-filename.R b/tests/testthat/test-plotly-filename.R index d608b925cc..fe5637452b 100644 --- a/tests/testthat/test-plotly-filename.R +++ b/tests/testthat/test-plotly-filename.R @@ -3,7 +3,7 @@ context("Filename") test_that("filepath with directories is returned as passed", { skip_on_cran() skip_on_pull_request() - p <- plot_ly(mtcars, x = wt, y = vs) + p <- plot_ly(mtcars, x = ~wt, y = ~vs) f <- plotly_POST(p, filename = "directory/awesome") expect_match(f$filename, "directory/awesome") }) diff --git a/tests/testthat/test-plotly-getfigure.R b/tests/testthat/test-plotly-getfigure.R index 23ff460bd6..0fad32c4e9 100644 --- a/tests/testthat/test-plotly-getfigure.R +++ b/tests/testthat/test-plotly-getfigure.R @@ -37,7 +37,7 @@ test_that("can add traces to a subplot figure", { skip_on_cran() skip_on_pull_request() fig <- get_figure('chelsea_lyn', 6366) - p <- add_trace(fig, x=c(1, 2, 3), y=c(4, 2, 4)) + p <- add_trace(fig, x = c(1, 2, 3), y = c(4, 2, 4)) l <- plotly_build(p) expect_equivalent(length(plotly_build(fig)$data) + 1, length(l$data)) }) From b12f507100a35f02b832823aebb4c77a3c0e7edc Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 15:17:03 -0500 Subject: [PATCH 36/73] fix problems identified by R CMD check --- DESCRIPTION | 4 +++- NAMESPACE | 22 +++++++++++----------- R/add.R | 6 ++++++ R/dev.R | 2 +- R/helpers.R | 2 +- R/plotly_data.R | 8 ++++---- R/utils.R | 6 +++--- man/add_lines.Rd | 6 ++++++ man/add_markers.Rd | 6 ++++++ man/add_paths.Rd | 6 ++++++ man/add_polygons.Rd | 6 ++++++ man/add_ribbons.Rd | 6 ++++++ man/add_text.Rd | 6 ++++++ man/plotly_data.Rd | 22 +++++++++++----------- man/plotly_json.Rd | 2 +- tests/testthat/test-plotly-getfigure.R | 6 +++--- 16 files changed, 80 insertions(+), 36 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 19138d50d6..b8c0ec0102 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,6 +20,7 @@ Description: Easily translate 'ggplot2' graphs to an interactive web-based versi URL: https://plot.ly/r, https://github.com/ropensci/plotly BugReports: https://github.com/ropensci/plotly/issues Depends: + R (>= 2.10), ggplot2 (>= 2.1.0) Imports: scales, @@ -49,7 +50,8 @@ Suggests: Rserve, RSclient, broom, - webshot + webshot, + listviewer LazyData: true VignetteBuilder: knitr RoxygenNote: 5.0.1 diff --git a/NAMESPACE b/NAMESPACE index 2c9b46014f..001dda9592 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,7 @@ # Generated by roxygen2: do not edit by hand +S3method(arrange_,plotly) +S3method(distinct_,plotly) S3method(geom2trace,GeomBar) S3method(geom2trace,GeomBlank) S3method(geom2trace,GeomBoxplot) @@ -13,12 +15,19 @@ S3method(geom2trace,GeomTile) S3method(geom2trace,default) S3method(ggplotly,ggmatrix) S3method(ggplotly,ggplot) +S3method(group_by_,plotly) +S3method(groups,plotly) S3method(layout,matrix) S3method(layout,plotly) +S3method(mutate_,plotly) S3method(plotly_build,gg) S3method(plotly_build,list) S3method(plotly_build,plotly) S3method(print,plotly_figure) +S3method(rename_,plotly) +S3method(select_,plotly) +S3method(slice_,plotly) +S3method(summarise_,plotly) S3method(to_basic,GeomAbline) S3method(to_basic,GeomArea) S3method(to_basic,GeomBoxplot) @@ -44,6 +53,8 @@ S3method(to_basic,GeomTile) S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) S3method(to_basic,default) +S3method(transmute_,plotly) +S3method(ungroup,plotly) export("%>%") export(add_data) export(add_lines) @@ -53,10 +64,8 @@ export(add_polygons) export(add_ribbons) export(add_text) export(add_trace) -export(arrange_.plotly) export(as.widget) export(config) -export(distinct_.plotly) export(embed_notebook) export(event_data) export(export) @@ -66,11 +75,8 @@ export(get_figure) export(gg2list) export(ggplotly) export(group_by) -export(group_by_.plotly) -export(groups.plotly) export(knit_print.plotly_figure) export(layout) -export(mutate_.plotly) export(offline) export(plot_ly) export(plotly) @@ -81,20 +87,14 @@ export(plotly_build) export(plotly_data) export(plotly_empty) export(plotly_json) -export(rename_.plotly) export(renderPlotly) export(schema) -export(select_.plotly) export(signup) -export(slice_.plotly) export(style) export(subplot) -export(summarise_.plotly) export(toRGB) export(toWebGL) export(to_basic) -export(transmute_.plotly) -export(ungroup.plotly) import(ggplot2) importFrom(base64enc,base64encode) importFrom(dplyr,arrange_) diff --git a/R/add.R b/R/add.R index 3126bf39de..ae75f6a0c5 100644 --- a/R/add.R +++ b/R/add.R @@ -77,6 +77,7 @@ add_trace <- function(p, ..., #' Add points to a plotly vis #' +#' @inheritParams add_trace #' @export add_markers <- function(p, ...) { add_trace(p, type = "scatter", mode = "markers", ...) @@ -84,6 +85,7 @@ add_markers <- function(p, ...) { #' Add paths to a plotly vis #' +#' @inheritParams add_trace #' @export add_paths <- function(p, ...) { add_trace(p, type = "scatter", mode = "lines", ...) @@ -93,6 +95,7 @@ add_paths <- function(p, ...) { #' #' Equivalent to \code{add_paths}, but with the x-values sorted. #' +#' @inheritParams add_trace #' @export add_lines <- function(p, ...) { add_trace(p, type = "scatter", mode = "lines", ...) @@ -100,6 +103,7 @@ add_lines <- function(p, ...) { #' Add text to a plotly vis #' +#' @inheritParams add_trace #' @export add_text <- function(p, ...) { # TODO: throw error if no text attribute is found @@ -108,6 +112,7 @@ add_text <- function(p, ...) { #' Add polygons to a plotly vis #' +#' @inheritParams add_trace #' @export #' @examples #' @@ -129,6 +134,7 @@ add_polygons <- function(p, ...) { #' #' Ribbons are a special case of polygons. #' +#' @inheritParams add_trace #' @export add_ribbons <- function(p, ...) { # TODO: add ymin, ymax arguments? diff --git a/R/dev.R b/R/dev.R index 0ed55ca5f8..c940f6b2e8 100644 --- a/R/dev.R +++ b/R/dev.R @@ -10,7 +10,7 @@ #' @examples #' #' plotly_json(plot_ly()) -#' plotly_json(plot_ly(), F) +#' plotly_json(plot_ly(), FALSE) plotly_json <- function(p = plot_ly(), jsonedit = interactive(), ...) { plotlyJSON <- to_JSON(plotly_build(p)$x, pretty = TRUE) diff --git a/R/helpers.R b/R/helpers.R index c74ad37f4b..e7d7be7cf3 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -30,7 +30,7 @@ hide_colorbar <- function(p) { toWebGL <- function(p, warn = TRUE) { p <- plotly_build(p) types <- sapply(p$x$data, function(x) x[["type"]][1] %||% "scatter") - idx <- paste0(types, "gl") %in% traces + idx <- paste0(types, "gl") %in% names(Schema$traces) if (any(!idx) && warn) { warning( "The following traces don't have a WebGL equivalent: ", diff --git a/R/plotly_data.R b/R/plotly_data.R index 97c204eb95..bb843245c7 100644 --- a/R/plotly_data.R +++ b/R/plotly_data.R @@ -114,7 +114,7 @@ filter_.plotly <- function(.data, ..., .dots) { #' @export distinct_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) - d <- dplyr::distinct_(d, ..., .dots, add = add) + d <- dplyr::distinct_(d, ..., .dots) add_data(.data, d) } @@ -122,7 +122,7 @@ distinct_.plotly <- function(.data, ..., .dots) { #' @export slice_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) - d <- dplyr::slice_(d, ..., .dots, add = add) + d <- dplyr::slice_(d, ..., .dots) add_data(.data, d) } @@ -130,7 +130,7 @@ slice_.plotly <- function(.data, ..., .dots) { #' @export rename_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) - d <- dplyr::rename_(d, ..., .dots, add = add) + d <- dplyr::rename_(d, ..., .dots) add_data(.data, d) } @@ -138,7 +138,7 @@ rename_.plotly <- function(.data, ..., .dots) { #' @export transmute_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) - d <- dplyr::transmute_(d, ..., .dots, add = add) + d <- dplyr::transmute_(d, ..., .dots) add_data(.data, d) } diff --git a/R/utils.R b/R/utils.R index 666da36cde..22942c059e 100644 --- a/R/utils.R +++ b/R/utils.R @@ -178,21 +178,21 @@ verify_mode <- function(p) { for (tr in seq_along(p$x$data)) { trace <- p$x$data[[tr]] if (grepl("scatter", trace$type %||% "scatter")) { - if (!is.null(trace$marker) && !grepl("markers", trace$mode)) { + if (!is.null(trace$marker) && !grepl("markers", trace$mode %||% "")) { message( "A marker object has been specified, but markers is not in the mode\n", "Adding markers to the mode..." ) p$x$data[[tr]]$mode <- paste0(p$x$data[[tr]]$mode, "+markers") } - if (!is.null(trace$line) && !grepl("lines", trace$mode)) { + if (!is.null(trace$line) && !grepl("lines", trace$mode %||% "")) { message( "A line object has been specified, but lines is not in the mode\n", "Adding lines to the mode..." ) p$x$data[[tr]]$mode <- paste0(p$x$data[[tr]]$mode, "+lines") } - if (!is.null(trace$textfont) && !grepl("text", trace$mode)) { + if (!is.null(trace$textfont) && !grepl("text", trace$mode %||% "")) { warning( "A textfont object has been specified, but text is not in the mode\n", "Adding text to the mode..." diff --git a/man/add_lines.Rd b/man/add_lines.Rd index 5fa1907ae9..a2d22933af 100644 --- a/man/add_lines.Rd +++ b/man/add_lines.Rd @@ -6,6 +6,12 @@ \usage{ add_lines(p, ...) } +\arguments{ +\item{p}{a plotly or ggplot object.} + +\item{...}{These arguments are documented in the references section below. +Note that acceptable arguments depend on the trace type.} +} \description{ Equivalent to \code{add_paths}, but with the x-values sorted. } diff --git a/man/add_markers.Rd b/man/add_markers.Rd index db0fcb9ab5..0154c7bcff 100644 --- a/man/add_markers.Rd +++ b/man/add_markers.Rd @@ -6,6 +6,12 @@ \usage{ add_markers(p, ...) } +\arguments{ +\item{p}{a plotly or ggplot object.} + +\item{...}{These arguments are documented in the references section below. +Note that acceptable arguments depend on the trace type.} +} \description{ Add points to a plotly vis } diff --git a/man/add_paths.Rd b/man/add_paths.Rd index a85e143124..9032799a63 100644 --- a/man/add_paths.Rd +++ b/man/add_paths.Rd @@ -6,6 +6,12 @@ \usage{ add_paths(p, ...) } +\arguments{ +\item{p}{a plotly or ggplot object.} + +\item{...}{These arguments are documented in the references section below. +Note that acceptable arguments depend on the trace type.} +} \description{ Add paths to a plotly vis } diff --git a/man/add_polygons.Rd b/man/add_polygons.Rd index 1851766bd3..e8a0affadb 100644 --- a/man/add_polygons.Rd +++ b/man/add_polygons.Rd @@ -6,6 +6,12 @@ \usage{ add_polygons(p, ...) } +\arguments{ +\item{p}{a plotly or ggplot object.} + +\item{...}{These arguments are documented in the references section below. +Note that acceptable arguments depend on the trace type.} +} \description{ Add polygons to a plotly vis } diff --git a/man/add_ribbons.Rd b/man/add_ribbons.Rd index 32f5084b57..4395588da1 100644 --- a/man/add_ribbons.Rd +++ b/man/add_ribbons.Rd @@ -6,6 +6,12 @@ \usage{ add_ribbons(p, ...) } +\arguments{ +\item{p}{a plotly or ggplot object.} + +\item{...}{These arguments are documented in the references section below. +Note that acceptable arguments depend on the trace type.} +} \description{ Ribbons are a special case of polygons. } diff --git a/man/add_text.Rd b/man/add_text.Rd index 71c4f3e142..ee784a819d 100644 --- a/man/add_text.Rd +++ b/man/add_text.Rd @@ -6,6 +6,12 @@ \usage{ add_text(p, ...) } +\arguments{ +\item{p}{a plotly or ggplot object.} + +\item{...}{These arguments are documented in the references section below. +Note that acceptable arguments depend on the trace type.} +} \description{ Add text to a plotly vis } diff --git a/man/plotly_data.Rd b/man/plotly_data.Rd index d45f8732ac..7ee3388c2c 100644 --- a/man/plotly_data.Rd +++ b/man/plotly_data.Rd @@ -18,29 +18,29 @@ \usage{ plotly_data(p, id = p$x$cur_data) -groups.plotly(x) +\method{groups}{plotly}(x) -group_by_.plotly(.data, ..., .dots, add = FALSE) +\method{group_by_}{plotly}(.data, ..., .dots, add = FALSE) -ungroup.plotly(x) +\method{ungroup}{plotly}(x) -summarise_.plotly(.data, ..., .dots) +\method{summarise_}{plotly}(.data, ..., .dots) -mutate_.plotly(.data, ..., .dots) +\method{mutate_}{plotly}(.data, ..., .dots) -arrange_.plotly(.data, ..., .dots) +\method{arrange_}{plotly}(.data, ..., .dots) -select_.plotly(.data, ..., .dots) +\method{select_}{plotly}(.data, ..., .dots) filter_.plotly(.data, ..., .dots) -distinct_.plotly(.data, ..., .dots) +\method{distinct_}{plotly}(.data, ..., .dots) -slice_.plotly(.data, ..., .dots) +\method{slice_}{plotly}(.data, ..., .dots) -rename_.plotly(.data, ..., .dots) +\method{rename_}{plotly}(.data, ..., .dots) -transmute_.plotly(.data, ..., .dots) +\method{transmute_}{plotly}(.data, ..., .dots) } \description{ \code{plotly_data()} returns the data associated with diff --git a/man/plotly_json.Rd b/man/plotly_json.Rd index babe997b00..cc0cc029a0 100644 --- a/man/plotly_json.Rd +++ b/man/plotly_json.Rd @@ -20,6 +20,6 @@ sent to plotly.js. \examples{ plotly_json(plot_ly()) -plotly_json(plot_ly(), F) +plotly_json(plot_ly(), FALSE) } diff --git a/tests/testthat/test-plotly-getfigure.R b/tests/testthat/test-plotly-getfigure.R index 0fad32c4e9..896e2b022d 100644 --- a/tests/testthat/test-plotly-getfigure.R +++ b/tests/testthat/test-plotly-getfigure.R @@ -29,7 +29,7 @@ test_that("retrieving a public figure ... works.", { skip_on_pull_request() fig <- get_figure("get_test_user", 0) # get the data behind the hash - p <- plotly_build(fig) + p <- plotly_build(fig)$x expect_equivalent(p$data[[1]]$x, c("1", "2", "3")) }) @@ -38,8 +38,8 @@ test_that("can add traces to a subplot figure", { skip_on_pull_request() fig <- get_figure('chelsea_lyn', 6366) p <- add_trace(fig, x = c(1, 2, 3), y = c(4, 2, 4)) - l <- plotly_build(p) - expect_equivalent(length(plotly_build(fig)$data) + 1, length(l$data)) + l <- plotly_build(p)$x + expect_equivalent(length(plotly_build(fig)$x$data) + 1, length(l$data)) }) test_that("posting a hidden plot returns a secret key", { From d724e59f3d52b03d05bacb96097860557e50a2ad Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 15:47:03 -0500 Subject: [PATCH 37/73] let the travis fun begin --- tests/testthat.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat.R b/tests/testthat.R index ccae55ab7e..8184c82aec 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -18,7 +18,7 @@ if (report_diffs || build_table) { # we don't make assumptions about ggplot2 versioning, # but it is _strongly_ recommended to use the CRAN version (of ggplot2) RSeval(conn, "devtools::install_github('ropensci/plotly')") - RSeval(conn, "library(plotly)") + #RSeval(conn, "library(plotly)") if (report_diffs) { # hash of the version being tested this_hash <- substr(Sys.getenv("TRAVIS_COMMIT"), 1, 7) From 2578156ce2493b15913e83f0b4068ca921852049 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 16:10:51 -0500 Subject: [PATCH 38/73] get add_polygon working --- NAMESPACE | 23 ++++++++++++----------- R/add.R | 27 ++++++++++++++++++--------- R/imports.R | 2 +- R/plotly.R | 2 +- R/plotly_build.R | 5 +++-- man/add_polygons.Rd | 13 +++++++------ man/plot_ly.Rd | 6 +++--- man/plotly_data.Rd | 22 +++++++++++----------- 8 files changed, 56 insertions(+), 44 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 001dda9592..7ad3f3249c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,5 @@ # Generated by roxygen2: do not edit by hand -S3method(arrange_,plotly) -S3method(distinct_,plotly) S3method(geom2trace,GeomBar) S3method(geom2trace,GeomBlank) S3method(geom2trace,GeomBoxplot) @@ -15,19 +13,12 @@ S3method(geom2trace,GeomTile) S3method(geom2trace,default) S3method(ggplotly,ggmatrix) S3method(ggplotly,ggplot) -S3method(group_by_,plotly) -S3method(groups,plotly) S3method(layout,matrix) S3method(layout,plotly) -S3method(mutate_,plotly) S3method(plotly_build,gg) S3method(plotly_build,list) S3method(plotly_build,plotly) S3method(print,plotly_figure) -S3method(rename_,plotly) -S3method(select_,plotly) -S3method(slice_,plotly) -S3method(summarise_,plotly) S3method(to_basic,GeomAbline) S3method(to_basic,GeomArea) S3method(to_basic,GeomBoxplot) @@ -53,8 +44,6 @@ S3method(to_basic,GeomTile) S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) S3method(to_basic,default) -S3method(transmute_,plotly) -S3method(ungroup,plotly) export("%>%") export(add_data) export(add_lines) @@ -64,8 +53,10 @@ export(add_polygons) export(add_ribbons) export(add_text) export(add_trace) +export(arrange_.plotly) export(as.widget) export(config) +export(distinct_.plotly) export(embed_notebook) export(event_data) export(export) @@ -75,8 +66,11 @@ export(get_figure) export(gg2list) export(ggplotly) export(group_by) +export(group_by_.plotly) +export(groups.plotly) export(knit_print.plotly_figure) export(layout) +export(mutate_.plotly) export(offline) export(plot_ly) export(plotly) @@ -87,14 +81,20 @@ export(plotly_build) export(plotly_data) export(plotly_empty) export(plotly_json) +export(rename_.plotly) export(renderPlotly) export(schema) +export(select_.plotly) export(signup) +export(slice_.plotly) export(style) export(subplot) +export(summarise_.plotly) export(toRGB) export(toWebGL) export(to_basic) +export(transmute_.plotly) +export(ungroup.plotly) import(ggplot2) importFrom(base64enc,base64encode) importFrom(dplyr,arrange_) @@ -131,6 +131,7 @@ importFrom(lazyeval,f_eval) importFrom(lazyeval,is_formula) importFrom(magrittr,"%>%") importFrom(stats,complete.cases) +importFrom(stats,quantile) importFrom(stats,setNames) importFrom(tidyr,gather) importFrom(tidyr,gather_) diff --git a/R/add.R b/R/add.R index ae75f6a0c5..5d2b407be1 100644 --- a/R/add.R +++ b/R/add.R @@ -75,6 +75,13 @@ add_trace <- function(p, ..., p } +add_trace_classed <- function(p, class = "plotly_polygon", ...) { + p <- add_trace(p, ...) + nAttrs <- length(p$x$attrs) + p$x$attrs[[nAttrs]] <- prefix_class(p$x$attrs[[nAttrs]], class) + p +} + #' Add points to a plotly vis #' #' @inheritParams add_trace @@ -98,7 +105,7 @@ add_paths <- function(p, ...) { #' @inheritParams add_trace #' @export add_lines <- function(p, ...) { - add_trace(p, type = "scatter", mode = "lines", ...) + add_trace_classed(p, type = "scatter", mode = "lines", class = "plotly_lines", ...) } #' Add text to a plotly vis @@ -113,21 +120,23 @@ add_text <- function(p, ...) { #' Add polygons to a plotly vis #' #' @inheritParams add_trace +#' @param mode Determines the drawing mode for this scatter trace +#' \url{https://plot.ly/r/reference/#scatter-mode} #' @export #' @examples #' -#' library(dplyr) -#' data(canada.cities, package = "maps") -#' #' ggplot2::map_data("world", "canada") %>% #' group_by(group) %>% -#' plot_ly(x = ~long, y = ~lat, hoverinfo = "none") %>% +#' plot_ly(x = ~long, y = ~lat) %>% +#' add_polygons(hoverinfo = "none") %>% #' add_markers(text = ~paste(name, "
", pop), hoverinfo = "text", -#' data = canada.cities) %>% +#' data = maps::canada.cities) %>% #' layout(showlegend = FALSE) -add_polygons <- function(p, ...) { - # TODO: Should mode='markers+lines'? If so, retrace first points? - add_trace(p, type = "scatter", mode = "lines", fill = "toself", ...) +add_polygons <- function(p, mode = "lines", ...) { + add_trace_classed( + p, class = "plotly_polygon", type = "scatter", + fill = "toself", mode = mode, ... + ) } #' Add ribbons to a plotly vis diff --git a/R/imports.R b/R/imports.R index fef971ec7f..1fa70fa4fa 100644 --- a/R/imports.R +++ b/R/imports.R @@ -2,7 +2,7 @@ #' @importFrom grDevices col2rgb #' @importFrom graphics layout #' @importFrom utils getFromNamespace modifyList data packageVersion browseURL -#' @importFrom stats setNames complete.cases +#' @importFrom stats setNames complete.cases quantile #' @importFrom tidyr gather gather_ unnest #' @importFrom dplyr mutate_ summarise_ select_ arrange_ group_by_ distinct_ slice_ rename_ transmute_ do groups ungroup #' @importFrom viridisLite viridis diff --git a/R/plotly.R b/R/plotly.R index 6d5b30a79f..45eb45587c 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -65,7 +65,7 @@ #' #' } #' -plot_ly <- function(data = data.frame(), ..., type = NULL, +plot_ly <- function(data = data.frame(), ..., type = NULL, group, color, colors = NULL, symbol, symbols = NULL, size, sizes = c(10, 100), linetype, linetypes = NULL, width = NULL, height = NULL, source = "A") { diff --git a/R/plotly_build.R b/R/plotly_build.R index bc5ce8ebd2..8bf497e4d6 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -83,7 +83,8 @@ plotly_build.plotly <- function(p) { nestedVars[[id]] <- i d[[id]] <- newVar } - d <- group2NA(d, as.character(grps), names(nestedVars)) + retrace <- inherits(x, "plotly_polygon") + d <- group2NA(d, as.character(grps), names(nestedVars), retrace) } # perform the evaluation @@ -245,7 +246,7 @@ map_color <- function(traces, title = "", na.color = "transparent") { colScale <- scales::col_numeric(palette, rng, na.color = na.color) # generate the colorscale to be shared across traces vals <- if (diff(rng) > 0) { - as.numeric(quantile(allColor, probs = seq(0, 1, length.out = 25), na.rm = TRUE)) + as.numeric(stats::quantile(allColor, probs = seq(0, 1, length.out = 25), na.rm = TRUE)) } else { c(0, 1) } diff --git a/man/add_polygons.Rd b/man/add_polygons.Rd index e8a0affadb..f403b3cb82 100644 --- a/man/add_polygons.Rd +++ b/man/add_polygons.Rd @@ -4,11 +4,14 @@ \alias{add_polygons} \title{Add polygons to a plotly vis} \usage{ -add_polygons(p, ...) +add_polygons(p, mode = "lines", ...) } \arguments{ \item{p}{a plotly or ggplot object.} +\item{mode}{Determines the drawing mode for this scatter trace +\url{https://plot.ly/r/reference/#scatter-mode}} + \item{...}{These arguments are documented in the references section below. Note that acceptable arguments depend on the trace type.} } @@ -17,14 +20,12 @@ Add polygons to a plotly vis } \examples{ -library(dplyr) -data(canada.cities, package = "maps") - ggplot2::map_data("world", "canada") \%>\% group_by(group) \%>\% - plot_ly(x = ~long, y = ~lat, hoverinfo = "none") \%>\% + plot_ly(x = ~long, y = ~lat) \%>\% + add_polygons(hoverinfo = "none") \%>\% add_markers(text = ~paste(name, "
", pop), hoverinfo = "text", - data = canada.cities) \%>\% + data = maps::canada.cities) \%>\% layout(showlegend = FALSE) } diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index d43ee9f7b7..d21e028737 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -4,9 +4,9 @@ \alias{plot_ly} \title{Initiate a plotly visualization} \usage{ -plot_ly(data = data.frame(), ..., type = NULL, color, colors = NULL, - symbol, symbols = NULL, size, sizes = c(10, 100), linetype, - linetypes = NULL, width = NULL, height = NULL, source = "A") +plot_ly(data = data.frame(), ..., type = NULL, group, color, + colors = NULL, symbol, symbols = NULL, size, sizes = c(10, 100), + linetype, linetypes = NULL, width = NULL, height = NULL, source = "A") } \arguments{ \item{data}{A data frame (optional).} diff --git a/man/plotly_data.Rd b/man/plotly_data.Rd index 7ee3388c2c..d45f8732ac 100644 --- a/man/plotly_data.Rd +++ b/man/plotly_data.Rd @@ -18,29 +18,29 @@ \usage{ plotly_data(p, id = p$x$cur_data) -\method{groups}{plotly}(x) +groups.plotly(x) -\method{group_by_}{plotly}(.data, ..., .dots, add = FALSE) +group_by_.plotly(.data, ..., .dots, add = FALSE) -\method{ungroup}{plotly}(x) +ungroup.plotly(x) -\method{summarise_}{plotly}(.data, ..., .dots) +summarise_.plotly(.data, ..., .dots) -\method{mutate_}{plotly}(.data, ..., .dots) +mutate_.plotly(.data, ..., .dots) -\method{arrange_}{plotly}(.data, ..., .dots) +arrange_.plotly(.data, ..., .dots) -\method{select_}{plotly}(.data, ..., .dots) +select_.plotly(.data, ..., .dots) filter_.plotly(.data, ..., .dots) -\method{distinct_}{plotly}(.data, ..., .dots) +distinct_.plotly(.data, ..., .dots) -\method{slice_}{plotly}(.data, ..., .dots) +slice_.plotly(.data, ..., .dots) -\method{rename_}{plotly}(.data, ..., .dots) +rename_.plotly(.data, ..., .dots) -\method{transmute_}{plotly}(.data, ..., .dots) +transmute_.plotly(.data, ..., .dots) } \description{ \code{plotly_data()} returns the data associated with From 445b9af83d7ef6d229a4626b565fd31820d59c43 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 17:31:53 -0500 Subject: [PATCH 39/73] get add_lines() working --- LICENSE | 4 ++-- NEWS | 4 ++-- R/add.R | 31 ++++++++++++++++++++++++++----- R/layers2traces.R | 2 +- R/plotly_build.R | 33 +++++++++++++++++---------------- R/plotly_data.R | 33 +++++++++++++++++++++++++-------- 6 files changed, 73 insertions(+), 34 deletions(-) diff --git a/LICENSE b/LICENSE index 6ea7fce0d9..7a86fec81b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,2 @@ -YEAR: 2014 -COPYRIGHT HOLDER: Chris Parmer \ No newline at end of file +YEAR: 2016 +COPYRIGHT HOLDER: Chris Parmer diff --git a/NEWS b/NEWS index afd11aae89..f0c32d37c5 100644 --- a/NEWS +++ b/NEWS @@ -11,8 +11,8 @@ BREAKING CHANGES & IMPROVEMENTS: NEW FEATURES & IMPROVEMENTS: * Error checking for trace and layout attributes. -* Trace type inference based on specified attributes. -* New `add_markers()`/`add_lines()`/`add_text()`/`add_polygon`/`add_ribbon()` functions provide a shorthand for common plots. +* If no trace type is provided, a sensible type is inferred from the supplied data. +* New `add_polygons()`/`add_ribbons()`/`add_lines()`/`add_markers()`/`add_paths()`/`add_text()` functions provide a shorthand for common plots. * Added `linetype`/`linetypes` arguments for mapping discrete variables to line types (this works very much like the `symbol`/`symbols`). * Added a `sizes` argument for controlling the range of marker size scaling. * New `toWebGL()` function for easy conversion from SVG to WebGL. diff --git a/R/add.R b/R/add.R index 5d2b407be1..c642c4df31 100644 --- a/R/add.R +++ b/R/add.R @@ -105,16 +105,20 @@ add_paths <- function(p, ...) { #' @inheritParams add_trace #' @export add_lines <- function(p, ...) { - add_trace_classed(p, type = "scatter", mode = "lines", class = "plotly_lines", ...) + add_trace_classed( + p, class = "plotly_line", type = "scatter", mode = "lines", ... + ) } #' Add text to a plotly vis #' #' @inheritParams add_trace #' @export -add_text <- function(p, ...) { - # TODO: throw error if no text attribute is found - add_trace(p, type = "scatter", mode = "text", ...) +add_text <- function(p, text = NULL, ...) { + if (is.null(text %||% p$x$attrs[[1]]$text)) { + stop("Must supply text attribute", call. = FALSE) + } + add_trace(p, type = "scatter", mode = "text", text = text, ...) } #' Add polygons to a plotly vis @@ -147,7 +151,24 @@ add_polygons <- function(p, mode = "lines", ...) { #' @export add_ribbons <- function(p, ...) { # TODO: add ymin, ymax arguments? - add_polygons(...) + add_trace_classed( + p, class = c("plotly_ribbon", "plotly_polygon"), type = "scatter", + fill = "toself", mode = "lines", ... + ) +} + +#' Area +#' +#' Ribbons are a special case of polygons. +#' +#' @inheritParams add_trace +#' @export +add_ribbons <- function(p, ...) { + # TODO: add ymin, ymax arguments? + add_trace_classed( + p, class = c("plotly_ribbon", "plotly_polygon"), type = "scatter", + fill = "toself", mode = "lines", ... + ) } diff --git a/R/layers2traces.R b/R/layers2traces.R index fc47d573d5..2eaa5f3497 100644 --- a/R/layers2traces.R +++ b/R/layers2traces.R @@ -193,7 +193,7 @@ to_basic.GeomSegment <- function(data, prestats_data, layout, params, p, ...) { #' @export to_basic.GeomRect <- function(data, prestats_data, layout, params, p, ...) { data$group <- seq_len(nrow(data)) - others <- data[!names(data) %in% c("xmin", "ymin", "xmax", "ymax")] + others <- data[!names(data) %in% c("xmin", "ymin", "xmax", "ymax", "y", "x")] data <- with(data, { rbind(cbind(x = xmin, y = ymin, others), cbind(x = xmin, y = ymax, others), diff --git a/R/plotly_build.R b/R/plotly_build.R index 8bf497e4d6..ed4ff4a1b0 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -67,25 +67,26 @@ plotly_build.plotly <- function(p) { } d <- plotly_data(p, y) + # in order to do grouping _within trace_ correctly, we need to know about + # variables that transform one trace into multiple traces + nestedVars <- list() + for (i in c("symbol", "linetype", "color")) { + newVar <- eval_attr(x[[i]], d) + if (is.null(newVar) || i == "color" && !is.discrete(newVar)) next + id <- paste0("x", new_id()) + nestedVars[[id]] <- i + d[[id]] <- newVar + } # if the data has groups, insert missing values to introduce gaps grps <- dplyr::groups(d) - if (length(grps)) { - if (isTRUE(x$connectgaps)) { - stop("Can't set connectgaps=T in a trace that has 1 or more groups.", call. = FALSE) - } - # in order to do grouping _within trace_ correctly, we need to know about - # variables that transform one trace into multiple traces - nestedVars <- list() - for (i in c("symbol", "linetype", "color")) { - newVar <- eval_attr(x[[i]], d) - if (is.null(newVar) || i == "color" && !is.discrete(newVar)) next - id <- paste0("x", new_id()) - nestedVars[[id]] <- i - d[[id]] <- newVar - } - retrace <- inherits(x, "plotly_polygon") - d <- group2NA(d, as.character(grps), names(nestedVars), retrace) + if (length(grps) &&isTRUE(x$connectgaps)) { + stop("Can't set connectgaps=T in a trace that has 1 or more groups.", call. = FALSE) } + d <- group2NA( + d, as.character(grps), names(nestedVars), + if (inherits(x, "plotly_line")) "x" else NULL, + inherits(x, "plotly_polygon") + ) # perform the evaluation x <- rapply(x, eval_attr, data = d, how = "list") diff --git a/R/plotly_data.R b/R/plotly_data.R index bb843245c7..718dd0d31c 100644 --- a/R/plotly_data.R +++ b/R/plotly_data.R @@ -153,6 +153,8 @@ transmute_.plotly <- function(.data, ..., .dots) { # @param groupNames name(s) of the grouping variable(s) as a character vector # @param nested other variables that group should be nested # (i.e., ordered) within. +# @param ordered a variable to arrange by (within nested & groupNames). This +# is useful primarily for ordering by x # @param retrace.first should the first row of each group be appended to the # last row? This is useful for enclosing polygons with lines. # @examples @@ -163,7 +165,7 @@ transmute_.plotly <- function(.data, ..., .dots) { # plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) # -group2NA <- function(data, groupNames = "group", nested = NULL, +group2NA <- function(data, groupNames = "group", nested = NULL, ordered = NULL, retrace.first = inherits(data, "GeomPolygon")) { if (nrow(data) == 0) return(data) # a few workarounds since dplyr clobbers classes that we rely on in ggplotly @@ -172,13 +174,24 @@ group2NA <- function(data, groupNames = "group", nested = NULL, # sanitize variable names groupNames <- groupNames[groupNames %in% names(data)] nested <- nested[nested %in% names(data)] - # nothing to do if the group var doesn't exist - if (!length(groupNames)) return(data) - # arrange + group_by, ignoring any already existing groups - vars <- c(nested, groupNames) - data <- data[do.call(order, data[, vars, drop = FALSE]), ] + ordered <- ordered[ordered %in% names(data)] + # ignore any already existing groups data <- dplyr::ungroup(data) - for (i in vars) { + # if group doesn't exist, just arrange before returning + if (!length(groupNames)) { + if (length(ordered)) { + data <- dplyr::arrange_(data, c(nested, ordered)) + } + return(data) + } + allVars <- c(nested, groupNames, ordered) + for (i in allVars) { + data <- dplyr::group_by_(data, i, add = TRUE) + } + # first, arrange everything + data <- dplyr::do(data, dplyr::arrange_(., allVars)) + data <- dplyr::ungroup(data) + for (i in c(nested, groupNames)) { data <- dplyr::group_by_(data, i, add = TRUE) } d <- if (retrace.first) { @@ -186,7 +199,7 @@ group2NA <- function(data, groupNames = "group", nested = NULL, } else { dplyr::do(data, rbind(., NA)) } - # TODO: how to drop the NAs separating the nested values? + # TODO: how to drop the NAs separating the nested values? Does it even matter? # d <- dplyr::ungroup(d) # for (i in nested) { # d <- dplyr::group_by_(dplyr::ungroup(d), i, add = TRUE) @@ -196,3 +209,7 @@ group2NA <- function(data, groupNames = "group", nested = NULL, if (all(is.na(d[n, ]))) d <- d[-n, ] structure(d, class = datClass) } + + +# to appease R CMD check (currently we reference '.' in group2NA) +utils::globalVariables(".") From 6410831b4f912fa150b36230d59dd3daa1dd29ce Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 21:05:26 -0500 Subject: [PATCH 40/73] maybe caching is the problem --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 98329875e3..5efb650a8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,9 +17,9 @@ env: # GITHUB_PAT (for pushing to plotly-test-table) - secure: "LHJONgWOo+98vNeFLI7LSJU3RtbMVszlI79GB8CcXmc2mlgM/UtZ5b6RnkNlhmg3Gj1/uObfm/rIybVTwuS1yNpeKv73+gsZOYhobVXiUGVxdRFG/mg5mbqwyWkkuofjPGFlMZCEMgHim37eZzgjSibwVH1LClRDsCoFMCgvgV0=" -cache: - directories: - $R_LIBS_USER +#cache: +# directories: +# $R_LIBS_USER before_script: - mkdir -p "$R_LIBS_USER" From a5600a77bbde935b852c1b0981744294e9ac3df0 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 21:21:33 -0500 Subject: [PATCH 41/73] GGally --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5efb650a8e..917f98cd5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,7 @@ before_script: - Rscript -e 'if (length(find.package("devtools", quiet = TRUE)) == 0L) { install.packages("devtools", repos = "http://cran.rstudio.com") }' - Rscript -e 'devtools::update_packages("devtools", repos = "http://cran.rstudio.com")' - Rscript -e 'devtools::install_deps(repos = "http://cran.rstudio.com", dependencies = TRUE)' + - Rscript -e 'install.packages("GGally")' - cd ..; rm -f *.tar.gz; R CMD build $R_PKG - R CMD INSTALL ${R_PKG}_*.tar.gz From 57a9b711f8f7523faa22420f137044ca99da33b1 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 21:40:51 -0500 Subject: [PATCH 42/73] are we having fun yet? --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 917f98cd5a..35ab6c689f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ before_script: - Rscript -e 'if (length(find.package("devtools", quiet = TRUE)) == 0L) { install.packages("devtools", repos = "http://cran.rstudio.com") }' - Rscript -e 'devtools::update_packages("devtools", repos = "http://cran.rstudio.com")' - Rscript -e 'devtools::install_deps(repos = "http://cran.rstudio.com", dependencies = TRUE)' - - Rscript -e 'install.packages("GGally")' + - Rscript -e 'install.packages("GGally", repos = "http://cran.rstudio.com")' - cd ..; rm -f *.tar.gz; R CMD build $R_PKG - R CMD INSTALL ${R_PKG}_*.tar.gz From 254422cebca2d2da4a51b4e595390a81986a4496 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Mon, 20 Jun 2016 22:49:48 -0500 Subject: [PATCH 43/73] I give up --- vignettes/subplot.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/subplot.Rmd b/vignettes/subplot.Rmd index 91aa1e0459..fe66752157 100644 --- a/vignettes/subplot.Rmd +++ b/vignettes/subplot.Rmd @@ -150,7 +150,7 @@ This infrastructure allows `ggplotly()` to understand ggmatrix objects -- the class of object returned by the `ggpairs()` function in the **GGally** package. -```{r, fig.height = 5} +```{r, fig.height = 5, eval = FALSE} pm <- GGally::ggpairs(iris) ggplotly(pm) ``` From d6aeeec5c3ace7aa3a3d8a3bdab7f9c3c1ad5ebe Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 21 Jun 2016 13:58:58 -0500 Subject: [PATCH 44/73] more transform/group fixes; deparsed axis titles should only be set when empty --- R/plotly_build.R | 139 ++++++++++++++++++++++------------- R/plotly_data.R | 4 +- tests/testthat.R | 2 +- tests/testthat/test-plotly.R | 14 ++++ 4 files changed, 104 insertions(+), 55 deletions(-) diff --git a/R/plotly_build.R b/R/plotly_build.R index ed4ff4a1b0..63b7c3ef1c 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -52,6 +52,7 @@ plotly_build.plotly <- function(p) { } dats <- Map(function(x, y) { + # add sensible axis names to layout for (i in c("x", "y", "z")) { nm <- paste0(i, "axis") @@ -59,43 +60,69 @@ plotly_build.plotly <- function(p) { if (length(idx) == 1) { title <- sub("^~", "", deparse2(x[[idx]])) if (is3d(x$type) || i == "z") { - p$x$layout$scene[[nm]]$title <<- title + p$x$layout$scene[[nm]]$title <<- p$x$layout$scene[[nm]]$title %||% title } else { - p$x$layout[[nm]]$title <<- title + p$x$layout[[nm]]$title <<- p$x$layout[[nm]]$title %||% title } } } - d <- plotly_data(p, y) - # in order to do grouping _within trace_ correctly, we need to know about - # variables that transform one trace into multiple traces - nestedVars <- list() + # perform the evaluation + # TODO: remove/warn about missing values here? Provide a way to control na.color? + dat <- plotly_data(p, y) + x <- rapply(x, eval_attr, data = dat, how = "list") + # ensure we have a trace type (depends on the # of data points) + x <- verify_type(x) + + # TODO: if we ever provide some semantics for statistics, it should probably go here + + # gather the "built" or "evaluated" data + nobs <- NROW(dat) + isVar <- vapply(x, function(attr) length(attr) == nobs, logical(1)) + builtData <- data.frame(x[isVar & !names(x) %in% c("colors", "symbols", "linetypes")]) + x$.plotlyVariableMapping <- names(builtData) + + # find any groupings, so we can arrange the data now, + # and insert missing values (to create gaps between traces) later + grps <- as.character(dplyr::groups(dat)) + # does grouping even make sense for this trace type? + hasGrp <- inherits(x, c("plotly_lines", "plotly_polygon")) || + (grepl("scatter", x$type) && grepl("lines", x$mode %||% "lines")) + if (length(grps) && hasGrp) { + if (isTRUE(x$connectgaps)) { + stop( + "Can't set connectgaps=T in a trace that has 1 or more groups.", + call. = FALSE + ) + } + builtData$group <- interaction(dat[, grps, drop = FALSE]) + } + + # build the index used to transform one "trace" into multiple traces + discreteMappings <- list() for (i in c("symbol", "linetype", "color")) { - newVar <- eval_attr(x[[i]], d) - if (is.null(newVar) || i == "color" && !is.discrete(newVar)) next - id <- paste0("x", new_id()) - nestedVars[[id]] <- i - d[[id]] <- newVar + if (is.null(x[[i]]) || i == "color" && !is.discrete(x[[i]])) next + discreteMappings[[i]] <- x[[i]] } - # if the data has groups, insert missing values to introduce gaps - grps <- dplyr::groups(d) - if (length(grps) &&isTRUE(x$connectgaps)) { - stop("Can't set connectgaps=T in a trace that has 1 or more groups.", call. = FALSE) + if (!is.null(names(discreteMappings))) { + paste_it <- function(...) paste(..., sep = "
") + builtData$.plotlyTraceIndex <- do.call(paste_it, discreteMappings) } - d <- group2NA( - d, as.character(grps), names(nestedVars), - if (inherits(x, "plotly_line")) "x" else NULL, - inherits(x, "plotly_polygon") + # arrange the built data + arrangeVars <- c( + ".plotlyTraceIndex", "group", if (inherits(x, "plotly_line")) "x" ) + arrangeVars <- arrangeVars[arrangeVars %in% names(builtData)] + if (length(arrangeVars)) { + builtData <- dplyr::arrange_(builtData, arrangeVars) + } + # copy over to the trace data + for (i in names(builtData)) { + x[[i]] <- builtData[[i]] + } - # perform the evaluation - x <- rapply(x, eval_attr, data = d, how = "list") - - # ensure we have a trace type (depends on the # of data points) - x <- verify_type(x) - - attrLengths <- lengths(x) # if appropriate, set the mode now since we need to reference it later + attrLengths <- lengths(x) if (grepl("scatter", x$type) && is.null(x$mode)) { x$mode <- if (any(attrLengths > 20)) "lines" else "markers+lines" } @@ -104,40 +131,48 @@ plotly_build.plotly <- function(p) { }, p$x$attrs, names2(p$x$attrs)) - # "transforms" of (i.e., apply scaling to) special arguments - # IMPORTANT: these should be applied at the plot-level - colorTitle <- unlist(lapply(p$x$attrs, function(x) x$color %||% x$z))[[1]] - dats <- map_color(dats, title = sub("^~", "", deparse2(colorTitle))) - dats <- map_size(dats) - dats <- map_symbol(dats) - dats <- map_linetype(dats) - # traceify by the interaction of discrete variables - # although I hate this programming pattern, it seems necessary since we don't - # know how many traces we need traces <- list() for (i in seq_along(dats)) { d <- dats[[i]] + scaleAttrs <- names(d) %in% c("colors", "linetypes", "symbols", "sizes") + traces <- c(traces, traceify(d[!scaleAttrs], d$.plotlyTraceIndex)) + if (i == 1) traces[[1]] <- c(traces[[1]], d[scaleAttrs]) + } + + # insert NAs to differentiate groups + traces <- lapply(traces, function(x) { + d <- data.frame(x[names(x) %in% c(x$.plotlyVariableMapping, "group")]) + d <- group2NA(d, retrace.first = inherits(x, "plotly_polygon")) + for (i in x$.plotlyVariableMapping) { + x[[i]] <- uniq(d[[i]]) + } + x + }) + + # "transforms" of (i.e., apply scaling to) special arguments + # IMPORTANT: scales are applied at the plot-level!! + colorTitle <- unlist(lapply(p$x$attrs, function(x) x$color %||% x$z))[[1]] + traces <- map_color(traces, title = sub("^~", "", deparse2(colorTitle))) + traces <- map_size(traces) + traces <- map_symbol(traces) + traces <- map_linetype(traces) + + # remove special mapping attributes + for (i in seq_along(traces)) { mappingAttrs <- c( "color", "colors", "symbol", "symbols", - "linetype", "linetypes", "size", "sizes" + "linetype", "linetypes", "size", "sizes", + "group", ".plotlyTraceIndex", ".plotlyVariableMapping" ) for (j in mappingAttrs) { - dats[[i]][[j]] <- NULL + traces[[i]][[j]] <- NULL } - params <- list( - if (is.discrete(d[["color"]])) d[["color"]], - d[["symbol"]], - d[["linetype"]] - ) - params <- compact(params) %||% list(NULL) - idx <- do.call("interaction", params) - traces <- c(traces, traceify(dats[[i]], idx)) } - # it's possible that some things (like figures pulled from a plotly server) - # already have "built" data - p$x$data <- c(p$x$data, traces) + # it's possible that the plot object already has some traces + # (like figures pulled from a plotly server) + p$x$data <- setNames(c(p$x$data, traces), NULL) # get rid of data -> vis mapping stuff p$x[c("visdat", "cur_data", "attrs")] <- NULL @@ -159,9 +194,6 @@ plotly_build.plotly <- function(p) { } } - # traces can't have names - p$x$data <- setNames(p$x$data, NULL) - # verify plot attributes are legal according to the plotly.js spec p <- verify_attr_names(p) # box up 'data_array' attributes where appropriate @@ -312,6 +344,7 @@ map_color <- function(traces, title = "", na.color = "transparent") { "When using the color/colors arguments, only one palette is allowed.", call. = FALSE) } + colScale <- scales::col_factor(palette, levels = lvls, na.color = na.color) for (i in which(isDiscrete)) { if (hasLine[[i]]) { @@ -441,7 +474,7 @@ traceify <- function(dat, x = NULL) { n <- length(x) # recursively search for a non-list of appropriate length (if it is, subset it) recurse <- function(z, n, idx) { - if (is.list(z)) lapply(z, recurse, n, idx) else if (length(z) == n) uniq(z[idx]) else z + if (is.list(z)) lapply(z, recurse, n, idx) else if (length(z) == n) z[idx] else z } new_dat <- list() for (j in seq_along(lvls)) { diff --git a/R/plotly_data.R b/R/plotly_data.R index 718dd0d31c..80c348fbbe 100644 --- a/R/plotly_data.R +++ b/R/plotly_data.R @@ -167,16 +167,18 @@ transmute_.plotly <- function(.data, ..., .dots) { group2NA <- function(data, groupNames = "group", nested = NULL, ordered = NULL, retrace.first = inherits(data, "GeomPolygon")) { - if (nrow(data) == 0) return(data) + if (NROW(data) == 0) return(data) # a few workarounds since dplyr clobbers classes that we rely on in ggplotly retrace <- force(retrace.first) datClass <- class(data) + # sanitize variable names groupNames <- groupNames[groupNames %in% names(data)] nested <- nested[nested %in% names(data)] ordered <- ordered[ordered %in% names(data)] # ignore any already existing groups data <- dplyr::ungroup(data) + # if group doesn't exist, just arrange before returning if (!length(groupNames)) { if (length(ordered)) { diff --git a/tests/testthat.R b/tests/testthat.R index 8184c82aec..ccae55ab7e 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -18,7 +18,7 @@ if (report_diffs || build_table) { # we don't make assumptions about ggplot2 versioning, # but it is _strongly_ recommended to use the CRAN version (of ggplot2) RSeval(conn, "devtools::install_github('ropensci/plotly')") - #RSeval(conn, "library(plotly)") + RSeval(conn, "library(plotly)") if (report_diffs) { # hash of the version being tested this_hash <- substr(Sys.getenv("TRAVIS_COMMIT"), 1, 7) diff --git a/tests/testthat/test-plotly.R b/tests/testthat/test-plotly.R index 0b96b12394..d4881c2110 100644 --- a/tests/testthat/test-plotly.R +++ b/tests/testthat/test-plotly.R @@ -122,3 +122,17 @@ test_that("x/y/z properties have a class of AsIs", { expect_true(inherits(tr$y, "AsIs")) expect_true(inherits(tr$z, "AsIs")) }) + +test_that("grouping within multiples traces works", { + g <- expand.grid(visit = 1:2, id = 1:3, cohort = c("A", "B")) + g$response <- rnorm(nrow(g)) + d <- group_by(g, id) + p <- plot_ly(d, x = ~visit, y = ~response, color = ~cohort, colors = c("red", "blue")) + l <- expect_traces(p, 2, "group-within-trace") + expect_equal(l$data[[1]]$x, c(1, 2, NA, 1, 2, NA, 1, 2)) + expect_equal(l$data[[2]]$x, c(1, 2, NA, 1, 2, NA, 1, 2)) + expect_true(l$data[[1]]$marker$color == "#FF0000") + expect_true(l$data[[1]]$line$color == "#FF0000") + expect_true(l$data[[2]]$marker$color == "#0000FF") + expect_true(l$data[[2]]$line$color == "#0000FF") +}) From 6a59af221cad8e5bed5b1662ff5631ea1e6bebda Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 21 Jun 2016 14:54:48 -0500 Subject: [PATCH 45/73] fix some special cases in color mapping --- R/plotly_build.R | 21 ++++++++++++++------- R/utils.R | 9 +++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/R/plotly_build.R b/R/plotly_build.R index 63b7c3ef1c..6a5229610d 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -152,8 +152,11 @@ plotly_build.plotly <- function(p) { # "transforms" of (i.e., apply scaling to) special arguments # IMPORTANT: scales are applied at the plot-level!! - colorTitle <- unlist(lapply(p$x$attrs, function(x) x$color %||% x$z))[[1]] - traces <- map_color(traces, title = sub("^~", "", deparse2(colorTitle))) + colorTitle <- unlist(lapply(p$x$attrs, function(x) { + col <- x[["color"]] %||% x[["z"]] + if (lazyeval::is_lang(col)) sub("^~", "", deparse2(col)) else "" + })) + traces <- map_color(traces, title = paste(colorTitle, collapse = "
")) traces <- map_size(traces) traces <- map_symbol(traces) traces <- map_linetype(traces) @@ -251,7 +254,9 @@ map_size <- function(traces) { # appends a new (empty) trace to generate (plot-wide) colorbar/colorscale map_color <- function(traces, title = "", na.color = "transparent") { - color <- lapply(traces, function(x) x$color %||% if (has_attr(x$type, "zmin")) x$z else NULL) + color <- lapply(traces, function(x) { + x[["color"]] %||% if (has_attr(x$type, "zmin")) x[["z"]] else NULL + }) nColors <- lengths(color) # if no "top-level" color is present, return traces untouched if (all(nColors == 0)) { @@ -272,7 +277,7 @@ map_color <- function(traces, title = "", na.color = "transparent") { any(vapply(traces, function(tr) !is.null(tr$z), logical(1))) if (any(isNumeric)) { - palette <- traces[[1]]$colors %||% viridisLite::viridis(10) + palette <- traces[[1]][["colors"]] %||% viridisLite::viridis(10) # TODO: use ggstat::frange() when it's on CRAN? allColor <- unlist(color[isNumeric]) rng <- range(allColor, na.rm = TRUE) @@ -297,18 +302,20 @@ map_color <- function(traces, title = "", na.color = "transparent") { if (types[[i]] %in% c("scatter", "scattergl")) { warning("Numeric color variables cannot (yet) be mapped to lines.\n", " when the trace type is 'scatter' or 'scattergl'.\n", call. = FALSE) - traces[[i]]$mode <- "markers" + traces[[i]]$mode <- paste0(traces[[i]]$mode, "+markers") hasMarker[[i]] <- TRUE } } if (hasMarker[[i]]) { traces[[i]]$marker <- modify_list(colorObj, traces[[i]]$marker) + traces[[i]]$marker$colorscale <- as_df(traces[[i]]$marker$colorscale) } if (hasZ[[i]]) { colorObj[c("zmin", "zmax")] <- colorObj[c("cmin", "cmax")] colorObj[c("cmin", "cmax")] <- NULL - colorObj$showscale <- TRUE + colorObj[["showscale"]] <- TRUE traces[[i]] <- modify_list(colorObj, traces[[i]]) + traces[[i]]$colorscale <- as_df(traces[[i]]$colorscale) } if (hasText[[i]]) { warning("Numeric color variables cannot (yet) be mapped to text.\n", @@ -337,7 +344,7 @@ map_color <- function(traces, title = "", na.color = "transparent") { allColor <- unlist(color[isDiscrete]) lvls <- unique(allColor) N <- length(lvls) - palette <- traces[[1]]$colors %||% + palette <- traces[[1]][["colors"]] %||% if (is.ordered(allColor)) viridisLite::viridis(N) else RColorBrewer::brewer.pal(N, "Set2") if (is.list(palette) && length(palette) > 1) { stop("Multiple numeric color palettes specified (via the colors argument).\n", diff --git a/R/utils.R b/R/utils.R index 22942c059e..4ba67e09c2 100644 --- a/R/utils.R +++ b/R/utils.R @@ -39,6 +39,15 @@ names2 <- function(x) { names(x) %||% rep("", length(x)) } +# modifyList turns elements that are data.frames into lists +# which changes the behavior of toJSON +as_df <- function(x) { + if (is.null(x) || is.matrix(x)) return(x) + if (is.list(x) && !is.data.frame(x)) { + setNames(as.data.frame(x), NULL) + } +} + verify_arg <- function(arg) { if (missing(arg)) return(NULL) if (!is.formula(arg)) { From 14abd2a669fac8b8865c4bd828283298485a6f25 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 21 Jun 2016 15:19:50 -0500 Subject: [PATCH 46/73] make hide_colorbar more universal; don't require formulas for variable mappings --- NAMESPACE | 23 ++++++++++++----------- R/add.R | 7 ++++--- R/helpers.R | 11 ++++++++--- R/imports.R | 2 +- R/plotly.R | 8 ++++---- R/utils.R | 8 -------- man/add_ribbons.Rd | 4 ++++ man/add_text.Rd | 2 +- man/plotly_data.Rd | 22 +++++++++++----------- 9 files changed, 45 insertions(+), 42 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 7ad3f3249c..75f1f55be0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,7 @@ # Generated by roxygen2: do not edit by hand +S3method(arrange_,plotly) +S3method(distinct_,plotly) S3method(geom2trace,GeomBar) S3method(geom2trace,GeomBlank) S3method(geom2trace,GeomBoxplot) @@ -13,12 +15,19 @@ S3method(geom2trace,GeomTile) S3method(geom2trace,default) S3method(ggplotly,ggmatrix) S3method(ggplotly,ggplot) +S3method(group_by_,plotly) +S3method(groups,plotly) S3method(layout,matrix) S3method(layout,plotly) +S3method(mutate_,plotly) S3method(plotly_build,gg) S3method(plotly_build,list) S3method(plotly_build,plotly) S3method(print,plotly_figure) +S3method(rename_,plotly) +S3method(select_,plotly) +S3method(slice_,plotly) +S3method(summarise_,plotly) S3method(to_basic,GeomAbline) S3method(to_basic,GeomArea) S3method(to_basic,GeomBoxplot) @@ -44,6 +53,8 @@ S3method(to_basic,GeomTile) S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) S3method(to_basic,default) +S3method(transmute_,plotly) +S3method(ungroup,plotly) export("%>%") export(add_data) export(add_lines) @@ -53,10 +64,8 @@ export(add_polygons) export(add_ribbons) export(add_text) export(add_trace) -export(arrange_.plotly) export(as.widget) export(config) -export(distinct_.plotly) export(embed_notebook) export(event_data) export(export) @@ -66,11 +75,8 @@ export(get_figure) export(gg2list) export(ggplotly) export(group_by) -export(group_by_.plotly) -export(groups.plotly) export(knit_print.plotly_figure) export(layout) -export(mutate_.plotly) export(offline) export(plot_ly) export(plotly) @@ -81,20 +87,14 @@ export(plotly_build) export(plotly_data) export(plotly_empty) export(plotly_json) -export(rename_.plotly) export(renderPlotly) export(schema) -export(select_.plotly) export(signup) -export(slice_.plotly) export(style) export(subplot) -export(summarise_.plotly) export(toRGB) export(toWebGL) export(to_basic) -export(transmute_.plotly) -export(ungroup.plotly) import(ggplot2) importFrom(base64enc,base64encode) importFrom(dplyr,arrange_) @@ -129,6 +129,7 @@ importFrom(jsonlite,toJSON) importFrom(lazyeval,all_dots) importFrom(lazyeval,f_eval) importFrom(lazyeval,is_formula) +importFrom(lazyeval,is_lang) importFrom(magrittr,"%>%") importFrom(stats,complete.cases) importFrom(stats,quantile) diff --git a/R/add.R b/R/add.R index c642c4df31..a51e042ded 100644 --- a/R/add.R +++ b/R/add.R @@ -54,9 +54,10 @@ add_trace <- function(p, ..., attrs <- list(...) # tack on "special" arguments - attrs$color <- verify_arg(color) - attrs$symbol <- verify_arg(symbol) - attrs$size <- verify_arg(size) + attrs$color <- if (!missing(color)) color + attrs$symbol <- if (!missing(symbol)) symbol + attrs$linetype <- if (!missing(linetype)) linetype + attrs$size <- if (!missing(size)) size if (!is.null(attrs[["group"]])) { warning("The group argument has been deprecated. Use group_by() instead.") diff --git a/R/helpers.R b/R/helpers.R index e7d7be7cf3..95fa842d21 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -8,9 +8,14 @@ #' hide_colorbar() hide_colorbar <- function(p) { p <- plotly_build(p) - idx <- vapply(p$x$data, is.colorbar, logical(1)) - for (i in which(idx)) { - p$x$data[[i]]$marker$showscale <- FALSE + for (i in seq_along(p$x$data)) { + trace <- p$x$data[[i]] + if (has_attr(trace$type, "showscale")) { + p$x$data[[i]]$showscale <- FALSE + } + if (has_attr(trace$type, "marker")) { + p$x$data[[i]]$marker$showscale <- FALSE + } } p } diff --git a/R/imports.R b/R/imports.R index 1fa70fa4fa..88d1bea9e5 100644 --- a/R/imports.R +++ b/R/imports.R @@ -9,5 +9,5 @@ #' @importFrom jsonlite toJSON fromJSON #' @importFrom httr GET POST PATCH content config add_headers stop_for_status #' @importFrom htmlwidgets createWidget sizingPolicy saveWidget -#' @importFrom lazyeval f_eval is_formula all_dots +#' @importFrom lazyeval f_eval is_formula all_dots is_lang NULL diff --git a/R/plotly.R b/R/plotly.R index 45eb45587c..bf7d825682 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -90,10 +90,10 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, group, } # tack on "special" arguments - attrs$color <- verify_arg(color) - attrs$symbol <- verify_arg(symbol) - attrs$linetype <- verify_arg(linetype) - attrs$size <- verify_arg(size) + attrs$color <- if (!missing(color)) color + attrs$symbol <- if (!missing(symbol)) symbol + attrs$linetype <- if (!missing(linetype)) linetype + attrs$size <- if (!missing(size)) size attrs$colors <- colors attrs$symbols <- symbols diff --git a/R/utils.R b/R/utils.R index 4ba67e09c2..59f0ce8c85 100644 --- a/R/utils.R +++ b/R/utils.R @@ -48,14 +48,6 @@ as_df <- function(x) { } } -verify_arg <- function(arg) { - if (missing(arg)) return(NULL) - if (!is.formula(arg)) { - stop("Argument must be a formula.") - } - arg -} - # make sure plot attributes adhere to the plotly.js schema verify_attr_names <- function(p) { # some layout attributes (e.g., [x-y]axis can have trailing numbers) diff --git a/man/add_ribbons.Rd b/man/add_ribbons.Rd index 4395588da1..db7ac49d19 100644 --- a/man/add_ribbons.Rd +++ b/man/add_ribbons.Rd @@ -4,6 +4,8 @@ \alias{add_ribbons} \title{Add ribbons to a plotly vis} \usage{ +add_ribbons(p, ...) + add_ribbons(p, ...) } \arguments{ @@ -13,6 +15,8 @@ add_ribbons(p, ...) Note that acceptable arguments depend on the trace type.} } \description{ +Ribbons are a special case of polygons. + Ribbons are a special case of polygons. } diff --git a/man/add_text.Rd b/man/add_text.Rd index ee784a819d..6e6ec13e6c 100644 --- a/man/add_text.Rd +++ b/man/add_text.Rd @@ -4,7 +4,7 @@ \alias{add_text} \title{Add text to a plotly vis} \usage{ -add_text(p, ...) +add_text(p, text = NULL, ...) } \arguments{ \item{p}{a plotly or ggplot object.} diff --git a/man/plotly_data.Rd b/man/plotly_data.Rd index d45f8732ac..7ee3388c2c 100644 --- a/man/plotly_data.Rd +++ b/man/plotly_data.Rd @@ -18,29 +18,29 @@ \usage{ plotly_data(p, id = p$x$cur_data) -groups.plotly(x) +\method{groups}{plotly}(x) -group_by_.plotly(.data, ..., .dots, add = FALSE) +\method{group_by_}{plotly}(.data, ..., .dots, add = FALSE) -ungroup.plotly(x) +\method{ungroup}{plotly}(x) -summarise_.plotly(.data, ..., .dots) +\method{summarise_}{plotly}(.data, ..., .dots) -mutate_.plotly(.data, ..., .dots) +\method{mutate_}{plotly}(.data, ..., .dots) -arrange_.plotly(.data, ..., .dots) +\method{arrange_}{plotly}(.data, ..., .dots) -select_.plotly(.data, ..., .dots) +\method{select_}{plotly}(.data, ..., .dots) filter_.plotly(.data, ..., .dots) -distinct_.plotly(.data, ..., .dots) +\method{distinct_}{plotly}(.data, ..., .dots) -slice_.plotly(.data, ..., .dots) +\method{slice_}{plotly}(.data, ..., .dots) -rename_.plotly(.data, ..., .dots) +\method{rename_}{plotly}(.data, ..., .dots) -transmute_.plotly(.data, ..., .dots) +\method{transmute_}{plotly}(.data, ..., .dots) } \description{ \code{plotly_data()} returns the data associated with From c48c5ae2906bcbcaccedefe8f76fa1323f6f290f Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 21 Jun 2016 15:56:06 -0500 Subject: [PATCH 47/73] better 3d/z color mapping --- R/plotly_build.R | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/R/plotly_build.R b/R/plotly_build.R index 6a5229610d..320e377575 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -154,7 +154,7 @@ plotly_build.plotly <- function(p) { # IMPORTANT: scales are applied at the plot-level!! colorTitle <- unlist(lapply(p$x$attrs, function(x) { col <- x[["color"]] %||% x[["z"]] - if (lazyeval::is_lang(col)) sub("^~", "", deparse2(col)) else "" + if (is.language(col)) sub("^~", "", deparse2(col)) else "" })) traces <- map_color(traces, title = paste(colorTitle, collapse = "
")) traces <- map_size(traces) @@ -255,7 +255,7 @@ map_size <- function(traces) { # appends a new (empty) trace to generate (plot-wide) colorbar/colorscale map_color <- function(traces, title = "", na.color = "transparent") { color <- lapply(traces, function(x) { - x[["color"]] %||% if (has_attr(x$type, "zmin")) x[["z"]] else NULL + x[["color"]] %||% if (has_attr(x$type, "colorscale")) x[["z"]] else NULL }) nColors <- lengths(color) # if no "top-level" color is present, return traces untouched @@ -273,7 +273,7 @@ map_color <- function(traces, title = "", na.color = "transparent") { hasMarker <- has_marker(types, modes) hasLine <- has_line(types, modes) hasText <- has_text(types, modes) - hasZ <- has_attr(types, "zmin") & + hasZ <- has_attr(types, "colorscale") & any(vapply(traces, function(tr) !is.null(tr$z), logical(1))) if (any(isNumeric)) { @@ -297,6 +297,13 @@ map_color <- function(traces, title = "", na.color = "transparent") { showscale = FALSE ) for (i in which(isNumeric)) { + if (hasZ[[i]]) { + colorObj[c("cmin", "cmax")] <- NULL + colorObj[["showscale"]] <- TRUE + traces[[i]] <- modify_list(colorObj, traces[[i]]) + traces[[i]]$colorscale <- as_df(traces[[i]]$colorscale) + next + } colorObj$color <- color[[i]] if (hasLine[[i]]) { if (types[[i]] %in% c("scatter", "scattergl")) { @@ -310,13 +317,6 @@ map_color <- function(traces, title = "", na.color = "transparent") { traces[[i]]$marker <- modify_list(colorObj, traces[[i]]$marker) traces[[i]]$marker$colorscale <- as_df(traces[[i]]$marker$colorscale) } - if (hasZ[[i]]) { - colorObj[c("zmin", "zmax")] <- colorObj[c("cmin", "cmax")] - colorObj[c("cmin", "cmax")] <- NULL - colorObj[["showscale"]] <- TRUE - traces[[i]] <- modify_list(colorObj, traces[[i]]) - traces[[i]]$colorscale <- as_df(traces[[i]]$colorscale) - } if (hasText[[i]]) { warning("Numeric color variables cannot (yet) be mapped to text.\n", "Feel free to make a feature request \n", @@ -337,6 +337,10 @@ map_color <- function(traces, title = "", na.color = "transparent") { showlegend = FALSE, marker = colorObj ) + if ("scatter3d" %in% unlist(lapply(traces, "[[", "type"))) { + colorBarTrace$type <- "scatter3d" + colorBarTrace$z <- range(unlist(lapply(traces, "[[", "z")), na.rm = TRUE) + } traces[[length(traces) + 1]] <- structure(colorBarTrace, class = "plotly_colorbar") } From 09a03d437f57c35afad38d40ab90103dc99c4489 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 21 Jun 2016 16:13:45 -0500 Subject: [PATCH 48/73] go back to caching --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 35ab6c689f..98329875e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,9 +17,9 @@ env: # GITHUB_PAT (for pushing to plotly-test-table) - secure: "LHJONgWOo+98vNeFLI7LSJU3RtbMVszlI79GB8CcXmc2mlgM/UtZ5b6RnkNlhmg3Gj1/uObfm/rIybVTwuS1yNpeKv73+gsZOYhobVXiUGVxdRFG/mg5mbqwyWkkuofjPGFlMZCEMgHim37eZzgjSibwVH1LClRDsCoFMCgvgV0=" -#cache: -# directories: -# $R_LIBS_USER +cache: + directories: + $R_LIBS_USER before_script: - mkdir -p "$R_LIBS_USER" @@ -31,7 +31,6 @@ before_script: - Rscript -e 'if (length(find.package("devtools", quiet = TRUE)) == 0L) { install.packages("devtools", repos = "http://cran.rstudio.com") }' - Rscript -e 'devtools::update_packages("devtools", repos = "http://cran.rstudio.com")' - Rscript -e 'devtools::install_deps(repos = "http://cran.rstudio.com", dependencies = TRUE)' - - Rscript -e 'install.packages("GGally", repos = "http://cran.rstudio.com")' - cd ..; rm -f *.tar.gz; R CMD build $R_PKG - R CMD INSTALL ${R_PKG}_*.tar.gz From 066b12d37fd720a5432c6771db71a8691625f2bb Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 21 Jun 2016 21:01:03 -0500 Subject: [PATCH 49/73] get add_area()/add_ribbon() working; place all add_*() functions on ?add_trace --- NAMESPACE | 3 +- R/add.R | 90 ++++++++++++++++++++++++++++++++++++--------- R/plotly_build.R | 21 ++++++++++- man/add_lines.Rd | 18 --------- man/add_paths.Rd | 18 --------- man/add_polygons.Rd | 31 ---------------- man/add_ribbons.Rd | 22 ----------- man/add_text.Rd | 18 --------- man/add_trace.Rd | 48 ++++++++++++++++++++++++ man/plotly_data.Rd | 2 +- 10 files changed, 142 insertions(+), 129 deletions(-) delete mode 100644 man/add_lines.Rd delete mode 100644 man/add_paths.Rd delete mode 100644 man/add_polygons.Rd delete mode 100644 man/add_ribbons.Rd delete mode 100644 man/add_text.Rd diff --git a/NAMESPACE b/NAMESPACE index 75f1f55be0..3c891d969a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ S3method(arrange_,plotly) S3method(distinct_,plotly) +S3method(filter_,plotly) S3method(geom2trace,GeomBar) S3method(geom2trace,GeomBlank) S3method(geom2trace,GeomBoxplot) @@ -61,7 +62,6 @@ export(add_lines) export(add_markers) export(add_paths) export(add_polygons) -export(add_ribbons) export(add_text) export(add_trace) export(as.widget) @@ -69,7 +69,6 @@ export(config) export(embed_notebook) export(event_data) export(export) -export(filter_.plotly) export(geom2trace) export(get_figure) export(gg2list) diff --git a/R/add.R b/R/add.R index a51e042ded..00a85a747f 100644 --- a/R/add.R +++ b/R/add.R @@ -24,6 +24,11 @@ add_data <- function(p, data = NULL) { #' @param p a plotly or ggplot object. #' @param ... These arguments are documented in the references section below. #' Note that acceptable arguments depend on the trace type. +#' @param x the x variable. +#' @param y the y variable. +#' @param text textual labels. +#' @param ymin a variable used to define the lower boundary of a polygon. +#' @param ymax a variable used to define the upper boundary of a polygon. #' @param color Either a variable name or a vector to use for color mapping. #' @param symbol Either a variable name or a (discrete) vector to use for symbol encoding. #' @param size A variable name or numeric vector to encode the size of markers. @@ -34,6 +39,7 @@ add_data <- function(p, data = NULL) { #' @references \url{https://plot.ly/r/reference/} #' @author Carson Sievert #' @export +#' @rdname add_trace #' @examples #' #' p <- plot_ly(economics, x = ~date, y = ~uempmed) @@ -76,6 +82,7 @@ add_trace <- function(p, ..., p } +# attach a class to a trace which informs data processing in plotly_build add_trace_classed <- function(p, class = "plotly_polygon", ...) { p <- add_trace(p, ...) nAttrs <- length(p$x$attrs) @@ -94,8 +101,15 @@ add_markers <- function(p, ...) { #' Add paths to a plotly vis #' #' @inheritParams add_trace +#' @rdname add_trace #' @export -add_paths <- function(p, ...) { +add_paths <- function(p, x = NULL, y = NULL, ...) { + if (is.null(x %||% p$x$attrs[[1]]$x)) { + stop("Must supply `x` attribute", call. = FALSE) + } + if (is.null(y %||% p$x$attrs[[1]]$y)) { + stop("Must supply `y` attribute", call. = FALSE) + } add_trace(p, type = "scatter", mode = "lines", ...) } @@ -104,8 +118,15 @@ add_paths <- function(p, ...) { #' Equivalent to \code{add_paths}, but with the x-values sorted. #' #' @inheritParams add_trace +#' @rdname add_trace #' @export -add_lines <- function(p, ...) { +add_lines <- function(p, x = NULL, y = NULL, ...) { + if (is.null(x %||% p$x$attrs[[1]]$x)) { + stop("Must supply `x` attribute", call. = FALSE) + } + if (is.null(y %||% p$x$attrs[[1]]$y)) { + stop("Must supply `y` attribute", call. = FALSE) + } add_trace_classed( p, class = "plotly_line", type = "scatter", mode = "lines", ... ) @@ -114,10 +135,17 @@ add_lines <- function(p, ...) { #' Add text to a plotly vis #' #' @inheritParams add_trace +#' @rdname add_trace #' @export -add_text <- function(p, text = NULL, ...) { +add_text <- function(p, x = NULL, y = NULL, text = NULL, ...) { + if (is.null(x %||% p$x$attrs[[1]]$x)) { + stop("Must supply `x` attribute", call. = FALSE) + } + if (is.null(y %||% p$x$attrs[[1]]$y)) { + stop("Must supply `y` attribute", call. = FALSE) + } if (is.null(text %||% p$x$attrs[[1]]$text)) { - stop("Must supply text attribute", call. = FALSE) + stop("Must supply `text` attribute", call. = FALSE) } add_trace(p, type = "scatter", mode = "text", text = text, ...) } @@ -125,9 +153,8 @@ add_text <- function(p, text = NULL, ...) { #' Add polygons to a plotly vis #' #' @inheritParams add_trace -#' @param mode Determines the drawing mode for this scatter trace -#' \url{https://plot.ly/r/reference/#scatter-mode} #' @export +#' @rdname add_trace #' @examples #' #' ggplot2::map_data("world", "canada") %>% @@ -137,37 +164,64 @@ add_text <- function(p, text = NULL, ...) { #' add_markers(text = ~paste(name, "
", pop), hoverinfo = "text", #' data = maps::canada.cities) %>% #' layout(showlegend = FALSE) -add_polygons <- function(p, mode = "lines", ...) { +add_polygons <- function(p, x = NULL, y = NULL, ...) { + if (is.null(x %||% p$x$attrs[[1]]$x)) { + stop("Must supply `x` attribute", call. = FALSE) + } + if (is.null(y %||% p$x$attrs[[1]]$y)) { + stop("Must supply `y` attribute", call. = FALSE) + } add_trace_classed( p, class = "plotly_polygon", type = "scatter", - fill = "toself", mode = mode, ... + fill = "toself", mode = "lines", ... ) } -#' Add ribbons to a plotly vis -#' -#' Ribbons are a special case of polygons. +#' Ribbon plots #' #' @inheritParams add_trace +#' @rdname add_trace #' @export -add_ribbons <- function(p, ...) { - # TODO: add ymin, ymax arguments? +#' +#' plot_ly(economics, x = ~date) %>% +#' add_ribbons(ymin = ~pce - 1e3, ymax = ~pce + 1e3) +#' +add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, ...) { + if (is.null(x %||% p$x$attrs[[1]]$x)) { + stop("Must supply `x` attribute", call. = FALSE) + } + if (is.null(ymin %||% p$x$attrs[[1]]$ymin)) { + stop("Must supply `ymin` attribute", call. = FALSE) + } + if (is.null(ymax %||% p$x$attrs[[1]]$ymax)) { + stop("Must supply `ymax` attribute", call. = FALSE) + } add_trace_classed( p, class = c("plotly_ribbon", "plotly_polygon"), type = "scatter", fill = "toself", mode = "lines", ... ) } -#' Area +#' Area plots #' -#' Ribbons are a special case of polygons. +#' Equivalent to \link{add_ribbon} with \code{ymin} set to 0. #' #' @inheritParams add_trace +#' @rdname add_trace #' @export -add_ribbons <- function(p, ...) { - # TODO: add ymin, ymax arguments? +#' +#' huron <- data.frame(year = 1875:1972, level = as.vector(LakeHuron)) +#' plot_ly(huron, x = ~year, ymax = ~level) %>% add_area() +#' +add_area <- function(p, x = NULL, ymax = NULL, ...) { + if (is.null(x %||% p$x$attrs[[1]]$x)) { + stop("Must supply `x` attribute", call. = FALSE) + } + if (is.null(ymax %||% p$x$attrs[[1]]$ymax)) { + stop("Must supply `ymax` attribute", call. = FALSE) + } add_trace_classed( - p, class = c("plotly_ribbon", "plotly_polygon"), type = "scatter", + p, class = c("plotly_area", "plotly_ribbon", "plotly_polygon"), type = "scatter", fill = "toself", mode = "lines", ... ) } diff --git a/R/plotly_build.R b/R/plotly_build.R index 320e377575..2967771076 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -70,7 +70,7 @@ plotly_build.plotly <- function(p) { # perform the evaluation # TODO: remove/warn about missing values here? Provide a way to control na.color? dat <- plotly_data(p, y) - x <- rapply(x, eval_attr, data = dat, how = "list") + x <- structure(rapply(x, eval_attr, data = dat, how = "list"), class = class(x)) # ensure we have a trace type (depends on the # of data points) x <- verify_type(x) @@ -80,6 +80,9 @@ plotly_build.plotly <- function(p) { nobs <- NROW(dat) isVar <- vapply(x, function(attr) length(attr) == nobs, logical(1)) builtData <- data.frame(x[isVar & !names(x) %in% c("colors", "symbols", "linetypes")]) + builtData <- train_data(builtData, x) + # TODO: provide a better way to clean up "high-level" attrs + x[c("ymin", "ymax")] <- NULL x$.plotlyVariableMapping <- names(builtData) # find any groupings, so we can arrange the data now, @@ -210,6 +213,22 @@ plotly_build.plotly <- function(p) { p <- verify_hovermode(p) } +# ---------------------------------------------------------------- +# Functions used solely within plotly_build +# ---------------------------------------------------------------- + +train_data <- function(data, trace) { + if (inherits(trace, "plotly_area")) { + data$ymin <- 0 + } + if (inherits(trace, "plotly_ribbon")) { + data <- ribbon_dat(data) + } + # TODO: a lot more geoms!!! + data +} + + map_size <- function(traces) { sizeList <- lapply(traces, "[[", "size") nSizes <- lengths(sizeList) diff --git a/man/add_lines.Rd b/man/add_lines.Rd deleted file mode 100644 index a2d22933af..0000000000 --- a/man/add_lines.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add.R -\name{add_lines} -\alias{add_lines} -\title{Add lines to a plotly vis} -\usage{ -add_lines(p, ...) -} -\arguments{ -\item{p}{a plotly or ggplot object.} - -\item{...}{These arguments are documented in the references section below. -Note that acceptable arguments depend on the trace type.} -} -\description{ -Equivalent to \code{add_paths}, but with the x-values sorted. -} - diff --git a/man/add_paths.Rd b/man/add_paths.Rd deleted file mode 100644 index 9032799a63..0000000000 --- a/man/add_paths.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add.R -\name{add_paths} -\alias{add_paths} -\title{Add paths to a plotly vis} -\usage{ -add_paths(p, ...) -} -\arguments{ -\item{p}{a plotly or ggplot object.} - -\item{...}{These arguments are documented in the references section below. -Note that acceptable arguments depend on the trace type.} -} -\description{ -Add paths to a plotly vis -} - diff --git a/man/add_polygons.Rd b/man/add_polygons.Rd deleted file mode 100644 index f403b3cb82..0000000000 --- a/man/add_polygons.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add.R -\name{add_polygons} -\alias{add_polygons} -\title{Add polygons to a plotly vis} -\usage{ -add_polygons(p, mode = "lines", ...) -} -\arguments{ -\item{p}{a plotly or ggplot object.} - -\item{mode}{Determines the drawing mode for this scatter trace -\url{https://plot.ly/r/reference/#scatter-mode}} - -\item{...}{These arguments are documented in the references section below. -Note that acceptable arguments depend on the trace type.} -} -\description{ -Add polygons to a plotly vis -} -\examples{ - -ggplot2::map_data("world", "canada") \%>\% - group_by(group) \%>\% - plot_ly(x = ~long, y = ~lat) \%>\% - add_polygons(hoverinfo = "none") \%>\% - add_markers(text = ~paste(name, "
", pop), hoverinfo = "text", - data = maps::canada.cities) \%>\% - layout(showlegend = FALSE) -} - diff --git a/man/add_ribbons.Rd b/man/add_ribbons.Rd deleted file mode 100644 index db7ac49d19..0000000000 --- a/man/add_ribbons.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add.R -\name{add_ribbons} -\alias{add_ribbons} -\title{Add ribbons to a plotly vis} -\usage{ -add_ribbons(p, ...) - -add_ribbons(p, ...) -} -\arguments{ -\item{p}{a plotly or ggplot object.} - -\item{...}{These arguments are documented in the references section below. -Note that acceptable arguments depend on the trace type.} -} -\description{ -Ribbons are a special case of polygons. - -Ribbons are a special case of polygons. -} - diff --git a/man/add_text.Rd b/man/add_text.Rd deleted file mode 100644 index 6e6ec13e6c..0000000000 --- a/man/add_text.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add.R -\name{add_text} -\alias{add_text} -\title{Add text to a plotly vis} -\usage{ -add_text(p, text = NULL, ...) -} -\arguments{ -\item{p}{a plotly or ggplot object.} - -\item{...}{These arguments are documented in the references section below. -Note that acceptable arguments depend on the trace type.} -} -\description{ -Add text to a plotly vis -} - diff --git a/man/add_trace.Rd b/man/add_trace.Rd index 6d37f36ba5..a52d1fe74c 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -1,10 +1,28 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/add.R \name{add_trace} +\alias{add_area} +\alias{add_lines} +\alias{add_paths} +\alias{add_polygons} +\alias{add_ribbons} +\alias{add_text} \alias{add_trace} \title{Add trace(s) to a plotly visualization} \usage{ add_trace(p, ..., color, symbol, size, linetype, data = NULL) + +add_paths(p, x = NULL, y = NULL, ...) + +add_lines(p, x = NULL, y = NULL, ...) + +add_text(p, x = NULL, y = NULL, text = NULL, ...) + +add_polygons(p, x = NULL, y = NULL, ...) + +add_ribbons(p, x = NULL, ymin = NULL, ymax = NULL, ...) + +add_area(p, x = NULL, ymax = NULL, ...) } \arguments{ \item{p}{a plotly or ggplot object.} @@ -22,9 +40,31 @@ Note that acceptable arguments depend on the trace type.} \item{data}{A data frame to associate with this trace (optional). If not provided, arguments are evaluated using the data frame in \code{\link{plot_ly}()}.} + +\item{x}{the x variable.} + +\item{y}{the y variable.} + +\item{text}{textual labels.} + +\item{ymin}{a variable used to define the lower boundary of a polygon.} + +\item{ymax}{a variable used to define the upper boundary of a polygon.} } \description{ Add trace(s) to a plotly visualization + +Add paths to a plotly vis + +Equivalent to \code{add_paths}, but with the x-values sorted. + +Add text to a plotly vis + +Add polygons to a plotly vis + +Ribbon plots + +Equivalent to \link{add_ribbon} with \code{ymin} set to 0. } \examples{ @@ -40,6 +80,14 @@ plot_ly(economics, x = ~date, y = ~uempmed) \%>\% add_lines(line = list(color = "red")) + +ggplot2::map_data("world", "canada") \%>\% + group_by(group) \%>\% + plot_ly(x = ~long, y = ~lat) \%>\% + add_polygons(hoverinfo = "none") \%>\% + add_markers(text = ~paste(name, "
", pop), hoverinfo = "text", + data = maps::canada.cities) \%>\% + layout(showlegend = FALSE) } \author{ Carson Sievert diff --git a/man/plotly_data.Rd b/man/plotly_data.Rd index 7ee3388c2c..f7879f36bd 100644 --- a/man/plotly_data.Rd +++ b/man/plotly_data.Rd @@ -32,7 +32,7 @@ plotly_data(p, id = p$x$cur_data) \method{select_}{plotly}(.data, ..., .dots) -filter_.plotly(.data, ..., .dots) +\method{filter_}{plotly}(.data, ..., .dots) \method{distinct_}{plotly}(.data, ..., .dots) From 22d180a07623f186214ba77abcc169122eb9b1c8 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 21 Jun 2016 21:27:32 -0500 Subject: [PATCH 50/73] fix NAMESPACING --- NAMESPACE | 24 ++++++++++++------------ man/plotly_data.Rd | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 3c891d969a..bb370aaf28 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,8 +1,5 @@ # Generated by roxygen2: do not edit by hand -S3method(arrange_,plotly) -S3method(distinct_,plotly) -S3method(filter_,plotly) S3method(geom2trace,GeomBar) S3method(geom2trace,GeomBlank) S3method(geom2trace,GeomBoxplot) @@ -16,19 +13,12 @@ S3method(geom2trace,GeomTile) S3method(geom2trace,default) S3method(ggplotly,ggmatrix) S3method(ggplotly,ggplot) -S3method(group_by_,plotly) -S3method(groups,plotly) S3method(layout,matrix) S3method(layout,plotly) -S3method(mutate_,plotly) S3method(plotly_build,gg) S3method(plotly_build,list) S3method(plotly_build,plotly) S3method(print,plotly_figure) -S3method(rename_,plotly) -S3method(select_,plotly) -S3method(slice_,plotly) -S3method(summarise_,plotly) S3method(to_basic,GeomAbline) S3method(to_basic,GeomArea) S3method(to_basic,GeomBoxplot) @@ -54,8 +44,6 @@ S3method(to_basic,GeomTile) S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) S3method(to_basic,default) -S3method(transmute_,plotly) -S3method(ungroup,plotly) export("%>%") export(add_data) export(add_lines) @@ -64,18 +52,24 @@ export(add_paths) export(add_polygons) export(add_text) export(add_trace) +export(arrange_.plotly) export(as.widget) export(config) +export(distinct_.plotly) export(embed_notebook) export(event_data) export(export) +export(filter_.plotly) export(geom2trace) export(get_figure) export(gg2list) export(ggplotly) export(group_by) +export(group_by_.plotly) +export(groups.plotly) export(knit_print.plotly_figure) export(layout) +export(mutate_.plotly) export(offline) export(plot_ly) export(plotly) @@ -86,14 +80,20 @@ export(plotly_build) export(plotly_data) export(plotly_empty) export(plotly_json) +export(rename_.plotly) export(renderPlotly) export(schema) +export(select_.plotly) export(signup) +export(slice_.plotly) export(style) export(subplot) +export(summarise_.plotly) export(toRGB) export(toWebGL) export(to_basic) +export(transmute_.plotly) +export(ungroup.plotly) import(ggplot2) importFrom(base64enc,base64encode) importFrom(dplyr,arrange_) diff --git a/man/plotly_data.Rd b/man/plotly_data.Rd index f7879f36bd..d45f8732ac 100644 --- a/man/plotly_data.Rd +++ b/man/plotly_data.Rd @@ -18,29 +18,29 @@ \usage{ plotly_data(p, id = p$x$cur_data) -\method{groups}{plotly}(x) +groups.plotly(x) -\method{group_by_}{plotly}(.data, ..., .dots, add = FALSE) +group_by_.plotly(.data, ..., .dots, add = FALSE) -\method{ungroup}{plotly}(x) +ungroup.plotly(x) -\method{summarise_}{plotly}(.data, ..., .dots) +summarise_.plotly(.data, ..., .dots) -\method{mutate_}{plotly}(.data, ..., .dots) +mutate_.plotly(.data, ..., .dots) -\method{arrange_}{plotly}(.data, ..., .dots) +arrange_.plotly(.data, ..., .dots) -\method{select_}{plotly}(.data, ..., .dots) +select_.plotly(.data, ..., .dots) -\method{filter_}{plotly}(.data, ..., .dots) +filter_.plotly(.data, ..., .dots) -\method{distinct_}{plotly}(.data, ..., .dots) +distinct_.plotly(.data, ..., .dots) -\method{slice_}{plotly}(.data, ..., .dots) +slice_.plotly(.data, ..., .dots) -\method{rename_}{plotly}(.data, ..., .dots) +rename_.plotly(.data, ..., .dots) -\method{transmute_}{plotly}(.data, ..., .dots) +transmute_.plotly(.data, ..., .dots) } \description{ \code{plotly_data()} returns the data associated with From 0ed22718f029f2949c803d733cf6197834976fa4 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 21 Jun 2016 21:36:50 -0500 Subject: [PATCH 51/73] you have to pass the arguments through silly --- R/add.R | 97 +++++++++++++++++++++++++--------------------- man/add_markers.Rd | 18 --------- man/add_trace.Rd | 13 +++++-- 3 files changed, 62 insertions(+), 66 deletions(-) delete mode 100644 man/add_markers.Rd diff --git a/R/add.R b/R/add.R index 00a85a747f..0713de4709 100644 --- a/R/add.R +++ b/R/add.R @@ -82,20 +82,19 @@ add_trace <- function(p, ..., p } -# attach a class to a trace which informs data processing in plotly_build -add_trace_classed <- function(p, class = "plotly_polygon", ...) { - p <- add_trace(p, ...) - nAttrs <- length(p$x$attrs) - p$x$attrs[[nAttrs]] <- prefix_class(p$x$attrs[[nAttrs]], class) - p -} - #' Add points to a plotly vis #' #' @inheritParams add_trace +#' @rdname add_trace #' @export -add_markers <- function(p, ...) { - add_trace(p, type = "scatter", mode = "markers", ...) +add_markers <- function(p, x = NULL, y = NULL, ...) { + if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { + stop("Must supply `x` attribute", call. = FALSE) + } + if (is.null(y <- y %||% p$x$attrs[[1]]$y)) { + stop("Must supply `y` attribute", call. = FALSE) + } + add_trace(p, x = x, y = y, type = "scatter", mode = "markers", ...) } #' Add paths to a plotly vis @@ -104,50 +103,50 @@ add_markers <- function(p, ...) { #' @rdname add_trace #' @export add_paths <- function(p, x = NULL, y = NULL, ...) { - if (is.null(x %||% p$x$attrs[[1]]$x)) { + if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(y %||% p$x$attrs[[1]]$y)) { + if (is.null(y <- y %||% p$x$attrs[[1]]$y)) { stop("Must supply `y` attribute", call. = FALSE) } - add_trace(p, type = "scatter", mode = "lines", ...) + add_trace(p, x = x, y = y, type = "scatter", mode = "lines", ...) } -#' Add lines to a plotly vis -#' -#' Equivalent to \code{add_paths}, but with the x-values sorted. +#' Add text to a plotly vis #' #' @inheritParams add_trace #' @rdname add_trace #' @export -add_lines <- function(p, x = NULL, y = NULL, ...) { - if (is.null(x %||% p$x$attrs[[1]]$x)) { +add_text <- function(p, x = NULL, y = NULL, text = NULL, ...) { + if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(y %||% p$x$attrs[[1]]$y)) { + if (is.null(y <- y %||% p$x$attrs[[1]]$y)) { stop("Must supply `y` attribute", call. = FALSE) } - add_trace_classed( - p, class = "plotly_line", type = "scatter", mode = "lines", ... - ) + if (is.null(text <- text %||% p$x$attrs[[1]]$text)) { + stop("Must supply `text` attribute", call. = FALSE) + } + add_trace(p, x = x, y = y, text = text, type = "scatter", mode = "text", ...) } -#' Add text to a plotly vis +#' Add lines to a plotly vis +#' +#' Equivalent to \code{add_paths}, but with the x-values sorted. #' #' @inheritParams add_trace #' @rdname add_trace #' @export -add_text <- function(p, x = NULL, y = NULL, text = NULL, ...) { - if (is.null(x %||% p$x$attrs[[1]]$x)) { +add_lines <- function(p, x = NULL, y = NULL, ...) { + if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(y %||% p$x$attrs[[1]]$y)) { + if (is.null(y <- y %||% p$x$attrs[[1]]$y)) { stop("Must supply `y` attribute", call. = FALSE) } - if (is.null(text %||% p$x$attrs[[1]]$text)) { - stop("Must supply `text` attribute", call. = FALSE) - } - add_trace(p, type = "scatter", mode = "text", text = text, ...) + add_trace_classed( + p, x = x, y = y, class = "plotly_line", type = "scatter", mode = "lines", ... + ) } #' Add polygons to a plotly vis @@ -165,15 +164,15 @@ add_text <- function(p, x = NULL, y = NULL, text = NULL, ...) { #' data = maps::canada.cities) %>% #' layout(showlegend = FALSE) add_polygons <- function(p, x = NULL, y = NULL, ...) { - if (is.null(x %||% p$x$attrs[[1]]$x)) { + if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(y %||% p$x$attrs[[1]]$y)) { + if (is.null(y <- y %||% p$x$attrs[[1]]$y)) { stop("Must supply `y` attribute", call. = FALSE) } add_trace_classed( - p, class = "plotly_polygon", type = "scatter", - fill = "toself", mode = "lines", ... + p, class = "plotly_polygon", x = x, y = y, + type = "scatter", fill = "toself", mode = "lines", ... ) } @@ -185,20 +184,21 @@ add_polygons <- function(p, x = NULL, y = NULL, ...) { #' #' plot_ly(economics, x = ~date) %>% #' add_ribbons(ymin = ~pce - 1e3, ymax = ~pce + 1e3) -#' + add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, ...) { - if (is.null(x %||% p$x$attrs[[1]]$x)) { + if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(ymin %||% p$x$attrs[[1]]$ymin)) { + if (is.null(ymin <- ymin %||% p$x$attrs[[1]]$ymin)) { stop("Must supply `ymin` attribute", call. = FALSE) } - if (is.null(ymax %||% p$x$attrs[[1]]$ymax)) { + if (is.null(ymax <- ymax %||% p$x$attrs[[1]]$ymax)) { stop("Must supply `ymax` attribute", call. = FALSE) } add_trace_classed( - p, class = c("plotly_ribbon", "plotly_polygon"), type = "scatter", - fill = "toself", mode = "lines", ... + p, class = c("plotly_ribbon", "plotly_polygon"), + x = x, ymin = ymin, ymax = ymax, + type = "scatter", fill = "toself", mode = "lines", ... ) } @@ -214,18 +214,27 @@ add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, ...) { #' plot_ly(huron, x = ~year, ymax = ~level) %>% add_area() #' add_area <- function(p, x = NULL, ymax = NULL, ...) { - if (is.null(x %||% p$x$attrs[[1]]$x)) { + if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(ymax %||% p$x$attrs[[1]]$ymax)) { + if (is.null(ymax <- ymax %||% p$x$attrs[[1]]$ymax)) { stop("Must supply `ymax` attribute", call. = FALSE) } add_trace_classed( - p, class = c("plotly_area", "plotly_ribbon", "plotly_polygon"), type = "scatter", - fill = "toself", mode = "lines", ... + p, class = c("plotly_area", "plotly_ribbon", "plotly_polygon"), + x = x, ymax = ymax, + type = "scatter", fill = "toself", mode = "lines", ... ) } +# attach a class to a trace which informs data processing in plotly_build +add_trace_classed <- function(p, class = "plotly_polygon", ...) { + p <- add_trace(p, ...) + nAttrs <- length(p$x$attrs) + p$x$attrs[[nAttrs]] <- prefix_class(p$x$attrs[[nAttrs]], class) + p +} + # #' # #' diff --git a/man/add_markers.Rd b/man/add_markers.Rd deleted file mode 100644 index 0154c7bcff..0000000000 --- a/man/add_markers.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/add.R -\name{add_markers} -\alias{add_markers} -\title{Add points to a plotly vis} -\usage{ -add_markers(p, ...) -} -\arguments{ -\item{p}{a plotly or ggplot object.} - -\item{...}{These arguments are documented in the references section below. -Note that acceptable arguments depend on the trace type.} -} -\description{ -Add points to a plotly vis -} - diff --git a/man/add_trace.Rd b/man/add_trace.Rd index a52d1fe74c..1ab2177551 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -3,6 +3,7 @@ \name{add_trace} \alias{add_area} \alias{add_lines} +\alias{add_markers} \alias{add_paths} \alias{add_polygons} \alias{add_ribbons} @@ -12,12 +13,14 @@ \usage{ add_trace(p, ..., color, symbol, size, linetype, data = NULL) -add_paths(p, x = NULL, y = NULL, ...) +add_markers(p, x = NULL, y = NULL, ...) -add_lines(p, x = NULL, y = NULL, ...) +add_paths(p, x = NULL, y = NULL, ...) add_text(p, x = NULL, y = NULL, text = NULL, ...) +add_lines(p, x = NULL, y = NULL, ...) + add_polygons(p, x = NULL, y = NULL, ...) add_ribbons(p, x = NULL, ymin = NULL, ymax = NULL, ...) @@ -54,12 +57,14 @@ provided, arguments are evaluated using the data frame in \code{\link{plot_ly}() \description{ Add trace(s) to a plotly visualization -Add paths to a plotly vis +Add points to a plotly vis -Equivalent to \code{add_paths}, but with the x-values sorted. +Add paths to a plotly vis Add text to a plotly vis +Equivalent to \code{add_paths}, but with the x-values sorted. + Add polygons to a plotly vis Ribbon plots From 7a1254e2ddc89a2030c80ed2e5eec1946d39720f Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 21 Jun 2016 22:57:07 -0500 Subject: [PATCH 52/73] add add_segments() --- NAMESPACE | 1 + R/add.R | 63 +++++++++++++++++++++++++++++++++--------------- R/plotly_build.R | 34 ++++++++++++++++---------- man/add_trace.Rd | 9 ++++--- 4 files changed, 70 insertions(+), 37 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index bb370aaf28..b7f229dc86 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -50,6 +50,7 @@ export(add_lines) export(add_markers) export(add_paths) export(add_polygons) +export(add_segments) export(add_text) export(add_trace) export(arrange_.plotly) diff --git a/R/add.R b/R/add.R index 0713de4709..64a35825a6 100644 --- a/R/add.R +++ b/R/add.R @@ -50,9 +50,9 @@ add_data <- function(p, data = NULL) { #' #' # attributes declared in plot_ly() carry over to downstream traces #' plot_ly(economics, x = ~date, y = ~uempmed) %>% +#' add_lines(line = list(color = "red")) %>% #' add_markers(color = ~pop) %>% -#' add_lines(line = list(color = "red")) -#' +#' layout(showlegend = FALSE) #' add_trace <- function(p, ..., color, symbol, size, linetype, data = NULL) { @@ -88,10 +88,10 @@ add_trace <- function(p, ..., #' @rdname add_trace #' @export add_markers <- function(p, x = NULL, y = NULL, ...) { - if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { + if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(y <- y %||% p$x$attrs[[1]]$y)) { + if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { stop("Must supply `y` attribute", call. = FALSE) } add_trace(p, x = x, y = y, type = "scatter", mode = "markers", ...) @@ -103,10 +103,10 @@ add_markers <- function(p, x = NULL, y = NULL, ...) { #' @rdname add_trace #' @export add_paths <- function(p, x = NULL, y = NULL, ...) { - if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { + if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(y <- y %||% p$x$attrs[[1]]$y)) { + if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { stop("Must supply `y` attribute", call. = FALSE) } add_trace(p, x = x, y = y, type = "scatter", mode = "lines", ...) @@ -118,13 +118,13 @@ add_paths <- function(p, x = NULL, y = NULL, ...) { #' @rdname add_trace #' @export add_text <- function(p, x = NULL, y = NULL, text = NULL, ...) { - if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { + if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(y <- y %||% p$x$attrs[[1]]$y)) { + if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { stop("Must supply `y` attribute", call. = FALSE) } - if (is.null(text <- text %||% p$x$attrs[[1]]$text)) { + if (is.null(text <- text %||% p$x$attrs[[1]][["text"]])) { stop("Must supply `text` attribute", call. = FALSE) } add_trace(p, x = x, y = y, text = text, type = "scatter", mode = "text", ...) @@ -138,10 +138,10 @@ add_text <- function(p, x = NULL, y = NULL, text = NULL, ...) { #' @rdname add_trace #' @export add_lines <- function(p, x = NULL, y = NULL, ...) { - if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { + if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(y <- y %||% p$x$attrs[[1]]$y)) { + if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { stop("Must supply `y` attribute", call. = FALSE) } add_trace_classed( @@ -149,11 +149,34 @@ add_lines <- function(p, x = NULL, y = NULL, ...) { ) } -#' Add polygons to a plotly vis -#' + #' @inheritParams add_trace +#' @rdname add_trace #' @export +#' +add_segments <- function(p, x = NULL, y = NULL, xend = NULL, yend = NULL, ...) { + if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { + stop("Must supply `x` attribute", call. = FALSE) + } + if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { + stop("Must supply `y` attribute", call. = FALSE) + } + if (is.null(xend <- xend %||% p$x$attrs[[1]][["xend"]])) { + stop("Must supply `xend` attribute", call. = FALSE) + } + if (is.null(yend <- yend %||% p$x$attrs[[1]][["yend"]])) { + stop("Must supply `yend` attribute", call. = FALSE) + } + add_trace_classed( + p, x = x, y = y, xend = xend, yend = yend, + class = "plotly_segment", type = "scatter", mode = "lines", ... + ) +} + + +#' @inheritParams add_trace #' @rdname add_trace +#' @export #' @examples #' #' ggplot2::map_data("world", "canada") %>% @@ -164,10 +187,10 @@ add_lines <- function(p, x = NULL, y = NULL, ...) { #' data = maps::canada.cities) %>% #' layout(showlegend = FALSE) add_polygons <- function(p, x = NULL, y = NULL, ...) { - if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { + if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(y <- y %||% p$x$attrs[[1]]$y)) { + if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { stop("Must supply `y` attribute", call. = FALSE) } add_trace_classed( @@ -186,13 +209,13 @@ add_polygons <- function(p, x = NULL, y = NULL, ...) { #' add_ribbons(ymin = ~pce - 1e3, ymax = ~pce + 1e3) add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, ...) { - if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { + if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(ymin <- ymin %||% p$x$attrs[[1]]$ymin)) { + if (is.null(ymin <- ymin %||% p$x$attrs[[1]][["ymin"]])) { stop("Must supply `ymin` attribute", call. = FALSE) } - if (is.null(ymax <- ymax %||% p$x$attrs[[1]]$ymax)) { + if (is.null(ymax <- ymax %||% p$x$attrs[[1]][["ymax"]])) { stop("Must supply `ymax` attribute", call. = FALSE) } add_trace_classed( @@ -214,10 +237,10 @@ add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, ...) { #' plot_ly(huron, x = ~year, ymax = ~level) %>% add_area() #' add_area <- function(p, x = NULL, ymax = NULL, ...) { - if (is.null(x <- x %||% p$x$attrs[[1]]$x)) { + if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } - if (is.null(ymax <- ymax %||% p$x$attrs[[1]]$ymax)) { + if (is.null(ymax <- ymax %||% p$x$attrs[[1]][["ymax"]])) { stop("Must supply `ymax` attribute", call. = FALSE) } add_trace_classed( diff --git a/R/plotly_build.R b/R/plotly_build.R index 2967771076..a5b963d339 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -82,14 +82,14 @@ plotly_build.plotly <- function(p) { builtData <- data.frame(x[isVar & !names(x) %in% c("colors", "symbols", "linetypes")]) builtData <- train_data(builtData, x) # TODO: provide a better way to clean up "high-level" attrs - x[c("ymin", "ymax")] <- NULL + x[c("ymin", "ymax", "yend", "xend")] <- NULL x$.plotlyVariableMapping <- names(builtData) # find any groupings, so we can arrange the data now, # and insert missing values (to create gaps between traces) later - grps <- as.character(dplyr::groups(dat)) + grps <- as.character(dplyr::groups(builtData)) # does grouping even make sense for this trace type? - hasGrp <- inherits(x, c("plotly_lines", "plotly_polygon")) || + hasGrp <- inherits(x, c("plotly_segment", "plotly_line", "plotly_polygon")) || (grepl("scatter", x$type) && grepl("lines", x$mode %||% "lines")) if (length(grps) && hasGrp) { if (isTRUE(x$connectgaps)) { @@ -98,18 +98,15 @@ plotly_build.plotly <- function(p) { call. = FALSE ) } - builtData$group <- interaction(dat[, grps, drop = FALSE]) + builtData$group <- interaction(builtData[, grps, drop = FALSE]) } # build the index used to transform one "trace" into multiple traces - discreteMappings <- list() - for (i in c("symbol", "linetype", "color")) { - if (is.null(x[[i]]) || i == "color" && !is.discrete(x[[i]])) next - discreteMappings[[i]] <- x[[i]] - } - if (!is.null(names(discreteMappings))) { - paste_it <- function(...) paste(..., sep = "
") - builtData$.plotlyTraceIndex <- do.call(paste_it, discreteMappings) + discreteData <- builtData[vapply(builtData, is.discrete, logical(1))] + discreteData <- discreteData[names(discreteData) %in% c("symbol", "linetype", "color")] + if (NCOL(discreteData) > 0) { + paste2 <- function(x, y) paste(x, y, sep = "
") + builtData$.plotlyTraceIndex <- Reduce(paste2, discreteData) } # arrange the built data arrangeVars <- c( @@ -157,7 +154,7 @@ plotly_build.plotly <- function(p) { # IMPORTANT: scales are applied at the plot-level!! colorTitle <- unlist(lapply(p$x$attrs, function(x) { col <- x[["color"]] %||% x[["z"]] - if (is.language(col)) sub("^~", "", deparse2(col)) else "" + if (is.language(col)) sub("^~", "", deparse2(col)) else NULL })) traces <- map_color(traces, title = paste(colorTitle, collapse = "
")) traces <- map_size(traces) @@ -224,6 +221,17 @@ train_data <- function(data, trace) { if (inherits(trace, "plotly_ribbon")) { data <- ribbon_dat(data) } + if (inherits(trace, "plotly_segment")) { + # TODO: this could be faster, more efficient + data$.plotlyGroupIndex <- seq_len(NROW(data)) + data <- gather_( + gather_(data, "tmp", "x", c("x", "xend")), + "tmp", "y", c("y", "yend") + ) + data <- dplyr::arrange_(data[!names(data) %in% "tmp"], ".plotlyGroupIndex") + data <- dplyr::distinct(data) + data <- dplyr::group_by_(data, ".plotlyGroupIndex", add = TRUE) + } # TODO: a lot more geoms!!! data } diff --git a/man/add_trace.Rd b/man/add_trace.Rd index 1ab2177551..fd682fa3cf 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -7,6 +7,7 @@ \alias{add_paths} \alias{add_polygons} \alias{add_ribbons} +\alias{add_segments} \alias{add_text} \alias{add_trace} \title{Add trace(s) to a plotly visualization} @@ -21,6 +22,8 @@ add_text(p, x = NULL, y = NULL, text = NULL, ...) add_lines(p, x = NULL, y = NULL, ...) +add_segments(p, x = NULL, y = NULL, xend = NULL, yend = NULL, ...) + add_polygons(p, x = NULL, y = NULL, ...) add_ribbons(p, x = NULL, ymin = NULL, ymax = NULL, ...) @@ -65,8 +68,6 @@ Add text to a plotly vis Equivalent to \code{add_paths}, but with the x-values sorted. -Add polygons to a plotly vis - Ribbon plots Equivalent to \link{add_ribbon} with \code{ymin} set to 0. @@ -81,9 +82,9 @@ p \%>\% add_text(text = ".") # attributes declared in plot_ly() carry over to downstream traces plot_ly(economics, x = ~date, y = ~uempmed) \%>\% + add_lines(line = list(color = "red")) \%>\% add_markers(color = ~pop) \%>\% - add_lines(line = list(color = "red")) - + layout(showlegend = FALSE) ggplot2::map_data("world", "canada") \%>\% From 86c41f79ef63021ab355093fc15d44612537760f Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 21 Jun 2016 23:18:07 -0500 Subject: [PATCH 53/73] improve toWebGl implementation; safer group var naming --- R/helpers.R | 17 ++--------------- R/plotly_build.R | 10 ++++++---- R/utils.R | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/R/helpers.R b/R/helpers.R index 95fa842d21..a954596a48 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -23,8 +23,6 @@ hide_colorbar <- function(p) { #' Convert trace types to WebGL #' #' @param p a plotly or ggplot object. -#' @param warn should a warning be produced if the trace type doesn't have -#' a WebGL equivalent? #' @export #' @examples #' @@ -32,19 +30,8 @@ hide_colorbar <- function(p) { #' toWebGL(qplot(1:10)) #' toWebGL(qplot(1:10, 1:10)) #' -toWebGL <- function(p, warn = TRUE) { - p <- plotly_build(p) - types <- sapply(p$x$data, function(x) x[["type"]][1] %||% "scatter") - idx <- paste0(types, "gl") %in% names(Schema$traces) - if (any(!idx) && warn) { - warning( - "The following traces don't have a WebGL equivalent: ", - paste(which(!idx), collapse = ", ") - ) - } - for (i in which(idx)) { - p$x$data[[i]]$type <- paste0(p$x$data[[i]]$type, "gl") - } +toWebGL <- function(p) { + p$x$.plotlyWebGl <- TRUE p } diff --git a/R/plotly_build.R b/R/plotly_build.R index a5b963d339..8cdc4dd5fd 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -98,7 +98,7 @@ plotly_build.plotly <- function(p) { call. = FALSE ) } - builtData$group <- interaction(builtData[, grps, drop = FALSE]) + builtData$.plotlyGroupIndex <- interaction(builtData[, grps, drop = FALSE]) } # build the index used to transform one "trace" into multiple traces @@ -142,8 +142,8 @@ plotly_build.plotly <- function(p) { # insert NAs to differentiate groups traces <- lapply(traces, function(x) { - d <- data.frame(x[names(x) %in% c(x$.plotlyVariableMapping, "group")]) - d <- group2NA(d, retrace.first = inherits(x, "plotly_polygon")) + d <- data.frame(x[names(x) %in% c(x$.plotlyVariableMapping)]) + d <- group2NA(d, ".plotlyGroupIndex", retrace.first = inherits(x, "plotly_polygon")) for (i in x$.plotlyVariableMapping) { x[[i]] <- uniq(d[[i]]) } @@ -166,7 +166,7 @@ plotly_build.plotly <- function(p) { mappingAttrs <- c( "color", "colors", "symbol", "symbols", "linetype", "linetypes", "size", "sizes", - "group", ".plotlyTraceIndex", ".plotlyVariableMapping" + ".plotlyGroupIndex", ".plotlyTraceIndex", ".plotlyVariableMapping" ) for (j in mappingAttrs) { traces[[i]][[j]] <- NULL @@ -208,6 +208,8 @@ plotly_build.plotly <- function(p) { p <- verify_arrays(p) # set a sensible hovermode if it hasn't been specified already p <- verify_hovermode(p) + # try to convert to webgl if toWebGl was used + verify_webgl(p) } # ---------------------------------------------------------------- diff --git a/R/utils.R b/R/utils.R index 59f0ce8c85..054fc1ce14 100644 --- a/R/utils.R +++ b/R/utils.R @@ -227,6 +227,25 @@ verify_hovermode <- function(p) { p } +verify_webgl <- function(p) { + # see toWebGL + if (!isTRUE(p$x$.plotlyWebGl)) { + return(p) + } + types <- sapply(p$x$data, function(x) x[["type"]][1] %||% "scatter") + idx <- paste0(types, "gl") %in% names(Schema$traces) + if (any(!idx)) { + warning( + "The following traces don't have a WebGL equivalent: ", + paste(which(!idx), collapse = ", ") + ) + } + for (i in which(idx)) { + p$x$data[[i]]$type <- paste0(p$x$data[[i]]$type, "gl") + } + p +} + has_marker <- function(types, modes) { is_scatter <- grepl("scatter", types) ifelse(is_scatter, grepl("marker", modes), has_attr(types, "marker")) From abc39dd4f7d61558fdf59420011b244ba92bd0e6 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 22 Jun 2016 11:01:51 -0500 Subject: [PATCH 54/73] deprecate as.widget --- R/deprecated.R | 19 +++++ R/ggplotly.R | 2 +- R/helpers.R | 16 ++++ R/plotly.R | 35 ++++++--- R/plotly_build.R | 2 +- R/print.R | 34 +-------- R/process.R | 2 +- R/shiny.R | 2 + R/subplots.R | 2 +- inst/arguments.R | 180 -------------------------------------------- man/as.widget.Rd | 7 +- man/plotly_empty.Rd | 2 +- man/toWebGL.Rd | 5 +- 13 files changed, 71 insertions(+), 237 deletions(-) delete mode 100644 inst/arguments.R diff --git a/R/deprecated.R b/R/deprecated.R index fb42000b79..ca76472a0a 100644 --- a/R/deprecated.R +++ b/R/deprecated.R @@ -47,3 +47,22 @@ offline <- function(p, height, width, out_dir, open_browser) { .Deprecated("plot_ly") p } + + +#' Convert a plotly object to an htmlwidget object +#' +#' This function was deprecated in 4.0.0, +#' as plotly objects are now htmlwidget objects, +#' so there is no need to convert them. +#' +#' @param x a plotly object. +#' @param ... other options passed onto \code{htmlwidgets::createWidget} +#' @export + +as.widget <- function(x, ...) { + .Deprecated("plot_ly") + x +} + +# for legacy reasons +toWidget <- as.widget diff --git a/R/ggplotly.R b/R/ggplotly.R index 06e898e9b3..df22cca590 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -73,7 +73,7 @@ ggplotly.ggmatrix <- function(p = ggplot2::last_plot(), width = NULL, ggplotly.ggplot <- function(p = ggplot2::last_plot(), width = NULL, height = NULL, tooltip = "all", source = "A", ...) { l <- gg2list(p, width = width, height = height, tooltip = tooltip, source = source, ...) - as.widget(l) + as_widget(l) } #' Convert a ggplot to a list. diff --git a/R/helpers.R b/R/helpers.R index a954596a48..10d24d7565 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -35,3 +35,19 @@ toWebGL <- function(p) { p } + +#' Create a complete empty plotly graph. +#' +#' Useful when used with \link{subplot} +#' +#' @export +plotly_empty <- function(...) { + eaxis <- list( + showticklabels = FALSE, + showgrid = FALSE, + zeroline = FALSE + ) + layout(plot_ly(...), xaxis = eaxis, yaxis = eaxis) +} + + diff --git a/R/plotly.R b/R/plotly.R index bf7d825682..f3264c81b4 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -121,20 +121,31 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, group, base_url = get_domain() ) - as.widget(p) + as_widget(p) } -#' Create a complete empty plotly graph. -#' -#' Useful when used with \link{subplot} -#' -#' @export -plotly_empty <- function(...) { - eaxis <- list( - showticklabels = FALSE, - showgrid = FALSE, - zeroline = FALSE +# Convert a list to a plotly htmlwidget object +# +# @param x a plotly object. +# @param ... other options passed onto \code{htmlwidgets::createWidget} +# + +as_widget <- function(x, ...) { + if (inherits(x, "htmlwidget")) return(x) + # add plotly class mainly for printing method + # customize the JSON serializer (for htmlwidgets) + attr(x, 'TOJSON_FUNC') <- to_JSON + htmlwidgets::createWidget( + name = "plotly", + x = x, + width = x$layout$width, + height = x$layout$height, + sizingPolicy = htmlwidgets::sizingPolicy( + browser.fill = TRUE, + defaultWidth = '100%', + defaultHeight = 400 + ), + preRenderHook = plotly_build ) - layout(plot_ly(...), xaxis = eaxis, yaxis = eaxis) } diff --git a/R/plotly_build.R b/R/plotly_build.R index 8cdc4dd5fd..907db4d94d 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -21,7 +21,7 @@ plotly_build <- function(p) { #' @export plotly_build.list <- function(p) { - as.widget(p) + as_widget(p) } #' @export diff --git a/R/print.R b/R/print.R index 8a7725fda6..11031638ab 100644 --- a/R/print.R +++ b/R/print.R @@ -1,35 +1,3 @@ -#' Convert a plotly object to an htmlwidget object -#' -#' As of version 4.0.0, plotly objects are now htmlwidget objects, -#' so users shouldn't have to use this function directly. -#' -#' @param x a plotly object. -#' @param ... other options passed onto \code{htmlwidgets::createWidget} -#' @export -#' - -as.widget <- function(x, ...) { - if (inherits(x, "htmlwidget")) return(x) - # add plotly class mainly for printing method - # customize the JSON serializer (for htmlwidgets) - attr(x, 'TOJSON_FUNC') <- to_JSON - htmlwidgets::createWidget( - name = "plotly", - x = x, - width = x$layout$width, - height = x$layout$height, - sizingPolicy = htmlwidgets::sizingPolicy( - browser.fill = TRUE, - defaultWidth = '100%', - defaultHeight = 400 - ), - preRenderHook = plotly_build - ) -} - -# for legacy reasons -toWidget <- as.widget - #' Print a plotly figure object #' #' @param x a plotly figure object @@ -79,7 +47,7 @@ embed_notebook <- function(x, width = NULL, height = NULL, if (!dir.exists(dir)) dir.create(dir, recursive = TRUE) owd <- setwd(dir) on.exit(setwd(owd), add = TRUE) - htmlwidgets::saveWidget(as.widget(l), file = basename(file)) + htmlwidgets::saveWidget(l, file = basename(file)) file } else { l$url diff --git a/R/process.R b/R/process.R index 73a11e3a4a..cb6515b265 100644 --- a/R/process.R +++ b/R/process.R @@ -33,7 +33,7 @@ process.plotly_figure <- function(resp) { con$url <- sub("^http[s]?:", "https:", con$url) fig <- verify_boxed(fig) fig$data <- lapply(fig$data, verify_type) - as.widget(fig) + as_widget(fig) } process.signup <- function(resp) { diff --git a/R/shiny.R b/R/shiny.R index 3bcebf19c4..ca02268f42 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -25,6 +25,8 @@ plotlyOutput <- function(outputId, width = "100%", height = "400px") { #' @export renderPlotly <- function(expr, env = parent.frame(), quoted = FALSE) { if (!quoted) { expr <- substitute(expr) } # force quoted + # https://github.com/ramnathv/htmlwidgets/issues/166#issuecomment-153000306 + expr <- call("plotly_build", expr) shinyRenderWidget(expr, plotlyOutput, env, quoted = TRUE) } diff --git a/R/subplots.R b/R/subplots.R index bf81364189..d14bfe0ca6 100644 --- a/R/subplots.R +++ b/R/subplots.R @@ -236,7 +236,7 @@ subplot <- function(..., nrows = 1, widths = NULL, heights = NULL, margin = 0.02 layouts <- layouts[which_layout] } p$layout <- c(p$layout, Reduce(modify_list, layouts)) - as.widget(p) + as_widget(p) } diff --git a/inst/arguments.R b/inst/arguments.R deleted file mode 100644 index 2df5e5340a..0000000000 --- a/inst/arguments.R +++ /dev/null @@ -1,180 +0,0 @@ -# This script grabs argument names from plotly documentation and provides some -# convenience functions for translating all those arguments to the R package - -library(rvest) -ref <- read_html("https://plot.ly/javascript-graphing-library/reference") -# complete set of args -argz <- ref %>% html_nodes(".gamma .link--impt") %>% html_text() %>% - gsub("\\n", "", .) %>% stringr::str_trim() - - -# function arguments -fun_args <- function(x) paste(x, "= NULL", collapse = ", ") -# argument documentation (put inside @param) -doc_args <- function(x) paste(x, collapse = ", ") -# put inside function body -in_args <- function(x) paste(x, "=", x, collapse = ", ") - -# scatter args -fun_args(argz[1:24]) -doc_args(argz[1:24]) -in_args(argz[1:24]) - -# bar args -fun_args(argz[26:43]) -doc_args(argz[26:43]) -in_args(argz[26:43]) - -# histogram args -fun_args(argz[45:68]) -doc_args(argz[45:68]) -in_args(argz[45:68]) - -# box args -fun_args(argz[70:89]) -doc_args(argz[70:89]) -in_args(argz[70:89]) - -# heatmap args -fun_args(argz[91:116]) -doc_args(argz[91:116]) -in_args(argz[91:116]) - -# contour args -fun_args(argz[118:145]) -doc_args(argz[118:145]) -in_args(argz[118:145]) - -# histogram2d args -fun_args(argz[147:173]) -doc_args(argz[147:173]) -in_args(argz[147:173]) - -# histogram2dcontour args -fun_args(argz[175:204]) -doc_args(argz[175:204]) -in_args(argz[175:204]) - -# area args -fun_args(argz[206:214]) -doc_args(argz[206:214]) -in_args(argz[206:214]) - -# scatter3d args -fun_args(argz[216:230]) -doc_args(argz[216:230]) -in_args(argz[216:230]) - -# surface args -fun_args(argz[232:240]) -doc_args(argz[232:240]) -in_args(argz[232:240]) - -# ---------------------------------------------------------------------- -# Trace auxiliary objects (in R/aux.R) -# ---------------------------------------------------------------------- - -# error_y args -fun_args(argz[241:251]) -doc_args(argz[241:251]) -in_args(argz[241:251]) - -# error_x args -fun_args(argz[252:263]) -doc_args(argz[252:263]) -in_args(argz[252:263]) - -# xbins args -fun_args(argz[264:266]) -doc_args(argz[264:266]) -in_args(argz[264:266]) - -# ybins args -fun_args(argz[267:269]) -doc_args(argz[267:269]) -in_args(argz[267:269]) - -# marker args -fun_args(argz[270:282]) -doc_args(argz[270:282]) -in_args(argz[270:282]) - -# line args -fun_args(argz[283:290]) -doc_args(argz[283:290]) -in_args(argz[283:290]) - -# contour args -fun_args(argz[291:295]) -doc_args(argz[291:295]) -in_args(argz[291:295]) - -# colorbar args -fun_args(argz[296:326]) -doc_args(argz[296:326]) -in_args(argz[296:326]) - -# stream args -fun_args(argz[327:328]) -doc_args(argz[327:328]) -in_args(argz[327:328]) - -# error_z args -fun_args(argz[329:339]) -doc_args(argz[329:339]) -in_args(argz[329:339]) - -# ---------------------------------------------------------------------- -# Axis objects (in R/axis.R) -# ---------------------------------------------------------------------- - -# xaxis/yaxis/zaxis args are identical -x <- fun_args(argz[340:378]) -y <- fun_args(argz[379:417]) -z <- fun_args(argz[444:482]) -identical(x, y) && identical(y, z) - -x -doc_args(argz[340:378]) -in_args(argz[340:378]) - - -# radialaxis/angularaxis args -fun_args(argz[418:437]) -doc_args(argz[418:437]) -in_args(argz[418:437]) - -# scene args -fun_args(argz[438:443]) -doc_args(argz[438:443]) -in_args(argz[438:443]) - - -# ---------------------------------------------------------------------- -# Layout objects (in R/layout.R) -# ---------------------------------------------------------------------- - -# layout args -fun_args(argz[483:512]) -doc_args(argz[483:512]) -in_args(argz[483:512]) - -# font args -fun_args(argz[513:516]) -doc_args(argz[513:516]) -in_args(argz[513:516]) - -# legend args -fun_args(argz[517:527]) -doc_args(argz[517:527]) -in_args(argz[517:527]) - -# annotation args -fun_args(argz[528:549]) -doc_args(argz[528:549]) -in_args(argz[528:549]) - -# margin args -fun_args(argz[550:557]) -doc_args(argz[550:557]) -in_args(argz[550:557]) diff --git a/man/as.widget.Rd b/man/as.widget.Rd index 9a570a27fe..a4b36000df 100644 --- a/man/as.widget.Rd +++ b/man/as.widget.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/print.R +% Please edit documentation in R/deprecated.R \name{as.widget} \alias{as.widget} \title{Convert a plotly object to an htmlwidget object} @@ -12,7 +12,8 @@ as.widget(x, ...) \item{...}{other options passed onto \code{htmlwidgets::createWidget}} } \description{ -As of version 4.0.0, plotly objects are now htmlwidget objects, -so users shouldn't have to use this function directly. +This function was deprecated in 4.0.0, +as plotly objects are now htmlwidget objects, +so there is no need to convert them. } diff --git a/man/plotly_empty.Rd b/man/plotly_empty.Rd index bdfbc56830..481a37677d 100644 --- a/man/plotly_empty.Rd +++ b/man/plotly_empty.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotly.R +% Please edit documentation in R/helpers.R \name{plotly_empty} \alias{plotly_empty} \title{Create a complete empty plotly graph.} diff --git a/man/toWebGL.Rd b/man/toWebGL.Rd index 901504b427..87ee4df29c 100644 --- a/man/toWebGL.Rd +++ b/man/toWebGL.Rd @@ -4,13 +4,10 @@ \alias{toWebGL} \title{Convert trace types to WebGL} \usage{ -toWebGL(p, warn = TRUE) +toWebGL(p) } \arguments{ \item{p}{a plotly or ggplot object.} - -\item{warn}{should a warning be produced if the trace type doesn't have -a WebGL equivalent?} } \description{ Convert trace types to WebGL From 268d5c402082aa998fe94c5b54875efec40493b5 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 22 Jun 2016 11:45:57 -0500 Subject: [PATCH 55/73] update NEWS; better deparsing --- NEWS | 14 ++++++++------ R/plotly_build.R | 5 ++--- R/utils.R | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index f0c32d37c5..a16982a8f2 100644 --- a/NEWS +++ b/NEWS @@ -3,22 +3,24 @@ BREAKING CHANGES & IMPROVEMENTS: * Formulas (instead of plain expressions) are now required when using variable mappings. For example, `plot_ly(mtcars, x = wt, y = mpg, color = vs)` should now be `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~vs)`. This is a major breaking change, but it is necessary to ensure that evaluation is correct in all contexts (as a result, `evaluate` argument is now deprecated as it is no longer needed). It also has the benefit of being easier to program with (i.e., writing your own custom functions that wrap `plot_ly()`). For more details, see the [lazyeval vignette](https://github.com/hadley/lazyeval/blob/master/vignettes/lazyeval.Rmd) -* The data structure used to represent plotly objects is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, plotly objects can now be serialized across R sessions and avoid [memory leak issues](https://github.com/rstudio/shiny/issues/1151). This also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `help("plotly-data")` for more details). -* The `group` variable mapping no longer create multiple traces, but instead defines "gaps" within a trace (fixes #418, #381, #577). Groupings should be declared via the new `group_by()` function (for examples, see `help("plotly-data")`) instead of the `group` argument (which is now deprecated). -* Scales for variable mappings (such as `color`, `symbol`, `linetype`) are now applied at the plot-level instead of the trace level. As a result, the `colors`/`symbols` arguments have been removed from `add_trace()`. +* The data structure used to represent plotly objects is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, the `as.widget()` function has been deprecated, and [serialization/memory leak problems](https://github.com/rstudio/shiny/issues/1151) are no longer an issue. This change also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `help("plotly-data")` for examples). +* The `group` variable mapping no longer create multiple traces, but instead defines "gaps" within a trace (fixes #418, #381, #577). Groupings should be declared via the new `group_by()` function (see `help("plotly-data")` for examples) instead of the `group` argument (which is now deprecated). +* `plot_ly()` now _initializes_ a plotly object (i.e., won't add a scatter trace by default), meaning that something like `plot_ly(x = 1:10, y = 1:10) %>% add_trace(y = 10:1)` will create one trace, instead of two. However, `plot_ly()` will draw a trace if you manually specify a trace type, for example, `plot_ly(x = 1:10, y = 1:10, type = "scatter") %>% add_trace(y = 10:1)` will draw two scatter traces. If no trace type is provided, a sensible type is inferred from the supplied data, and automatically added (i.e., `plot_ly(x = rnorm(100))` now creates a histogram). * The `inherit` argument is deprecated. Any arguments/attributes specified in `plot_ly()` will automatically be passed along to additional traces added via `add_trace()` (or any of it's `add_*()` siblings). +* Scales for variable mappings (such as `color`, `symbol`, `linetype`) are now applied at the plot-level instead of the trace level. For this reason, the range of these scales (`colors`/`symbols`/`linetypes`) should be specified in `plot_ly()`, instead of `add_trace()` or any of it's `add_*()` siblings. NEW FEATURES & IMPROVEMENTS: * Error checking for trace and layout attributes. -* If no trace type is provided, a sensible type is inferred from the supplied data. -* New `add_polygons()`/`add_ribbons()`/`add_lines()`/`add_markers()`/`add_paths()`/`add_text()` functions provide a shorthand for common plots. +* New `add_polygons()`/`add_ribbons()`/`add_area()`/`add_segments()`/`add_lines()`/`add_markers()`/`add_paths()`/`add_text()` functions provide a shorthand for common visual markings. +* New `plotly_data()` function for returning/inspecting data frame(s) associated with a plotly object. +* New `plotly_json()` function for inspecting the data sent to plotly.js (as an R list or JSON). * Added `linetype`/`linetypes` arguments for mapping discrete variables to line types (this works very much like the `symbol`/`symbols`). * Added a `sizes` argument for controlling the range of marker size scaling. * New `toWebGL()` function for easy conversion from SVG to WebGL. * New `export()` function makes it easy to save plots as png/jpeg/pdf (fixes #311). * `layout()` is now a generic function and uses method dispatch to avoid conflicts with `graphics:layout()` (fixes #464). -* Added a `plotly_json()` function for inspecting the data sent to plotly.js (as an R list or JSON). + OTHER CHANGES: diff --git a/R/plotly_build.R b/R/plotly_build.R index 907db4d94d..a04307ac40 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -58,7 +58,7 @@ plotly_build.plotly <- function(p) { nm <- paste0(i, "axis") idx <- which(names(x) %in% i) if (length(idx) == 1) { - title <- sub("^~", "", deparse2(x[[idx]])) + title <- deparse2(x[[idx]]) if (is3d(x$type) || i == "z") { p$x$layout$scene[[nm]]$title <<- p$x$layout$scene[[nm]]$title %||% title } else { @@ -153,8 +153,7 @@ plotly_build.plotly <- function(p) { # "transforms" of (i.e., apply scaling to) special arguments # IMPORTANT: scales are applied at the plot-level!! colorTitle <- unlist(lapply(p$x$attrs, function(x) { - col <- x[["color"]] %||% x[["z"]] - if (is.language(col)) sub("^~", "", deparse2(col)) else NULL + deparse2(x[["color"]] %||% x[["z"]]) })) traces <- map_color(traces, title = paste(colorTitle, collapse = "
")) traces <- map_size(traces) diff --git a/R/utils.R b/R/utils.R index 054fc1ce14..3a185a1852 100644 --- a/R/utils.R +++ b/R/utils.R @@ -27,8 +27,8 @@ is.discrete <- function(x) { } deparse2 <- function(x) { - if (is.null(x)) return(NULL) - paste(deparse(x, 500L), collapse = "") + if (is.null(x) || !is.language(x)) return(NULL) + sub("^~", "", paste(deparse(x, 500L), collapse = "")) } new_id <- function() { From 456d186714d79afe56703a242d0238ec6390c0b3 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 22 Jun 2016 12:16:42 -0500 Subject: [PATCH 56/73] add event source; fixes event_data() on plotly graphs --- R/plotly.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/plotly.R b/R/plotly.R index f3264c81b4..334be23b19 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -118,7 +118,9 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, group, margin = list(b = 40, l = 60, t = 25, r = 10) ), config = list(modeBarButtonsToRemove = I("sendDataToCloud")), - base_url = get_domain() + base_url = get_domain(), + # TODO: make this trace specific when we merge with crosstalk branch + source = source ) as_widget(p) From b2b9bd76efb7df40baa77222292709df269f0597 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 22 Jun 2016 12:20:46 -0500 Subject: [PATCH 57/73] fix config() --- R/layout.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/layout.R b/R/layout.R index bbfa66a716..6bd47bd550 100644 --- a/R/layout.R +++ b/R/layout.R @@ -42,7 +42,6 @@ layout.plotly <- function(p, ..., data = NULL) { #' } config <- function(p, ...) { - nConfig <- length(p$x$config) - p$x$config[[nConfig + 1]] <- list(...) + p$x$config <- modify_list(p$x$config, list(...)) p } From 04dde5d86d946192acf809f58b7af2bcbb6513d4 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 22 Jun 2016 13:14:01 -0500 Subject: [PATCH 58/73] update inst/examples --- R/utils.R | 2 +- inst/examples/Movies/server.R | 2 +- inst/examples/UN_Advanced/server.R | 36 +++++-------------- inst/examples/UN_Simple/server.R | 2 +- inst/examples/lmGadget/app.R | 52 +++++++++++---------------- inst/examples/plotlyEvents/app.R | 2 +- inst/examples/plotlyLinkedBrush/app.R | 2 +- inst/examples/plotlyLinkedClick/app.R | 7 ++-- vignettes/subplot.Rmd | 2 +- 9 files changed, 38 insertions(+), 69 deletions(-) diff --git a/R/utils.R b/R/utils.R index 3a185a1852..35f9292859 100644 --- a/R/utils.R +++ b/R/utils.R @@ -88,7 +88,7 @@ verify_boxed <- function(p) { } for (tr in seq_along(p$x$data)) { thisTrace <- p$x$data[[tr]] - validAttrs <- Schema$traces[[thisTrace$type]]$attributes + validAttrs <- Schema$traces[[thisTrace$type %||% "scatter"]]$attributes p$x$data[[tr]] <- verify_box(thisTrace, validAttrs) } p diff --git a/inst/examples/Movies/server.R b/inst/examples/Movies/server.R index 779db302ac..343a42cb24 100644 --- a/inst/examples/Movies/server.R +++ b/inst/examples/Movies/server.R @@ -12,7 +12,7 @@ shinyServer(function(input, output) { size <- (maxx - minx) / input$bins # a simple histogram of movie ratings - p <- plot_ly(movies, x = rating, autobinx = F, type = "histogram", + p <- plot_ly(movies, x = ~rating, autobinx = F, type = "histogram", xbins = list(start = minx, end = maxx, size = size)) # style the xaxis layout(p, xaxis = list(title = "Ratings", range = c(minx, maxx), autorange = F, diff --git a/inst/examples/UN_Advanced/server.R b/inst/examples/UN_Advanced/server.R index 8e255b8054..27f127d282 100644 --- a/inst/examples/UN_Advanced/server.R +++ b/inst/examples/UN_Advanced/server.R @@ -22,38 +22,18 @@ shinyServer(function(input, output, session) { graph_title <- paste("Ideal Points for ", j_names, sep="") ggideal_point <- ggplot(df_trend) + - geom_line(aes(x = Year, y = Ideal.point, by = Name, color = Name)) + + geom_line(aes(x = Year, y = Ideal.point, color = Name)) + labs(x = "Year", y = "Ideology", title = graph_title) + scale_colour_hue("clarity", l = 70, c = 150) + ggthemes::theme_few() + - theme(legend.direction = "horizontal", legend.position = "bottom") + theme(legend.position = "none") # Convert ggplot object to plotly - gg <- plotly_build(ggideal_point) - - # Use Plotly syntax to further edit the plot: - gg$layout$annotations <- NULL # Remove the existing annotations (the legend label) - gg$layout$annotations <- list() - - # Add colored text annotations next to the end of each line - # More about plotly annotations: https://plot.ly/r/reference/#annotation - # Each key that we update is documented in that link above. - for (i in 1:length(gg$data)) { # data is a list of the lines in the graph - gg$layout$annotations[[i]] <- list( - text = gg$data[[i]]$name, # The text label of the annotation, e.g. "Canada" - font = list(color = gg$data[[i]]$line$color), # Match the font color to the line color - showarrow = FALSE, # Don't show the annotation arrow - y = gg$data[[i]]$y[[length(gg$data[[i]]$y)]], # set the y position of the annotation to the last point of the line - yref = "y1", # the "y" coordinates above are with respect to the yaxis - x = 1, # set the x position of the graph to the right hand side of the graph - xref = "paper", # the x coordinates are with respect to the "paper", where 1 means the right hand side of the graph and 0 means the left hand side - xanchor = "left" # position the x coordinate with respect to the left of the text - ); - } - - gg$layout$showlegend <- FALSE # remove the legend - gg$layout$margin$r <- 170 # increase the size of the right margin to accommodate more room for the annotation labels - gg - + ggplotly(ggideal_point) %>% + layout( + showlegend = FALSE, + # increase the size of the right margin to accommodate more room for the annotation labels + margin = list(r = 170) + ) } }) diff --git a/inst/examples/UN_Simple/server.R b/inst/examples/UN_Simple/server.R index 3c99f90ca4..61746c41b5 100644 --- a/inst/examples/UN_Simple/server.R +++ b/inst/examples/UN_Simple/server.R @@ -10,7 +10,7 @@ shinyServer(function(input, output, session) { } else { df_trend <- ideal[ideal$Name == input$name, ] ggplot(df_trend) + - geom_line(aes(x = Year, y = Ideal.point, by = Name, color = Name)) + + geom_line(aes(x = Year, y = Ideal.point, color = Name)) + labs(x = "Year", y = "Ideology", title = "Ideal Points for Countries") + scale_colour_hue("clarity", l = 70, c = 150) + ggthemes::theme_few() } diff --git a/inst/examples/lmGadget/app.R b/inst/examples/lmGadget/app.R index ab74a479ad..18683e9782 100644 --- a/inst/examples/lmGadget/app.R +++ b/inst/examples/lmGadget/app.R @@ -10,10 +10,11 @@ library(plotly) #' Click on points to add/remove them from consideration #' #' @param dat a data.frame -#' @param x a character string specifying the x variable -#' @param y a character string specifying the y variable +#' @param x a formula specifying the x variable +#' @param y a formula specifying the y variable +#' @param key a vector specifying unique attributes for each row -lmGadget <- function(dat, x, y) { +lmGadget <- function(dat, x, y, key = row.names(dat)) { ui <- miniPage( gadgetTitleBar("Interactive lm"), @@ -40,38 +41,25 @@ lmGadget <- function(dat, x, y) { selection <- init() server <- function(input, output) { - - # obtain a subset of the data that is still under consideration - left <- reactive({ - d <- event_data("plotly_click") - if (!is.null(d)) { - dat <- dat[!selection(row.names(dat) %in% d[["key"]]), ] - } - dat - }) - - # fit a model to subsetted data - refit <- reactive({ + + output$plot1 <- renderPlotly({ req(input$degree) + d <- event_data("plotly_click") + selected <- selection(key %in% d[["key"]]) + modelDat <- dat[!selected, ] formula <- as.formula( - sprintf("%s ~ poly(%s, degree = %s)", y, x, input$degree) + sprintf("%s ~ poly(%s, degree = %s)", as.character(y)[2], as.character(x)[2], input$degree) ) - lm(formula, left()) - }) - - output$plot1 <- renderPlotly({ - dat2 <- left() - dat2$yhat <- as.numeric(fitted(refit())) - # sort data by 'x' variable so we draw a line (not a path) - dat2 <- dat2[order(dat2[, x]), ] + m <- lm(formula, modelDat) + modelDat$yhat <- as.numeric(fitted(m)) + mcolor <- rep(toRGB("black"), NROW(dat)) + mcolor[selected] <- toRGB("grey90") - plot_ly(x = dat[, x], y = dat[, y], key = row.names(dat), mode = "markers", - marker = list(color = toRGB("grey90"), size = 10)) %>% - add_trace(x = dat2[, x], y = dat2[, y], mode = "markers", - marker = list(color = toRGB("black"), size = 10)) %>% - add_trace(x = dat2[, x], y = dat2$yhat, mode = "lines", - marker = list(color = toRGB("black"))) %>% - layout(showlegend = FALSE, xaxis = list(title = x), yaxis = list(title = y)) + dat %>% + plot_ly(x = x, y = y) %>% + add_markers(key = key, marker = list(color = mcolor, size = 10)) %>% + add_lines(y = ~yhat, data = modelDat) %>% + layout(showlegend = FALSE) }) # Return the most recent fitted model, when we press "done" @@ -83,4 +71,4 @@ lmGadget <- function(dat, x, y) { runGadget(ui, server) } -m <- lmGadget(mtcars, "wt", "mpg") +m <- lmGadget(mtcars, x = ~wt, y = ~mpg) diff --git a/inst/examples/plotlyEvents/app.R b/inst/examples/plotlyEvents/app.R index a140df4666..3d64c349ff 100644 --- a/inst/examples/plotlyEvents/app.R +++ b/inst/examples/plotlyEvents/app.R @@ -20,7 +20,7 @@ server <- function(input, output, session) { geom_point() ggplotly(p) %>% layout(dragmode = "select") } else { - plot_ly(mtcars, x = mpg, y = wt, key = key, mode = "markers") %>% + plot_ly(mtcars, x = ~mpg, y = ~wt, key = ~key, mode = "markers") %>% layout(dragmode = "select") } }) diff --git a/inst/examples/plotlyLinkedBrush/app.R b/inst/examples/plotlyLinkedBrush/app.R index 24e5c075d4..aaf8c32451 100644 --- a/inst/examples/plotlyLinkedBrush/app.R +++ b/inst/examples/plotlyLinkedBrush/app.R @@ -72,7 +72,7 @@ server <- function(input, output, session) { output$xy <- renderPlotly({ cars %>% - plot_ly(x = speed, y = dist, + plot_ly(x = ~speed, y = ~dist, mode = "markers", marker = m) %>% layout(dragmode = "select") }) diff --git a/inst/examples/plotlyLinkedClick/app.R b/inst/examples/plotlyLinkedClick/app.R index 5167cea3d7..3f0af79789 100644 --- a/inst/examples/plotlyLinkedClick/app.R +++ b/inst/examples/plotlyLinkedClick/app.R @@ -40,13 +40,14 @@ server <- function(input, output, session) { vars <- c(s[["x"]], s[["y"]]) d <- setNames(mtcars[vars], c("x", "y")) yhat <- fitted(lm(y ~ x, data = d)) - plot_ly(d, x = x, y = y, mode = "markers") %>% - add_trace(x = x, y = yhat, mode = "lines") %>% + plot_ly(d, x = ~x) %>% + add_markers(y = ~y) %>% + add_lines(y = ~yhat) %>% layout(xaxis = list(title = s[["x"]]), yaxis = list(title = s[["y"]]), showlegend = FALSE) } else { - plot_ly() + plotly_empty() } }) diff --git a/vignettes/subplot.Rmd b/vignettes/subplot.Rmd index fe66752157..bca66b9620 100644 --- a/vignettes/subplot.Rmd +++ b/vignettes/subplot.Rmd @@ -55,7 +55,7 @@ subplot(plots, nrows = length(plots), shareX = TRUE, titleX = FALSE) # this works too, but I'm not sure we should advertise... elong <- tidyr::gather(economics, variable, value, -date) elong$id <- as.integer(factor(elong$variable)) -p <- plot_ly(elong, x = ~date, y = ~value, group = ~variable, yaxis = ~paste0("y", id)) +p <- plot_ly(elong, x = ~date, y = ~value, color = ~variable, yaxis = ~paste0("y", id)) subplot(p, nrows = 5, shareX = TRUE) ``` From 132b9cda93f9c46740e5a9c1afc5a2d2fda8fc4b Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 22 Jun 2016 16:41:03 -0500 Subject: [PATCH 59/73] vapply is too strict --- R/plotly_build.R | 8 ++++---- R/utils.R | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/plotly_build.R b/R/plotly_build.R index a04307ac40..fa98b731d5 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -252,8 +252,8 @@ map_size <- function(traces) { } sizeRange <- range(allSize, na.rm = TRUE) - types <- vapply(traces, function(tr) tr$type, character(1)) - modes <- vapply(traces, function(tr) tr$mode %||% "lines", character(1)) + types <- unlist(lapply(traces, function(tr) tr$type %||% "scatter")) + modes <- unlist(lapply(traces, function(tr) tr$mode %||% "lines")) hasMarker <- has_marker(types, modes) hasLine <- has_line(types, modes) hasText <- has_text(types, modes) @@ -296,8 +296,8 @@ map_color <- function(traces, title = "", na.color = "transparent") { stop("Can't have both discrete and numeric color mappings", call. = FALSE) } # color/colorscale/colorbar attribute placement depends on trace type and marker mode - types <- vapply(traces, function(tr) tr$type, character(1)) - modes <- vapply(traces, function(tr) tr$mode %||% "lines", character(1)) + types <- unlist(lapply(traces, function(tr) tr$type %||% "scatter")) + modes <- unlist(lapply(traces, function(tr) tr$mode %||% "lines")) hasMarker <- has_marker(types, modes) hasLine <- has_line(types, modes) hasText <- has_text(types, modes) diff --git a/R/utils.R b/R/utils.R index 35f9292859..f5eb98fb09 100644 --- a/R/utils.R +++ b/R/utils.R @@ -219,8 +219,8 @@ verify_hovermode <- function(p) { if (!is.null(p$x$layout$hovermode)) { return(p) } - types <- vapply(p$x$data, function(tr) tr$type, character(1)) - modes <- vapply(p$x$data, function(tr) tr$mode %||% "lines", character(1)) + types <- unlist(lapply(p$x$data, function(tr) tr$type %||% "scatter")) + modes <- unlist(lapply(p$x$data, function(tr) tr$mode %||% "lines")) if (any(grepl("markers", modes) & types == "scatter")) { p$x$layout$hovermode <- "closest" } From 3335d3934ca08ee33b752657c38b26d9e8a344ad Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 22 Jun 2016 17:12:18 -0500 Subject: [PATCH 60/73] documentation fixes --- NAMESPACE | 3 +++ R/add.R | 8 +++++--- R/helpers.R | 1 + R/utils.R | 1 - man/add_trace.Rd | 9 +++++++-- man/hide_colorbar.Rd | 6 ++++++ 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index b7f229dc86..4cee612392 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -45,11 +45,13 @@ S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) S3method(to_basic,default) export("%>%") +export(add_area) export(add_data) export(add_lines) export(add_markers) export(add_paths) export(add_polygons) +export(add_ribbons) export(add_segments) export(add_text) export(add_trace) @@ -68,6 +70,7 @@ export(ggplotly) export(group_by) export(group_by_.plotly) export(groups.plotly) +export(hide_colorbar) export(knit_print.plotly_figure) export(layout) export(mutate_.plotly) diff --git a/R/add.R b/R/add.R index 64a35825a6..7421e879f5 100644 --- a/R/add.R +++ b/R/add.R @@ -153,7 +153,6 @@ add_lines <- function(p, x = NULL, y = NULL, ...) { #' @inheritParams add_trace #' @rdname add_trace #' @export -#' add_segments <- function(p, x = NULL, y = NULL, xend = NULL, yend = NULL, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) @@ -174,6 +173,8 @@ add_segments <- function(p, x = NULL, y = NULL, xend = NULL, yend = NULL, ...) { } +#' +#' #' @inheritParams add_trace #' @rdname add_trace #' @export @@ -199,11 +200,11 @@ add_polygons <- function(p, x = NULL, y = NULL, ...) { ) } -#' Ribbon plots -#' + #' @inheritParams add_trace #' @rdname add_trace #' @export +#' @examples #' #' plot_ly(economics, x = ~date) %>% #' add_ribbons(ymin = ~pce - 1e3, ymax = ~pce + 1e3) @@ -232,6 +233,7 @@ add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, ...) { #' @inheritParams add_trace #' @rdname add_trace #' @export +#' @examples #' #' huron <- data.frame(year = 1875:1972, level = as.vector(LakeHuron)) #' plot_ly(huron, x = ~year, ymax = ~level) %>% add_area() diff --git a/R/helpers.R b/R/helpers.R index 10d24d7565..94f7e03723 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -2,6 +2,7 @@ #' #' @param p a plotly object. #' @export +#' @examples #' #' plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop) %>% #' add_markers() %>% diff --git a/R/utils.R b/R/utils.R index f5eb98fb09..6ab983f0b0 100644 --- a/R/utils.R +++ b/R/utils.R @@ -106,7 +106,6 @@ verify_box <- function(proposed, schema) { identical(attrSchema[["role"]], "object"), error = function(e) FALSE ) - if (isArray) { proposed[[attr]] <- i(attrVal) } diff --git a/man/add_trace.Rd b/man/add_trace.Rd index fd682fa3cf..12ef1f0f49 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -68,8 +68,6 @@ Add text to a plotly vis Equivalent to \code{add_paths}, but with the x-values sorted. -Ribbon plots - Equivalent to \link{add_ribbon} with \code{ymin} set to 0. } \examples{ @@ -94,6 +92,13 @@ ggplot2::map_data("world", "canada") \%>\% add_markers(text = ~paste(name, "
", pop), hoverinfo = "text", data = maps::canada.cities) \%>\% layout(showlegend = FALSE) + +plot_ly(economics, x = ~date) \%>\% + add_ribbons(ymin = ~pce - 1e3, ymax = ~pce + 1e3) + +huron <- data.frame(year = 1875:1972, level = as.vector(LakeHuron)) +plot_ly(huron, x = ~year, ymax = ~level) \%>\% add_area() + } \author{ Carson Sievert diff --git a/man/hide_colorbar.Rd b/man/hide_colorbar.Rd index 14ddffe2b6..575d45f689 100644 --- a/man/hide_colorbar.Rd +++ b/man/hide_colorbar.Rd @@ -12,4 +12,10 @@ hide_colorbar(p) \description{ Hide a color bar } +\examples{ + +plot_ly(economics, x = ~date, y = ~unemploy / pop, color = ~pop) \%>\% + add_markers() \%>\% + hide_colorbar() +} From fd2d9d594c5d994a5491fde9d11d41bd81e1ec96 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 22 Jun 2016 21:19:17 -0500 Subject: [PATCH 61/73] some grouping/ordering fixes --- R/add.R | 27 ++++++++++++++++++--------- R/plotly_build.R | 20 ++++++++++++-------- man/add_trace.Rd | 14 ++++++++++---- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/R/add.R b/R/add.R index 7421e879f5..70e807fe36 100644 --- a/R/add.R +++ b/R/add.R @@ -97,37 +97,39 @@ add_markers <- function(p, x = NULL, y = NULL, ...) { add_trace(p, x = x, y = y, type = "scatter", mode = "markers", ...) } -#' Add paths to a plotly vis +#' Add text to a plotly vis #' #' @inheritParams add_trace #' @rdname add_trace #' @export -add_paths <- function(p, x = NULL, y = NULL, ...) { +add_text <- function(p, x = NULL, y = NULL, text = NULL, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { stop("Must supply `y` attribute", call. = FALSE) } - add_trace(p, x = x, y = y, type = "scatter", mode = "lines", ...) + if (is.null(text <- text %||% p$x$attrs[[1]][["text"]])) { + stop("Must supply `text` attribute", call. = FALSE) + } + add_trace(p, x = x, y = y, text = text, type = "scatter", mode = "text", ...) } -#' Add text to a plotly vis +#' Add paths to a plotly vis #' #' @inheritParams add_trace #' @rdname add_trace #' @export -add_text <- function(p, x = NULL, y = NULL, text = NULL, ...) { +add_paths <- function(p, x = NULL, y = NULL, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { stop("Must supply `y` attribute", call. = FALSE) } - if (is.null(text <- text %||% p$x$attrs[[1]][["text"]])) { - stop("Must supply `text` attribute", call. = FALSE) - } - add_trace(p, x = x, y = y, text = text, type = "scatter", mode = "text", ...) + add_trace_classed( + p, x = x, y = y, class = "plotly_path", type = "scatter", mode = "lines", ... + ) } #' Add lines to a plotly vis @@ -137,6 +139,13 @@ add_text <- function(p, x = NULL, y = NULL, text = NULL, ...) { #' @inheritParams add_trace #' @rdname add_trace #' @export +#' @examples +#' +#' txhousing %>% +#' group_by(city) %>% +#' plot_ly(x = ~date, y = ~median) %>% +#' add_lines(line = list(color = toRGB("black", 0.2))) +#' add_lines <- function(p, x = NULL, y = NULL, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) diff --git a/R/plotly_build.R b/R/plotly_build.R index fa98b731d5..ea25b938c7 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -80,16 +80,12 @@ plotly_build.plotly <- function(p) { nobs <- NROW(dat) isVar <- vapply(x, function(attr) length(attr) == nobs, logical(1)) builtData <- data.frame(x[isVar & !names(x) %in% c("colors", "symbols", "linetypes")]) - builtData <- train_data(builtData, x) - # TODO: provide a better way to clean up "high-level" attrs - x[c("ymin", "ymax", "yend", "xend")] <- NULL - x$.plotlyVariableMapping <- names(builtData) # find any groupings, so we can arrange the data now, # and insert missing values (to create gaps between traces) later - grps <- as.character(dplyr::groups(builtData)) + grps <- as.character(dplyr::groups(dat)) # does grouping even make sense for this trace type? - hasGrp <- inherits(x, c("plotly_segment", "plotly_line", "plotly_polygon")) || + hasGrp <- inherits(x, c("plotly_segment", "plotly_path", "plotly_line", "plotly_polygon")) || (grepl("scatter", x$type) && grepl("lines", x$mode %||% "lines")) if (length(grps) && hasGrp) { if (isTRUE(x$connectgaps)) { @@ -98,9 +94,14 @@ plotly_build.plotly <- function(p) { call. = FALSE ) } - builtData$.plotlyGroupIndex <- interaction(builtData[, grps, drop = FALSE]) + builtData$.plotlyGroupIndex <- interaction(dat[, grps, drop = FALSE]) } + builtData <- train_data(builtData, x) + # TODO: provide a better way to clean up "high-level" attrs + x[c("ymin", "ymax", "yend", "xend")] <- NULL + x$.plotlyVariableMapping <- names(builtData) + # build the index used to transform one "trace" into multiple traces discreteData <- builtData[vapply(builtData, is.discrete, logical(1))] discreteData <- discreteData[names(discreteData) %in% c("symbol", "linetype", "color")] @@ -143,7 +144,10 @@ plotly_build.plotly <- function(p) { # insert NAs to differentiate groups traces <- lapply(traces, function(x) { d <- data.frame(x[names(x) %in% c(x$.plotlyVariableMapping)]) - d <- group2NA(d, ".plotlyGroupIndex", retrace.first = inherits(x, "plotly_polygon")) + d <- group2NA( + d, ".plotlyGroupIndex", ordered = if (inherits(x, "plotly_line")) "x", + retrace.first = inherits(x, "plotly_polygon") + ) for (i in x$.plotlyVariableMapping) { x[[i]] <- uniq(d[[i]]) } diff --git a/man/add_trace.Rd b/man/add_trace.Rd index 12ef1f0f49..ec0fc18787 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -16,10 +16,10 @@ add_trace(p, ..., color, symbol, size, linetype, data = NULL) add_markers(p, x = NULL, y = NULL, ...) -add_paths(p, x = NULL, y = NULL, ...) - add_text(p, x = NULL, y = NULL, text = NULL, ...) +add_paths(p, x = NULL, y = NULL, ...) + add_lines(p, x = NULL, y = NULL, ...) add_segments(p, x = NULL, y = NULL, xend = NULL, yend = NULL, ...) @@ -62,10 +62,10 @@ Add trace(s) to a plotly visualization Add points to a plotly vis -Add paths to a plotly vis - Add text to a plotly vis +Add paths to a plotly vis + Equivalent to \code{add_paths}, but with the x-values sorted. Equivalent to \link{add_ribbon} with \code{ymin} set to 0. @@ -85,6 +85,12 @@ plot_ly(economics, x = ~date, y = ~uempmed) \%>\% layout(showlegend = FALSE) +txhousing \%>\% + group_by(city) \%>\% + plot_ly(x = ~date, y = ~median) \%>\% + add_lines(line = list(color = toRGB("black", 0.2))) + + ggplot2::map_data("world", "canada") \%>\% group_by(group) \%>\% plot_ly(x = ~long, y = ~lat) \%>\% From 0e744dcf7ac87dc34a143f1c73e0bfe41faab657 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 23 Jun 2016 10:20:44 -0500 Subject: [PATCH 62/73] add_heatmap --- NAMESPACE | 1 + R/add.R | 21 +++++++++++++++++++++ R/plotly_build.R | 11 +++++++++++ man/add_trace.Rd | 8 ++++++++ 4 files changed, 41 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 4cee612392..869e40791a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -47,6 +47,7 @@ S3method(to_basic,default) export("%>%") export(add_area) export(add_data) +export(add_heatmap) export(add_lines) export(add_markers) export(add_paths) diff --git a/R/add.R b/R/add.R index 70e807fe36..d37128c606 100644 --- a/R/add.R +++ b/R/add.R @@ -261,6 +261,27 @@ add_area <- function(p, x = NULL, ymax = NULL, ...) { ) } +#' Heatmaps +#' +#' @inheritParams add_trace +#' @rdname add_trace +#' @export +#' @examples +#' +#' plot_ly(z = ~volcano) %>% add_heatmap() +#' +add_heatmap <- function(p, z = NULL, ...) { + if (is.null(z <- z %||% p$x$attrs[[1]][["z"]])) { + stop("Must supply `z` attribute", call. = FALSE) + } + add_trace_classed( + p, class = "plotly_heatmap", z = z, + type = "heatmap", ... + ) +} + + + # attach a class to a trace which informs data processing in plotly_build add_trace_classed <- function(p, class = "plotly_polygon", ...) { p <- add_trace(p, ...) diff --git a/R/plotly_build.R b/R/plotly_build.R index ea25b938c7..221123289e 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -74,6 +74,17 @@ plotly_build.plotly <- function(p) { # ensure we have a trace type (depends on the # of data points) x <- verify_type(x) + # do some attribute type checking for special trace types + if (inherits(x, "plotly_heatmap")) { + if (!is.matrix(x$z)) { + stop("`z` must be a matrix", call. = FALSE) + } + if (!is.numeric(x$z)) { + stop("`z` must be numeric", call. = FALSE) + } + } + + # TODO: if we ever provide some semantics for statistics, it should probably go here # gather the "built" or "evaluated" data diff --git a/man/add_trace.Rd b/man/add_trace.Rd index ec0fc18787..08d89ba113 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/add.R \name{add_trace} \alias{add_area} +\alias{add_heatmap} \alias{add_lines} \alias{add_markers} \alias{add_paths} @@ -29,6 +30,8 @@ add_polygons(p, x = NULL, y = NULL, ...) add_ribbons(p, x = NULL, ymin = NULL, ymax = NULL, ...) add_area(p, x = NULL, ymax = NULL, ...) + +add_heatmap(p, z = NULL, ...) } \arguments{ \item{p}{a plotly or ggplot object.} @@ -69,6 +72,8 @@ Add paths to a plotly vis Equivalent to \code{add_paths}, but with the x-values sorted. Equivalent to \link{add_ribbon} with \code{ymin} set to 0. + +Heatmaps } \examples{ @@ -105,6 +110,9 @@ plot_ly(economics, x = ~date) \%>\% huron <- data.frame(year = 1875:1972, level = as.vector(LakeHuron)) plot_ly(huron, x = ~year, ymax = ~level) \%>\% add_area() + +plot_ly(z = ~volcano) \%>\% add_heatmap() + } \author{ Carson Sievert From a807ad4be800b205d2bb944232e226d2816716be Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 23 Jun 2016 11:33:11 -0500 Subject: [PATCH 63/73] add a few more basic add_*() functions --- NAMESPACE | 3 +++ R/add.R | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ R/plotly_build.R | 2 +- R/utils.R | 2 +- man/add_trace.Rd | 28 ++++++++++++++++++++ 5 files changed, 99 insertions(+), 2 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 869e40791a..0d75f3d44c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -46,14 +46,17 @@ S3method(to_basic,GeomVline) S3method(to_basic,default) export("%>%") export(add_area) +export(add_bars) export(add_data) export(add_heatmap) +export(add_histogram) export(add_lines) export(add_markers) export(add_paths) export(add_polygons) export(add_ribbons) export(add_segments) +export(add_surface) export(add_text) export(add_trace) export(arrange_.plotly) diff --git a/R/add.R b/R/add.R index d37128c606..76104581ca 100644 --- a/R/add.R +++ b/R/add.R @@ -261,6 +261,54 @@ add_area <- function(p, x = NULL, ymax = NULL, ...) { ) } + +#' Bar chart +#' +#' @inheritParams add_trace +#' @rdname add_trace +#' @export +#' @examples +#' +#' library(dplyr) +#' mtcars %>% +#' count(vs) %>% +#' plot_ly(x = ~vs, y = ~n) %>% +#' add_bars() +#' +add_bars <- function(p, x = NULL, y = NULL, ...) { + x <- x %||% p$x$attrs[[1]][["x"]] + y <- y %||% p$x$attrs[[1]][["y"]] + if (is.null(x) && is.null(y)) { + stop("Must supply `x` and/or `y` attributes", call. = FALSE) + } + # TODO: provide type checking in plotly_build for this trace type + add_trace_classed( + p, class = "plotly_bar", x = x, y = y, type = "bar", ... + ) +} + +#' Histogram +#' +#' @inheritParams add_trace +#' @rdname add_trace +#' @export +#' @examples +#' +#' plot_ly(x = ~rnorm(100)) %>% add_histogram() +#' +add_histogram <- function(p, x = NULL, y = NULL, ...) { + x <- x %||% p$x$attrs[[1]][["x"]] + y <- y %||% p$x$attrs[[1]][["y"]] + if (is.null(x) && is.null(y)) { + stop("Must supply `x` and/or `y` attributes", call. = FALSE) + } + # TODO: provide type checking in plotly_build for this trace type + add_trace_classed( + p, class = "plotly_histogram", x = x, y = y, type = "histogram", ... + ) +} + + #' Heatmaps #' #' @inheritParams add_trace @@ -280,6 +328,24 @@ add_heatmap <- function(p, z = NULL, ...) { ) } +#' Surface +#' +#' @inheritParams add_trace +#' @rdname add_trace +#' @export +#' @examples +#' +#' plot_ly(z = ~volcano) %>% add_surface() +#' +add_surface <- function(p, z = NULL, ...) { + if (is.null(z <- z %||% p$x$attrs[[1]][["z"]])) { + stop("Must supply `z` attribute", call. = FALSE) + } + add_trace_classed( + p, class = "plotly_surface", z = z, type = "surface", ... + ) +} + # attach a class to a trace which informs data processing in plotly_build diff --git a/R/plotly_build.R b/R/plotly_build.R index 221123289e..a6abb8d886 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -75,7 +75,7 @@ plotly_build.plotly <- function(p) { x <- verify_type(x) # do some attribute type checking for special trace types - if (inherits(x, "plotly_heatmap")) { + if (inherits(x, c("plotly_heatmap", "plotly_surface"))) { if (!is.matrix(x$z)) { stop("`z` must be a matrix", call. = FALSE) } diff --git a/R/utils.R b/R/utils.R index 6ab983f0b0..089349c2ca 100644 --- a/R/utils.R +++ b/R/utils.R @@ -168,7 +168,7 @@ verify_type <- function(trace) { relay_type <- function(type) { message( - "No trace type specified. Inferring a type of '", type, "'.\n", + "No trace type specified. Applying `add_", type, "()`.\n", "Read more about this trace type here -> https://plot.ly/r/reference/#", type ) type diff --git a/man/add_trace.Rd b/man/add_trace.Rd index 08d89ba113..2feccf7a4e 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -2,13 +2,16 @@ % Please edit documentation in R/add.R \name{add_trace} \alias{add_area} +\alias{add_bars} \alias{add_heatmap} +\alias{add_histogram} \alias{add_lines} \alias{add_markers} \alias{add_paths} \alias{add_polygons} \alias{add_ribbons} \alias{add_segments} +\alias{add_surface} \alias{add_text} \alias{add_trace} \title{Add trace(s) to a plotly visualization} @@ -31,7 +34,13 @@ add_ribbons(p, x = NULL, ymin = NULL, ymax = NULL, ...) add_area(p, x = NULL, ymax = NULL, ...) +add_bars(p, x = NULL, y = NULL, ...) + +add_histogram(p, x = NULL, y = NULL, ...) + add_heatmap(p, z = NULL, ...) + +add_surface(p, z = NULL, ...) } \arguments{ \item{p}{a plotly or ggplot object.} @@ -73,7 +82,13 @@ Equivalent to \code{add_paths}, but with the x-values sorted. Equivalent to \link{add_ribbon} with \code{ymin} set to 0. +Bar chart + +Histogram + Heatmaps + +Surface } \examples{ @@ -111,8 +126,21 @@ huron <- data.frame(year = 1875:1972, level = as.vector(LakeHuron)) plot_ly(huron, x = ~year, ymax = ~level) \%>\% add_area() +library(dplyr) +mtcars \%>\% + count(vs) \%>\% + plot_ly(x = ~vs, y = ~n) \%>\% + add_bars() + + +plot_ly(x = ~rnorm(100)) \%>\% add_histogram() + + plot_ly(z = ~volcano) \%>\% add_heatmap() + +plot_ly(z = ~volcano) \%>\% add_surface() + } \author{ Carson Sievert From 1359a14256c10b934b1a61892f6f1b70e2b64ec2 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 23 Jun 2016 12:02:30 -0500 Subject: [PATCH 64/73] moar add_*() --- NAMESPACE | 6 +++ R/add.R | 131 +++++++++++++++++++++++++++++++++++++++++++++++ R/plotly_build.R | 2 +- man/add_trace.Rd | 55 ++++++++++++++++++++ 4 files changed, 193 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index 0d75f3d44c..77d12284fe 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -47,14 +47,20 @@ S3method(to_basic,default) export("%>%") export(add_area) export(add_bars) +export(add_boxplot) +export(add_choropleth) +export(add_contour) export(add_data) export(add_heatmap) export(add_histogram) +export(add_histogram2d) +export(add_histogram2dcontour) export(add_lines) export(add_markers) export(add_paths) export(add_polygons) export(add_ribbons) +export(add_scattergeo) export(add_segments) export(add_surface) export(add_text) diff --git a/R/add.R b/R/add.R index 76104581ca..cfcca497bf 100644 --- a/R/add.R +++ b/R/add.R @@ -308,6 +308,60 @@ add_histogram <- function(p, x = NULL, y = NULL, ...) { ) } +#' 2D Histogram +#' +#' @inheritParams add_trace +#' @rdname add_trace +#' @export +#' @examples +#' +#' plot_ly(x = ~LETTERS, y = ~LETTERS) %>% add_histogram2d() +#' z <- as.matrix(table(LETTERS, LETTERS)) +#' plot_ly(x = ~LETTERS, y = ~LETTERS, z = ~z) %>% add_histogram2d() +#' +add_histogram2d <- function(p, x = NULL, y = NULL, z = NULL, ...) { + x <- x %||% p$x$attrs[[1]][["x"]] + y <- y %||% p$x$attrs[[1]][["y"]] + z <- z %||% p$x$attrs[[1]][["z"]] + if (is.null(z)) { + if (is.null(x) || is.null(y)) { + stop("Must supply both `x` and `y` attributes if `z` is NULL", call. = FALSE) + } + } + # TODO: provide type checking in plotly_build for this trace type + add_trace_classed( + p, class = "plotly_histogram2d", x = x, y = y, z = z, + type = "histogram2d", ... + ) +} + +#' 2D Histogram Contour +#' +#' @inheritParams add_trace +#' @rdname add_trace +#' @export +#' @examples +#' +#' plot_ly(MASS::geyser, x = ~waiting, y = ~duration) %>% +#' add_histogram2dcontour() +#' +#' +add_histogram2dcontour <- function(p, x = NULL, y = NULL, z = NULL, ...) { + x <- x %||% p$x$attrs[[1]][["x"]] + y <- y %||% p$x$attrs[[1]][["y"]] + z <- z %||% p$x$attrs[[1]][["z"]] + if (is.null(z)) { + if (is.null(x) || is.null(y)) { + stop("Must supply both `x` and `y` attributes if `z` is NULL", call. = FALSE) + } + } + # TODO: provide type checking in plotly_build for this trace type + add_trace_classed( + p, class = "plotly_histogram2dcontour", x = x, y = y, z = z, + type = "histogram2dcontour", ... + ) +} + #' Heatmaps #' @@ -328,6 +382,45 @@ add_heatmap <- function(p, z = NULL, ...) { ) } +#' Contours +#' +#' @inheritParams add_trace +#' @rdname add_trace +#' @export +#' @examples +#' +#' plot_ly(z = ~volcano) %>% add_contour() +#' +add_contour <- function(p, z = NULL, ...) { + if (is.null(z <- z %||% p$x$attrs[[1]][["z"]])) { + stop("Must supply `z` attribute", call. = FALSE) + } + add_trace_classed( + p, class = "plotly_contour", z = z, + type = "contour", ... + ) +} + +#' Boxplots +#' +#' @inheritParams add_trace +#' @rdname add_trace +#' @export +#' @examples +#' +#' plot_ly(mtcars, x = ~factor(vs), y = ~mpg) %>% add_boxplot() +#' +add_boxplot <- function(p, x = NULL, y = NULL, ...) { + x <- x %||% p$x$attrs[[1]][["x"]] + y <- y %||% p$x$attrs[[1]][["y"]] + if (is.null(x) && is.null(y)) { + stop("Must supply either `x` or `y` attribute", call. = FALSE) + } + add_trace_classed( + p, class = "plotly_boxplot", x = x, y = y, type = "box", ... + ) +} + #' Surface #' #' @inheritParams add_trace @@ -347,6 +440,44 @@ add_surface <- function(p, z = NULL, ...) { } +#' Geo +#' +#' @inheritParams add_trace +#' @rdname add_trace +#' @export +#' @examples +#' +#' plot_ly() %>% add_scattergeo() +#' +add_scattergeo <- function(p, ...) { + add_trace_classed( + p, class = "plotly_scattergeo", type = "scattergeo", ... + ) +} + +#' Choropleths +#' +#' @inheritParams add_trace +#' @rdname add_trace +#' @export +#' @examples +#' +#' density <- state.x77[, "Population"] / state.x77[, "Area"] +#' plot_ly(z = ~density) %>% +#' add_choropleth(locations = state.abb, locationmode = 'USA-states') %>% +#' layout(geo = list(scope = "usa")) +#' +add_choropleth <- function(p, z = NULL, ...) { + if (is.null(z <- z %||% p$x$attrs[[1]][["z"]])) { + stop("Must supply `z` attribute", call. = FALSE) + } + add_trace_classed( + p, class = "plotly_choropleth", type = "choropleth", ... + ) +} + + + # attach a class to a trace which informs data processing in plotly_build add_trace_classed <- function(p, class = "plotly_polygon", ...) { diff --git a/R/plotly_build.R b/R/plotly_build.R index a6abb8d886..10bc37013c 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -75,7 +75,7 @@ plotly_build.plotly <- function(p) { x <- verify_type(x) # do some attribute type checking for special trace types - if (inherits(x, c("plotly_heatmap", "plotly_surface"))) { + if (inherits(x, c("plotly_heatmap", "plotly_surface", "plotly_contour"))) { if (!is.matrix(x$z)) { stop("`z` must be a matrix", call. = FALSE) } diff --git a/man/add_trace.Rd b/man/add_trace.Rd index 2feccf7a4e..f8186bf64f 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -3,13 +3,19 @@ \name{add_trace} \alias{add_area} \alias{add_bars} +\alias{add_boxplot} +\alias{add_choropleth} +\alias{add_contour} \alias{add_heatmap} \alias{add_histogram} +\alias{add_histogram2d} +\alias{add_histogram2dcontour} \alias{add_lines} \alias{add_markers} \alias{add_paths} \alias{add_polygons} \alias{add_ribbons} +\alias{add_scattergeo} \alias{add_segments} \alias{add_surface} \alias{add_text} @@ -38,9 +44,21 @@ add_bars(p, x = NULL, y = NULL, ...) add_histogram(p, x = NULL, y = NULL, ...) +add_histogram2d(p, x = NULL, y = NULL, z = NULL, ...) + +add_histogram2dcontour(p, x = NULL, y = NULL, z = NULL, ...) + add_heatmap(p, z = NULL, ...) +add_contour(p, z = NULL, ...) + +add_boxplot(p, x = NULL, y = NULL, ...) + add_surface(p, z = NULL, ...) + +add_scattergeo(p, ...) + +add_choropleth(p, z = NULL, ...) } \arguments{ \item{p}{a plotly or ggplot object.} @@ -86,9 +104,21 @@ Bar chart Histogram +2D Histogram + +2D Histogram Contour + Heatmaps +Contours + +Boxplots + Surface + +Geo + +Choropleths } \examples{ @@ -136,11 +166,36 @@ mtcars \%>\% plot_ly(x = ~rnorm(100)) \%>\% add_histogram() +plot_ly(x = ~LETTERS, y = ~LETTERS) \%>\% add_histogram2d() +z <- as.matrix(table(LETTERS, LETTERS)) +plot_ly(x = ~LETTERS, y = ~LETTERS, z = ~z) \%>\% add_histogram2d() + + +plot_ly(MASS::geyser, x = ~waiting, y = ~duration) \%>\% +add_histogram2dcontour() + + + plot_ly(z = ~volcano) \%>\% add_heatmap() +plot_ly(z = ~volcano) \%>\% add_contour() + + +plot_ly(mtcars, x = ~factor(vs), y = ~mpg) \%>\% add_boxplot() + + plot_ly(z = ~volcano) \%>\% add_surface() + +plot_ly() \%>\% add_scattergeo() + + +density <- state.x77[, "Population"] / state.x77[, "Area"] +plot_ly(z = ~density) \%>\% + add_choropleth(locations = state.abb, locationmode = 'USA-states') \%>\% + layout(geo = list(scope = "usa")) + } \author{ Carson Sievert From e9676693e7f4babe327e8daa4f3f95b18399e0ea Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 24 Jun 2016 08:02:16 -0700 Subject: [PATCH 65/73] symbol/linetype fixes --- R/add.R | 71 +++++--------------------------- R/layers2traces.R | 4 +- R/plotly_build.R | 15 ++++--- R/shiny.R | 2 +- inst/examples/plotlyEvents/app.R | 31 +++----------- man/add_trace.Rd | 54 ------------------------ 6 files changed, 29 insertions(+), 148 deletions(-) diff --git a/R/add.R b/R/add.R index cfcca497bf..aebb709903 100644 --- a/R/add.R +++ b/R/add.R @@ -82,8 +82,6 @@ add_trace <- function(p, ..., p } -#' Add points to a plotly vis -#' #' @inheritParams add_trace #' @rdname add_trace #' @export @@ -97,8 +95,7 @@ add_markers <- function(p, x = NULL, y = NULL, ...) { add_trace(p, x = x, y = y, type = "scatter", mode = "markers", ...) } -#' Add text to a plotly vis -#' + #' @inheritParams add_trace #' @rdname add_trace #' @export @@ -115,8 +112,7 @@ add_text <- function(p, x = NULL, y = NULL, text = NULL, ...) { add_trace(p, x = x, y = y, text = text, type = "scatter", mode = "text", ...) } -#' Add paths to a plotly vis -#' + #' @inheritParams add_trace #' @rdname add_trace #' @export @@ -132,20 +128,14 @@ add_paths <- function(p, x = NULL, y = NULL, ...) { ) } -#' Add lines to a plotly vis -#' -#' Equivalent to \code{add_paths}, but with the x-values sorted. -#' #' @inheritParams add_trace #' @rdname add_trace #' @export #' @examples -#' #' txhousing %>% #' group_by(city) %>% #' plot_ly(x = ~date, y = ~median) %>% #' add_lines(line = list(color = toRGB("black", 0.2))) -#' add_lines <- function(p, x = NULL, y = NULL, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) @@ -182,8 +172,7 @@ add_segments <- function(p, x = NULL, y = NULL, xend = NULL, yend = NULL, ...) { } -#' -#' + #' @inheritParams add_trace #' @rdname add_trace #' @export @@ -235,18 +224,13 @@ add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, ...) { ) } -#' Area plots -#' -#' Equivalent to \link{add_ribbon} with \code{ymin} set to 0. -#' + #' @inheritParams add_trace #' @rdname add_trace #' @export #' @examples -#' #' huron <- data.frame(year = 1875:1972, level = as.vector(LakeHuron)) #' plot_ly(huron, x = ~year, ymax = ~level) %>% add_area() -#' add_area <- function(p, x = NULL, ymax = NULL, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) @@ -262,19 +246,16 @@ add_area <- function(p, x = NULL, ymax = NULL, ...) { } -#' Bar chart -#' + #' @inheritParams add_trace #' @rdname add_trace #' @export #' @examples -#' #' library(dplyr) #' mtcars %>% #' count(vs) %>% #' plot_ly(x = ~vs, y = ~n) %>% #' add_bars() -#' add_bars <- function(p, x = NULL, y = NULL, ...) { x <- x %||% p$x$attrs[[1]][["x"]] y <- y %||% p$x$attrs[[1]][["y"]] @@ -287,15 +268,13 @@ add_bars <- function(p, x = NULL, y = NULL, ...) { ) } -#' Histogram -#' + #' @inheritParams add_trace #' @rdname add_trace #' @export #' @examples #' #' plot_ly(x = ~rnorm(100)) %>% add_histogram() -#' add_histogram <- function(p, x = NULL, y = NULL, ...) { x <- x %||% p$x$attrs[[1]][["x"]] y <- y %||% p$x$attrs[[1]][["y"]] @@ -308,17 +287,14 @@ add_histogram <- function(p, x = NULL, y = NULL, ...) { ) } -#' 2D Histogram -#' + #' @inheritParams add_trace #' @rdname add_trace #' @export #' @examples -#' #' plot_ly(x = ~LETTERS, y = ~LETTERS) %>% add_histogram2d() #' z <- as.matrix(table(LETTERS, LETTERS)) #' plot_ly(x = ~LETTERS, y = ~LETTERS, z = ~z) %>% add_histogram2d() -#' add_histogram2d <- function(p, x = NULL, y = NULL, z = NULL, ...) { x <- x %||% p$x$attrs[[1]][["x"]] y <- y %||% p$x$attrs[[1]][["y"]] @@ -335,17 +311,12 @@ add_histogram2d <- function(p, x = NULL, y = NULL, z = NULL, ...) { ) } -#' 2D Histogram Contour -#' #' @inheritParams add_trace #' @rdname add_trace #' @export #' @examples -#' #' plot_ly(MASS::geyser, x = ~waiting, y = ~duration) %>% #' add_histogram2dcontour() -#' -#' add_histogram2dcontour <- function(p, x = NULL, y = NULL, z = NULL, ...) { x <- x %||% p$x$attrs[[1]][["x"]] y <- y %||% p$x$attrs[[1]][["y"]] @@ -363,15 +334,12 @@ add_histogram2dcontour <- function(p, x = NULL, y = NULL, z = NULL, ...) { } -#' Heatmaps -#' + #' @inheritParams add_trace #' @rdname add_trace #' @export #' @examples -#' #' plot_ly(z = ~volcano) %>% add_heatmap() -#' add_heatmap <- function(p, z = NULL, ...) { if (is.null(z <- z %||% p$x$attrs[[1]][["z"]])) { stop("Must supply `z` attribute", call. = FALSE) @@ -382,15 +350,11 @@ add_heatmap <- function(p, z = NULL, ...) { ) } -#' Contours -#' #' @inheritParams add_trace #' @rdname add_trace #' @export #' @examples -#' #' plot_ly(z = ~volcano) %>% add_contour() -#' add_contour <- function(p, z = NULL, ...) { if (is.null(z <- z %||% p$x$attrs[[1]][["z"]])) { stop("Must supply `z` attribute", call. = FALSE) @@ -401,15 +365,12 @@ add_contour <- function(p, z = NULL, ...) { ) } -#' Boxplots -#' + #' @inheritParams add_trace #' @rdname add_trace #' @export #' @examples -#' #' plot_ly(mtcars, x = ~factor(vs), y = ~mpg) %>% add_boxplot() -#' add_boxplot <- function(p, x = NULL, y = NULL, ...) { x <- x %||% p$x$attrs[[1]][["x"]] y <- y %||% p$x$attrs[[1]][["y"]] @@ -421,15 +382,12 @@ add_boxplot <- function(p, x = NULL, y = NULL, ...) { ) } -#' Surface -#' + #' @inheritParams add_trace #' @rdname add_trace #' @export #' @examples -#' #' plot_ly(z = ~volcano) %>% add_surface() -#' add_surface <- function(p, z = NULL, ...) { if (is.null(z <- z %||% p$x$attrs[[1]][["z"]])) { stop("Must supply `z` attribute", call. = FALSE) @@ -440,33 +398,26 @@ add_surface <- function(p, z = NULL, ...) { } -#' Geo -#' #' @inheritParams add_trace #' @rdname add_trace #' @export #' @examples -#' #' plot_ly() %>% add_scattergeo() -#' add_scattergeo <- function(p, ...) { add_trace_classed( p, class = "plotly_scattergeo", type = "scattergeo", ... ) } -#' Choropleths -#' + #' @inheritParams add_trace #' @rdname add_trace #' @export #' @examples -#' #' density <- state.x77[, "Population"] / state.x77[, "Area"] #' plot_ly(z = ~density) %>% #' add_choropleth(locations = state.abb, locationmode = 'USA-states') %>% #' layout(geo = list(scope = "usa")) -#' add_choropleth <- function(p, z = NULL, ...) { if (is.null(z <- z %||% p$x$attrs[[1]][["z"]])) { stop("Must supply `z` attribute", call. = FALSE) diff --git a/R/layers2traces.R b/R/layers2traces.R index 2eaa5f3497..65b0f00237 100644 --- a/R/layers2traces.R +++ b/R/layers2traces.R @@ -644,12 +644,12 @@ ribbon_dat <- function(dat) { # top-half of ribbon tmp <- dat[o, ] others <- tmp[not_used] - dat1 <- cbind(x = tmp$x, y = tmp$ymax, others) + dat1 <- cbind(x = tmp$x, y = tmp$ymin, others) dat1[n+1, ] <- cbind(x = tmp$x[n], y = tmp$ymin[n], others[n, ]) # bottom-half of ribbon tmp2 <- dat[o2, ] others2 <- tmp2[not_used] - dat2 <- cbind(x = tmp2$x, y = tmp2$ymin, others2) + dat2 <- cbind(x = tmp2$x, y = tmp2$ymax, others2) rbind(dat1, dat2) } diff --git a/R/plotly_build.R b/R/plotly_build.R index 10bc37013c..58d32aa19d 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -89,7 +89,9 @@ plotly_build.plotly <- function(p) { # gather the "built" or "evaluated" data nobs <- NROW(dat) - isVar <- vapply(x, function(attr) length(attr) == nobs, logical(1)) + attrLengths <- lengths(x) + if (nobs == 0) nobs <- max(attrLengths) + isVar <- attrLengths == nobs builtData <- data.frame(x[isVar & !names(x) %in% c("colors", "symbols", "linetypes")]) # find any groupings, so we can arrange the data now, @@ -134,7 +136,6 @@ plotly_build.plotly <- function(p) { } # if appropriate, set the mode now since we need to reference it later - attrLengths <- lengths(x) if (grepl("scatter", x$type) && is.null(x$mode)) { x$mode <- if (any(attrLengths > 20)) "lines" else "markers+lines" } @@ -463,7 +464,8 @@ map_symbol <- function(traces) { } palette <- setNames(symbols[seq_len(N)], unique(symbol)) for (i in which(nSymbols > 0)) { - traces[[i]]$marker$symbol <- as.character(palette[symbolList[[i]]]) + symbols <- as.character(palette[symbolList[[i]]]) + traces[[i]]$marker <- modify_list(list(symbol = symbols), traces[[i]]$marker) # ensure the mode is set so that the symbol is relevant if (!grepl("markers", traces[[i]]$mode %||% "")) { message("Adding markers to mode; otherwise symbol would have no effect.") @@ -497,7 +499,7 @@ map_linetype <- function(traces) { linetypes <- unique(unlist(lapply(traces, "[[", "linetypes"))) %||% validLinetypes illegalLinetypes <- setdiff(linetypes, validLinetypes) if (length(illegalLinetypes)) { - stop("The following are not valid symbol codes:\n'", + stop("The following are not valid linetype codes:\n'", paste(illegalLinetypes, collapse = "', '"), "Valid linetypes include:\n'", paste(validLinetypes, collapse = "', '"), @@ -505,11 +507,12 @@ map_linetype <- function(traces) { } palette <- setNames(linetypes[seq_len(N)], unique(linetype)) for (i in which(nLinetypes > 0)) { - traces[[i]][["line"]][["dash"]] <- as.character(palette[linetypeList[[i]]]) + dashes <- as.character(palette[linetypeList[[i]]]) + traces[[i]][["line"]] <- modify_list(list(dash = dashes), traces[[i]][["line"]]) # ensure the mode is set so that the linetype is relevant if (!grepl("lines", traces[[i]]$mode %||% "")) { message("Adding lines to mode; otherwise linetype would have no effect.") - traces[[i]]$mode <- paste0(traces[[i]]$mode, "+lines") + traces[[i]][["mode"]] <- paste0(traces[[i]][["mode"]], "+lines") } } traces diff --git a/R/shiny.R b/R/shiny.R index ca02268f42..5abb794296 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -26,7 +26,7 @@ plotlyOutput <- function(outputId, width = "100%", height = "400px") { renderPlotly <- function(expr, env = parent.frame(), quoted = FALSE) { if (!quoted) { expr <- substitute(expr) } # force quoted # https://github.com/ramnathv/htmlwidgets/issues/166#issuecomment-153000306 - expr <- call("plotly_build", expr) + #expr <- call("plotly_build", expr) shinyRenderWidget(expr, plotlyOutput, env, quoted = TRUE) } diff --git a/inst/examples/plotlyEvents/app.R b/inst/examples/plotlyEvents/app.R index 3d64c349ff..2eba3cf16d 100644 --- a/inst/examples/plotlyEvents/app.R +++ b/inst/examples/plotlyEvents/app.R @@ -1,33 +1,19 @@ library(shiny) -library(plotly) ui <- fluidPage( - radioButtons("plotType", "Plot Type:", choices = c("ggplotly", "plotly")), plotlyOutput("plot"), - verbatimTextOutput("hover"), verbatimTextOutput("click"), - verbatimTextOutput("brush"), - verbatimTextOutput("zoom") + verbatimTextOutput("brush") ) server <- function(input, output, session) { output$plot <- renderPlotly({ # use the key aesthetic/argument to help uniquely identify selected observations - key <- row.names(mtcars) - if (identical(input$plotType, "ggplotly")) { - p <- ggplot(mtcars, aes(x = mpg, y = wt, colour = factor(vs), key = key)) + - geom_point() - ggplotly(p) %>% layout(dragmode = "select") - } else { - plot_ly(mtcars, x = ~mpg, y = ~wt, key = ~key, mode = "markers") %>% - layout(dragmode = "select") - } - }) - - output$hover <- renderPrint({ - d <- event_data("plotly_hover") - if (is.null(d)) "Hover events appear here (unhover to clear)" else d + mtcars %>% + plot_ly(x = ~mpg, y = ~wt, key = row.names(mtcars)) %>% + add_markers() %>% + layout(dragmode = "select") }) output$click <- renderPrint({ @@ -40,11 +26,6 @@ server <- function(input, output, session) { if (is.null(d)) "Click and drag events (i.e., select/lasso) appear here (double-click to clear)" else d }) - output$zoom <- renderPrint({ - d <- event_data("plotly_relayout") - if (is.null(d)) "Relayout (i.e., zoom) events appear here" else d - }) - } -shinyApp(ui, server, options = list(display.mode = "showcase")) +shinyApp(ui, server) diff --git a/man/add_trace.Rd b/man/add_trace.Rd index f8186bf64f..d02ebee473 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -89,36 +89,6 @@ provided, arguments are evaluated using the data frame in \code{\link{plot_ly}() } \description{ Add trace(s) to a plotly visualization - -Add points to a plotly vis - -Add text to a plotly vis - -Add paths to a plotly vis - -Equivalent to \code{add_paths}, but with the x-values sorted. - -Equivalent to \link{add_ribbon} with \code{ymin} set to 0. - -Bar chart - -Histogram - -2D Histogram - -2D Histogram Contour - -Heatmaps - -Contours - -Boxplots - -Surface - -Geo - -Choropleths } \examples{ @@ -134,13 +104,11 @@ plot_ly(economics, x = ~date, y = ~uempmed) \%>\% add_markers(color = ~pop) \%>\% layout(showlegend = FALSE) - txhousing \%>\% group_by(city) \%>\% plot_ly(x = ~date, y = ~median) \%>\% add_lines(line = list(color = toRGB("black", 0.2))) - ggplot2::map_data("world", "canada") \%>\% group_by(group) \%>\% plot_ly(x = ~long, y = ~lat) \%>\% @@ -151,51 +119,29 @@ ggplot2::map_data("world", "canada") \%>\% plot_ly(economics, x = ~date) \%>\% add_ribbons(ymin = ~pce - 1e3, ymax = ~pce + 1e3) - huron <- data.frame(year = 1875:1972, level = as.vector(LakeHuron)) plot_ly(huron, x = ~year, ymax = ~level) \%>\% add_area() - - library(dplyr) mtcars \%>\% count(vs) \%>\% plot_ly(x = ~vs, y = ~n) \%>\% add_bars() - plot_ly(x = ~rnorm(100)) \%>\% add_histogram() - - plot_ly(x = ~LETTERS, y = ~LETTERS) \%>\% add_histogram2d() z <- as.matrix(table(LETTERS, LETTERS)) plot_ly(x = ~LETTERS, y = ~LETTERS, z = ~z) \%>\% add_histogram2d() - - plot_ly(MASS::geyser, x = ~waiting, y = ~duration) \%>\% add_histogram2dcontour() - - - plot_ly(z = ~volcano) \%>\% add_heatmap() - - plot_ly(z = ~volcano) \%>\% add_contour() - - plot_ly(mtcars, x = ~factor(vs), y = ~mpg) \%>\% add_boxplot() - - plot_ly(z = ~volcano) \%>\% add_surface() - - plot_ly() \%>\% add_scattergeo() - - density <- state.x77[, "Population"] / state.x77[, "Area"] plot_ly(z = ~density) \%>\% add_choropleth(locations = state.abb, locationmode = 'USA-states') \%>\% layout(geo = list(scope = "usa")) - } \author{ Carson Sievert From ced729f9c65bb43ef5602d8350553abe69ca2362 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Fri, 24 Jun 2016 09:41:26 -0700 Subject: [PATCH 66/73] fix return value of lmgadget --- inst/examples/lmGadget/app.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/inst/examples/lmGadget/app.R b/inst/examples/lmGadget/app.R index 18683e9782..f0ea2be846 100644 --- a/inst/examples/lmGadget/app.R +++ b/inst/examples/lmGadget/app.R @@ -34,6 +34,7 @@ lmGadget <- function(dat, x, y, key = row.names(dat)) { init <- function() { selected <- rep(FALSE, nrow(dat)) function(x) { + if (missing(x)) return(selected) selected <<- xor(selected, x) selected } @@ -64,7 +65,12 @@ lmGadget <- function(dat, x, y, key = row.names(dat)) { # Return the most recent fitted model, when we press "done" observeEvent(input$done, { - stopApp(refit()) + selected <- selection() + modelDat <- dat[!selected, ] + formula <- as.formula( + sprintf("%s ~ poly(%s, degree = %s)", as.character(y)[2], as.character(x)[2], input$degree) + ) + stopApp(lm(formula, modelDat)) }) } From b16f8b75926d7b65b9ec0cb21cf7d10b35c886bb Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Sun, 26 Jun 2016 13:15:41 -0700 Subject: [PATCH 67/73] better plotly_data() examples; use @rawNamespace to avoid unwanted S3method() in NAMESPACE --- NAMESPACE | 31 ++++++- NEWS | 4 +- R/group2NA.R | 74 ++++++++++++++++ R/imports.R | 203 +++++++++++++++++++++++++++++++++++++++++- R/plotly_data.R | 214 +++++++++++++++------------------------------ man/arrange.Rd | 9 ++ man/arrange_.Rd | 9 ++ man/distinct.Rd | 9 ++ man/distinct_.Rd | 9 ++ man/do.Rd | 9 ++ man/do_.Rd | 9 ++ man/group_by.Rd | 15 +--- man/group_by_.Rd | 9 ++ man/groups.Rd | 9 ++ man/mutate.Rd | 9 ++ man/mutate_.Rd | 9 ++ man/plotly_data.Rd | 105 +++++++++++----------- man/rename.Rd | 9 ++ man/rename_.Rd | 9 ++ man/select.Rd | 9 ++ man/select_.Rd | 9 ++ man/slice.Rd | 9 ++ man/slice_.Rd | 9 ++ man/summarise.Rd | 9 ++ man/summarise_.Rd | 9 ++ man/transmute.Rd | 9 ++ man/transmute_.Rd | 9 ++ man/ungroup.Rd | 9 ++ 28 files changed, 621 insertions(+), 214 deletions(-) create mode 100644 R/group2NA.R create mode 100644 man/arrange.Rd create mode 100644 man/arrange_.Rd create mode 100644 man/distinct.Rd create mode 100644 man/distinct_.Rd create mode 100644 man/do.Rd create mode 100644 man/do_.Rd create mode 100644 man/group_by_.Rd create mode 100644 man/groups.Rd create mode 100644 man/mutate.Rd create mode 100644 man/mutate_.Rd create mode 100644 man/rename.Rd create mode 100644 man/rename_.Rd create mode 100644 man/select.Rd create mode 100644 man/select_.Rd create mode 100644 man/slice.Rd create mode 100644 man/slice_.Rd create mode 100644 man/summarise.Rd create mode 100644 man/summarise_.Rd create mode 100644 man/transmute.Rd create mode 100644 man/transmute_.Rd create mode 100644 man/ungroup.Rd diff --git a/NAMESPACE b/NAMESPACE index 77d12284fe..6f3eb1ea1e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -65,10 +65,16 @@ export(add_segments) export(add_surface) export(add_text) export(add_trace) +export(arrange) +export(arrange_) export(arrange_.plotly) export(as.widget) export(config) +export(distinct) +export(distinct_) export(distinct_.plotly) +export(do) +export(do_) export(embed_notebook) export(event_data) export(export) @@ -78,11 +84,15 @@ export(get_figure) export(gg2list) export(ggplotly) export(group_by) +export(group_by_) export(group_by_.plotly) +export(groups) export(groups.plotly) export(hide_colorbar) export(knit_print.plotly_figure) export(layout) +export(mutate) +export(mutate_) export(mutate_.plotly) export(offline) export(plot_ly) @@ -91,36 +101,55 @@ export(plotlyOutput) export(plotly_IMAGE) export(plotly_POST) export(plotly_build) -export(plotly_data) export(plotly_empty) export(plotly_json) +export(rename) +export(rename_) export(rename_.plotly) export(renderPlotly) export(schema) +export(select) +export(select_) export(select_.plotly) export(signup) +export(slice) +export(slice_) export(slice_.plotly) export(style) export(subplot) +export(summarise) +export(summarise_) export(summarise_.plotly) export(toRGB) export(toWebGL) export(to_basic) +export(transmute) +export(transmute_) export(transmute_.plotly) +export(ungroup) export(ungroup.plotly) import(ggplot2) importFrom(base64enc,base64encode) +importFrom(dplyr,arrange) importFrom(dplyr,arrange_) +importFrom(dplyr,distinct) importFrom(dplyr,distinct_) importFrom(dplyr,do) +importFrom(dplyr,do_) importFrom(dplyr,group_by) importFrom(dplyr,group_by_) importFrom(dplyr,groups) +importFrom(dplyr,mutate) importFrom(dplyr,mutate_) +importFrom(dplyr,rename) importFrom(dplyr,rename_) +importFrom(dplyr,select) importFrom(dplyr,select_) +importFrom(dplyr,slice) importFrom(dplyr,slice_) +importFrom(dplyr,summarise) importFrom(dplyr,summarise_) +importFrom(dplyr,transmute) importFrom(dplyr,transmute_) importFrom(dplyr,ungroup) importFrom(grDevices,col2rgb) diff --git a/NEWS b/NEWS index a16982a8f2..95ece5e79d 100644 --- a/NEWS +++ b/NEWS @@ -3,8 +3,8 @@ BREAKING CHANGES & IMPROVEMENTS: * Formulas (instead of plain expressions) are now required when using variable mappings. For example, `plot_ly(mtcars, x = wt, y = mpg, color = vs)` should now be `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~vs)`. This is a major breaking change, but it is necessary to ensure that evaluation is correct in all contexts (as a result, `evaluate` argument is now deprecated as it is no longer needed). It also has the benefit of being easier to program with (i.e., writing your own custom functions that wrap `plot_ly()`). For more details, see the [lazyeval vignette](https://github.com/hadley/lazyeval/blob/master/vignettes/lazyeval.Rmd) -* The data structure used to represent plotly objects is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, the `as.widget()` function has been deprecated, and [serialization/memory leak problems](https://github.com/rstudio/shiny/issues/1151) are no longer an issue. This change also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `help("plotly-data")` for examples). -* The `group` variable mapping no longer create multiple traces, but instead defines "gaps" within a trace (fixes #418, #381, #577). Groupings should be declared via the new `group_by()` function (see `help("plotly-data")` for examples) instead of the `group` argument (which is now deprecated). +* The data structure used to represent plotly objects is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, the `as.widget()` function has been deprecated, and [serialization/memory leak problems](https://github.com/rstudio/shiny/issues/1151) are no longer an issue. This change also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `?plotly_data` for examples). +* The `group` variable mapping no longer create multiple traces, but instead defines "gaps" within a trace (fixes #418, #381, #577). Groupings should be declared via the new `group_by()` function (see `help(plotly_data)` for examples) instead of the `group` argument (which is now deprecated). * `plot_ly()` now _initializes_ a plotly object (i.e., won't add a scatter trace by default), meaning that something like `plot_ly(x = 1:10, y = 1:10) %>% add_trace(y = 10:1)` will create one trace, instead of two. However, `plot_ly()` will draw a trace if you manually specify a trace type, for example, `plot_ly(x = 1:10, y = 1:10, type = "scatter") %>% add_trace(y = 10:1)` will draw two scatter traces. If no trace type is provided, a sensible type is inferred from the supplied data, and automatically added (i.e., `plot_ly(x = rnorm(100))` now creates a histogram). * The `inherit` argument is deprecated. Any arguments/attributes specified in `plot_ly()` will automatically be passed along to additional traces added via `add_trace()` (or any of it's `add_*()` siblings). * Scales for variable mappings (such as `color`, `symbol`, `linetype`) are now applied at the plot-level instead of the trace level. For this reason, the range of these scales (`colors`/`symbols`/`linetypes`) should be specified in `plot_ly()`, instead of `add_trace()` or any of it's `add_*()` siblings. diff --git a/R/group2NA.R b/R/group2NA.R new file mode 100644 index 0000000000..f49efc9510 --- /dev/null +++ b/R/group2NA.R @@ -0,0 +1,74 @@ + +# Insert missing values to create trace groupings +# +# If a group of traces share the same non-positional characteristics (i.e., +# color, fill, etc), it is more efficient to draw them as a single trace +# with missing values that separate the groups (instead of multiple traces). +# This is a helper function for inserting missing values into a data set +# +# @param data a data frame. +# @param groupNames name(s) of the grouping variable(s) as a character vector +# @param nested other variables that group should be nested +# (i.e., ordered) within. +# @param ordered a variable to arrange by (within nested & groupNames). This +# is useful primarily for ordering by x +# @param retrace.first should the first row of each group be appended to the +# last row? This is useful for enclosing polygons with lines. +# @examples +# +# group2NA(mtcars, "vs", "cyl") +# +# elong <- tidyr::gather(economics, variable, value, -date) +# plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) +# + +group2NA <- function(data, groupNames = "group", nested = NULL, ordered = NULL, + retrace.first = inherits(data, "GeomPolygon")) { + if (NROW(data) == 0) return(data) + # a few workarounds since dplyr clobbers classes that we rely on in ggplotly + retrace <- force(retrace.first) + datClass <- class(data) + + # sanitize variable names + groupNames <- groupNames[groupNames %in% names(data)] + nested <- nested[nested %in% names(data)] + ordered <- ordered[ordered %in% names(data)] + # ignore any already existing groups + data <- dplyr::ungroup(data) + + # if group doesn't exist, just arrange before returning + if (!length(groupNames)) { + if (length(ordered)) { + data <- dplyr::arrange_(data, c(nested, ordered)) + } + return(data) + } + allVars <- c(nested, groupNames, ordered) + for (i in allVars) { + data <- dplyr::group_by_(data, i, add = TRUE) + } + # first, arrange everything + data <- dplyr::do(data, dplyr::arrange_(., allVars)) + data <- dplyr::ungroup(data) + for (i in c(nested, groupNames)) { + data <- dplyr::group_by_(data, i, add = TRUE) + } + d <- if (retrace.first) { + dplyr::do(data, rbind(., .[1,], NA)) + } else { + dplyr::do(data, rbind(., NA)) + } + # TODO: how to drop the NAs separating the nested values? Does it even matter? + # d <- dplyr::ungroup(d) + # for (i in nested) { + # d <- dplyr::group_by_(dplyr::ungroup(d), i, add = TRUE) + # } + # d <- dplyr::do(d, .[seq_len(NROW(.)),]) + n <- NROW(d) + if (all(is.na(d[n, ]))) d <- d[-n, ] + structure(d, class = datClass) +} + + +# to appease R CMD check (currently we reference '.' in group2NA) +utils::globalVariables(".") diff --git a/R/imports.R b/R/imports.R index 88d1bea9e5..8086febfcb 100644 --- a/R/imports.R +++ b/R/imports.R @@ -4,10 +4,211 @@ #' @importFrom utils getFromNamespace modifyList data packageVersion browseURL #' @importFrom stats setNames complete.cases quantile #' @importFrom tidyr gather gather_ unnest -#' @importFrom dplyr mutate_ summarise_ select_ arrange_ group_by_ distinct_ slice_ rename_ transmute_ do groups ungroup #' @importFrom viridisLite viridis #' @importFrom jsonlite toJSON fromJSON #' @importFrom httr GET POST PATCH content config add_headers stop_for_status #' @importFrom htmlwidgets createWidget sizingPolicy saveWidget #' @importFrom lazyeval f_eval is_formula all_dots is_lang NULL + +# ------------------------------------------------------------------ +# Import dplyr generics and re-export them +# ------------------------------------------------------------------ + +#' Add new variables. +#' +#' See \link[dplyr]{mutate}. +#' +#' @importFrom dplyr mutate +#' @name mutate +#' @export +NULL + +#' Add new variables. +#' +#' See \link[dplyr]{mutate_}. +#' +#' @importFrom dplyr mutate_ +#' @name mutate_ +#' @export +NULL + +#' Add new variables. +#' +#' See \link[dplyr]{transmute}. +#' +#' @importFrom dplyr transmute +#' @name transmute +#' @export +NULL + +#' Add new variables. +#' +#' See \link[dplyr]{transmute_}. +#' +#' @importFrom dplyr transmute_ +#' @name transmute_ +#' @export +NULL + +#' Select/rename variables by name. +#' +#' See \link[dplyr]{select}. +#' +#' @importFrom dplyr select +#' @name select +#' @export +NULL + +#' Select/rename variables by name. +#' +#' See \link[dplyr]{select_}. +#' +#' @importFrom dplyr select_ +#' @name select_ +#' @export +NULL + +#' Select/rename variables by name. +#' +#' See \link[dplyr]{rename}. +#' +#' @importFrom dplyr rename +#' @name rename +#' @export +NULL + +#' Select/rename variables by name. +#' +#' See \link[dplyr]{rename_}. +#' +#' @importFrom dplyr rename_ +#' @name rename_ +#' @export +NULL + +#' Group a tbl by one or more variables. +#' +#' See \link[dplyr]{group_by}. +#' +#' @importFrom dplyr group_by +#' @name group_by +#' @export +NULL + +#' Group a tbl by one or more variables. +#' +#' See \link[dplyr]{group_by}. +#' +#' @importFrom dplyr group_by_ +#' @name group_by_ +#' @export +NULL + +#' Get/set the grouping variables for tbl. +#' +#' See \link[dplyr]{groups}. +#' +#' @importFrom dplyr groups +#' @name groups +#' @export +NULL + +#' Get/set the grouping variables for tbl. +#' +#' See \link[dplyr]{ungroup}. +#' +#' @importFrom dplyr ungroup +#' @name ungroup +#' @export +NULL + +#' Summarise multiple values to a single value. +#' +#' See \link[dplyr]{summarise}. +#' +#' @importFrom dplyr summarise +#' @name summarise +#' @export +NULL + +#' Summarise multiple values to a single value. +#' +#' See \link[dplyr]{summarise_}. +#' +#' @importFrom dplyr summarise_ +#' @name summarise_ +#' @export +NULL + +#' Do arbitrary operations on a tbl. +#' +#' See \link[dplyr]{do}. +#' +#' @importFrom dplyr do +#' @name do +#' @export +NULL + +#' Do arbitrary operations on a tbl. +#' +#' See \link[dplyr]{do_}. +#' +#' @importFrom dplyr do_ +#' @name do_ +#' @export +NULL + +#' Arrange rows by variables. +#' +#' See \link[dplyr]{arrange}. +#' +#' @importFrom dplyr arrange +#' @name arrange +#' @export +NULL + +#' Arrange rows by variables. +#' +#' See \link[dplyr]{arrange_}. +#' +#' @importFrom dplyr arrange_ +#' @name arrange_ +#' @export +NULL + +#' Select distinct/unique rows. +#' +#' See \link[dplyr]{distinct}. +#' +#' @importFrom dplyr distinct +#' @name distinct +#' @export +NULL + +#' Select distinct/unique rows. +#' +#' See \link[dplyr]{distinct_}. +#' +#' @importFrom dplyr distinct_ +#' @name distinct_ +#' @export +NULL + +#' Select rows by position. +#' +#' See \link[dplyr]{slice}. +#' +#' @importFrom dplyr slice +#' @name slice +#' @export +NULL + +#' Select rows by position. +#' +#' See \link[dplyr]{slice_}. +#' +#' @importFrom dplyr slice_ +#' @name slice_ +#' @export +NULL diff --git a/R/plotly_data.R b/R/plotly_data.R index 80c348fbbe..a5abfd757e 100644 --- a/R/plotly_data.R +++ b/R/plotly_data.R @@ -1,217 +1,141 @@ -#' Divide data into groups. +#' Obtain data associated with a plotly graph #' -#' @param x a visualisation -#' @param ... variables to group by. -#' @param add By default, when \code{add = FALSE}, \code{group_by} will -#' override existing groups. To instead add to the existing groups, -#' use \code{add = TRUE} -#' @importFrom dplyr group_by -#' @name group_by -#' @export -NULL - - -#' View and manipulate data associated with a plotly graph -#' -#' \code{plotly_data()} returns the data associated with -#' a plotly visualization. This data can be manipulated via -#' the dplyr and tidyr verbs listed below: +#' \code{plotly_data()} returns data associated with +#' a plotly visualization (if there are multiple data frames, by default, +#' it returns the most recent one). #' -#' -#' @name plotly_data -#' @keywords internal +#' @param p a plotly visualization +#' @param id a character string or number referencing an "attribute layer". +#' @return returns a data frame #' @examples #' -#' # loading dplyr is super important! -#' library(dplyr) +#' # use group_by() to define groups of visual markings +#' p <- txhousing %>% +#' group_by(city) %>% +#' plot_ly(x = ~date, y = ~sales) +#' p #' -#' mtcars %>% -#' plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") %>% -#' filter(cyl == 4) %>% -#' add_markers(x = ~wt, y = ~mpg, name = "filtered points", -#' marker = list(color = "red")) -#' -#' library(tidyr) -#' economics %>% -#' gather(variable, value, -date) %>% -#' group_by(variable) %>% -#' plot_ly(x = ~date, y = ~value) +#' # plotly objects preserve data groupings +#' groups(p) +#' plotly_data(p) +#' +#' # dplyr verbs operate on plotly objects as if they were data frames +#' p <- economics %>% +#' plot_ly(x = ~date, y = ~unemploy / pop) %>% +#' add_lines() %>% +#' mutate(rate = unemploy / pop) %>% +#' filter(rate == max(rate)) +#' plotly_data(p) +#' add_markers(p) +#' layout(p, annotations = list(x = ~date, y = ~rate, text = "peak")) +#' +#' # use group_by() + do() + subplot() for trellis displays +#' d <- group_by(mpg, drv) +#' plots <- do(d, p = plot_ly(., x = ~cty, name = ~drv)) +#' subplot(plots[["p"]], nrows = 3, shareX = TRUE) +#' +#' # arrange displays by their mean +#' means <- summarise(d, mn = mean(cty, na.rm = TRUE)) +#' means %>% +#' left_join(plots) %>% +#' arrange(mn) %>% +#' .[["p"]] %>% +#' subplot(nrows = NROW(.), shareX = TRUE) #' -NULL - -#' @export -#' @rdname plotly_data +#' # more dplyr verbs applied to plotly objects +#' p <- mtcars %>% +#' plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") %>% +#' add_markers() +#' p %>% slice(1) %>% plotly_data() +#' p %>% slice(1) %>% add_markers(name = "first observation") +#' p %>% filter(cyl == 4) %>% plotly_data() +#' p %>% filter(cyl == 4) %>% add_markers(name = "four cylinders") +#' +#' plotly_data <- function(p, id = p$x$cur_data) { f <- p$x$visdat[[id]] - # if data has been specified, this should be a closure that, when called + # if data has been specified, f should be a closure that, when called, # returns data if (is.function(f)) return(f()) data.frame() } -#' @export -#' @rdname plotly_data +#' @rawNamespace export(groups.plotly) groups.plotly <- function(x) { dplyr::groups(plotly_data(x)) } -#' @export -#' @rdname plotly_data +#' @rawNamespace export(ungroup.plotly) +ungroup.plotly <- function(x) { + dplyr::ungroup(plotly_data(x)) +} + +#' @rawNamespace export(group_by_.plotly) group_by_.plotly <- function(.data, ..., .dots, add = FALSE) { d <- plotly_data(.data) d <- dplyr::group_by_(d, .dots = lazyeval::all_dots(.dots, ...), add = add) - # TODO: where to use group2NA? In plotly_build() add_data(.data, d) } -#' @export -#' @rdname plotly_data -ungroup.plotly <- function(x) { - dplyr::ungroup(plotly_data(x)) -} - -#' @rdname plotly_data -#' @export +#' @rawNamespace export(summarise_.plotly) summarise_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) d <- dplyr::summarise_(d, .dots = lazyeval::all_dots(.dots, ...)) add_data(.data, d) } -#' @rdname plotly_data -#' @export +#' @rawNamespace export(mutate_.plotly) mutate_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) d <- dplyr::mutate_(d, .dots = lazyeval::all_dots(.dots, ...)) add_data(.data, d) } -#' @rdname plotly_data -#' @export +#' @rawNamespace export(arrange_.plotly) arrange_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) d <- dplyr::arrange_(d, .dots = lazyeval::all_dots(.dots, ...)) add_data(.data, d) } -#' @rdname plotly_data -#' @export +#' @rawNamespace export(select_.plotly) select_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) d <- dplyr::select_(d, .dots = lazyeval::all_dots(.dots, ...)) add_data(.data, d) } -#' @rdname plotly_data -#' @export +#' @rawNamespace export(filter_.plotly) filter_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) d <- dplyr::filter_(d, .dots = lazyeval::all_dots(.dots, ...)) add_data(.data, d) } -#' @rdname plotly_data -#' @export +#' @rawNamespace export(distinct_.plotly) distinct_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) - d <- dplyr::distinct_(d, ..., .dots) + d <- dplyr::distinct_(d, .dots = lazyeval::all_dots(.dots, ...)) add_data(.data, d) } -#' @rdname plotly_data -#' @export +#' @rawNamespace export(slice_.plotly) slice_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) - d <- dplyr::slice_(d, ..., .dots) + d <- dplyr::slice_(d, .dots = lazyeval::all_dots(.dots, ...)) add_data(.data, d) } -#' @rdname plotly_data -#' @export +#' @rawNamespace export(rename_.plotly) rename_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) - d <- dplyr::rename_(d, ..., .dots) + d <- dplyr::rename_(d, .dots = lazyeval::all_dots(.dots, ...)) add_data(.data, d) } -#' @rdname plotly_data -#' @export +#' @rawNamespace export(transmute_.plotly) transmute_.plotly <- function(.data, ..., .dots) { d <- plotly_data(.data) - d <- dplyr::transmute_(d, ..., .dots) + d <- dplyr::transmute_(d, .dots = lazyeval::all_dots(.dots, ...)) add_data(.data, d) } - -# Insert missing values to create trace groupings -# -# If a group of traces share the same non-positional characteristics (i.e., -# color, fill, etc), it is more efficient to draw them as a single trace -# with missing values that separate the groups (instead of multiple traces). -# This is a helper function for inserting missing values into a data set -# -# @param data a data frame. -# @param groupNames name(s) of the grouping variable(s) as a character vector -# @param nested other variables that group should be nested -# (i.e., ordered) within. -# @param ordered a variable to arrange by (within nested & groupNames). This -# is useful primarily for ordering by x -# @param retrace.first should the first row of each group be appended to the -# last row? This is useful for enclosing polygons with lines. -# @examples -# -# group2NA(mtcars, "vs", "cyl") -# -# elong <- tidyr::gather(economics, variable, value, -date) -# plot_ly(group2NA(elong, "variable"), x = ~date, y = ~value) -# - -group2NA <- function(data, groupNames = "group", nested = NULL, ordered = NULL, - retrace.first = inherits(data, "GeomPolygon")) { - if (NROW(data) == 0) return(data) - # a few workarounds since dplyr clobbers classes that we rely on in ggplotly - retrace <- force(retrace.first) - datClass <- class(data) - - # sanitize variable names - groupNames <- groupNames[groupNames %in% names(data)] - nested <- nested[nested %in% names(data)] - ordered <- ordered[ordered %in% names(data)] - # ignore any already existing groups - data <- dplyr::ungroup(data) - - # if group doesn't exist, just arrange before returning - if (!length(groupNames)) { - if (length(ordered)) { - data <- dplyr::arrange_(data, c(nested, ordered)) - } - return(data) - } - allVars <- c(nested, groupNames, ordered) - for (i in allVars) { - data <- dplyr::group_by_(data, i, add = TRUE) - } - # first, arrange everything - data <- dplyr::do(data, dplyr::arrange_(., allVars)) - data <- dplyr::ungroup(data) - for (i in c(nested, groupNames)) { - data <- dplyr::group_by_(data, i, add = TRUE) - } - d <- if (retrace.first) { - dplyr::do(data, rbind(., .[1,], NA)) - } else { - dplyr::do(data, rbind(., NA)) - } - # TODO: how to drop the NAs separating the nested values? Does it even matter? - # d <- dplyr::ungroup(d) - # for (i in nested) { - # d <- dplyr::group_by_(dplyr::ungroup(d), i, add = TRUE) - # } - # d <- dplyr::do(d, .[seq_len(NROW(.)),]) - n <- NROW(d) - if (all(is.na(d[n, ]))) d <- d[-n, ] - structure(d, class = datClass) -} - - -# to appease R CMD check (currently we reference '.' in group2NA) -utils::globalVariables(".") diff --git a/man/arrange.Rd b/man/arrange.Rd new file mode 100644 index 0000000000..a9b31cbeb1 --- /dev/null +++ b/man/arrange.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{arrange} +\alias{arrange} +\title{Arrange rows by variables.} +\description{ +See \link[dplyr]{arrange}. +} + diff --git a/man/arrange_.Rd b/man/arrange_.Rd new file mode 100644 index 0000000000..531364e7c4 --- /dev/null +++ b/man/arrange_.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{arrange_} +\alias{arrange_} +\title{Arrange rows by variables.} +\description{ +See \link[dplyr]{arrange_}. +} + diff --git a/man/distinct.Rd b/man/distinct.Rd new file mode 100644 index 0000000000..545e331acf --- /dev/null +++ b/man/distinct.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{distinct} +\alias{distinct} +\title{Select distinct/unique rows.} +\description{ +See \link[dplyr]{distinct}. +} + diff --git a/man/distinct_.Rd b/man/distinct_.Rd new file mode 100644 index 0000000000..9e6485b3d4 --- /dev/null +++ b/man/distinct_.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{distinct_} +\alias{distinct_} +\title{Select distinct/unique rows.} +\description{ +See \link[dplyr]{distinct_}. +} + diff --git a/man/do.Rd b/man/do.Rd new file mode 100644 index 0000000000..0da033a893 --- /dev/null +++ b/man/do.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{do} +\alias{do} +\title{Do arbitrary operations on a tbl.} +\description{ +See \link[dplyr]{do}. +} + diff --git a/man/do_.Rd b/man/do_.Rd new file mode 100644 index 0000000000..fad75fc292 --- /dev/null +++ b/man/do_.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{do_} +\alias{do_} +\title{Do arbitrary operations on a tbl.} +\description{ +See \link[dplyr]{do_}. +} + diff --git a/man/group_by.Rd b/man/group_by.Rd index c2cb5f39e0..2110f11730 100644 --- a/man/group_by.Rd +++ b/man/group_by.Rd @@ -1,18 +1,9 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotly_data.R +% Please edit documentation in R/imports.R \name{group_by} \alias{group_by} -\title{Divide data into groups.} -\arguments{ -\item{x}{a visualisation} - -\item{...}{variables to group by.} - -\item{add}{By default, when \code{add = FALSE}, \code{group_by} will -override existing groups. To instead add to the existing groups, -use \code{add = TRUE}} -} +\title{Group a tbl by one or more variables.} \description{ -Divide data into groups. +See \link[dplyr]{group_by}. } diff --git a/man/group_by_.Rd b/man/group_by_.Rd new file mode 100644 index 0000000000..acfbe1b371 --- /dev/null +++ b/man/group_by_.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{group_by_} +\alias{group_by_} +\title{Group a tbl by one or more variables.} +\description{ +See \link[dplyr]{group_by}. +} + diff --git a/man/groups.Rd b/man/groups.Rd new file mode 100644 index 0000000000..1ed0ffbd93 --- /dev/null +++ b/man/groups.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{groups} +\alias{groups} +\title{Get/set the grouping variables for tbl.} +\description{ +See \link[dplyr]{groups}. +} + diff --git a/man/mutate.Rd b/man/mutate.Rd new file mode 100644 index 0000000000..2dc90edbd6 --- /dev/null +++ b/man/mutate.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{mutate} +\alias{mutate} +\title{Add new variables.} +\description{ +See \link[dplyr]{mutate}. +} + diff --git a/man/mutate_.Rd b/man/mutate_.Rd new file mode 100644 index 0000000000..3efada1894 --- /dev/null +++ b/man/mutate_.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{mutate_} +\alias{mutate_} +\title{Add new variables.} +\description{ +See \link[dplyr]{mutate_}. +} + diff --git a/man/plotly_data.Rd b/man/plotly_data.Rd index d45f8732ac..064ed70362 100644 --- a/man/plotly_data.Rd +++ b/man/plotly_data.Rd @@ -1,69 +1,68 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/plotly_data.R \name{plotly_data} -\alias{arrange_.plotly} -\alias{distinct_.plotly} -\alias{filter_.plotly} -\alias{group_by_.plotly} -\alias{groups.plotly} -\alias{mutate_.plotly} \alias{plotly_data} -\alias{rename_.plotly} -\alias{select_.plotly} -\alias{slice_.plotly} -\alias{summarise_.plotly} -\alias{transmute_.plotly} -\alias{ungroup.plotly} -\title{View and manipulate data associated with a plotly graph} +\title{Obtain data associated with a plotly graph} \usage{ plotly_data(p, id = p$x$cur_data) +} +\arguments{ +\item{p}{a plotly visualization} -groups.plotly(x) - -group_by_.plotly(.data, ..., .dots, add = FALSE) - -ungroup.plotly(x) - -summarise_.plotly(.data, ..., .dots) - -mutate_.plotly(.data, ..., .dots) - -arrange_.plotly(.data, ..., .dots) - -select_.plotly(.data, ..., .dots) - -filter_.plotly(.data, ..., .dots) - -distinct_.plotly(.data, ..., .dots) - -slice_.plotly(.data, ..., .dots) - -rename_.plotly(.data, ..., .dots) - -transmute_.plotly(.data, ..., .dots) +\item{id}{a character string or number referencing an "attribute layer".} +} +\value{ +returns a data frame } \description{ -\code{plotly_data()} returns the data associated with -a plotly visualization. This data can be manipulated via -the dplyr and tidyr verbs listed below: +\code{plotly_data()} returns data associated with +a plotly visualization (if there are multiple data frames, by default, +it returns the most recent one). } \examples{ -# loading dplyr is super important! -library(dplyr) +# use group_by() to define groups of visual markings +p <- txhousing \%>\% + group_by(city) \%>\% + plot_ly(x = ~date, y = ~sales) +p -mtcars \%>\% - plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") \%>\% - filter(cyl == 4) \%>\% - add_markers(x = ~wt, y = ~mpg, name = "filtered points", - marker = list(color = "red")) - -library(tidyr) -economics \%>\% - gather(variable, value, -date) \%>\% - group_by(variable) \%>\% - plot_ly(x = ~date, y = ~value) +# plotly objects preserve data groupings +groups(p) +plotly_data(p) + +# dplyr verbs operate on plotly objects as if they were data frames +p <- economics \%>\% + plot_ly(x = ~date, y = ~unemploy / pop) \%>\% + add_lines() \%>\% + mutate(rate = unemploy / pop) \%>\% + filter(rate == max(rate)) +plotly_data(p) +add_markers(p) +layout(p, annotations = list(x = ~date, y = ~rate, text = "peak")) + +# use group_by() + do() + subplot() for trellis displays +d <- group_by(mpg, drv) +plots <- do(d, p = plot_ly(., x = ~cty, name = ~drv)) +subplot(plots[["p"]], nrows = 3, shareX = TRUE) + +# arrange displays by their mean +means <- summarise(d, mn = mean(cty, na.rm = TRUE)) +means \%>\% + left_join(plots) \%>\% + arrange(mn) \%>\% + .[["p"]] \%>\% + subplot(nrows = NROW(.), shareX = TRUE) +# more dplyr verbs applied to plotly objects +p <- mtcars \%>\% + plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") \%>\% + add_markers() +p \%>\% slice(1) \%>\% plotly_data() +p \%>\% slice(1) \%>\% add_markers(name = "first observation") +p \%>\% filter(cyl == 4) \%>\% plotly_data() +p \%>\% filter(cyl == 4) \%>\% add_markers(name = "four cylinders") + + } -\keyword{internal} diff --git a/man/rename.Rd b/man/rename.Rd new file mode 100644 index 0000000000..451f1cefa8 --- /dev/null +++ b/man/rename.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{rename} +\alias{rename} +\title{Select/rename variables by name.} +\description{ +See \link[dplyr]{rename}. +} + diff --git a/man/rename_.Rd b/man/rename_.Rd new file mode 100644 index 0000000000..6fcaba4005 --- /dev/null +++ b/man/rename_.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{rename_} +\alias{rename_} +\title{Select/rename variables by name.} +\description{ +See \link[dplyr]{rename_}. +} + diff --git a/man/select.Rd b/man/select.Rd new file mode 100644 index 0000000000..65de1e2e7d --- /dev/null +++ b/man/select.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{select} +\alias{select} +\title{Select/rename variables by name.} +\description{ +See \link[dplyr]{select}. +} + diff --git a/man/select_.Rd b/man/select_.Rd new file mode 100644 index 0000000000..4b078e32bb --- /dev/null +++ b/man/select_.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{select_} +\alias{select_} +\title{Select/rename variables by name.} +\description{ +See \link[dplyr]{select_}. +} + diff --git a/man/slice.Rd b/man/slice.Rd new file mode 100644 index 0000000000..652cd3cf25 --- /dev/null +++ b/man/slice.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{slice} +\alias{slice} +\title{Select rows by position.} +\description{ +See \link[dplyr]{slice}. +} + diff --git a/man/slice_.Rd b/man/slice_.Rd new file mode 100644 index 0000000000..553f2155b6 --- /dev/null +++ b/man/slice_.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{slice_} +\alias{slice_} +\title{Select rows by position.} +\description{ +See \link[dplyr]{slice_}. +} + diff --git a/man/summarise.Rd b/man/summarise.Rd new file mode 100644 index 0000000000..697e77b456 --- /dev/null +++ b/man/summarise.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{summarise} +\alias{summarise} +\title{Summarise multiple values to a single value.} +\description{ +See \link[dplyr]{summarise}. +} + diff --git a/man/summarise_.Rd b/man/summarise_.Rd new file mode 100644 index 0000000000..9566370289 --- /dev/null +++ b/man/summarise_.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{summarise_} +\alias{summarise_} +\title{Summarise multiple values to a single value.} +\description{ +See \link[dplyr]{summarise_}. +} + diff --git a/man/transmute.Rd b/man/transmute.Rd new file mode 100644 index 0000000000..c926663a6e --- /dev/null +++ b/man/transmute.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{transmute} +\alias{transmute} +\title{Add new variables.} +\description{ +See \link[dplyr]{transmute}. +} + diff --git a/man/transmute_.Rd b/man/transmute_.Rd new file mode 100644 index 0000000000..3cf7168f78 --- /dev/null +++ b/man/transmute_.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{transmute_} +\alias{transmute_} +\title{Add new variables.} +\description{ +See \link[dplyr]{transmute_}. +} + diff --git a/man/ungroup.Rd b/man/ungroup.Rd new file mode 100644 index 0000000000..16afe0109f --- /dev/null +++ b/man/ungroup.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{ungroup} +\alias{ungroup} +\title{Get/set the grouping variables for tbl.} +\description{ +See \link[dplyr]{ungroup}. +} + From 522224c9979b833ad40682a409c280b7c6ca3db9 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Tue, 28 Jun 2016 11:25:40 -0700 Subject: [PATCH 68/73] export filter --- NAMESPACE | 4 ++++ R/helpers.R | 3 +++ R/imports.R | 18 ++++++++++++++++++ man/filter.Rd | 9 +++++++++ man/filter_.Rd | 9 +++++++++ 5 files changed, 43 insertions(+) create mode 100644 man/filter.Rd create mode 100644 man/filter_.Rd diff --git a/NAMESPACE b/NAMESPACE index 6f3eb1ea1e..41c87a4e27 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -78,6 +78,8 @@ export(do_) export(embed_notebook) export(event_data) export(export) +export(filter) +export(filter_) export(filter_.plotly) export(geom2trace) export(get_figure) @@ -136,6 +138,8 @@ importFrom(dplyr,distinct) importFrom(dplyr,distinct_) importFrom(dplyr,do) importFrom(dplyr,do_) +importFrom(dplyr,filter) +importFrom(dplyr,filter_) importFrom(dplyr,group_by) importFrom(dplyr,group_by_) importFrom(dplyr,groups) diff --git a/R/helpers.R b/R/helpers.R index 94f7e03723..68d1c1d070 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -32,6 +32,9 @@ hide_colorbar <- function(p) { #' toWebGL(qplot(1:10, 1:10)) #' toWebGL <- function(p) { + if (ggplot2::is.ggplot(p)) { + p <- plotly_build(p) + } p$x$.plotlyWebGl <- TRUE p } diff --git a/R/imports.R b/R/imports.R index 8086febfcb..55981b9ec6 100644 --- a/R/imports.R +++ b/R/imports.R @@ -212,3 +212,21 @@ NULL #' @name slice_ #' @export NULL + +#' Return rows with matching conditions. +#' +#' See \link[dplyr]{filter}. +#' +#' @importFrom dplyr filter +#' @name filter +#' @export +NULL + +#' Return rows with matching conditions. +#' +#' See \link[dplyr]{filter_asw}. +#' +#' @importFrom dplyr filter_ +#' @name filter_ +#' @export +NULL diff --git a/man/filter.Rd b/man/filter.Rd new file mode 100644 index 0000000000..c7ad44660e --- /dev/null +++ b/man/filter.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{filter} +\alias{filter} +\title{Return rows with matching conditions.} +\description{ +See \link[dplyr]{filter}. +} + diff --git a/man/filter_.Rd b/man/filter_.Rd new file mode 100644 index 0000000000..cf52143354 --- /dev/null +++ b/man/filter_.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/imports.R +\name{filter_} +\alias{filter_} +\title{Return rows with matching conditions.} +\description{ +See \link[dplyr]{filter_asw}. +} + From 3e3e881626f4c2ea86de49fc35694038c616e999 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 29 Jun 2016 16:22:05 -0700 Subject: [PATCH 69/73] a few half-baked ideas for fill/stroke/alpha shortcuts --- R/add.R | 39 ++++++++++++++++++++++++------- R/plotly_build.R | 3 ++- man/add_trace.Rd | 9 ++++++- tests/testthat/test-plotly-data.R | 21 +++++++++++++++++ tests/testthat/test-plotly.R | 4 ---- 5 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 tests/testthat/test-plotly-data.R diff --git a/R/add.R b/R/add.R index aebb709903..7736066b19 100644 --- a/R/add.R +++ b/R/add.R @@ -84,15 +84,27 @@ add_trace <- function(p, ..., #' @inheritParams add_trace #' @rdname add_trace +#' @param fill fill color. Supplies defaults for +#' \url{https://plot.ly/r/reference/#scatter-marker-color} +#' @param stroke stroke color. Supplies defaults for +#' \url{https://plot.ly/r/reference/#scatter-marker-line-color} +#' @param alpha alpha channel for fill/stroke (on 0-1 scale). #' @export -add_markers <- function(p, x = NULL, y = NULL, ...) { +add_markers <- function(p, x = NULL, y = NULL, fill = "rgba(31, 119, 180, 1)", + stroke = "rgba(31, 119, 180, 1)", alpha = 1, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { stop("Must supply `y` attribute", call. = FALSE) } - add_trace(p, x = x, y = y, type = "scatter", mode = "markers", ...) + # TODO: should stroke/fill inherit from the top-level? + marker <- modify_list(p$x$attrs[[1]][["marker"]], list(...)[["marker"]]) + marker <- modify_list(marker, list(color = toRGB(fill, alpha))) + marker$line <- modify_list(marker$line, list(color = toRGB(stroke, alpha))) + add_trace( + p, x = x, y = y, marker = marker, type = "scatter", mode = "markers", ... + ) } @@ -135,16 +147,20 @@ add_paths <- function(p, x = NULL, y = NULL, ...) { #' txhousing %>% #' group_by(city) %>% #' plot_ly(x = ~date, y = ~median) %>% -#' add_lines(line = list(color = toRGB("black", 0.2))) -add_lines <- function(p, x = NULL, y = NULL, ...) { +#' add_lines(fill = "black") +add_lines <- function(p, x = NULL, y = NULL, stroke = NULL, alpha = 1, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { stop("Must supply `y` attribute", call. = FALSE) } + + line <- modify_list(p$x$attrs[[1]][["line"]], list(...)[["line"]]) + line <- modify_list(line, list(color = toRGB(stroke, alpha))) + add_trace_classed( - p, x = x, y = y, class = "plotly_line", type = "scatter", mode = "lines", ... + p, x = x, y = y, line = line, class = "plotly_line", type = "scatter", mode = "lines", ... ) } @@ -207,7 +223,9 @@ add_polygons <- function(p, x = NULL, y = NULL, ...) { #' plot_ly(economics, x = ~date) %>% #' add_ribbons(ymin = ~pce - 1e3, ymax = ~pce + 1e3) -add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, ...) { +add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, + fill = "rgba(31, 119, 180, 1)", + stroke = "transparent", alpha = 1, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } @@ -217,10 +235,15 @@ add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, ...) { if (is.null(ymax <- ymax %||% p$x$attrs[[1]][["ymax"]])) { stop("Must supply `ymax` attribute", call. = FALSE) } + # TODO: should stroke/fill inherit from the top-level? + # probably not, since fill conflicts with scatter's fill attribute! + line <- modify_list(p$x$attrs[[1]][["line"]], list(...)[["line"]]) + line <- modify_list(line, list(color = toRGB(stroke, alpha))) + add_trace_classed( p, class = c("plotly_ribbon", "plotly_polygon"), - x = x, ymin = ymin, ymax = ymax, - type = "scatter", fill = "toself", mode = "lines", ... + x = x, ymin = ymin, ymax = ymax, type = "scatter", mode = "lines", + line = line, fillcolor = toRGB(fill, alpha), fill = "toself", ... ) } diff --git a/R/plotly_build.R b/R/plotly_build.R index 58d32aa19d..6188b52e64 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -130,6 +130,7 @@ plotly_build.plotly <- function(p) { if (length(arrangeVars)) { builtData <- dplyr::arrange_(builtData, arrangeVars) } + # copy over to the trace data for (i in names(builtData)) { x[[i]] <- builtData[[i]] @@ -140,7 +141,7 @@ plotly_build.plotly <- function(p) { x$mode <- if (any(attrLengths > 20)) "lines" else "markers+lines" } - x[attrLengths > 0] + x[lengths(x) > 0] }, p$x$attrs, names2(p$x$attrs)) diff --git a/man/add_trace.Rd b/man/add_trace.Rd index d02ebee473..dd16c61fd8 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -24,7 +24,8 @@ \usage{ add_trace(p, ..., color, symbol, size, linetype, data = NULL) -add_markers(p, x = NULL, y = NULL, ...) +add_markers(p, x = NULL, y = NULL, fill = NULL, stroke = NULL, + alpha = 1, ...) add_text(p, x = NULL, y = NULL, text = NULL, ...) @@ -81,6 +82,12 @@ provided, arguments are evaluated using the data frame in \code{\link{plot_ly}() \item{y}{the y variable.} +\item{fill}{fill color} + +\item{stroke}{stroke color} + +\item{alpha}{alpha transparency} + \item{text}{textual labels.} \item{ymin}{a variable used to define the lower boundary of a polygon.} diff --git a/tests/testthat/test-plotly-data.R b/tests/testthat/test-plotly-data.R new file mode 100644 index 0000000000..48cb658f46 --- /dev/null +++ b/tests/testthat/test-plotly-data.R @@ -0,0 +1,21 @@ +context("plotly data") + +test_that("uniq works as expected", { + expect_equal(uniq(c("red", "red", NA)), "red") +}) + +test_that("plotly_data returns empty data frame when none is specified", { + d <- plotly_data(plot_ly()) + expect_true(is.data.frame(d) && NROW(d) == 0) +}) + +test_that("plotly_data returns data frame", { + d <- plotly_data(plot_ly(economics)) + expect_identical(economics, d) +}) + +test_that("plotly_data preserves groups in data", { + d <- plotly_data(group_by_(plot_ly(mtcars), c("vs", "am"))) + expect_true(dplyr::groups(d)[[1]] == "vs") +}) + diff --git a/tests/testthat/test-plotly.R b/tests/testthat/test-plotly.R index d4881c2110..cf79d19f1c 100644 --- a/tests/testthat/test-plotly.R +++ b/tests/testthat/test-plotly.R @@ -1,9 +1,5 @@ context("plot_ly") -test_that("uniq works as expected", { - expect_equal(uniq(c("red", "red", NA)), "red") -}) - expect_traces <- function(p, n.traces, name){ stopifnot(is.numeric(n.traces)) L <- save_outputs(p, paste0("plotly-", name)) From 77d47ed9b2bb1383203e5305dfe56526c3894afe Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 6 Jul 2016 15:01:25 -0500 Subject: [PATCH 70/73] upgrade to plotlyjs 1.14.1 --- NEWS | 4 +- .../lib/plotlyjs/plotly-latest.min.js | 37 ++++++++++--------- inst/htmlwidgets/plotly.yaml | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/NEWS b/NEWS index 95ece5e79d..ff92aede34 100644 --- a/NEWS +++ b/NEWS @@ -7,7 +7,7 @@ BREAKING CHANGES & IMPROVEMENTS: * The `group` variable mapping no longer create multiple traces, but instead defines "gaps" within a trace (fixes #418, #381, #577). Groupings should be declared via the new `group_by()` function (see `help(plotly_data)` for examples) instead of the `group` argument (which is now deprecated). * `plot_ly()` now _initializes_ a plotly object (i.e., won't add a scatter trace by default), meaning that something like `plot_ly(x = 1:10, y = 1:10) %>% add_trace(y = 10:1)` will create one trace, instead of two. However, `plot_ly()` will draw a trace if you manually specify a trace type, for example, `plot_ly(x = 1:10, y = 1:10, type = "scatter") %>% add_trace(y = 10:1)` will draw two scatter traces. If no trace type is provided, a sensible type is inferred from the supplied data, and automatically added (i.e., `plot_ly(x = rnorm(100))` now creates a histogram). * The `inherit` argument is deprecated. Any arguments/attributes specified in `plot_ly()` will automatically be passed along to additional traces added via `add_trace()` (or any of it's `add_*()` siblings). -* Scales for variable mappings (such as `color`, `symbol`, `linetype`) are now applied at the plot-level instead of the trace level. For this reason, the range of these scales (`colors`/`symbols`/`linetypes`) should be specified in `plot_ly()`, instead of `add_trace()` or any of it's `add_*()` siblings. +* Scales for aesthetics (e.g., `color`, `symbol`, `linetype`) are now applied at the plot-level, instead of the trace level. To avoid scaling, wrap the aesthetic value with `I()`, for example: `plot_ly(x = 1:10, y = 1:10, color = I("red"))`. NEW FEATURES & IMPROVEMENTS: @@ -24,7 +24,7 @@ NEW FEATURES & IMPROVEMENTS: OTHER CHANGES: -* Upgraded to plotly.js v1.13.0 -- https://github.com/plotly/plotly.js/releases/tag/v1.13.0 +* Upgraded to plotly.js v1.14.1 -- https://github.com/plotly/plotly.js/releases/tag/v1.14.1 3.6.5 -- 10 June 2016 diff --git a/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js b/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js index 3dfca5ec0a..6172533e33 100644 --- a/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js +++ b/inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js @@ -1,5 +1,5 @@ /** -* plotly.js v1.13.0 +* plotly.js v1.14.1 * Copyright 2012-2016, Plotly, Inc. * All rights reserved. * Licensed under the MIT license @@ -25,20 +25,21 @@ e:for(var gt=0;3>gt;++gt){it[gt]=0;var vt=(et+gt+1)%3;for(H=0;2>H;++H){var mt=H? r.unique=c,r.findCell=u,r.incidence=f,r.dual=h,r.explode=d,r.skeleton=p,r.boundary=g,r.connectedComponents=y},{"bit-twiddle":236,"union-find":237}],239:[function(t,e,r){"use strict";function n(t){for(var e=new Array(t),r=0;t>r;++r)e[r]=r;return e}e.exports=n},{}],240:[function(t,e,r){e.exports=function(t){return!(null==t||!(t._isBuffer||t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)))}},{}],241:[function(t,e,r){"use strict";function n(t,e){function r(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==g.alt,g.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==g.shift,g.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==g.control,g.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==g.meta,g.meta=!!t.metaKey),e}function n(t,n){var a=i.x(n),o=i.y(n);"buttons"in n&&(t=0|n.buttons),(t!==h||a!==d||o!==p||r(n))&&(h=0|t,d=a||0,p=o||0,e(h,d,p,g))}function a(t){n(0,t)}function o(){(h||d||p||g.shift||g.alt||g.meta||g.control)&&(d=p=0,h=0,g.shift=g.alt=g.control=g.meta=!1,e(0,0,0,g))}function s(t){r(t)&&e(h,d,p,g)}function l(t){0===i.buttons(t)?n(0,t):n(h,t)}function c(t){n(h|i.buttons(t),t)}function u(t){n(h&~i.buttons(t),t)}function f(){v||(v=!0,t.addEventListener("mousemove",l),t.addEventListener("mousedown",c),t.addEventListener("mouseup",u),t.addEventListener("mouseleave",a),t.addEventListener("mouseenter",a),t.addEventListener("mouseout",a),t.addEventListener("mouseover",a),t.addEventListener("blur",o),t.addEventListener("keyup",s),t.addEventListener("keydown",s),t.addEventListener("keypress",s),t!==window&&(window.addEventListener("blur",o),window.addEventListener("keyup",s),window.addEventListener("keydown",s),window.addEventListener("keypress",s)))}e||(e=t,t=window);var h=0,d=0,p=0,g={shift:!1,alt:!1,control:!1,meta:!1},v=!1;f();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return v},set:function(t){t&&f()},enumerable:!0},buttons:{get:function(){return h},enumerable:!0},x:{get:function(){return d},enumerable:!0},y:{get:function(){return p},enumerable:!0},mods:{get:function(){return g},enumerable:!0}}),m}e.exports=n;var i=t("mouse-event")},{"mouse-event":242}],242:[function(t,e,r){"use strict";function n(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<=0&&r=0&&r+1=0&&n=0&&n+1=0&&s=0&&s+1=0&&i=0&&i+1=0&&l=0&&l+1=0&&h=0&&h+1e;++e)r=+arguments[e+1],i[e]=Math.floor(r),a[e]=r-i[e],o[e]=0<=i[e]&&i[e]e;++e){for(c=1,u=t.offset,l=0;n>l;++l)if(e&1<r;++r){t[r]=o[(n+1)*n+r];for(var i=0;n>i;++i)t[r]+=o[(n+1)*i+r]*e[i]}for(var a=o[(n+1)*(n+1)-1],i=0;n>i;++i)a+=o[(n+1)*i+n]*e[i];for(var s=1/a,r=0;n>r;++r)t[r]*=s;return t}),t}var i=t("ndarray-warp"),a=t("gl-matrix-invert");e.exports=n},{"gl-matrix-invert":247,"ndarray-warp":250}],252:[function(t,e,r){"use strict";function n(t){if(!t)return s;for(var e=0;e>",rrshift:">>>"};!function(){for(var t in l){var e=l[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var c={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in c){var e=c[t];r[t]=a({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var u={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in u){var e=u[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var f=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=o({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=o({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=o({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":109}],253:[function(t,e,r){function n(t,e){return t[0]-e[0]}function i(){var t,e=this.stride,r=new Array(e.length);for(t=0;te&&(r="View_Nil"+t);var n="generic"===t;if(-1===e){var a="function "+r+"(a){this.data=a;};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+r+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+r+"(a){return new "+r+"(a);}",o=new Function(a);return o()}if(0===e){var a="function "+r+"(a,d) {this.data = a;this.offset = d};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+r+"_copy() {return new "+r+"(this.data,this.offset)};proto.pick=function "+r+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+r+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+r+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+r+"(a,b,c,d){return new "+r+"(a,d)}",o=new Function("TrivialArray",a);return o(f[t][0])}var a=["'use strict'"],s=l(e),c=s.map(function(t){return"i"+t}),u="this.offset+"+s.map(function(t){return"this.stride["+t+"]*i"+t}).join("+"),h=s.map(function(t){return"b"+t}).join(","),d=s.map(function(t){return"c"+t}).join(",");a.push("function "+r+"(a,"+h+","+d+",d){this.data=a","this.shape=["+h+"]","this.stride=["+d+"]","this.offset=d|0}","var proto="+r+".prototype","proto.dtype='"+t+"'","proto.dimension="+e),a.push("Object.defineProperty(proto,'size',{get:function "+r+"_size(){return "+s.map(function(t){return"this.shape["+t+"]"}).join("*"),"}})"),1===e?a.push("proto.order=[0]"):(a.push("Object.defineProperty(proto,'order',{get:"),4>e?(a.push("function "+r+"_order(){"),2===e?a.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+c.join(",")+",v){"),n?a.push("return this.data.set("+u+",v)}"):a.push("return this.data["+u+"]=v}"),a.push("proto.get=function "+r+"_get("+c.join(",")+"){"),n?a.push("return this.data.get("+u+")}"):a.push("return this.data["+u+"]}"),a.push("proto.index=function "+r+"_index(",c.join(),"){return "+u+"}"),a.push("proto.hi=function "+r+"_hi("+c.join(",")+"){return new "+r+"(this.data,"+s.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+s.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=s.map(function(t){return"a"+t+"=this.shape["+t+"]"}),g=s.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+c.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+g.join(","));for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){d=i"+v+"|0;b+=c"+v+"*d;a"+v+"-=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+c.join(",")+"){var "+s.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+s.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'){d=i"+v+"|0;if(d<0){c+=b"+v+"*(a"+v+"-1);a"+v+"=ceil(-a"+v+"/d)}else{a"+v+"=ceil(a"+v+"/d)}b"+v+"*=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"b"+t}).join(",")+",c)}");for(var m=new Array(e),y=new Array(e),v=0;e>v;++v)m[v]="a[i"+v+"]",y[v]="b[i"+v+"]";a.push("proto.transpose=function "+r+"_transpose("+c+"){"+c.map(function(t,e){return t+"=("+t+"===undefined?"+e+":"+t+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+r+"(this.data,"+m.join(",")+","+y.join(",")+",this.offset)}"),a.push("proto.pick=function "+r+"_pick("+c+"){var a=[],b=[],c=this.offset");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+s.map(function(t){return"shape["+t+"]"}).join(",")+","+s.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}");var o=new Function("CTOR_LIST","ORDER",a.join("\n"));return o(f[t],i)}function o(t){if(c(t))return"buffer";if(u)switch(Object.prototype.toString.call(t)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(t)?"array":"generic"}function s(t,e,r,n){if(void 0===t){var i=f.array[0];return i([])}"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var s=e.length;if(void 0===r){r=new Array(s);for(var l=s-1,c=1;l>=0;--l)r[l]=c,c*=e[l]}if(void 0===n){n=0;for(var l=0;s>l;++l)r[l]<0&&(n-=(e[l]-1)*r[l])}for(var u=o(t),h=f[u];h.length<=s+1;)h.push(a(u,h.length-1));var i=h[s+1];return i(t,e,r,n)}var l=t("iota-array"),c=t("is-buffer"),u="undefined"!=typeof Float64Array,f={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=s},{"iota-array":239,"is-buffer":240}],254:[function(t,e,r){"use strict";function n(t,e){if("string"!=typeof t)throw new TypeError("repeat-string expects a string.");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;for(i===t&&"undefined"!=typeof i||(i=t,a="");r>a.length&&e>0&&(1&e&&(a+=t),e>>=1);)t+=t;return a.substr(0,r)}var i,a="";e.exports=n},{}],255:[function(t,e,r){(function(t){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],256:[function(t,e,r){"use strict";function n(t){for(var e="robustLinearSolve"+t+"d",r=["function ",e,"(A,b){return ["],n=0;t>n;++n){r.push("det([");for(var i=0;t>i;++i){i>0&&r.push(","),r.push("[");for(var a=0;t>a;++a)a>0&&r.push(","),a===n?r.push("+b[",i,"]"):r.push("+A[",i,"][",a,"]");r.push("]")}r.push("]),")}r.push("det(A)]}return ",e);var o=new Function("det",r.join(""));return o(6>t?s[t]:s)}function i(){return[0]}function a(t,e){return[[e[0]],[t[0][0]]]}function o(){for(;c.lengthi;++i)t.push("s"+i),r.push("case ",i,":return s",i,"(A,b);");r.push("}var s=CACHE[A.length];if(!s)s=CACHE[A.length]=g(A.length);return s(A,b)}return dispatchLinearSolve"),t.push("CACHE","g",r.join(""));var a=Function.apply(void 0,t);e.exports=a.apply(void 0,c.concat([c,n]));for(var i=0;l>i;++i)e.exports[i]=c[i]}var s=t("robust-determinant"),l=6,c=[i,a];o()},{"robust-determinant":258}],257:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=t[t.length-1],n=e,i=e-2;i>=0;--i){var a=r,o=t[i];r=a+o;var s=r-a,l=o-s;l&&(t[--n]=r,r=l)}for(var c=0,i=n;e>i;++i){var a=t[i],o=r;r=a+o;var s=r-a,l=o-s;l&&(t[c++]=l)}return t[c++]=r,t.length=c,t}e.exports=n},{}],258:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m[",r,"][",n,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("");for(var e=[],r=0;rn;++n)t.push("det"+n),r.push("case ",n,":return det",n,"(m);");r.push("}var det=CACHE[m.length];if(!det)det=CACHE[m.length]=gen(m.length);return det(m);}return robustDeterminant"),t.push("CACHE","gen",r.join(""));var i=Function.apply(void 0,t);e.exports=i.apply(void 0,g.concat([g,l]));for(var n=0;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-1,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;rc;++c)0===(1&c)?e.push.apply(e,s(n(a,c))):r.push.apply(r,s(n(a,c))),l.push("m"+c);var u=o(e),g=o(r),v="orientation"+t+"Exact",m=["function ",v,"(",l.join(),"){var p=",u,",n=",g,",d=sub(p,n);return d[d.length-1];};return ",v].join(""),y=new Function("sum","prod","scale","sub",m);return y(h,f,d,p)}function c(t){var e=_[t.length];return e||(e=_[t.length]=l(t.length)),e.apply(void 0,t)}function u(){for(;_.length<=g;)_.push(l(_.length));for(var t=[],r=["slow"],n=0;g>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;g>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var f=t("two-product"),h=t("robust-sum"),d=t("robust-scale"),p=t("robust-subtract"),g=5,v=1.1102230246251565e-16,m=(3+16*v)*v,y=(7+56*v)*v,b=l(3),x=l(4),_=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,r){var n,i=(t[1]-r[1])*(e[0]-r[0]),a=(t[0]-r[0])*(e[1]-r[1]),o=i-a;if(i>0){if(0>=a)return o;n=i+a}else{if(!(0>i))return o;if(a>=0)return o;n=-(i+a)}var s=m*n;return o>=s||-s>=o?o:b(t,e,r)},function(t,e,r,n){ var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],d=a*c,p=o*l,g=o*s,v=i*c,m=i*l,b=a*s,_=u*(d-p)+f*(g-v)+h*(m-b),w=(Math.abs(d)+Math.abs(p))*Math.abs(u)+(Math.abs(g)+Math.abs(v))*Math.abs(f)+(Math.abs(m)+Math.abs(b))*Math.abs(h),k=y*w;return _>k||-_>k?_:x(t,e,r,n)}];u()},{"robust-scale":260,"robust-subtract":261,"robust-sum":262,"two-product":276}],260:[function(t,e,r){"use strict";function n(t,e){var r=t.length;if(1===r){var n=i(t[0],e);return n[0]?n:[n[1]]}var o=new Array(2*r),s=[.1,.1],l=[.1,.1],c=0;i(t[0],e,s),s[0]&&(o[c++]=s[0]);for(var u=1;r>u;++u){i(t[u],e,l);var f=s[1];a(f,l[0],s),s[0]&&(o[c++]=s[0]);var h=l[1],d=s[1],p=h+d,g=p-h,v=d-g;s[1]=p,v&&(o[c++]=v)}return s[1]&&(o[c++]=s[1]),0===c&&(o[c++]=0),o.length=c,o}var i=t("two-product"),a=t("two-sum");e.exports=n},{"two-product":276,"two-sum":277}],261:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],-e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=-e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=-e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=-e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],262:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],e[0]);var a,o,s=r+i,l=new Array(s),c=0,u=0,f=0,h=Math.abs,d=t[u],p=h(d),g=e[f],v=h(g);v>p?(o=d,u+=1,r>u&&(d=t[u],p=h(d))):(o=g,f+=1,i>f&&(g=e[f],v=h(g))),r>u&&v>p||f>=i?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,k=w-a,A=o-k,M=A,T=w;r>u&&i>f;)v>p?(a=d,u+=1,r>u&&(d=t[u],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g))),o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m;for(;r>u;)a=d,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,u+=1,r>u&&(d=t[u]);for(;i>f;)a=g,o=M,w=a+o,k=w-a,A=o-k,A&&(l[c++]=A),m=T+w,y=m-T,b=m-y,x=w-y,_=T-b,M=_+x,T=m,f+=1,i>f&&(g=e[f]);return M&&(l[c++]=M),T&&(l[c++]=T),c||(l[c++]=0),l.length=c,l}e.exports=i},{}],263:[function(t,e,r){"use strict";function n(t){return t.split("").map(function(t){return t in i?i[t]:""}).join("")}e.exports=n;var i={" ":" ",0:"\u2070",1:"\xb9",2:"\xb2",3:"\xb3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079","+":"\u207a","-":"\u207b",a:"\u1d43",b:"\u1d47",c:"\u1d9c",d:"\u1d48",e:"\u1d49",f:"\u1da0",g:"\u1d4d",h:"\u02b0",i:"\u2071",j:"\u02b2",k:"\u1d4f",l:"\u02e1",m:"\u1d50",n:"\u207f",o:"\u1d52",p:"\u1d56",r:"\u02b3",s:"\u02e2",t:"\u1d57",u:"\u1d58",v:"\u1d5b",w:"\u02b7",x:"\u02e3",y:"\u02b8",z:"\u1dbb"}},{}],264:[function(t,e,r){"use strict";function n(t){return"a"+t}function i(t){return"d"+t}function a(t,e){return"c"+t+"_"+e}function o(t){return"s"+t}function s(t,e){return"t"+t+"_"+e}function l(t){return"o"+t}function c(t){return"x"+t}function u(t){return"p"+t}function f(t,e){return"d"+t+"_"+e}function h(t){return"i"+t}function d(t,e){return"u"+t+"_"+e}function p(t){return"b"+t}function g(t){return"y"+t}function v(t){return"e"+t}function m(t){return"v"+t}function y(t,e,r){for(var n=0,i=0;t>i;++i)e&1<e;++e)F.push(u(e),"+=",d(e,x[t]),";");F.push("}")}function z(t){for(var e=t-1;e>=0;--e)S(e,0);for(var r=[],e=0;I>e;++e)L[e]?r.push(i(e)+".get("+u(e)+")"):r.push(i(e)+"["+u(e)+"]");for(var e=0;b>e;++e)r.push(c(e));F.push(k,"[",T,"++]=phase(",r.join(),");");for(var e=0;t>e;++e)C(e);for(var n=0;I>n;++n)F.push(u(n),"+=",d(n,x[t]),";")}function P(t){for(var e=0;I>e;++e)L[e]?F.push(a(e,0),"=",i(e),".get(",u(e),");"):F.push(a(e,0),"=",i(e),"[",u(e),"];");for(var r=[],e=0;I>e;++e)r.push(a(e,0));for(var e=0;b>e;++e)r.push(c(e));F.push(p(0),"=",k,"[",T,"]=phase(",r.join(),");");for(var n=1;1<n;++n)F.push(p(n),"=",k,"[",T,"+",v(n),"];");for(var o=[],n=1;1<n;++n)o.push("("+p(0)+"!=="+p(n)+")");F.push("if(",o.join("||"),"){");for(var s=[],e=0;N>e;++e)s.push(h(e));for(var e=0;I>e;++e){s.push(a(e,0));for(var n=1;1<n;++n)L[e]?F.push(a(e,n),"=",i(e),".get(",u(e),"+",f(e,n),");"):F.push(a(e,n),"=",i(e),"[",u(e),"+",f(e,n),"];"),s.push(a(e,n))}for(var e=0;1<e;++e)s.push(p(e));for(var e=0;b>e;++e)s.push(c(e));F.push("vertex(",s.join(),");",m(0),"=",w,"[",T,"]=",A,"++;");for(var l=(1<n;++n)if(0===(t&~(1<0;_=_-1&g)x.push(w+"["+T+"+"+v(_)+"]");x.push(m(0));for(var _=0;I>_;++_)1&n?x.push(a(_,l),a(_,g)):x.push(a(_,g),a(_,l));1&n?x.push(d,y):x.push(y,d);for(var _=0;b>_;++_)x.push(c(_));F.push("if(",d,"!==",y,"){","face(",x.join(),")}")}F.push("}",T,"+=1;")}function R(){for(var t=1;1<t;++t)F.push(E,"=",v(t),";",v(t),"=",g(t),";",g(t),"=",E,";")}function O(t,e){if(0>t)return void P(e);z(t),F.push("if(",o(x[t]),">0){",h(x[t]),"=1;"),O(t-1,e|1<r;++r)F.push(u(r),"+=",d(r,x[t]),";");t===N-1&&(F.push(T,"=0;"),R()),S(t,2),O(t-1,e),t===N-1&&(F.push("if(",h(x[N-1]),"&1){",T,"=0;}"),R()),C(t),F.push("}")}var I=L.length,N=x.length;if(2>N)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var j="extractContour"+x.join("_"),F=[],D=[],B=[],U=0;I>U;++U)B.push(n(U));for(var U=0;b>U;++U)B.push(c(U));for(var U=0;N>U;++U)D.push(o(U)+"="+n(0)+".shape["+U+"]|0");for(var U=0;I>U;++U){D.push(i(U)+"="+n(U)+".data",l(U)+"="+n(U)+".offset|0");for(var V=0;N>V;++V)D.push(s(U,V)+"="+n(U)+".stride["+V+"]|0")}for(var U=0;I>U;++U){D.push(u(U)+"="+l(U)),D.push(a(U,0));for(var V=1;1<V;++V){for(var q=[],H=0;N>H;++H)V&1<U;++U)for(var V=0;N>V;++V){var G=[s(U,x[V])];V>0&&G.push(s(U,x[V-1])+"*"+o(x[V-1])),D.push(d(U,x[V])+"=("+G.join("-")+")|0")}for(var U=0;N>U;++U)D.push(h(U)+"=0");D.push(A+"=0");for(var Y=["2"],U=N-2;U>=0;--U)Y.push(o(x[U]));D.push(M+"=("+Y.join("*")+")|0",k+"=mallocUint32("+M+")",w+"=mallocUint32("+M+")",T+"=0"),D.push(p(0)+"=0");for(var V=1;1<V;++V){for(var X=[],W=[],H=0;N>H;++H)V&1<n&&e("Must have at least one array argument");var i=t.scalarArguments||0;0>i&&e("Scalar arg count must be > 0"),"function"!=typeof t.vertex&&e("Must specify vertex creation function"),"function"!=typeof t.cell&&e("Must specify cell creation function"),"function"!=typeof t.phase&&e("Must specify phase function");for(var a=t.getters||[],o=new Array(n),s=0;n>s;++s)a.indexOf(s)>=0?o[s]=!0:o[s]=!1;return b(t.vertex,t.cell,t.phase,i,r,o)}var _=t("typedarray-pool");e.exports=x;var w="V",k="P",A="N",M="Q",T="X",E="T"},{"typedarray-pool":278}],265:[function(t,e,r){function n(t){if(0>t)return Number("0/0");for(var e=s[0],r=s.length-1;r>0;--r)e+=s[r]/(t+r);var n=t+o+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}var i=7,a=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],o=607/128,s=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];e.exports=function l(t){if(.5>t)return Math.PI/(Math.sin(Math.PI*t)*l(1-t));if(t>100)return Math.exp(n(t));t-=1;for(var e=a[0],r=1;i+2>r;r++)e+=a[r]/(t+r);var o=t+i+.5;return Math.sqrt(2*Math.PI)*Math.pow(o,t+.5)*Math.exp(-o)*e},e.exports.log=n},{}],266:[function(t,e,r){"use strict";function n(t){var e=t.length;if(i>e){for(var r=1,n=0;e>n;++n)for(var o=0;n>o;++o)if(t[n]n;++n)s[n]=0;for(var r=1,n=0;e>n;++n)if(!s[n]){var l=1;s[n]=1;for(var o=t[n];o!==n;o=t[o]){if(s[o])return a.freeUint8(s),0;l+=1,s[o]=1}1&l||(r=-r)}return a.freeUint8(s),r}e.exports=n;var i=32,a=t("typedarray-pool")},{"typedarray-pool":278}],267:[function(t,e,r){"use strict";function n(t){var e=t.length;switch(e){case 0:case 1:return 0;case 2:return t[1]}var r,n,i,s=a.mallocUint32(e),l=a.mallocUint32(e),c=0;for(o(t,l),i=0;e>i;++i)s[i]=t[i];for(i=e-1;i>0;--i)n=l[i],r=s[i],s[i]=s[n],s[n]=r,l[i]=l[r],l[r]=n,c=(c+r)*i;return a.freeUint32(l),a.freeUint32(s),c}function i(t,e,r){switch(t){case 0:return r?r:[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}r=r||new Array(t);var n,i,a,o=1;for(r[0]=0,a=1;t>a;++a)r[a]=a,o=o*a|0;for(a=t-1;a>0;--a)n=e/o|0,e=e-n*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}var a=t("typedarray-pool"),o=t("invert-permutation");r.rank=n,r.unrank=i},{"invert-permutation":268,"typedarray-pool":278}],268:[function(t,e,r){"use strict";function n(t,e){e=e||new Array(t.length);for(var r=0;rt)return[];if(0===t)return[[0]];for(var e=0|Math.round(o(t+1)),r=[],n=0;e>n;++n){for(var s=i.unrank(t,n),l=[0],c=0,u=0;u= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":109}],271:[function(t,e,r){"use strict";function n(t,e){var r=[];return e=+e||0,i(t.hi(t.shape[0]-1),r,e),r}e.exports=n;var i=t("./lib/zc-core")},{"./lib/zc-core":270}],272:[function(t,e,r){"use strict";function n(t,e){var r=t.length,n=["'use strict';"],i="surfaceNets"+t.join("_")+"d"+e;n.push("var contour=genContour({","order:[",t.join(),"],","scalarArguments: 3,","phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },"),"generic"===e&&n.push("getters:[0],");for(var a=[],l=[],c=0;r>c;++c)a.push("d"+c),l.push("d"+c);for(var c=0;1<c;++c)a.push("v"+c),l.push("v"+c);for(var c=0;1<c;++c)a.push("p"+c),l.push("p"+c);a.push("a","b","c"),l.push("a","c"),n.push("vertex:function vertexFunc(",a.join(),"){");for(var u=[],c=0;1<c;++c)u.push("(p"+c+"<<"+c+")");n.push("var m=(",u.join("+"),")|0;if(m===0||m===",(1<<(1<=1<<(1<>>7){");for(var c=0;1<<(1<c;++c){if(1<<(1<128&&c%128===0){f.length>0&&h.push("}}");var d="vExtra"+f.length;n.push("case ",c>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&c,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;r>b;++b)p[b]=[],g[b]=[],v[b]=0,m[b]=0;for(var b=0;1<b;++b)for(var x=0;r>x;++x){var _=b^1<b)&&!(c&1<<_)!=!(c&1<w?(p[x].push("-v"+b+"-v"+_),v[x]+=2):(p[x].push("v"+b+"+v"+_),v[x]-=2),y+=1;for(var k=0;r>k;++k)k!==x&&(_&1<x;++x)if(0===p[x].length)A.push("d"+x+"-0.5");else{var M="";v[x]<0?M=v[x]+"*c":v[x]>0&&(M="+"+v[x]+"*c");var T=.5*(p[x].length/y),E=.5+.5*(m[x]/y);A.push("d"+x+"-"+E+"-"+T+"*("+p[x].join("+")+M+")/("+g[x].join("+")+")")}h.push("a.push([",A.join(),"]);","break;")}n.push("}},"),f.length>0&&h.push("}}");for(var L=[],c=0;1<c;++c)L.push("v"+c);L.push("c0","c1","p0","p1","a","b","c"),n.push("cell:function cellFunc(",L.join(),"){");var S=s(r-1);n.push("if(p0){b.push(",S.map(function(t){return"["+t.map(function(t){return"v"+t})+"]"}).join(),")}else{b.push(",S.map(function(t){var e=t.slice();return e.reverse(),"["+e.map(function(t){return"v"+t})+"]"}).join(),")}}});function ",i,"(array,level){var verts=[],cells=[];contour(array,verts,cells,level);return {positions:verts,cells:cells};} return ",i,";");for(var c=0;co;++o)i[o]=[r[o]],a[o]=[o];return{positions:i,cells:a}}function a(t,e){if(t.dimension<=0)return{positions:[],cells:[]};if(1===t.dimension)return i(t,e);var r=t.order.join()+"-"+t.dtype,a=c[r],e=+e||0;return a||(a=c[r]=n(t.order,t.dtype)),a(t,e)}e.exports=a;var o=t("ndarray-extract-contour"),s=t("triangulate-hypercube"),l=t("zero-crossings"),c={}},{"ndarray-extract-contour":264,"triangulate-hypercube":269,"zero-crossings":271}],273:[function(t,e,r){(function(r){"use strict";function n(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;ol;++l){var c=r[s[l]];n[i++]=c[0],n[i++]=c[1]+1.4,a=Math.max(c[0],a)}return{data:n,shape:a}}function i(t,e){var r=s[t];r||(r=s[t]={" ":{data:new Float32Array(0),shape:.2}});var o=r[e];if(!o)if(e.length<=1||!/\d/.test(e))o=r[e]=n(a(e,{triangles:!0,font:t,textAlign:"left",textBaseline:"alphabetic"}));else{for(var l=e.split(/(\d|\s)/),c=new Array(l.length),u=0,f=0,h=0;h0&&(f+=.02);for(var d=new Float32Array(u),p=0,g=-.5*f,h=0;h.5?l/(2-a-o):l/(a+o),a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,l:s}}function o(t,e,r){function n(t,e,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?t+6*(e-t)*r:.5>r?e:2/3>r?t+(e-t)*(2/3-r)*6:t}var i,a,o;if(t=T(t,360),e=T(e,100),r=T(r,100),0===e)i=a=o=r;else{var s=.5>r?r*(1+e):r+e-r*e,l=2*r-s;i=n(l,s,t+1/3),a=n(l,s,t),o=n(l,s,t-1/3)}return{r:255*i,g:255*a,b:255*o}}function s(t,e,r){t=T(t,255),e=T(e,255),r=T(r,255);var n,i,a=q(t,e,r),o=V(t,e,r),s=a,l=a-o;if(i=0===a?0:l/a,a==o)n=0;else{switch(a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,v:s}}function l(t,e,r){t=6*T(t,360),e=T(e,100),r=T(r,100);var n=B.floor(t),i=t-n,a=r*(1-e),o=r*(1-i*e),s=r*(1-(1-i)*e),l=n%6,c=[r,o,a,a,s,r][l],u=[s,r,r,o,a,a][l],f=[a,a,s,r,r,o][l];return{r:255*c,g:255*u,b:255*f}}function c(t,e,r,n){var i=[z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function u(t,e,r,n){var i=[z(R(n)),z(U(t).toString(16)),z(U(e).toString(16)),z(U(r).toString(16))];return i.join("")}function f(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s-=r/100,n.s=E(n.s),e(n)}function h(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s+=r/100,n.s=E(n.s),e(n)}function d(t){return e(t).desaturate(100)}function p(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l+=r/100,n.l=E(n.l),e(n)}function g(t,r){r=0===r?0:r||10;var n=e(t).toRgb();return n.r=q(0,V(255,n.r-U(255*-(r/100)))),n.g=q(0,V(255,n.g-U(255*-(r/100)))),n.b=q(0,V(255,n.b-U(255*-(r/100)))),e(n)}function v(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l-=r/100,n.l=E(n.l),e(n)}function m(t,r){var n=e(t).toHsl(),i=(U(n.h)+r)%360;return n.h=0>i?360+i:i,e(n)}function y(t){var r=e(t).toHsl();return r.h=(r.h+180)%360,e(r)}function b(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+120)%360,s:r.s,l:r.l}),e({h:(n+240)%360,s:r.s,l:r.l})]}function x(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+90)%360,s:r.s,l:r.l}),e({h:(n+180)%360,s:r.s,l:r.l}),e({h:(n+270)%360,s:r.s,l:r.l})]}function _(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+72)%360,s:r.s,l:r.l}),e({h:(n+216)%360,s:r.s,l:r.l})]}function w(t,r,n){r=r||6,n=n||30;var i=e(t).toHsl(),a=360/n,o=[e(t)];for(i.h=(i.h-(a*r>>1)+720)%360;--r;)i.h=(i.h+a)%360,o.push(e(i));return o}function k(t,r){r=r||6;for(var n=e(t).toHsv(),i=n.h,a=n.s,o=n.v,s=[],l=1/r;r--;)s.push(e({h:i,s:a,v:o})),o=(o+l)%1;return s}function A(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}function M(t){return t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=1),t}function T(t,e){S(t)&&(t="100%");var r=C(t);return t=V(e,q(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),B.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function E(t){return V(1,q(0,t))}function L(t){return parseInt(t,16)}function S(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function C(t){return"string"==typeof t&&-1!=t.indexOf("%")}function z(t){return 1==t.length?"0"+t:""+t}function P(t){return 1>=t&&(t=100*t+"%"),t}function R(t){return Math.round(255*parseFloat(t)).toString(16)}function O(t){return L(t)/255}function I(t){t=t.replace(j,"").replace(F,"").toLowerCase();var e=!1;if(G[t])t=G[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=X.rgb.exec(t))?{r:r[1],g:r[2],b:r[3]}:(r=X.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=X.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=X.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=X.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=X.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=X.hex8.exec(t))?{a:O(r[1]),r:L(r[2]),g:L(r[3]),b:L(r[4]),format:e?"name":"hex8"}:(r=X.hex6.exec(t))?{r:L(r[1]),g:L(r[2]),b:L(r[3]),format:e?"name":"hex"}:(r=X.hex3.exec(t))?{r:L(r[1]+""+r[1]),g:L(r[2]+""+r[2]),b:L(r[3]+""+r[3]),format:e?"name":"hex"}:!1}function N(t){var e,r;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==r&&"large"!==r&&(r="small"),{level:e,size:r}}var j=/^\s+/,F=/\s+$/,D=0,B=Math,U=B.round,V=B.min,q=B.max,H=B.random;e.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,r,n,i,a,o=this.toRgb();return t=o.r/255,e=o.g/255,r=o.b/255,n=.03928>=t?t/12.92:Math.pow((t+.055)/1.055,2.4),i=.03928>=e?e/12.92:Math.pow((e+.055)/1.055,2.4),a=.03928>=r?r/12.92:Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*i+.0722*a},setAlpha:function(t){return this._a=M(t),this._roundA=U(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=a(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=a(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return u(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:U(this._r),g:U(this._g),b:U(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+U(this._r)+", "+U(this._g)+", "+U(this._b)+")":"rgba("+U(this._r)+", "+U(this._g)+", "+U(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:U(100*T(this._r,255))+"%",g:U(100*T(this._g,255))+"%",b:U(100*T(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%)":"rgba("+U(100*T(this._r,255))+"%, "+U(100*T(this._g,255))+"%, "+U(100*T(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:Y[c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+u(this._r,this._g,this._b,this._a),n=r,i=this._gradientType?"GradientType = 1, ":"";if(t){var a=e(t);n=a.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+r+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0,i=!e&&n&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return i?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return e(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(p,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(v,arguments)},desaturate:function(){return this._applyModification(f,arguments)},saturate:function(){return this._applyModification(h,arguments)},greyscale:function(){return this._applyModification(d,arguments)},spin:function(){return this._applyModification(m,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(w,arguments)},complement:function(){return this._applyCombination(y,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(_,arguments)},triad:function(){return this._applyCombination(b,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},e.fromRatio=function(t,r){if("object"==typeof t){var n={};for(var i in t)t.hasOwnProperty(i)&&("a"===i?n[i]=t[i]:n[i]=P(t[i]));t=n}return e(t,r)},e.equals=function(t,r){return t&&r?e(t).toRgbString()==e(r).toRgbString():!1},e.random=function(){return e.fromRatio({r:H(),g:H(),b:H()})},e.mix=function(t,r,n){n=0===n?0:n||50;var i,a=e(t).toRgb(),o=e(r).toRgb(),s=n/100,l=2*s-1,c=o.a-a.a;i=l*c==-1?l:(l+c)/(1+l*c),i=(i+1)/2;var u=1-i,f={r:o.r*i+a.r*u,g:o.g*i+a.g*u,b:o.b*i+a.b*u,a:o.a*s+a.a*(1-s)};return e(f)},e.readability=function(t,r){var n=e(t),i=e(r);return(Math.max(n.getLuminance(),i.getLuminance())+.05)/(Math.min(n.getLuminance(),i.getLuminance())+.05)},e.isReadable=function(t,r,n){var i,a,o=e.readability(t,r);switch(a=!1,i=N(n),i.level+i.size){case"AAsmall":case"AAAlarge":a=o>=4.5;break;case"AAlarge":a=o>=3;break;case"AAAsmall":a=o>=7}return a},e.mostReadable=function(t,r,n){var i,a,o,s,l=null,c=0;n=n||{},a=n.includeFallbackColors,o=n.level,s=n.size;for(var u=0;uc&&(c=i,l=e(r[u]));return e.isReadable(t,l,{level:o,size:s})||!a?l:(n.includeFallbackColors=!1,e.mostReadable(t,["#fff","#000"],n))};var G=e.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Y=e.hexNames=A(G),X=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",r="(?:"+e+")|(?:"+t+")",n="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",i="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof r&&r.exports?r.exports=e:"function"==typeof t&&t.amd?t(function(){return e}):window.tinycolor=e}()},{}],275:[function(e,r,n){!function(e,i){"object"==typeof n&&"undefined"!=typeof r?i(n):"function"==typeof t&&t.amd?t(["exports"],i):i(e.topojson={})}(this,function(t){"use strict";function e(){}function r(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0),t[0]=(r+=t[0])*i+o,t[1]=(n+=t[1])*a+s}}function n(t){if(!t)return e;var r,n,i=t.scale[0],a=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,e){e||(r=n=0);var l=(t[0]-o)/i|0,c=(t[1]-s)/a|0;t[0]=l-r,t[1]=c-n,r=l,n=c}}function i(t,e){for(var r,n=t.length,i=n-e;i<--n;)r=t[i],t[i++]=t[n],t[n]=r}function a(t,e){for(var r=0,n=t.length;n>r;){var i=r+n>>>1;t[i]t?~t:t],a=0,o=n.length;o>a;++a)e.push(r=n[a].slice()),u(r,a);0>t&&i(e,o)}function a(t){return t=t.slice(),u(t,0),t}function o(t){for(var e=[],r=0,i=t.length;i>r;++r)n(t[r],e);return e.length<2&&e.push(e[0].slice()),e}function s(t){for(var e=o(t);e.length<4;)e.push(e[0].slice());return e}function l(t){return t.map(s)}function c(t){var e=t.type;return"GeometryCollection"===e?{type:e,geometries:t.geometries.map(c)}:e in h?{type:e,coordinates:h[e](t)}:null}var u=r(t.transform),f=t.arcs,h={Point:function(t){return a(t.coordinates)},MultiPoint:function(t){return t.coordinates.map(a)},LineString:function(t){return o(t.arcs)},MultiLineString:function(t){return t.arcs.map(o)},Polygon:function(t){return l(t.arcs)},MultiPolygon:function(t){return t.arcs.map(l)}};return c(e)}function c(t,e){function r(e){var r,n=t.arcs[0>e?~e:e],i=n[0];return t.transform?(r=[0,0],n.forEach(function(t){r[0]+=t[0],r[1]+=t[1]})):r=n[n.length-1],0>e?[r,i]:[i,r]}function n(t,e){for(var r in t){var n=t[r];delete e[n.start],delete n.start,delete n.end,n.forEach(function(t){i[0>t?~t:t]=1}),s.push(n)}}var i={},a={},o={},s=[],l=-1;return e.forEach(function(r,n){ var i,a=t.arcs[0>r?~r:r];a.length<3&&!a[1][0]&&!a[1][1]&&(i=e[++l],e[l]=r,e[n]=i)}),e.forEach(function(t){var e,n,i=r(t),s=i[0],l=i[1];if(e=o[s])if(delete o[e.end],e.push(t),e.end=l,n=a[l]){delete a[n.start];var c=n===e?e:e.concat(n);a[c.start=e.start]=o[c.end=n.end]=c}else a[e.start]=o[e.end]=e;else if(e=a[l])if(delete a[e.start],e.unshift(t),e.start=s,n=o[s]){delete o[n.end];var u=n===e?e:n.concat(e);a[u.start=n.start]=o[u.end=e.end]=u}else a[e.start]=o[e.end]=e;else e=[t],a[e.start=s]=o[e.end=l]=e}),n(o,a),n(a,o),e.forEach(function(t){i[0>t?~t:t]||s.push([t])}),s}function u(t){return l(t,f.apply(this,arguments))}function f(t,e,r){function n(t){var e=0>t?~t:t;(u[e]||(u[e]=[])).push({i:t,g:l})}function i(t){t.forEach(n)}function a(t){t.forEach(i)}function o(t){"GeometryCollection"===t.type?t.geometries.forEach(o):t.type in f&&(l=t,f[t.type](t.arcs))}var s=[];if(arguments.length>1){var l,u=[],f={LineString:i,MultiLineString:a,Polygon:a,MultiPolygon:function(t){t.forEach(a)}};o(e),u.forEach(arguments.length<3?function(t){s.push(t[0].i)}:function(t){r(t[0].g,t[t.length-1].g)&&s.push(t[0].i)})}else for(var h=0,d=t.arcs.length;d>h;++h)s.push(h);return{type:"MultiLineString",arcs:c(t,s)}}function h(t){var e=t[0],r=t[1],n=t[2];return Math.abs((e[0]-n[0])*(r[1]-e[1])-(e[0]-r[0])*(n[1]-e[1]))}function d(t){for(var e,r=-1,n=t.length,i=t[n-1],a=0;++re?~e:e]||(i[e]=[])).push(t)})}),a.push(t)}function n(e){return d(l(t,{type:"Polygon",arcs:[e]}).coordinates[0])>0}var i={},a=[],o=[];return e.forEach(function(t){"Polygon"===t.type?r(t.arcs):"MultiPolygon"===t.type&&t.arcs.forEach(r)}),a.forEach(function(t){if(!t._){var e=[],r=[t];for(t._=1,o.push(e);t=r.pop();)e.push(t),t.forEach(function(t){t.forEach(function(t){i[0>t?~t:t].forEach(function(t){t._||(t._=1,r.push(t))})})})}}),a.forEach(function(t){delete t._}),{type:"MultiPolygon",arcs:o.map(function(e){var r,a=[];if(e.forEach(function(t){t.forEach(function(t){t.forEach(function(t){i[0>t?~t:t].length<2&&a.push(t)})})}),a=c(t,a),(r=a.length)>1)for(var o,s=n(e[0][0]),l=0;r>l;++l)if(s===n(a[l])){o=a[0],a[0]=a[l],a[l]=o;break}return a})}}function v(t){function e(t,e){t.forEach(function(t){0>t&&(t=~t);var r=i[t];r?r.push(e):i[t]=[e]})}function r(t,r){t.forEach(function(t){e(t,r)})}function n(t,e){"GeometryCollection"===t.type?t.geometries.forEach(function(t){n(t,e)}):t.type in s&&s[t.type](t.arcs,e)}var i={},o=t.map(function(){return[]}),s={LineString:e,MultiLineString:r,Polygon:r,MultiPolygon:function(t,e){t.forEach(function(t){r(t,e)})}};t.forEach(n);for(var l in i)for(var c=i[l],u=c.length,f=0;u>f;++f)for(var h=f+1;u>h;++h){var d,p=c[f],g=c[h];(d=o[p])[l=a(d,g)]!==g&&d.splice(l,0,g),(d=o[g])[l=a(d,p)]!==p&&d.splice(l,0,p)}return o}function m(t,e){return t[1][2]-e[1][2]}function y(){function t(t,e){for(;e>0;){var r=(e+1>>1)-1,i=n[r];if(m(t,i)>=0)break;n[i._=e]=i,n[t._=e=r]=t}}function e(t,e){for(;;){var r=e+1<<1,a=r-1,o=e,s=n[o];if(i>a&&m(n[a],s)<0&&(s=n[o=a]),i>r&&m(n[r],s)<0&&(s=n[o=r]),o===e)break;n[s._=e]=s,n[t._=e=o]=t}}var r={},n=[],i=0;return r.push=function(e){return t(n[e._=i]=e,i++),i},r.pop=function(){if(!(0>=i)){var t,r=n[0];return--i>0&&(t=n[i],e(n[t._=0]=t,0)),r}},r.remove=function(r){var a,o=r._;if(n[o]===r)return o!==--i&&(a=n[i],(m(a,r)<0?t:e)(n[a._=o]=a,o)),o},r}function b(t,e){function i(t){s.remove(t),t[1][2]=e(t),s.push(t)}var a=r(t.transform),o=n(t.transform),s=y();return e||(e=h),t.arcs.forEach(function(t){var r,n,l,c,u=[],f=0;for(n=0,l=t.length;l>n;++n)c=t[n],a(t[n]=[c[0],c[1],1/0],n);for(n=1,l=t.length-1;l>n;++n)r=t.slice(n-1,n+2),r[1][2]=e(r),u.push(r),s.push(r);for(n=0,l=u.length;l>n;++n)r=u[n],r.previous=u[n-1],r.next=u[n+1];for(;r=s.pop();){var h=r.previous,d=r.next;r[1][2]0?r.pop():new ArrayBuffer(t)}function s(t){return new Uint8Array(o(t),0,t)}function l(t){return new Uint16Array(o(2*t),0,t)}function c(t){return new Uint32Array(o(4*t),0,t)}function u(t){return new Int8Array(o(t),0,t)}function f(t){return new Int16Array(o(2*t),0,t)}function h(t){return new Int32Array(o(4*t),0,t)}function d(t){return new Float32Array(o(4*t),0,t)}function p(t){return new Float64Array(o(8*t),0,t)}function g(t){return x?new Uint8ClampedArray(o(t),0,t):s(t)}function v(t){return new DataView(o(t),0,t)}function m(t){t=y.nextPow2(t);var e=y.log2(t),r=k[e];return r.length>0?r.pop():new n(t)}var y=t("bit-twiddle"),b=t("dup");e.__TYPEDARRAY_POOL||(e.__TYPEDARRAY_POOL={UINT8:b([32,0]),UINT16:b([32,0]),UINT32:b([32,0]),INT8:b([32,0]),INT16:b([32,0]),INT32:b([32,0]),FLOAT:b([32,0]),DOUBLE:b([32,0]),DATA:b([32,0]),UINT8C:b([32,0]),BUFFER:b([32,0])});var x="undefined"!=typeof Uint8ClampedArray,_=e.__TYPEDARRAY_POOL;_.UINT8C||(_.UINT8C=b([32,0])),_.BUFFER||(_.BUFFER=b([32,0]));var w=_.DATA,k=_.BUFFER;r.free=function(t){if(n.isBuffer(t))k[y.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|y.log2(e);w[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=a,r.freeArrayBuffer=i,r.freeBuffer=function(t){k[y.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return o(t);switch(e){case"uint8":return s(t);case"uint16":return l(t);case"uint32":return c(t);case"int8":return u(t);case"int16":return f(t);case"int32":return h(t);case"float":case"float32":return d(t);case"double":case"float64":return p(t);case"uint8_clamped":return g(t);case"buffer":return m(t);case"data":case"dataview":return v(t);default:return null}return null},r.mallocArrayBuffer=o,r.mallocUint8=s,r.mallocUint16=l,r.mallocUint32=c,r.mallocInt8=u,r.mallocInt16=f,r.mallocInt32=h,r.mallocFloat32=r.mallocFloat=d,r.mallocFloat64=r.mallocDouble=p,r.mallocUint8Clamped=g,r.mallocDataView=v,r.mallocBuffer=m,r.clearCache=function(){for(var t=0;32>t;++t)_.UINT8[t].length=0,_.UINT16[t].length=0,_.UINT32[t].length=0,_.INT8[t].length=0,_.INT16[t].length=0,_.INT32[t].length=0,_.FLOAT[t].length=0,_.DOUBLE[t].length=0,_.UINT8C[t].length=0,w[t].length=0,k[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":50,buffer:51,dup:115}],279:[function(t,e,r){"use strict";function n(t,e){for(var r=1,n=t.length,i=t[0],a=t[0],o=1;n>o;++o)if(a=i,i=t[o],e(i,a)){if(o===r){r++;continue}t[r++]=i}return t.length=r,t}function i(t){for(var e=1,r=t.length,n=t[0],i=t[0],a=1;r>a;++a,i=n)if(i=n,n=t[a],n!==i){if(a===e){e++;continue}t[e++]=n}return t.length=e,t}function a(t,e,r){return 0===t.length?t:e?(r||t.sort(e),n(t,e)):(r||t.sort(),i(t))}e.exports=a},{}],280:[function(t,e,r){"use strict";function n(t,e){return"object"==typeof e&&null!==e||(e={}),i(t,e.canvas||a,e.context||o,e)}e.exports=n;var i=t("./lib/vtext"),a=null,o=null;"undefined"!=typeof document&&(a=document.createElement("canvas"),a.width=8192,a.height=1024,o=a.getContext("2d"))},{"./lib/vtext":281}],281:[function(t,e,r){"use strict";function n(t,e,r){for(var n=e.textAlign||"start",i=e.textBaseline||"alphabetic",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;s>l;++l)for(var c=t[l],u=0;2>u;++u)a[u]=0|Math.min(a[u],c[u]),o[u]=0|Math.max(o[u],c[u]);var f=0;switch(n){case"center":f=-.5*(a[0]+o[0]);break;case"right":case"end":f=-o[0];break;case"left":case"start":f=-a[0];break;default:throw new Error("vectorize-text: Unrecognized textAlign: '"+n+"'")}var h=0;switch(i){case"hanging":case"top":h=-a[1];break;case"middle":h=-.5*(a[1]+o[1]);break;case"alphabetic":case"ideographic":h=-3*r;break;case"bottom":h=-o[1];break;default:throw new Error("vectorize-text: Unrecoginized textBaseline: '"+i+"'")}var d=1/r;return"lineHeight"in e?d*=+e.lineHeight:"width"in e?d=e.width/(o[0]-a[0]):"height"in e&&(d=e.height/(o[1]-a[1])),t.map(function(t){return[d*(t[0]+f),d*(t[1]+h)]})}function i(t,e,r,n){var i=0|Math.ceil(e.measureText(r).width+2*n);if(i>8192)throw new Error("vectorize-text: String too long (sorry, this will get fixed later)");var a=3*n;t.height=l&&o.push(s)}for(;o.length>0;){var c=o.pop();n[c]=!1;for(var u=r[c],s=0;sn;++n){var a=t[n];e=Math.max(e,a[0],a[1])}e=(0|e)+1}e=0|e;for(var o=new Array(e),n=0;e>n;++n)o[n]=[];for(var n=0;r>n;++n){var a=t[n];o[a[0]].push(a[1]),o[a[1]].push(a[0])}for(var s=0;e>s;++s)i(o[s],function(t,e){return t-e});return o}e.exports=n;var i=t("uniq")},{uniq:279}],284:[function(t,e,r){"use strict";function n(t,e){function r(t,e){var r=c[e][t[e]];r.splice(r.indexOf(t),1)}function n(t,n,a){for(var o,s,l,u=0;2>u;++u)if(c[u][n].length>0){o=c[u][n][0],l=u;break}s=o[1^l];for(var f=0;2>f;++f)for(var h=c[f][n],d=0;d0&&(o=p,s=g,l=f)}return a?s:(o&&r(o,l),s)}function a(t,a){var o=c[a][t][0],s=[t];r(o,a);for(var l=o[1^a];;){for(;l!==t;)s.push(l),l=n(s[s.length-2],l,!1);if(c[0][t].length+c[1][t].length===0)break;var u=s[s.length-1],f=t,h=s[1],d=n(u,f,!0);if(i(e[u],e[f],e[h],e[d])<0)break;s.push(t),l=n(u,f)}return s}function o(t,e){return e[1]===e[e.length-1]}for(var s=0|e.length,l=t.length,c=[new Array(s),new Array(s)],u=0;s>u;++u)c[0][u]=[],c[1][u]=[];for(var u=0;l>u;++u){var f=t[u];c[0][f[0]].push(f),c[1][f[1]].push(f)}for(var h=[],u=0;s>u;++u)c[0][u].length+c[1][u].length===0&&h.push([u]);for(var u=0;s>u;++u)for(var d=0;2>d;++d){for(var p=[];c[d][u].length>0;){var g=(c[0][u].length,a(u,d));o(p,g)?p.push.apply(p,g):(p.length>0&&h.push(p),p=g)}p.length>0&&h.push(p)}return h}e.exports=n;var i=t("compare-angle")},{"compare-angle":285}],285:[function(t,e,r){"use strict";function n(t,e,r){var n=s(t[0],-e[0]),i=s(t[1],-e[1]),a=s(r[0],-e[0]),o=s(r[1],-e[1]),u=c(l(n,a),l(i,o));return u[u.length-1]>=0}function i(t,e,r,i){var s=a(e,r,i);if(0===s){var l=o(a(t,e,r)),c=o(a(t,e,i));if(l===c){if(0===l){var u=n(t,e,r),f=n(t,e,i);return u===f?0:u?1:-1}return 0}return 0===c?l>0?-1:n(t,e,i)?-1:1:0===l?c>0?1:n(t,e,r)?1:-1:o(c-l)}var h=a(t,e,r);if(h>0)return s>0&&a(t,e,i)>0?1:-1;if(0>h)return s>0||a(t,e,i)>0?1:-1;var d=a(t,e,i);return d>0?1:n(t,e,r)?1:-1}e.exports=i;var a=t("robust-orientation"),o=t("signum"),s=t("two-sum"),l=t("robust-product"),c=t("robust-sum")},{"robust-orientation":259,"robust-product":286,"robust-sum":262,signum:287,"two-sum":277}],286:[function(t,e,r){"use strict";function n(t,e){if(1===t.length)return a(e,t[0]);if(1===e.length)return a(t,e[0]);if(0===t.length||0===e.length)return[0];var r=[0];if(t.lengtht?-1:t>0?1:0}},{}],288:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],289:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}function i(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function a(t,e){var r=p(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function o(t,e){var r=t.intervals([]);r.push(e),a(t,r)}function s(t,e){var r=t.intervals([]),n=r.indexOf(e);return 0>n?y:(r.splice(n,1),a(t,r),b)}function l(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function u(t,e){for(var r=0;r>1],a=[],o=[],s=[],r=0;r3*(e+1)?o(this,t):this.left.insert(t):this.left=p([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?o(this,t):this.right.insert(t):this.right=p([t]);else{var r=m.ge(this.leftPoints,t,h),n=m.ge(this.rightPoints,t,d);this.leftPoints.splice(r,0,t),this.rightPoints.splice(n,0,t)}},_.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1))return s(this,t);var n=this.left.remove(t);return n===x?(this.left=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(t[0]>this.mid){if(!this.right)return y;var a=this.left?this.left.count:0;if(4*a>3*(e-1))return s(this,t);var n=this.right.remove(t);return n===x?(this.right=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(1===this.count)return this.leftPoints[0]===t?x:y;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var o=this,l=this.left;l.right;)o=l,l=l.right;if(o===this)l.right=this.right;else{var c=this.left,n=this.right;o.count-=l.count,o.right=l.left,l.left=c,l.right=n}i(this,l),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?i(this,this.left):i(this,this.right);return b}for(var c=m.ge(this.leftPoints,t,h);cthis.mid){if(this.right){var r=this.right.queryPoint(t,e);if(r)return r}return c(this.rightPoints,t,e)}return u(this.leftPoints,e)},_.queryInterval=function(t,e,r){if(tthis.mid&&this.right){var n=this.right.queryInterval(t,e,r);if(n)return n}return ethis.mid?c(this.rightPoints,t,r):u(this.leftPoints,r)};var w=g.prototype;w.insert=function(t){this.root?this.root.insert(t):this.root=new n(t[0],null,null,[t],[t])},w.remove=function(t){if(this.root){var e=this.root.remove(t);return e===x&&(this.root=null),e!==y}return!1},w.queryPoint=function(t,e){return this.root?this.root.queryPoint(t,e):void 0},w.queryInterval=function(t,e,r){return e>=t&&this.root?this.root.queryInterval(t,e,r):void 0},Object.defineProperty(w,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(w,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":288}],290:[function(t,e,r){"use strict";function n(t,e){var r,n;if(e[0][0]e[1][0])){var i=Math.min(t[0][1],t[1][1]),o=Math.max(t[0][1],t[1][1]),s=Math.min(e[0][1],e[1][1]),l=Math.max(e[0][1],e[1][1]);return s>o?o-s:i>l?i-l:o-l}r=e[1],n=e[0]}var c,u;t[0][1]e[1][0]))return n(e,t);r=e[1],i=e[0]}var o,s;if(t[0][0]t[1][0]))return-n(t,e);o=t[1],s=t[0]}var l=a(r,i,s),c=a(r,i,o);if(0>l){if(0>=c)return l}else if(l>0){if(c>=0)return l}else if(c)return c;if(l=a(s,o,i),c=a(s,o,r),0>l){if(0>=c)return l}else if(l>0){if(c>=0)return l}else if(c)return c;return i[0]-s[0]}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":259}],291:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function i(t){return new n(t._color,t.key,t.value,t.left,t.right,t._count)}function a(t,e){return new n(t,e.key,e.value,e.left,e.right,e._count)}function o(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function s(t,e){this._compare=t,this.root=e}function l(t,e){if(e.left){var r=l(t,e.left);if(r)return r}var r=t(e.key,e.value);return r?r:e.right?l(t,e.right):void 0}function c(t,e,r,n){var i=e(t,n.key);if(0>=i){if(n.left){var a=c(t,e,r,n.left);if(a)return a}var a=r(n.key,n.value);if(a)return a}return n.right?c(t,e,r,n.right):void 0}function u(t,e,r,n,i){var a,o=r(t,i.key),s=r(e,i.key);if(0>=o){if(i.left&&(a=u(t,e,r,n,i.left)))return a;if(s>0&&(a=n(i.key,i.value)))return a}return s>0&&i.right?u(t,e,r,n,i.right):void 0}function f(t,e){this.tree=t,this._stack=e}function h(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function d(t){for(var e,r,n,s,l=t.length-1;l>=0;--l){if(e=t[l],0===l)return void(e._color=m);if(r=t[l-1],r.left===e){if(n=r.right,n.right&&n.right._color===v){if(n=r.right=i(n),s=n.right=i(n.right),r.right=n.left,n.left=r,n.right=s,n._color=r._color,e._color=m,r._color=m,s._color=m,o(r),o(n),l>1){var c=t[l-2];c.left===r?c.left=n:c.right=n}return void(t[l-1]=n)}if(n.left&&n.left._color===v){if(n=r.right=i(n),s=n.left=i(n.left),r.right=s.left,n.left=s.right,s.left=r,s.right=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var c=t[l-2];c.left===r?c.left=s:c.right=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.right=a(v,n));r.right=a(v,n);continue}if(n=i(n),r.right=n.left,n.left=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var c=t[l-2];c.left===r?c.left=n:c.right=n}t[l-1]=n,t[l]=r,l+11){var c=t[l-2];c.right===r?c.right=n:c.left=n}return void(t[l-1]=n)}if(n.right&&n.right._color===v){if(n=r.left=i(n),s=n.right=i(n.right),r.left=s.right,n.right=s.left,s.right=r,s.left=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var c=t[l-2];c.right===r?c.right=s:c.left=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.left=a(v,n));r.left=a(v,n);continue}if(n=i(n),r.left=n.right,n.right=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var c=t[l-2];c.right===r?c.right=n:c.left=n}t[l-1]=n,t[l]=r,l+1t?-1:t>e?1:0}function g(t){return new s(t||p,null)}e.exports=g;var v=0,m=1,y=s.prototype;Object.defineProperty(y,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(y,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(y,"length",{get:function(){return this.root?this.root._count:0}}),y.insert=function(t,e){for(var r=this._compare,i=this.root,l=[],c=[];i;){var u=r(t,i.key);l.push(i),c.push(u),i=0>=u?i.left:i.right}l.push(new n(v,t,e,null,null,1));for(var f=l.length-2;f>=0;--f){var i=l[f];c[f]<=0?l[f]=new n(i._color,i.key,i.value,l[f+1],i.right,i._count+1):l[f]=new n(i._color,i.key,i.value,i.left,l[f+1],i._count+1)}for(var f=l.length-1;f>1;--f){var h=l[f-1],i=l[f];if(h._color===m||i._color===m)break;var d=l[f-2];if(d.left===h)if(h.left===i){var p=d.right;if(!p||p._color!==v){if(d._color=v,d.left=h.right,h._color=m,h.right=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.left===d?g.left=h:g.right=h}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else{var p=d.right;if(!p||p._color!==v){if(h.right=i.left,d._color=v,d.left=i.right,i._color=m,i.left=h,i.right=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.left===d?g.left=i:g.right=i}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else if(h.right===i){var p=d.left;if(!p||p._color!==v){if(d._color=v,d.right=h.left,h._color=m,h.left=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.right===d?g.right=h:g.left=h}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}else{var p=d.left;if(!p||p._color!==v){if(h.left=i.right,d._color=v,d.right=i.left,i._color=m,i.right=h,i.left=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.right===d?g.right=i:g.left=i}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}}return l[0]._color=m,new s(r,l[0])},y.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return l(t,this.root);case 2:return c(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return u(e,r,this._compare,t,this.root)}},Object.defineProperty(y,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(y,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),y.at=function(t){if(0>t)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},y.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>=a&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>a&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new f(this,n);r=0>=i?r.left:r.right}return new f(this,[])},y.remove=function(t){var e=this.find(t);return e?e.remove():this},y.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=0>=n?r.left:r.right}};var b=f.prototype;Object.defineProperty(b,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(b,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),b.clone=function(){return new f(this.tree,this._stack.slice())},b.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new n(r._color,r.key,r.value,r.left,r.right,r._count);for(var i=t.length-2;i>=0;--i){var r=t[i];r.left===t[i+1]?e[i]=new n(r._color,r.key,r.value,e[i+1],r.right,r._count):e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count)}if(r=e[e.length-1],r.left&&r.right){var a=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var o=e[a-1];e.push(new n(r._color,o.key,o.value,r.left,r.right,r._count)),e[a-1].key=r.key,e[a-1].value=r.value;for(var i=e.length-2;i>=a;--i)r=e[i],e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count);e[a-1].left=e[a]}if(r=e[e.length-1],r._color===v){var l=e[e.length-2];l.left===r?l.left=null:l.right===r&&(l.right=null),e.pop();for(var i=0;i0?this._stack[this._stack.length-1].key:void 0},enumerable:!0}),Object.defineProperty(b,"value",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1].value:void 0},enumerable:!0}),Object.defineProperty(b,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),b.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),b.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),i=e[e.length-1];r[r.length-1]=new n(i._color,i.key,t,i.left,i.right,i._count);for(var a=e.length-2;a>=0;--a)i=e[a],i.left===e[a+1]?r[a]=new n(i._color,i.key,i.value,r[a+1],i.right,i._count):r[a]=new n(i._color,i.key,i.value,i.left,r[a+1],i._count);return new s(this.tree._compare,r[0])},b.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],292:[function(t,e,r){"use strict";function n(t,e,r){this.slabs=t,this.coordinates=e,this.horizontal=r}function i(t,e){return t.y-e}function a(t,e){for(var r=null;t;){var n,i,o=t.key;o[0][0]s)t=t.left;else if(s>0)if(e[0]!==o[1][0])r=t,t=t.right;else{var l=a(t.right,e);if(l)return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l=a(t.right,e);if(l)return l;t=t.left}}return r}function o(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function s(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}function l(t){for(var e=t.length,r=2*e,i=new Array(r),a=0;e>a;++a){var l=t[a],c=l[0][0]a;){for(var v=i[a].x,m=[];r>a;){var y=i[a];if(y.x!==v)break;a+=1,y.segment[0][0]===y.x&&y.segment[1][0]===y.x?y.create&&(y.segment[0][1]e)return-1;var r=(this.slabs[e],a(this.slabs[e],t)),n=-1;if(r&&(n=r.value),this.coordinates[e]===t[0]){var o=null;if(r&&(o=r.key),e>0){var s=a(this.slabs[e-1],t);s&&(o?h(s.key,o)>0&&(o=s.key,n=s.value):(n=s.value,o=s.key))}var l=this.horizontal[e];if(l.length>0){var u=c.ge(l,t[1],i);if(u=l.length)return n;d=l[u]}}if(d.start)if(o){var p=f(o[0],o[1],[t[0],d.y]);o[0][0]>o[1][0]&&(p=-p),p>0&&(n=d.index)}else n=d.index;else d.y!==t[1]&&(n=d.index)}}}return n}},{"./lib/order-segments":290,"binary-search-bounds":288,"functional-red-black-tree":291,"robust-orientation":259}],293:[function(t,e,r){function n(){return!0}function i(t){return function(e,r){var i=t[e];return i?!!i.queryPoint(r,n):!1}}function a(t){for(var e={},r=0;rn)return 1;var i=t[n];if(!i){if(!(n>0&&e[n]===r[0]))return 1;i=t[n-1]}for(var a=1;i;){var o=i.key,s=f(r,o[0],o[1]);if(o[0][0]s)i=i.left;else{if(!(s>0))return 0;a=-1,i=i.right}else if(s>0)i=i.left;else{if(!(0>s))return 0;a=1,i=i.right}}return a}}function s(t){return 1}function l(t){return function(e){return t(e[0],e[1])?0:1}}function c(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}function u(t){for(var e=t.length,r=[],n=[],i=0;e>i;++i)for(var u=t[i],f=u.length,d=f-1,p=0;f>p;d=p++){var g=u[d],v=u[p];g[0]===v[0]?n.push([g,v]):r.push([g,v]); -}if(0===r.length)return 0===n.length?s:l(a(n));var m=h(r),y=o(m.slabs,m.coordinates);return 0===n.length?y:c(a(n),y)}e.exports=u;var f=t("robust-orientation")[3],h=t("slab-decomposition"),d=t("interval-tree-1d"),p=t("binary-search-bounds")},{"binary-search-bounds":288,"interval-tree-1d":289,"robust-orientation":259,"slab-decomposition":292}],294:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function i(t){for(var e=new Array(t),r=0;t>r;++r)e[r]=[];return e}function a(t,e){function r(t){for(var r=t.length,n=[0],i=0;r>i;++i){var a=e[t[i]],o=e[t[(i+1)%r]],s=c(-a[0],a[1]),l=c(-a[0],o[1]),f=c(o[0],a[1]),h=c(o[0],o[1]);n=u(n,u(u(s,l),u(f,h)))}return n[n.length-1]>0}function a(t){for(var e=t.length,r=0;e>r;++r)if(!O[t[r]])return!1;return!0}var d=h(t,e);t=d[0],e=d[1];for(var p=e.length,g=(t.length,o(t,e.length)),v=0;p>v;++v)if(g[v].length%2===1)throw new Error("planar-graph-to-polyline: graph must be manifold");var m=s(t,e);m=m.filter(r);for(var y=m.length,b=new Array(y),x=new Array(y),v=0;y>v;++v){b[v]=v;var _=new Array(y),w=m[v].map(function(t){return e[t]}),k=l([w]),A=0;t:for(var M=0;y>M;++M)if(_[M]=0,v!==M){for(var T=m[M],E=T.length,L=0;E>L;++L){var S=k(e[T[L]]);if(0!==S){0>S&&(_[M]=1,A+=1);continue t}}_[M]=1,A+=1}x[v]=[A,v,_]}x.sort(function(t,e){return e[0]-t[0]});for(var v=0;y>v;++v)for(var _=x[v],C=_[1],z=_[2],M=0;y>M;++M)z[M]&&(b[M]=C);for(var P=i(y),v=0;y>v;++v)P[v].push(b[v]),P[b[v]].push(v);for(var R={},O=n(p,!1),v=0;y>v;++v)for(var T=m[v],E=T.length,M=0;E>M;++M){var I=T[M],N=T[(M+1)%E],j=Math.min(I,N)+":"+Math.max(I,N);if(j in R){var F=R[j];P[F].push(v),P[v].push(F),O[I]=O[N]=!0}else R[j]=v}for(var D=[],B=n(y,-1),v=0;y>v;++v)b[v]!==v||a(m[v])?B[v]=-1:(D.push(v),B[v]=0);for(var d=[];D.length>0;){var U=D.pop(),V=P[U];f(V,function(t,e){return t-e});var q,H=V.length,G=B[U];if(0===G){var T=m[U];q=[T]}for(var v=0;H>v;++v){var Y=V[v];if(!(B[Y]>=0)&&(B[Y]=1^G,D.push(Y),0===G)){var T=m[Y];a(T)||(T.reverse(),q.push(T))}}0===G&&d.push(q)}return d}e.exports=a;var o=t("edges-to-adjacency-list"),s=t("planar-dual"),l=t("point-in-big-polygon"),c=t("two-product"),u=t("robust-sum"),f=t("uniq"),h=t("./lib/trim-leaves")},{"./lib/trim-leaves":282,"edges-to-adjacency-list":283,"planar-dual":284,"point-in-big-polygon":293,"robust-sum":262,"two-product":276,uniq:279}],295:[function(t,e,r){arguments[4][50][0].apply(r,arguments)},{dup:50}],296:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;t>e;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n,n.prototype.length=function(){return this.roots.length},n.prototype.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},n.prototype.find=function(t){for(var e=this.roots;e[t]!==t;){var r=e[t];e[t]=e[r],t=r}return t},n.prototype.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],297:[function(t,e,r){arguments[4][238][0].apply(r,arguments)},{"bit-twiddle":295,dup:238,"union-find":296}],298:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.abs(a(t,e,r)),i=Math.sqrt(Math.pow(e[0]-r[0],2)+Math.pow(e[1]-r[1],2));return n/i}function i(t,e,r){function i(t){if(x[t])return 1/0;var r=m[t],i=y[t];return 0>r||0>i?1/0:n(e[t],e[r],e[i])}function a(t,e){var r=M[t],n=M[e];M[t]=n,M[e]=r,T[r]=e,T[n]=t}function s(t){return b[M[t]]}function l(t){return 1&t?t-1>>1:(t>>1)-1}function c(t){for(var e=s(t);;){var r=e,n=2*t+1,i=2*(t+1),o=t;if(L>n){var l=s(n);r>l&&(o=n,r=l)}if(L>i){var c=s(i);r>c&&(o=i)}if(o===t)return t;a(t,o),t=o}}function u(t){for(var e=s(t);t>0;){var r=l(t);if(r>=0){var n=s(r);if(n>e){a(t,r),t=r;continue}}return t}}function f(){if(L>0){var t=M[0];return a(0,L-1),L-=1,c(0),t}return-1}function h(t,e){var r=M[t];return b[r]===e?t:(b[r]=-(1/0),u(t),f(),b[r]=e,L+=1,u(L-1))}function d(t){if(!x[t]){x[t]=!0;var e=m[t],r=y[t];m[r]>=0&&(m[r]=e),y[e]>=0&&(y[e]=r),T[e]>=0&&h(T[e],i(e)),T[r]>=0&&h(T[r],i(r))}}function p(t,e){if(t[e]<0)return e;var r=e,n=e;do{var i=t[n];if(!x[n]||0>i||i===n)break;if(n=i,i=t[n],!x[n]||0>i||i===n)break;n=i,r=t[r]}while(r!==n);for(var a=e;a!==n;a=t[a])t[a]=n;return n}for(var g=e.length,v=t.length,m=new Array(g),y=new Array(g),b=new Array(g),x=new Array(g),_=0;g>_;++_)m[_]=y[_]=-1,b[_]=1/0,x[_]=!1;for(var _=0;v>_;++_){var w=t[_];if(2!==w.length)throw new Error("Input must be a graph");var k=w[1],A=w[0];-1!==y[A]?y[A]=-2:y[A]=k,-1!==m[k]?m[k]=-2:m[k]=A}for(var M=[],T=new Array(g),_=0;g>_;++_){var E=b[_]=i(_);1/0>E?(T[_]=M.length,M.push(_)):T[_]=-1}for(var L=M.length,_=L>>1;_>=0;--_)c(_);for(;;){var S=f();if(0>S||b[S]>r)break;d(S)}for(var C=[],_=0;g>_;++_)x[_]||(T[_]=C.length,C.push(e[_].slice()));var z=(C.length,[]);return t.forEach(function(t){var e=p(m,t[0]),r=p(y,t[1]);if(e>=0&&r>=0&&e!==r){var n=T[e],i=T[r];n!==i&&z.push([n,i])}}),o.unique(o.normalize(z)),{positions:C,edges:z}}e.exports=i;var a=t("robust-orientation"),o=t("simplicial-complex")},{"robust-orientation":259,"simplicial-complex":297}],299:[function(t,e,r){"use strict";e.exports=["",{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],300:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:o({},i,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":377,"../../plots/cartesian/constants":410,"../../plots/font_attributes":423,"./arrow_paths":299}],301:[function(t,e,r){"use strict";function n(t,e){function r(e,r){return c.coerce(t,n,v.layoutAttributes,e,r)}var n={};r("opacity"),r("align"),r("bgcolor");var i=r("bordercolor"),a=f.opacity(i);r("borderpad");var o=r("borderwidth"),s=r("showarrow");s&&(r("arrowcolor",a?n.bordercolor:f.defaultLine),r("arrowhead"),r("arrowsize"),r("arrowwidth",2*(a&&o||1)),r("ax"),r("ay"),c.noneOrAll(t,n,["ax","ay"])),r("text",s?" ":"new text"),r("textangle"),c.coerceFont(r,"font",e.font);for(var l=["x","y"],h=0;2>h;h++){var d=l[h],p={_fullLayout:e},g=u.coerceRef(t,n,p,d),m=.5;if("paper"!==g){var y=u.getFromId(p,g);if(m=y.range[0]+m*(y.range[1]-y.range[0]),-1!==["date","category"].indexOf(y.type)&&"string"==typeof t[d]){var b;"date"===y.type?(b=c.dateTime2ms(t[d]),b!==!1&&(t[d]=b)):(y._categories||[]).length&&(b=y._categories.indexOf(t[d]),-1!==b&&(t[d]=b))}}r(d,m),s||r(d+"anchor")}return c.noneOrAll(t,n,["x","y"]),n}function i(t){var e=t._fullLayout;e.annotations.forEach(function(e){var r=u.getFromId(t,e.xref),n=u.getFromId(t,e.yref);if(r||n){var i=(e._xsize||0)/2,a=e._xshift||0,o=(e._ysize||0)/2,s=e._yshift||0,l=i-a,c=i+a,f=o-s,h=o+s;if(e.showarrow){var d=3*e.arrowsize*e.arrowwidth;l=Math.max(l,d),c=Math.max(c,d),f=Math.max(f,d),h=Math.max(h,d)}r&&r.autorange&&u.expand(r,[r.l2c(e.x)],{ppadplus:c,ppadminus:l}),n&&n.autorange&&u.expand(n,[n.l2c(e.y)],{ppadplus:h,ppadminus:f})}})}function a(t,e,r,n,i,a,o,s){var l=r-t,c=i-t,u=o-i,f=n-e,h=a-e,d=s-a,p=l*d-u*f;if(0===p)return null;var g=(c*d-u*h)/p,v=(c*f-l*h)/p;return 0>v||v>1||0>g||g>1?null:{x:t+l*g,y:e+f*g}}var o=t("d3"),s=t("fast-isnumeric"),l=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),h=t("../drawing"),d=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var r=t.annotations||[],i=e.annotations=[],a=0;at?"left":t>2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var n=W.select(".annotation-math-group"),i=!n.empty(),s=h.bBox((i?n:tt).node()),d=s.width,m=s.height,y=Math.round(d+2*$),b=Math.round(m+2*$);U._w=d,U._h=m;var x=!1;if(["x","y"].forEach(function(e){var n,i=u.getFromId(t,U[e+"ref"]||e),a=(G+("x"===e?0:90))*Math.PI/180,o=y*Math.abs(Math.cos(a))+b*Math.abs(Math.sin(a)),s=U[e+"anchor"];if(i){if(!i.autorange&&(U[e]-i.range[0])*(U[e]-i.range[1])>0)return void(x=!0);H[e]=i._offset+i.l2p(U[e]),n=.5}else n=U[e],"y"===e&&(n=1-n),H[e]="x"===e?S.l+S.w*n:S.t+S.h*n;var l=0;l=U.showarrow?U["a"+e]:o*r(n,s),H[e]+=l,U["_"+e+"type"]=i&&i.type,U["_"+e+"size"]=o,U["_"+e+"shift"]=l}),x)return void W.remove();var w,k;U.showarrow&&(w=c.constrain(H.x-U.ax,1,_.width-1),k=c.constrain(H.y-U.ay,1,_.height-1)),H.x=c.constrain(H.x,1,_.width-1),H.y=c.constrain(H.y,1,_.height-1);var A=$-s.top,M=$-s.left;i?n.select("svg").attr({x:$-1,y:$}):(tt.attr({x:M,y:A}),tt.selectAll("tspan.line").attr({y:A,x:M})),Q.call(h.setRect,Z/2,Z/2,y-Z,b-Z);var T=Math.round(H.x-y/2),E=Math.round(H.y-b/2);W.call(c.setTranslate,T,E);var L="annotations["+e+"]",C=function(r,n){o.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var i=H.x+r,s=H.y+n,u=c.rotationXYMatrix(G,i,s),h=c.apply2DTransform(u),d=c.apply2DTransform2(u),p=Q.attr("width")/2,m=Q.attr("height")/2,y=[[i-p,s-m,i-p,s+m],[i-p,s+m,i+p,s+m],[i+p,s+m,i+p,s-m],[i+p,s-m,i-p,s-m]].map(d);if(!y.reduce(function(t,e){return t^!!a(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=a(i,s,w,k,t[0],t[1],t[2],t[3]);e&&(i=e.x,s=e.y)});var b=U.arrowwidth,x=U.arrowcolor,_=Y.append("g").style({opacity:f.opacity(x)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),A=_.append("path").attr("d","M"+i+","+s+"L"+w+","+k).style("stroke-width",b+"px").call(f.stroke,f.rgb(x));v.arrowhead(A,U.arrowhead,"end",U.arrowsize);var M=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(i-w)+","+(s-k),transform:"translate("+w+","+k+")"}).style("stroke-width",b+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var T,E,C;g.init({element:M.node(),prepFn:function(){var t=c.getTranslate(W);E=t.x,C=t.y,T={},V&&V.autorange&&(T[V._name+".autorange"]=!0),q&&q.autorange&&(T[q._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var r=h(E,C),n=r[0]+t,i=r[1]+e;W.call(c.setTranslate,n,i),T[L+".x"]=V?U.x+t/V._m:(w+t-S.l)/S.w,T[L+".y"]=q?U.y+e/q._m:1-(k+e-S.t)/S.h,X.attr({transform:"rotate("+G+","+n+","+i+")"})},doneFn:function(e){if(e){l.relayout(t,T);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}};U.showarrow&&C(0,0);var z=c.rotationXYMatrix(G,H.x,H.y),P=c.apply2DTransform(z);if(t._context.editable){var R,O,I;g.init({element:W.node(),prepFn:function(){var t=c.getTranslate(W);R=t.x,O=t.y,I={}},moveFn:function(t,e){W.call(c.setTranslate,R+t,O+e);var r="pointer";if(U.showarrow)I[L+".ax"]=U.ax+t,I[L+".ay"]=U.ay+e,C(t,e);else{if(V)I[L+".x"]=U.x+t/V._m;else{var n=U._xsize/S.w,i=U.x+U._xshift/S.w-n/2;I[L+".x"]=g.align(i+t/S.w,n,0,1,U.xanchor)}if(q)I[L+".y"]=U.y+e/q._m;else{var a=U._ysize/S.h,o=U.y-U._yshift/S.h-a/2;I[L+".y"]=g.align(o-e/S.h,a,0,1,U.yanchor)}V&&q||(r=g.getCursor(V?.5:I[L+".x"],q?.5:I[L+".y"],U.xanchor,U.yanchor))}var s=P(R,O),l=s[0]+t,u=s[1]+e;W.call(c.setTranslate,R+t,O+e),X.attr({transform:"rotate("+G+","+l+","+u+")"}),p(W,r)},doneFn:function(e){if(p(W),e){l.relayout(t,I);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}var b,x=t.layout,_=t._fullLayout;if(!s(e)||-1===e){if(!e&&Array.isArray(i))return x.annotations=i,v.supplyLayoutDefaults(x,_),void v.drawAll(t);if("remove"===i)return delete x.annotations,_.annotations=[],void v.drawAll(t);if(r&&"add"!==i){for(b=0;b<_.annotations.length;b++)v.draw(t,b,r,i);return}e=_.annotations.length,_.annotations.push({})}if(!r&&i){if("remove"===i){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),x.annotations.splice(e,1),b=e;b<_.annotations.length;b++)_._infolayer.selectAll('.annotation[data-index="'+(b+1)+'"]').attr("data-index",String(b)),v.draw(t,b);return}if("add"===i||c.isPlainObject(i)){_.annotations.splice(e,0,{});var w=c.isPlainObject(i)?c.extendFlat({},i):{text:"New text"};for(x.annotations?x.annotations.splice(e,0,w):x.annotations=[w],b=_.annotations.length-1;b>e;b--)_._infolayer.selectAll('.annotation[data-index="'+(b-1)+'"]').attr("data-index",String(b)),v.draw(t,b)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=x.annotations[e],A=_.annotations[e];if(k){var M={xref:k.xref,yref:k.yref},T={};"string"==typeof r&&r?T[r]=i:c.isPlainObject(r)&&(T=r);var E=Object.keys(T);for(b=0;bb;b++){var z=C[b];if(void 0===T[z]&&void 0!==k[z]){var P=u.getFromId(t,u.coerceRef(M,{},t,z)),R=u.getFromId(t,u.coerceRef(k,{},t,z)),O=k[z],I=A["_"+z+"type"];if(void 0!==T[z+"ref"]){var N="auto"===k[z+"anchor"],j="x"===z?S.w:S.h,F=(A["_"+z+"size"]||0)/(2*j);if(P&&R)O=(O-P.range[0])/(P.range[1]-P.range[0]),O=R.range[0]+O*(R.range[1]-R.range[0]);else if(P){if(O=(O-P.range[0])/(P.range[1]-P.range[0]),O=P.domain[0]+O*(P.domain[1]-P.domain[0]),N){var D=O+F,B=O-F;2/3>O+B?O=B:O+D>4/3&&(O=D)}}else R&&(N&&(1/3>O?O+=F:O>2/3&&(O-=F)),O=(O-R.domain[0])/(R.domain[1]-R.domain[0]),O=R.range[0]+O*(R.range[1]-R.range[0]))}R&&R===P&&I&&("log"===I&&"log"!==R.type?O=Math.pow(10,O):"log"!==I&&"log"===R.type&&(O=O>0?Math.log(O)/Math.LN10:void 0)),k[z]=O}}var U=n(k,_);_.annotations[e]=U;var V=u.getFromId(t,U.xref),q=u.getFromId(t,U.yref),H={x:0,y:0},G=+U.textangle||0,Y=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",U.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:U})}),X=Y.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),W=X.append("g"),Z=U.borderwidth,K=U.borderpad,$=Z+K,Q=W.append("rect").attr("class","bg").style("stroke-width",Z+"px").call(f.stroke,U.bordercolor).call(f.fill,U.bgcolor),J=U.font,tt=W.append("text").classed("annotation",!0).attr("data-unformatted",U.text).text(U.text);t._context.editable?tt.call(d.makeEditable,W).call(m).on("edit",function(r){U.text=r,this.attr({"data-unformatted":U.text}),this.call(m);var n={};n["annotations["+e+"].text"]=U.text,V&&V.autorange&&(n[V._name+".autorange"]=!0),q&&q.autorange&&(n[q._name+".autorange"]=!0),l.relayout(t,n)}):tt.call(m),X.attr({transform:"rotate("+G+","+H.x+","+H.y+")"}).call(h.setPosition,H.x,H.y)}},v.arrowhead=function(t,e,r,n){s(n)||(n=1);var i=t.node(),a=v.ARROWPATHS[e||0];if(a){"string"==typeof r&&r||(r="end");var l,c,u,d,p=(h.getPx(t,"stroke-width")||1)*n,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=r.indexOf("start")>=0,b=r.indexOf("end")>=0,x=a.backoff*p;if("line"===i.nodeName){if(l={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(l.y-c.y,l.x-c.x),d=u+Math.PI,x){var _=x*Math.cos(u),w=x*Math.sin(u);y&&(l.x-=_,l.y-=w,t.attr({x1:l.x,y1:l.y})),b&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===i.nodeName){var k=i.getTotalLength(),A="";if(y){var M=i.getPointAtLength(0),T=i.getPointAtLength(.1);u=Math.atan2(M.y-T.y,M.x-T.x),l=i.getPointAtLength(Math.min(x,k)),x&&(A="0px,"+x+"px,")}if(b){var E=i.getPointAtLength(k),L=i.getPointAtLength(k-.1);if(d=Math.atan2(E.y-L.y,E.x-L.x),c=i.getPointAtLength(Math.max(0,k-x)),x){var S=A?2*x:x;A+=k-S+"px,"+k+"px"}}else A&&(A+=k+"px");A&&t.style("stroke-dasharray",A)}var C=function(r,n){e>5&&(n=0),o.select(i.parentElement).append("path").attr({"class":t.attr("class"),d:a.path,transform:"translate("+r.x+","+r.y+")rotate("+180*n/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(l,u),b&&C(c,d)}},v.calcAutorange=function(t){var e=t._fullLayout,r=e.annotations;if(r.length&&t._fullData.length){var n={};r.forEach(function(t){n[t.xref]=!0,n[t.yref]=!0});var a=u.list(t).filter(function(t){return t.autorange&&n[t._id]});if(a.length)return c.syncOrAsync([v.drawAll,i],t)}}},{"../../lib":382,"../../lib/setcursor":391,"../../lib/svg_text_utils":395,"../../plotly":402,"../../plots/cartesian/axes":405,"../color":303,"../dragelement":324,"../drawing":326,"./arrow_paths":299,"./attributes":300,d3:113,"fast-isnumeric":117}],302:[function(t,e,r){"use strict";r.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],r.defaultLine="#444",r.lightLine="#eee",r.background="#fff",r.lightFraction=1e3/11},{}],303:[function(t,e,r){"use strict";function n(t){if(a(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var r=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!r)return t;var n=r[1].trim().split(/\s*[\s,]\s*/),i="a"===e.charAt(3)&&4===n.length;if(!i&&3!==n.length)return t;for(var o=0;o=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}var i=t("tinycolor2"),a=t("fast-isnumeric"),o=e.exports={},s=t("./attributes");o.defaults=s.defaults,o.defaultLine=s.defaultLine,o.lightLine=s.lightLine,o.background=s.background,o.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},o.rgb=function(t){return o.tinyRGB(i(t))},o.opacity=function(t){return t?i(t).getAlpha():0},o.addOpacity=function(t,e){var r=i(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},o.combine=function(t,e){var r=i(t).toRgb();if(1===r.a)return i(t).toRgbString();var n=i(e||o.background).toRgb(),a=1===n.a?n:{r:255*(1-n.a)+n.r*n.a,g:255*(1-n.a)+n.g*n.a,b:255*(1-n.a)+n.b*n.a},s={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return i(s).toRgbString()},o.stroke=function(t,e){var r=i(e);t.style({stroke:o.tinyRGB(r),"stroke-opacity":r.getAlpha()})},o.fill=function(t,e){var r=i(e);t.style({fill:o.tinyRGB(r),"fill-opacity":r.getAlpha()})},o.clean=function(t){if(t&&"object"==typeof t){var e,r,i,a,s=Object.keys(t);for(e=0;el&&(a[1]-=(ot-l)/2)):r.node()&&!r.classed("js-placeholder")&&(ot=h.bBox(e.node()).height),ot){if(ot+=5,"top"===x.titleside)Q.domain[1]-=ot/M.h,a[1]*=-1;else{Q.domain[0]+=ot/M.h;var u=Math.max(1,r.selectAll("tspan.line").size());a[1]+=(1-u)*l}e.attr("transform","translate("+a+")"),Q.setScale()}}it.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(M.h*(1-Q.domain[1]))+")");var f=it.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var r=[0===e?E[0]:(S[e]+S[e-1])/2,e===S.length-1?E[1]:(S[e]+S[e+1])/2].map(Q.c2p).map(Math.round);e!==S.length-1&&(r[1]+=r[1]>r[0]?1:-1);var a=z(t).replace("e-",""),o=i(a).toHexString();n.select(this).attr({x:Y,width:Math.max(D,2),y:n.min(r),height:Math.max(n.max(r)-n.min(r),2),fill:o})});var d=it.select(".cblines").selectAll("path.cbline").data(x.line.color&&x.line.width?L:[]);return d.enter().append("path").classed("cbline",!0),d.exit().remove(),d.each(function(t){n.select(this).attr("d","M"+Y+","+(Math.round(Q.c2p(t))+x.line.width/2%1)+"h"+D).call(h.lineGroupStyle,x.line.width,C(t),x.line.dash)}),Q._axislayer.selectAll("g."+Q._id+"tick,path").remove(),Q._pos=Y+D+(x.outlinewidth||0)/2-("outside"===x.ticks?1:0),Q.side="right",c.syncOrAsync([function(){return s.doTicks(t,Q,!0)},function(){if(-1===["top","bottom"].indexOf(x.titleside)){var e=Q.titlefont.size,r=Q._offset+Q._length/2,i=M.l+(Q.position||0)*M.w+("right"===Q.side?10+e*(Q.showticklabels?1:.5):-10-e*(Q.showticklabels?.5:0));w("h"+Q._id+"title",{avoid:{selection:n.select(t).selectAll("g."+Q._id+"tick"),side:x.titleside,offsetLeft:M.l,offsetTop:M.t,maxShift:A.width},attributes:{x:i,y:r,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,r){var n,i=b();n=o.traceIs(i,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var a={propContainer:Q,propName:n,traceIndex:i.index,dfltName:"colorscale",containerGroup:it.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;it.selectAll("."+s+",."+s+"-math-group").remove(),p.draw(t,e,u(a,r||{}))}function k(){var r=D+x.outlinewidth/2+h.bBox(Q._axislayer.node()).width;if(N=at.select("text"),N.node()&&!N.classed("js-placeholder")){var n,i=at.select(".h"+Q._id+"title-math-group").node();n=i&&-1!==["top","bottom"].indexOf(x.titleside)?h.bBox(i).width:h.bBox(at.node()).right-Y-M.l,r=Math.max(r,n)}var a=2*x.xpad+r+x.borderwidth+x.outlinewidth/2,s=Z-K;it.select(".cbbg").attr({x:Y-x.xpad-(x.borderwidth+x.outlinewidth)/2,y:K-H,width:Math.max(a,2),height:Math.max(s+2*H,2)}).call(d.fill,x.bgcolor).call(d.stroke,x.bordercolor).style({"stroke-width":x.borderwidth}),it.selectAll(".cboutline").attr({x:Y,y:K+x.ypad+("top"===x.titleside?ot:0),width:Math.max(D,2),height:Math.max(s-2*x.ypad-ot,2)}).call(d.stroke,x.outlinecolor).style({fill:"None","stroke-width":x.outlinewidth});var l=({center:.5,right:1}[x.xanchor]||0)*a;it.attr("transform","translate("+(M.l-l)+","+M.t+")"),o.autoMargin(t,e,{x:x.x,y:x.y,l:a*({right:1,center:.5}[x.xanchor]||0),r:a*({left:1,center:.5}[x.xanchor]||0),t:s*({bottom:1,middle:.5}[x.yanchor]||0),b:s*({top:1,middle:.5}[x.yanchor]||0)})}var A=t._fullLayout,M=A._size;if("function"!=typeof x.fillcolor&&"function"!=typeof x.line.color)return void A._infolayer.selectAll("g."+e).remove();var T,E=n.extent(("function"==typeof x.fillcolor?x.fillcolor:x.line.color).domain()),L=[],S=[],C="function"==typeof x.line.color?x.line.color:function(){return x.line.color},z="function"==typeof x.fillcolor?x.fillcolor:function(){return x.fillcolor},P=x.levels.end+x.levels.size/100,R=x.levels.size,O=1.001*E[0]-.001*E[1],I=1.001*E[1]-.001*E[0];for(T=x.levels.start;0>(T-P)*R;T+=R)T>O&&I>T&&L.push(T);if("function"==typeof x.fillcolor)if(x.filllevels)for(P=x.filllevels.end+x.filllevels.size/100,R=x.filllevels.size,T=x.filllevels.start;0>(T-P)*R;T+=R)T>E[0]&&T1){var nt=Math.pow(10,Math.floor(Math.log(rt)/Math.LN10));tt*=nt*c.roundUp(rt/nt,[2,5,10]),(Math.abs(x.levels.start)/x.levels.size+1e-6)%1<2e-6&&(Q.tick0=0)}Q.dtick=tt}Q.domain=[W+G,W+V-G],Q.setScale();var it=A._infolayer.selectAll("g."+e).data([0]);it.enter().append("g").classed(e,!0).each(function(){var t=n.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),it.attr("transform","translate("+Math.round(M.l)+","+Math.round(M.t)+")");var at=it.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(M.l)+",-"+Math.round(M.t)+")");Q._axislayer=it.select(".cbaxis");var ot=0;if(-1!==["top","bottom"].indexOf(x.titleside)){var st,lt=M.l+(x.x+q)*M.w,ct=Q.titlefont.size;st="top"===x.titleside?(1-(W+V-G))*M.h+M.t+3+.75*ct:(1-(W+G))*M.h+M.t-3-.25*ct,w(Q._id+"title",{attributes:{x:lt,y:st,"text-anchor":"start"}})}var ut=c.syncOrAsync([o.previousPromises,_,o.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,ht,dt;l.init({element:it.node(),prepFn:function(){ft=it.attr("transform"),f(it)},moveFn:function(t,e){it.attr("transform",ft+" translate("+t+","+e+")"),ht=l.align(X+t/M.w,B,0,1,x.xanchor),dt=l.align(W-e/M.h,V,0,1,x.yanchor);var r=l.getCursor(ht,dt,x.xanchor,x.yanchor);f(it,r)},doneFn:function(e){f(it),e&&void 0!==ht&&void 0!==dt&&a.restyle(t,{"colorbar.x":ht,"colorbar.y":dt},b().index)}})}return ut}function b(){var r,n,i=e.substr(2);for(r=0;ru*f?i.RdBu:u>=0?i.Reds:i.Blues,l.colorscale=h,s.reversescale&&(h=a(h)),s.colorscale=h)}},{"../../lib":382,"./flip_scale":314,"./scales":321}],311:[function(t,e,r){"use strict";var n=t("./attributes"),i=t("../../lib/extend").extendDeep;e.exports=function(t){return{color:{valType:"color",arrayOk:!0},colorscale:i({},n.colorscale,{}),cauto:i({},n.zauto,{}),cmax:i({},n.zmax,{}),cmin:i({},n.zmin,{}),autocolorscale:i({},n.autocolorscale,{}),reversescale:i({},n.reversescale,{})}}},{"../../lib/extend":377,"./attributes":309}],312:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":321}],313:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,c,u){var f=u.prefix,h=u.cLetter,d=f.slice(0,f.length-1),p=f?i.nestedProperty(t,d).get()||{}:t,g=f?i.nestedProperty(e,d).get()||{}:e,v=p[h+"min"],m=p[h+"max"],y=p.colorscale,b=n(v)&&n(m)&&m>v;c(f+h+"auto",!b),c(f+h+"min"),c(f+h+"max");var x;void 0!==y&&(x=!s(y)),c(f+"autocolorscale",x);var _=c(f+"colorscale"),w=c(f+"reversescale");if(w&&(g.colorscale=l(_)),"marker.line."!==f){var k;f&&(k=a(p));var A=c(f+"showscale",k);A&&o(p,g,r)}}},{"../../lib":382,"../colorbar/defaults":305,"../colorbar/has_colorbar":307,"./flip_scale":314,"./is_valid_scale":318,"fast-isnumeric":117}],314:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=t.length,n=new Array(r),i=r-1,a=0;i>=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],315:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return e||(e=i),t?("string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e):e}},{"./default_scale":312,"./is_valid_scale_array":319,"./scales":321}],316:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(Array.isArray(o))for(var l=0;lh;h++)l=t[h],u[h]=e+l[0]*(r-e),f[h]=i(l[1]).toRgb();var d=n.scale.linear().domain(u).interpolate(n.interpolateObject).range(f);return function(t){if(a(t)){var n=o.constrain(t,e,r),l=d(n);return i(l).toRgbString()}return i(t).isValid()?t:s.defaultLine}}},{"../../lib":382,"../color":303,d3:113,"fast-isnumeric":117,tinycolor2:274}],321:[function(t,e,r){"use strict";e.exports={Greys:[[0,"rgb(0,0,0)"],[1,"rgb(255,255,255)"]],YlGnBu:[[0,"rgb(8,29,88)"],[.125,"rgb(37,52,148)"],[.25,"rgb(34,94,168)"],[.375,"rgb(29,145,192)"],[.5,"rgb(65,182,196)"],[.625,"rgb(127,205,187)"],[.75,"rgb(199,233,180)"],[.875,"rgb(237,248,217)"],[1,"rgb(255,255,217)"]],Greens:[[0,"rgb(0,68,27)"],[.125,"rgb(0,109,44)"],[.25,"rgb(35,139,69)"],[.375,"rgb(65,171,93)"],[.5,"rgb(116,196,118)"],[.625,"rgb(161,217,155)"],[.75,"rgb(199,233,192)"],[.875,"rgb(229,245,224)"],[1,"rgb(247,252,245)"]],YlOrRd:[[0,"rgb(128,0,38)"],[.125,"rgb(189,0,38)"],[.25,"rgb(227,26,28)"],[.375,"rgb(252,78,42)"],[.5,"rgb(253,141,60)"],[.625,"rgb(254,178,76)"],[.75,"rgb(254,217,118)"],[.875,"rgb(255,237,160)"],[1,"rgb(255,255,204)"]],Bluered:[[0,"rgb(0,0,255)"],[1,"rgb(255,0,0)"]],RdBu:[[0,"rgb(5,10,172)"],[.35,"rgb(106,137,247)"],[.5,"rgb(190,190,190)"],[.6,"rgb(220,170,132)"],[.7,"rgb(230,145,90)"],[1,"rgb(178,10,28)"]],Reds:[[0,"rgb(220,220,220)"],[.2,"rgb(245,195,157)"],[.4,"rgb(245,160,105)"],[1,"rgb(178,10,28)"]],Blues:[[0,"rgb(5,10,172)"],[.35,"rgb(40,60,190)"],[.5,"rgb(70,100,245)"],[.6,"rgb(90,120,245)"],[.7,"rgb(106,137,247)"],[1,"rgb(220,220,220)"]],Picnic:[[0,"rgb(0,0,255)"],[.1,"rgb(51,153,255)"],[.2,"rgb(102,204,255)"],[.3,"rgb(153,204,255)"],[.4,"rgb(204,204,255)"],[.5,"rgb(255,255,255)"],[.6,"rgb(255,204,255)"],[.7,"rgb(255,153,255)"],[.8,"rgb(255,102,204)"],[.9,"rgb(255,102,102)"],[1,"rgb(255,0,0)"]],Rainbow:[[0,"rgb(150,0,90)"],[.125,"rgb(0,0,200)"],[.25,"rgb(0,25,255)"],[.375,"rgb(0,152,255)"],[.5,"rgb(44,255,150)"],[.625,"rgb(151,255,0)"],[.75,"rgb(255,234,0)"],[.875,"rgb(255,111,0)"],[1,"rgb(255,0,0)"]],Portland:[[0,"rgb(12,51,131)"],[.25,"rgb(10,136,186)"],[.5,"rgb(242,211,56)"],[.75,"rgb(242,143,56)"],[1,"rgb(217,30,30)"]],Jet:[[0,"rgb(0,0,131)"],[.125,"rgb(0,60,170)"],[.375,"rgb(5,255,255)"],[.625,"rgb(255,255,0)"],[.875,"rgb(250,0,0)"],[1,"rgb(128,0,0)"]],Hot:[[0,"rgb(0,0,0)"],[.3,"rgb(230,0,0)"],[.6,"rgb(255,210,0)"],[1,"rgb(255,255,255)"]],Blackbody:[[0,"rgb(0,0,0)"],[.2,"rgb(230,0,0)"],[.4,"rgb(230,210,0)"],[.7,"rgb(255,255,255)"],[1,"rgb(160,200,255)"]],Earth:[[0,"rgb(0,0,130)"],[.1,"rgb(0,180,180)"],[.2,"rgb(40,210,40)"],[.4,"rgb(230,230,50)"],[.6,"rgb(120,70,20)"],[1,"rgb(255,255,255)"]],Electric:[[0,"rgb(0,0,0)"],[.15,"rgb(30,0,100)"],[.4,"rgb(120,0,100)"],[.6,"rgb(160,90,0)"],[.8,"rgb(230,200,0)"],[1,"rgb(255,250,220)"]],Viridis:[[0,"#440154"],[.06274509803921569,"#48186a"],[.12549019607843137,"#472d7b"],[.18823529411764706,"#424086"],[.25098039215686274,"#3b528b"],[.3137254901960784,"#33638d"],[.3764705882352941,"#2c728e"],[.4392156862745098,"#26828e"],[.5019607843137255,"#21918c"],[.5647058823529412,"#1fa088"],[.6274509803921569,"#28ae80"],[.6901960784313725,"#3fbc73"],[.7529411764705882,"#5ec962"],[.8156862745098039,"#84d44b"],[.8784313725490196,"#addc30"],[.9411764705882353,"#d8e219"],[1,"#fde725"]]}},{}],322:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i){var a=(t-r)/(n-r),o=a+e/(n-r),s=(a+o)/2;return"left"===i||"bottom"===i?a:"center"===i||"middle"===i?s:"right"===i||"top"===i?o:2/3-s>a?a:o>4/3-s?o:s}},{}],323:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":382}],324:[function(t,e,r){"use strict";function n(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function i(t){t._dragging=!1,t._replotPending&&a.plot(t)}var a=t("../../plotly"),o=t("../../lib"),s=t("../../plots/cartesian/constants"),l=e.exports={};l.align=t("./align"),l.getCursor=t("./cursor");var c=t("./unhover");l.unhover=c.wrapped,l.unhoverRaw=c.raw,l.init=function(t){function e(e){return p._dragged=!1,p._dragging=!0,c=e.clientX,u=e.clientY,d=e.target,f=(new Date).getTime(),f-p._mouseDownTimev&&(g=Math.max(g-1,1)),t.doneFn&&t.doneFn(p._dragged,g),!p._dragged){var r=document.createEvent("MouseEvents");r.initEvent("click",!0,!0),d.dispatchEvent(r)}return i(p),p._dragged=!1,o.pauseEvent(e)}var c,u,f,h,d,p=o.getPlotDiv(t.element)||{},g=1,v=s.DBLCLICKDELAY;p._mouseDownTime||(p._mouseDownTime=0),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":382,"../../plotly":402,"../../plots/cartesian/constants":410,"./align":322,"./cursor":323,"./unhover":325}],325:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=e.exports={};i.wrapped=function(t,e,r){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),i.raw(t,e,r)},i.raw=function(t,e){var r=t._fullLayout;e||(e={}),e.target&&n.triggerHandler(t,"plotly_beforehover",e)===!1||(r._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":376}],326:[function(t,e,r){"use strict";function n(t,e,r,n){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],c=Math.pow(a*a+o*o,x/2),u=Math.pow(s*s+l*l,x/2),f=(u*u*a-c*c*s)*n,h=(u*u*o-c*c*l)*n,d=3*u*(c+u),p=3*c*(c+u);return[[i.round(e[0]+(d&&f/d),2),i.round(e[1]+(d&&h/d),2)],[i.round(e[0]-(p&&f/p),2),i.round(e[1]-(p&&h/p),2)]]}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../plots/plots"),s=t("../color"),l=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../traces/scatter/subtypes"),d=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,r,n){e&&e.family&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},p.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},p.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},p.setRect=function(t,e,r,n,i){t.call(p.setPosition,e,r).call(p.setSize,n,i)},p.translatePoints=function(t,e,r){t.each(function(t){var n=t.xp||e.c2p(t.x),o=t.yp||r.c2p(t.y),s=i.select(this);a(n)&&a(o)?"text"===this.nodeName?s.attr("x",n).attr("y",o):s.attr("transform","translate("+n+","+o+")"):s.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:1>e?1:Math.round(e):r||0},p.lineGroupStyle=function(t,e,r,n){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=n||a.dash||"";i.select(this).call(s.stroke,r||a.color).call(p.dashLine,l,o)})},p.dashLine=function(t,e,r){var n=Math.max(r,3);"solid"===e?e="":"dot"===e?e=n+"px,"+n+"px":"dash"===e?e=3*n+"px,"+3*n+"px":"longdash"===e?e=5*n+"px,"+5*n+"px":"dashdot"===e?e=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===e&&(e=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var r=i.select(this);try{r.call(s.fill,e[0].trace.fillcolor)}catch(n){c.error(n,t),r.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var r=e.marker,n=r.line;if(o.traceIs(e,"symbols")){var a=d(e);t.attr("d",function(t){var n;n="various"===t.ms||"various"===r.size?3:h.isBubble(e)?a(t.ms):(r.size||6)/2,t.mrc=n;var i=p.symbolNumber(t.mx||r.symbol)||0,o=i%100;return t.om=i%200>=100,p.symbolFuncs[o](n)+(i>=200?m:"")}).style("opacity",function(t){return(t.mo+1||r.opacity+1)-1})}var l=(e._input||{}).marker||{},c=p.tryColorscale(r,l,""),u=p.tryColorscale(r,l,"line.");t.each(function(t){var e,a,o;t.so?(o=n.outlierwidth,a=n.outliercolor,e=r.outliercolor):(o=(t.mlw+1||n.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,a="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(n.color)?s.defaultLine:n.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(r.color)?s.defaultLine:r.color||"rgba(0,0,0,0)");var l=i.select(this);t.om?l.call(s.stroke,e).style({"stroke-width":(o||1)+"px",fill:"none"}):(l.style("stroke-width",o+"px").call(s.fill,e),o&&l.call(s.stroke,a))})}},p.tryColorscale=function(t,e,r){var n=c.nestedProperty(t,r+"color").get(),i=c.nestedProperty(t,r+"colorscale").get(),o=c.nestedProperty(t,r+"cauto").get(),s=c.nestedProperty(t,r+"cmin"),u=c.nestedProperty(t,r+"cmax"),f=s.get(),h=u.get();return i&&Array.isArray(n)?(!o&&a(f)&&a(h)||(f=1/0,h=-(1/0),n.forEach(function(t){a(t)&&(f>t&&(f=+t),t>h&&(h=+t))}),f>h&&(f=0,h=1),s.set(f),u.set(h),c.nestedProperty(e,r+"cmin").set(f),c.nestedProperty(e,r+"cmax").set(h)),l.makeScaleFunction(i,f,h)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},b=1.3;p.textPointStyle=function(t,e){t.each(function(t){var r=i.select(this),n=t.tx||e.text;if(!n||Array.isArray(n))return void r.remove();var o=t.tp||e.textposition,s=-1!==o.indexOf("top")?"top":-1!==o.indexOf("bottom")?"bottom":"middle",l=-1!==o.indexOf("left")?"end":-1!==o.indexOf("right")?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=a(c)&&c>0?c:0,r.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",l).text(n).call(u.convertToTspans);var h=i.select(this.parentNode),d=r.selectAll("tspan.line"),g=((d[0].length||1)-1)*b+1,v=y[l]*f,m=.75*c+y[s]*f+(y[s]-1)*g*c/2;h.attr("transform","translate("+v+","+m+")"),g>1&&d.attr({x:r.attr("x"),y:r.attr("y")})})};var x=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,i="M"+t[0],a=[];for(r=1;rr;r++)o.push(n(t[r-1],t[r],t[r+1],e));for(o.push(n(t[a-1],t[a],t[0],e)),r=1;a>=r;r++)i+="C"+o[r-1][1]+" "+o[r][0]+" "+t[r];return i+="C"+o[a][1]+" "+o[0][0]+" "+t[0]+"Z"};var _={hv:function(t,e){return"H"+i.round(e[0],2)+"V"+i.round(e[1],2)},vh:function(t,e){return"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},hvh:function(t,e){return"H"+i.round((t[0]+e[0])/2,2)+"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},vhv:function(t,e){return"V"+i.round((t[1]+e[1])/2,2)+"H"+i.round(e[0],2)+"V"+i.round(e[1],2)}},w=function(t,e){return"L"+i.round(e[0],2)+","+i.round(e[1],2)};p.steps=function(t){var e=_[t]||w;return function(t){for(var r="M"+i.round(t[0][0],2)+","+i.round(t[0][1],2),n=1;n=A&&(i.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(l),c.extendFlat({},l)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var r="#"+e,n=i.select("base");n.size()&&n.attr("href")&&(r=window.location.href+r),t.attr("clip-path","url("+r+")")}},{"../../constants/xmlns_namespaces":370,"../../lib":382,"../../lib/svg_text_utils":395,"../../plots/plots":454,"../../traces/scatter/make_bubble_size_func":569,"../../traces/scatter/subtypes":575,"../color":303,"../colorscale":317,"./symbol_defs":327,d3:113,"fast-isnumeric":117}],327:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+","+r+"H"+e+"L0,-"+i+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+",-"+r+"H"+e+"L0,"+i+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M"+r+",-"+e+"V"+e+"L-"+i+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+r+",-"+e+"V"+e+"L"+i+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(t*-.309,2),o=n.round(.809*t,2);return"M"+e+","+a+"L"+r+","+o+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(e*-.309,2),c=n.round(.118*e,2),u=n.round(.809*e,2),f=n.round(.382*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+c+"L"+o+","+u+"L0,"+f+"L-"+o+","+u+"L-"+a+","+c+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:113}],328:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],329:[function(t,e,r){"use strict";function n(t,e,r,n){var a=e["error_"+n]||{},l=a.visible&&-1!==["linear","log"].indexOf(r.type),c=[];if(l){for(var u=s(a),f=0;fs;s++)o[s]={x:r[s],y:i[s]};return o[0].trace=t,n.calc({calcdata:[o],_fullLayout:e}),o},n.plot=t("./plot"),n.style=t("./style"),n.hoverInfo=function(t,e,r){(e.error_y||{}).visible&&(r.yerr=t.yh-t.y,e.error_y.symmetric||(r.yerrneg=t.y-t.ys)),(e.error_x||{}).visible&&(r.xerr=t.xh-t.x,e.error_x.symmetric||(r.xerrneg=t.x-t.xs))}},{"./attributes":328,"./calc":329,"./defaults":331,"./plot":333,"./style":334}],333:[function(t,e,r){"use strict";function n(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};return void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0))),void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0))),n}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),s=t("../../traces/scatter/subtypes");e.exports=function(t,e){var r=e.x(),l=e.y();t.each(function(t){var e=t[0].trace,c=e.error_x||{},u=e.error_y||{},f=s.hasMarkers(e)&&e.marker.maxdisplayed>0;if(u.visible||c.visible){var h=i.select(this).selectAll("g.errorbar").data(o.identity);h.enter().append("g").classed("errorbar",!0),h.each(function(t){var e=i.select(this),o=n(t,r,l);if(!f||t.vis){var s;if(u.visible&&a(o.x)&&a(o.yh)&&a(o.ys)){var h=u.width;s="M"+(o.x-h)+","+o.yh+"h"+2*h+"m-"+h+",0V"+o.ys,o.noYS||(s+="m-"+h+",0h"+2*h),e.append("path").classed("yerror",!0).attr("d",s)}if(c.visible&&a(o.y)&&a(o.xh)&&a(o.xs)){var d=(c.copy_ystyle?u:c).width;s="M"+o.xh+","+(o.y-d)+"v"+2*d+"m0,-"+d+"H"+o.xs,o.noXS||(s+="m0,-"+d+"v"+2*d),e.append("path").classed("xerror",!0).attr("d",s)}}})}})}},{"../../lib":382,"../../traces/scatter/subtypes":575,d3:113,"fast-isnumeric":117}],334:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":303,d3:113}],335:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",n.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",n.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":410}],336:[function(t,e,r){"use strict";function n(t,e,r){function n(r,n){return a.coerce(t,e,o,r,n)}e=e||{},n("source"),n("layer"),n("x"),n("y"),n("xanchor"),n("yanchor"),n("sizex"),n("sizey"),n("sizing"),n("opacity");for(var s=0;2>s;s++){var l={_fullLayout:r},c=["x","y"][s];i.coerceRef(t,e,l,c,"paper")}return e}var i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var r=t.images,i=e.images=[],a=0;a=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],340:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:a({},n,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":377,"../../plots/font_attributes":423,"../color/attributes":302}],341:[function(t,e,r){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],342:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/plots"),a=t("./attributes"),o=t("./helpers");e.exports=function(t,e,r){function s(t,e){return n.coerce(h,d,a,t,e)}for(var l,c,u,f,h=t.legend||{},d=e.legend={},p=0,g="normal",v=0;v1);if(y!==!1){if(s("bgcolor",e.paper_bgcolor),s("bordercolor"),s("borderwidth"),n.coerceFont(s,"font",e.font),s("orientation"),"h"===d.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(l=0,u="left",c=1.1,f="bottom"):(l=0,u="left",c=-.1,f="top")}s("traceorder",g),o.isGrouped(e.legend)&&s("tracegroupgap"),s("x",l),s("xanchor",u),s("y",c),s("yanchor",f),n.noneOrAll(h,d,["x","y"])}}},{"../../lib":382,"../../plots/plots":454,"./attributes":340,"./helpers":345}],343:[function(t,e,r){"use strict";function n(t,e){function r(r){u.util.convertToTspans(r,function(){r.selectAll("tspan.line").attr({x:r.attr("x")}),t.call(a,e)})}var n=t.data()[0][0],i=e._fullLayout,o=n.trace,s=h.traceIs(o,"pie"),l=o.index,c=s?n.label:o.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":c}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,i.legend.font).text(c),e._context.editable&&!s?f.call(u.util.makeEditable).call(r).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(r),this.text()||(t=" "),u.restyle(e,"name",t,l)}):f.call(r)}function i(t,e){var r=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],n=t.selectAll("rect").data([0]);n.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"),n.on("click",function(){if(!e._dragged){var n,i,a=t.data()[0][0],o=e._fullData,s=a.trace,l=s.legendgroup,c=[];if(h.traceIs(s,"pie")){var f=a.label,d=r.indexOf(f);-1===d?r.push(f):r.splice(d,1),u.relayout(e,"hiddenlabels",r)}else{if(""===l)c=[s.index];else for(var p=0;ptspan"),d=h[0].length||1;r=l*d,n=u.node()&&p.bBox(u.node()).width;var g=l*(.3+(1-d)/2);u.attr("y",g),h.attr("y",g)}r=Math.max(r,16)+3,a.attr({x:0,y:-r/2,height:r}),i.height=r,i.width=n}function o(t,e,r){var n=t._fullLayout,i=n.legend,a=i.borderwidth,o=b.isGrouped(i);if(b.isVertical(i))o&&e.each(function(t,e){f.setTranslate(this,0,e*i.tracegroupgap)}),i.width=0,i.height=0,r.each(function(t){var e=t[0],r=e.height,n=e.width;f.setTranslate(this,a,5+a+i.height+r/2),i.height+=r,i.width=Math.max(i.width,n)}),i.width+=45+2*a,i.height+=10+2*a,o&&(i.height+=(i._lgroupsLength-1)*i.tracegroupgap),r.selectAll(".legendtoggle").attr("width",(t._context.editable?0:i.width)+40),i.width=Math.ceil(i.width),i.height=Math.ceil(i.height);else if(o){i.width=0,i.height=0;for(var s=[i.width],l=e.data(),u=0,h=l.length;h>u;u++){var d=l[u].map(function(t){return t[0].width}),p=40+Math.max.apply(null,d);i.width+=i.tracegroupgap+p,s.push(i.width)}e.each(function(t,e){f.setTranslate(this,s[e],0)}),e.each(function(){var t=c.select(this),e=t.selectAll("g.traces"),r=0;e.each(function(t){var e=t[0],n=e.height;f.setTranslate(this,0,5+a+r+n/2),r+=n}),i.height=Math.max(i.height,r)}),i.height+=10+2*a,i.width+=2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}else i.width=0,i.height=0,r.each(function(t){var e=t[0],r=40+e.width,n=i.tracegroupgap||5;f.setTranslate(this,a+i.width,5+a+e.height/2),i.width+=n+r,i.height=Math.max(i.height,e.height)}),i.width+=2*a,i.height+=10+2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}function s(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center");var i="top";x.isBottomAnchor(r)?i="bottom":x.isMiddleAnchor(r)&&(i="middle"),h.autoMargin(t,"legend",{x:r.x,y:r.y,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:r.height*({top:1,middle:.5}[i]||0),t:r.height*({bottom:1,middle:.5}[i]||0)})}function l(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center"),h.autoMargin(t,"legend",{x:r.x,y:.5,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:0,t:0})}var c=t("d3"),u=t("../../plotly"),f=t("../../lib"),h=t("../../plots/plots"),d=t("../dragelement"),p=t("../drawing"),g=t("../color"),v=t("./constants"),m=t("./get_legend_data"),y=t("./style"),b=t("./helpers"),x=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e).call(f.setTranslate,0,e),E.call(p.setRect,F,t,v.scrollBarWidth,v.scrollBarHeight),A.select("rect").attr({y:b.borderwidth-e})}var r=t._fullLayout,a="legend"+r._uid;if(r._infolayer&&t.calcdata){var b=r.legend,_=r.showlegend&&m(t.calcdata,b),w=r.hiddenlabels||[];if(!r.showlegend||!_.length)return r._infolayer.selectAll(".legend").remove(),r._topdefs.select("#"+a).remove(),void h.autoMargin(t,"legend");var k=r._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({"class":"legend","pointer-events":"all"});var A=r._topdefs.selectAll("#"+a).data([0]);A.enter().append("clipPath").attr("id",a).append("rect");var M=k.selectAll("rect.bg").data([0]);M.enter().append("rect").attr({"class":"bg","shape-rendering":"crispEdges"}).call(g.stroke,b.bordercolor).call(g.fill,b.bgcolor).style("stroke-width",b.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var E=k.selectAll("rect.scrollbar").data([0]);E.enter().append("rect").attr({"class":"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var L=T.selectAll("g.groups").data(_);L.enter().append("g").attr("class","groups"),L.exit().remove();var S=L.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return h.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(){c.select(this).call(n,t).call(i,t)});var C=0!==k.enter().size();C&&(o(t,L,S),s(t));var z=0,P=r.width,R=0,O=r.height;o(t,L,S),b.height>O?l(t):s(t);var I=r._size,N=I.l+I.w*b.x,j=I.t+I.h*(1-b.y);x.isRightAnchor(b)?N-=b.width:x.isCenterAnchor(b)&&(N-=b.width/2),x.isBottomAnchor(b)?j-=b.height:x.isMiddleAnchor(b)&&(j-=b.height/2);var F=b.width,D=I.w;F>D?(N=I.l,F=D):(N+F>P&&(N=P-F),z>N&&(N=z),F=Math.min(P-N,b.width));var B=b.height,U=I.h;B>U?(j=I.t,B=U):(j+B>O&&(j=O-B),R>j&&(j=R),B=Math.min(O-j,b.height)),f.setTranslate(k,N,j);var V,q,H=B-v.scrollBarHeight-2*v.scrollBarMargin,G=b.height-B;if(b.height<=B||t._context.staticPlot)M.attr({width:F-b.borderwidth,height:B-b.borderwidth,x:b.borderwidth/2,y:b.borderwidth/2}),f.setTranslate(T,0,0),A.select("rect").attr({width:F-2*b.borderwidth,height:B-2*b.borderwidth,x:b.borderwidth,y:b.borderwidth}),T.call(p.setClipUrl,a);else{V=v.scrollBarMargin,q=T.attr("data-scroll")||0,M.attr({width:F-2*b.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:B-b.borderwidth,x:b.borderwidth/2,y:b.borderwidth/2}),A.select("rect").attr({width:F-2*b.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:B-2*b.borderwidth,x:b.borderwidth,y:b.borderwidth-q}),T.call(p.setClipUrl,a),C&&e(V,q),k.on("wheel",null),k.on("wheel",function(){q=f.constrain(T.attr("data-scroll")-c.event.deltaY/H*G,-G,0),V=v.scrollBarMargin-q/G*H,e(V,q),c.event.preventDefault()}),E.on(".drag",null),T.on(".drag",null);var Y=c.behavior.drag().on("drag",function(){V=f.constrain(c.event.y-v.scrollBarHeight/2,v.scrollBarMargin,v.scrollBarMargin+H),q=-(V-v.scrollBarMargin)/H*G,e(V,q)});E.call(Y),T.call(Y)}if(t._context.editable){var X,W,Z,K;k.classed("cursor-move",!0),d.init({element:k.node(),prepFn:function(){var t=f.getTranslate(k);Z=t.x,K=t.y},moveFn:function(t,e){var r=Z+t,n=K+e;f.setTranslate(k,r,n),X=d.align(r,0,I.l,I.l+I.w,b.xanchor),W=d.align(n,0,I.t+I.h,I.t,b.yanchor)},doneFn:function(e){e&&void 0!==X&&void 0!==W&&u.relayout(t,{"legend.x":X,"legend.y":W})}})}}}},{"../../lib":382,"../../plotly":402,"../../plots/plots":454,"../color":303,"../dragelement":324,"../drawing":326,"./anchor_utils":339,"./constants":341,"./get_legend_data":344,"./helpers":345,"./style":347,d3:113}],344:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("./helpers");e.exports=function(t,e){function r(t,r){if(""!==t&&i.isGrouped(e))-1===l.indexOf(t)?(l.push(t),c=!0,s[t]=[[r]]):s[t].push([r]);else{var n="~~i"+f;l.push(n),s[n]=[[r]],f++}}var a,o,s={},l=[],c=!1,u={},f=0;for(a=0;aa;a++)m=s[l[a]],y[a]=i.isReversed(e)?m.reverse():m;else{for(y=[new Array(b)],a=0;b>a;a++)m=s[l[a]][0],y[0][i.isReversed(e)?b-a-1:a]=m;b=1}return e._lgroupsLength=b,y}},{"../../plots/plots":454,"./helpers":345}],345:[function(t,e,r){"use strict";var n=t("../../plots/plots");r.legendGetsTrace=function(t){return t.visible&&n.traceIs(t,"showLegend")},r.isGrouped=function(t){return-1!==(t.traceorder||"").indexOf("grouped")},r.isVertical=function(t){return"h"!==t.orientation},r.isReversed=function(t){return-1!==(t.traceorder||"").indexOf("reversed")}},{"../../plots/plots":454}],346:[function(t,e,r){"use strict";var n=e.exports={};n.layoutAttributes=t("./attributes"),n.supplyLayoutDefaults=t("./defaults"),n.draw=t("./draw"),n.style=t("./style")},{"./attributes":340,"./defaults":342,"./draw":343,"./style":347}],347:[function(t,e,r){"use strict";function n(t){var e=t[0].trace,r=e.visible&&e.fill&&"none"!==e.fill,n=d.hasLines(e),i=l.select(this).select(".legendfill").selectAll("path").data(r?[t]:[]);i.enter().append("path").classed("js-fill",!0),i.exit().remove(),i.attr("d","M5,0h30v6h-30z").call(f.fillGroupStyle);var a=l.select(this).select(".legendlines").selectAll("path").data(n?[t]:[]);a.enter().append("path").classed("js-line",!0).attr("d","M5,0h30"),a.exit().remove(),a.call(f.lineGroupStyle)}function i(t){function e(t,e,r){var n=c.nestedProperty(o,t).get(),i=Array.isArray(n)&&e?e(n):n;if(r){if(ir[1])return r[1]}return i}function r(t){return t[0]}var n,i,a=t[0],o=a.trace,s=d.hasMarkers(o),u=d.hasText(o),h=d.hasLines(o);if(s||u||h){var p={},g={};s&&(p.mc=e("marker.color",r),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",r),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),h&&(g.line={width:e("line.width",r,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",r),p.ts=10,p.tc=e("textfont.color",r),p.tf=e("textfont.family",r)),n=[c.minExtend(a,p)],i=c.minExtend(o,g)}var v=l.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(s?n:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,i),s&&(n[0].mrc=3);var y=v.selectAll("g.pointtext").data(u?n:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,i)}function a(t){var e=t[0].trace,r=e.marker||{},n=r.line||{},i=l.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);i.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),i.exit().remove(),i.each(function(t){var e=(t.mlw+1||n.width+1)-1,i=l.select(this);i.style("stroke-width",e+"px").call(h.fill,t.mc||r.color),e&&i.call(h.stroke,t.mlc||n.color)})}function o(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);r.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.each(function(t){var r=(t.lw+1||e.line.width+1)-1,n=l.select(this);n.style("stroke-width",r+"px").call(h.fill,t.fc||e.fillcolor),r&&n.call(h.stroke,t.lc||e.line.color)})}function s(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);r.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.size()&&r.call(p,t[0],e)}var l=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),h=t("../color"),d=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=l.select(this),r=e.selectAll("g.legendfill").data([t]);r.enter().append("g").classed("legendfill",!0);var n=e.selectAll("g.legendlines").data([t]);n.enter().append("g").classed("legendlines",!0);var i=e.selectAll("g.legendsymbols").data([t]);i.enter().append("g").classed("legendsymbols",!0),i.style("opacity",t[0].trace.opacity),i.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(a).each(o).each(s).each(n).each(i)}},{"../../lib":382,"../../plots/plots":454,"../../traces/pie/style_one":554,"../../traces/scatter/subtypes":575,"../color":303,"../drawing":326,d3:113}],348:[function(t,e,r){"use strict";function n(t,e){var r=e.currentTarget,n=r.getAttribute("data-attr"),i=r.getAttribute("data-val")||!0,a=t._fullLayout,o={};if("zoom"===n){for(var s,l,u="in"===i?.5:2,h=(1+u)/2,d=(1-u)/2,p=c.Axes.list(t,null,!0),v=0;vy;y++){var b=s[y];h=m[b]={};for(var x=0;x1)return n(["resetViews","toggleHover"]),o(v,r);u&&(n(["zoom3d","pan3d","orbitRotation","tableRotation"]),n(["resetCameraDefault3d","resetCameraLastSave3d"]),n(["hoverClosest3d"])),h&&(n(["zoomInGeo","zoomOutGeo","resetGeo"]),n(["hoverClosestGeo"]));var m=i(s),y=[];return((c||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(c||g)&&a(l)&&(y.push("select2d"),y.push("lasso2d")),y.length&&n(y),!c&&!p||m||g||n(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&d?n(["toggleHover"]):p?n(["hoverClosestGl2d"]):c?n(["hoverClosestCartesian","hoverCompareCartesian"]):d&&n(["hoverClosestPie"]),o(v,r)}function i(t){for(var e=l.Axes.list({_fullLayout:t},null,!0),r=!0,n=0;n0);if(h){var d=i(e,r,s);l("x",d[0]),l("y",d[1]),a.noneOrAll(t,e,["x","y"]),l("xanchor"),l("yanchor"),a.coerceFont(l,"font",r.font),l("bgcolor"),l("bordercolor"),l("borderwidth")}}},{"../../lib":382,"./attributes":351,"./button_attributes":352,"./constants":353}],355:[function(t,e,r){"use strict";function n(t){for(var e=m.list(t,"x",!0),r=[],n=0;ne){var r=e;e=t,t=r}s.setAttributes(w,{"data-min":t,"data-max":e}),s.setAttributes(R,{x:t,width:e-t}),s.setAttributes(M,{width:t}),s.setAttributes(T,{x:e,width:p-e}),s.setAttributes(E,{transform:"translate("+(t-v-1)+")"}),s.setAttributes(C,{transform:"translate("+e+")"})}var f=t._fullLayout,h=f._infolayer.selectAll("g.range-slider"),d=f.xaxis.rangeslider,p=f._size.w,g=(f.height-f.margin.b-f.margin.t)*d.thickness,v=2,m=Math.floor(d.borderwidth/2),y=f.margin.l,b=f.height-g-f.margin.b,x=0,_=p,w=document.createElementNS(o,"g");s.setAttributes(w,{"class":"range-slider","data-min":x,"data-max":_,"pointer-events":"all",transform:"translate("+y+","+b+")"});var k=document.createElementNS(o,"rect"),A=d.borderwidth%2===0?d.borderwidth:d.borderwidth-1;s.setAttributes(k,{fill:d.bgcolor,stroke:d.bordercolor,"stroke-width":d.borderwidth,height:g+A,width:p+A,transform:"translate(-"+m+", -"+m+")","shape-rendering":"crispEdges"});var M=document.createElementNS(o,"rect");s.setAttributes(M,{x:0,width:x,height:g,fill:"rgba(0,0,0,0.4)"});var T=document.createElementNS(o,"rect");s.setAttributes(T,{x:_,width:p-_,height:g,fill:"rgba(0,0,0,0.4)"});var E=document.createElementNS(o,"g"),L=document.createElementNS(o,"rect"),S=document.createElementNS(o,"rect");s.setAttributes(E,{transform:"translate("+(x-v-1)+")"}),s.setAttributes(L,{width:10,height:g,x:-6,fill:"transparent",cursor:"col-resize"}),s.setAttributes(S,{width:v,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(E,[S,L]);var C=document.createElementNS(o,"g"),z=document.createElementNS(o,"rect"),P=document.createElementNS(o,"rect");s.setAttributes(C,{transform:"translate("+_+")"}),s.setAttributes(z,{width:10,height:g,x:-2,fill:"transparent",cursor:"col-resize"}),s.setAttributes(P,{width:v,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(C,[P,z]);var R=document.createElementNS(o,"rect");s.setAttributes(R,{x:x,width:_-x,height:g,cursor:"ew-resize",fill:"transparent"}),w.addEventListener("mousedown",function(t){function r(t){var r,n,f=+t.clientX-a;switch(i){case R:w.style.cursor="ew-resize",r=+s+f,n=+l+f,u(r,n),c(e(r),e(n));break;case L:w.style.cursor="col-resize",r=+s+f,n=+l,u(r,n),c(e(r),e(n));break;case z:w.style.cursor="col-resize",r=+s,n=+l+f,u(r,n),c(e(r),e(n));break;default:w.style.cursor="ew-resize",r=o,n=o+f,u(r,n),c(e(r),e(n))}}function n(){window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",n),w.style.cursor="auto"}var i=t.target,a=t.clientX,o=a-w.getBoundingClientRect().left,s=w.getAttribute("data-min"),l=w.getAttribute("data-max");window.addEventListener("mousemove",r),window.addEventListener("mouseup",n)}),d.range||(d.range=i.getAutoRange(f.xaxis));var O=l(t,p,g);s.appendChildren(w,[k,O,M,T,R,E,C]),r(f.xaxis.range[0],f.xaxis.range[1]),h.data([0]).enter().append(function(){return d.setRange=r,w})}},{"../../constants/xmlns_namespaces":370,"../../lib":382,"../../plotly":402,"../../plots/cartesian/axes":405,"./helpers":361,"./range_plot":363}],360:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(t,e){return n.coerce(s,l,i,t,e)}if(t[r].rangeslider){var s="object"==typeof t[r].rangeslider?t[r].rangeslider:{},l=e[r].rangeslider={};if(o("bgcolor"),o("bordercolor"),o("borderwidth"),o("thickness"),o("visible"),o("range"),l.range&&!e[r].autorange){var c=l.range,u=e[r].range;c[0]=Math.min(c[0],u[0]),c[1]=Math.max(c[1],u[1])}else e[r]._needsExpand=!0;l.visible&&a.forEach(function(t){var r=e[t]||{};r.fixedrange=!0,e[t]=r})}}},{"../../lib":382,"./attributes":358}],361:[function(t,e,r){"use strict";r.setAttributes=function(t,e){for(var r in e)t.setAttribute(r,e[r])},r.appendChildren=function(t,e){for(var r=0;rl;l++){var c=s[l],u={_fullLayout:e},f=x.coerceRef(t,n,u,c);if("path"!==o){var h=.25,d=.75;if("paper"!==f){var p=x.getFromId(u,f),g=a(p);h=g(p.range[0]+h*(p.range[1]-p.range[0])),d=g(p.range[0]+d*(p.range[1]-p.range[0]))}r(c+"0",h),r(c+"1",d)}}return"path"===o?r("path"):b.noneOrAll(t,n,["x0","x1","y0","y1"]),n}function i(t){return"category"===t.type?t.c2l:t.d2l}function a(t){return"category"===t.type?t.l2c:t.l2d}function o(t,e){t.layout.shapes=e,k.supplyLayoutDefaults(t.layout,t._fullLayout),k.drawAll(t)}function s(t){delete t.layout.shapes,t._fullLayout.shapes=[],k.drawAll(t)}function l(t,e,r){for(var n=0;ne;i--)h(t,i).selectAll('[data-index="'+(i-1)+'"]').attr("data-index",i),k.draw(t,i)}function f(t,e,r,o){function s(e){var r=e.append("path").attr(z).style("opacity",S.opacity).call(_.stroke,P).call(_.fill,S.fillcolor).call(w.dashLine,S.line.dash,S.line.width);C&&r.call(w.setClipUrl,"clip"+t._fullLayout._uid+C)}var l,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},p={};"string"==typeof r&&r?p[r]=o:b.isPlainObject(r)&&(p=r);var v=Object.keys(p);for(l=0;ll;l++){var k=y[l];if(void 0===p[k]&&void 0!==u[k]){var A,M=k.charAt(0),T=x.getFromId(t,x.coerceRef(f,{},t,M)),E=x.getFromId(t,x.coerceRef(u,{},t,M)),L=u[k];void 0!==p[M+"ref"]&&(T?(A=i(T)(L),L=(A-T.range[0])/(T.range[1]-T.range[0])):L=(L-E.domain[0])/(E.domain[1]-E.domain[0]),E?(A=E.range[0]+L*(E.range[1]-E.range[0]),L=a(E)(A)):L=T.domain[0]+L*(T.domain[1]-T.domain[0])),u[k]=L}}var S=n(u,t._fullLayout);t._fullLayout.shapes[e]=S;var C,z={"data-index":e,"fill-rule":"evenodd",d:g(t,S)},P=S.line.width?S.line.color:"rgba(0,0,0,0)";if("below"!==S.layer)C=(S.xref+S.yref).replace(/paper/g,""),s(t._fullLayout._shapeUpperLayer);else if("paper"===S.xref&&"paper"===S.yref)C="",s(t._fullLayout._shapeLowerLayer);else{var R,O=t._fullLayout._plots||{},I=Object.keys(O);for(l=0,c=I.length;c>l;l++)R=O[I[l]],C=I[l],d(t,S,R)&&s(R.shapelayer)}}}function h(t,e){var r=t._fullLayout.shapes[e],n=t._fullLayout._shapeUpperLayer;return r?"below"===r.layer&&(n="paper"===r.xref&&"paper"===r.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):b.log("getShapeLayer: undefined shape: index",e),n}function d(t,e,r){var n=y.Axes.getFromId(t,r.id,"x")._id,i=y.Axes.getFromId(t,r.id,"y")._id,a="below"===e.layer,o=n===e.xref||i===e.yref,s=!!r.shapelayer;return a&&o&&s}function p(t){return function(e){return t(e.replace("_"," "))}}function g(t,e){var r,n,a,o,s=e.type,l=x.getFromId(t,e.xref),c=x.getFromId(t,e.yref),u=t._fullLayout._size;if(l?(r=i(l),n=function(t){return l._offset+l.l2p(r(t,!0))}):n=function(t){return u.l+u.w*t},c?(a=i(c),o=function(t){return c._offset+c.l2p(a(t,!0))}):o=function(t){return u.t+u.h*(1-t)},"path"===s)return l&&"date"===l.type&&(n=p(n)),c&&"date"===c.type&&(o=p(o)),k.convertPath(e.path,n,o);var f=n(e.x0),h=n(e.x1),d=o(e.y0),g=o(e.y1);if("line"===s)return"M"+f+","+d+"L"+h+","+g;if("rect"===s)return"M"+f+","+d+"H"+h+"V"+g+"H"+f+"Z";var v=(f+h)/2,m=(d+g)/2,y=Math.abs(v-f),b=Math.abs(m-d),_="A"+y+","+b,w=v+y+","+m,A=v+","+(m-b);return"M"+w+_+" 0 1,1 "+A+_+" 0 0,1 "+w+"Z"}function v(t,e,r,n,i){var a="category"===t.type?Number:t.d2c;if(void 0!==e)return[a(e),a(r)];if(n){var o,s,l,c,u,f=1/0,h=-(1/0),d=n.match(A);for("date"===t.type&&(a=p(a)),o=0;ou&&(f=u),u>h&&(h=u)));return h>=f?[f,h]:void 0}}var m=t("fast-isnumeric"),y=t("../../plotly"),b=t("../../lib"),x=t("../../plots/cartesian/axes"),_=t("../color"),w=t("../drawing"),k=e.exports={};k.layoutAttributes=t("./attributes"),k.supplyLayoutDefaults=function(t,e){for(var r=t.shapes||[],i=e.shapes=[],a=0;as&&(t="X"),t});return n>s&&(l=l.replace(/[\s,]*X.*/,""),b.log("Ignoring extra params in segment "+t)),i+l})},k.calcAutorange=function(t){var e,r,n,i,a,o=t._fullLayout,s=o.shapes;if(s.length&&t._fullData.length)for(e=0;eh?r=h:(u.left-=b.offsetLeft,u.right-=b.offsetLeft,u.top-=b.offsetTop,u.bottom-=b.offsetTop,b.selection.each(function(){var t=l.bBox(this);s.bBoxIntersect(u,t,c)&&(r=Math.max(r,o*(t[b.side]-u[a])+c))}),r=Math.min(h,r)),r>0||0>h){var d={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[b.side];e.attr("transform","translate("+d+")")}}}function p(){E=0,L=!0,S=z,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)})}var g=r.propContainer,v=r.propName,m=r.traceIndex,y=r.dfltName,b=r.avoid||{},x=r.attributes,_=r.transform,w=r.containerGroup,k=t._fullLayout,A=g.titlefont.family,M=g.titlefont.size,T=g.titlefont.color,E=1,L=!1,S=g.title.trim();""===S&&(E=0),S.match(/Click to enter .+ title/)&&(E=.2,L=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var z="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==m?a.restyle(t,v,e,m):a.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(x).selectAll("tspan.line").attr(x)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",L)}},{"../../lib":382,"../../lib/svg_text_utils":395,"../../plotly":402,"../../plots/plots":454,"../color":303,"../drawing":326,d3:113,"fast-isnumeric":117}],367:[function(t,e,r){"use strict";e.exports={solid:[1],dot:[1,1],dash:[4,1],longdash:[8,1],dashdot:[4,1,1,1],longdashdot:[8,1,1,1]}},{}],368:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],369:[function(t,e,r){"use strict";e.exports={circle:"\u25cf","circle-open":"\u25cb",square:"\u25a0","square-open":"\u25a1",diamond:"\u25c6","diamond-open":"\u25c7",cross:"+",x:"\u274c"}},{}],370:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],371:[function(t,e,r){"use strict";var n=t("./plotly");r.version="1.13.0",r.plot=n.plot,r.newPlot=n.newPlot,r.restyle=n.restyle,r.relayout=n.relayout,r.redraw=n.redraw,r.extendTraces=n.extendTraces,r.prependTraces=n.prependTraces,r.addTraces=n.addTraces,r.deleteTraces=n.deleteTraces,r.moveTraces=n.moveTraces,r.purge=n.purge,r.setPlotConfig=t("./plot_api/set_plot_config"),r.register=n.register,r.toImage=t("./plot_api/to_image"),r.downloadImage=t("./snapshot/download"),r.Icons=t("../build/ploticon"),r.Plots=n.Plots,r.Fx=n.Fx,r.Snapshot=n.Snapshot,r.PlotSchema=n.PlotSchema,r.Queue=n.Queue,r.d3=t("d3")},{"../build/ploticon":2,"./plot_api/set_plot_config":400,"./plot_api/to_image":401,"./plotly":402,"./snapshot/download":469,d3:113}],372:[function(t,e,r){"use strict";"undefined"!=typeof MathJax?(r.MathJax=!0,MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:!0,displayAlign:"left",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]}}),MathJax.Hub.Configured()):r.MathJax=!1},{}],373:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){Array.isArray(t)&&(e[r]=t[n])}},{}],374:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("./nested_property"),o=t("../components/colorscale/get_scale"),s=(Object.keys(t("../components/colorscale/scales")),/^([2-9]|[1-9][0-9]+)$/);r.valObjects={data_array:{coerceFunction:function(t,e,r){Array.isArray(t)?e.set(t):void 0!==r&&e.set(r)}},enumerated:{coerceFunction:function(t,e,r,n){n.coerceNumber&&(t=+t),-1===n.values.indexOf(t)?e.set(r):e.set(t)}},"boolean":{coerceFunction:function(t,e,r){t===!0||t===!1?e.set(t):e.set(r)}},number:{coerceFunction:function(t,e,r,i){!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if(n.strict===!0&&"string"!=typeof t)return void e.set(r);var i=String(t);void 0===t||n.noBlank===!0&&!i?e.set(r):e.set(i)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r){var n=r.length;return"string"==typeof t&&t.substr(0,n)===r&&s.test(t.substr(n))?void e.set(t):void e.set(r)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"!=typeof t)return void e.set(r);if(-1!==n.extras.indexOf(t))return void e.set(t);for(var i=t.split("+"),a=0;a2)return!1;var l=o[0].split("-");if(l.length>3||3!==l.length&&o[1])return!1;if(4===l[0].length)r=Number(l[0]);else{if(2!==l[0].length)return!1;var c=(new Date).getFullYear();r=((Number(l[0])-c+70)%100+200)%100+c-70}return s(r)?1===l.length?new Date(r,0,1).getTime():(n=Number(l[1])-1,l[1].length>2||!(n>=0&&11>=n)?!1:2===l.length?new Date(r,n,1).getTime():(i=Number(l[2]),l[2].length>2||!(i>=1&&31>=i)?!1:(i=new Date(r,n,i).getTime(),o[1]?(l=o[1].split(":"),l.length>3?!1:(a=Number(l[0]),l[0].length>2||!(a>=0&&23>=a)?!1:(i+=36e5*a,1===l.length?i:(n=Number(l[1]),l[1].length>2||!(n>=0&&59>=n)?!1:(i+=6e4*n,2===l.length?i:(t=Number(l[2]),t>=0&&60>t?i+1e3*t:!1)))))):i))):!1},r.isDateTime=function(t){return r.dateTime2ms(t)!==!1},r.ms2DateTime=function(t,e){if("undefined"==typeof o)return void l.error("d3 is not defined.");e||(e=0);var r=new Date(t),i=o.time.format("%Y-%m-%d")(r);return 7776e6>e?(i+=" "+n(r.getHours(),2),432e6>e&&(i+=":"+n(r.getMinutes(),2),108e5>e&&(i+=":"+n(r.getSeconds(),2),3e5>e&&(i+="."+n(r.getMilliseconds(),3)))),i.replace(/([:\s]00)*\.?[0]*$/,"")):i};var c={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},u={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},f=o.time.format.utc,h={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(f),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(f)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(f)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){u[t].forEach(function(e){h[t].D.push(f(e)),["H","I","D"].forEach(function(r){c[r].forEach(function(n){var i=h[t][r];i.push(f(e+"~"+n)),i.push(f(n+"~"+e))})})})});var d=/[a-z]*/g,p=function(t){return t.substr(0,3)},g=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,v=/[\s,\/\-\.\(\)]+/g,m=/~?([ap])~?m(~|$)/,y=function(t,e){return e+"m "},b=/\d\d\d\d/,x=/(^|~)[a-z]{3}/,_=/[ap]m/,w=/:/,k=/q([1-4])/,A=["31~mar","30~jun","30~sep","31~dec"],M=function(t,e){return A[e-1]},T=/ ?([+\-]\d\d:?\d\d|Z)$/;r.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(d,p).replace(g,"").replace(v,"~").replace(m,y).replace(k,M).trim().replace(T,"");var e,r,n=null,o=i(t),s=a(t);e=h[o][s],r=e.length;for(var l=0;r>l&&!(n=e[l].parse(t));l++);if(!(n instanceof Date))return!1;var c=n.getTimezoneOffset();return n.setTime(n.getTime()+60*c*1e3),n}},{"../lib":382,d3:113,"fast-isnumeric":117}],376:[function(t,e,r){"use strict";var n=t("events").EventEmitter,i={init:function(t){if(t._ev instanceof n)return t;var e=new n;return t._ev=e,t.on=e.on.bind(e),t.once=e.once.bind(e),t.removeListener=e.removeListener.bind(e),t.removeAllListeners=e.removeAllListeners.bind(e),t.emit=function(r,n){"undefined"!=typeof jQuery&&jQuery(t).trigger(r,n),e.emit(r,n)},t},triggerHandler:function(t,e,r){var n,i;"undefined"!=typeof jQuery&&(n=jQuery(t).triggerHandler(e,r));var a=t._ev;if(!a)return n;var o=a._events[e];if(!o)return n;"function"==typeof o&&(o=[o]);for(var s=o.pop(),l=0;lp;p++){o=t[p];for(s in o)l=h[s],c=o[s],e&&c&&(i(c)||(u=a(c)))?(u?(u=!1,f=l&&a(l)?l:[]):f=l&&i(l)?l:{},h[s]=n([f,c],e,r)):("undefined"!=typeof c||r)&&(h[s]=c)}return h}var i=t("./is_plain_object.js"),a=Array.isArray;r.extendFlat=function(){return n(arguments,!1,!1)},r.extendDeep=function(){return n(arguments,!0,!1)},r.extendDeepAll=function(){return n(arguments,!0,!0)}},{"./is_plain_object.js":383}],378:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=0;ry;y++)f=s(p,y),d=l(e,y),m[y]=n(f,d);else m=n(p,e);return m}var s=t("tinycolor2"),l=t("fast-isnumeric"),c=t("../components/colorscale/make_scale_function"),u=t("../components/color/attributes").defaultLine,f=t("./str2rgbarray"),h=1;e.exports=o},{"../components/color/attributes":302,"../components/colorscale/make_scale_function":320,"./str2rgbarray":394,"fast-isnumeric":117,tinycolor2:274}],381:[function(t,e,r){"use strict";function n(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(e>r)break;t=t.slice(0,e)+l(t.slice(e+5,r))+t.slice(r+6); -}return t}function i(t){return t.replace(/\/g,"\n")}function a(t){return t.replace(/\<.*\>/g,"")}function o(t){for(var e=0;(e=t.indexOf("&",e))>=0;){var r=t.indexOf(";",e);if(e>r)e+=1;else{var n=c[t.slice(e+1,r)];t=n?t.slice(0,e)+n+t.slice(r+1):t.slice(0,e)+t.slice(r+1)}}return t}function s(t){return""+o(a(n(i(t))))}var l=t("superscript-text"),c={mu:"\u03bc",amp:"&",lt:"<",gt:">"};e.exports=s},{"superscript-text":263}],382:[function(t,e,r){"use strict";var n=t("d3"),i=e.exports={};i.nestedProperty=t("./nested_property"),i.isPlainObject=t("./is_plain_object");var a=t("./coerce");i.valObjects=a.valObjects,i.coerce=a.coerce,i.coerce2=a.coerce2,i.coerceFont=a.coerceFont;var o=t("./dates");i.dateTime2ms=o.dateTime2ms,i.isDateTime=o.isDateTime,i.ms2DateTime=o.ms2DateTime,i.parseDate=o.parseDate;var s=t("./search");i.findBin=s.findBin,i.sorterAsc=s.sorterAsc,i.sorterDes=s.sorterDes,i.distinctVals=s.distinctVals,i.roundUp=s.roundUp;var l=t("./stats");i.aggNums=l.aggNums,i.len=l.len,i.mean=l.mean,i.variance=l.variance,i.stdev=l.stdev,i.interp=l.interp;var c=t("./matrix");i.init2dArray=c.init2dArray,i.transposeRagged=c.transposeRagged,i.dot=c.dot,i.translationMatrix=c.translationMatrix,i.rotationMatrix=c.rotationMatrix,i.rotationXYMatrix=c.rotationXYMatrix,i.apply2DTransform=c.apply2DTransform,i.apply2DTransform2=c.apply2DTransform2;var u=t("./extend");i.extendFlat=u.extendFlat,i.extendDeep=u.extendDeep,i.extendDeepAll=u.extendDeepAll;var f=t("./loggers");i.log=f.log,i.warn=f.warn,i.error=f.error,i.notifier=t("./notifier"),i.swapAttrs=function(t,e,r,n){r||(r="x"),n||(n="y");for(var a=0;ar?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},i.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},i.identity=function(t){return t},i.randstr=function h(t,e,r){if(r||(r=16),void 0===e&&(e=24),0>=e)return"0";var n,i,a,o=Math.log(Math.pow(2,e))/Math.log(r),s="";for(n=2;o===1/0;n*=2)o=Math.log(Math.pow(2,e/n))/Math.log(r)*n;var l=o-Math.floor(o);for(n=0;n-1||c!==1/0&&c>=Math.pow(2,e)?h(t,e,r):s},i.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={};return r.optionList=[],r._newoption=function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)},r["_"+e]=t,r},i.smooth=function(t,e){if(e=Math.round(e)||0,2>e)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,c=new Array(l),u=new Array(o);for(r=0;l>r;r++)c[r]=(1-Math.cos(Math.PI*(r+1)/e))/(2*e);for(r=0;o>r;r++){for(a=0,n=0;l>n;n++)i=r+n+1-e,-o>i?i-=s*Math.round(i/s):i>=s&&(i-=s*Math.floor(i/s)),0>i?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*c[n];u[r]=a}return u},i.syncOrAsync=function(t,e,r){function n(){return i.syncOrAsync(t,e,r)}for(var a,o;t.length;)if(o=t.splice(0,1)[0],a=o(e),a&&a.then)return a.then(n).then(void 0,i.promiseError);return r&&r(e)},i.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},i.noneOrAll=function(t,e,r){if(t){var n,i,a=!1,o=!0;for(n=0;ni;i++)e[i][r]=t[i]},i.minExtend=function(t,e){var r={};"object"!=typeof e&&(e={});var n,a,o,s=3,l=Object.keys(t);for(n=0;n1?n+a[1]:"";if(i&&(a.length>1||o.length>4))for(;r.test(o);)o=o.replace(r,"$1"+i+"$2");return o+s}},{"./coerce":374,"./dates":375,"./extend":377,"./is_plain_object":383,"./loggers":384,"./matrix":385,"./nested_property":386,"./notifier":387,"./search":390,"./stats":393,d3:113}],383:[function(t,e,r){"use strict";e.exports=function(t){return"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],384:[function(t,e,r){"use strict";var n=t("../plot_api/plot_config"),i=e.exports={};i.log=function(){if(n.logging>1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;en;n++)r[n]=new Array(e);return r},r.transposeRagged=function(t){var e,r,n=0,i=t.length;for(e=0;i>e;e++)n=Math.max(n,t[e].length);var a=new Array(n);for(e=0;n>e;e++)for(a[e]=new Array(i),r=0;i>r;r++)a[e][r]=t[r][e];return a},r.dot=function(t,e){if(!t.length||!e.length||t.length!==e.length)return null;var n,i,a=t.length;if(t[0].length)for(n=new Array(a),i=0;a>i;i++)n[i]=r.dot(t[i],e);else if(e[0].length){var o=r.transposeRagged(e);for(n=new Array(o.length),i=0;ii;i++)n+=t[i]*e[i];return n},r.translationMatrix=function(t,e){return[[1,0,t],[0,1,e],[0,0,1]]},r.rotationMatrix=function(t){var e=t*Math.PI/180;return[[Math.cos(e),-Math.sin(e),0],[Math.sin(e),Math.cos(e),0],[0,0,1]]},r.rotationXYMatrix=function(t,e,n){return r.dot(r.dot(r.translationMatrix(e,n),r.rotationMatrix(t)),r.translationMatrix(-e,-n))},r.apply2DTransform=function(t){return function(){var e=arguments;3===e.length&&(e=e[0]);var n=1===arguments.length?e[0]:[e[0],e[1]];return r.dot(t,[n[0],n[1],1]).slice(0,2)}},r.apply2DTransform2=function(t){var e=r.apply2DTransform(t);return function(t){return e(t.slice(0,2)).concat(e(t.slice(2,4)))}}},{}],386:[function(t,e,r){"use strict";function n(t,e){return function(){var r,i,a,o,s,l=t;for(o=0;o=0;e--){if(n=t[e],o=!1,Array.isArray(n))for(r=n.length-1;r>=0;r--)c(n[r])?o?n[r]=void 0:n.pop():o=!0;else if("object"==typeof n&&null!==n)for(a=Object.keys(n),o=!1,r=a.length-1;r>=0;r--)c(n[a[r]])&&!i(n[a[r]],a[r])?delete n[a[r]]:o=!0;if(o)return}}function c(t){return void 0===t||null===t?!0:"object"!=typeof t?!1:Array.isArray(t)?!t.length:!Object.keys(t).length}function u(t,e,r){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:r,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,l=e.split(".");sr||r>a||o>n||n>s?!1:!e||!c(t)}function r(t,e){var r=t[0],l=t[1];if(i>r||r>a||o>l||l>s)return!1;var c,u,f,h,d,p=n.length,g=n[0][0],v=n[0][1],m=0;for(c=1;p>c;c++)if(u=g,f=v,g=n[c][0],v=n[c][1],h=Math.min(u,g),!(h>r||r>Math.max(u,g)||l>Math.max(f,v)))if(l=l&&r!==h&&m++}return m%2===1}var n=t.slice(),i=n[0][0],a=i,o=n[0][1],s=o;n.push(n[0]);for(var l=1;la;a++)if(o=[t[a][0]-l[0],t[a][1]-l[1]],s=n(o,c),0>s||s>u||Math.abs(n(o,h))>i)return!0;return!1};i.filter=function(t,e){function r(r){t.push(r);var s=n.length,l=i;n.splice(o+1);for(var c=l+1;c1){var s=t.pop();r(s)}return{addPt:r,raw:t,filtered:n}}},{"./matrix":385}],389:[function(t,e,r){"use strict";function n(t,e){for(var r,n=[],a=0;a=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;rt}function i(t,e){return e>=t}function a(t,e){return t>e}function o(t,e){return t>=e}var s=t("fast-isnumeric"),l=t("../lib");r.findBin=function(t,e,r){if(s(e.start))return r?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var c,u,f=0,h=e.length,d=0;for(u=e[e.length-1]>=e[0]?r?n:i:r?o:a;h>f&&d++<100;)c=Math.floor((f+h)/2),u(e[c],t)?f=c+1:h=c;return d>90&&l.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;n>s;s++)e[s+1]>e[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,c=r?Math.ceil:Math.floor;a>i&&o++<100;)n=c((i+a)/2),e[n]<=t?i=n+s:a=n-l;return e[i]}},{"../lib":382,"fast-isnumeric":117}],391:[function(t,e,r){"use strict";e.exports=function(t,e){(t.attr("class")||"").split(" ").forEach(function(e){0===e.indexOf("cursor-")&&t.classed(e,!1)}),e&&t.classed("cursor-"+e,!0)}},{}],392:[function(t,e,r){"use strict";var n=t("../components/color"),i=function(){};e.exports=function(t){for(var e in t)"function"==typeof t[e]&&(t[e]=i);t.destroy=function(){t.container.parentNode.removeChild(t.container)};var r=document.createElement("div");return r.textContent="Webgl is not supported by your browser - visit http://get.webgl.org for more info",r.style.cursor="pointer",r.style.fontSize="24px",r.style.color=n.defaults[0],t.container.appendChild(r),t.container.style.background="#FFFFFF",t.container.onclick=function(){window.open("http://get.webgl.org")},!1}},{"../components/color":303}],393:[function(t,e,r){"use strict";var n=t("fast-isnumeric");r.aggNums=function(t,e,i,a){var o,s;if(a||(a=i.length),n(e)||(e=!1),Array.isArray(i[0])){for(s=new Array(a),o=0;a>o;o++)s[o]=r.aggNums(t,e,i[o]);i=s}for(o=0;a>o;o++)n(e)?n(i[o])&&(e=t(+e,+i[o])):e=i[o];return e},r.len=function(t){return r.aggNums(function(t){return t+1},0,t)},r.mean=function(t,e){return e||(e=r.len(t)),r.aggNums(function(t,e){return t+e},0,t)/e},r.variance=function(t,e,i){return e||(e=r.len(t)),n(i)||(i=r.mean(t,e)),r.aggNums(function(t,e){return t+Math.pow(e-i,2)},0,t)/e},r.stdev=function(t,e,n){return Math.sqrt(r.variance(t,e,n))},r.interp=function(t,e){if(!n(e))throw"n should be a finite number";if(e=e*t.length-.5,0>e)return t[0];if(e>t.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"fast-isnumeric":117}],394:[function(t,e,r){"use strict";function n(t){return t=i(t),a.str2RgbaArray(t.toRgbString())}var i=t("tinycolor2"),a=t("arraytools");e.exports=n},{arraytools:49,tinycolor2:274}],395:[function(t,e,r){"use strict";function n(t,e){return t.node().getBoundingClientRect()[e]}function i(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function a(t,e,r){var n="math-output-"+l.Lib.randstr([],64),a=c.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(i(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,a.node()],function(){var e=c.select("body").select("#MathJax_SVG_glyphs");if(a.select(".MathJax_SVG").empty()||!a.select("svg").node())u.log("There was an error in the tex syntax.",t),r();else{var n=a.select("svg").node().getBoundingClientRect();r(a.select(".MathJax_SVG"),e,n)}a.remove()})}function o(t){for(var e=l.util.html_entity_decode(t),r=e.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),r=e&&e[2].toLowerCase(),n=d[r];if(void 0!==n){var i=e[1],a=e[3],o=a.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===r){if(i)return"
";if("href"!==a.substr(0,4).toLowerCase())return"";var s=document.createElement("a");return s.href=a.substr(4).replace(/["'=]/g,""),-1===p.indexOf(s.protocol)?"":'"}if("br"===r)return"
";if(i)return"sup"===r?'':"sub"===r?'':"";var c=""}return l.util.xml_entity_encode(t).replace(/");i>0;i=r.indexOf("
",i+1))n.push(i);var a=0;n.forEach(function(t){for(var e=t+a,n=r.slice(0,e),i="",o=n.length-1;o>=0;o--){var s=n[o].match(/<(\/?).*>/i);if(s&&"
"!==n[o]){s[1]||(i=n[o]);break}}i&&(r.splice(e+1,0,i),r.splice(e,0,""),a+=2)});var o=r.join(""),s=o.split(/
/gi);return s.length>1&&(r=s.map(function(t,e){return''+t+""})),r.join("")}function s(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-c.top+"px",left:a()-c.left+"px","z-index":1e3}),this}}var l=t("../plotly"),c=t("d3"),u=t("../lib"),f=t("../constants/xmlns_namespaces"),h=e.exports={};c.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),r=(new DOMParser).parseFromString(e,"application/xml"),n=r.documentElement.firstChild;n;)this.node().appendChild(this.node().ownerDocument.importNode(n,!0)),n=n.nextSibling;return r.querySelector("parsererror")?(u.log(r.querySelector("parsererror div").textContent),null):c.select(this.node().lastChild)},h.html_entity_decode=function(t){var e=c.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),r},h.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},h.convertToTspans=function(t,e){function r(){d.empty()||(p=u.attr("class")+"-math",d.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),h=t.appendSVG(s),h||t.text(i),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(u)}var i=t.text(),s=o(i),u=t,f=!u.attr("data-notex")&&s.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),h=i,d=c.select(u.node().parentNode);if(!d.empty()){var p=u.attr("class")?u.attr("class").split(" ")[0]:"text";p+="-math",d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=l.Lib.getPlotDiv(u.node());(v&&v._promises||[]).push(new Promise(function(t){u.style({visibility:"hidden"});var i={fontSize:parseInt(u.style("font-size"),10)};a(f[2],i,function(i,a,o){d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove();var s=i&&i.select("svg");if(!s||!s.node())return r(),void t();var l=d.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});l.node().appendChild(s.node()),a&&a.node()&&s.node().insertBefore(a.node().cloneNode(!0),s.node().firstChild),s.attr({"class":p,height:o.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=u.style("fill")||"black";s.select("g").attr({fill:c,stroke:c});var f=n(s,"width"),h=n(s,"height"),g=+u.attr("x")-f*{start:0,middle:.5,end:1}[u.attr("text-anchor")||"start"],v=parseInt(u.style("font-size"),10)||n(u,"height"),m=-v/4;"y"===p[0]?(l.attr({transform:"rotate("+[-90,+u.attr("x"),+u.attr("y")]+") translate("+[-f/2,m-h/2]+")"}),s.attr({x:+u.attr("x"),y:+u.attr("y")})):"l"===p[0]?s.attr({x:u.attr("x"),y:m-h/2}):"a"===p[0]?s.attr({x:0,y:m}):s.attr({x:g,y:+u.attr("y")+m-h/2}),e&&e.call(u,l),t(l)})}))}else r();return t}};var d={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},p=["http:","https:","mailto:"],g=new RegExp("]*)?/?>","g");h.plainText=function(t){return(t||"").replace(g," ")},h.makeEditable=function(t,e,r){function n(){a(),o.style({opacity:0});var t,e=h.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0})}function i(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}function a(){var t=c.select(l.Lib.getPlotDiv(o.node())),e=t.select(".svg-container"),n=e.append("div");n.classed("plugin-editable editable",!0).style({position:"absolute","font-family":o.style("font-family")||"Arial","font-size":o.style("font-size")||12,color:r.fill||o.style("fill")||"black",opacity:1,"background-color":r.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(o.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(r.text||o.attr("data-unformatted")).call(s(o,e,r)).on("blur",function(){o.text(this.textContent).style({opacity:1});var t,e=c.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0});var r=this.textContent;c.select(this).transition().duration(0).remove(),c.select(document).on("mouseup",null),u.edit.call(o,r)}).on("focus",function(){var t=this;c.select(document).on("mouseup",function(){return c.event.target===t?!1:void(document.activeElement===n.node()&&n.node().blur())})}).on("keyup",function(){27===c.event.which?(o.style({opacity:1}),c.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),u.cancel.call(o,this.textContent)):(u.input.call(o,this.textContent),c.select(this).call(s(o,e,r)))}).on("keydown",function(){13===c.event.which&&this.blur()}).call(i)}r||(r={});var o=this,u=c.dispatch("edit","input","cancel"),f=c.select(this.node()).style({"pointer-events":"all"}),h=e||f;return e&&f.style({"pointer-events":"none"}),r.immediate?n():h.on("click",n),c.rebind(this,u,"on")}},{"../constants/xmlns_namespaces":370,"../lib":382,"../plotly":402,d3:113}],396:[function(t,e,r){"use strict";var n=e.exports={},i=t("../plots/geo/constants").locationmodeToLayer,a=t("topojson").feature;n.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},n.getTopojsonPath=function(t,e){return t+e+".json"},n.getTopojsonFeatures=function(t,e){var r=i[t.locationmode],n=e.objects[r];return a(e,n).features}},{"../plots/geo/constants":424,topojson:275}],397:[function(t,e,r){"use strict";function n(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function i(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function a(t,e){t._context||(t._context=R.extendFlat({},P.defaultConfig));var r=t._context;e&&(Object.keys(e).forEach(function(t){t in r&&("setBackground"===t&&"opaque"===e[t]?r[t]=i:r[t]=e[t])}),e.plot3dPixelRatio&&!r.plotGlPixelRatio&&(r.plotGlPixelRatio=r.plot3dPixelRatio)),r.staticPlot&&(r.editable=!1,r.autosizable=!1,r.scrollZoom=!1,r.doubleClick=!1,r.showTips=!1,r.showLink=!1,r.displayModeBar=!1)}function o(t,e,r){var n=S.select(t).selectAll(".plot-container").data([0]);n.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=n.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e),r&&(t.layout=r),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(w(t,{}),t._fullLayout.autosize=r.autosize=!0),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var a=t.framework.svg(),o=1,s=t._fullLayout.title;""!==s&&s||(o=0);var l="Click to enter title",c=function(){this.call(P.util.convertToTspans)},u=a.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":s}),s&&s!==l||(o=.2,u.attr({"data-unformatted":l}).text(l).style({opacity:o}).on("mouseover.opacity",function(){S.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){S.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),N.addLinks(t),Promise.resolve()}function s(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var n=P.Axes.list({_fullLayout:t});for(e=0;ee;e++){var o=t.annotations[e];o.ref&&("paper"===o.ref?(o.xref="paper",o.yref="paper"):"data"===o.ref&&(o.xref="x",o.yref="y"),delete o.ref),l(o,"xref"),l(o,"yref")}void 0===t.shapes||Array.isArray(t.shapes)||(R.warn("Shapes must be an array."),delete t.shapes);var s=(t.shapes||[]).length;for(e=0;s>e;e++){var c=t.shapes[e];l(c,"xref"),l(c,"yref")}var u=t.legend;u&&(u.x>3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var h=N.getSubplotIds(t,"gl3d");for(e=0;er;++r)b[r]=v[e]+m*y[2+4*r];d.camera={eye:{x:b[0],y:b[1],z:b[2]},center:{x:v[0],y:v[1],z:v[2]},up:{x:y[1],y:y[5],z:y[9]}},delete d.cameraposition}}return F.clean(t),t}function l(t,e){var r=t[e],n=e.charAt(0);r&&"paper"!==r&&(t[e]=P.Axes.cleanId(r,n))}function c(t,e){for(var r=[],n=(t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid})),i=0;ia&&(s=R.randstr(n),-1!==r.indexOf(s));a++);o.uid=R.randstr(n),n.push(o.uid)}if(r.push(o.uid),"histogramy"===o.type&&"xbins"in o&&!("ybins"in o)&&(o.ybins=o.xbins,delete o.xbins),o.error_y&&"opacity"in o.error_y){var l=F.defaults,c=o.error_y.color||(N.traceIs(o,"bar")?F.defaultLine:l[i%l.length]);o.error_y.color=F.addOpacity(F.rgb(c),F.opacity(c)*o.error_y.opacity),delete o.error_y.opacity}if("bardir"in o&&("h"!==o.bardir||!N.traceIs(o,"bar")&&"histogram"!==o.type.substr(0,9)||(o.orientation="h",x(o)),delete o.bardir),"histogramy"===o.type&&x(o),"histogramx"!==o.type&&"histogramy"!==o.type||(o.type="histogram"),"scl"in o&&(o.colorscale=o.scl,delete o.scl),"reversescl"in o&&(o.reversescale=o.reversescl,delete o.reversescl),o.xaxis&&(o.xaxis=P.Axes.cleanId(o.xaxis,"x")),o.yaxis&&(o.yaxis=P.Axes.cleanId(o.yaxis,"y")),N.traceIs(o,"gl3d")&&o.scene&&(o.scene=N.subplotsRegistry.gl3d.cleanId(o.scene)),N.traceIs(o,"pie")||(Array.isArray(o.textposition)?o.textposition=o.textposition.map(u):o.textposition&&(o.textposition=u(o.textposition))),N.traceIs(o,"2dMap")&&("YIGnBu"===o.colorscale&&(o.colorscale="YlGnBu"),"YIOrRd"===o.colorscale&&(o.colorscale="YlOrRd")),N.traceIs(o,"markerColorscale")&&o.marker){var h=o.marker;"YIGnBu"===h.colorscale&&(h.colorscale="YlGnBu"),"YIOrRd"===h.colorscale&&(h.colorscale="YlOrRd")}if("surface"===o.type&&R.isPlainObject(o.contours)){var d=["x","y","z"];for(a=0;an?a.push(i+n):a.push(n);return a}function p(t,e,r){var n,i;for(n=0;n=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||0>i&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function g(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),p(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&p(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function v(t,e,r){var n,i;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),n=0;n=0&&l0){var s=_(t._boundingBoxMargins),l=s.left+s.right,c=s.bottom+s.top,u=a._container.node().getBoundingClientRect(),f=1-2*o.frameMargins;i=Math.round(f*(u.width-l)),n=Math.round(f*(u.height-c))}else r=window.getComputedStyle(t),n=parseFloat(r.height)||a.height,i=parseFloat(r.width)||a.width;return Math.abs(a.width-i)>1||Math.abs(a.height-n)>1?(a.height=t.layout.height=n,a.width=t.layout.width=i):"initial"!==a.autosize&&(delete e.autosize,a.autosize=t.layout.autosize=!0),N.sanitizeMargins(a),e}function k(t){var e=S.select(t),r=t._fullLayout;if(r._container=e.selectAll(".plot-container").data([0]),r._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),r._paperdiv=r._container.selectAll(".svg-container").data([0]),r._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===r.autosize&&(w(t,{}),r.autosize=!0,t.layout.autosize=!0),r._glcontainer=r._paperdiv.selectAll(".gl-container").data([0]),r._glcontainer.enter().append("div").classed("gl-container",!0),r._geocontainer=r._paperdiv.selectAll(".geo-container").data([0]),r._geocontainer.enter().append("div").classed("geo-container",!0),r._paperdiv.selectAll(".main-svg").remove(),r._paper=r._paperdiv.insert("svg",":first-child").classed("main-svg",!0),r._toppaper=r._paperdiv.append("svg").classed("main-svg",!0),!r._uid){var n=[];S.selectAll("defs").each(function(){this.id&&n.push(this.id.split("-")[1])}),r._uid=R.randstr(n)}r._paperdiv.selectAll(".main-svg").attr(W.svgAttrs),r._defs=r._paper.append("defs").attr("id","defs-"+r._uid),r._topdefs=r._toppaper.append("defs").attr("id","topdefs-"+r._uid),r._draggers=r._paper.append("g").classed("draglayer",!0);var i=r._paper.append("g").classed("layer-below",!0);r._imageLowerLayer=i.append("g").classed("imagelayer",!0),r._shapeLowerLayer=i.append("g").classed("shapelayer",!0);var a=P.Axes.getSubplots(t);a.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,a),r._has("cartesian")&&M(t,a),r._ternarylayer=r._paper.append("g").classed("ternarylayer",!0);var o=r._paper.selectAll(".layer-subplot");r._imageSubplotLayer=o.selectAll(".imagelayer"),r._shapeSubplotLayer=o.selectAll(".shapelayer");var s=r._paper.append("g").classed("layer-above",!0);r._imageUpperLayer=s.append("g").classed("imagelayer",!0),r._shapeUpperLayer=s.append("g").classed("shapelayer",!0),r._pielayer=r._paper.append("g").classed("pielayer",!0),r._glimages=r._paper.append("g").classed("glimages",!0),r._geoimages=r._paper.append("g").classed("geoimages",!0),r._infolayer=r._toppaper.append("g").classed("infolayer",!0),r._zoomlayer=r._toppaper.append("g").classed("zoomlayer",!0),r._hoverlayer=r._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var l=R.syncOrAsync([T,function(){return P.Axes.doTicks(t,"redraw")},j.init],t);return l&&l.then&&t._promises.push(l),l}function A(t,e){function r(e,r){return function(){return P.Axes.getFromId(t,e,r)}}for(var n,i,a=t._fullLayout._plots={},o=0;o0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),A=w===_;x?t.framework===k&&!b&&A||(t.framework=k,k(t)):A?b&&k(t):(t.framework=k,k(t)),b&&P.Axes.saveRangeInitial(t);var M=t._fullLayout,E=!t.calcdata||t.calcdata.length!==(t.data||[]).length;E&&h(t);for(var L=0;LY.range[0]?[1,2]:[2,1]);else{var W=Y.range[0],Z=Y.range[1];"log"===O?(0>=W&&0>=Z&&i(q+".autorange",!0),0>=W?W=Z/1e6:0>=Z&&(Z=W/1e6),i(q+".range[0]",Math.log(W)/Math.LN10),i(q+".range[1]",Math.log(Z)/Math.LN10)):(i(q+".range[0]",Math.pow(10,W)),i(q+".range[1]",Math.pow(10,Z)))}else i(q+".autorange",!0)}if("reverse"===D)H.range?H.range.reverse():(i(q+".autorange",!0),H.range=[1,0]),G.autorange?_=!0:x=!0;else if("annotations"===z.parts[0]||"shapes"===z.parts[0]){var K=z.parts[1],$=z.parts[0],Q=p[$]||[],J=P[R.titleCase($)],tt=Q[K]||{};2===z.parts.length&&("add"===v[C]||R.isPlainObject(v[C])?E[C]="remove":"remove"===v[C]?-1===K?(E[$]=Q,delete E[C]):E[C]=tt:R.log("???",v)),!a(tt,"x")&&!a(tt,"y")||R.containsAny(C,["color","opacity","align","dash"])||(_=!0),J.draw(t,K,z.parts.slice(2).join("."),v[C]),delete v[C]}else if("images"===z.parts[0]){var rt=R.objectFromPath(C,O);R.extendDeepAll(t.layout,rt),U.supplyLayoutDefaults(t.layout,t._fullLayout),U.draw(t)}else if("mapbox"===z.parts[0]&&"layers"===z.parts[1]){R.extendDeepAll(t.layout,R.objectFromPath(C,O));var nt=(t._fullLayout.mapbox||{}).layers||[],it=z.parts[2]+1-nt.length;for(d=0;it>d;d++)nt.push({});x=!0}else 0===z.parts[0].indexOf("scene")?x=!0:0===z.parts[0].indexOf("geo")?x=!0:0===z.parts[0].indexOf("ternary")?x=!0:!g._has("gl2d")||-1===C.indexOf("axis")&&"plot_bgcolor"!==z.parts[0]?"hiddenlabels"===C?_=!0:-1!==z.parts[0].indexOf("legend")?m=!0:-1!==C.indexOf("title")?y=!0:-1!==z.parts[0].indexOf("bgcolor")?b=!0:z.parts.length>1&&R.containsAny(z.parts[1],["tick","exponent","grid","zeroline"])?y=!0:-1!==C.indexOf(".linewidth")&&-1!==C.indexOf("axis")?y=b=!0:z.parts.length>1&&-1!==z.parts[1].indexOf("line")?b=!0:z.parts.length>1&&"mirror"===z.parts[1]?y=b=!0:"margin.pad"===C?y=b=!0:"margin"===z.parts[0]||"autorange"===z.parts[1]||"rangemode"===z.parts[1]||"type"===z.parts[1]||"domain"===z.parts[1]||C.match(/^(bar|box|font)/)?_=!0:-1!==["hovermode","dragmode"].indexOf(C)?k=!0:-1===["hovermode","dragmode","height","width","autosize"].indexOf(C)&&(x=!0):x=!0,z.set(O)}I&&I.add(t,et,[t,E],et,[t,M]),v.autosize&&(v=w(t,v)),(v.height||v.width||v.autosize)&&(_=!0);var at=Object.keys(v),ot=[N.previousPromises];if(x||_)ot.push(function(){return t.layout=void 0,_&&(t.calcdata=void 0),P.plot(t,"",p)});else if(at.length&&(N.supplyDefaults(t),g=t._fullLayout,m&&ot.push(function(){return V.draw(t),N.previousPromises(t)}),b&&ot.push(T),y&&ot.push(function(){return P.Axes.doTicks(t,"redraw"),L(t),N.previousPromises(t)}),k)){var st;for(X(t),st=N.getSubplotIds(g,"gl3d"),d=0;d1)};c(r.width)&&c(r.height)||s(new Error("Height and width should be pixel values."));var u=n.clone(e,{format:"png",height:r.height,width:r.width}),f=u.td;f.style.position="absolute",f.style.left="-5000px",document.body.appendChild(f);var h=n.getRedrawFunc(f);a.plot(f,u.data,u.layout,u.config).then(h).then(l).then(function(e){t(e)}).catch(function(t){s(t)})});return s}var i=t("fast-isnumeric"),a=t("../plotly"),o=t("../lib");e.exports=n},{"../lib":382,"../plotly":402,"../snapshot":471,"fast-isnumeric":117}],402:[function(t,e,r){"use strict";t("es6-promise").polyfill(),r.Lib=t("./lib"),r.util=t("./lib/svg_text_utils"),r.Queue=t("./lib/queue"),t("../build/plotcss"),r.MathJaxConfig=t("./fonts/mathjax_config"),r.defaultConfig=t("./plot_api/plot_config");var n=r.Plots=t("./plots/plots");r.Axes=t("./plots/cartesian/axes"),r.Fx=t("./plots/cartesian/graph_interact"),r.micropolar=t("./plots/polar/micropolar"),r.Color=t("./components/color"),r.Drawing=t("./components/drawing"),r.Colorscale=t("./components/colorscale"),r.Colorbar=t("./components/colorbar"),r.ErrorBars=t("./components/errorbars"),r.Annotations=t("./components/annotations"),r.Shapes=t("./components/shapes"),r.Legend=t("./components/legend"),r.Images=t("./components/images"),r.ModeBar=t("./components/modebar"),r.register=function(t){if(!t)throw new Error("No argument passed to Plotly.register.");t&&!Array.isArray(t)&&(t=[t]);for(var e=0;ec&&u>e&&(void 0===i[r]?a[f]=T.tickText(t,e):a[f]=s(t,e,String(i[r])),f++);return f=864e5?t._tickround="d":r>=36e5?t._tickround="H":r>=6e4?t._tickround="M":r>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(r/2)/Math.LN10);else{b(r)||(r=Number(r.substr(1))),t._tickround=2-Math.floor(Math.log(r)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var n=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(n)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((n-1)/3):t._tickexponent=n)}else"M"===r.charAt(0)?t._tickround=2===r.length?"m":"y":t._tickround=null}function o(t,e){var r=t.match(U),n=new Date(e);if(r){var i=Math.min(+r[1]||6,6),a=String(e/1e3%1+2.0000005).substr(2,i).replace(/0+$/,"")||"0";return y.time.format(t.replace(U,a))(n)}return y.time.format(t)(n)}function s(t,e,r){var n=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}function l(t,e,r,n){var i,a=e.x,s=t._tickround,l=new Date(a),c="";r&&t.hoverformat?i=o(t.hoverformat,a):t.tickformat?i=o(t.tickformat,a):(n&&(b(s)?s+=2:s={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[s]),"y"===s?i=I(l):"m"===s?i=N(l):(a!==t._tmin||r||(c="
"+I(l)),"d"===s?i=j(l):"H"===s?i=F(l):(a!==t._tmin||r||(c="
"+j(l)+", "+I(l)),i=D(l),"M"!==s&&(i+=B(l),"S"!==s&&(i+=h(m(a/1e3,1),t,"none",r).substr(1)))))),e.text=i+c}function c(t,e,r,n,i){var a=t.dtick,o=e.x;if(!n||"string"==typeof a&&"L"===a.charAt(0)||(a="L3"),t.tickformat||"string"==typeof a&&"L"===a.charAt(0))e.text=h(Math.pow(10,o),t,i,n);else if(b(a)||"D"===a.charAt(0)&&m(o+.01,1)<.1)if(-1!==["e","E","power"].indexOf(t.exponentformat)){var s=Math.round(o);0===s?e.text=1:1===s?e.text="10":s>1?e.text="10"+s+"":e.text="10\u2212"+-s+"",e.fontSize*=1.25}else e.text=h(Math.pow(10,o),t,"","fakehover"),"D1"===a&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==a.charAt(0))throw"unrecognized dtick "+String(a);e.text=String(Math.round(Math.pow(10,m(o,1)))),e.fontSize*=.75}if("D1"===t.dtick){var l=String(e.text).charAt(0);"0"!==l&&"1"!==l||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(0>o?.5:.25)))}}function u(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r=""),e.text=String(r)}function f(t,e,r,n,i){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide"),e.text=h(e.x,t,i,n)}function h(t,e,r,n){var i=0>t,o=e._tickround,s=r||e.exponentformat||"B",l=e._tickexponent,c=e.tickformat;if(n){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:b(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};a(u),o=(Number(u._tickround)||0)+4,l=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return y.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-o)/2;if("none"===s&&(l=0),t=Math.abs(t),f>t)t="0",i=!1;else{if(t+=f,l&&(t*=Math.pow(10,-l),o+=l),0===o)t=String(Math.floor(t));else if(0>o){t=String(Math.round(t)),t=t.substr(0,t.length+o);for(var h=o;0>h;h++)t+="0"}else{t=String(t);var d=t.indexOf(".")+1;d&&(t=t.substr(0,d+o).replace(/\.?0+$/,""))}t=_.numSeparate(t,e._gd._fullLayout.separators)}if(l&&"hide"!==s){var p;p=0>l?"\u2212"+-l:"power"!==s?"+"+l:String(l),"e"===s||("SI"===s||"B"===s)&&(l>12||-15>l)?t+="e"+p:"E"===s?t+="E"+p:"power"===s?t+="×10"+p+"":"B"===s&&9===l?t+="B":"SI"!==s&&"B"!==s||(t+=V[l/3+5])}return i?"\u2212"+t:t}function d(t,e){var r,n,i=[];for(r=0;r1)for(n=1;n2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.getAutoRange=function(t){var e,r=[],n=t._min[0].val,i=t._max[0].val;for(e=1;e0&&u>0&&f/u>h&&(l=o,c=s,h=f/u);return n===i?r=d?[n+1,"normal"!==t.rangemode?0:n-1]:["normal"!==t.rangemode?0:n-1,n+1]:h&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode&&l.val>=0?l={val:0,pad:0}:"nonnegative"===t.rangemode&&(l.val-h*l.pad<0&&(l={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),h=(c.val-l.val)/(t._length-l.pad-c.pad)),r=[l.val-h*l.pad,c.val+h*c.pad],r[0]===r[1]&&(r=[r[0]-1,r[0]+1]),d&&r.reverse()),r},T.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=T.getAutoRange(t);var r=t._gd.layout[t._name];r||(t._gd.layout[t._name]=r={}),r!==t&&(r.range=t.range.slice(),r.autorange=t.autorange)}},T.saveRangeInitial=function(t,e){for(var r=T.list(t,"",!0),n=!1,i=0;ip&&(p=g/10),c=t.c2l(p),u=t.c2l(g),y&&(c=Math.min(0,c),u=Math.max(0,u)),n(c)){for(d=!0,o=0;o=h?d=!1:s.val>=c&&s.pad<=h&&(t._min.splice(o,1),o--);d&&t._min.push({val:c,pad:y&&0===c?0:h})}if(n(u)){for(d=!0,o=0;o=u&&s.pad>=f?d=!1:s.val<=u&&s.pad<=f&&(t._max.splice(o,1),o--);d&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),r||(r={}),t._m||t.setScale();var a,o,s,l,c,u,f,h,d,p,g,v=e.length,m=r.padded?.05*t._length:0,y=r.tozero&&("linear"===t.type||"-"===t.type),x=n((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),_=n((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),w=n(r.vpadplus||r.vpad),k=n(r.vpadminus||r.vpad);for(a=0;6>a;a++)i(a);for(a=v-1;a>5;a--)i(a)}},T.autoBin=function(t,e,r,n){function i(t){return(1+100*(t-d)/f.dtick)%100<2}var a=_.aggNums(Math.min,null,t),o=_.aggNums(Math.max,null,t);if("category"===e.type)return{start:a-.5,end:o+.5,size:1};var s;if(r)s=(o-a)/r;else{var l=_.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(l.minDiff)/Math.LN10)),u=c*_.roundUp(l.minDiff/c,[.9,1.9,4.9,9.9],!0);s=Math.max(u,2*_.stdev(t)/Math.pow(t.length,n?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[a,o]};T.autoTicks(f,s);var h,d=T.tickIncrement(T.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;yg&&(p>.3*x||i(a)||i(o))){var w=f.dtick/2;d+=a>d+w?w:-w}var k=1+Math.floor((o-d)/f.dtick);h=d+k*f.dtick}else for(h=d;o>=h;)h=T.tickIncrement(h,f.dtick);return{start:d,end:h,size:f.dtick}},T.calcTicks=function(t){if("array"===t.tickmode)return n(t);if("auto"===t.tickmode||!t.dtick){var e,r=t.nticks;r||("category"===t.type?(e=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/e):(e="y"===t._id.charAt(0)?40:80,r=_.constrain(t._length/e,4,9)+1)),T.autoTicks(t,Math.abs(t.range[1]-t.range[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),a(t),t._tmin=T.tickFirst(t);var i=t.range[1]=s:s>=l)&&(o.push(l),!(o.length>1e3));l=T.tickIncrement(l,t.dtick,i));t._tmax=o[o.length-1];for(var c=new Array(o.length),u=0;u157788e5?(e/=315576e5,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*i(e,r,S)):e>12096e5?(e/=26298e5,t.dtick="M"+i(e,1,C)):e>432e5?(t.dtick=i(e,864e5,P),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=i(e,36e5,C):e>3e4?t.dtick=i(e,6e4,z):e>500?t.dtick=i(e,1e3,z):(r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,S));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var n=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/n,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+i(e,r,S)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,S));if(0===t.dtick&&(t.dtick=1),!b(t.dtick)&&"string"!=typeof t.dtick){var a=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(a)}},T.tickIncrement=function(t,e,r){var n=r?-1:1;if(b(e))return t+n*e;var i=e.charAt(0),a=n*Number(e.substr(1));if("M"===i){var o=new Date(t);return o.setMonth(o.getMonth()+a)}if("L"===i)return Math.log(Math.pow(10,t)+a)/Math.LN10;if("D"===i){var s="D2"===e?O:R,l=t+.01*n,c=_.roundUp(m(l,1),s,r);return Math.floor(l)+Math.log(y.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.range[1]n:n>c;)c=T.tickIncrement(c,i,e);return c}if("L"===u)return Math.log(r((Math.pow(10,n)-a)/f)*f+a)/Math.LN10;if("D"===u){var h="D2"===i?O:R,d=_.roundUp(m(n,1),h,e);return Math.floor(n)+Math.log(y.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(i)};var I=y.time.format("%Y"),N=y.time.format("%b %Y"),j=y.time.format("%b %-d"),F=y.time.format("%b %-d %Hh"),D=y.time.format("%H:%M"),B=y.time.format(":%S"),U=/%(\d?)f/g;T.tickText=function(t,e,r){function n(n){var i;return void 0===n?!0:r?"none"===n:(i={first:t._tmin,last:t._tmax}[n],"all"!==n&&e!==i)}var i,a,o=s(t,e),h="array"===t.tickmode,d=r||h;if(h&&Array.isArray(t.ticktext)){var p=Math.abs(t.range[1]-t.range[0])/1e4;for(a=0;a1&&er&&(A=90),i(u,A)}c._lastangle=A}return o(e),e+" done"}function l(){c._boundingBox=r.node().getBoundingClientRect()}var u=r.selectAll("g."+C).data(L,S);if(!c.showticklabels||!b(n))return u.remove(),void o(e);var f,h,p,m,x;"x"===v?(x="bottom"===B?1:-1,f=function(t){return t.dx+I*x},m=n+(O+R)*x,h=function(t){return t.dy+m+t.fontSize*("bottom"===B?1:-.5)},p=function(t){return b(t)&&0!==t&&180!==t?0>t*x?"end":"start":"middle"}):(x="right"===B?1:-1,h=function(t){return t.dy+t.fontSize/2-I*x},f=function(t){return t.dx+n+(O+R+(90===Math.abs(c.tickangle)?t.fontSize/2:0))*x},p=function(t){return b(t)&&90===Math.abs(t)?"middle":"right"===B?"start":"end"});var k=0,A=0,T=[];u.enter().append("g").classed(C,1).append("text").attr("text-anchor","middle").each(function(e){var r=y.select(this),n=t._promises.length;r.call(M.setPosition,f(e),h(e)).call(M.font,e.font,e.fontSize,e.fontColor).text(e.text).call(w.convertToTspans),n=t._promises[n],n?T.push(t._promises.pop().then(function(){i(r,c.tickangle)})):i(r,c.tickangle)}),u.exit().remove(),u.each(function(t){k=Math.max(k,t.fontSize)}),i(u,c._lastangle||c.tickangle);var E=_.syncOrAsync([a,s,l]);return E&&E.then&&t._promises.push(E),E}function o(e){if(!r){var n,i,a,o,s=E.getFromId(t,e),l=y.select(t).selectAll("g."+e+"tick"),c={selection:l,side:s.side},f=e.charAt(0),h=t._fullLayout._size,d=1.5,p=s.titlefont.size;if(l.size()){var g=y.select(l.node().parentNode).attr("transform").match(/translate\(([-\.\d]+),([-\.\d]+)\)/);g&&(c.offsetLeft=+g[1],c.offsetTop=+g[2])}"x"===f?(i="free"===s.anchor?{_offset:h.t+(1-(s.position||0))*h.h,_length:0}:E.getFromId(t,s.anchor),a=s._offset+s._length/2,o=i._offset+("top"===s.side?-10-p*(d+(s.showticklabels?1:0)):i._length+10+p*(d+(s.showticklabels?1.5:.5))),s.rangeslider&&s.rangeslider.visible&&s._boundingBox&&(o+=(u.height-u.margin.b-u.margin.t)*s.rangeslider.thickness+s._boundingBox.height),c.side||(c.side="bottom")):(i="free"===s.anchor?{_offset:h.l+(s.position||0)*h.w,_length:0}:E.getFromId(t,s.anchor),o=s._offset+s._length/2,a=i._offset+("right"===s.side?i._length+10+p*(d+(s.showticklabels?1:.5)):-10-p*(d+(s.showticklabels?.5:0))),n={rotate:"-90",offset:0},c.side||(c.side="left")),k.draw(t,e+"title",{propContainer:s,propName:s._name+".title",dfltName:f.toUpperCase()+" axis",avoid:c,transform:n,attributes:{x:a,y:o,"text-anchor":"middle"}})}}function s(t,e){return t.visible!==!0||t.xaxis+t.yaxis!==e?!1:x.Plots.traceIs(t,"bar")&&t.orientation==={x:"h",y:"v"}[v]?!0:t.fill&&t.fill.charAt(t.fill.length-1)===v}function l(e,r,i){var a=e.gridlayer,o=e.zerolinelayer,l=e["hidegrid"+v]?[]:V,u=c._gridpath||"M0,0"+("x"===v?"v":"h")+r._length,f=a.selectAll("path."+z).data(c.showgrid===!1?[]:l,S);if(f.enter().append("path").classed(z,1).classed("crisp",1).attr("d",u).each(function(t){c.zeroline&&("linear"===c.type||"-"===c.type)&&Math.abs(t.x)g;g++){var y=c.mirrors[o._id+h[g]];"ticks"!==y&&"labels"!==y||(f[g]=!0)}return void 0!==n[2]&&(f[2]=!0),f.forEach(function(t,e){var r=n[e],i=U[e];t&&b(r)&&(d+=p(r+R*i,i*c.ticklen))}),i(r,d),l(e,o,t),a(r,n[3])}}).filter(function(t){return t&&t.then});return H.length?Promise.all(H):0},T.swap=function(t,e){for(var r=d(t,e),n=0;n2*n; -}function u(t){for(var e,r=Math.max(1,(t.length-1)/1e3),n=0,i=0,a=0;a2*n}var f=t("fast-isnumeric"),h=t("tinycolor2").mix,d=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),b=t("./tick_label_defaults"),x=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),A=t("./axis_ids");e.exports=function(t,e,r,i){function a(r,n){return d.coerce2(t,e,v,r,n)}var o=i.letter,s=i.font||{},l="Click to enter "+(i.title||o.toUpperCase()+" axis")+" title";i.name&&(e._name=i.name,e._id=A.name2id(i.name));var c=r("type");"-"===c&&(n(e,i.data),"-"===e.type?e.type="linear":c=t.type=e.type),_(e);var u=r("color"),p=u===t.color?u:s.color;r("title",l),d.coerceFont(r,"titlefont",{family:s.family,size:Math.round(1.2*s.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),M=r("autorange",!k);M&&r("rangemode");var T=r("range",[-1,"x"===o?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),d.noneOrAll(t.range,e.range,[0,1]),r("fixedrange"),m(t,e,r,c),b(t,e,r,c,i),y(t,e,r,i),x(t,e,r);var E=a("linecolor",u),L=a("linewidth"),S=r("showline",!!E||!!L);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&r("mirror");var C=a("gridcolor",h(u,i.bgColor,g).toRgbString()),z=a("gridwidth"),P=r("showgrid",i.showGrid||!!C||!!z);P||(delete e.gridcolor,delete e.gridwidth);var R=a("zerolinecolor",u),O=a("zerolinewidth"),I=r("zeroline",i.showGrid||!!R||!!O);return I||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===c?w(o,e.categoryorder,e.categoryarray,i.data):[],e}},{"../../components/color/attributes":302,"../../lib":382,"../plots":454,"./axis_ids":407,"./category_order_defaults":408,"./clean_datum":409,"./layout_attributes":414,"./ordered_categories":416,"./set_convert":419,"./tick_label_defaults":420,"./tick_mark_defaults":421,"./tick_value_defaults":422,"fast-isnumeric":117,tinycolor2:274}],407:[function(t,e,r){"use strict";function n(t,e,r){function n(t,r){for(var n=Object.keys(t),i=/^[xyz]axis[0-9]*/,a=[],o=0;o0;a&&(n="array");var o=r("categoryorder",n);"array"===o&&r("categoryarray"),a||"array"!==o||(e.categoryorder="trace")}}},{}],409:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return i.ms2DateTime(t);if("string"!=typeof t&&!n(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){i.error(e,t)}return t}},{"../../lib":382,"fast-isnumeric":117}],410:[function(t,e,r){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5,REDRAWDELAY:50}},{}],411:[function(t,e,r){"use strict";function n(t,e){var r,n=t.range[e],i=Math.abs(n-t.range[1-e]);return"date"===t.type?c.ms2DateTime(n,i):"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,o.format("."+r+"g")(Math.pow(10,n))):(r=Math.floor(Math.log(Math.abs(n))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,o.format("."+String(r)+"g")(n))}function i(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function a(t){o.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var o=t("d3"),s=t("tinycolor2"),l=t("../../plotly"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../components/color"),h=t("../../components/drawing"),d=t("../../lib/setcursor"),p=t("../../components/dragelement"),g=t("./axes"),v=t("./select"),m=t("./constants"),y=!0;e.exports=function(t,e,r,o,b,x,_,w){function k(t,e){for(var r=0;r.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+ht+", "+dt+")").attr("d",ot+"Z"),ut=ft.append("path").attr("class","zoombox-corners").style({fill:f.background,stroke:f.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+ht+", "+dt+")").attr("d","M0,0Z"),T();for(var a=0;ai?(lt="",it.r=it.l,it.t=it.b,ut.attr("d","M0,0Z")):(it.t=0,it.b=V,lt="x",ut.attr("d","M"+(it.l-.5)+","+(nt-H-.5)+"h-3v"+(2*H+1)+"h3ZM"+(it.r+.5)+","+(nt-H-.5)+"h3v"+(2*H+1)+"h-3Z")):!Z||i.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),ut.transition().style("opacity",1).duration(200),st=!0)}function L(t,e,r){var n,i,a;for(n=0;nzoom back out","long"),y=!1)))}function C(e,r){var i=1===(_+w).length;if(e)I();else if(2!==r||i){if(1===r&&i){var a=_?B[0]:D[0],o="s"===_||"w"===w?0:1,s=a._name+".range["+o+"]",c=n(a,o),f="left",h="middle";if(a.fixedrange)return;_?(h="n"===_?"top":"bottom","right"===a.side&&(f="right")):"e"===w&&(f="right"),J.call(u.makeEditable,null,{immediate:!0,background:j.paper_bgcolor,text:String(c),fill:a.tickfont?a.tickfont.color:"#444",horizontalAlign:f,verticalAlign:h}).on("edit",function(e){var r="category"===a.type?a.c2l(e):a.d2l(e);void 0!==r&&l.relayout(t,s,r)})}}else O()}function z(e){function r(t,e,r){if(!t.fixedrange){A(t.range);var n=t.range,i=n[0]+(n[1]-n[0])*e;t.range=[i+(n[0]-i)*r,i+(n[1]-i)*r]}}if(t._context.scrollZoom||j._enablescrollzoom){var n=t.querySelector(".plotly");if(!(n.scrollHeight-n.clientHeight>10||n.scrollWidth-n.clientWidth>10)){clearTimeout(gt);var i=-e.deltaY;if(isFinite(i)||(i=e.wheelDelta/10),!isFinite(i))return void c.log("Did not find wheel motion attributes: ",e);var a,o=Math.exp(-Math.min(Math.max(i,-20),20)/100),s=mt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-s.left)/s.width,u=pt[0]+pt[2]*l,f=(s.bottom-e.clientY)/s.height,h=pt[1]+pt[3]*(1-f);if(w){for(a=0;a=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function i(t,e,r){for(var i=1-e,a=0,o=0;o0;n--)r.push(e);return r}function i(t,e){for(var r=[],n=0;nT;T++){var E=a[T],L=d[E];if(L)A[T]=w.getFromId(t,L.xaxis._id),M[T]=w.getFromId(t,L.yaxis._id);else{var S=o[E]._subplot;A[T]=S.xaxis,M[T]=S.yaxis}}var C=e.hovermode||o.hovermode;if(-1===["x","y","closest"].indexOf(C)||!t.calcdata||t.querySelector(".zoombox")||t._dragging)return _.unhoverRaw(t,e);var z,P,R,O,I,N,j,F,D,B,U,V,q=[],H=[];if(Array.isArray(e))for(C="array",R=0;RG||G>X.width||0>Y||Y>X.height)return _.unhoverRaw(t,e)}else G="xpx"in e?e.xpx:A[0]._length/2,Y="ypx"in e?e.ypx:M[0]._length/2;if(z="xval"in e?n(a,e.xval):i(A,G),P="yval"in e?n(a,e.yval):i(M,Y),!g(z[0])||!g(P[0]))return v.warn("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var W=1/0;for(O=0;O1||-1!==N.hoverinfo.indexOf("name")?N.name:void 0,index:!1,distance:Math.min(W,k.MAXDIST),color:b.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},V=q.length,"array"===F){var Z=e[O];"pointNumber"in Z?(U.index=Z.pointNumber,F="closest"):(F="","xval"in Z&&(D=Z.xval,F="x"),"yval"in Z&&(B=Z.yval,F=F?"closest":"y"))}else D=z[j],B=P[j];if(N._module&&N._module.hoverPoints){var K=N._module.hoverPoints(U,D,B,F);if(K)for(var $,Q=0;QV&&(q.splice(0,V),W=q[0].distance)}if(0===q.length)return _.unhoverRaw(t,e);var J="y"===C&&H.length>1;q.sort(function(t,e){return t.distance-e.distance});var tt=b.combine(o.plot_bgcolor||b.background,o.paper_bgcolor),et={hovermode:C,rotateLabels:J,bgColor:tt,container:o._hoverlayer,outerContainer:o._paperdiv},rt=c(q,et);u(q,J?"xa":"ya"),f(rt,J);var nt=t._hoverdata,it=[];for(R=0;R128?"#000":b.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,r=u.textContent||"",r.length>15&&(r=r.substr(0,12)+"...")}void 0!==t.extraText&&(n+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(n+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(n+="y: "+t.yLabel+"
"),n+=(n?"z: ":"")+t.zLabel):M&&t[i+"Label"]===g?n=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(n=t.yLabel):n=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(n+=(n?"
":"")+t.text),""===n&&(""===r&&e.remove(),n=r);var f=e.select("text.nums").style("fill",c).call(x.setPosition,0,0).text(n).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(x.setPosition,0,0);var h=e.select("text.name"),v=0;r&&r!==n?(h.style("fill",l).text(r).call(x.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),h.selectAll("tspan.line").call(x.setPosition,0,0),v=h.node().getBoundingClientRect().width+2*P):(h.remove(),e.select("rect").remove()),e.select("path").style({fill:l,stroke:c});var m,k,E=f.node().getBoundingClientRect(),L=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),R=Math.abs(t.y1-t.y0),O=E.width+z+P+v;t.ty0=_-E.top,t.bx=E.width+2*P,t.by=E.height+2*P,t.anchor="start",t.txwidth=E.width,t.tx2width=v,t.offset=0,a?(t.pos=L,m=A>=S+R/2+O,k=S-R/2-O>=0,"top"!==t.idealAlign&&m||!k?m?(S+=R/2,t.anchor="start"):t.anchor="middle":(S-=R/2,t.anchor="end")):(t.pos=S,m=w>=L+C/2+O,k=L-C/2-O>=0,"left"!==t.idealAlign&&m||!k?m?(L+=C/2,t.anchor="start"):t.anchor="middle":(L-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&h.attr("text-anchor",t.anchor),e.attr("transform","translate("+L+","+S+")"+(a?"rotate("+T+")":""))}),S}function u(t,e){function r(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(.01>a)){if(-.01>i){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos>e.pmax-1&&(l.del=!0,c--);for(o=0;o=c);o++)if(l=t[o],l.pos=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos+l.dp+l.size>e.pmax&&(l.del=!0,c--)}}}for(var n,i,a,o,s,l,c,u=0,f=t.map(function(t,r){var n=t[e];return[{i:r,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===n._id.charAt(0)?L:1)/2,pmin:n._offset,pmax:n._offset+n._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(s=d.length-1;s>=0;s--)d[s].dp+=i;for(h.push.apply(h,d),f.splice(o+1,1),c=0,s=h.length-1;s>=0;s--)c+=h[s].dp;for(a=c/h.length,s=h.length-1;s>=0;s--)h[s].dp-=a;n=!1}else o++}f.forEach(r)}for(o=f.length-1;o>=0;o--){var v=f[o];for(s=v.length-1;s>=0;s--){var m=v[s],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var r=d.select(this);if(t.del)return void r.remove();var n="end"===t.anchor?-1:1,i=r.select("text.nums"),a={start:1,end:-1,middle:0}[t.anchor],o=a*(z+P),s=o+a*(t.txwidth+P),l=0,c=t.offset;"middle"===t.anchor&&(o-=t.tx2width/2,s-=t.tx2width/2),e&&(c*=-C,l=t.offset*S),r.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(n*z+l)+","+(z+c)+"v"+(t.by/2-z)+"h"+n*t.bx+"v-"+t.by+"H"+(n*z+l)+"V"+(c-z)+"Z"),i.call(x.setPosition,o+l,c+t.ty0-t.by/2+P).selectAll("tspan.line").attr({x:i.attr("x"),y:i.attr("y")}),t.tx2width&&(r.select("text.name, text.name tspan.line").call(x.setPosition,s+a*P+l,c+t.ty0-t.by/2+P),r.select("rect").call(x.setRect,s+(a-1)*t.tx2width/2+l,c-t.by/2-1,t.tx2width,t.by+2))})}function h(t,e,r){if(!e.target)return!1;if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}var d=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),b=t("../../components/color"),x=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),A=t("./dragbox"),M=e.exports={};M.unhover=_.unhover,M.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},M.supplyLayoutDefaults=function(t,e,r){function n(r,n){return v.coerce(t,e,M.layoutAttributes,r,n)}n("dragmode");var i;if(e._has("cartesian")){var a=e._isHoriz=M.isHoriz(r);i=a?"y":"x"}else i="closest";n("hovermode",i)},M.isHoriz=function(t){for(var e=!0,r=0;rt._lastHoverTime+k.HOVERMINTIME?(o(t,e,r),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){o(t,e,r),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},M.getDistanceFunction=function(t,e,r,n){return"closest"===t?n||a(e,r):"x"===t?e:r},M.getClosest=function(t,e,r){if(r.index!==!1)r.index>=0&&r.indext*e||0===t?k.MAXDIST*(.6-.3/Math.max(3,Math.abs(t-e))):1/0}},{"../../components/color":303,"../../components/dragelement":324,"../../components/drawing":326,"../../lib":382,"../../lib/events":376,"../../lib/svg_text_utils":395,"./axes":405,"./constants":410,"./dragbox":411,d3:113,"fast-isnumeric":117,tinycolor2:274}],413:[function(t,e,r){"use strict";var n=t("../plots"),i=t("./constants");r.name="cartesian",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex=i.idRegex,r.attrRegex=i.attrRegex,r.attributes=t("./attributes"),r.plot=function(t){function e(t,e){for(var r=[],n=0;nf[1]-.01&&(e.domain=[0,1]),i.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":382,"fast-isnumeric":117}],418:[function(t,e,r){"use strict";function n(t){return t._id}var i=t("../../lib/polygon"),a=t("../../components/color"),o=t("./axes"),s=t("./constants"),l=i.filter,c=i.tester,u=s.MINSELECT;e.exports=function(t,e,r,i,f){function h(t){var e="y"===t._id.charAt(0)?1:0;return function(r){return t.p2d(r[e])}}function d(t,e){return t-e}var p,g=i.gd._fullLayout._zoomlayer,v=i.element.getBoundingClientRect(),m=i.plotinfo.x()._offset,y=i.plotinfo.y()._offset,b=e-v.left,x=r-v.top,_=b,w=x,k="M"+b+","+x,A=i.xaxes[0]._length,M=i.yaxes[0]._length,T=i.xaxes.map(n),E=i.yaxes.map(n),L=i.xaxes.concat(i.yaxes);"lasso"===f&&(p=l([[b,x]],s.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",k+"Z");var C,z,P,R,O,I=g.append("path").attr("class","zoombox-corners").style({fill:a.background,stroke:a.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),N=[],j=i.gd,F=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(0>=e&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-3*u*Math.abs(n-i))}return o.BADNUM}function r(t){return Math.pow(10,t)}function c(t){return i(t)?Number(t):o.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?r:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,r=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var n=l.getFromId(t._gd,t.overlaying);t.domain=n.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;2>e;e++)i(t.range[e])||(t.range[e]=i(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=r.t+(1-t.domain[1])*r.h,t._length=r.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=r.l+t.domain[0]*r.w,t._length=r.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw a.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return i(e)?n.round(t._b+t._m*e,2):o.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,r){return t.l2p(t.c2l(e,r))},t.p2c=function(e){return t.l2c(t.p2l(e))},-1!==["linear","log","-"].indexOf(t.type))t.c2d=c,t.d2c=function(t){return t=s(t),i(t)?Number(t):o.BADNUM},t.d2l=function(e,r){return"log"===t.type?t.c2l(t.d2c(e),r):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return i(t)?a.ms2DateTime(t):o.BADNUM},t.d2c=function(t){return i(t)?Number(t):a.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(a.dateTime2ms);!i(t.range[0])&&i(f[0])&&(t.range[0]=f[0]),!i(t.range[1])&&i(f[1])&&(t.range[1]=f[1])}catch(h){a.error(h,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&-1===t._categories.indexOf(e)&&t._categories.push(e);var r=t._categories.indexOf(e);return-1===r?o.BADNUM:r},t.d2l=t.d2c);t.makeCalcdata=function(e,r){var n,i,a;if(r in e)for(n=e[r],i=new Array(n.length),a=0;an?"0":"1.0"}var r=this.framework,n=r.select("g.choroplethlayer"),i=r.select("g.scattergeolayer"),a=this.projection,o=this.path,s=this.clipAngle;r.selectAll("path.basepath").attr("d",o),r.selectAll("path.graticulepath").attr("d",o),n.selectAll("path.choroplethlocation").attr("d",o),n.selectAll("path.basepath").attr("d",o),i.selectAll("path.js-line").attr("d",o),null!==s?(i.selectAll("path.point").style("opacity",e).attr("transform",t),i.selectAll("text").style("opacity",e).attr("transform",t)):(i.selectAll("path.point").attr("transform",t),i.selectAll("text").attr("transform",t))}},{"../../components/color":303,"../../components/drawing":326,"../../constants/xmlns_namespaces":370,"../../lib/filter_visible":378,"../../lib/topojson_utils":396,"../../plots/cartesian/axes":405,"./constants":424,"./projections":432,"./set_scale":433,"./zoom":434,"./zoom_reset":435,d3:113,topojson:275}],426:[function(t,e,r){"use strict";var n=t("./geo"),i=t("../../plots/plots");r.name="geo",r.attr="geo",r.idRoot="geo",r.idRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"geo");void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var o=0;o=n}function a(t,e){for(var r=e[0],n=e[1],i=!1,a=0,o=t.length,s=o-1;o>a;s=a++){var l=t[a],c=l[0],u=l[1],f=t[s],h=f[0],d=f[1];u>n^d>n&&(h-c)*(n-u)/(d-u)+c>r&&(i=!i)}return i}function o(t){return t?t/Math.sin(t):1}function s(t){return t>1?P:-1>t?-P:Math.asin(t)}function l(t){return t>1?0:-1>t?z:Math.acos(t)}function c(t,e){var r=(2+P)*Math.sin(e);e/=2;for(var n=0,i=1/0;10>n&&Math.abs(i)>S;n++){var a=Math.cos(e);e-=i=(e+Math.sin(e)*(a+2)-r)/(2*a*(1+a))}return[2/Math.sqrt(z*(4+z))*t*(1+Math.cos(e)),2*Math.sqrt(z/(4+z))*Math.sin(e)]}function u(t,e){function r(r,n){var i=j(r/e,n);return i[0]*=t,i}return arguments.length<2&&(e=t),1===e?j:e===1/0?h:(r.invert=function(r,n){var i=j.invert(r/t,n);return i[0]*=e,i},r)}function f(){var t=2,e=N(u),r=e(t);return r.coefficient=function(r){return arguments.length?e(t=+r):t},r}function h(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function d(t,e){return[3*t/(2*z)*Math.sqrt(z*z/3-e*e),e]}function p(t,e){return[t,1.25*Math.log(Math.tan(z/4+.4*e))]}function g(t){return function(e){var r,n=t*Math.sin(e),i=30;do e-=r=(e+Math.sin(e)-n)/(1+Math.cos(e));while(Math.abs(r)>S&&--i>0);return e/2}}function v(t,e,r){function n(r,n){return[t*r*Math.cos(n=i(n)),e*Math.sin(n)]}var i=g(r);return n.invert=function(n,i){var a=s(i/e);return[n/(t*Math.cos(a)),s((2*a+Math.sin(2*a))/r)]},n}function m(t,e){var r=e*e,n=r*r;return[t*(.8707-.131979*r+n*(-.013791+n*(.003971*r-.001529*n))),e*(1.007226+r*(.015085+n*(-.044475+.028874*r-.005916*n)))]}function y(t,e){var r,n=Math.min(18,36*Math.abs(e)/z),i=Math.floor(n),a=n-i,o=(r=D[i])[0],s=r[1],l=(r=D[++i])[0],c=r[1],u=(r=D[Math.min(19,++i)])[0],f=r[1];return[t*(l+a*(u-o)/2+a*a*(u-2*l+o)/2),(e>0?P:-P)*(c+a*(f-s)/2+a*a*(f-2*c+s)/2)]}function b(t,e){return[t*Math.cos(e),e]}function x(t,e){var r=Math.cos(e),n=o(l(r*Math.cos(t/=2)));return[2*r*Math.sin(t)*n,Math.sin(e)*n]}function _(t,e){var r=x(t,e);return[(r[0]+t/P)/2,(r[1]+e)/2]}t.geo.project=function(t,e){var n=e.stream;if(!n)throw new Error("not yet supported");return(t&&w.hasOwnProperty(t.type)?w[t.type]:r)(t,n)};var w={Feature:e,FeatureCollection:function(t,r){return{type:"FeatureCollection",features:t.features.map(function(t){return e(t,r)})}}},k=[],A=[],M={point:function(t,e){k.push([t,e])},result:function(){var t=k.length?k.length<2?{type:"Point",coordinates:k[0]}:{type:"MultiPoint",coordinates:k}:null;return k=[],t}},T={lineStart:n,point:function(t,e){k.push([t,e])},lineEnd:function(){k.length&&(A.push(k),k=[])},result:function(){var t=A.length?A.length<2?{type:"LineString",coordinates:A[0]}:{type:"MultiLineString",coordinates:A}:null;return A=[],t}},E={polygonStart:n,lineStart:n,point:function(t,e){k.push([t,e])},lineEnd:function(){var t=k.length;if(t){do k.push(k[0].slice());while(++t<4);A.push(k),k=[]}},polygonEnd:n,result:function(){if(!A.length)return null;var t=[],e=[];return A.forEach(function(r){i(r)?t.push([r]):e.push(r)}),e.forEach(function(e){var r=e[0];t.some(function(t){return a(t[0],r)?(t.push(e),!0):void 0})||t.push([e])}),A=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},L={Point:M,MultiPoint:M,LineString:T,MultiLineString:T,Polygon:E,MultiPolygon:E,Sphere:E},S=1e-6,C=S*S,z=Math.PI,P=z/2,R=(Math.sqrt(z),z/180),O=180/z,I=t.geo.projection,N=t.geo.projectionMutator;t.geo.interrupt=function(e){function r(t,r){for(var n=0>r?-1:1,i=l[+(0>r)],a=0,o=i.length-1;o>a&&t>i[a][2][0];++a);var s=e(t-i[a][1][0],r);return s[0]+=e(i[a][1][0],n*r>n*i[a][0][1]?i[a][0][1]:r)[0],s}function n(){s=l.map(function(t){return t.map(function(t){var r,n=e(t[0][0],t[0][1])[0],i=e(t[2][0],t[2][1])[0],a=e(t[1][0],t[0][1])[1],o=e(t[1][0],t[1][1])[1];return a>o&&(r=a,a=o,o=r),[[n,a],[i,o]]})})}function i(){for(var e=1e-6,r=[],n=0,i=l[0].length;i>n;++n){var o=l[0][n],s=180*o[0][0]/z,c=180*o[0][1]/z,u=180*o[1][1]/z,f=180*o[2][0]/z,h=180*o[2][1]/z;r.push(a([[s+e,c+e],[s+e,u-e],[f-e,u-e],[f-e,h+e]],30))}for(var n=l[1].length-1;n>=0;--n){var o=l[1][n],s=180*o[0][0]/z,c=180*o[0][1]/z,u=180*o[1][1]/z,f=180*o[2][0]/z,h=180*o[2][1]/z;r.push(a([[f-e,h-e],[f-e,u+e],[s+e,u+e],[s+e,c-e]],30))}return{type:"Polygon",coordinates:[t.merge(r)]}}function a(t,e){for(var r,n,i,a=-1,o=t.length,s=t[0],l=[];++ac;++c)l.push([s[0]+c*n,s[1]+c*i]);s=r}return l.push(r),l}function o(t,e){return Math.abs(t[0]-e[0])n)],a=l[+(0>n)],c=0,u=i.length;u>c;++c){var f=i[c];if(f[0][0]<=t&&tS&&--i>0);return[t/(.8707+(a=n*n)*(-.131979+a*(-.013791+a*a*a*(.003971-.001529*a)))),n]},(t.geo.naturalEarth=function(){return I(m)}).raw=m;var D=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];D.forEach(function(t){t[1]*=1.0144}),y.invert=function(t,e){var r=e/P,n=90*r,i=Math.min(18,Math.abs(n/5)),a=Math.max(0,Math.floor(i));do{var o=D[a][1],s=D[a+1][1],l=D[Math.min(19,a+2)][1],c=l-o,u=l-2*s+o,f=2*(Math.abs(r)-s)/c,h=u/c,d=f*(1-h*f*(1-2*h*f));if(d>=0||1===a){n=(e>=0?5:-5)*(d+i);var p,g=50;do i=Math.min(18,Math.abs(n)/5),a=Math.floor(i),d=i-a,o=D[a][1],s=D[a+1][1],l=D[Math.min(19,a+2)][1],n-=(p=(e>=0?P:-P)*(s+d*(l-o)/2+d*d*(l-2*s+o)/2)-e)*O;while(Math.abs(p)>C&&--g>0);break}}while(--a>=0);var v=D[a][0],m=D[a+1][0],y=D[Math.min(19,a+2)][0];return[t/(m+d*(y-v)/2+d*d*(y-2*m+v)/2),n*R]},(t.geo.robinson=function(){return I(y)}).raw=y,b.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return I(b)}).raw=b,x.invert=function(t,e){if(!(t*t+4*e*e>z*z+S)){var r=t,n=e,i=25;do{var a,o=Math.sin(r),s=Math.sin(r/2),c=Math.cos(r/2),u=Math.sin(n),f=Math.cos(n),h=Math.sin(2*n),d=u*u,p=f*f,g=s*s,v=1-p*c*c,m=v?l(f*c)*Math.sqrt(a=1/v):a=0,y=2*m*f*s-t,b=m*u-e,x=a*(p*g+m*f*c*d),_=a*(.5*o*h-2*m*u*s),w=.25*a*(h*s-m*u*p*o),k=a*(d*c+m*g*f),A=_*w-k*x;if(!A)break;var M=(b*_-y*k)/A,T=(y*w-b*x)/A;r-=M,n-=T}while((Math.abs(M)>S||Math.abs(T)>S)&&--i>0);return[r,n]}},(t.geo.aitoff=function(){return I(x)}).raw=x,_.invert=function(t,e){var r=t,n=e,i=25;do{var a,o=Math.cos(n),s=Math.sin(n),c=Math.sin(2*n),u=s*s,f=o*o,h=Math.sin(r),d=Math.cos(r/2),p=Math.sin(r/2),g=p*p,v=1-f*d*d,m=v?l(o*d)*Math.sqrt(a=1/v):a=0,y=.5*(2*m*o*p+r/P)-t,b=.5*(m*s+n)-e,x=.5*a*(f*g+m*o*d*u)+.5/P,_=a*(h*c/4-m*s*p),w=.125*a*(c*p-m*s*f*h),k=.5*a*(u*d+m*g*o)+.5,A=_*w-k*x,M=(b*_-y*k)/A,T=(y*w-b*x)/A;r-=M,n-=T}while((Math.abs(M)>S||Math.abs(T)>S)&&--i>0);return[r,n]},(t.geo.winkel3=function(){return I(_)}).raw=_}e.exports=n},{}],433:[function(t,e,r){"use strict";function n(t,e){var r=t.projection,n=t.lonaxis,o=t.lataxis,l=t.domain,c=t.framewidth||0,u=e.w*(l.x[1]-l.x[0]),f=e.h*(l.y[1]-l.y[0]),h=n.range[0]+s,d=n.range[1]-s,p=o.range[0]+s,g=o.range[1]-s,v=n._fullRange[0]+s,m=n._fullRange[1]-s,y=o._fullRange[0]+s,b=o._fullRange[1]-s;r._translate0=[e.l+u/2,e.t+f/2];var x=d-h,_=g-p,w=[h+x/2,p+_/2],k=r._rotate;r._center=[w[0]+k[0],w[1]+k[1]];var A=function(e){function n(t){return Math.min(_*u/(t[1][0]-t[0][0]),_*f/(t[1][1]-t[0][1]))}var o,s,l,x,_=e.scale(),w=r._translate0,k=i(h,p,d,g),A=i(v,y,m,b);l=a(e,k),o=n(l),x=a(e,A),r._fullScale=n(x),e.scale(o),l=a(e,k),s=[w[0]-l[0][0]+c,w[1]-l[0][1]+c],r._translate=s,e.translate(s),l=a(e,k),t._isAlbersUsa||e.clipExtent(l),o=r.scale*o,r._scale=o,t._width=Math.round(l[1][0])+c,t._height=Math.round(l[1][1])+c,t._marginX=(u-Math.round(l[1][0]))/2,t._marginY=(f-Math.round(l[1][1]))/2};return A}function i(t,e,r,n){var i=(r-t)/4;return{type:"Polygon",coordinates:[[[t,e],[t,n],[t+i,n],[t+2*i,n],[t+3*i,n],[r,n],[r,e],[r-i,e],[r-2*i,e],[r-3*i,e],[t,e]]]}}function a(t,e){return o.geo.path().projection(t).bounds(e)}var o=t("d3"),s=t("./constants").clipPad;e.exports=n},{"./constants":424,d3:113}],434:[function(t,e,r){"use strict";function n(t,e){var r;return(r=e._isScoped?a:e._clipAngle?s:o)(t,e.projection)}function i(t,e){var r=e._fullScale;return _.behavior.zoom().translate(t.translate()).scale(t.scale()).scaleExtent([.5*r,100*r])}function a(t,e){function r(){_.select(this).style(A)}function n(){o.scale(_.event.scale).translate(_.event.translate),t.render()}function a(){_.select(this).style(M)}var o=t.projection,s=i(o,e);return s.on("zoomstart",r).on("zoom",n).on("zoomend",a),s}function o(t,e){function r(t){return v.invert(t)}function n(t){var e=v(r(t));return Math.abs(e[0]-t[0])>y||Math.abs(e[1]-t[1])>y}function a(){_.select(this).style(A),l=_.mouse(this),c=v.rotate(),u=v.translate(),f=c,h=r(l)}function o(){return d=_.mouse(this),n(l)?(m.scale(v.scale()),void m.translate(v.translate())):(v.scale(_.event.scale),v.translate([u[0],_.event.translate[1]]),h?r(d)&&(g=r(d),p=[f[0]+(g[0]-h[0]),c[1],c[2]],v.rotate(p),f=p):(l=d,h=r(l)),void t.render())}function s(){_.select(this).style(M)}var l,c,u,f,h,d,p,g,v=t.projection,m=i(v,e),y=2;return m.on("zoomstart",a).on("zoom",o).on("zoomend",s),m}function s(t,e){function r(t){m++||t({type:"zoomstart"})}function n(t){t({type:"zoom"})}function a(t){--m||t({type:"zoomend"})}var o,s=t.projection,d={r:s.rotate(),k:s.scale()},p=i(s,e),g=x(p,"zoomstart","zoom","zoomend"),m=0,y=p.on;return p.on("zoomstart",function(){_.select(this).style(A);var t=_.mouse(this),e=s.rotate(),i=e,a=s.translate(),m=c(e);o=l(s,t),y.call(p,"zoom",function(){var r=_.mouse(this);if(s.scale(d.k=_.event.scale),o){if(l(s,r)){s.rotate(e).translate(a);var c=l(s,r),p=f(o,c),y=v(u(m,p)),b=d.r=h(y,o,i);isFinite(b[0])&&isFinite(b[1])&&isFinite(b[2])||(b=i),s.rotate(b),i=b}}else t=r,o=l(s,t);n(g.of(this,arguments))}),r(g.of(this,arguments))}).on("zoomend",function(){_.select(this).style(M),y.call(p,"zoom",null),a(g.of(this,arguments))}).on("zoom.redraw",function(){t.render()}),_.rebind(p,g,"on")}function l(t,e){var r=t.invert(e);return r&&isFinite(r[0])&&isFinite(r[1])&&m(r)}function c(t){var e=.5*t[0]*w,r=.5*t[1]*w,n=.5*t[2]*w,i=Math.sin(e),a=Math.cos(e),o=Math.sin(r),s=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return[a*s*c+i*o*l,i*s*c-a*o*l,a*o*c+i*s*l,a*s*l-i*o*c]}function u(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=e[0],s=e[1],l=e[2],c=e[3];return[r*o-n*s-i*l-a*c,r*s+n*o+i*c-a*l,r*l-n*c+i*o+a*s,r*c+n*l-i*s+a*o]}function f(t,e){if(t&&e){var r=b(t,e),n=Math.sqrt(y(r,r)),i=.5*Math.acos(Math.max(-1,Math.min(1,y(t,e)))),a=Math.sin(i)/n;return n&&[Math.cos(i),r[2]*a,-r[1]*a,r[0]*a]}}function h(t,e,r){var n=g(e,2,t[0]);n=g(n,1,t[1]),n=g(n,0,t[2]-r[2]);var i,a,o=e[0],s=e[1],l=e[2],c=n[0],u=n[1],f=n[2],h=Math.atan2(s,o)*k,p=Math.sqrt(o*o+s*s);Math.abs(u)>p?(a=(u>0?90:-90)-h,i=0):(a=Math.asin(u/p)*k-h,i=Math.sqrt(p*p-u*u));var v=180-a-2*h,m=(Math.atan2(f,c)-Math.atan2(l,i))*k,y=(Math.atan2(f,c)-Math.atan2(l,-i))*k,b=d(r[0],r[1],a,m),x=d(r[0],r[1],v,y);return x>=b?[a,m,r[2]]:[v,y,r[2]]}function d(t,e,r,n){var i=p(r-t),a=p(n-e);return Math.sqrt(i*i+a*a)}function p(t){return(t%360+540)%360-180}function g(t,e,r){var n=r*w,i=t.slice(),a=0===e?1:0,o=2===e?1:2,s=Math.cos(n),l=Math.sin(n);return i[a]=t[a]*s-t[o]*l,i[o]=t[o]*s+t[a]*l,i}function v(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*k,Math.asin(Math.max(-1,Math.min(1,2*(t[0]*t[2]-t[3]*t[1]))))*k,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*k]}function m(t){var e=t[0]*w,r=t[1]*w,n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function y(t,e){for(var r=0,n=0,i=t.length;i>n;++n)r+=t[n]*e[n];return r}function b(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function x(t){for(var e=0,r=arguments.length,n=[];++ed;++d){for(e=c[d],r=t[this.scene[e]._name],n=/Click to enter .+ title/.test(r.title)?"":r.title,p=0;2>=p;p+=2)this.labelEnable[d+p]=!1,this.labels[d+p]=o(n),this.labelColor[d+p]=s(r.titlefont.color),this.labelFont[d+p]=r.titlefont.family,this.labelSize[d+p]=r.titlefont.size,this.labelPad[d+p]=this.getLabelPad(e,r),this.tickEnable[d+p]=!1,this.tickColor[d+p]=s((r.tickfont||{}).color),this.tickAngle[d+p]="auto"===r.tickangle?0:Math.PI*-r.tickangle/180,this.tickPad[d+p]=this.getTickPad(r),this.tickMarkLength[d+p]=0,this.tickMarkWidth[d+p]=r.tickwidth||0,this.tickMarkColor[d+p]=s(r.tickcolor),this.borderLineEnable[d+p]=!1,this.borderLineColor[d+p]=s(r.linecolor),this.borderLineWidth[d+p]=r.linewidth||0;u=this.hasSharedAxis(r),a=this.hasAxisInDfltPos(e,r)&&!u,l=this.hasAxisInAltrPos(e,r)&&!u,i=r.mirror||!1,f=u?-1!==String(i).indexOf("all"):!!i,h=u?"allticks"===i:-1!==String(i).indexOf("ticks"),a?this.labelEnable[d]=!0:l&&(this.labelEnable[d+2]=!0),a?this.tickEnable[d]=r.showticklabels:l&&(this.tickEnable[d+2]=r.showticklabels),(a||f)&&(this.borderLineEnable[d]=r.showline),(l||f)&&(this.borderLineEnable[d+2]=r.showline),(a||h)&&(this.tickMarkLength[d]=this.getTickMarkLength(r)),(l||h)&&(this.tickMarkLength[d+2]=this.getTickMarkLength(r)),this.gridLineEnable[d]=r.showgrid,this.gridLineColor[d]=s(r.gridcolor),this.gridLineWidth[d]=r.gridwidth,this.zeroLineEnable[d]=r.zeroline,this.zeroLineColor[d]=s(r.zerolinecolor),this.zeroLineWidth[d]=r.zerolinewidth}},l.hasSharedAxis=function(t){var e=this.scene,r=a.Plots.getSubplotIds(e.fullLayout,"gl2d"),n=a.Axes.findSubplotsWithAxis(r,t);return 0!==n.indexOf(e.id)},l.hasAxisInDfltPos=function(t,e){var r=e.side;return"xaxis"===t?"bottom"===r:"yaxis"===t?"left"===r:void 0},l.hasAxisInAltrPos=function(t,e){var r=e.side;return"xaxis"===t?"top"===r:"yaxis"===t?"right"===r:void 0},l.getLabelPad=function(t,e){var r=1.5,n=e.titlefont.size,i=e.showticklabels;return"xaxis"===t?"top"===e.side?-10+n*(r+(i?1:0)):-10+n*(r+(i?.5:0)):"yaxis"===t?"right"===e.side?10+n*(r+(i?1:.5)):10+n*(r+(i?.5:0)):void 0},l.getTickPad=function(t){return"outside"===t.ticks?10+t.ticklen:15},l.getTickMarkLength=function(t){if(!t.ticks)return 0;var e=t.ticklen;return"inside"===t.ticks?-e:e},e.exports=i},{"../../lib/html2unicode":381,"../../lib/str2rgbarray":394,"../../plotly":402}],438:[function(t,e,r){"use strict";var n=t("./scene2d"),i=t("../plots"),a=t("../../constants/xmlns_namespaces");r.name="gl2d",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex={x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},r.attrRegex={x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},r.attributes=t("../cartesian/attributes"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"gl2d"),o=0;or;++r){var n=t[r],i=e[r];if(n.length!==i.length)return!0;for(var a=0;ao;++o,--s)for(var l=0;r>l;++l)for(var c=0;4>c;++c){var u=i[4*(r*o+l)+c];i[4*(r*o+l)+c]=i[4*(r*s+l)+c],i[4*(r*s+l)+c]=u}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticPlot&&this.container.removeChild(a),p},m.computeTickMarks=function(){this.xaxis._length=this.glplot.viewBox[2]-this.glplot.viewBox[0],this.yaxis._length=this.glplot.viewBox[3]-this.glplot.viewBox[1];for(var t=[s.calcTicks(this.xaxis),s.calcTicks(this.yaxis)],e=0;2>e;++e)for(var r=0;rk;++k)w[k]=Math.min(w[k],a.bounds[k]),w[k+2]=Math.max(w[k+2],a.bounds[k+2])}var A;for(n=0;2>n;++n)w[n]>w[n+2]&&(w[n]=-1,w[n+2]=1),A=this[v[n]],A._length=y.viewBox[n+2]-y.viewBox[n],s.doAutoRange(A);y.ticks=this.computeTickMarks();var M=this.xaxis.range,T=this.yaxis.range;y.dataBox=[M[0],T[0],M[1],T[1]],y.merge(r),o.update(y),this.glplot.draw()},m.draw=function(){if(!this.stopped){requestAnimationFrame(this.redraw);var t=this.glplot,e=this.camera,r=e.mouseListener,n=this.fullLayout;this.cameraChanged();var i=r.x*t.pixelRatio,a=this.canvas.height-t.pixelRatio*r.y;if(e.boxEnabled&&"zoom"===n.dragmode)this.selectBox.enabled=!0,this.selectBox.selectBox=[Math.min(e.boxStart[0],e.boxEnd[0]),Math.min(e.boxStart[1],e.boxEnd[1]),Math.max(e.boxStart[0],e.boxEnd[0]),Math.max(e.boxStart[1],e.boxEnd[1])],t.setDirty();else{this.selectBox.enabled=!1;var o=n._size,s=this.xaxis.domain,c=this.yaxis.domain,u=t.pick(i/t.pixelRatio+o.l+s[0]*o.w,a/t.pixelRatio-(o.t+(1-c[1])*o.h));if(u&&n.hovermode){var f=u.object._trace.handlePick(u);if(f&&(!this.lastPickResult||this.lastPickResult.trace!==f.trace||this.lastPickResult.dataCoord[0]!==f.dataCoord[0]||this.lastPickResult.dataCoord[1]!==f.dataCoord[1])){var h=this.lastPickResult=f;this.spikes.update({center:u.dataCoord}),h.screenCoord=[((t.viewBox[2]-t.viewBox[0])*(u.dataCoord[0]-t.dataBox[0])/(t.dataBox[2]-t.dataBox[0])+t.viewBox[0])/t.pixelRatio,(this.canvas.height-(t.viewBox[3]-t.viewBox[1])*(u.dataCoord[1]-t.dataBox[1])/(t.dataBox[3]-t.dataBox[1])-t.viewBox[1])/t.pixelRatio];var d=h.hoverinfo;if("all"!==d){var p=d.split("+");-1===p.indexOf("x")&&(h.traceCoord[0]=void 0),-1===p.indexOf("y")&&(h.traceCoord[1]=void 0),-1===p.indexOf("z")&&(h.traceCoord[2]=void 0),-1===p.indexOf("text")&&(h.textLabel=void 0),-1===p.indexOf("name")&&(h.name=void 0)}l.loneHover({x:h.screenCoord[0],y:h.screenCoord[1],xLabel:this.hoverFormatter("xaxis",h.traceCoord[0]),yLabel:this.hoverFormatter("yaxis",h.traceCoord[1]),zLabel:h.traceCoord[2],text:h.textLabel,name:h.name,color:h.color},{container:this.svgContainer}),this.lastPickResult={dataCoord:u.dataCoord}}}else!u&&this.lastPickResult&&(this.spikes.update({}),this.lastPickResult=null,l.loneUnhover(this.svgContainer))}t.draw()}},m.hoverFormatter=function(t,e){if(void 0!==e){var r=this[t];return s.tickText(r,r.c2l(e),"hover").text}}},{"../../lib/html2unicode":381,"../../lib/show_no_webgl_msg":392,"../../plots/cartesian/axes":405,"../../plots/cartesian/graph_interact":412,"./camera":436,"./convert":437,"gl-plot2d":165,"gl-select-box":195,"gl-spikes2d":215}],440:[function(t,e,r){"use strict";function n(t,e){t=t||document.body,e=e||{};var r=[.01,1/0];"distanceLimits"in e&&(r[0]=e.distanceLimits[0],r[1]=e.distanceLimits[1]),"zoomMin"in e&&(r[0]=e.zoomMin),"zoomMax"in e&&(r[1]=e.zoomMax);var n=a({center:e.center||[0,0,0],up:e.up||[0,1,0],eye:e.eye||[0,0,10],mode:e.mode||"orbit",distanceLimits:r}),l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0,u=t.clientWidth,f=t.clientHeight,h={keyBindingMode:"rotate",view:n,element:t,delay:e.delay||16,rotateSpeed:e.rotateSpeed||1,zoomSpeed:e.zoomSpeed||1,translateSpeed:e.translateSpeed||1,flipX:!!e.flipX,flipY:!!e.flipY,modes:n.modes,tick:function(){var e=i(),r=this.delay,a=e-2*r;n.idle(e-r),n.recalcMatrix(a),n.flush(e-(100+2*r));for(var o=!0,s=n.computedMatrix,h=0;16>h;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){var e=n.computedUp.slice(),r=n.computedEye.slice(),a=n.computedCenter.slice();if(n.setMode(t),"turntable"===t){var o=i();n._active.lookAt(o,r,a,e),n._active.lookAt(o+500,r,a,[0,0,1]),n._active.flush(o)}return n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s="rotate"===h.keyBindingMode,l="pan"===h.keyBindingMode,u="zoom"===h.keyBindingMode,f=!!o.control,g=!!o.alt,v=!!o.shift,m=!!(1&e),y=!!(2&e),b=!!(4&e),x=1/t.clientHeight,_=x*(r-d),w=x*(a-p),k=h.flipX?1:-1,A=h.flipY?1:-1,M=i(),T=Math.PI*h.rotateSpeed;if((s&&m&&!f&&!g&&!v||m&&!f&&!g&&v)&&n.rotate(M,k*T*_,-A*T*w,0),(l&&m&&!f&&!g&&!v||y||m&&f&&!g&&!v)&&n.pan(M,-h.translateSpeed*_*c,h.translateSpeed*w*c,0),u&&m&&!f&&!g&&!v||b||m&&!f&&g&&!v){var E=-h.zoomSpeed*w/window.innerHeight*(M-n.lastT())*100;n.pan(M,0,0,c*(Math.exp(E)-1))}return d=r,p=a,!0}),s(t,function(t,e){var r=h.flipX?1:-1,a=h.flipY?1:-1,o=i();if(Math.abs(t)>Math.abs(e))n.rotate(o,0,0,-t*r*Math.PI*h.rotateSpeed/window.innerWidth);else{var s=-h.zoomSpeed*a*e/window.innerHeight*(o-n.lastT())/100;n.pan(o,0,0,c*(Math.exp(s)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":39,"mouse-change":241,"mouse-wheel":245,"right-now":255}],441:[function(t,e,r){"use strict";function n(t,e){for(var r=0;3>r;++r){var n=s[r];e[n]._gd=t}}var i=t("./scene"),a=t("../plots"),o=t("../../constants/xmlns_namespaces"),s=["xaxis","yaxis","zaxis"];r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,o=a.getSubplotIds(e,"gl3d");e._paperdiv.style({width:e.width+"px",height:e.height+"px"}),t._context.setBackground(t,e.paper_bgcolor);for(var s=0;sr;++r){var n=t[c[r]];e.labels[r]=o(n.title),"titlefont"in n&&(n.titlefont.color&&(e.labelColor[r]=s(n.titlefont.color)),n.titlefont.family&&(e.labelFont[r]=n.titlefont.family),n.titlefont.size&&(e.labelSize[r]=n.titlefont.size)),"showline"in n&&(e.lineEnable[r]=n.showline),"linecolor"in n&&(e.lineColor[r]=s(n.linecolor)),"linewidth"in n&&(e.lineWidth[r]=n.linewidth),"showgrid"in n&&(e.gridEnable[r]=n.showgrid),"gridcolor"in n&&(e.gridColor[r]=s(n.gridcolor)),"gridwidth"in n&&(e.gridWidth[r]=n.gridwidth), -"log"===n.type?e.zeroEnable[r]=!1:"zeroline"in n&&(e.zeroEnable[r]=n.zeroline),"zerolinecolor"in n&&(e.zeroLineColor[r]=s(n.zerolinecolor)),"zerolinewidth"in n&&(e.zeroLineWidth[r]=n.zerolinewidth),"ticks"in n&&n.ticks?e.lineTickEnable[r]=!0:e.lineTickEnable[r]=!1,"ticklen"in n&&(e.lineTickLength[r]=e._defaultLineTickLength[r]=n.ticklen),"tickcolor"in n&&(e.lineTickColor[r]=s(n.tickcolor)),"tickwidth"in n&&(e.lineTickWidth[r]=n.tickwidth),"tickangle"in n&&(e.tickAngle[r]="auto"===n.tickangle?0:Math.PI*-n.tickangle/180),"showticklabels"in n&&(e.tickEnable[r]=n.showticklabels),"tickfont"in n&&(n.tickfont.color&&(e.tickColor[r]=s(n.tickfont.color)),n.tickfont.family&&(e.tickFont[r]=n.tickfont.family),n.tickfont.size&&(e.tickSize[r]=n.tickfont.size)),"mirror"in n?-1!==["ticks","all","allticks"].indexOf(n.mirror)?(e.lineTickMirror[r]=!0,e.lineMirror[r]=!0):n.mirror===!0?(e.lineTickMirror[r]=!1,e.lineMirror[r]=!0):(e.lineTickMirror[r]=!1,e.lineMirror[r]=!1):e.lineMirror[r]=!1,"showbackground"in n&&n.showbackground!==!1?(e.backgroundEnable[r]=!0,e.backgroundColor[r]=s(n.backgroundcolor)):e.backgroundEnable[r]=!1}},e.exports=i},{"../../../lib/html2unicode":381,"../../../lib/str2rgbarray":394,arraytools:49}],446:[function(t,e,r){"use strict";function n(t,e,r,n){for(var a=r("bgcolor"),l=i.combine(a,n.paper_bgcolor),c=Object.keys(o.camera),u=0;ue;++e){var r=t[o[e]];this.enabled[e]=r.showspikes,this.colors[e]=a(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness}},e.exports=i},{"../../../lib/str2rgbarray":394}],449:[function(t,e,r){"use strict";function n(t){for(var e=new Array(3),r=0;3>r;++r){for(var n=t[r],i=new Array(n.length),a=0;au;++u){var f=i[s[u]];if(f._length=(r[u].hi-r[u].lo)*r[u].pixelsPerDataUnit/t.dataScale[u],Math.abs(f._length)===1/0)c[u]=[];else{f.range[0]=r[u].lo/t.dataScale[u],f.range[1]=r[u].hi/t.dataScale[u],f._m=1/(t.dataScale[u]*r[u].pixelsPerDataUnit),f.range[0]===f.range[1]&&(f.range[0]-=1,f.range[1]+=1);var h=f.tickmode;if("auto"===f.tickmode){f.tickmode="linear";var d=f.nticks||a.Lib.constrain(f._length/40,4,9);a.Axes.autoTicks(f,Math.abs(f.range[1]-f.range[0])/d)}for(var p=a.Axes.calcTicks(f),g=0;gu;++u){l[u]=.5*(t.glplot.bounds[0][u]+t.glplot.bounds[1][u]);for(var g=0;2>g;++g)e.bounds[g][u]=t.glplot.bounds[g][u]}t.contourLevels=n(c)}e.exports=i;var a=t("../../../plotly"),o=t("../../../lib/html2unicode"),s=["xaxis","yaxis","zaxis"],l=[0,0,0]},{"../../../lib/html2unicode":381,"../../../plotly":402}],450:[function(t,e,r){"use strict";function n(t,e){var r,n,i=[0,0,0,0];for(r=0;4>r;++r)for(n=0;4>n;++n)i[n]+=t[4*r+n]*e[r];return i}function i(t,e){var r=n(t.projection,n(t.view,n(t.model,[e[0],e[1],e[2],1])));return r}e.exports=i},{}],451:[function(t,e,r){"use strict";function n(t){function e(e,r){if("string"==typeof r)return r;var n=t.fullSceneLayout[e];return g.tickText(n,n.c2l(r),"hover").text}var r,n=t.svgContainer,i=t.container.getBoundingClientRect(),a=i.width,o=i.height;n.setAttributeNS(null,"viewBox","0 0 "+a+" "+o),n.setAttributeNS(null,"width",a),n.setAttributeNS(null,"height",o),A(t),t.glplot.axes.update(t.axesOptions);for(var s=Object.keys(t.traces),l=null,c=t.glplot.selection,u=0;ua;++a)l=u[T[a]],_(l);t?Array.isArray(t)||(t=[t]):t=[];var h=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]];for(a=0;ao;++o)h[0][o]>h[1][o]?d[o]=1:h[1][o]===h[0][o]?d[o]=1:d[o]=1/(h[1][o]-h[0][o]);for(this.dataScale=d,a=0;aa;++a){if(l=u[T[a]],c=l.type,c in x?(x[c].acc*=d[a],x[c].count+=1):x[c]={acc:d[a],count:1},l.autorange){for(y[0][a]=1/0,y[1][a]=-(1/0),o=0;oy[1][a])y[0][a]=-1,y[1][a]=1;else{var k=y[1][a]-y[0][a];y[0][a]-=k/32,y[1][a]+=k/32}}else{var A=u[T[a]].range;y[0][a]=A[0],y[1][a]=A[1]}y[0][a]===y[1][a]&&(y[0][a]-=1,y[1][a]+=1),b[a]=y[1][a]-y[0][a],this.glplot.bounds[0][a]=y[0][a]*d[a],this.glplot.bounds[1][a]=y[1][a]*d[a]}var M=[1,1,1];for(a=0;3>a;++a){l=u[T[a]],c=l.type;var E=x[c];M[a]=Math.pow(E.acc,1/E.count)/d[a]}var L,S=4;if("auto"===u.aspectmode)L=Math.max.apply(null,M)/Math.min.apply(null,M)<=S?M:[1,1,1];else if("cube"===u.aspectmode)L=[1,1,1];else if("data"===u.aspectmode)L=M;else{if("manual"!==u.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var C=u.aspectratio;L=[C.x,C.y,C.z]}u.aspectratio.x=f.aspectratio.x=L[0],u.aspectratio.y=f.aspectratio.y=L[1],u.aspectratio.z=f.aspectratio.z=L[2],this.glplot.aspect=L;var z=u.domain||null,P=e._size||null;if(z&&P){var R=this.container.style;R.position="absolute",R.left=P.l+z.x[0]*P.w+"px",R.top=P.t+(1-z.y[1])*P.h+"px",R.width=P.w*(z.x[1]-z.x[0])+"px",R.height=P.h*(z.y[1]-z.y[0])+"px"}this.glplot.redraw()}},M.destroy=function(){this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null},M.setCameraToDefault=function(){this.setCamera({eye:{x:1.25,y:1.25,z:1.25},center:{x:0,y:0,z:0},up:{x:0,y:0,z:1}})},M.getCamera=function(){return this.glplot.camera.view.recalcMatrix(this.camera.view.lastT()),c(this.glplot.camera)},M.setCamera=function(t){var e={};e[this.id]=t,this.glplot.camera.lookAt.apply(this,l(t)),this.graphDiv.emit("plotly_relayout",e)},M.saveCamera=function(t){function e(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return e[i[r]]&&t[i[r]][a[n]]===e[i[r]][a[n]]}var r=this.getCamera(),n=d.nestedProperty(t,this.id+".camera"),i=n.get(),a=!1;if(void 0===i)a=!0;else for(var o=0;3>o;o++)for(var s=0;3>s;s++)if(!e(r,i,o,s)){a=!0;break}return a&&n.set(r),a},M.updateFx=function(t,e){var r=this.camera;r&&("orbit"===t?(r.mode="orbit",r.keyBindingMode="rotate"):"turntable"===t?(r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate"):r.keyBindingMode=t),this.fullSceneLayout.hovermode=e},M.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(u),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,n=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var i=new Uint8Array(r*n*4);e.readPixels(0,0,r,n,e.RGBA,e.UNSIGNED_BYTE,i);for(var a=0,o=n-1;o>a;++a,--o)for(var s=0;r>s;++s)for(var l=0;4>l;++l){var c=i[4*(r*a+s)+l];i[4*(r*a+s)+l]=i[4*(r*o+s)+l],i[4*(r*o+s)+l]=c}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticMode&&this.container.removeChild(u),p},e.exports=a},{"../../lib":382,"../../lib/show_no_webgl_msg":392,"../../lib/str2rgbarray":394,"../../plots/cartesian/axes":405,"../../plots/cartesian/graph_interact":412,"../../plots/plots":454,"./camera":440,"./layout/convert":445,"./layout/spikes":448,"./layout/tick_marks":449,"./project":450,"./set_convert":452,"gl-plot3d":183}],452:[function(t,e,r){"use strict";var n=t("../cartesian/axes"),i=function(){};e.exports=function(t){n.setConvert(t),t.setScale=i}},{"../cartesian/axes":405}],453:[function(t,e,r){"use strict";var n=t("../plotly"),i=t("./font_attributes"),a=t("../components/color/attributes"),o=n.Lib.extendFlat;e.exports={font:{family:o({},i.family,{dflt:'"Open Sans", verdana, arial, sans-serif'}),size:o({},i.size,{dflt:12}),color:o({},i.color,{dflt:a.defaultLine})},title:{valType:"string",dflt:"Click to enter Plot title"},titlefont:o({},i,{}),autosize:{valType:"enumerated",values:[!0,!1,"initial"]},width:{valType:"number",min:10,dflt:700},height:{valType:"number",min:10,dflt:450},margin:{l:{valType:"number",min:0,dflt:80},r:{valType:"number",min:0,dflt:80},t:{valType:"number",min:0,dflt:100},b:{valType:"number",min:0,dflt:80},pad:{valType:"number",min:0,dflt:0},autoexpand:{valType:"boolean",dflt:!0}},paper_bgcolor:{valType:"color",dflt:a.background},plot_bgcolor:{valType:"color",dflt:a.background},separators:{valType:"string",dflt:".,"},hidesources:{valType:"boolean",dflt:!1},smith:{valType:"enumerated",values:[!1],dflt:!1},showlegend:{valType:"boolean"},_composedModules:{"*":"Fx"},_nestedModules:{xaxis:"Axes",yaxis:"Axes",scene:"gl3d",geo:"geo",legend:"Legend",annotations:"Annotations",shapes:"Shapes",images:"Images",ternary:"ternary",mapbox:"mapbox"}}},{"../components/color/attributes":302,"../plotly":402,"./font_attributes":423}],454:[function(t,e,r){"use strict";function n(t){return"object"==typeof t&&(t=t.type),t}function i(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#","class":"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){f.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}function a(t,e){for(var r,n=Object.keys(e),i=0;i=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var s=r.select(".js-link-to-tool"),l=r.select(".js-link-spacer"),c=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&i(t,s),l.text(s.text()&&c.text()?" - ":"")},f.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",r=o.select(t).append("div").attr("id","hiddenform").style("display","none"),n=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),i=n.append("input").attr({type:"text",name:"data"});return i.node().value=f.graphJson(t,!1,"keepdata"),n.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1},f.supplyDefaults=function(t){var e,r,n=t._fullLayout||{},i=t._fullLayout={},o=t.layout||{},s=t._fullData||[],u=t._fullData=[],h=t.data||[],d=i._modules=[],p=i._basePlotModules=[];for(f.supplyLayoutGlobalDefaults(o,i),i._dataLength=h.length,e=0;ea&&(e=(r-1)/(i.l+i.r),i.l=Math.floor(e*i.l),i.r=Math.floor(e*i.r)),0>o&&(e=(n-1)/(i.t+i.b),i.t=Math.floor(e*i.t),i.b=Math.floor(e*i.b))}},f.autoMargin=function(t,e,r){var n=t._fullLayout;if(n._pushmargin||(n._pushmargin={}),n.margin.autoexpand!==!1){if(r){var i=void 0===r.pad?12:r.pad;r.l+r.r>.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0),n._pushmargin[e]={l:{val:r.x,size:r.l+i},r:{val:r.x,size:r.r+i},b:{val:r.y,size:r.b+i},t:{val:r.y,size:r.t+i}}}else delete n._pushmargin[e];t._replotting||f.doAutoMargin(t)}},f.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var r=e._size,n=JSON.stringify(r),i=Math.max(e.margin.l||0,0),a=Math.max(e.margin.r||0,0),o=Math.max(e.margin.t||0,0),c=Math.max(e.margin.b||0,0),u=e._pushmargin;return e.margin.autoexpand!==!1&&(u.base={l:{val:0,size:i},r:{val:1,size:a},t:{val:1,size:o},b:{val:0,size:c}},Object.keys(u).forEach(function(t){var r=u[t].l||{},n=u[t].b||{},l=r.val,f=r.size,h=n.val,d=n.size;Object.keys(u).forEach(function(t){if(s(f)&&u[t].r){var r=u[t].r.val,n=u[t].r.size;if(r>l){var p=(f*r+(n-e.width)*l)/(r-l),g=(n*(1-l)+(f-e.width)*(1-r))/(r-l);p>=0&&g>=0&&p+g>i+a&&(i=p,a=g)}}if(s(d)&&u[t].t){var v=u[t].t.val,m=u[t].t.size;if(v>h){var y=(d*v+(m-e.height)*h)/(v-h),b=(m*(1-h)+(d-e.height)*(1-v))/(v-h);y>=0&&b>=0&&y+b>c+o&&(c=y,o=b)}}})})),r.l=Math.round(i),r.r=Math.round(a),r.t=Math.round(o),r.b=Math.round(c),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,t._replotting||"{}"===n||n===JSON.stringify(e._size)?void 0:l.plot(t)},f.graphJson=function(t,e,r,n,i){function a(t){if("function"==typeof t)return null;if(c.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0&&!c.isPlainObject(t.stream))continue}else if("keepall"!==r&&(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0))continue;i[e]=a(t[e])}return i}return Array.isArray(t)?t.map(a):t&&t.getTime?c.ms2DateTime(t):t}(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&f.supplyDefaults(t);var o=i?t._fullData:t.data,s=i?t._fullLayout:t.layout,l={data:(o||[]).map(function(t){var r=a(t);return e&&delete r.fit,r})};return e||(l.layout=a(s)),t.framework&&t.framework.isPolar&&(l=t.framework.getConfig()),"object"===n?l:JSON.stringify(l)}},{"../components/color":303,"../lib":382,"../plotly":402,"./attributes":403,"./font_attributes":423,"./layout_attributes":453,d3:113,"fast-isnumeric":117}],455:[function(t,e,r){"use strict";var n=t("../../traces/scatter/attributes"),i=n.marker;e.exports={r:n.r,t:n.t,marker:{color:i.color,size:i.size,symbol:i.symbol,opacity:i.opacity}}},{"../../traces/scatter/attributes":556}],456:[function(t,e,r){"use strict";function n(t,e){var r={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return a({},e,r)}var i=t("../cartesian/layout_attributes"),a=t("../../lib/extend").extendFlat,o=a({},i.domain,{});e.exports={radialaxis:n("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:o,orientation:{valType:"number"}}),angularaxis:n("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:o}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":377,"../cartesian/layout_attributes":414}],457:[function(t,e,r){var n=t("../../plotly"),i=t("d3"),a=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},o=n.Lib.extendDeepAll;a.Axis=function(){function t(t){r=t||r;var c=l.data,f=l.layout;return("string"==typeof r||r.nodeName)&&(r=i.select(r)),r.datum(c).each(function(t,r){function l(t,e){return s(t)%360+f.orientation}var c=t.slice();u={data:a.util.cloneJson(c),layout:a.util.cloneJson(f)};var h=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[h],h=(h+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:i.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var d=c.filter(function(t,e){var r=t.visible;return"undefined"==typeof r||r===!0}),p=!1,g=d.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=i.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var r=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,n){t.yStack=[r],m.push(r),r=a.util.sumArrays(t.r,r)}),t.values});d=i.merge(y)}d.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var b=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;b=Math.max(10,b);var x,_=[f.margin.left+b,f.margin.top+b];if(p){var w=i.max(a.util.sumArrays(a.util.arrayLast(d).r[0],a.util.arrayLast(m)));x=[0,w]}else x=i.extent(a.util.flattenArray(d.map(function(t,e){return t.r})));f.radialAxis.domain!=a.DATAEXTENT&&(x[0]=0),n=i.scale.linear().domain(f.radialAxis.domain!=a.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:x).range([0,b]),u.layout.radialAxis.domain=n.domain();var k,A=a.util.flattenArray(d.map(function(t,e){return t.t})),M="string"==typeof A[0];M&&(A=a.util.deduplicate(A),k=A.slice(),A=i.range(A.length),d=d.map(function(t,e){var r=t;return t.t=[A],p&&(r.yStack=t.yStack),r}));var T=d.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===d.length,E=null===f.needsEndSpacing?M||!T:f.needsEndSpacing,L=f.angularAxis.domain&&f.angularAxis.domain!=a.DATAEXTENT&&!M&&f.angularAxis.domain[0]>=0,S=L?f.angularAxis.domain:i.extent(A),C=Math.abs(A[1]-A[0]);T&&!M&&(C=0);var z=S.slice();E&&M&&(z[1]+=C);var P=f.angularAxis.ticksCount||4;P>8&&(P=P/(P/8)+P%8),f.angularAxis.ticksStep&&(P=(z[1]-z[0])/P);var R=f.angularAxis.ticksStep||(z[1]-z[0])/(P*(f.minorTicks+1));k&&(R=Math.max(Math.round(R),1)),z[2]||(z[2]=R);var O=i.range.apply(this,z);if(O=O.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=i.scale.linear().domain(z.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=s.domain(),u.layout.angularAxis.endPadding=E?C:0,e=i.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var I="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",N=(new DOMParser).parseFromString(I,"application/xml"),j=this.appendChild(this.ownerDocument.importNode(N.documentElement,!0)); -e=i.select(j)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var F,D=e.select(".chart-group"),B={fill:"none",stroke:f.tickColor},U={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){F=e.select(".legend-group").attr({transform:"translate("+[b,f.margin.top]+")"}).style({display:"block"});var V=d.map(function(t,e){var r=a.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});a.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:o({},a.Legend.defaultConfig().legendConfig,{container:F,elements:V,reverseOrder:f.legend.reverseOrder})})();var q=F.node().getBBox();b=Math.min(f.width-q.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,b=Math.max(10,b),_=[f.margin.left+b,f.margin.top+b],n.range([0,b]),u.layout.radialAxis.domain=n.domain(),F.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else F=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),D.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(f.width-(f.margin.left+f.margin.right+2*b+(q?q.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*b))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),e.select(".outer-group").attr("transform","translate("+H+")"),f.title){var G=e.select("g.title-group text").style(U).text(f.title),Y=G.node().getBBox();G.attr({x:_[0]-Y.width/2,y:_[1]-b-20})}var X=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var W=X.selectAll("circle.grid-circle").data(n.ticks(5));W.enter().append("circle").attr({"class":"grid-circle"}).style(B),W.attr("r",n),W.exit().remove()}X.select("circle.outside-circle").attr({r:b}).style(B);var Z=e.select("circle.background-circle").attr({r:b}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var K=i.svg.axis().scale(n).ticks(5).tickSize(5);X.call(K).attr({transform:"rotate("+f.radialAxis.orientation+")"}),X.selectAll(".domain").style(B),X.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(U).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,U["font-size"]]+")":"translate("+[0,U["font-size"]]+")"}}),X.selectAll("g>line").style({stroke:"black"})}var $=e.select(".angular.axis-group").selectAll("g.angular-tick").data(O),Q=$.enter().append("g").classed("angular-tick",!0);$.attr({transform:function(t,e){return"rotate("+l(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),$.exit().remove(),Q.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(B),Q.selectAll(".minor").style({stroke:f.minorTickColor}),$.select("line.grid-line").attr({x1:f.tickLength?b-f.tickLength:0,x2:b}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),Q.append("text").classed("axis-text",!0).style(U);var J=$.select("text.axis-text").attr({x:b+f.labelOffset,dy:".35em",transform:function(t,e){var r=l(t,e),n=b+f.labelOffset,i=f.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?270>r&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(180>=r&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(U);f.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=i.max(D.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));F.attr({transform:"translate("+[b+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,rt=e.select("g.geometry-group").selectAll("g.geometry").data(d);if(rt.enter().append("g").attr({"class":function(t,e){return"geometry geometry"+e}}),rt.exit().remove(),d[0]||et){var nt=[];d.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=s,r.container=rt.filter(function(t,r){return r==e}),r.geometry=t.geometry,r.orientation=f.orientation,r.direction=f.direction,r.index=e,nt.push({data:t,geometryConfig:r})});var it=i.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(nt),at=[];it.forEach(function(t,e){"unstacked"===t.key?at=at.concat(t.values.map(function(t,e){return[t]})):at.push(t.values)}),at.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return o(a[r].defaultConfig(),t)});a[r]().config(n)()})}var ot,st,lt=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=a.tooltipPanel().config({container:ct,fontSize:8})(),ft=a.tooltipPanel().config({container:ct,fontSize:8})(),ht=a.tooltipPanel().config({container:ct,hasTick:!0})();if(!M){var dt=lt.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});D.on("mousemove.angular-guide",function(t,e){var r=a.util.getMousePos(Z).angle;dt.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-f.orientation)%360;ot=s.invert(n);var i=a.util.convertToCartesian(b+12,r+180);ut.text(a.util.round(ot)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){lt.select("line").style({opacity:0})})}var pt=lt.select("circle").style({stroke:"grey",fill:"none"});D.on("mousemove.radial-guide",function(t,e){var r=a.util.getMousePos(Z).radius;pt.attr({r:r}).style({opacity:.5}),st=n.invert(a.util.getMousePos(Z).radius);var i=a.util.convertToCartesian(r,f.radialAxis.orientation);ft.text(a.util.round(st)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),ht.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,r){var n=i.select(this),o=n.style("fill"),s="black",l=n.style("opacity")||1;if(n.attr({"data-opacity":l}),"none"!=o){n.attr({"data-fill":o}),s=i.hsl(o).darker().toString(),n.style({fill:s,opacity:1});var c={t:a.util.round(t[0]),r:a.util.round(t[1])};M&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),h=e.node().getBoundingClientRect(),d=[f.left+f.width/2-H[0]-h.left,f.top+f.height/2-H[1]-h.top];ht.config({color:s}).text(u),ht.move(d)}else o=n.style("stroke"),n.attr({"data-stroke":o}),s=i.hsl(o).darker().toString(),n.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0!=i.event.which?!1:void(i.select(this).attr("data-fill")&&ht.show())}).on("mouseout.tooltip",function(t,e){ht.hide();var r=i.select(this),n=r.attr("data-fill");n?r.style({fill:n,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})}),h}var e,r,n,s,l={data:[],layout:{}},c={},u={},f=i.dispatch("hover"),h={};return h.render=function(e){return t(e),this},h.config=function(t){if(!arguments.length)return l;var e=a.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),o(l.data[e],a.Axis.defaultConfig().data[0]),o(l.data[e],t)}),o(l.layout,a.Axis.defaultConfig().layout),o(l.layout,e.layout),this},h.getLiveConfig=function(){return u},h.getinputConfig=function(){return c},h.radialScale=function(t){return n},h.angularScale=function(t){return s},h.svg=function(){return e},i.rebind(h,f,"on"),h},a.Axis.defaultConfig=function(t,e){var r={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:i.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return r},a.util={},a.DATAEXTENT="dataExtent",a.AREA="AreaChart",a.LINE="LinePlot",a.DOT="DotPlot",a.BAR="BarChart",a.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},a.util._extend=function(t,e){for(var r in t)e[r]=t[r]},a.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},a.util.dataFromEquation2=function(t,e){var r=e||6,n=i.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180,i=t(n);return[e,i]});return n},a.util.dataFromEquation=function(t,e,r){var n=e||6,a=[],o=[];i.range(0,360+n,n).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},a.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return i.range(e).map(function(t,e){return r[e]||r[0]})},a.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=a.util.ensureArray(t[e],r)}),t},a.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},a.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},a.util.sumArrays=function(t,e){return i.zip(t,e).map(function(t,e){return i.sum(t)})},a.util.arrayLast=function(t){return t[t.length-1]},a.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},a.util.flattenArray=function(t){for(var e=[];!a.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},a.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},a.util.convertToCartesian=function(t,e){var r=e*Math.PI/180,n=t*Math.cos(r),i=t*Math.sin(r);return[n,i]},a.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},a.util.getMousePos=function(t){var e=i.mouse(t.node()),r=e[0],n=e[1],a={};return a.x=r,a.y=n,a.pos=e,a.angle=180*(Math.atan2(n,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+n*n),a},a.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;a>i;i++)e=t[i],e in r?(r[e]++,n[e]=r[e]):r[e]=1;return n},a.util.duplicates=function(t){return Object.keys(a.util.duplicatesCount(t))},a.util.translator=function(t,e,r,n){if(n){var i=r.slice();r=e,e=i}var a=e.reduce(function(t,e){return"undefined"!=typeof t?t[e]:void 0},t);"undefined"!=typeof a&&(e.reduce(function(t,r,n){return"undefined"!=typeof t?(n===e.length-1&&delete t[r],t[r]):void 0},t),r.reduce(function(t,e,n){return"undefined"==typeof t[e]&&(t[e]={}),n===r.length-1&&(t[e]=a),t[e]},t))},a.PolyChart=function(){function t(){var t=r[0].geometryConfig,e=t.container;"string"==typeof e&&(e=i.select(e)),e.datum(r).each(function(e,r){function n(e,r){var n=t.radialScale(e[1]),i=(t.angularScale(e[0])+t.orientation)*Math.PI/180;return{r:n,t:i}}function a(t){var e=t.r*Math.cos(t.t),r=t.r*Math.sin(t.t);return{x:e,y:r}}var o=!!e[0].data.yStack,l=e.map(function(t,e){return o?i.zip(t.data.t[0],t.data.r[0],t.data.yStack[0]):i.zip(t.data.t[0],t.data.r[0])}),c=t.angularScale,u=t.radialScale.domain()[0],f={};f.bar=function(r,n,a){var o=e[a].data,s=t.radialScale(r[1])-t.radialScale(0),l=t.radialScale(r[2]||0),u=o.barWidth;i.select(this).attr({"class":"mark bar",d:"M"+[[s+l,-u/2],[s+l,u/2],[l,u/2],[l,-u/2]].join("L")+"Z",transform:function(e,r){return"rotate("+(t.orientation+c(e[0]))+")"}})},f.dot=function(t,r,o){var s=t[2]?[t[0],t[1]+t[2]]:t,l=i.svg.symbol().size(e[o].data.dotSize).type(e[o].data.dotType)(t,r);i.select(this).attr({"class":"mark dot",d:l,transform:function(t,e){var r=a(n(s));return"translate("+[r.x,r.y]+")"}})};var h=i.svg.line.radial().interpolate(e[0].data.lineInterpolation).radius(function(e){return t.radialScale(e[1])}).angle(function(e){return t.angularScale(e[0])*Math.PI/180});f.line=function(r,n,a){var o=r[2]?l[a].map(function(t,e){return[t[0],t[1]+t[2]]}):l[a];if(i.select(this).each(f.dot).style({opacity:function(t,r){return+e[a].data.dotVisible},fill:v.stroke(r,n,a)}).attr({"class":"mark dot"}),!(n>0)){var s=i.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({"class":"line",d:h(o),transform:function(e,r){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(r,n,a)},"fill-opacity":0,stroke:function(t,e){return v.stroke(r,n,a)},"stroke-width":function(t,e){return v["stroke-width"](r,n,a)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](r,n,a)},opacity:function(t,e){return v.opacity(r,n,a)},display:function(t,e){return v.display(r,n,a)}})}};var d=t.angularScale.range(),p=Math.abs(d[1]-d[0])/l[0].length*Math.PI/180,g=i.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,r,n){i.select(this).attr({"class":"mark arc",d:g,transform:function(e,r){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var v={fill:function(t,r,n){return e[n].data.color},stroke:function(t,r,n){return e[n].data.strokeColor},"stroke-width":function(t,r,n){return e[n].data.strokeSize+"px"},"stroke-dasharray":function(t,r,n){return s[e[n].data.strokeDash]},opacity:function(t,r,n){return e[n].data.opacity},display:function(t,r,n){return"undefined"==typeof e[n].data.visible||e[n].data.visible?"block":"none"}},m=i.select(this).selectAll("g.layer").data(l);m.enter().append("g").attr({"class":"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({"class":"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,r=[a.PolyChart.defaultConfig()],n=i.dispatch("hover"),s={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){r[e]||(r[e]={}),o(r[e],a.PolyChart.defaultConfig()),o(r[e],t)}),this):r},t.getColorScale=function(){return e},i.rebind(t,n,"on"),t},a.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:i.scale.category20()}};return t},a.BarChart=function(){return a.PolyChart()},a.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},a.AreaChart=function(){return a.PolyChart()},a.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},a.DotPlot=function(){return a.PolyChart()},a.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},a.LinePlot=function(){return a.PolyChart()},a.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},a.Legend=function(){function t(){var r=e.legendConfig,n=e.data.map(function(t,e){return[].concat(t).map(function(t,n){var i=o({},r.elements[e]);return i.name=t,i.color=[].concat(r.elements[e].color)[n],i})}),a=i.merge(n);a=a.filter(function(t,e){return r.elements[e]&&(r.elements[e].visibleInLegend||"undefined"==typeof r.elements[e].visibleInLegend)}),r.reverseOrder&&(a=a.reverse());var s=r.container;("string"==typeof s||s.nodeName)&&(s=i.select(s));var l=a.map(function(t,e){return t.color}),c=r.fontSize,u=null==r.isContinuous?"number"==typeof a[0]:r.isContinuous,f=u?r.height:c*a.length,h=s.classed("legend-group",!0),d=h.selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=i.range(a.length),v=i.scale[u?"linear":"ordinal"]().domain(g).range(l),m=i.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var r=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=i.svg.symbolTypes.indexOf(t)?i.svg.symbol().type(t).size(r)():i.svg.symbol().type("square").size(r)()};if(u){var b=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);b.enter().append("stop"),b.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:r.height,width:r.colorBandWidth,fill:"url(#grad1)"})}else{var x=d.select(".legend-marks").selectAll("path.legend-mark").data(a);x.enter().append("path").classed("legend-mark",!0),x.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var r=t.symbol;return y(r,c)},fill:function(t,e){return v(e)}}),x.exit().remove()}var _=i.svg.axis().scale(m).orient("right"),w=d.select("g.legend-axis").attr({transform:"translate("+[u?r.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?r.textColor:"none"}),w.selectAll("text").style({fill:r.textColor,"font-size":r.fontSize}).text(function(t,e){return a[e].name}),t}var e=a.Legend.defaultConfig(),r=i.dispatch("hover");return t.config=function(t){return arguments.length?(o(e,t),this):e},i.rebind(t,r,"on"),t},a.Legend.defaultConfig=function(t,e){var r={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return r},a.tooltipPanel=function(){var t,e,r,n={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+a.tooltipPanel.uid++,l=10,c=function(){t=n.container.selectAll("g."+s).data([0]);var i=t.enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=i.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=i.append("text").attr({dx:n.padding+l,dy:.3*+n.fontSize}),c};return c.text=function(a){var o=i.hsl(n.color).l,s=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":n.fontSize+"px"}).text(f);var h=n.padding,d=e.node().getBBox(),p={fill:n.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[n.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),c},c.move=function(e){return t?(t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c):void 0},c.hide=function(){return t?(t.style({display:"none"}),c):void 0},c.show=function(){return t?(t.style({display:"block"}),c):void 0},c.config=function(t){return o(n,t),c},c},a.tooltipPanel.uid=1,a.adapter={},a.adapter.plotly=function(){var t={};return t.convert=function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=o({},t),i=[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]];return i.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",n.dotVisible===!0?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var n=a.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var i=n.indexOf(t.geometry);-1!=i&&(r.data[e].groupId=i)})}if(t.layout){var s=o({},t.layout),l=[[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]];if(l.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};i.entries(s.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),s.margin=f}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r},t}},{"../../plotly":402,"./micropolar_manager":458,d3:113}],458:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("d3"),a=t("./undo_manager"),o=e.exports={},s=n.Lib.extendDeepAll;o.framework=function(t){function e(e,a){return a&&(f=a),i.select(i.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),r=r?s(r,e):e,c||(c=n.micropolar.Axis()),u=n.micropolar.adapter.plotly().convert(r),c.config(u).render(f),t.data=r.data,t.layout=r.layout,o.fillLayout(t),r}var r,l,c,u,f,h=new a;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return r},e.getLiveConfig=function(){return n.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=n.micropolar.util.cloneJson(r);!function(e,r){h.add({undo:function(){r&&t(r)},redo:function(){t(e)}})}(e,l),l=n.micropolar.util.cloneJson(e)},e.undo=function(){h.undo()},e.redo=function(){h.redo()},e},o.fillLayout=function(t){var e=i.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:n.Color.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../plotly":402,"./undo_manager":459,d3:113}],459:[function(t,e,r){"use strict";e.exports=function(){function t(t,e){return t?(i=!0,t[e](),i=!1,this):this}var e,r=[],n=-1,i=!1;return{add:function(t){return i?this:(r.splice(n+1,r.length-n),r.push(t),n=r.length-1,this)},setCallback:function(t){e=t},undo:function(){var i=r[n];return i?(t(i,"undo"),n-=1,e&&e(i.undo),this):this},redo:function(){var i=r[n+1];return i?(t(i,"redo"),n+=1,e&&e(i.redo),this):this},clear:function(){r=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return ng;g++){var v=d[g];s=t[v]?t[v]:t[v]={},e[v]=l={},o("domain."+h,[g/p,(g+1)/p]),o("domain."+{x:"y",y:"x"}[h]),a.id=v,f(s,l,o,a)}}},{"../lib":382,"./plots":454}],461:[function(t,e,r){"use strict";var n=t("./ternary"),i=t("../../plots/plots");r.name="ternary",r.attr="subplot",r.idRoot="ternary",r.idRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"ternary"),o=0;o=o&&(d.min=0,p.min=0,g.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}var i=t("../../../components/color"),a=t("../../subplot_defaults"),o=t("./layout_attributes"),s=t("./axis_defaults"),l=["aaxis","baxis","caxis"];e.exports=function(t,e,r){a(t,e,r,{type:"ternary",attributes:o,handleDefaults:n,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../../components/color":303,"../../subplot_defaults":460,"./axis_defaults":464,"./layout_attributes":466}],466:[function(t,e,r){"use strict";var n=t("../../../components/color/attributes"),i=t("./axis_attributes");e.exports={domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},bgcolor:{valType:"color",dflt:n.background},sum:{valType:"number",dflt:1,min:0},aaxis:i,baxis:i,caxis:i}},{"../../../components/color/attributes":302,"./axis_attributes":463}],467:[function(t,e,r){"use strict";function n(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework()}function i(t){a.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var a=t("d3"),o=t("tinycolor2"),s=t("../../plotly"),l=t("../../lib"),c=t("../../components/color"),u=t("../../components/drawing"),f=t("../cartesian/set_convert"),h=t("../../lib/extend").extendFlat,d=t("../cartesian/axes"),p=t("../../lib/filter_visible"),g=t("../../components/dragelement"),v=t("../../components/titles"),m=t("../cartesian/select"),y=t("../cartesian/constants"),b=t("../cartesian/graph_interact");e.exports=n;var x=n.prototype;x.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={}},x.plot=function(t,e){var r,n=this,i=e[n.id],a=e._size;l.getPlotDiv(n.plotContainer.node())!==n.graphDiv&&(n.init(n.graphDiv._fullLayout),n.makeFramework()),n.adjustLayout(i,a);var o=n.traceHash,s={};for(r=0;r_*y?(a=y,i=a*_):(i=m,a=i/_),o=g*i/m,s=v*a/y,r=e.l+e.w*d-i/2,n=e.t+e.h*(1-p)-a/2,l.x0=r,l.y0=n,l.w=i,l.h=a,l.sum=b,l.xaxis={type:"linear",range:[x+2*k-b,b-x-2*w],domain:[d-o/2,d+o/2],_id:"x",_gd:l.graphDiv},f(l.xaxis),l.xaxis.setScale(),l.yaxis={type:"linear",range:[x,b-w-k],domain:[p-s/2,p+s/2],_id:"y",_gd:l.graphDiv},f(l.yaxis),l.yaxis.setScale();var A=l.yaxis.domain[0],M=l.aaxis=h({},t.aaxis,{range:[x,b-w-k],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[A,A+s*_],_axislayer:l.layers.aaxis,_gridlayer:l.layers.agrid,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l"+a+",-"+i/2});f(M);var T=l.baxis=h({},t.baxis,{range:[b-x-k,w],side:"bottom",_counterangle:30,domain:l.xaxis.domain,_axislayer:l.layers.baxis,_gridlayer:l.layers.bgrid,_counteraxis:l.aaxis,_pos:0,_gd:l.graphDiv,_id:"x",_length:i,_gridpath:"M0,0l-"+i/2+",-"+a});f(T),M._counteraxis=T;var E=l.caxis=h({},t.caxis,{range:[b-x-w,k],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[A,A+s*_],_axislayer:l.layers.caxis,_gridlayer:l.layers.cgrid,_counteraxis:l.baxis,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l-"+a+","+i/2});f(E);var L="M"+r+","+(n+a)+"h"+i+"l-"+i/2+",-"+a+"Z";l.clipDef.select("path").attr("d",L),l.layers.plotbg.select("path").attr("d",L);var S="translate("+r+","+n+")";l.plotContainer.selectAll(".scatterlayer,.maplayer,.zoom").attr("transform",S);var C="translate("+r+","+(n+a)+")";l.layers.baxis.attr("transform",C),l.layers.bgrid.attr("transform",C);var z="translate("+(r+i/2)+","+n+")rotate(30)";l.layers.aaxis.attr("transform",z),l.layers.agrid.attr("transform",z);var P="translate("+(r+i/2)+","+n+")rotate(-30)";l.layers.caxis.attr("transform",P),l.layers.cgrid.attr("transform",P),l.drawAxes(!0),l.plotContainer.selectAll(".crisp").classed("crisp",!1);var R=l.layers.axlines;R.select(".aline").attr("d",M.showline?"M"+r+","+(n+a)+"l"+i/2+",-"+a:"M0,0").call(c.stroke,M.linecolor||"#000").style("stroke-width",(M.linewidth||0)+"px"),R.select(".bline").attr("d",T.showline?"M"+r+","+(n+a)+"h"+i:"M0,0").call(c.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),R.select(".cline").attr("d",E.showline?"M"+(r+i/2)+","+n+"l"+i/2+","+a:"M0,0").call(c.stroke,E.linecolor||"#000").style("stroke-width",(E.linewidth||0)+"px")},x.drawAxes=function(t){var e=this,r=e.graphDiv,n=e.id.substr(7)+"title",i=e.aaxis,a=e.baxis,o=e.caxis;if(d.doTicks(r,i,!0),d.doTicks(r,a,!0),d.doTicks(r,o,!0),t){var s=Math.max(i.showticklabels?i.tickfont.size/2:0,(o.showticklabels?.75*o.tickfont.size:0)+("outside"===o.ticks?.87*o.ticklen:0));v.draw(r,"a"+n,{propContainer:i,propName:e.id+".aaxis.title",dfltName:"Component A",attributes:{x:e.x0+e.w/2,y:e.y0-i.titlefont.size/3-s,"text-anchor":"middle"}});var l=(a.showticklabels?a.tickfont.size:0)+("outside"===a.ticks?a.ticklen:0)+3;v.draw(r,"b"+n,{propContainer:a,propName:e.id+".baxis.title",dfltName:"Component B",attributes:{x:e.x0-l,y:e.y0+e.h+.83*a.titlefont.size+l,"text-anchor":"middle"}}),v.draw(r,"c"+n,{propContainer:o,propName:e.id+".caxis.title",dfltName:"Component C",attributes:{x:e.x0+e.w+l,y:e.y0+e.h+.83*o.titlefont.size+l,"text-anchor":"middle"}})}};var w=y.MINZOOM/2+.87,k="m-0.87,.5h"+w+"v3h-"+(w+5.2)+"l"+(w/2+2.6)+",-"+(.87*w+4.5)+"l2.6,1.5l-"+w/2+","+.87*w+"Z",A="m0.87,.5h-"+w+"v3h"+(w+5.2)+"l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-2.6,1.5l"+w/2+","+.87*w+"Z",M="m0,1l"+w/2+","+.87*w+"l2.6,-1.5l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-"+(w/2+2.6)+","+(.87*w+4.5)+"l2.6,1.5l"+w/2+",-"+.87*w+"Z",T="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",E=!0;x.initInteractions=function(){function t(t,e,r){var n=j.getBoundingClientRect();x=e-n.left,w=r-n.top,L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L,S=N.aaxis.range[1]-L.a,z=o(N.graphDiv._fullLayout[N.id].bgcolor).getLuminance(),P="M0,"+N.h+"L"+N.w/2+", 0L"+N.w+","+N.h+"Z",R=!1,O=D.append("path").attr("class","zoombox").style({fill:z>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",P),I=D.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),p()}function e(t,e){return 1-e/N.h}function r(t,e){return 1-(t+(N.h-e)/Math.sqrt(3))/N.w}function n(t,e){return(t-(N.h-e)/Math.sqrt(3))/N.w}function a(t,i){var a=x+t,o=w+i,s=Math.max(0,Math.min(1,e(x,w),e(a,o))),l=Math.max(0,Math.min(1,r(x,w),r(a,o))),c=Math.max(0,Math.min(1,n(x,w),n(a,o))),u=(s/2+c)*N.w,f=(1-s/2-l)*N.w,h=(u+f)/2,d=f-u,p=(1-s)*N.h,g=p-d/_;d.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),I.transition().style("opacity",1).duration(200),R=!0)}function u(t,e){if(C===L)return 2===e&&v(),i(F);i(F);var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r),E&&F.data&&F._context.showTips&&(l.notifier("Double-click to
zoom back out","long"),E=!1)}function f(){L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L}function h(t,e){var r=t/N.xaxis._m,n=e/N.yaxis._m;C={a:L.a-n,b:L.b+(r+n)/2,c:L.c-(r-n)/2};var i=[C.a,C.b,C.c].sort(),a={a:i.indexOf(C.a),b:i.indexOf(C.b),c:i.indexOf(C.c)};i[0]<0&&(i[1]+i[0]/2<0?(i[2]+=i[0]+i[1],i[0]=i[1]=0):(i[2]+=i[0]/2,i[1]+=i[0]/2,i[0]=0),C={a:i[a.a],b:i[a.b],c:i[a.c]},e=(L.a-C.a)*N.yaxis._m,t=(L.c-C.c-L.b+C.b)*N.xaxis._m);var o="translate("+(N.x0+t)+","+(N.y0+e)+")";N.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",o),N.aaxis.range=[C.a,N.sum-C.b-C.c],N.baxis.range=[N.sum-C.a-C.c,C.b],N.caxis.range=[N.sum-C.a-C.b,C.c],N.drawAxes(!1),N.plotContainer.selectAll(".crisp").classed("crisp",!1)}function d(t,e){if(t){var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r)}else 2===e&&v()}function p(){N.plotContainer.selectAll(".select-outline").remove()}function v(){var t={};t[N.id+".aaxis.min"]=0,t[N.id+".baxis.min"]=0,t[N.id+".caxis.min"]=0,F.emit("plotly_doubleclick",null),s.relayout(F,t)}var x,w,L,S,C,z,P,R,O,I,N=this,j=N.layers.plotbg.select("path").node(),F=N.graphDiv,D=N.layers.zoom,B={element:j,gd:F,plotinfo:{plot:D},doubleclick:v,subplot:N.id,prepFn:function(e,r,n){B.xaxes=[N.xaxis],B.yaxes=[N.yaxis];var i=F._fullLayout.dragmode;e.shiftKey&&(i="pan"===i?"zoom":"pan"),"lasso"===i?B.minDrag=1:B.minDrag=void 0,"zoom"===i?(B.moveFn=a,B.doneFn=u,t(e,r,n)):"pan"===i?(B.moveFn=h,B.doneFn=d,f(),p()):"select"!==i&&"lasso"!==i||m(e,r,n,B,i)}};g.init(B),j.onmousemove=function(t){b.hover(F,t,N.id),F._fullLayout._lasthover=j,F._fullLayout._hoversubplot=N.id},j.onmouseout=function(t){F._dragging||g.unhover(F,t)},j.onclick=function(t){b.click(F,t)}}},{"../../components/color":303,"../../components/dragelement":324,"../../components/drawing":326,"../../components/titles":366,"../../lib":382,"../../lib/extend":377,"../../lib/filter_visible":378,"../../plotly":402,"../cartesian/axes":405,"../cartesian/constants":410,"../cartesian/graph_interact":412,"../cartesian/select":418,"../cartesian/set_convert":419,d3:113,tinycolor2:274}],468:[function(t,e,r){"use strict";function n(t){var e;switch(t){case"themes__thumb":e={autosize:!0,width:150,height:150,title:"",showlegend:!1,margin:{l:5,r:5,t:5,b:5,pad:0},annotations:[]};break;case"thumbnail":e={title:"",hidesources:!0,showlegend:!1,borderwidth:0,bordercolor:"",margin:{l:1,r:1,t:1,b:1,pad:0},annotations:[]};break;default:e={}}return e}function i(t){var e=["xaxis","yaxis","zaxis"];return e.indexOf(t.slice(0,5))>-1}var a=t("../plotly"),o=a.Lib.extendFlat,s=a.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var r,l=t.data,c=t.layout,u=s([],l),f=s({},c,n(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var h=Object.keys(f);for(r=0;rl;l++)n(r[l])&&d.push({p:r[l],s:s[l],b:0});return a(e,"marker")&&o(e,e.marker.color,"marker","c"),a(e,"marker.line")&&o(e,e.marker.line.color,"marker.line","c"),d}},{"../../components/colorscale/calc":310,"../../components/colorscale/has_colorscale":316,"../../plots/cartesian/axes":405,"fast-isnumeric":117}],478:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("../scatter/xy_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=a(t,e,u);return f?(u("orientation",e.x&&!e.y?"h":"v"),u("text"),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),void s(t,e,i.defaultLine,{axis:"x",inherit:"y"})):void(e.visible=!1)}},{"../../components/color":303,"../../components/errorbars/defaults":331,"../../lib":382,"../bar/style_defaults":486,"../scatter/xy_defaults":577,"./attributes":476}],479:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../components/errorbars"),a=t("../../components/color");e.exports=function(t,e,r,o){var s,l=t.cd,c=l[0].trace,u=l[0].t,f=t.xa,h=t.ya,d="closest"===o?u.barwidth/2:u.dbar*(1-f._gd._fullLayout.bargap)/2;s="closest"!==o?function(t){return t.p}:"h"===c.orientation?function(t){return t.y}:function(t){return t.x};var p,g;"h"===c.orientation?(p=function(t){return n.inbox(t.b-e,t.x-e)+(t.x-e)/(t.x-t.b)},g=function(t){var e=s(t)-r;return n.inbox(e-d,e+d)}):(g=function(t){return n.inbox(t.b-r,t.y-r)+(t.y-r)/(t.y-t.b)},p=function(t){var r=s(t)-e;return n.inbox(r-d,r+d)});var v=n.getDistanceFunction(o,p,g);if(n.getClosest(l,v,t),t.index!==!1){var m=l[t.index],y=m.mcc||c.marker.color,b=m.mlcc||c.marker.line.color,x=m.mlw||c.marker.line.width;return a.opacity(y)?t.color=y:a.opacity(b)&&x&&(t.color=b),"h"===c.orientation?(t.x0=t.x1=f.c2p(m.x,!0),t.xLabelVal=m.s,t.y0=h.c2p(s(m)-d,!0),t.y1=h.c2p(s(m)+d,!0),t.yLabelVal=m.p):(t.y0=t.y1=h.c2p(m.y,!0),t.yLabelVal=m.s,t.x0=f.c2p(s(m)-d,!0),t.x1=f.c2p(s(m)+d,!0),t.xLabelVal=m.p),m.tx&&(t.text=m.tx),i.hoverInfo(m,c,t),[t]}}},{"../../components/color":303,"../../components/errorbars":332,"../../plots/cartesian/graph_interact":412}],480:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("./layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.calc=t("./calc"),n.setPositions=t("./set_positions"),n.colorbar=t("../scatter/colorbar"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.moduleType="trace",n.name="bar",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","oriented","markerColorscale","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"../scatter/colorbar":559,"./arrays_to_calcdata":475,"./attributes":476,"./calc":477,"./defaults":478,"./hover":479,"./layout_attributes":481,"./layout_defaults":482,"./plot":483,"./set_positions":484,"./style":485}],481:[function(t,e,r){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","group","overlay","relative"],dflt:"group"},barnorm:{valType:"enumerated",values:["","fraction","percent"],dflt:""},bargap:{valType:"number",min:0,max:1},bargroupgap:{valType:"number",min:0,max:1,dflt:0}}},{}],482:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./layout_attributes");e.exports=function(t,e,r){function s(r,n){return a.coerce(t,e,o,r,n)}for(var l=!1,c=!1,u=!1,f={},h=0;h=2?a(t):t>e?Math.ceil(t):Math.floor(t)}var h,d,p,g;if("h"===s.orientation?(p=u.c2p(r.poffset+e.p,!0),g=u.c2p(r.poffset+e.p+r.barwidth,!0),h=c.c2p(e.b,!0),d=c.c2p(e.s+e.b,!0)):(h=c.c2p(r.poffset+e.p,!0),d=c.c2p(r.poffset+e.p+r.barwidth,!0),g=u.c2p(e.s+e.b,!0),p=u.c2p(e.b,!0)),!(i(h)&&i(d)&&i(p)&&i(g)&&h!==d&&p!==g))return void n.select(this).remove();var v=(e.mlw+1||s.marker.line.width+1||(e.trace?e.trace.marker.line.width:0)+1)-1,m=n.round(v/2%1,2);if(!t._context.staticPlot){var y=o.opacity(e.mc||s.marker.color),b=1>y||v>.01?a:l;h=b(h,d),d=b(d,h),p=b(p,g),g=b(g,p)}n.select(this).attr("d","M"+h+","+p+"V"+g+"H"+d+"V"+p+"Z")})}),h.call(s.plot,e)}},{"../../components/color":303,"../../components/errorbars":332,"../../lib":382,"./arrays_to_calcdata":475,d3:113,"fast-isnumeric":117}],484:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axes"),o=t("../../lib");e.exports=function(t,e){var r,s,l=t._fullLayout,c=e.x(),u=e.y();["v","h"].forEach(function(f){function h(e){function r(t){t[p]=t.p+h}var n=[];e.forEach(function(e){t.calcdata[e].forEach(function(t){n.push(t.p)})});var i=o.distinctVals(n),s=i.vals,c=i.minDiff,u=!1,f=[];"group"===l.barmode&&e.forEach(function(e){u||(t.calcdata[e].forEach(function(t){u||f.forEach(function(e){Math.abs(t.p-e)_&&(S=!0,M=_),_>A+R&&(S=!0,A=_))}a.expand(m,[M,A],{tozero:!0,padded:S})}else{var O=function(t){return t[g]=t.s,t.s};for(r=0;r1||0===s.bargap&&0===s.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),e.selectAll("g.points").each(function(t){var e=t[0].trace,r=e.marker,o=r.line,s=(e._input||{}).marker||{},l=a.tryColorscale(r,s,""),c=a.tryColorscale(r,s,"line.");n.select(this).selectAll("path").each(function(t){var e,a,s=(t.mlw+1||o.width+1)-1,u=n.select(this);e="mc"in t?t.mcc=l(t.mc):Array.isArray(r.color)?i.defaultLine:r.color,u.style("stroke-width",s+"px").call(i.fill,e),s&&(a="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(o.color)?i.defaultLine:o.color,u.call(i.stroke,a))})}),e.call(o.style)}},{"../../components/color":303,"../../components/drawing":326,"../../components/errorbars":332,d3:113}],486:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s){r("marker.color",o),i(t,"marker")&&a(t,e,s,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),i(t,"marker.line")&&a(t,e,s,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width")}},{"../../components/color":303,"../../components/colorscale/defaults":313,"../../components/colorscale/has_colorscale":316}],487:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/color/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=o.line;e.exports={y:{valType:"data_array"},x:{valType:"data_array"},x0:{valType:"any"},y0:{valType:"any"},whiskerwidth:{valType:"number",min:0,max:1,dflt:.5},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1},jitter:{valType:"number",min:0,max:1},pointpos:{valType:"number",min:-2,max:2},orientation:{valType:"enumerated",values:["v","h"]},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)"},symbol:a({},o.symbol,{arrayOk:!1}),opacity:a({},o.opacity,{arrayOk:!1,dflt:1}),size:a({},o.size,{arrayOk:!1}),color:a({},o.color,{arrayOk:!1}),line:{color:a({},s.color,{arrayOk:!1,dflt:i.defaultLine}),width:a({},s.width,{arrayOk:!1,dflt:0}),outliercolor:{valType:"color"},outlierwidth:{valType:"number",min:0,dflt:1}}},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2}},fillcolor:n.fillcolor}},{"../../components/color/attributes":302,"../../lib/extend":377,"../scatter/attributes":556}],488:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../../plots/cartesian/axes");e.exports=function(t,e){function r(t,e,r,a,o){var s;return r in e?p=a.makeCalcdata(e,r):(s=r+"0"in e?e[r+"0"]:"name"in e&&("category"===a.type||n(e.name)&&-1!==["linear","log"].indexOf(a.type)||i.isDateTime(e.name)&&"date"===a.type)?e.name:t.numboxes,s=a.d2c(s),p=o.map(function(){return s})),p}function o(t,e,r,a,o){var s,l,c,u,f=a.length,h=e.length,d=[],p=[];for(s=0;f>s;++s)l=a[s],t[s]={pos:l},p[s]=l-o,d[s]=[];for(p.push(a[f-1]+o),s=0;h>s;++s)u=e[s],n(u)&&(c=i.findBin(r[s],p),c>=0&&h>c&&d[c].push(u));return d}function s(t,e){var r,n,a,o;for(o=0;o1,m=r.dPos*(1-h.boxgap)*(1-h.boxgroupgap)/(v?t.numboxes:1),y=v?2*r.dPos*(-.5+(r.boxnum+.5)/t.numboxes)*(1-h.boxgap):0,b=m*g.whiskerwidth;return g.visible!==!0||r.emptybox?void a.select(this).remove():("h"===g.orientation?(l=p,f=d):(l=d,f=p),r.bPos=y,r.bdPos=m,n(),a.select(this).selectAll("path.box").data(o.identity).enter().append("path").attr("class","box").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=l.c2p(t.pos+y-b,!0),s=l.c2p(t.pos+y+b,!0),c=f.c2p(t.q1,!0),u=f.c2p(t.q3,!0),h=o.constrain(f.c2p(t.med,!0),Math.min(c,u)+1,Math.max(c,u)-1),d=f.c2p(g.boxpoints===!1?t.min:t.lf,!0),p=f.c2p(g.boxpoints===!1?t.max:t.uf,!0);"h"===g.orientation?a.select(this).attr("d","M"+h+","+r+"V"+n+"M"+c+","+r+"V"+n+"H"+u+"V"+r+"ZM"+c+","+e+"H"+d+"M"+u+","+e+"H"+p+(0===g.whiskerwidth?"":"M"+d+","+i+"V"+s+"M"+p+","+i+"V"+s)):a.select(this).attr("d","M"+r+","+h+"H"+n+"M"+r+","+c+"H"+n+"V"+u+"H"+r+"ZM"+e+","+c+"V"+d+"M"+e+","+u+"V"+p+(0===g.whiskerwidth?"":"M"+i+","+d+"H"+s+"M"+i+","+p+"H"+s))}),g.boxpoints&&a.select(this).selectAll("g.points").data(function(t){return t.forEach(function(t){t.t=r,t.trace=g}),t}).enter().append("g").attr("class","points").selectAll("path").data(function(t){var e,r,n,a,s,l,f,h="all"===g.boxpoints?t.val:t.val.filter(function(e){return et.uf}),d=(t.q3-t.q1)*u,p=[],v=0;if(g.jitter){for(e=0;et.lo&&(n.so=!0),n})}).enter().append("path").call(s.translatePoints,d,p),void(g.boxmean&&a.select(this).selectAll("path.mean").data(o.identity).enter().append("path").attr("class","mean").style("fill","none").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=f.c2p(t.mean,!0),o=f.c2p(t.mean-t.sd,!0),s=f.c2p(t.mean+t.sd,!0);"h"===g.orientation?a.select(this).attr("d","M"+i+","+r+"V"+n+("sd"!==g.boxmean?"":"m0,0L"+o+","+e+"L"+i+","+r+"L"+s+","+e+"Z")):a.select(this).attr("d","M"+r+","+i+"H"+n+("sd"!==g.boxmean?"":"m0,0L"+e+","+o+"L"+r+","+i+"L"+e+","+s+"Z"))})))})}},{"../../components/drawing":326,"../../lib":382,d3:113}],495:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib");e.exports=function(t,e){var r,o,s,l,c=t._fullLayout,u=e.x(),f=e.y(),h=["v","h"];for(o=0;ol&&(e.z=u.slice(0,l)),s("locationmode"),s("text"),s("marker.line.color"),s("marker.line.width"),i(t,e,o,s,{prefix:"",cLetter:"z"}),void s("hoverinfo",1===o._dataLength?"location+z+text":void 0)):void(e.visible=!1)}},{"../../components/colorscale/defaults":313,"../../lib":382,"./attributes":497}],500:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../heatmap/colorbar"),n.calc=t("./calc"),n.plot=t("./plot").plot,n.moduleType="trace",n.name="choropleth",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","noOpacity"],n.meta={},e.exports=n},{"../../plots/geo":426,"../heatmap/colorbar":514,"./attributes":497,"./calc":498,"./defaults":499,"./plot":501}],501:[function(t,e,r){"use strict";function n(t,e){function r(e){var r=t.mockAxis;return o.tickText(r,r.c2l(e),"hover").text}var n=e.hoverinfo;if("none"===n)return function(t){delete t.nameLabel,delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("name"),s=-1!==i.indexOf("location"),l=-1!==i.indexOf("z"),c=-1!==i.indexOf("text"),u=!a&&s;return function(t){var n=[];u?t.nameLabel=t.id:(a&&(t.nameLabel=e.name),s&&n.push(t.id)),l&&n.push(r(t.z)),c&&n.push(t.tx),t.textLabel=n.join("
")}}function i(t){return function(e,r){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:r,location:e.id,z:e.z}]}}}var a=t("d3"),o=t("../../plots/cartesian/axes"),s=t("../../plots/cartesian/graph_interact"),l=t("../../components/color"),c=t("../../components/drawing"),u=t("../../components/colorscale/get_scale"),f=t("../../components/colorscale/make_scale_function"),h=t("../../lib/topojson_utils").getTopojsonFeatures,d=t("../../lib/geo_location_utils").locationToFeature,p=t("../../lib/array_to_calc_item"),g=t("../../plots/geo/constants"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){for(var r,n=[],i=t.locations,a=i.length,o=h(t,e),s=(t.marker||{}).line||{},l=0;a>l;l++)r=d(t.locationmode,i[l],o),void 0!==r&&(r.z=t.z[l],void 0!==t.text&&(r.tx=t.text[l]),p(s.color,r,"mlc",l),p(s.width,r,"mlw",l),n.push(r));return n.length>0&&(n[0].trace=t),n},m.plot=function(t,e,r){var o,l=t.framework,c=l.select("g.choroplethlayer"),u=l.select("g.baselayer"),f=l.select("g.baselayeroverchoropleth"),h=g.baseLayersOverChoropleth,d=c.selectAll("g.trace.choropleth").data(e,function(t){return t.uid});d.enter().append("g").attr("class","trace choropleth"),d.exit().remove(),d.each(function(e){function r(e,r){if(t.showHover){var n=t.projection(e.properties.ct);c(e),s.loneHover({x:n[0],y:n[1],name:e.nameLabel,text:e.textLabel},{container:t.hoverContainer.node()}),f=u(e,r),t.graphDiv.emit("plotly_hover",f)}}function o(e,r){t.graphDiv.emit("plotly_click",u(e,r))}var l=m.calcGeoJSON(e,t.topojson),c=n(t,e),u=i(e),f=null,h=a.select(this).selectAll("path.choroplethlocation").data(l);h.enter().append("path").classed("choroplethlocation",!0).on("mouseover",r).on("click",o).on("mouseout",function(){s.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",f)}).on("mousedown",function(){s.loneUnhover(t.hoverContainer)}).on("mouseup",r),h.exit().remove()}),f.selectAll("*").remove();for(var p=0;pr;r++)e=f[r],d[r]=e[0]*(t.zmax-t.zmin)+t.zmin,p[r]=e[1];var g=n.extent([t.zmin,t.zmax,a.start,a.start+l*(c-1)]),v=g[t.zminr;r++)e=f[r],d[r]=(e[0]*(c+u-1)-u/2)*l+o,p[r]=e[1];var y=n.scale.linear().interpolate(n.interpolateRgb).domain(d).range(p);return y}},{"../../components/colorscale/get_scale":315,d3:113}],509:[function(t,e,r){"use strict";function n(t,e,r){var n=r[0].trace,a=r[0].x,s=r[0].y,c=n.contours,u=n.uid,f=e.x(),h=e.y(),v=t._fullLayout,b="contour"+u,x=i(c,e,r[0]);if(n.visible!==!0)return v._paper.selectAll("."+b+",.hm"+u).remove(),void v._infolayer.selectAll(".cb"+u).remove();"heatmap"===c.coloring?(n.zauto&&n.autocontour===!1&&(n._input.zmin=n.zmin=c.start-c.size/2,n._input.zmax=n.zmax=n.zmin+x.length*c.size),k(t,e,[r])):v._paper.selectAll(".hm"+u).remove(),o(x),l(x);var _=f.c2p(a[0],!0),w=f.c2p(a[a.length-1],!0),A=h.c2p(s[0],!0),M=h.c2p(s[s.length-1],!0),T=[[_,M],[w,M],[w,A],[_,A]],E=d(e,r,b);p(E,T,c),g(E,x,T,c),m(E,x,c),y(E,e,r[0],T)}function i(t,e,r){for(var n=t.size||1,i=[],a=t.start;at?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);if(5===r||10===r){var n=(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4;return t>n?5===r?713:1114:5===r?104:208}return 15===r?0:r}function o(t){var e,r,n,i,o,s,l,c,u,f=t[0].z,h=f.length,d=f[0].length,p=2===h||2===d;for(r=0;h-1>r;r++)for(i=[],0===r&&(i=i.concat(A)),r===h-2&&(i=i.concat(M)),e=0;d-1>e;e++)for(n=i.slice(),0===e&&(n=n.concat(T)),e===d-2&&(n=n.concat(E)),o=e+","+r,s=[[f[r][e],f[r][e+1]],[f[r+1][e],f[r+1][e+1]]],u=0;ui;i++){if(s>20?(s=S[s][(l[0]||l[1])<0?0:1],t.crossings[o]=C[s]):delete t.crossings[o],l=L[s],!l){_.log("Found bad marching index:",s,e,t.level);break}if(d.push(h(t,e,l)),e[0]+=l[0],e[1]+=l[1],u(d[d.length-1],d[d.length-2])&&d.pop(),o=e.join(","),o===a&&l.join(",")===p||r&&(l[0]&&(e[0]<0||e[0]>v-2)||l[1]&&(e[1]<0||e[1]>g-2)))break;s=t.crossings[o]}1e4===i&&_.log("Infinite loop in contour?");var m,y,b,x,w,k,A,M=u(d[0],d[d.length-1]),T=0,E=.2*t.smoothing,z=[],P=0;for(i=1;i=P;i--)if(m=z[i],R>m){for(b=0,y=i-1;y>=P&&m+z[y]b&&m+z[b]e;)e++,r=Object.keys(i.crossings)[0].split(",").map(Number),s(i,r);1e4===e&&_.log("Infinite loop in contour?")}}function c(t,e,r){var n=0,i=0;return t>20&&e?208===t||1114===t?n=0===r[0]?1:-1:i=0===r[1]?1:-1:-1!==A.indexOf(t)?i=1:-1!==T.indexOf(t)?n=1:-1!==M.indexOf(t)?i=-1:n=-1,[n,i]}function u(t,e){return Math.abs(t[0]-e[0])<.01&&Math.abs(t[1]-e[1])<.01}function f(t,e){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function h(t,e,r){var n=e[0]+Math.max(r[0],0),i=e[1]+Math.max(r[1],0),a=t.z[i][n],o=t.xaxis,s=t.yaxis;if(r[1]){var l=(t.level-a)/(t.z[i][n+1]-a);return[o.c2p((1-l)*t.x[n]+l*t.x[n+1],!0),s.c2p(t.y[i],!0)]}var c=(t.level-a)/(t.z[i+1][n]-a);return[o.c2p(t.x[n],!0),s.c2p((1-c)*t.y[i]+c*t.y[i+1],!0)]}function d(t,e,r){var n=t.plot.select(".maplayer").selectAll("g.contour."+r).data(e);return n.enter().append("g").classed("contour",!0).classed(r,!0),n.exit().remove(),n}function p(t,e,r){var n=t.selectAll("g.contourbg").data([0]);n.enter().append("g").classed("contourbg",!0);var i=n.selectAll("path").data("fill"===r.coloring?[0]:[]);i.enter().append("path"),i.exit().remove(),i.attr("d","M"+e.join("L")+"Z").style("stroke","none")}function g(t,e,r,n){var i=t.selectAll("g.contourfill").data([0]);i.enter().append("g").classed("contourfill",!0);var a=i.selectAll("path").data("fill"===n.coloring?e:[]);a.enter().append("path"),a.exit().remove(),a.each(function(t){var e=v(t,r);e?x.select(this).attr("d",e).style("stroke","none"):x.select(this).remove()})}function v(t,e){function r(t){return Math.abs(t[1]-e[0][1])<.01}function n(t){return Math.abs(t[1]-e[2][1])<.01}function i(t){return Math.abs(t[0]-e[0][0])<.01}function a(t){return Math.abs(t[0]-e[2][0])<.01}for(var o,s,l,c,u,f,h=t.edgepaths.length||t.z[0][0]l;l++){if(!o){_.log("Missing end?",d,t);break}for(r(o)&&!a(o)?s=e[1]:i(o)?s=e[0]:n(o)?s=e[3]:a(o)&&(s=e[2]),u=0;u=0&&(s=v,c=u):Math.abs(o[1]-s[1])<.01?Math.abs(o[1]-v[1])<.01&&(v[0]-o[0])*(s[0]-v[0])>=0&&(s=v,c=u):_.log("endpt to newendpt is not vert. or horz.",o,s,v)}if(o=s,c>=0)break;h+="L"+s}if(c===t.edgepaths.length){_.log("unclosed perimeter path");break}d=c,g=-1===p.indexOf(d),g&&(d=p[0],h+="Z")}for(d=0;de;e++)s.push(1);for(e=0;a>e;e++)i.push(s.slice());for(e=0;eo;o++)for(n=i(l,o),u[o]=new Array(n),s=0;n>s;s++)u[o][s]=e(a(l,o,s));return u}function i(t,e,r,n,i,a){var o,s,l,c=[],u=h.traceIs(t,"contour"),f=h.traceIs(t,"histogram"),d=h.traceIs(t,"gl2d");if(Array.isArray(e)&&!f&&"category"!==a.type){e=e.map(a.d2c);var p=e.length;if(!(i>=p))return u?e.slice(0,i):e.slice(0,i+1);if(u||d)c=e.slice(0,i);else if(1===i)c=[e[0]-.5,e[0]+.5];else{for(c=[1.5*e[0]-.5*e[1]],l=1;p>l;l++)c.push(.5*(e[l-1]+e[l]));c.push(1.5*e[p-1]-.5*e[p-2])}if(i>p){var g=c[c.length-1],v=g-c[c.length-2];for(l=p;i>l;l++)g+=v,c.push(g)}}else for(s=n||1,o=void 0===r?0:f||"category"===a.type?r:a.d2c(r),l=u||d?0:-.5;i>l;l++)c.push(o+s*l);return c}function a(t){return.5-.25*Math.min(1,.5*t)}function o(t,e,r){var n,i,o=1;if(Array.isArray(r))for(n=0;nn&&o>y;n++)o=l(t,e,a(o));return o>y&&u.log("interp2d didn't converge quickly",o),t}function s(t){var e,r,n,i,a,o,s,l,c=[],u={},f=[],h=t[0],d=[],p=[0,0,0],g=m(t);for(r=0;rn;n++)void 0===d[n]&&(o=(void 0!==d[n-1]?1:0)+(void 0!==d[n+1]?1:0)+(void 0!==e[n]?1:0)+(void 0!==h[n]?1:0),o?(0===r&&o++,0===n&&o++,r===t.length-1&&o++,n===d.length-1&&o++,4>o&&(u[[r,n]]=[r,n,o]),c.push([r,n,o])):f.push([r,n]));for(;f.length;){for(s={},l=!1,a=f.length-1;a>=0;a--)i=f[a],r=i[0],n=i[1],o=((u[[r-1,n]]||p)[2]+(u[[r+1,n]]||p)[2]+(u[[r,n-1]]||p)[2]+(u[[r,n+1]]||p)[2])/20,o&&(s[i]=[r,n,o],f.splice(a,1),l=!0);if(!l)throw"findEmpties iterated with no new neighbors";for(i in s)u[i]=s[i],c.push(s[i])}return c.sort(function(t,e){return e[2]-t[2]})}function l(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g,v=0;for(o=0;os;s++)l=b[s],c=t[i+l[0]],c&&(u=c[a+l[1]],void 0!==u&&(0===h?p=g=u:(p=Math.min(p,u),g=Math.max(g,u)),f++,h+=u));if(0===f)throw"iterateInterp2d order is wrong: no defined neighbors";t[i][a]=h/f,void 0===d?4>f&&(v=1):(t[i][a]=(1+r)*t[i][a]-r*d,g>p&&(v=Math.max(v,Math.abs(t[i][a]-d)/(g-p))))}return v}var c=t("fast-isnumeric"),u=t("../../lib"),f=t("../../plots/cartesian/axes"),h=t("../../plots/plots"),d=t("../histogram2d/calc"),p=t("../../components/colorscale/calc"),g=t("./has_columns"),v=t("./convert_column_xyz"),m=t("./max_row_length");e.exports=function(t,e){function r(t){E=e._input.zsmooth=e.zsmooth=!1,u.notifier("cannot fast-zsmooth: "+t)}var a,l,c,y,b,x,_,w,k=f.getFromId(t,e.xaxis||"x"),A=f.getFromId(t,e.yaxis||"y"),M=h.traceIs(e,"contour"),T=h.traceIs(e,"histogram"),E=M?"best":e.zsmooth;if(k._minDtick=0,A._minDtick=0,T){var L=d(t,e);a=L.x,l=L.x0,c=L.dx,y=L.y,b=L.y0,x=L.dy,_=L.z}else g(e)&&v(e,k,A),a=e.x?k.makeCalcdata(e,"x"):[],y=e.y?A.makeCalcdata(e,"y"):[],l=e.x0||0,c=e.dx||1,b=e.y0||0,x=e.dy||1,_=n(e),(M||e.connectgaps)&&(e._emptypoints=s(_),e._interpz=o(_,e._emptypoints,e._interpz));if("fast"===E)if("log"===k.type||"log"===A.type)r("log axis found");else if(!T){if(a.length){var S=(a[a.length-1]-a[0])/(a.length-1),C=Math.abs(S/100);for(w=0;wC){r("x scale is not linear");break}}if(y.length&&"fast"===E){var z=(y[y.length-1]-y[0])/(y.length-1),P=Math.abs(z/100);for(w=0;wP){r("y scale is not linear");break}}}var R=m(_),O="scaled"===e.xtype?"":e.x,I=i(e,O,l,c,R,k),N="scaled"===e.ytype?"":e.y,j=i(e,N,b,x,_.length,A);f.expand(k,I),f.expand(A,j);var F={x:I,y:j,z:_};if(p(e,_,"","z"),M&&e.contours&&"heatmap"===e.contours.coloring){var D="contour"===e.type?"heatmap":"histogram2d";F.xfill=i(D,O,l,c,R,k),F.yfill=i(D,N,b,x,_.length,A)}return[F]};var y=.01,b=[[-1,0],[1,0],[0,-1],[0,1]]},{"../../components/colorscale/calc":310,"../../lib":382,"../../plots/cartesian/axes":405,"../../plots/plots":454,"../histogram2d/calc":533,"./convert_column_xyz":515,"./has_columns":517,"./max_row_length":520,"fast-isnumeric":117}],514:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c="cb"+r.uid,u=s(r.colorscale),f=r.zmin,h=r.zmax;if(i(f)||(f=a.aggNums(Math.min,null,r.z)),i(h)||(h=a.aggNums(Math.max,null,r.z)),t._fullLayout._infolayer.selectAll("."+c).remove(),!r.showscale)return void o.autoMargin(t,c);var d=e[0].t.cb=l(t,c);d.fillcolor(n.scale.linear().domain(u.map(function(t){return f+t[0]*(h-f)})).range(u.map(function(t){return t[1]}))).filllevels({start:f,end:h,size:(h-f)/254}).options(r.colorbar)()}},{"../../components/colorbar/draw":306,"../../components/colorscale/get_scale":315,"../../lib":382,"../../plots/plots":454,d3:113,"fast-isnumeric":117}],515:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a=t.x.slice(),o=t.y.slice(),s=t.z,l=t.text,c=Math.min(a.length,o.length,s.length),u=void 0!==l&&!Array.isArray(l[0]);for(ci;i++)a[i]=e.d2c(a[i]),o[i]=r.d2c(o[i]);var f,h,d,p=n.distinctVals(a),g=p.vals,v=n.distinctVals(o),m=v.vals,y=n.init2dArray(m.length,g.length);for(u&&(d=n.init2dArray(m.length,g.length)),i=0;c>i;i++)f=n.findBin(a[i]+p.minDiff/2,g),h=n.findBin(o[i]+v.minDiff/2,m),y[h][f]=s[i],u&&(d[h][f]=l[i]);t.x=g,t.y=m,t.z=y,u&&(t.text=d)}},{"../../lib":382}],516:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./has_columns"),a=t("./xyz_defaults"),o=t("../../components/colorscale/defaults"),s=t("./attributes");e.exports=function(t,e,r,l){function c(r,i){return n.coerce(t,e,s,r,i)}var u=a(t,e,c);return u?(c("text"),c("zsmooth"),c("connectgaps",i(e)&&e.zsmooth!==!1),void o(t,e,l,c,{prefix:"",cLetter:"z"})):void(e.visible=!1)}},{"../../components/colorscale/defaults":313,"../../lib":382,"./attributes":512,"./has_columns":517,"./xyz_defaults":523}],517:[function(t,e,r){"use strict";e.exports=function(t){return!Array.isArray(t.z[0])}},{}],518:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../lib");e.exports=function(t,e,r,a,o){if(!(t.distancec||c>=m[0].length||0>u||u>m.length)return}else{if(n.inbox(e-g[0],e-g[g.length-1])>n.MAXDIST||n.inbox(r-v[0],r-v[v.length-1])>n.MAXDIST)return;if(o){var w;for(b=[2*g[0]-g[1]],w=1;w0;)_=v.c2p(C[M]),M--;for(x>_&&(w=_,_=x,x=w,N=!0),M=0;void 0===k&&M0;)A=m.c2p(z[M]),M--;if(k>A&&(w=k,k=A,A=w,j=!0),P&&(C=r[0].xfill,z=r[0].yfill),"fast"!==R){var F="best"===R?0:.5;x=Math.max(-F*v._length,x),_=Math.min((1+F)*v._length,_),k=Math.max(-F*m._length,k),A=Math.min((1+F)*m._length,A)}var D=Math.round(_-x),B=Math.round(A-k);if(!(0>=D||0>=B)){var U,V;"fast"===R?(U=I,V=O):(U=D,V=B);var q=document.createElement("canvas");q.width=U,q.height=V;var H,G,Y=q.getContext("2d"),X=i.scale.linear().domain(S.map(function(t){return t[0]})).range(S.map(function(t){var e=a(t[1]).toRgb();return[e.r,e.g,e.b,e.a]})).clamp(!0);"fast"===R?(H=N?function(t){return I-1-t}:o.identity,G=j?function(t){return O-1-t}:o.identity):(H=function(t){return o.constrain(Math.round(v.c2p(C[t])-x),0,D)},G=function(t){return o.constrain(Math.round(m.c2p(z[t])-k),0,B)});var W,Z,K,$,Q,J,tt=G(0),et=[tt,tt],rt=N?0:1,nt=j?0:1,it=0,at=0,ot=0,st=0;if(R){var lt=0,ct=new Uint8Array(D*B*4);if("best"===R){var ut,ft,ht,dt=new Array(C.length),pt=new Array(z.length),gt=new Array(D);for(M=0;MM;M++)gt[M]=n(M,dt);for(Z=0;B>Z;Z++)for(ut=n(Z,pt),ft=T[ut.bin0],ht=T[ut.bin1],M=0;D>M;M++,lt+=4)J=d(ft,ht,gt[M],ut),h(ct,lt,J)}else for(Z=0;O>Z;Z++)for(Q=T[Z],et=G(Z),M=0;D>M;M++)J=f(Q[M],1),lt=4*(et*D+H(M)),h(ct,lt,J);var vt=Y.createImageData(D,B);vt.data.set(ct),Y.putImageData(vt,0,0)}else for(Z=0;O>Z;Z++)if(Q=T[Z],et.reverse(),et[nt]=G(Z+1),et[0]!==et[1]&&void 0!==et[0]&&void 0!==et[1])for(K=H(0),W=[K,K],M=0;I>M;M++)W.reverse(),W[rt]=H(M+1),W[0]!==W[1]&&void 0!==W[0]&&void 0!==W[1]&&($=Q[M],J=f($,(W[1]-W[0])*(et[1]-et[0])),Y.fillStyle="rgba("+J.join(",")+")",Y.fillRect(W[0],et[0],W[1]-W[0],et[1]-et[0]));at=Math.round(at/it),ot=Math.round(ot/it),st=Math.round(st/it);var mt=a("rgb("+at+","+ot+","+st+")");t._hmpixcount=(t._hmpixcount||0)+it,t._hmlumcount=(t._hmlumcount||0)+it*mt.getLuminance();var yt=e.plot.select(".imagelayer").selectAll("g.hm."+b).data([0]);yt.enter().append("g").classed("hm",!0).classed(b,!0),yt.exit().remove();var bt=yt.selectAll("image").data(r);bt.enter().append("svg:image"),bt.exit().remove(),bt.attr({xmlns:c.svg,"xlink:href":q.toDataURL("image/png"),height:B,width:D,x:x,y:k,preserveAspectRatio:"none"})}}var i=t("d3"),a=t("tinycolor2"),o=t("../../lib"),s=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),c=t("../../constants/xmlns_namespaces"),u=t("./max_row_length");e.exports=function(t,e,r){for(var i=0;i0&&(n=!0);for(var s=0;si;i++)e[i]?(t[i]/=e[i],n+=t[i]):t[i]=null;return n}},{}],526:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){return r("histnorm"),n.forEach(function(t){var e=r(t+"bins.start"),n=r(t+"bins.end"),i=r("autobin"+t,!(e&&n));r(i?"nbins"+t:t+"bins.size")}),e}},{}],527:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports={count:function(t,e,r){return r[t]++,1},sum:function(t,e,r,i){var a=i[e];return n(a)?(a=Number(a),r[t]+=a,a):0},avg:function(t,e,r,i,a){var o=i[e];return n(o)&&(o=Number(o),r[t]+=o,a[t]++),0},min:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]>a)return r[t]=a,a-r[t]}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]r&&c.length<5e3;)g=a.tickIncrement(r,b.size),c.push((r+g)/2),u.push(S),x&&_.push(r),E&&w.push(1/(g-r)),P&&k.push(0),r=g;var R=u.length;for(r=0;r=0&&R>m&&(A+=C(m,r,u,y,k));P&&(A=l(u,k)),z&&z(u,A,w);var O=Math.min(c.length,u.length),I=[],N=0,j=O-1;for(r=0;O>r;r++)if(u[r]){N=r;break}for(r=O-1;r>N;r--)if(u[r]){j=r;break}for(r=N;j>=r;r++)n(c[r])&&n(u[r])&&I.push({p:c[r],s:u[r],b:0});return I}}},{"../../lib":382,"../../plots/cartesian/axes":405,"./average":525,"./bin_functions":527,"./norm_functions":531,"fast-isnumeric":117}],529:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("./bin_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=u("x"),h=u("y");u("text");var d=u("orientation",h&&!f?"h":"v"),p=e["v"===d?"x":"y"];if(!p||!p.length)return void(e.visible=!1);var g=e["h"===d?"x":"y"];g&&u("histfunc");var v="h"===d?["y"]:["x"];a(t,e,u,v),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),s(t,e,i.defaultLine,{axis:"x",inherit:"y"})}},{"../../components/color":303,"../../components/errorbars/defaults":331,"../../lib":382,"../bar/style_defaults":486,"./attributes":524,"./bin_defaults":526}],530:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("../bar/layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("../bar/layout_defaults"),n.calc=t("./calc"),n.setPositions=t("../bar/set_positions"),n.plot=t("../bar/plot"),n.style=t("../bar/style"),n.colorbar=t("../scatter/colorbar"),n.hoverPoints=t("../bar/hover"),n.moduleType="trace",n.name="histogram",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","histogram","oriented","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"../bar/hover":479,"../bar/layout_attributes":481,"../bar/layout_defaults":482,"../bar/plot":483,"../bar/set_positions":484,"../bar/style":485,"../scatter/colorbar":559,"./attributes":524,"./calc":528,"./defaults":529}],531:[function(t,e,r){"use strict";e.exports={percent:function(t,e){for(var r=t.length,n=100/e,i=0;r>i;i++)t[i]*=n},probability:function(t,e){for(var r=t.length,n=0;r>n;n++)t[n]/=e},density:function(t,e,r,n){var i=t.length;n=n||1;for(var a=0;i>a;a++)t[a]*=r[a]*n},"probability density":function(t,e,r,n){var i=t.length;n&&(e/=n);for(var a=0;i>a;a++)t[a]*=r[a]/e}}},{}],532:[function(t,e,r){"use strict";var n=t("../histogram/attributes"),i=t("../heatmap/attributes"),a=t("../../components/colorscale/attributes"),o=t("../../lib/extend").extendFlat;e.exports=o({},{x:n.x,y:n.y,z:{valType:"data_array"},marker:{color:{valType:"data_array"}},histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zsmooth:i.zsmooth,_nestedModules:{colorbar:"Colorbar"}},a,{autocolorscale:o({},a.autocolorscale,{dflt:!1})})},{"../../components/colorscale/attributes":309,"../../lib/extend":377,"../heatmap/attributes":512,"../histogram/attributes":524}],533:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("../histogram/bin_functions"),o=t("../histogram/norm_functions"),s=t("../histogram/average");e.exports=function(t,e){var r,l,c,u,f,h,d=i.getFromId(t,e.xaxis||"x"),p=e.x?d.makeCalcdata(e,"x"):[],g=i.getFromId(t,e.yaxis||"y"),v=e.y?g.makeCalcdata(e,"y"):[],m=Math.min(p.length,v.length);p.length>m&&p.splice(m,p.length-m),v.length>m&&v.splice(m,v.length-m),!e.autobinx&&"xbins"in e||(e.xbins=i.autoBin(p,d,e.nbinsx,"2d"),"histogram2dcontour"===e.type&&(e.xbins.start-=e.xbins.size,e.xbins.end+=e.xbins.size),e._input.xbins=e.xbins),!e.autobiny&&"ybins"in e||(e.ybins=i.autoBin(v,g,e.nbinsy,"2d"),"histogram2dcontour"===e.type&&(e.ybins.start-=e.ybins.size,e.ybins.end+=e.ybins.size),e._input.ybins=e.ybins),f=[];var y,b,x=[],_=[],w="string"==typeof e.xbins.size?[]:e.xbins,k="string"==typeof e.xbins.size?[]:e.ybins,A=0,M=[],T=e.histnorm,E=e.histfunc,L=-1!==T.indexOf("density"),S="max"===E||"min"===E,C=S?null:0,z=a.count,P=o[T],R=!1,O=[],I=[],N="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";N&&"count"!==E&&(R="avg"===E,z=a[E]);var j=e.xbins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6;for(h=j.start;F>h;h=i.tickIncrement(h,j.size))x.push(C),Array.isArray(w)&&w.push(h),R&&_.push(0);Array.isArray(w)&&w.push(h);var D=x.length;for(r=e.xbins.start,l=(h-r)/D,r+=l/2,j=e.ybins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6,h=j.start;F>h;h=i.tickIncrement(h,j.size))f.push(x.concat()),Array.isArray(k)&&k.push(h),R&&M.push(_.concat());Array.isArray(k)&&k.push(h);var B=f.length;for(c=e.ybins.start,u=(h-c)/B,c+=u/2,L&&(O=x.map(function(t,e){return Array.isArray(w)?1/(w[e+1]-w[e]):1/l}),I=f.map(function(t,e){return Array.isArray(k)?1/(k[e+1]-k[e]):1/u})),h=0;m>h;h++)y=n.findBin(p[h],w),b=n.findBin(v[h],k),y>=0&&D>y&&b>=0&&B>b&&(A+=z(y,h,f[b],N,M[b]));if(R)for(b=0;B>b;b++)A+=s(f[b],M[b]);if(P)for(b=0;B>b;b++)P(f[b],A,O,I[b]);return{x:p,x0:r,dx:l,y:v,y0:c,dy:u,z:f}}},{"../../lib":382,"../../plots/cartesian/axes":405,"../histogram/average":525,"../histogram/bin_functions":527,"../histogram/norm_functions":531}],534:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./sample_defaults"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r){function s(r,i){return n.coerce(t,e,o,r,i)}i(t,e,s),s("zsmooth"),a(t,e,r,s,{prefix:"",cLetter:"z"})}},{"../../components/colorscale/defaults":313,"../../lib":382,"./attributes":532,"./sample_defaults":536}],535:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../heatmap/calc"),n.plot=t("../heatmap/plot"),n.colorbar=t("../heatmap/colorbar"),n.style=t("../heatmap/style"),n.hoverPoints=t("../heatmap/hover"),n.moduleType="trace",n.name="histogram2d",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"../heatmap/calc":513,"../heatmap/colorbar":514,"../heatmap/hover":518,"../heatmap/plot":521,"../heatmap/style":522,"./attributes":532,"./defaults":534}],536:[function(t,e,r){"use strict";var n=t("../histogram/bin_defaults");e.exports=function(t,e,r){var i=r("x"),a=r("y");if(!(i&&i.length&&a&&a.length))return void(e.visible=!1);var o=r("z")||r("marker.color");o&&r("histfunc");var s=["x","y"];n(t,e,r,s)}},{"../histogram/bin_defaults":526}],537:[function(t,e,r){"use strict";var n=t("../histogram2d/attributes"),i=t("../contour/attributes"),a=t("../../components/colorscale/attributes"),o=t("../../lib/extend").extendFlat;e.exports=o({},{x:n.x,y:n.y,z:n.z,marker:n.marker,histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,autocontour:i.autocontour,ncontours:i.ncontours,contours:i.contours,line:i.line,_nestedModules:{colorbar:"Colorbar"}},a)},{"../../components/colorscale/attributes":309,"../../lib/extend":377,"../contour/attributes":502,"../histogram2d/attributes":532}],538:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../histogram2d/sample_defaults"),a=t("../contour/style_defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,i){return n.coerce(t,e,o,r,i)}i(t,e,l);var c=n.coerce2(t,e,o,"contours.start"),u=n.coerce2(t,e,o,"contours.end"),f=l("autocontour",!(c&&u));l(f?"ncontours":"contours.size"),a(t,e,l,s)}},{"../../lib":382,"../contour/style_defaults":511,"../histogram2d/sample_defaults":536,"./attributes":537}],539:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../contour/calc"),n.plot=t("../contour/plot"),n.style=t("../contour/style"),n.colorbar=t("../contour/colorbar"),n.hoverPoints=t("../contour/hover"),n.moduleType="trace",n.name="histogram2dcontour",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","contour","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"../contour/calc":503,"../contour/colorbar":504,"../contour/hover":506,"../contour/plot":509,"../contour/style":510,"./attributes":537,"./defaults":538}],540:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../surface/attributes"),a=t("../../lib/extend").extendFlat;e.exports={x:{valType:"data_array"},y:{valType:"data_array"},z:{valType:"data_array"},i:{valType:"data_array"},j:{valType:"data_array"},k:{valType:"data_array"},delaunayaxis:{valType:"enumerated",values:["x","y","z"],dflt:"z"},alphahull:{valType:"number",dflt:-1},intensity:{valType:"data_array"},color:{valType:"color"},vertexcolor:{valType:"data_array"},facecolor:{valType:"data_array"},opacity:a({},i.opacity),flatshading:{valType:"boolean",dflt:!1},contour:{show:a({},i.contours.x.show,{}),color:a({},i.contours.x.color),width:a({},i.contours.x.width)},colorscale:n.colorscale,reversescale:n.reversescale,showscale:n.showscale,lightposition:{x:a({},i.lightposition.x,{dflt:1e5}),y:a({},i.lightposition.y,{dflt:1e5}),z:a({},i.lightposition.z,{dflt:0})},lighting:a({},{vertexnormalsepsilon:{valType:"number",min:0,max:1,dflt:1e-12},facenormalsepsilon:{valType:"number",min:0,max:1,dflt:1e-6}},i.lighting),_nestedModules:{colorbar:"Colorbar"}}},{"../../components/colorscale/attributes":309,"../../lib/extend":377,"../surface/attributes":601}],541:[function(t,e,r){"use strict";function n(t,e,r){this.scene=t,this.uid=r,this.mesh=e,this.name="",this.color="#fff",this.data=null,this.showContour=!1}function i(t){return t.map(function(t){var e=t[0],r=c(t[1]),n=r.toRgb();return{index:e,rgb:[n.r,n.g,n.b,1]}})}function a(t){return t.map(d)}function o(t,e,r){for(var n=new Array(t.length),i=0;i0)s=f(t.alphahull,l);else{var c=["x","y","z"].indexOf(t.delaunayaxis);s=u(l.map(function(t){return[t[(c+1)%3],t[(c+2)%3]]}))}var p={positions:l,cells:s,lightPosition:[t.lightposition.x,t.lightposition.y,t.lightposition.z],ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,vertexNormalsEpsilon:t.lighting.vertexnormalsepsilon,faceNormalsEpsilon:t.lighting.facenormalsepsilon,opacity:t.opacity,contourEnable:t.contour.show,contourColor:d(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",p.vertexIntensity=t.intensity,p.colormap=i(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolors[0],p.vertexColors=a(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],p.cellColors=a(t.facecolor)):(this.color=t.color,p.meshColor=d(t.color)),this.mesh.update(p)},p.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=s},{"../../lib/str2rgbarray":394,"alpha-shape":40,"convex-hull":102,"delaunay-triangulate":114,"gl-mesh3d":150,tinycolor2:274}],542:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/colorbar/defaults"),a=t("./attributes");e.exports=function(t,e,r,o){function s(r,i){return n.coerce(t,e,a,r,i)}function l(t){var e=t.map(function(t){var e=s(t);return e&&Array.isArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var c=l(["x","y","z"]),u=l(["i","j","k"]);return c?(u&&u.forEach(function(t){for(var e=0;el||(c=p[r],void 0!==c&&""!==c||(c=r),c=String(c),void 0===y[c]&&(y[c]=!0,u=a(e.marker.colors[r]),u.isValid()?(u=o.addOpacity(u,u.getAlpha()),m[c]||(m[c]=u)):m[c]?u=m[c]:(u=!1,b=!0),f=-1!==_.indexOf(c),f||(x+=l),g.push({v:l,label:c,color:u,i:r,hidden:f}))));if(e.sort&&g.sort(function(t,e){return e.v-t.v}),b)for(r=0;r")}return g};var l},{"../../components/color":303,"./helpers":548,"fast-isnumeric":117,tinycolor2:274}],547:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(r,a){return n.coerce(t,e,i,r,a)}var s=n.coerceFont,l=o("values");if(!Array.isArray(l)||!l.length)return void(e.visible=!1);var c=o("labels");Array.isArray(c)||(o("label0"),o("dlabel"));var u=o("marker.line.width");u&&o("marker.line.color");var f=o("marker.colors");Array.isArray(f)||(e.marker.colors=[]),o("scalegroup");var h=o("text"),d=o("textinfo",Array.isArray(h)?"text+percent":"percent");if(o("hoverinfo",1===a._dataLength?"label+text+value+percent":void 0),d&&"none"!==d){var p=o("textposition"),g=Array.isArray(p)||"auto"===p,v=g||"inside"===p,m=g||"outside"===p;if(v||m){var y=s(o,"textfont",a.font);v&&s(o,"insidetextfont",y),m&&s(o,"outsidetextfont",y)}}o("domain.x"),o("domain.y"),o("hole"),o("sort"),o("direction"),o("rotation"),o("pull")}},{"../../lib":382,"./attributes":544}],548:[function(t,e,r){"use strict";var n=t("../../lib");r.formatPiePercent=function(t,e){var r=(100*t).toPrecision(3);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)+"%"},r.formatPieValue=function(t,e){var r=t.toPrecision(10);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)}},{"../../lib":382}],549:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.layoutAttributes=t("./layout_attributes"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.styleOne=t("./style_one"),n.moduleType="trace",n.name="pie",n.basePlotModule=t("./base_plot"),n.categories=["pie","showLegend"],n.meta={},e.exports=n},{"./attributes":544,"./base_plot":545,"./calc":546,"./defaults":547,"./layout_attributes":550,"./layout_defaults":551,"./plot":552,"./style":553,"./style_one":554}],550:[function(t,e,r){"use strict";e.exports={hiddenlabels:{valType:"data_array"}}},{}],551:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e){function r(r,a){return n.coerce(t,e,i,r,a)}r("hiddenlabels")}},{"../../lib":382,"./layout_attributes":550}],552:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,o=Math.PI*Math.min(e.v/r.vTotal,.5),s=1-r.trace.hole,l=i(e,r),c={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(c.scale>=1)return c;var u=a+1/(2*Math.tan(o)),f=r.r*Math.min(1/(Math.sqrt(u*u+.5)+u),s/(Math.sqrt(a*a+s/2)+a)),h={scale:2*f/t.height,rCenter:Math.cos(f/r.r)-f*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},d=1/a,p=d+1/(2*Math.tan(o)),g=r.r*Math.min(1/(Math.sqrt(p*p+.5)+p),s/(Math.sqrt(d*d+s/2)+d)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r,rotate:(180/Math.PI*e.midangle+810)%180-90},m=v.scale>h.scale?v:h;return c.scale<1&&m.scale>c.scale?m:c}function i(t,e){if(t.v===e.vTotal&&!e.trace.hole)return 1;var r=Math.PI*Math.min(t.v/e.vTotal,.5);return Math.min(1/(1+1/Math.sin(r)),(1-e.trace.hole)/2)}function a(t,e){var r=e.pxmid[0],n=e.pxmid[1],i=t.width/2,a=t.height/2;return 0>r&&(i*=-1),0>n&&(a*=-1),{scale:1,rCenter:1,rotate:0,x:i+Math.abs(a)*(i>0?1:-1)/2,y:a/(1+r*r/(n*n)),outside:!0}}function o(t,e){function r(t,e){return t.pxmid[1]-e.pxmid[1]}function n(t,e){return e.pxmid[1]-t.pxmid[1]}function i(t,r){r||(r={});var n,i,a,s,h,d,g=r.labelExtraY+(o?r.yLabelMax:r.yLabelMin),v=o?t.yLabelMin:t.yLabelMax,m=o?t.yLabelMax:t.yLabelMin,y=t.cyFinal+c(t.px0[1],t.px1[1]),b=g-v;if(b*f>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(i=0;i=e.pull[a.i]||((t.pxmid[1]-a.pxmid[1])*f>0?(s=a.cyFinal+c(a.px0[1],a.px1[1]),b=s-v-t.labelExtraY,b*f>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-y)*f>0&&(n=3*u*Math.abs(i-p.indexOf(t)),h=a.cxFinal+l(a.px0[0],a.px1[0]),d=h+n-(t.cxFinal+t.pxmid[0])-t.labelExtraX,d*u>0&&(t.labelExtraX+=d)))}var a,o,s,l,c,u,f,h,d,p,g,v,m;for(o=0;2>o;o++)for(s=o?r:n,c=o?Math.max:Math.min,f=o?1:-1,a=0;2>a;a++){for(l=a?Math.max:Math.min,u=a?1:-1,h=t[o][a],h.sort(s),d=t[1-o][a],p=d.concat(h),v=[],g=0;gu&&(u=s.pull[a]);o.r=Math.min(r/c(s.tilt,Math.sin(l),s.depth),n/c(s.tilt,Math.cos(l),s.depth))/(2+2*u),o.cx=e.l+e.w*(s.domain.x[1]+s.domain.x[0])/2,o.cy=e.t+e.h*(2-s.domain.y[1]-s.domain.y[0])/2,s.scalegroup&&-1===d.indexOf(s.scalegroup)&&d.push(s.scalegroup)}for(a=0;af.vTotal/2?1:0)}function c(t,e,r){if(!t)return 1;var n=Math.sin(t*Math.PI/180);return Math.max(.01,r*n*Math.abs(e)+2*Math.sqrt(1-n*n*e*e))}var u=t("d3"),f=t("../../plots/cartesian/graph_interact"),h=t("../../components/color"),d=t("../../components/drawing"),p=t("../../lib/svg_text_utils"),g=t("./helpers");e.exports=function(t,e){var r=t._fullLayout;s(e,r._size);var c=r._pielayer.selectAll("g.trace").data(e);c.enter().append("g").attr({"stroke-linejoin":"round","class":"trace"}),c.exit().remove(),c.order(),c.each(function(e){var s=u.select(this),c=e[0],v=c.trace,m=0,y=(v.depth||0)*c.r*Math.sin(m)/2,b=v.tiltaxis||0,x=b*Math.PI/180,_=[y*Math.sin(x),y*Math.cos(x)],w=c.r*Math.cos(m),k=s.selectAll("g.part").data(v.tilt?["top","sides"]:["top"]);k.enter().append("g").attr("class",function(t){return t+" part"}),k.exit().remove(),k.order(),l(e),s.selectAll(".top").each(function(){var s=u.select(this).selectAll("g.slice").data(e);s.enter().append("g").classed("slice",!0),s.exit().remove();var l=[[[],[]],[[],[]]],m=!1;s.each(function(o){function s(e){var n=t._fullLayout,a=t._fullData[v.index],s=a.hoverinfo;if("all"===s&&(s="label+text+value+percent+name"),!t._dragging&&n.hovermode!==!1&&"none"!==s&&s){var l=i(o,c),u=k+o.pxmid[0]*(1-l),h=A+o.pxmid[1]*(1-l),d=r.separators,p=[];-1!==s.indexOf("label")&&p.push(o.label),a.text&&a.text[o.i]&&-1!==s.indexOf("text")&&p.push(a.text[o.i]),-1!==s.indexOf("value")&&p.push(g.formatPieValue(o.v,d)),-1!==s.indexOf("percent")&&p.push(g.formatPiePercent(o.v/c.vTotal,d)),f.loneHover({x0:u-l*c.r,x1:u+l*c.r,y:h,text:p.join("
"),name:-1!==s.indexOf("name")?a.name:void 0,color:o.color,idealAlign:o.pxmid[0]<0?"left":"right"},{container:n._hoverlayer.node(), -outerContainer:n._paper.node()}),f.hover(t,e,"pie"),E=!0}}function h(e){t.emit("plotly_unhover",{points:[e]}),E&&(f.loneUnhover(r._hoverlayer.node()),E=!1)}function y(){t._hoverdata=[o],t._hoverdata.trace=e.trace,f.click(t,{target:!0})}function x(t,e,r,n){return"a"+n*c.r+","+n*w+" "+b+" "+o.largeArc+(r?" 1 ":" 0 ")+n*(e[0]-t[0])+","+n*(e[1]-t[1])}if(o.hidden)return void u.select(this).selectAll("path,g").remove();l[o.pxmid[1]<0?0:1][o.pxmid[0]<0?0:1].push(o);var k=c.cx+_[0],A=c.cy+_[1],M=u.select(this),T=M.selectAll("path.surface").data([o]),E=!1;if(T.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),M.select("path.textline").remove(),M.on("mouseover",s).on("mouseout",h).on("click",y),v.pull){var L=+(Array.isArray(v.pull)?v.pull[o.i]:v.pull)||0;L>0&&(k+=L*o.pxmid[0],A+=L*o.pxmid[1])}o.cxFinal=k,o.cyFinal=A;var S=v.hole;if(o.v===c.vTotal){var C="M"+(k+o.px0[0])+","+(A+o.px0[1])+x(o.px0,o.pxmid,!0,1)+x(o.pxmid,o.px0,!0,1)+"Z";S?T.attr("d","M"+(k+S*o.px0[0])+","+(A+S*o.px0[1])+x(o.px0,o.pxmid,!1,S)+x(o.pxmid,o.px0,!1,S)+"Z"+C):T.attr("d",C)}else{var z=x(o.px0,o.px1,!0,1);if(S){var P=1-S;T.attr("d","M"+(k+S*o.px1[0])+","+(A+S*o.px1[1])+x(o.px1,o.px0,!1,S)+"l"+P*o.px0[0]+","+P*o.px0[1]+z+"Z")}else T.attr("d","M"+k+","+A+"l"+o.px0[0]+","+o.px0[1]+z+"Z")}var R=Array.isArray(v.textposition)?v.textposition[o.i]:v.textposition,O=M.selectAll("g.slicetext").data(o.text&&"none"!==R?[0]:[]);O.enter().append("g").classed("slicetext",!0),O.exit().remove(),O.each(function(){var t=u.select(this).selectAll("text").data([0]);t.enter().append("text").attr("data-notex",1),t.exit().remove(),t.text(o.text).attr({"class":"slicetext",transform:"","data-bb":"","text-anchor":"middle",x:0,y:0}).call(d.font,"outside"===R?v.outsidetextfont:v.insidetextfont).call(p.convertToTspans),t.selectAll("tspan.line").attr({x:0,y:0});var e,r=d.bBox(t.node());"outside"===R?e=a(r,o):(e=n(r,o,c),"auto"===R&&e.scale<1&&(t.call(d.font,v.outsidetextfont),v.outsidetextfont.family===v.insidetextfont.family&&v.outsidetextfont.size===v.insidetextfont.size||(t.attr({"data-bb":""}),r=d.bBox(t.node())),e=a(r,o)));var i=k+o.pxmid[0]*e.rCenter+(e.x||0),s=A+o.pxmid[1]*e.rCenter+(e.y||0);e.outside&&(o.yLabelMin=s-r.height/2,o.yLabelMid=s,o.yLabelMax=s+r.height/2,o.labelExtraX=0,o.labelExtraY=0,m=!0),t.attr("transform","translate("+i+","+s+")"+(e.scale<1?"scale("+e.scale+")":"")+(e.rotate?"rotate("+e.rotate+")":"")+"translate("+-(r.left+r.right)/2+","+-(r.top+r.bottom)/2+")")})}),m&&o(l,v),s.each(function(t){if(t.labelExtraX||t.labelExtraY){var e=u.select(this),r=e.select("g.slicetext text");r.attr("transform","translate("+t.labelExtraX+","+t.labelExtraY+")"+r.attr("transform"));var n=t.cxFinal+t.pxmid[0],i=t.cyFinal+t.pxmid[1],a="M"+n+","+i,o=(t.yLabelMax-t.yLabelMin)*(t.pxmid[0]<0?-1:1)/4;if(t.labelExtraX){var s=t.labelExtraX*t.pxmid[1]/t.pxmid[0],l=t.yLabelMid+t.labelExtraY-(t.cyFinal+t.pxmid[1]);a+=Math.abs(s)>Math.abs(l)?"l"+l*t.pxmid[0]/t.pxmid[1]+","+l+"H"+(n+t.labelExtraX+o):"l"+t.labelExtraX+","+s+"v"+(l-s)+"h"+o}else a+="V"+(t.yLabelMid+t.labelExtraY)+"h"+o;e.append("path").classed("textline",!0).call(h.stroke,v.outsidetextfont.color).attr({"stroke-width":Math.min(2,v.outsidetextfont.size/8),d:a,fill:"none"})}})})}),setTimeout(function(){c.selectAll("tspan").each(function(){var t=u.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":303,"../../components/drawing":326,"../../lib/svg_text_utils":395,"../../plots/cartesian/graph_interact":412,"./helpers":548,d3:113}],553:[function(t,e,r){"use strict";var n=t("d3"),i=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0],r=e.trace,a=n.select(this);a.style({opacity:r.opacity}),a.selectAll(".top path.surface").each(function(t){n.select(this).call(i,t,r)})})}},{"./style_one":554,d3:113}],554:[function(t,e,r){"use strict";var n=t("../../components/color");e.exports=function(t,e,r){var i=r.marker.line.color;Array.isArray(i)&&(i=i[e.i]||n.defaultLine);var a=r.marker.line.width||0;Array.isArray(a)&&(a=a[e.i]||0),t.style({"stroke-width":a,fill:e.color}).call(n.stroke,i)}},{"../../components/color":303}],555:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t){var e=t[0].trace,r=e.marker;if(n.mergeArray(e.text,t,"tx"),n.mergeArray(e.textposition,t,"tp"),e.textfont&&(n.mergeArray(e.textfont.size,t,"ts"),n.mergeArray(e.textfont.color,t,"tc"),n.mergeArray(e.textfont.family,t,"tf")),r&&r.line){var i=r.line;n.mergeArray(r.opacity,t,"mo"),n.mergeArray(r.symbol,t,"mx"),n.mergeArray(r.color,t,"mc"),n.mergeArray(i.color,t,"mlc"),n.mergeArray(i.width,t,"mlw")}}},{"../../lib":382}],556:[function(t,e,r){"use strict";var n=t("../../components/colorscale/color_attributes"),i=t("../../components/drawing"),a=(t("./constants"),t("../../lib/extend").extendFlat);e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number",min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:a({},{symbol:{valType:"enumerated",values:i.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number",dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},showscale:{valType:"boolean",dflt:!1},line:a({},{width:{valType:"number",min:0,arrayOk:!0}},n("marker.line"))},n("marker")),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:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":311,"../../components/drawing":326,"../../lib/extend":377,"./constants":560}],557:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./subtypes"),s=t("./marker_colorscale_calc");e.exports=function(t,e){var r,l,c,u=i.getFromId(t,e.xaxis||"x"),f=i.getFromId(t,e.yaxis||"y"),h=u.makeCalcdata(e,"x"),d=f.makeCalcdata(e,"y"),p=Math.min(h.length,d.length);u._minDtick=0,f._minDtick=0,h.length>p&&h.splice(p,h.length-p),d.length>p&&d.splice(p,d.length-p);var g={padded:!0},v={padded:!0};if(o.hasMarkers(e)){if(r=e.marker,l=r.size,Array.isArray(l)){var m={type:"linear"};i.setConvert(m),l=m.makeCalcdata(e.marker,"size"),l.length>p&&l.splice(p,l.length-p)}var y,b=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/b),3)}:function(t){return Math.max((t||0)/b,3)},g.ppad=v.ppad=Array.isArray(l)?l.map(y):y(l)}s(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||h[0]===h[p-1]&&d[0]===d[p-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(o.hasMarkers(e)||o.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||h[0]===h[p-1]&&d[0]===d[p-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(v.padded=!1):v.tozero=!0,i.expand(u,h,g),i.expand(f,d,v);var x=new Array(p);for(c=0;p>c;c++)x[c]=n(h[c])&&n(d[c])?{x:h[c],y:d[c]}:{x:!1,y:!1};return void 0!==typeof l&&a.mergeArray(l,x,"ms"),t.firstscatter=!1,x}},{"../../lib":382,"../../plots/cartesian/axes":405,"./marker_colorscale_calc":570,"./subtypes":575,"fast-isnumeric":117}],558:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i,a;for(e=0;e=0;i--)if(a=t[i],"scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}},{}],559:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c=r.marker,u="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void o.autoMargin(t,u);var f=s(c.colorscale),h=c.color,d=c.cmin,p=c.cmax;i(d)||(d=a.aggNums(Math.min,null,h)),i(p)||(p=a.aggNums(Math.max,null,h));var g=e[0].t.cb=l(t,u);g.fillcolor(n.scale.linear().domain(f.map(function(t){return d+t[0]*(p-d)})).range(f.map(function(t){return t[1]}))).filllevels({start:d,end:p,size:(p-d)/254}).options(c.colorbar)()}},{"../../components/colorbar/draw":306,"../../components/colorscale/get_scale":315,"../../lib":382,"../../plots/plots":454,d3:113,"fast-isnumeric":117}],560:[function(t,e,r){"use strict";e.exports={PTS_LINESONLY:20}},{}],561:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("./constants"),o=t("./subtypes"),s=t("./xy_defaults"),l=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),h=t("./fillcolor_defaults"),d=t("../../components/errorbars/defaults");e.exports=function(t,e,r,p){function g(r,a){return n.coerce(t,e,i,r,a)}var v=s(t,e,g),m=vi(f))break;l=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,c=f,d=!1):m>y&&(m=y,u=f,d=!0)}if(d?(C[z++]=c,l!==u&&(C[z++]=u)):(u!==s&&(C[z++]=u),l!==c&&(C[z++]=c)),C[z++]=l,o>=t.length||!f)break;C[z++]=f,s=f}}else C[z++]=c}E.push(C.slice(0,z))}return E}},{"../../plots/cartesian/axes":405}],568:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=r("line.shape");"spline"===n&&r("line.smoothing")}},{}],569:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t){var e=t.marker,r=e.sizeref||1,i=e.sizemin||0,a="area"===e.sizemode?function(t){return Math.sqrt(t/r)}:function(t){return t/r};return function(t){var e=a(t/2);return n(e)&&e>0?Math.max(e,i):0}}},{"fast-isnumeric":117}],570:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("./subtypes");e.exports=function(t){if(a.hasMarkers(t)){var e=t.marker;n(t,"marker")&&i(t,e.color,"marker","c"),n(t,"marker.line")&&i(t,e.line.color,"marker.line","c")}}},{"../../components/colorscale/calc":310,"../../components/colorscale/has_colorscale":316,"./subtypes":575}],571:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l){var c,u=o.isBubble(t),f=(t.line||{}).color;f&&(r=f),l("marker.symbol"),l("marker.opacity",u?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),c=f&&e.marker.color!==f?f:u?n.background:n.defaultLine,l("marker.line.color",c),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",u?1:0),u&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode"))}},{"../../components/color":303,"../../components/colorscale/defaults":313,"../../components/colorscale/has_colorscale":316,"./subtypes":575}],572:[function(t,e,r){"use strict";function n(t,e,r){var n=e.x(),a=e.y(),o=i.extent(n.range.map(n.l2c)),s=i.extent(a.range.map(a.l2c));r.forEach(function(t,e){var n=t[0].trace;if(l.hasMarkers(n)){var i=n.marker.maxdisplayed;if(0!==i){var a=t.filter(function(t){return t.x>=o[0]&&t.x<=o[1]&&t.y>=s[0]&&t.y<=s[1]}),c=Math.ceil(a.length/i),u=0;r.forEach(function(t,r){var n=t[0].trace;l.hasMarkers(n)&&n.marker.maxdisplayed>0&&e>r&&u++});var f=Math.round(u*c/3+Math.floor(u/3)*c/7.1);t.forEach(function(t){delete t.vis}),a.forEach(function(t,e){0===Math.round((e+f)%c)&&(t.vis=!0)})}}})}var i=t("d3"),a=t("../../lib"),o=t("../../components/drawing"),s=t("../../components/errorbars"),l=t("./subtypes"),c=t("./arrays_to_calcdata"),u=t("./line_points");e.exports=function(t,e,r){function f(t){return t.filter(function(t){return t.vis})}n(t,e,r);var h=e.x(),d=e.y(),p=e.plot.select(".scatterlayer").selectAll("g.trace.scatter").data(r);p.enter().append("g").attr("class","trace scatter").style("stroke-miterlimit",2),p.call(s.plot,e);var g,v,m,y,b="";p.each(function(t){var e=t[0].trace,r=e.line,n=i.select(this);if(e.visible===!0&&(v=e.fill.charAt(e.fill.length-1),"x"!==v&&"y"!==v&&(v=""),t[0].node3=n,c(t),l.hasLines(e)||"none"!==e.fill)){var a,s,f,p,x,_="",w="";g="tozero"===e.fill.substr(0,6)||"toself"===e.fill||"to"===e.fill.substr(0,2)&&!b?n.append("path").classed("js-fill",!0):null,y&&(m=y.datum(t)),y=n.append("path").classed("js-fill",!0),-1!==["hv","vh","hvh","vhv"].indexOf(r.shape)?(f=o.steps(r.shape),p=o.steps(r.shape.split("").reverse().join(""))):f=p="spline"===r.shape?function(t){var e=t[t.length-1];return t[0][0]===e[0]&&t[0][1]===e[1]?o.smoothclosed(t.slice(1),r.smoothing):o.smoothopen(t,r.smoothing)}:function(t){return"M"+t.join("L")},x=function(t){return p(t.reverse())};var k=u(t,{xaxis:h,yaxis:d,connectGaps:e.connectgaps,baseTolerance:Math.max(r.width||1,3)/4,linear:"linear"===r.shape});if(k.length){for(var A=k[0][0],M=k[k.length-1],T=M[M.length-1],E=0;E1&&n.append("path").classed("js-line",!0).attr("d",a)}g?A&&T&&(v?("y"===v?A[1]=T[1]=d.c2p(0,!0):"x"===v&&(A[0]=T[0]=h.c2p(0,!0)),g.attr("d",_+"L"+T+"L"+A+"Z")):g.attr("d",_+"Z")):"tonext"===e.fill.substr(0,6)&&_&&b&&("tonext"===e.fill?m.attr("d",_+"Z"+b+"Z"):m.attr("d",_+"L"+b.substr(1)+"Z")),b=w}}}),p.selectAll("path:not([d])").remove(),p.append("g").attr("class","points").each(function(t){var e=t[0].trace,r=i.select(this),n=l.hasMarkers(e),s=l.hasText(e);!n&&!s||e.visible!==!0?r.remove():(n&&r.selectAll("path.point").data(e.marker.maxdisplayed?f:a.identity).enter().append("path").classed("point",!0).call(o.translatePoints,h,d),s&&r.selectAll("g").data(e.marker.maxdisplayed?f:a.identity).enter().append("g").append("text").call(o.translatePoints,h,d))})}},{"../../components/drawing":326,"../../components/errorbars":332,"../../lib":382,"./arrays_to_calcdata":555,"./line_points":567,"./subtypes":575,d3:113}],573:[function(t,e,r){"use strict";var n=t("./subtypes"),i=.2;e.exports=function(t,e){var r,a,o,s,l=t.cd,c=t.xaxis,u=t.yaxis,f=[],h=l[0].trace,d=h.index,p=h.marker;if(n.hasMarkers(h)||n.hasText(h)){var g=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(r=0;rs;s++){for(var l=[[0,0,0],[0,0,0]],c=0;3>c;c++)if(r[c])for(var u=0;2>u;u++)l[u][c]=r[c][s][u];o[s]=l}return o}var o=t("../../components/errorbars/compute_error");e.exports=a},{"../../components/errorbars/compute_error":330}],581:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.linePlot=null,this.scatterPlot=null,this.errorBars=null,this.textMarkers=null,this.delaunayMesh=null,this.color=null,this.mode="",this.dataPoints=[],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.textLabels=null,this.data=null}function i(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],s=[];for(n=0;ni;i++){var a=t[i];a&&a.copy_zstyle!==!1&&(a=t[2]),a&&(e[i]=a.width/2,r[i]=b(a.color),n=a.thickness)}return{capSize:e,color:r,lineWidth:n}}function o(t){var e=[0,0];return Array.isArray(t)?[0,-1]:(t.indexOf("bottom")>=0&&(e[1]+=1),t.indexOf("top")>=0&&(e[1]-=1),t.indexOf("left")>=0&&(e[0]-=1),t.indexOf("right")>=0&&(e[0]+=1),e)}function s(t,e){return e(4*t)}function l(t){return k[t]}function c(t,e,r,n,i){var a=null;if(Array.isArray(t)){a=[];for(var o=0;e>o;o++)void 0===t[o]?a[o]=n:a[o]=r(t[o],i)}else a=r(t,y.identity);return a}function u(t,e){var r,n,i,u,f,h,d=[],p=t.fullSceneLayout,g=t.dataScale,v=p.xaxis,m=p.yaxis,w=p.zaxis,k=e.marker,M=e.line,T=e.x||[],E=e.y||[],L=e.z||[],S=T.length;for(n=0;S>n;n++)i=v.d2l(T[n])*g[0],u=m.d2l(E[n])*g[1],f=w.d2l(L[n])*g[2],d[n]=[i,u,f];if(Array.isArray(e.text))h=e.text;else if(void 0!==e.text)for(h=new Array(S),n=0;S>n;n++)h[n]=e.text;if(r={position:d,mode:e.mode,text:h},"line"in e&&(r.lineColor=b(M.color),r.lineWidth=M.width,r.lineDashes=M.dash),"marker"in e){var C=_(e);r.scatterColor=x(k,1,S),r.scatterSize=c(k.size,S,s,20,C),r.scatterMarker=c(k.symbol,S,l,"\u25cf"),r.scatterLineWidth=k.line.width,r.scatterLineColor=x(k.line,1,S),r.scatterAngle=0}"textposition"in e&&(r.textOffset=o(e.textposition),r.textColor=x(e.textfont,1,S),r.textSize=c(e.textfont.size,S,y.identity,12),r.textFont=e.textfont.family,r.textAngle=0);var z=["x","y","z"];for(r.project=[!1,!1,!1],r.projectScale=[1,1,1],r.projectOpacity=[1,1,1],n=0;3>n;++n){var P=e.projection[z[n]];(r.project[n]=P.show)&&(r.projectOpacity[n]=P.opacity,r.projectScale[n]=P.scale)}r.errorBounds=A(e,g);var R=a([e.error_x,e.error_y,e.error_z]);return r.errorColor=R.color,r.errorLineWidth=R.lineWidth,r.errorCapSize=R.capSize,r.delaunayAxis=e.surfaceaxis,r.delaunayColor=b(e.surfacecolor),r}function f(t){if(Array.isArray(t)){var e=t[0];return Array.isArray(e)&&(t=e),"rgb("+t.slice(0,3).map(function(t){return Math.round(255*t)})+")"}return null}function h(t,e){var r=new n(t,e.uid);return r.update(e),r}var d=t("gl-line3d"),p=t("gl-scatter3d"),g=t("gl-error3d"),v=t("gl-mesh3d"),m=t("delaunay-triangulate"),y=t("../../lib"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/make_bubble_size_func"),w=t("../../constants/gl3d_dashes"),k=t("../../constants/gl_markers"),A=t("./calc_errors"),M=n.prototype;M.handlePick=function(t){if(t.object&&(t.object===this.linePlot||t.object===this.delaunayMesh||t.object===this.textMarkers||t.object===this.scatterPlot)){t.object.highlight&&t.object.highlight(null),this.scatterPlot&&(t.object=this.scatterPlot,this.scatterPlot.highlight(t.data)),this.textLabels&&void 0!==this.textLabels[t.data.index]?t.textLabel=this.textLabels[t.data.index]:t.textLabel="";var e=t.data.index;return t.traceCoordinate=[this.data.x[e],this.data.y[e],this.data.z[e]],!0}},M.update=function(t){var e,r,n,a,o=this.scene.glplot.gl,s=w.solid;this.data=t;var l=u(this.scene,t);"mode"in l&&(this.mode=l.mode),"lineDashes"in l&&l.lineDashes in w&&(s=w[l.lineDashes]),this.color=f(l.scatterColor)||f(l.lineColor),this.dataPoints=l.position,e={gl:o,position:l.position,color:l.lineColor,lineWidth:l.lineWidth||1,dashes:s[0],dashScale:s[1],opacity:t.opacity,connectGaps:t.connectgaps},-1!==this.mode.indexOf("lines")?this.linePlot?this.linePlot.update(e):(this.linePlot=d(e),this.scene.glplot.add(this.linePlot)):this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose(),this.linePlot=null);var c=t.opacity;if(t.marker&&t.marker.opacity&&(c*=t.marker.opacity),r={gl:o,position:l.position,color:l.scatterColor,size:l.scatterSize,glyph:l.scatterMarker,opacity:c,orthographic:!0,lineWidth:l.scatterLineWidth,lineColor:l.scatterLineColor,project:l.project,projectScale:l.projectScale,projectOpacity:l.projectOpacity},-1!==this.mode.indexOf("markers")?this.scatterPlot?this.scatterPlot.update(r):(this.scatterPlot=p(r),this.scatterPlot.highlightScale=1,this.scene.glplot.add(this.scatterPlot)):this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose(),this.scatterPlot=null),a={gl:o,position:l.position,glyph:l.text,color:l.textColor,size:l.textSize,angle:l.textAngle,alignment:l.textOffset,font:l.textFont,orthographic:!0,lineWidth:0,project:!1,opacity:t.opacity},this.textLabels=l.text,-1!==this.mode.indexOf("text")?this.textMarkers?this.textMarkers.update(a):(this.textMarkers=p(a),this.textMarkers.highlightScale=1,this.scene.glplot.add(this.textMarkers)):this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose(),this.textMarkers=null),n={gl:o,position:l.position,color:l.errorColor,error:l.errorBounds,lineWidth:l.errorLineWidth,capSize:l.errorCapSize,opacity:t.opacity},this.errorBars?l.errorBounds?this.errorBars.update(n):(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose(),this.errorBars=null):l.errorBounds&&(this.errorBars=g(n),this.scene.glplot.add(this.errorBars)),l.delaunayAxis>=0){var h=i(l.position,l.delaunayColor,l.delaunayAxis);h.opacity=t.opacity,this.delaunayMesh?this.delaunayMesh.update(h):(h.gl=o,this.delaunayMesh=v(h),this.scene.glplot.add(this.delaunayMesh))}else this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose(),this.delaunayMesh=null)},M.dispose=function(){this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose()),this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose()),this.errorBars&&(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose()),this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose()),this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose())},e.exports=h},{"../../constants/gl3d_dashes":368,"../../constants/gl_markers":369,"../../lib":382,"../../lib/gl_format_color":380,"../../lib/str2rgbarray":394,"../scatter/make_bubble_size_func":569,"./calc_errors":580,"delaunay-triangulate":114,"gl-error3d":121,"gl-line3d":127,"gl-mesh3d":150,"gl-scatter3d":193}],582:[function(t,e,r){"use strict";function n(t,e,r){var n=0,i=r("x"),a=r("y"),o=r("z");return i&&a&&o&&(n=Math.min(i.length,a.length,o.length),n=0&&h("surfacecolor",p||g);for(var v=["x","y","z"],m=0;3>m;++m){var y="projection."+v[m];h(y+".show")&&(h(y+".opacity"),h(y+".scale"))}c(t,e,r,{axis:"z"}),c(t,e,r,{axis:"y",inherit:"z"}),c(t,e,r,{axis:"x",inherit:"z"})}},{"../../components/errorbars/defaults":331,"../../lib":382,"../scatter/line_defaults":566,"../scatter/marker_defaults":571,"../scatter/subtypes":575,"../scatter/text_defaults":576,"./attributes":578}],583:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../constants/gl_markers":369,"../../plots/gl3d":441,"../scatter/colorbar":559,"./attributes":578,"./calc":579,"./convert":581,"./defaults":582}],584:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../components/colorscale/color_attributes"),o=t("../../lib/extend").extendFlat,s=n.marker,l=n.line,c=s.line; -e.exports={lon:{valType:"data_array"},lat:{valType:"data_array"},locations:{valType:"data_array"},locationmode:{valType:"enumerated",values:["ISO-3","USA-states","country names"],dflt:"ISO-3"},mode:o({},n.mode,{dflt:"markers"}),text:o({},n.text,{}),line:{color:l.color,width:l.width,dash:l.dash},marker:o({},{symbol:s.symbol,opacity:s.opacity,size:s.size,sizeref:s.sizeref,sizemin:s.sizemin,sizemode:s.sizemode,showscale:s.showscale,line:o({},{width:c.width},a("marker.line"))},a("marker")),textfont:n.textfont,textposition:n.textposition,hoverinfo:o({},i.hoverinfo,{flags:["lon","lat","location","text","name"]}),_nestedModules:{"marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":311,"../../lib/extend":377,"../../plots/attributes":403,"../scatter/attributes":556}],585:[function(t,e,r){"use strict";var n=t("../scatter/marker_colorscale_calc");e.exports=function(t,e){var r=[{x:!1,y:!1,trace:e,t:{}}];return n(e),r}},{"../scatter/marker_colorscale_calc":570}],586:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=0,o=r("locations");return o?(r("locationmode"),a=o.length):(n=r("lon")||[],i=r("lat")||[],a=Math.min(n.length,i.length),an;n++)r[n]=[t.lon[n],t.lat[n]];return{type:"LineString",coordinates:r,trace:t}}function a(t,e){function r(e){var r=t.mockAxis;return c.tickText(r,r.c2l(e),"hover").text+"\xb0"}var n=e.hoverinfo;if("none"===n)return function(t){delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("location")&&Array.isArray(e.locations),o=-1!==i.indexOf("lon"),s=-1!==i.indexOf("lat"),l=-1!==i.indexOf("text");return function(t){var n=[];a?n.push(t.location):o&&s?n.push("("+r(t.lon)+", "+r(t.lat)+")"):o?n.push("lon: "+r(t.lon)):s&&n.push("lat: "+r(t.lat)),l&&n.push(t.tx||e.text),t.textLabel=n.join("
")}}function o(t){var e=Array.isArray(t.locations);return function(r,n){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:n,lon:r.lon,lat:r.lat,location:e?r.location:null}]}}}var s=t("d3"),l=t("../../plots/cartesian/graph_interact"),c=t("../../plots/cartesian/axes"),u=t("../../lib/topojson_utils").getTopojsonFeatures,f=t("../../lib/geo_location_utils").locationToFeature,h=t("../../lib/array_to_calc_item"),d=t("../../components/color"),p=t("../../components/drawing"),g=t("../scatter/subtypes"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){var r,i,a,o,s=[],l=Array.isArray(t.locations);l?(o=t.locations,r=o.length,i=u(t,e),a=function(t,e){var r=f(t.locationmode,o[e],i);return void 0!==r?r.properties.ct:void 0}):(r=t.lon.length,a=function(t,e){return[t.lon[e],t.lat[e]]});for(var c=0;r>c;c++){var h=a(t,c);if(h){var d={lon:h[0],lat:h[1],location:l?t.locations[c]:null};n(t,d,c),s.push(d)}}return s.length>0&&(s[0].trace=t),s},m.plot=function(t,e){var r=t.framework.select(".scattergeolayer").selectAll("g.trace.scattergeo").data(e,function(t){return t.uid});r.enter().append("g").attr("class","trace scattergeo"),r.exit().remove(),r.selectAll("*").remove(),r.each(function(t){var e=s.select(this);g.hasLines(t)&&e.selectAll("path.js-line").data([i(t)]).enter().append("path").classed("js-line",!0)}),r.each(function(e){function r(r,n){if(t.showHover){var i=t.projection([r.lon,r.lat]);h(r),l.loneHover({x:i[0],y:i[1],name:v?e.name:void 0,text:r.textLabel,color:r.mc||(e.marker||{}).color},{container:t.hoverContainer.node()}),y=d(r,n),t.graphDiv.emit("plotly_hover",y)}}function n(e,r){t.graphDiv.emit("plotly_click",d(e,r))}var i=s.select(this),c=g.hasMarkers(e),u=g.hasText(e);if(c||u){var f=m.calcGeoJSON(e,t.topojson),h=a(t,e),d=o(e),p=e.hoverinfo,v="all"===p||-1!==p.indexOf("name"),y=null;c&&i.selectAll("path.point").data(f).enter().append("path").classed("point",!0).on("mouseover",r).on("click",n).on("mouseout",function(){l.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",y)}).on("mousedown",function(){l.loneUnhover(t.hoverContainer)}).on("mouseup",r),u&&i.selectAll("g").data(f).enter().append("g").append("text")}}),m.style(t)},m.style=function(t){var e=t.framework.selectAll("g.trace.scattergeo");e.style("opacity",function(t){return t.opacity}),e.each(function(t){s.select(this).selectAll("path.point").call(p.pointStyle,t),s.select(this).selectAll("text").call(p.textPointStyle,t)}),e.selectAll("path.js-line").style("fill","none").each(function(t){var e=t.trace,r=e.line||{};s.select(this).call(d.stroke,r.color).call(p.dashLine,r.dash||"",r.width||0)})}},{"../../components/color":303,"../../components/drawing":326,"../../lib/array_to_calc_item":373,"../../lib/geo_location_utils":379,"../../lib/topojson_utils":396,"../../plots/cartesian/axes":405,"../../plots/cartesian/graph_interact":412,"../scatter/subtypes":575,"./attributes":584,d3:113}],589:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/colorscale/color_attributes"),a=t("../../constants/gl2d_dashes"),o=t("../../constants/gl_markers"),s=t("../../lib/extend").extendFlat,l=t("../../lib/extend").extendDeep,c=n.line,u=n.marker,f=u.line;e.exports={x:n.x,x0:n.x0,dx:n.dx,y:n.y,y0:n.y0,dy:n.dy,text:s({},n.text,{}),mode:{valType:"flaglist",flags:["lines","markers"],extras:["none"]},line:{color:c.color,width:c.width,dash:{valType:"enumerated",values:Object.keys(a),dflt:"solid"}},marker:l({},i("marker"),{symbol:{valType:"enumerated",values:Object.keys(o),dflt:"circle",arrayOk:!0},size:u.size,sizeref:u.sizeref,sizemin:u.sizemin,sizemode:u.sizemode,opacity:u.opacity,showscale:u.showscale,line:l({},i("marker.line"),{width:f.width})}),connectgaps:n.connectgaps,fill:s({},n.fill,{values:["none","tozeroy","tozerox"]}),fillcolor:n.fillcolor,_nestedModules:{error_x:"ErrorBars",error_y:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":311,"../../constants/gl2d_dashes":367,"../../constants/gl_markers":369,"../../lib/extend":377,"../scatter/attributes":556}],590:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.pickXData=[],this.pickYData=[],this.xData=[],this.yData=[],this.textLabels=[],this.color="rgb(0, 0, 0)",this.name="",this.hoverinfo="all",this.connectgaps=!0,this.idToIndex=[],this.bounds=[0,0,0,0],this.hasLines=!1,this.lineOptions={positions:new Float32Array(0),color:[0,0,0,1],width:1,fill:[!1,!1,!1,!1],fillColor:[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],dashes:[1]},this.line=d(t.glplot,this.lineOptions),this.line._trace=this,this.hasErrorX=!1,this.errorXOptions={positions:new Float32Array(0),errors:new Float32Array(0),lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorX=p(t.glplot,this.errorXOptions),this.errorX._trace=this,this.hasErrorY=!1,this.errorYOptions={positions:new Float32Array(0),errors:new Float32Array(0),lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorY=p(t.glplot,this.errorYOptions),this.errorY._trace=this,this.hasMarkers=!1,this.scatterOptions={positions:new Float32Array(0),sizes:[],colors:[],glyphs:[],borderWidths:[],borderColors:[],size:12,color:[0,0,0,1],borderSize:1,borderColor:[0,0,0,1]},this.scatter=f(t.glplot,this.scatterOptions),this.scatter._trace=this,this.fancyScatter=h(t.glplot,this.scatterOptions),this.fancyScatter._trace=this}function i(t,e,r){return Array.isArray(e)||(e=[e]),a(t,e,r)}function a(t,e,r){for(var n=new Array(r),i=e[0],a=0;r>a;++a)n[a]=t(a>=e.length?i:e[a]);return n}function o(t,e,r){return l(S(t,r),L(e,r),r)}function s(t,e,r,n){var i=x(t,e,n);return i=Array.isArray(i[0])?i:a(v.identity,[i],n),l(i,L(r,n),n)}function l(t,e,r){for(var n=new Array(4*r),i=0;r>i;++i){for(var a=0;3>a;++a)n[4*i+a]=t[i][a];n[4*i+3]=t[i][3]*e[i]}return n}function c(t,e){if(void 0===Float32Array.slice){for(var r=new Float32Array(e),n=0;e>n;n++)r[n]=t[n];return r}return t.slice(0,e)}function u(t,e){var r=new n(t,e.uid);return r.update(e),r}var f=t("gl-scatter2d"),h=t("gl-scatter2d-fancy"),d=t("gl-line2d"),p=t("gl-error2d"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../plots/cartesian/axes"),y=t("../../components/errorbars"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/subtypes"),w=t("../scatter/make_bubble_size_func"),k=t("../scatter/get_trace_color"),A=t("../../constants/gl_markers"),M=t("../../constants/gl2d_dashes"),T=["xaxis","yaxis"],E=n.prototype;E.handlePick=function(t){var e=t.pointId;return(t.object!==this.line||this.connectgaps)&&(e=this.idToIndex[t.pointId]),{trace:this,dataCoord:t.dataCoord,traceCoord:[this.pickXData[e],this.pickYData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:Array.isArray(this.color)?this.color[e]:this.color,name:this.name,hoverinfo:this.hoverinfo}},E.isFancy=function(t){if("linear"!==this.scene.xaxis.type)return!0;if("linear"!==this.scene.yaxis.type)return!0;if(!t.x||!t.y)return!0;if(this.hasMarkers){var e=t.marker||{};if(Array.isArray(e.symbol)||"circle"!==e.symbol||Array.isArray(e.size)||Array.isArray(e.color)||Array.isArray(e.line.width)||Array.isArray(e.line.color)||Array.isArray(e.opacity))return!0}return this.hasLines&&!this.connectgaps?!0:this.hasErrorX?!0:!!this.hasErrorY};var L=i.bind(null,function(t){return+t}),S=i.bind(null,b),C=i.bind(null,function(t){return A[t]||"\u25cf"});E.update=function(t){t.visible!==!0?(this.hasLines=!1,this.hasErrorX=!1,this.hasErrorY=!1,this.hasMarkers=!1):(this.hasLines=_.hasLines(t),this.hasErrorX=t.error_x.visible===!0,this.hasErrorY=t.error_y.visible===!0,this.hasMarkers=_.hasMarkers(t)),this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.connectgaps=!!t.connectgaps,this.isFancy(t)?this.updateFancy(t):this.updateFast(t),this.color=k(t,{})},E.updateFast=function(t){for(var e,r,n=this.xData=this.pickXData=t.x,i=this.yData=this.pickYData=t.y,a=n.length,o=new Array(a),s=new Float32Array(2*a),l=this.bounds,u=0,f=0,h=0;a>h;++h)e=n[h],r=i[h],g(e)&&g(r)&&(o[u++]=h,s[f++]=e,s[f++]=r,l[0]=Math.min(l[0],e),l[1]=Math.min(l[1],r),l[2]=Math.max(l[2],e),l[3]=Math.max(l[3],r));s=c(s,f),this.idToIndex=o,this.updateLines(t,s),this.updateError("X",t),this.updateError("Y",t);var d;if(this.hasMarkers){this.scatterOptions.positions=s;var p=b(t.marker.color),v=b(t.marker.line.color),m=t.opacity*t.marker.opacity;p[3]*=m,this.scatterOptions.color=p,v[3]*=m,this.scatterOptions.borderColor=v,d=t.marker.size,this.scatterOptions.size=d,this.scatterOptions.borderSize=t.marker.line.width,this.scatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions),this.expandAxesFast(l,d)},E.updateFancy=function(t){var e=this.scene,r=e.xaxis,n=e.yaxis,a=this.bounds,o=this.pickXData=r.makeCalcdata(t,"x").slice(),l=this.pickYData=n.makeCalcdata(t,"y").slice();this.xData=o.slice(),this.yData=l.slice();var u,f,h,d,p,g,v,m,b=y.calcFromTrace(t,e.fullLayout),x=o.length,_=new Array(x),k=new Float32Array(2*x),A=new Float32Array(4*x),M=new Float32Array(4*x),T=0,E=0,S=0,z=0,P="log"===r.type?function(t){return r.d2l(t)}:function(t){return t},R="log"===n.type?function(t){return n.d2l(t)}:function(t){return t};for(u=0;x>u;++u)this.xData[u]=h=P(o[u]),this.yData[u]=d=R(l[u]),isNaN(h)||isNaN(d)||(_[T++]=u,k[E++]=h,k[E++]=d,p=A[S++]=h-b[u].xs||0,g=A[S++]=b[u].xh-h||0,A[S++]=0,A[S++]=0,M[z++]=0,M[z++]=0,v=M[z++]=d-b[u].ys||0,m=M[z++]=b[u].yh-d||0,a[0]=Math.min(a[0],h-p),a[1]=Math.min(a[1],d-v),a[2]=Math.max(a[2],h+g),a[3]=Math.max(a[3],d+m));k=c(k,E),this.idToIndex=_,this.updateLines(t,k),this.updateError("X",t,k,A),this.updateError("Y",t,k,M);var O;if(this.hasMarkers){this.scatterOptions.positions=k,this.scatterOptions.sizes=new Array(T),this.scatterOptions.glyphs=new Array(T),this.scatterOptions.borderWidths=new Array(T),this.scatterOptions.colors=new Array(4*T),this.scatterOptions.borderColors=new Array(4*T);var I,N=w(t),j=t.marker,F=j.opacity,D=t.opacity,B=s(j,F,D,x),U=C(j.symbol,x),V=L(j.line.width,x),q=s(j.line,F,D,x);for(O=i(N,j.size,x),u=0;T>u;++u)for(I=_[u],this.scatterOptions.sizes[u]=4*O[I],this.scatterOptions.glyphs[u]=U[I],this.scatterOptions.borderWidths[u]=.5*V[I],f=0;4>f;++f)this.scatterOptions.colors[4*u+f]=B[4*I+f],this.scatterOptions.borderColors[4*u+f]=q[4*I+f];this.fancyScatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions),this.expandAxesFancy(o,l,O)},E.updateLines=function(t,e){var r;if(this.hasLines){var n=e;if(!t.connectgaps){var i=0,a=this.xData,s=this.yData;for(n=new Float32Array(2*a.length),r=0;ro;o++)r=this.scene[T[o]],n=r._min,n||(n=[]),n.push({val:t[o],pad:a}),i=r._max,i||(i=[]),i.push({val:t[o+2],pad:a})},E.expandAxesFancy=function(t,e,r){var n=this.scene,i={padded:!0,ppad:r};m.expand(n.xaxis,t,i),m.expand(n.yaxis,e,i)},E.dispose=function(){this.line.dispose(),this.errorX.dispose(),this.errorY.dispose(),this.scatter.dispose(),this.fancyScatter.dispose()},e.exports=u},{"../../components/errorbars":332,"../../constants/gl2d_dashes":367,"../../constants/gl_markers":369,"../../lib":382,"../../lib/gl_format_color":380,"../../lib/str2rgbarray":394,"../../plots/cartesian/axes":405,"../scatter/get_trace_color":563,"../scatter/make_bubble_size_func":569,"../scatter/subtypes":575,"fast-isnumeric":117,"gl-error2d":119,"gl-line2d":125,"gl-scatter2d":190,"gl-scatter2d-fancy":185}],591:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/xy_defaults"),s=t("../scatter/marker_defaults"),l=t("../scatter/line_defaults"),c=t("../scatter/fillcolor_defaults"),u=t("../../components/errorbars/defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p=o(t,e,d);return p?(d("text"),d("mode",pr;r++)y=e.a[r],b=e.b[r],x=e.c[r],n(y)&&n(b)&&n(x)?(y=+y,b=+b,x=+x,_=v/(y+b+x),1!==_&&(y*=_,b*=_,x*=_),k=y,w=x-b,M[r]={x:w,y:k,a:y,b:b,c:x}):M[r]={x:!1,y:!1};var T,E;if(o.hasMarkers(e)&&(T=e.marker,E=T.size,Array.isArray(E))){var L={type:"linear"};i.setConvert(L),E=L.makeCalcdata(e.marker,"size"),E.length>A&&E.splice(A,E.length-A)}return s(e),void 0!==typeof E&&a.mergeArray(E,M,"ms"),M}},{"../../lib":382,"../../plots/cartesian/axes":405,"../scatter/marker_colorscale_calc":570,"../scatter/subtypes":575,"fast-isnumeric":117}],595:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/marker_defaults"),s=t("../scatter/line_defaults"),l=t("../scatter/line_shape_defaults"),c=t("../scatter/text_defaults"),u=t("../scatter/fillcolor_defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p,g=d("a"),v=d("b"),m=d("c");if(g?(p=g.length,v?(p=Math.min(p,v.length),m&&(p=Math.min(p,m.length))):p=m?Math.min(p,m.length):0):v&&m&&(p=Math.min(v.length,m.length)),!p)return void(e.visible=!1);g&&p"),s}}},{"../../plots/cartesian/axes":405,"../scatter/hover":564}],597:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../plots/ternary":461,"../scatter/colorbar":559,"./attributes":593,"./calc":594,"./defaults":595,"./hover":596,"./plot":598,"./select":599,"./style":600}],598:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e){var r=t.plotContainer;r.select(".scatterlayer").selectAll("*").remove();for(var i={x:function(){return t.xaxis},y:function(){return t.yaxis},plot:r},a=new Array(e.length),o=t.graphDiv.calcdata,s=0;se){for(var r=g/e,n=[0|Math.floor(t[0].shape[0]*r+1),0|Math.floor(t[0].shape[1]*r+1)],i=n[0]*n[1],o=0;or;++r)this.showContour[r]&&(e=!0,t[r]=this.scene.contourLevels[r]);e&&this.surface.update({levels:t})},v.update=function(t){var e,r=this.scene,n=r.fullSceneLayout,a=this.surface,s=t.opacity,l=i(t.colorscale,s),u=t.z,h=t.x,d=t.y,g=n.xaxis,v=n.yaxis,m=n.zaxis,y=r.dataScale,b=u[0].length,x=u.length,_=[c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x])],w=_[0],k=_[1],A=r.contourLevels;this.data=t,f(_[2],function(t,e){return m.d2l(u[e][t])*y[2]}),Array.isArray(h[0])?f(w,function(t,e){return g.d2l(h[e][t])*y[0]}):f(w,function(t){return g.d2l(h[t])*y[0]}),Array.isArray(d[0])?f(k,function(t,e){return v.d2l(d[e][t])*y[1]}):f(k,function(t,e){return v.d2l(d[e])*y[1]});var M={colormap:l,levels:[[],[],[]],showContour:[!0,!0,!0],showSurface:!t.hidesurface,contourProject:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],contourWidth:[1,1,1],contourColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],contourTint:[1,1,1],dynamicColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],dynamicWidth:[1,1,1],dynamicTint:[1,1,1],opacity:1};if(M.intensityBounds=[t.cmin,t.cmax],t.surfacecolor){var T=c(new Float32Array(b*x),[b,x]);f(T,function(e,r){return t.surfacecolor[r][e]}),_.push(T)}else M.intensityBounds[0]*=y[2],M.intensityBounds[1]*=y[2];this.dataScale=o(_),t.surfacecolor&&(M.intensity=_.pop()),"opacity"in t&&t.opacity<1&&(M.opacity=.25*t.opacity);var E=[!0,!0,!0],L=["x","y","z"];for(e=0;3>e;++e){var S=t.contours[L[e]];E[e]=S.highlight,M.showContour[e]=S.show||S.highlight,M.showContour[e]&&(M.contourProject[e]=[S.project.x,S.project.y,S.project.z],S.show?(this.showContour[e]=!0,M.levels[e]=A[e],a.highlightColor[e]=M.contourColor[e]=p(S.color),S.usecolormap?a.highlightTint[e]=M.contourTint[e]=0:a.highlightTint[e]=M.contourTint[e]=1,M.contourWidth[e]=S.width):this.showContour[e]=!1,S.highlight&&(M.dynamicColor[e]=p(S.highlightcolor),M.dynamicWidth[e]=S.highlightwidth))}M.coords=_,a.update(M),a.visible=t.visible,a.enableDynamic=E,a.snapToData=!0,"lighting"in t&&(a.ambientLight=t.lighting.ambient,a.diffuseLight=t.lighting.diffuse,a.specularLight=t.lighting.specular,a.roughness=t.lighting.roughness,a.fresnel=t.lighting.fresnel),"lightposition"in t&&(a.lightPosition=[t.lightposition.x,t.lightposition.y,t.lightposition.z]),s&&1>s&&(a.supportsTransparency=!0)},v.dispose=function(){this.scene.glplot.remove(this.surface),this.surface.dispose()},e.exports=s},{"../../lib/str2rgbarray":394,"gl-surface3d":221,ndarray:253,"ndarray-fill":246,"ndarray-homography":251,"ndarray-ops":252,tinycolor2:274}],605:[function(t,e,r){"use strict";function n(t,e,r){e in t&&!(r in t)&&(t[r]=t[e])}var i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}var c,u,f=l("z");if(!f)return void(e.visible=!1);var h=f[0].length,d=f.length;if(l("x"),l("y"),!Array.isArray(e.x))for(e.x=[],c=0;h>c;++c)e.x[c]=c;if(l("text"),!Array.isArray(e.y))for(e.y=[],c=0;d>c;++c)e.y[c]=c;["lighting.ambient","lighting.diffuse","lighting.specular","lighting.roughness","lighting.fresnel","lightposition.x","lightposition.y","lightposition.z","hidesurface","opacity"].forEach(function(t){l(t)});var p=l("surfacecolor");l("colorscale");var g=["x","y","z"];for(c=0;3>c;++c){var v="contours."+g[c],m=l(v+".show"),y=l(v+".highlight");if(m||y)for(u=0;3>u;++u)l(v+".project."+g[u]);m&&(l(v+".color"),l(v+".width"),l(v+".usecolormap")),y&&(l(v+".highlightcolor"),l(v+".highlightwidth"))}p||(n(t,"zmin","cmin"),n(t,"zmax","cmax"),n(t,"zauto","cauto")),a(t,e,s,l,{prefix:"",cLetter:"c"})}},{"../../components/colorscale/defaults":313,"../../lib":382,"./attributes":601}],606:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("./colorbar"),n.calc=t("./calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="surface",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","noOpacity"],n.meta={},e.exports=n},{"../../plots/gl3d":441,"./attributes":601,"./calc":602,"./colorbar":603,"./convert":604,"./defaults":605}]},{},[12])(12)}); \ No newline at end of file +}if(0===r.length)return 0===n.length?s:l(a(n));var m=h(r),y=o(m.slabs,m.coordinates);return 0===n.length?y:c(a(n),y)}e.exports=u;var f=t("robust-orientation")[3],h=t("slab-decomposition"),d=t("interval-tree-1d"),p=t("binary-search-bounds")},{"binary-search-bounds":288,"interval-tree-1d":289,"robust-orientation":259,"slab-decomposition":292}],294:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function i(t){for(var e=new Array(t),r=0;t>r;++r)e[r]=[];return e}function a(t,e){function r(t){for(var r=t.length,n=[0],i=0;r>i;++i){var a=e[t[i]],o=e[t[(i+1)%r]],s=c(-a[0],a[1]),l=c(-a[0],o[1]),f=c(o[0],a[1]),h=c(o[0],o[1]);n=u(n,u(u(s,l),u(f,h)))}return n[n.length-1]>0}function a(t){for(var e=t.length,r=0;e>r;++r)if(!O[t[r]])return!1;return!0}var d=h(t,e);t=d[0],e=d[1];for(var p=e.length,g=(t.length,o(t,e.length)),v=0;p>v;++v)if(g[v].length%2===1)throw new Error("planar-graph-to-polyline: graph must be manifold");var m=s(t,e);m=m.filter(r);for(var y=m.length,b=new Array(y),x=new Array(y),v=0;y>v;++v){b[v]=v;var _=new Array(y),w=m[v].map(function(t){return e[t]}),k=l([w]),A=0;t:for(var M=0;y>M;++M)if(_[M]=0,v!==M){for(var T=m[M],E=T.length,L=0;E>L;++L){var S=k(e[T[L]]);if(0!==S){0>S&&(_[M]=1,A+=1);continue t}}_[M]=1,A+=1}x[v]=[A,v,_]}x.sort(function(t,e){return e[0]-t[0]});for(var v=0;y>v;++v)for(var _=x[v],C=_[1],z=_[2],M=0;y>M;++M)z[M]&&(b[M]=C);for(var P=i(y),v=0;y>v;++v)P[v].push(b[v]),P[b[v]].push(v);for(var R={},O=n(p,!1),v=0;y>v;++v)for(var T=m[v],E=T.length,M=0;E>M;++M){var I=T[M],N=T[(M+1)%E],j=Math.min(I,N)+":"+Math.max(I,N);if(j in R){var F=R[j];P[F].push(v),P[v].push(F),O[I]=O[N]=!0}else R[j]=v}for(var D=[],B=n(y,-1),v=0;y>v;++v)b[v]!==v||a(m[v])?B[v]=-1:(D.push(v),B[v]=0);for(var d=[];D.length>0;){var U=D.pop(),V=P[U];f(V,function(t,e){return t-e});var q,H=V.length,G=B[U];if(0===G){var T=m[U];q=[T]}for(var v=0;H>v;++v){var Y=V[v];if(!(B[Y]>=0)&&(B[Y]=1^G,D.push(Y),0===G)){var T=m[Y];a(T)||(T.reverse(),q.push(T))}}0===G&&d.push(q)}return d}e.exports=a;var o=t("edges-to-adjacency-list"),s=t("planar-dual"),l=t("point-in-big-polygon"),c=t("two-product"),u=t("robust-sum"),f=t("uniq"),h=t("./lib/trim-leaves")},{"./lib/trim-leaves":282,"edges-to-adjacency-list":283,"planar-dual":284,"point-in-big-polygon":293,"robust-sum":262,"two-product":276,uniq:279}],295:[function(t,e,r){arguments[4][50][0].apply(r,arguments)},{dup:50}],296:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;t>e;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n,n.prototype.length=function(){return this.roots.length},n.prototype.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},n.prototype.find=function(t){for(var e=this.roots;e[t]!==t;){var r=e[t];e[t]=e[r],t=r}return t},n.prototype.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],297:[function(t,e,r){arguments[4][238][0].apply(r,arguments)},{"bit-twiddle":295,dup:238,"union-find":296}],298:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.abs(a(t,e,r)),i=Math.sqrt(Math.pow(e[0]-r[0],2)+Math.pow(e[1]-r[1],2));return n/i}function i(t,e,r){function i(t){if(x[t])return 1/0;var r=m[t],i=y[t];return 0>r||0>i?1/0:n(e[t],e[r],e[i])}function a(t,e){var r=M[t],n=M[e];M[t]=n,M[e]=r,T[r]=e,T[n]=t}function s(t){return b[M[t]]}function l(t){return 1&t?t-1>>1:(t>>1)-1}function c(t){for(var e=s(t);;){var r=e,n=2*t+1,i=2*(t+1),o=t;if(L>n){var l=s(n);r>l&&(o=n,r=l)}if(L>i){var c=s(i);r>c&&(o=i)}if(o===t)return t;a(t,o),t=o}}function u(t){for(var e=s(t);t>0;){var r=l(t);if(r>=0){var n=s(r);if(n>e){a(t,r),t=r;continue}}return t}}function f(){if(L>0){var t=M[0];return a(0,L-1),L-=1,c(0),t}return-1}function h(t,e){var r=M[t];return b[r]===e?t:(b[r]=-(1/0),u(t),f(),b[r]=e,L+=1,u(L-1))}function d(t){if(!x[t]){x[t]=!0;var e=m[t],r=y[t];m[r]>=0&&(m[r]=e),y[e]>=0&&(y[e]=r),T[e]>=0&&h(T[e],i(e)),T[r]>=0&&h(T[r],i(r))}}function p(t,e){if(t[e]<0)return e;var r=e,n=e;do{var i=t[n];if(!x[n]||0>i||i===n)break;if(n=i,i=t[n],!x[n]||0>i||i===n)break;n=i,r=t[r]}while(r!==n);for(var a=e;a!==n;a=t[a])t[a]=n;return n}for(var g=e.length,v=t.length,m=new Array(g),y=new Array(g),b=new Array(g),x=new Array(g),_=0;g>_;++_)m[_]=y[_]=-1,b[_]=1/0,x[_]=!1;for(var _=0;v>_;++_){var w=t[_];if(2!==w.length)throw new Error("Input must be a graph");var k=w[1],A=w[0];-1!==y[A]?y[A]=-2:y[A]=k,-1!==m[k]?m[k]=-2:m[k]=A}for(var M=[],T=new Array(g),_=0;g>_;++_){var E=b[_]=i(_);1/0>E?(T[_]=M.length,M.push(_)):T[_]=-1}for(var L=M.length,_=L>>1;_>=0;--_)c(_);for(;;){var S=f();if(0>S||b[S]>r)break;d(S)}for(var C=[],_=0;g>_;++_)x[_]||(T[_]=C.length,C.push(e[_].slice()));var z=(C.length,[]);return t.forEach(function(t){var e=p(m,t[0]),r=p(y,t[1]);if(e>=0&&r>=0&&e!==r){var n=T[e],i=T[r];n!==i&&z.push([n,i])}}),o.unique(o.normalize(z)),{positions:C,edges:z}}e.exports=i;var a=t("robust-orientation"),o=t("simplicial-complex")},{"robust-orientation":259,"simplicial-complex":297}],299:[function(t,e,r){"use strict";e.exports=["",{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],300:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:o({},i,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.x.toString()]},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.y.toString()]},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":377,"../../plots/cartesian/constants":410,"../../plots/font_attributes":423,"./arrow_paths":299}],301:[function(t,e,r){"use strict";function n(t,e){function r(e,r){return c.coerce(t,n,v.layoutAttributes,e,r)}var n={};r("opacity"),r("align"),r("bgcolor");var i=r("bordercolor"),a=f.opacity(i);r("borderpad");var o=r("borderwidth"),s=r("showarrow");s&&(r("arrowcolor",a?n.bordercolor:f.defaultLine),r("arrowhead"),r("arrowsize"),r("arrowwidth",2*(a&&o||1)),r("ax"),r("ay"),r("axref"),r("ayref"),c.noneOrAll(t,n,["ax","ay"])),r("text",s?" ":"new text"),r("textangle"),c.coerceFont(r,"font",e.font);for(var l=["x","y"],h=0;2>h;h++){var d=l[h],p={_fullLayout:e},g=u.coerceRef(t,n,p,d),m=u.coerceARef(t,n,p,d),y=.5;if("paper"!==g){var b=u.getFromId(p,g);if(y=b.range[0]+y*(b.range[1]-b.range[0]),-1!==["date","category"].indexOf(b.type)&&"string"==typeof t[d]){var x;if("date"===b.type){if(x=c.dateTime2ms(t[d]),x!==!1&&(t[d]=x),m===g){var _=c.dateTime2ms(t["a"+d]);_!==!1&&(t["a"+d]=_)}}else(b._categories||[]).length&&(x=b._categories.indexOf(t[d]),-1!==x&&(t[d]=x))}}r(d,y),s||r(d+"anchor")}return c.noneOrAll(t,n,["x","y"]),n}function i(t){var e=t._fullLayout;e.annotations.forEach(function(e){var r=u.getFromId(t,e.xref),n=u.getFromId(t,e.yref);if(r||n){var i=(e._xsize||0)/2,a=e._xshift||0,o=(e._ysize||0)/2,s=e._yshift||0,l=i-a,c=i+a,f=o-s,h=o+s;if(e.showarrow){var d=3*e.arrowsize*e.arrowwidth;l=Math.max(l,d),c=Math.max(c,d),f=Math.max(f,d),h=Math.max(h,d)}r&&r.autorange&&u.expand(r,[r.l2c(e.x)],{ppadplus:c,ppadminus:l}),n&&n.autorange&&u.expand(n,[n.l2c(e.y)],{ppadplus:h,ppadminus:f})}})}function a(t,e,r,n,i,a,o,s){var l=r-t,c=i-t,u=o-i,f=n-e,h=a-e,d=s-a,p=l*d-u*f;if(0===p)return null;var g=(c*d-u*h)/p,v=(c*f-l*h)/p;return 0>v||v>1||0>g||g>1?null:{x:t+l*g,y:e+f*g}}var o=t("d3"),s=t("fast-isnumeric"),l=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),h=t("../drawing"),d=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var r=t.annotations||[],i=e.annotations=[],a=0;at?"left":t>2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var n=W.select(".annotation-math-group"),i=!n.empty(),s=h.bBox((i?n:tt).node()),d=s.width,m=s.height,y=Math.round(d+2*$),b=Math.round(m+2*$);U._w=d,U._h=m;var x=!1;if(["x","y"].forEach(function(e){var n,i=U[e+"ref"]||e,a=u.getFromId(t,i),o=(G+("x"===e?0:90))*Math.PI/180,s=y*Math.abs(Math.cos(o))+b*Math.abs(Math.sin(o)),l=U[e+"anchor"];if(a){if(!a.autorange&&(U[e]-a.range[0])*(U[e]-a.range[1])>0&&(U["a"+e+"ref"]===i?(U["a"+e]-a.range[0])*(U["a"+e]-a.range[1])>0&&(x=!0):x=!0,x))return;H[e]=a._offset+a.l2p(U[e]),n=.5}else n=U[e],"y"===e&&(n=1-n),H[e]="x"===e?S.l+S.w*n:S.t+S.h*n;var c=0;U["a"+e+"ref"]===i?H["aa"+e]=a._offset+a.l2p(U["a"+e]):(c=U.showarrow?U["a"+e]:s*r(n,l),H[e]+=c),U["_"+e+"type"]=a&&a.type,U["_"+e+"size"]=s,U["_"+e+"shift"]=c}),x)return void W.remove();var w,k;U.showarrow&&(w=U.axref===U.xref?H.x:c.constrain(H.x-U.ax,1,_.width-1),k=U.ayref===U.yref?H.y:c.constrain(H.y-U.ay,1,_.height-1)),H.x=c.constrain(H.x,1,_.width-1),H.y=c.constrain(H.y,1,_.height-1);var A=$-s.top,M=$-s.left;i?n.select("svg").attr({x:$-1,y:$}):(tt.attr({x:M,y:A}),tt.selectAll("tspan.line").attr({y:A,x:M})),Q.call(h.setRect,Z/2,Z/2,y-Z,b-Z);var T=0,E=0;T=U.axref===U.xref?Math.round(H.aax-y/2):Math.round(H.x-y/2),E=U.ayref===U.yref?Math.round(H.aay-b/2):Math.round(H.y-b/2),W.call(c.setTranslate,T,E);var L="annotations["+e+"]",C=function(r,n){o.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var i,s;i=U.axref===U.xref?H.aax+r:H.x+r,s=U.ayref===U.yref?H.aay+n:H.y+n;var u=c.rotationXYMatrix(G,i,s),h=c.apply2DTransform(u),d=c.apply2DTransform2(u),p=Q.attr("width")/2,m=Q.attr("height")/2,y=[[i-p,s-m,i-p,s+m],[i-p,s+m,i+p,s+m],[i+p,s+m,i+p,s-m],[i+p,s-m,i-p,s-m]].map(d);if(!y.reduce(function(t,e){return t^!!a(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=a(i,s,w,k,t[0],t[1],t[2],t[3]);e&&(i=e.x,s=e.y)});var b=U.arrowwidth,x=U.arrowcolor,_=Y.append("g").style({opacity:f.opacity(x)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),A=_.append("path").attr("d","M"+i+","+s+"L"+w+","+k).style("stroke-width",b+"px").call(f.stroke,f.rgb(x));v.arrowhead(A,U.arrowhead,"end",U.arrowsize);var M=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(i-w)+","+(s-k),transform:"translate("+w+","+k+")"}).style("stroke-width",b+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var T,E,C;g.init({element:M.node(),prepFn:function(){var t=c.getTranslate(W);E=t.x,C=t.y,T={},V&&V.autorange&&(T[V._name+".autorange"]=!0),q&&q.autorange&&(T[q._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var r=h(E,C),n=r[0]+t,i=r[1]+e;W.call(c.setTranslate,n,i),T[L+".x"]=V?U.x+t/V._m:(w+t-S.l)/S.w,T[L+".y"]=q?U.y+e/q._m:1-(k+e-S.t)/S.h,U.axref===U.xref&&(T[L+".ax"]=V?U.ax+t/V._m:(w+t-S.l)/S.w),U.ayref===U.yref&&(T[L+".ay"]=q?U.ay+e/q._m:1-(k+e-S.t)/S.h),X.attr({transform:"rotate("+G+","+n+","+i+")"})},doneFn:function(e){if(e){l.relayout(t,T);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}};U.showarrow&&C(0,0);var z=c.rotationXYMatrix(G,H.x,H.y),P=c.apply2DTransform(z);if(t._context.editable){var R,O,I;g.init({element:W.node(),prepFn:function(){var t=c.getTranslate(W);R=t.x,O=t.y,I={}},moveFn:function(t,e){W.call(c.setTranslate,R+t,O+e);var r="pointer";if(U.showarrow)U.axref===U.xref?I[L+".ax"]=V.p2l(V.l2p(U.ax)+t):I[L+".ax"]=U.ax+t,U.ayref===U.yref?I[L+".ay"]=q.p2l(q.l2p(U.ay)+e):I[L+".ay"]=U.ay+e,C(t,e);else{if(V)I[L+".x"]=U.x+t/V._m;else{var n=U._xsize/S.w,i=U.x+U._xshift/S.w-n/2;I[L+".x"]=g.align(i+t/S.w,n,0,1,U.xanchor)}if(q)I[L+".y"]=U.y+e/q._m;else{var a=U._ysize/S.h,o=U.y-U._yshift/S.h-a/2;I[L+".y"]=g.align(o-e/S.h,a,0,1,U.yanchor)}V&&q||(r=g.getCursor(V?.5:I[L+".x"],q?.5:I[L+".y"],U.xanchor,U.yanchor))}var s=P(R,O),l=s[0]+t,u=s[1]+e;W.call(c.setTranslate,R+t,O+e),X.attr({transform:"rotate("+G+","+l+","+u+")"}),p(W,r)},doneFn:function(e){if(p(W),e){l.relayout(t,I);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}var b,x=t.layout,_=t._fullLayout;if(!s(e)||-1===e){if(!e&&Array.isArray(i))return x.annotations=i,v.supplyLayoutDefaults(x,_),void v.drawAll(t);if("remove"===i)return delete x.annotations,_.annotations=[],void v.drawAll(t);if(r&&"add"!==i){for(b=0;b<_.annotations.length;b++)v.draw(t,b,r,i);return}e=_.annotations.length,_.annotations.push({})}if(!r&&i){if("remove"===i){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),x.annotations.splice(e,1),b=e;b<_.annotations.length;b++)_._infolayer.selectAll('.annotation[data-index="'+(b+1)+'"]').attr("data-index",String(b)),v.draw(t,b);return}if("add"===i||c.isPlainObject(i)){_.annotations.splice(e,0,{});var w=c.isPlainObject(i)?c.extendFlat({},i):{text:"New text"};for(x.annotations?x.annotations.splice(e,0,w):x.annotations=[w],b=_.annotations.length-1;b>e;b--)_._infolayer.selectAll('.annotation[data-index="'+(b-1)+'"]').attr("data-index",String(b)),v.draw(t,b)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=x.annotations[e],A=_.annotations[e];if(k){var M={xref:k.xref,yref:k.yref},T={};"string"==typeof r&&r?T[r]=i:c.isPlainObject(r)&&(T=r);var E=Object.keys(T);for(b=0;bb;b++){var z=C[b];if(void 0===T[z]&&void 0!==k[z]){var P=u.getFromId(t,u.coerceRef(M,{},t,z)),R=u.getFromId(t,u.coerceRef(k,{},t,z)),O=k[z],I=A["_"+z+"type"];if(void 0!==T[z+"ref"]){var N="auto"===k[z+"anchor"],j="x"===z?S.w:S.h,F=(A["_"+z+"size"]||0)/(2*j);if(P&&R)O=(O-P.range[0])/(P.range[1]-P.range[0]),O=R.range[0]+O*(R.range[1]-R.range[0]);else if(P){if(O=(O-P.range[0])/(P.range[1]-P.range[0]),O=P.domain[0]+O*(P.domain[1]-P.domain[0]),N){var D=O+F,B=O-F;2/3>O+B?O=B:O+D>4/3&&(O=D)}}else R&&(N&&(1/3>O?O+=F:O>2/3&&(O-=F)),O=(O-R.domain[0])/(R.domain[1]-R.domain[0]),O=R.range[0]+O*(R.range[1]-R.range[0]))}R&&R===P&&I&&("log"===I&&"log"!==R.type?O=Math.pow(10,O):"log"!==I&&"log"===R.type&&(O=O>0?Math.log(O)/Math.LN10:void 0)),k[z]=O}}var U=n(k,_);_.annotations[e]=U;var V=u.getFromId(t,U.xref),q=u.getFromId(t,U.yref),H={x:0,y:0},G=+U.textangle||0,Y=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",U.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:U})}),X=Y.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),W=X.append("g"),Z=U.borderwidth,K=U.borderpad,$=Z+K,Q=W.append("rect").attr("class","bg").style("stroke-width",Z+"px").call(f.stroke,U.bordercolor).call(f.fill,U.bgcolor),J=U.font,tt=W.append("text").classed("annotation",!0).attr("data-unformatted",U.text).text(U.text);t._context.editable?tt.call(d.makeEditable,W).call(m).on("edit",function(r){U.text=r,this.attr({"data-unformatted":U.text}),this.call(m);var n={};n["annotations["+e+"].text"]=U.text,V&&V.autorange&&(n[V._name+".autorange"]=!0),q&&q.autorange&&(n[q._name+".autorange"]=!0),l.relayout(t,n)}):tt.call(m),X.attr({transform:"rotate("+G+","+H.x+","+H.y+")"}).call(h.setPosition,H.x,H.y)}},v.arrowhead=function(t,e,r,n){s(n)||(n=1);var i=t.node(),a=v.ARROWPATHS[e||0];if(a){"string"==typeof r&&r||(r="end");var l,c,u,d,p=(h.getPx(t,"stroke-width")||1)*n,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=r.indexOf("start")>=0,b=r.indexOf("end")>=0,x=a.backoff*p;if("line"===i.nodeName){if(l={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(l.y-c.y,l.x-c.x),d=u+Math.PI,x){var _=x*Math.cos(u),w=x*Math.sin(u);y&&(l.x-=_,l.y-=w,t.attr({x1:l.x,y1:l.y})),b&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===i.nodeName){var k=i.getTotalLength(),A="";if(y){var M=i.getPointAtLength(0),T=i.getPointAtLength(.1);u=Math.atan2(M.y-T.y,M.x-T.x),l=i.getPointAtLength(Math.min(x,k)),x&&(A="0px,"+x+"px,")}if(b){var E=i.getPointAtLength(k),L=i.getPointAtLength(k-.1);if(d=Math.atan2(E.y-L.y,E.x-L.x),c=i.getPointAtLength(Math.max(0,k-x)),x){var S=A?2*x:x;A+=k-S+"px,"+k+"px"}}else A&&(A+=k+"px");A&&t.style("stroke-dasharray",A)}var C=function(r,n){e>5&&(n=0),o.select(i.parentElement).append("path").attr({"class":t.attr("class"),d:a.path,transform:"translate("+r.x+","+r.y+")rotate("+180*n/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(l,u),b&&C(c,d)}},v.calcAutorange=function(t){var e=t._fullLayout,r=e.annotations;if(r.length&&t._fullData.length){var n={};r.forEach(function(t){n[t.xref]=!0,n[t.yref]=!0});var a=u.list(t).filter(function(t){return t.autorange&&n[t._id]});if(a.length)return c.syncOrAsync([v.drawAll,i],t)}}},{"../../lib":382,"../../lib/setcursor":391,"../../lib/svg_text_utils":395,"../../plotly":402,"../../plots/cartesian/axes":405,"../color":303,"../dragelement":324,"../drawing":326,"./arrow_paths":299,"./attributes":300,d3:113,"fast-isnumeric":117}],302:[function(t,e,r){"use strict";r.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],r.defaultLine="#444",r.lightLine="#eee",r.background="#fff",r.lightFraction=1e3/11},{}],303:[function(t,e,r){"use strict";function n(t){if(a(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var r=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!r)return t;var n=r[1].trim().split(/\s*[\s,]\s*/),i="a"===e.charAt(3)&&4===n.length;if(!i&&3!==n.length)return t;for(var o=0;o=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}var i=t("tinycolor2"),a=t("fast-isnumeric"),o=e.exports={},s=t("./attributes");o.defaults=s.defaults,o.defaultLine=s.defaultLine,o.lightLine=s.lightLine,o.background=s.background,o.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},o.rgb=function(t){return o.tinyRGB(i(t))},o.opacity=function(t){return t?i(t).getAlpha():0},o.addOpacity=function(t,e){var r=i(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},o.combine=function(t,e){var r=i(t).toRgb();if(1===r.a)return i(t).toRgbString();var n=i(e||o.background).toRgb(),a=1===n.a?n:{r:255*(1-n.a)+n.r*n.a,g:255*(1-n.a)+n.g*n.a,b:255*(1-n.a)+n.b*n.a},s={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return i(s).toRgbString()},o.stroke=function(t,e){var r=i(e);t.style({stroke:o.tinyRGB(r),"stroke-opacity":r.getAlpha()})},o.fill=function(t,e){var r=i(e);t.style({fill:o.tinyRGB(r),"fill-opacity":r.getAlpha()})},o.clean=function(t){if(t&&"object"==typeof t){var e,r,i,a,s=Object.keys(t);for(e=0;el&&(a[1]-=(ot-l)/2)):r.node()&&!r.classed("js-placeholder")&&(ot=h.bBox(e.node()).height),ot){if(ot+=5,"top"===x.titleside)Q.domain[1]-=ot/M.h,a[1]*=-1;else{Q.domain[0]+=ot/M.h;var u=Math.max(1,r.selectAll("tspan.line").size());a[1]+=(1-u)*l}e.attr("transform","translate("+a+")"),Q.setScale()}}it.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(M.h*(1-Q.domain[1]))+")");var f=it.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var r=[0===e?E[0]:(S[e]+S[e-1])/2,e===S.length-1?E[1]:(S[e]+S[e+1])/2].map(Q.c2p).map(Math.round);e!==S.length-1&&(r[1]+=r[1]>r[0]?1:-1);var a=z(t).replace("e-",""),o=i(a).toHexString();n.select(this).attr({x:Y,width:Math.max(D,2),y:n.min(r),height:Math.max(n.max(r)-n.min(r),2),fill:o})});var d=it.select(".cblines").selectAll("path.cbline").data(x.line.color&&x.line.width?L:[]);return d.enter().append("path").classed("cbline",!0),d.exit().remove(),d.each(function(t){n.select(this).attr("d","M"+Y+","+(Math.round(Q.c2p(t))+x.line.width/2%1)+"h"+D).call(h.lineGroupStyle,x.line.width,C(t),x.line.dash)}),Q._axislayer.selectAll("g."+Q._id+"tick,path").remove(),Q._pos=Y+D+(x.outlinewidth||0)/2-("outside"===x.ticks?1:0),Q.side="right",c.syncOrAsync([function(){return s.doTicks(t,Q,!0)},function(){if(-1===["top","bottom"].indexOf(x.titleside)){var e=Q.titlefont.size,r=Q._offset+Q._length/2,i=M.l+(Q.position||0)*M.w+("right"===Q.side?10+e*(Q.showticklabels?1:.5):-10-e*(Q.showticklabels?.5:0));w("h"+Q._id+"title",{avoid:{selection:n.select(t).selectAll("g."+Q._id+"tick"),side:x.titleside,offsetLeft:M.l,offsetTop:M.t,maxShift:A.width},attributes:{x:i,y:r,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,r){var n,i=b();n=o.traceIs(i,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var a={propContainer:Q,propName:n,traceIndex:i.index,dfltName:"colorscale",containerGroup:it.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;it.selectAll("."+s+",."+s+"-math-group").remove(),p.draw(t,e,u(a,r||{}))}function k(){var r=D+x.outlinewidth/2+h.bBox(Q._axislayer.node()).width;if(N=at.select("text"),N.node()&&!N.classed("js-placeholder")){var n,i=at.select(".h"+Q._id+"title-math-group").node();n=i&&-1!==["top","bottom"].indexOf(x.titleside)?h.bBox(i).width:h.bBox(at.node()).right-Y-M.l,r=Math.max(r,n)}var a=2*x.xpad+r+x.borderwidth+x.outlinewidth/2,s=Z-K;it.select(".cbbg").attr({x:Y-x.xpad-(x.borderwidth+x.outlinewidth)/2,y:K-H,width:Math.max(a,2),height:Math.max(s+2*H,2)}).call(d.fill,x.bgcolor).call(d.stroke,x.bordercolor).style({"stroke-width":x.borderwidth}),it.selectAll(".cboutline").attr({x:Y,y:K+x.ypad+("top"===x.titleside?ot:0),width:Math.max(D,2),height:Math.max(s-2*x.ypad-ot,2)}).call(d.stroke,x.outlinecolor).style({fill:"None","stroke-width":x.outlinewidth});var l=({center:.5,right:1}[x.xanchor]||0)*a;it.attr("transform","translate("+(M.l-l)+","+M.t+")"),o.autoMargin(t,e,{x:x.x,y:x.y,l:a*({right:1,center:.5}[x.xanchor]||0),r:a*({left:1,center:.5}[x.xanchor]||0),t:s*({bottom:1,middle:.5}[x.yanchor]||0),b:s*({top:1,middle:.5}[x.yanchor]||0)})}var A=t._fullLayout,M=A._size;if("function"!=typeof x.fillcolor&&"function"!=typeof x.line.color)return void A._infolayer.selectAll("g."+e).remove();var T,E=n.extent(("function"==typeof x.fillcolor?x.fillcolor:x.line.color).domain()),L=[],S=[],C="function"==typeof x.line.color?x.line.color:function(){return x.line.color},z="function"==typeof x.fillcolor?x.fillcolor:function(){return x.fillcolor},P=x.levels.end+x.levels.size/100,R=x.levels.size,O=1.001*E[0]-.001*E[1],I=1.001*E[1]-.001*E[0];for(T=x.levels.start;0>(T-P)*R;T+=R)T>O&&I>T&&L.push(T);if("function"==typeof x.fillcolor)if(x.filllevels)for(P=x.filllevels.end+x.filllevels.size/100,R=x.filllevels.size,T=x.filllevels.start;0>(T-P)*R;T+=R)T>E[0]&&T1){var nt=Math.pow(10,Math.floor(Math.log(rt)/Math.LN10));tt*=nt*c.roundUp(rt/nt,[2,5,10]),(Math.abs(x.levels.start)/x.levels.size+1e-6)%1<2e-6&&(Q.tick0=0)}Q.dtick=tt}Q.domain=[W+G,W+V-G],Q.setScale();var it=A._infolayer.selectAll("g."+e).data([0]);it.enter().append("g").classed(e,!0).each(function(){var t=n.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),it.attr("transform","translate("+Math.round(M.l)+","+Math.round(M.t)+")");var at=it.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(M.l)+",-"+Math.round(M.t)+")");Q._axislayer=it.select(".cbaxis");var ot=0;if(-1!==["top","bottom"].indexOf(x.titleside)){var st,lt=M.l+(x.x+q)*M.w,ct=Q.titlefont.size;st="top"===x.titleside?(1-(W+V-G))*M.h+M.t+3+.75*ct:(1-(W+G))*M.h+M.t-3-.25*ct,w(Q._id+"title",{attributes:{x:lt,y:st,"text-anchor":"start"}})}var ut=c.syncOrAsync([o.previousPromises,_,o.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,ht,dt;l.init({element:it.node(),prepFn:function(){ft=it.attr("transform"),f(it)},moveFn:function(t,e){it.attr("transform",ft+" translate("+t+","+e+")"),ht=l.align(X+t/M.w,B,0,1,x.xanchor),dt=l.align(W-e/M.h,V,0,1,x.yanchor);var r=l.getCursor(ht,dt,x.xanchor,x.yanchor);f(it,r)},doneFn:function(e){f(it),e&&void 0!==ht&&void 0!==dt&&a.restyle(t,{"colorbar.x":ht,"colorbar.y":dt},b().index)}})}return ut}function b(){var r,n,i=e.substr(2);for(r=0;ru*f?i.RdBu:u>=0?i.Reds:i.Blues,l.colorscale=h,s.reversescale&&(h=a(h)),s.colorscale=h)}},{"../../lib":382,"./flip_scale":314,"./scales":321}],311:[function(t,e,r){"use strict";var n=t("./attributes"),i=t("../../lib/extend").extendDeep;t("./scales.js");e.exports=function(t){return{color:{valType:"color",arrayOk:!0},colorscale:i({},n.colorscale,{}),cauto:i({},n.zauto,{}),cmax:i({},n.zmax,{}),cmin:i({},n.zmin,{}),autocolorscale:i({},n.autocolorscale,{}),reversescale:i({},n.reversescale,{})}}},{"../../lib/extend":377,"./attributes":309,"./scales.js":321}],312:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":321}],313:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,c,u){var f=u.prefix,h=u.cLetter,d=f.slice(0,f.length-1),p=f?i.nestedProperty(t,d).get()||{}:t,g=f?i.nestedProperty(e,d).get()||{}:e,v=p[h+"min"],m=p[h+"max"],y=p.colorscale,b=n(v)&&n(m)&&m>v;c(f+h+"auto",!b),c(f+h+"min"),c(f+h+"max");var x;void 0!==y&&(x=!s(y)),c(f+"autocolorscale",x);var _=c(f+"colorscale"),w=c(f+"reversescale");if(w&&(g.colorscale=l(_)),"marker.line."!==f){var k;f&&(k=a(p));var A=c(f+"showscale",k);A&&o(p,g,r)}}},{"../../lib":382,"../colorbar/defaults":305,"../colorbar/has_colorbar":307,"./flip_scale":314,"./is_valid_scale":318,"fast-isnumeric":117}],314:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=t.length,n=new Array(r),i=r-1,a=0;i>=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],315:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return e||(e=i),t?("string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e):e}},{"./default_scale":312,"./is_valid_scale_array":319,"./scales":321}],316:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(Array.isArray(o))for(var l=0;lh;h++)l=t[h],u[h]=e+l[0]*(r-e),f[h]=i(l[1]).toRgb();var d=n.scale.linear().domain(u).interpolate(n.interpolateObject).range(f);return function(t){if(a(t)){var n=o.constrain(t,e,r),l=d(n);return i(l).toRgbString()}return i(t).isValid()?t:s.defaultLine}}},{"../../lib":382,"../color":303,d3:113,"fast-isnumeric":117,tinycolor2:274}],321:[function(t,e,r){"use strict";e.exports={Greys:[[0,"rgb(0,0,0)"],[1,"rgb(255,255,255)"]],YlGnBu:[[0,"rgb(8,29,88)"],[.125,"rgb(37,52,148)"],[.25,"rgb(34,94,168)"],[.375,"rgb(29,145,192)"],[.5,"rgb(65,182,196)"],[.625,"rgb(127,205,187)"],[.75,"rgb(199,233,180)"],[.875,"rgb(237,248,217)"],[1,"rgb(255,255,217)"]],Greens:[[0,"rgb(0,68,27)"],[.125,"rgb(0,109,44)"],[.25,"rgb(35,139,69)"],[.375,"rgb(65,171,93)"],[.5,"rgb(116,196,118)"],[.625,"rgb(161,217,155)"],[.75,"rgb(199,233,192)"],[.875,"rgb(229,245,224)"],[1,"rgb(247,252,245)"]],YlOrRd:[[0,"rgb(128,0,38)"],[.125,"rgb(189,0,38)"],[.25,"rgb(227,26,28)"],[.375,"rgb(252,78,42)"],[.5,"rgb(253,141,60)"],[.625,"rgb(254,178,76)"],[.75,"rgb(254,217,118)"],[.875,"rgb(255,237,160)"],[1,"rgb(255,255,204)"]],Bluered:[[0,"rgb(0,0,255)"],[1,"rgb(255,0,0)"]],RdBu:[[0,"rgb(5,10,172)"],[.35,"rgb(106,137,247)"],[.5,"rgb(190,190,190)"],[.6,"rgb(220,170,132)"],[.7,"rgb(230,145,90)"],[1,"rgb(178,10,28)"]],Reds:[[0,"rgb(220,220,220)"],[.2,"rgb(245,195,157)"],[.4,"rgb(245,160,105)"],[1,"rgb(178,10,28)"]],Blues:[[0,"rgb(5,10,172)"],[.35,"rgb(40,60,190)"],[.5,"rgb(70,100,245)"],[.6,"rgb(90,120,245)"],[.7,"rgb(106,137,247)"],[1,"rgb(220,220,220)"]],Picnic:[[0,"rgb(0,0,255)"],[.1,"rgb(51,153,255)"],[.2,"rgb(102,204,255)"],[.3,"rgb(153,204,255)"],[.4,"rgb(204,204,255)"],[.5,"rgb(255,255,255)"],[.6,"rgb(255,204,255)"],[.7,"rgb(255,153,255)"],[.8,"rgb(255,102,204)"],[.9,"rgb(255,102,102)"],[1,"rgb(255,0,0)"]],Rainbow:[[0,"rgb(150,0,90)"],[.125,"rgb(0,0,200)"],[.25,"rgb(0,25,255)"],[.375,"rgb(0,152,255)"],[.5,"rgb(44,255,150)"],[.625,"rgb(151,255,0)"],[.75,"rgb(255,234,0)"],[.875,"rgb(255,111,0)"],[1,"rgb(255,0,0)"]],Portland:[[0,"rgb(12,51,131)"],[.25,"rgb(10,136,186)"],[.5,"rgb(242,211,56)"],[.75,"rgb(242,143,56)"],[1,"rgb(217,30,30)"]],Jet:[[0,"rgb(0,0,131)"],[.125,"rgb(0,60,170)"],[.375,"rgb(5,255,255)"],[.625,"rgb(255,255,0)"],[.875,"rgb(250,0,0)"],[1,"rgb(128,0,0)"]],Hot:[[0,"rgb(0,0,0)"],[.3,"rgb(230,0,0)"],[.6,"rgb(255,210,0)"],[1,"rgb(255,255,255)"]],Blackbody:[[0,"rgb(0,0,0)"],[.2,"rgb(230,0,0)"],[.4,"rgb(230,210,0)"],[.7,"rgb(255,255,255)"],[1,"rgb(160,200,255)"]],Earth:[[0,"rgb(0,0,130)"],[.1,"rgb(0,180,180)"],[.2,"rgb(40,210,40)"],[.4,"rgb(230,230,50)"],[.6,"rgb(120,70,20)"],[1,"rgb(255,255,255)"]],Electric:[[0,"rgb(0,0,0)"],[.15,"rgb(30,0,100)"],[.4,"rgb(120,0,100)"],[.6,"rgb(160,90,0)"],[.8,"rgb(230,200,0)"],[1,"rgb(255,250,220)"]],Viridis:[[0,"#440154"],[.06274509803921569,"#48186a"],[.12549019607843137,"#472d7b"],[.18823529411764706,"#424086"],[.25098039215686274,"#3b528b"],[.3137254901960784,"#33638d"],[.3764705882352941,"#2c728e"],[.4392156862745098,"#26828e"],[.5019607843137255,"#21918c"],[.5647058823529412,"#1fa088"],[.6274509803921569,"#28ae80"],[.6901960784313725,"#3fbc73"],[.7529411764705882,"#5ec962"],[.8156862745098039,"#84d44b"],[.8784313725490196,"#addc30"],[.9411764705882353,"#d8e219"],[1,"#fde725"]]}},{}],322:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i){var a=(t-r)/(n-r),o=a+e/(n-r),s=(a+o)/2;return"left"===i||"bottom"===i?a:"center"===i||"middle"===i?s:"right"===i||"top"===i?o:2/3-s>a?a:o>4/3-s?o:s}},{}],323:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":382}],324:[function(t,e,r){"use strict";function n(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function i(t){t._dragging=!1,t._replotPending&&a.plot(t)}var a=t("../../plotly"),o=t("../../lib"),s=t("../../plots/cartesian/constants"),l=e.exports={};l.align=t("./align"),l.getCursor=t("./cursor");var c=t("./unhover");l.unhover=c.wrapped,l.unhoverRaw=c.raw,l.init=function(t){function e(e){return t.element.onmousemove=p,g._dragged=!1,g._dragging=!0,c=e.clientX,u=e.clientY,d=e.target,f=(new Date).getTime(),f-g._mouseDownTimem&&(v=Math.max(v-1,1)),t.doneFn&&t.doneFn(g._dragged,v),!g._dragged){var r=document.createEvent("MouseEvents");r.initEvent("click",!0,!0),d.dispatchEvent(r)}return i(g),g._dragged=!1,o.pauseEvent(e)}var c,u,f,h,d,p,g=o.getPlotDiv(t.element)||{},v=1,m=s.DBLCLICKDELAY;g._mouseDownTime||(g._mouseDownTime=0),p=t.element.onmousemove,t.setCursor&&(t.element.onmousemove=t.setCursor),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":382,"../../plotly":402,"../../plots/cartesian/constants":410,"./align":322,"./cursor":323,"./unhover":325}],325:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=e.exports={};i.wrapped=function(t,e,r){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),i.raw(t,e,r)},i.raw=function(t,e){var r=t._fullLayout;e||(e={}),e.target&&n.triggerHandler(t,"plotly_beforehover",e)===!1||(r._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":376}],326:[function(t,e,r){"use strict";function n(t,e,r,n){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],c=Math.pow(a*a+o*o,x/2),u=Math.pow(s*s+l*l,x/2),f=(u*u*a-c*c*s)*n,h=(u*u*o-c*c*l)*n,d=3*u*(c+u),p=3*c*(c+u);return[[i.round(e[0]+(d&&f/d),2),i.round(e[1]+(d&&h/d),2)],[i.round(e[0]-(p&&f/p),2),i.round(e[1]-(p&&h/p),2)]]}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../plots/plots"),s=t("../color"),l=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../traces/scatter/subtypes"),d=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,r,n){e&&e.family&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},p.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},p.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},p.setRect=function(t,e,r,n,i){t.call(p.setPosition,e,r).call(p.setSize,n,i)},p.translatePoints=function(t,e,r){t.each(function(t){var n=t.xp||e.c2p(t.x),o=t.yp||r.c2p(t.y),s=i.select(this);a(n)&&a(o)?"text"===this.nodeName?s.attr("x",n).attr("y",o):s.attr("transform","translate("+n+","+o+")"):s.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:1>e?1:Math.round(e):r||0},p.lineGroupStyle=function(t,e,r,n){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=n||a.dash||"";i.select(this).call(s.stroke,r||a.color).call(p.dashLine,l,o)})},p.dashLine=function(t,e,r){var n=Math.max(r,3);"solid"===e?e="":"dot"===e?e=n+"px,"+n+"px":"dash"===e?e=3*n+"px,"+3*n+"px":"longdash"===e?e=5*n+"px,"+5*n+"px":"dashdot"===e?e=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===e&&(e=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var r=i.select(this);try{r.call(s.fill,e[0].trace.fillcolor)}catch(n){c.error(n,t),r.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var r=e.marker,n=r.line;if(o.traceIs(e,"symbols")){var a=d(e);t.attr("d",function(t){var n;n="various"===t.ms||"various"===r.size?3:h.isBubble(e)?a(t.ms):(r.size||6)/2,t.mrc=n;var i=p.symbolNumber(t.mx||r.symbol)||0,o=i%100;return t.om=i%200>=100,p.symbolFuncs[o](n)+(i>=200?m:"")}).style("opacity",function(t){return(t.mo+1||r.opacity+1)-1})}var l=(e._input||{}).marker||{},c=p.tryColorscale(r,l,""),u=p.tryColorscale(r,l,"line.");t.each(function(t){var e,a,o;t.so?(o=n.outlierwidth,a=n.outliercolor,e=r.outliercolor):(o=(t.mlw+1||n.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,a="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(n.color)?s.defaultLine:n.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(r.color)?s.defaultLine:r.color||"rgba(0,0,0,0)");var l=i.select(this);t.om?l.call(s.stroke,e).style({"stroke-width":(o||1)+"px",fill:"none"}):(l.style("stroke-width",o+"px").call(s.fill,e),o&&l.call(s.stroke,a))})}},p.tryColorscale=function(t,e,r){var n=c.nestedProperty(t,r+"color").get(),i=c.nestedProperty(t,r+"colorscale").get(),o=c.nestedProperty(t,r+"cauto").get(),s=c.nestedProperty(t,r+"cmin"),u=c.nestedProperty(t,r+"cmax"),f=s.get(),h=u.get();return i&&Array.isArray(n)?(!o&&a(f)&&a(h)||(f=1/0,h=-(1/0),n.forEach(function(t){a(t)&&(f>t&&(f=+t),t>h&&(h=+t))}),f>h&&(f=0,h=1),s.set(f),u.set(h),c.nestedProperty(e,r+"cmin").set(f),c.nestedProperty(e,r+"cmax").set(h)),l.makeScaleFunction(i,f,h)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},b=1.3;p.textPointStyle=function(t,e){t.each(function(t){var r=i.select(this),n=t.tx||e.text;if(!n||Array.isArray(n))return void r.remove();var o=t.tp||e.textposition,s=-1!==o.indexOf("top")?"top":-1!==o.indexOf("bottom")?"bottom":"middle",l=-1!==o.indexOf("left")?"end":-1!==o.indexOf("right")?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=a(c)&&c>0?c:0,r.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",l).text(n).call(u.convertToTspans);var h=i.select(this.parentNode),d=r.selectAll("tspan.line"),g=((d[0].length||1)-1)*b+1,v=y[l]*f,m=.75*c+y[s]*f+(y[s]-1)*g*c/2;h.attr("transform","translate("+v+","+m+")"),g>1&&d.attr({x:r.attr("x"),y:r.attr("y")})})};var x=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,i="M"+t[0],a=[];for(r=1;rr;r++)o.push(n(t[r-1],t[r],t[r+1],e));for(o.push(n(t[a-1],t[a],t[0],e)),r=1;a>=r;r++)i+="C"+o[r-1][1]+" "+o[r][0]+" "+t[r];return i+="C"+o[a][1]+" "+o[0][0]+" "+t[0]+"Z"};var _={hv:function(t,e){return"H"+i.round(e[0],2)+"V"+i.round(e[1],2)},vh:function(t,e){return"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},hvh:function(t,e){return"H"+i.round((t[0]+e[0])/2,2)+"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},vhv:function(t,e){return"V"+i.round((t[1]+e[1])/2,2)+"H"+i.round(e[0],2)+"V"+i.round(e[1],2)}},w=function(t,e){return"L"+i.round(e[0],2)+","+i.round(e[1],2)};p.steps=function(t){var e=_[t]||w;return function(t){for(var r="M"+i.round(t[0][0],2)+","+i.round(t[0][1],2),n=1;n=A&&(i.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(l),c.extendFlat({},l)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var r="#"+e,n=i.select("base");n.size()&&n.attr("href")&&(r=window.location.href+r),t.attr("clip-path","url("+r+")")}},{"../../constants/xmlns_namespaces":370,"../../lib":382,"../../lib/svg_text_utils":395,"../../plots/plots":454,"../../traces/scatter/make_bubble_size_func":570,"../../traces/scatter/subtypes":575,"../color":303,"../colorscale":317,"./symbol_defs":327,d3:113,"fast-isnumeric":117}],327:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+","+r+"H"+e+"L0,-"+i+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+",-"+r+"H"+e+"L0,"+i+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M"+r+",-"+e+"V"+e+"L-"+i+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+r+",-"+e+"V"+e+"L"+i+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(t*-.309,2),o=n.round(.809*t,2);return"M"+e+","+a+"L"+r+","+o+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(e*-.309,2),c=n.round(.118*e,2),u=n.round(.809*e,2),f=n.round(.382*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+c+"L"+o+","+u+"L0,"+f+"L-"+o+","+u+"L-"+a+","+c+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:113}],328:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],329:[function(t,e,r){"use strict";function n(t,e,r,n){var a=e["error_"+n]||{},l=a.visible&&-1!==["linear","log"].indexOf(r.type),c=[];if(l){for(var u=s(a),f=0;fs;s++)o[s]={x:r[s],y:i[s]};return o[0].trace=t,n.calc({calcdata:[o],_fullLayout:e}),o},n.plot=t("./plot"),n.style=t("./style"),n.hoverInfo=function(t,e,r){(e.error_y||{}).visible&&(r.yerr=t.yh-t.y,e.error_y.symmetric||(r.yerrneg=t.y-t.ys)),(e.error_x||{}).visible&&(r.xerr=t.xh-t.x,e.error_x.symmetric||(r.xerrneg=t.x-t.xs))}},{"./attributes":328,"./calc":329,"./defaults":331,"./plot":333,"./style":334}],333:[function(t,e,r){"use strict";function n(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};return void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0))),void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0))),n}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),s=t("../../traces/scatter/subtypes");e.exports=function(t,e){var r=e.x(),l=e.y();t.each(function(t){var e=t[0].trace,c=e.error_x||{},u=e.error_y||{},f=s.hasMarkers(e)&&e.marker.maxdisplayed>0;if(u.visible||c.visible){var h=i.select(this).selectAll("g.errorbar").data(o.identity);h.enter().append("g").classed("errorbar",!0),h.each(function(t){var e=i.select(this),o=n(t,r,l);if(!f||t.vis){var s;if(u.visible&&a(o.x)&&a(o.yh)&&a(o.ys)){var h=u.width;s="M"+(o.x-h)+","+o.yh+"h"+2*h+"m-"+h+",0V"+o.ys,o.noYS||(s+="m-"+h+",0h"+2*h),e.append("path").classed("yerror",!0).attr("d",s)}if(c.visible&&a(o.y)&&a(o.xh)&&a(o.xs)){var d=(c.copy_ystyle?u:c).width;s="M"+o.xh+","+(o.y-d)+"v"+2*d+"m0,-"+d+"H"+o.xs,o.noXS||(s+="m0,-"+d+"v"+2*d),e.append("path").classed("xerror",!0).attr("d",s)}}})}})}},{"../../lib":382,"../../traces/scatter/subtypes":575,d3:113,"fast-isnumeric":117}],334:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":303,d3:113}],335:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",n.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",n.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":410}],336:[function(t,e,r){"use strict"; +function n(t,e,r){function n(r,n){return a.coerce(t,e,o,r,n)}e=e||{},n("source"),n("layer"),n("x"),n("y"),n("xanchor"),n("yanchor"),n("sizex"),n("sizey"),n("sizing"),n("opacity");for(var s=0;2>s;s++){var l={_fullLayout:r},c=["x","y"][s];i.coerceRef(t,e,l,c,"paper")}return e}var i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var r=t.images,i=e.images=[],a=0;a=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],340:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:a({},n,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":377,"../../plots/font_attributes":423,"../color/attributes":302}],341:[function(t,e,r){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],342:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/plots"),a=t("./attributes"),o=t("./helpers");e.exports=function(t,e,r){function s(t,e){return n.coerce(h,d,a,t,e)}for(var l,c,u,f,h=t.legend||{},d=e.legend={},p=0,g="normal",v=0;v1);if(y!==!1){if(s("bgcolor",e.paper_bgcolor),s("bordercolor"),s("borderwidth"),n.coerceFont(s,"font",e.font),s("orientation"),"h"===d.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(l=0,u="left",c=1.1,f="bottom"):(l=0,u="left",c=-.1,f="top")}s("traceorder",g),o.isGrouped(e.legend)&&s("tracegroupgap"),s("x",l),s("xanchor",u),s("y",c),s("yanchor",f),n.noneOrAll(h,d,["x","y"])}}},{"../../lib":382,"../../plots/plots":454,"./attributes":340,"./helpers":345}],343:[function(t,e,r){"use strict";function n(t,e){function r(r){u.util.convertToTspans(r,function(){r.selectAll("tspan.line").attr({x:r.attr("x")}),t.call(a,e)})}var n=t.data()[0][0],i=e._fullLayout,o=n.trace,s=h.traceIs(o,"pie"),l=o.index,c=s?n.label:o.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":c}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,i.legend.font).text(c),e._context.editable&&!s?f.call(u.util.makeEditable).call(r).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(r),this.text()||(t=" "),u.restyle(e,"name",t,l)}):f.call(r)}function i(t,e){var r=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],n=t.selectAll("rect").data([0]);n.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"),n.on("click",function(){if(!e._dragged){var n,i,a=t.data()[0][0],o=e._fullData,s=a.trace,l=s.legendgroup,c=[];if(h.traceIs(s,"pie")){var f=a.label,d=r.indexOf(f);-1===d?r.push(f):r.splice(d,1),u.relayout(e,"hiddenlabels",r)}else{if(""===l)c=[s.index];else for(var p=0;ptspan"),d=h[0].length||1;r=l*d,n=u.node()&&p.bBox(u.node()).width;var g=l*(.3+(1-d)/2);u.attr("y",g),h.attr("y",g)}r=Math.max(r,16)+3,a.attr({x:0,y:-r/2,height:r}),i.height=r,i.width=n}function o(t,e,r){var n=t._fullLayout,i=n.legend,a=i.borderwidth,o=b.isGrouped(i);if(b.isVertical(i))o&&e.each(function(t,e){f.setTranslate(this,0,e*i.tracegroupgap)}),i.width=0,i.height=0,r.each(function(t){var e=t[0],r=e.height,n=e.width;f.setTranslate(this,a,5+a+i.height+r/2),i.height+=r,i.width=Math.max(i.width,n)}),i.width+=45+2*a,i.height+=10+2*a,o&&(i.height+=(i._lgroupsLength-1)*i.tracegroupgap),r.selectAll(".legendtoggle").attr("width",(t._context.editable?0:i.width)+40),i.width=Math.ceil(i.width),i.height=Math.ceil(i.height);else if(o){i.width=0,i.height=0;for(var s=[i.width],l=e.data(),u=0,h=l.length;h>u;u++){var d=l[u].map(function(t){return t[0].width}),p=40+Math.max.apply(null,d);i.width+=i.tracegroupgap+p,s.push(i.width)}e.each(function(t,e){f.setTranslate(this,s[e],0)}),e.each(function(){var t=c.select(this),e=t.selectAll("g.traces"),r=0;e.each(function(t){var e=t[0],n=e.height;f.setTranslate(this,0,5+a+r+n/2),r+=n}),i.height=Math.max(i.height,r)}),i.height+=10+2*a,i.width+=2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}else i.width=0,i.height=0,r.each(function(t){var e=t[0],r=40+e.width,n=i.tracegroupgap||5;f.setTranslate(this,a+i.width,5+a+e.height/2),i.width+=n+r,i.height=Math.max(i.height,e.height)}),i.width+=2*a,i.height+=10+2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}function s(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center");var i="top";x.isBottomAnchor(r)?i="bottom":x.isMiddleAnchor(r)&&(i="middle"),h.autoMargin(t,"legend",{x:r.x,y:r.y,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:r.height*({top:1,middle:.5}[i]||0),t:r.height*({bottom:1,middle:.5}[i]||0)})}function l(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center"),h.autoMargin(t,"legend",{x:r.x,y:.5,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:0,t:0})}var c=t("d3"),u=t("../../plotly"),f=t("../../lib"),h=t("../../plots/plots"),d=t("../dragelement"),p=t("../drawing"),g=t("../color"),v=t("./constants"),m=t("./get_legend_data"),y=t("./style"),b=t("./helpers"),x=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e).call(f.setTranslate,0,e),E.call(p.setRect,F,t,v.scrollBarWidth,v.scrollBarHeight),A.select("rect").attr({y:b.borderwidth-e})}var r=t._fullLayout,a="legend"+r._uid;if(r._infolayer&&t.calcdata){var b=r.legend,_=r.showlegend&&m(t.calcdata,b),w=r.hiddenlabels||[];if(!r.showlegend||!_.length)return r._infolayer.selectAll(".legend").remove(),r._topdefs.select("#"+a).remove(),void h.autoMargin(t,"legend");var k=r._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({"class":"legend","pointer-events":"all"});var A=r._topdefs.selectAll("#"+a).data([0]);A.enter().append("clipPath").attr("id",a).append("rect");var M=k.selectAll("rect.bg").data([0]);M.enter().append("rect").attr({"class":"bg","shape-rendering":"crispEdges"}),M.call(g.stroke,b.bordercolor),M.call(g.fill,b.bgcolor),M.style("stroke-width",b.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var E=k.selectAll("rect.scrollbar").data([0]);E.enter().append("rect").attr({"class":"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var L=T.selectAll("g.groups").data(_);L.enter().append("g").attr("class","groups"),L.exit().remove();var S=L.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return h.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(){c.select(this).call(n,t).call(i,t)});var C=0!==k.enter().size();C&&(o(t,L,S),s(t));var z=0,P=r.width,R=0,O=r.height;o(t,L,S),b.height>O?l(t):s(t);var I=r._size,N=I.l+I.w*b.x,j=I.t+I.h*(1-b.y);x.isRightAnchor(b)?N-=b.width:x.isCenterAnchor(b)&&(N-=b.width/2),x.isBottomAnchor(b)?j-=b.height:x.isMiddleAnchor(b)&&(j-=b.height/2);var F=b.width,D=I.w;F>D?(N=I.l,F=D):(N+F>P&&(N=P-F),z>N&&(N=z),F=Math.min(P-N,b.width));var B=b.height,U=I.h;B>U?(j=I.t,B=U):(j+B>O&&(j=O-B),R>j&&(j=R),B=Math.min(O-j,b.height)),f.setTranslate(k,N,j);var V,q,H=B-v.scrollBarHeight-2*v.scrollBarMargin,G=b.height-B;if(b.height<=B||t._context.staticPlot)M.attr({width:F-b.borderwidth,height:B-b.borderwidth,x:b.borderwidth/2,y:b.borderwidth/2}),f.setTranslate(T,0,0),A.select("rect").attr({width:F-2*b.borderwidth,height:B-2*b.borderwidth,x:b.borderwidth,y:b.borderwidth}),T.call(p.setClipUrl,a);else{V=v.scrollBarMargin,q=T.attr("data-scroll")||0,M.attr({width:F-2*b.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:B-b.borderwidth,x:b.borderwidth/2,y:b.borderwidth/2}),A.select("rect").attr({width:F-2*b.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:B-2*b.borderwidth,x:b.borderwidth,y:b.borderwidth-q}),T.call(p.setClipUrl,a),C&&e(V,q),k.on("wheel",null),k.on("wheel",function(){q=f.constrain(T.attr("data-scroll")-c.event.deltaY/H*G,-G,0),V=v.scrollBarMargin-q/G*H,e(V,q),c.event.preventDefault()}),E.on(".drag",null),T.on(".drag",null);var Y=c.behavior.drag().on("drag",function(){V=f.constrain(c.event.y-v.scrollBarHeight/2,v.scrollBarMargin,v.scrollBarMargin+H),q=-(V-v.scrollBarMargin)/H*G,e(V,q)});E.call(Y),T.call(Y)}if(t._context.editable){var X,W,Z,K;k.classed("cursor-move",!0),d.init({element:k.node(),prepFn:function(){var t=f.getTranslate(k);Z=t.x,K=t.y},moveFn:function(t,e){var r=Z+t,n=K+e;f.setTranslate(k,r,n),X=d.align(r,0,I.l,I.l+I.w,b.xanchor),W=d.align(n,0,I.t+I.h,I.t,b.yanchor)},doneFn:function(e){e&&void 0!==X&&void 0!==W&&u.relayout(t,{"legend.x":X,"legend.y":W})}})}}}},{"../../lib":382,"../../plotly":402,"../../plots/plots":454,"../color":303,"../dragelement":324,"../drawing":326,"./anchor_utils":339,"./constants":341,"./get_legend_data":344,"./helpers":345,"./style":347,d3:113}],344:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("./helpers");e.exports=function(t,e){function r(t,r){if(""!==t&&i.isGrouped(e))-1===l.indexOf(t)?(l.push(t),c=!0,s[t]=[[r]]):s[t].push([r]);else{var n="~~i"+f;l.push(n),s[n]=[[r]],f++}}var a,o,s={},l=[],c=!1,u={},f=0;for(a=0;aa;a++)m=s[l[a]],y[a]=i.isReversed(e)?m.reverse():m;else{for(y=[new Array(b)],a=0;b>a;a++)m=s[l[a]][0],y[0][i.isReversed(e)?b-a-1:a]=m;b=1}return e._lgroupsLength=b,y}},{"../../plots/plots":454,"./helpers":345}],345:[function(t,e,r){"use strict";var n=t("../../plots/plots");r.legendGetsTrace=function(t){return t.visible&&n.traceIs(t,"showLegend")},r.isGrouped=function(t){return-1!==(t.traceorder||"").indexOf("grouped")},r.isVertical=function(t){return"h"!==t.orientation},r.isReversed=function(t){return-1!==(t.traceorder||"").indexOf("reversed")}},{"../../plots/plots":454}],346:[function(t,e,r){"use strict";var n=e.exports={};n.layoutAttributes=t("./attributes"),n.supplyLayoutDefaults=t("./defaults"),n.draw=t("./draw"),n.style=t("./style")},{"./attributes":340,"./defaults":342,"./draw":343,"./style":347}],347:[function(t,e,r){"use strict";function n(t){var e=t[0].trace,r=e.visible&&e.fill&&"none"!==e.fill,n=d.hasLines(e),i=l.select(this).select(".legendfill").selectAll("path").data(r?[t]:[]);i.enter().append("path").classed("js-fill",!0),i.exit().remove(),i.attr("d","M5,0h30v6h-30z").call(f.fillGroupStyle);var a=l.select(this).select(".legendlines").selectAll("path").data(n?[t]:[]);a.enter().append("path").classed("js-line",!0).attr("d","M5,0h30"),a.exit().remove(),a.call(f.lineGroupStyle)}function i(t){function e(t,e,r){var n=c.nestedProperty(o,t).get(),i=Array.isArray(n)&&e?e(n):n;if(r){if(ir[1])return r[1]}return i}function r(t){return t[0]}var n,i,a=t[0],o=a.trace,s=d.hasMarkers(o),u=d.hasText(o),h=d.hasLines(o);if(s||u||h){var p={},g={};s&&(p.mc=e("marker.color",r),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",r),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),h&&(g.line={width:e("line.width",r,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",r),p.ts=10,p.tc=e("textfont.color",r),p.tf=e("textfont.family",r)),n=[c.minExtend(a,p)],i=c.minExtend(o,g)}var v=l.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(s?n:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,i),s&&(n[0].mrc=3);var y=v.selectAll("g.pointtext").data(u?n:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,i)}function a(t){var e=t[0].trace,r=e.marker||{},n=r.line||{},i=l.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);i.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),i.exit().remove(),i.each(function(t){var e=(t.mlw+1||n.width+1)-1,i=l.select(this);i.style("stroke-width",e+"px").call(h.fill,t.mc||r.color),e&&i.call(h.stroke,t.mlc||n.color)})}function o(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);r.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.each(function(t){var r=(t.lw+1||e.line.width+1)-1,n=l.select(this);n.style("stroke-width",r+"px").call(h.fill,t.fc||e.fillcolor),r&&n.call(h.stroke,t.lc||e.line.color)})}function s(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);r.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.size()&&r.call(p,t[0],e)}var l=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),h=t("../color"),d=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=l.select(this),r=e.selectAll("g.legendfill").data([t]);r.enter().append("g").classed("legendfill",!0);var n=e.selectAll("g.legendlines").data([t]);n.enter().append("g").classed("legendlines",!0);var i=e.selectAll("g.legendsymbols").data([t]);i.enter().append("g").classed("legendsymbols",!0),i.style("opacity",t[0].trace.opacity),i.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(a).each(o).each(s).each(n).each(i)}},{"../../lib":382,"../../plots/plots":454,"../../traces/pie/style_one":554,"../../traces/scatter/subtypes":575,"../color":303,"../drawing":326,d3:113}],348:[function(t,e,r){"use strict";function n(t,e){var r=e.currentTarget,n=r.getAttribute("data-attr"),i=r.getAttribute("data-val")||!0,a=t._fullLayout,o={};if("zoom"===n){for(var s,l,u="in"===i?.5:2,h=(1+u)/2,d=(1-u)/2,p=c.Axes.list(t,null,!0),v=0;vy;y++){var b=s[y];h=m[b]={};for(var x=0;x1)return n(["resetViews","toggleHover"]),o(v,r);u&&(n(["zoom3d","pan3d","orbitRotation","tableRotation"]),n(["resetCameraDefault3d","resetCameraLastSave3d"]),n(["hoverClosest3d"])),h&&(n(["zoomInGeo","zoomOutGeo","resetGeo"]),n(["hoverClosestGeo"]));var m=i(s),y=[];return((c||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(c||g)&&a(l)&&(y.push("select2d"),y.push("lasso2d")),y.length&&n(y),!c&&!p||m||g||n(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&d?n(["toggleHover"]):p?n(["hoverClosestGl2d"]):c?n(["hoverClosestCartesian","hoverCompareCartesian"]):d&&n(["hoverClosestPie"]),o(v,r)}function i(t){for(var e=l.Axes.list({_fullLayout:t},null,!0),r=!0,n=0;n0);if(h){var d=i(e,r,s);l("x",d[0]),l("y",d[1]),a.noneOrAll(t,e,["x","y"]),l("xanchor"),l("yanchor"),a.coerceFont(l,"font",r.font),l("bgcolor"),l("bordercolor"),l("borderwidth")}}},{"../../lib":382,"./attributes":351,"./button_attributes":352,"./constants":353}],355:[function(t,e,r){"use strict";function n(t){for(var e=m.list(t,"x",!0),r=[],n=0;ne){var r=e;e=t,t=r}s.setAttributes(w,{"data-min":t,"data-max":e}),s.setAttributes(R,{x:t,width:e-t}),s.setAttributes(M,{width:t}),s.setAttributes(T,{x:e,width:p-e}),s.setAttributes(E,{transform:"translate("+(t-v-1)+")"}),s.setAttributes(C,{transform:"translate("+e+")"})}var f=t._fullLayout,h=f._infolayer.selectAll("g.range-slider"),d=f.xaxis.rangeslider,p=f._size.w,g=(f.height-f.margin.b-f.margin.t)*d.thickness,v=2,m=Math.floor(d.borderwidth/2),y=f.margin.l,b=f.height-g-f.margin.b,x=0,_=p,w=document.createElementNS(o,"g");s.setAttributes(w,{"class":"range-slider","data-min":x,"data-max":_,"pointer-events":"all",transform:"translate("+y+","+b+")"});var k=document.createElementNS(o,"rect"),A=d.borderwidth%2===0?d.borderwidth:d.borderwidth-1;s.setAttributes(k,{fill:d.bgcolor,stroke:d.bordercolor,"stroke-width":d.borderwidth,height:g+A,width:p+A,transform:"translate(-"+m+", -"+m+")","shape-rendering":"crispEdges"});var M=document.createElementNS(o,"rect");s.setAttributes(M,{x:0,width:x,height:g,fill:"rgba(0,0,0,0.4)"});var T=document.createElementNS(o,"rect");s.setAttributes(T,{x:_,width:p-_,height:g,fill:"rgba(0,0,0,0.4)"});var E=document.createElementNS(o,"g"),L=document.createElementNS(o,"rect"),S=document.createElementNS(o,"rect");s.setAttributes(E,{transform:"translate("+(x-v-1)+")"}),s.setAttributes(L,{width:10,height:g,x:-6,fill:"transparent",cursor:"col-resize"}),s.setAttributes(S,{width:v,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(E,[S,L]);var C=document.createElementNS(o,"g"),z=document.createElementNS(o,"rect"),P=document.createElementNS(o,"rect");s.setAttributes(C,{transform:"translate("+_+")"}),s.setAttributes(z,{width:10,height:g,x:-2,fill:"transparent",cursor:"col-resize"}),s.setAttributes(P,{width:v,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(C,[P,z]);var R=document.createElementNS(o,"rect");s.setAttributes(R,{x:x,width:_-x,height:g,cursor:"ew-resize",fill:"transparent"}),w.addEventListener("mousedown",function(t){function r(t){var r,n,f=+t.clientX-a;switch(i){case R:w.style.cursor="ew-resize",r=+s+f,n=+l+f,u(r,n),c(e(r),e(n));break;case L:w.style.cursor="col-resize",r=+s+f,n=+l,u(r,n),c(e(r),e(n));break;case z:w.style.cursor="col-resize",r=+s,n=+l+f,u(r,n),c(e(r),e(n));break;default:w.style.cursor="ew-resize",r=o,n=o+f,u(r,n),c(e(r),e(n))}}function n(){window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",n),w.style.cursor="auto"}var i=t.target,a=t.clientX,o=a-w.getBoundingClientRect().left,s=w.getAttribute("data-min"),l=w.getAttribute("data-max");window.addEventListener("mousemove",r),window.addEventListener("mouseup",n)}),d.range||(d.range=i.getAutoRange(f.xaxis));var O=l(t,p,g);s.appendChildren(w,[k,O,M,T,R,E,C]),r(f.xaxis.range[0],f.xaxis.range[1]),h.data([0]).enter().append(function(){return d.setRange=r,w})}},{"../../constants/xmlns_namespaces":370,"../../lib":382,"../../plotly":402,"../../plots/cartesian/axes":405,"./helpers":361,"./range_plot":363}],360:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(t,e){return n.coerce(s,l,i,t,e)}if(t[r].rangeslider){var s="object"==typeof t[r].rangeslider?t[r].rangeslider:{},l=e[r].rangeslider={};if(o("bgcolor"),o("bordercolor"),o("borderwidth"),o("thickness"),o("visible"),o("range"),l.range&&!e[r].autorange){var c=l.range,u=e[r].range;c[0]=Math.min(c[0],u[0]),c[1]=Math.max(c[1],u[1])}else e[r]._needsExpand=!0;l.visible&&a.forEach(function(t){var r=e[t]||{};r.fixedrange=!0,e[t]=r})}}},{"../../lib":382,"./attributes":358}],361:[function(t,e,r){"use strict";r.setAttributes=function(t,e){for(var r in e)t.setAttribute(r,e[r])},r.appendChildren=function(t,e){for(var r=0;rl;l++){var c=s[l],u={_fullLayout:e},f=M.coerceRef(t,n,u,c);if("path"!==o){var h=.25,d=.75;if("paper"!==f){var p=M.getFromId(u,f),g=a(p);h=g(p.range[0]+h*(p.range[1]-p.range[0])),d=g(p.range[0]+d*(p.range[1]-p.range[0]))}r(c+"0",h),r(c+"1",d)}}return"path"===o?r("path"):A.noneOrAll(t,n,["x0","x1","y0","y1"]),n}function i(t){return"category"===t.type?t.c2l:t.d2l}function a(t){return"category"===t.type?t.l2c:t.l2d}function o(t,e){t.layout.shapes=e,C.supplyLayoutDefaults(t.layout,t._fullLayout),C.drawAll(t)}function s(t){delete t.layout.shapes,t._fullLayout.shapes=[],C.drawAll(t)}function l(t,e,r){for(var n=0;ne;i--)d(t,i).selectAll('[data-index="'+(i-1)+'"]').attr("data-index",i),C.draw(t,i)}function f(t,e,r,o){function s(r){var n={"data-index":e,"fill-rule":"evenodd",d:b(t,C)},i=C.line.width?C.line.color:"rgba(0,0,0,0)",a=r.append("path").attr(n).style("opacity",C.opacity).call(T.stroke,i).call(T.fill,C.fillcolor).call(E.dashLine,C.line.dash,C.line.width);z&&a.call(E.setClipUrl,"clip"+t._fullLayout._uid+z),t._context.editable&&h(t,a,C,e)}var l,c;d(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},g={};"string"==typeof r&&r?g[r]=o:A.isPlainObject(r)&&(g=r);var v=Object.keys(g);for(l=0;ll;l++){var x=y[l];if(void 0===g[x]&&void 0!==u[x]){var _,w=x.charAt(0),k=M.getFromId(t,M.coerceRef(f,{},t,w)),L=M.getFromId(t,M.coerceRef(u,{},t,w)),S=u[x];void 0!==g[w+"ref"]&&(k?(_=i(k)(S),S=(_-k.range[0])/(k.range[1]-k.range[0])):S=(S-L.domain[0])/(L.domain[1]-L.domain[0]),L?(_=L.range[0]+S*(L.range[1]-L.range[0]),S=a(L)(_)):S=k.domain[0]+S*(k.domain[1]-k.domain[0])),u[x]=S}}var C=n(u,t._fullLayout);t._fullLayout.shapes[e]=C;var z;if("below"!==C.layer)z=(C.xref+C.yref).replace(/paper/g,""),s(t._fullLayout._shapeUpperLayer);else if("paper"===C.xref&&"paper"===C.yref)z="",s(t._fullLayout._shapeLowerLayer);else{var P,R=t._fullLayout._plots||{},O=Object.keys(R);for(l=0,c=O.length;c>l;l++)P=R[O[l]],z=O[l],p(t,C,P)&&s(P.shapelayer)}}}function h(t,e,r,n){function i(t){var r=$.right-$.left,n=$.bottom-$.top,i=t.clientX-$.left,a=t.clientY-$.top,o=r>W&&n>Z&&!t.shiftKey?L.getCursor(i/r,1-a/n):"move";S(e,o),X=o.split("-")[0]}function a(e){U=M.getFromId(t,r.xref),V=M.getFromId(t,r.yref),q=m(t,U),H=m(t,V,!0),G=y(t,U),Y=y(t,V,!0);var a="shapes["+n+"]";"path"===r.type?(D=r.path,B=a+".path"):(u=q(r.x0),f=H(r.y0),h=q(r.x1),d=H(r.y1),p=a+".x0",g=a+".y0",_=a+".x1",w=a+".y1"),h>u?(E=u,R=a+".x0",j="x0",C=h,O=a+".x1",F="x1"):(E=h,R=a+".x1",j="x1",C=u,O=a+".x0",F="x0"),d>f?(A=f,z=a+".y0",I="y0",T=d,P=a+".y1",N="y1"):(A=d,z=a+".y1",I="y1",T=f,P=a+".y0",N="y0"),c={},i(e),K.moveFn="move"===X?s:l}function o(r){S(e),r&&k.relayout(t,c)}function s(n,i){if("path"===r.type){var a=function(t){return G(q(t)+n)};U&&"date"===U.type&&(a=v(a));var o=function(t){return Y(H(t)+i)};V&&"date"===V.type&&(o=v(o)),r.path=x(D,a,o),c[B]=r.path}else c[p]=r.x0=G(u+n),c[g]=r.y0=Y(f+i),c[_]=r.x1=G(h+n),c[w]=r.y1=Y(d+i);e.attr("d",b(t,r))}function l(n,i){if("path"===r.type){var a=function(t){return G(q(t)+n)};U&&"date"===U.type&&(a=v(a));var o=function(t){return Y(H(t)+i)};V&&"date"===V.type&&(o=v(o)),r.path=x(D,a,o),c[B]=r.path}else{var s=~X.indexOf("n")?A+i:A,l=~X.indexOf("s")?T+i:T,u=~X.indexOf("w")?E+n:E,f=~X.indexOf("e")?C+n:C;l-s>Z&&(c[z]=r[I]=Y(s),c[P]=r[N]=Y(l)),f-u>W&&(c[R]=r[j]=G(u),c[O]=r[F]=G(f))}e.attr("d",b(t,r))}var c,u,f,h,d,p,g,_,w,A,T,E,C,z,P,R,O,I,N,j,F,D,B,U,V,q,H,G,Y,X,W=10,Z=10,K={setCursor:i,element:e.node(),prepFn:a,doneFn:o},$=K.element.getBoundingClientRect();L.init(K)}function d(t,e){var r=t._fullLayout.shapes[e],n=t._fullLayout._shapeUpperLayer;return r?"below"===r.layer&&(n="paper"===r.xref&&"paper"===r.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):A.log("getShapeLayer: undefined shape: index",e),n}function p(t,e,r){var n=k.Axes.getFromId(t,r.id,"x")._id,i=k.Axes.getFromId(t,r.id,"y")._id,a="below"===e.layer,o=n===e.xref||i===e.yref,s=!!r.shapelayer;return a&&o&&s}function g(t){return function(e){return e.replace&&(e=e.replace("_"," ")),t(e)}}function v(t){return function(e){return t(e).replace(" ","_")}}function m(t,e,r){var n,a=t._fullLayout._size;if(e){var o=i(e);n=function(t){return e._offset+e.l2p(o(t,!0))},"date"===e.type&&(n=g(n))}else n=r?function(t){return a.t+a.h*(1-t)}:function(t){return a.l+a.w*t};return n}function y(t,e,r){var n,i=t._fullLayout._size;if(e){var o=a(e);n=function(t){return o(e.p2l(t-e._offset))}}else n=r?function(t){return 1-(t-i.t)/i.h}:function(t){return(t-i.l)/i.w};return n}function b(t,e){var r,n,a,o,s=e.type,l=M.getFromId(t,e.xref),c=M.getFromId(t,e.yref),u=t._fullLayout._size;if(l?(r=i(l),n=function(t){return l._offset+l.l2p(r(t,!0))}):n=function(t){return u.l+u.w*t},c?(a=i(c),o=function(t){return c._offset+c.l2p(a(t,!0))}):o=function(t){return u.t+u.h*(1-t)},"path"===s)return l&&"date"===l.type&&(n=g(n)),c&&"date"===c.type&&(o=g(o)),C.convertPath(e.path,n,o);var f=n(e.x0),h=n(e.x1),d=o(e.y0),p=o(e.y1);if("line"===s)return"M"+f+","+d+"L"+h+","+p;if("rect"===s)return"M"+f+","+d+"H"+h+"V"+p+"H"+f+"Z";var v=(f+h)/2,m=(d+p)/2,y=Math.abs(v-f),b=Math.abs(m-d),x="A"+y+","+b,_=v+y+","+m,w=v+","+(m-b);return"M"+_+x+" 0 1,1 "+w+x+" 0 0,1 "+_+"Z"}function x(t,e,r){return t.replace(z,function(t){var n=0,i=t.charAt(0),a=R[i],o=O[i],s=I[i],l=t.substr(1).replace(P,function(t){return n>=s?t:(a[n]?t=e(t):o[n]&&(t=r(t)),n++,t)});return i+l})}function _(t,e,r,n,i){var a="category"===t.type?Number:t.d2c;if(void 0!==e)return[a(e),a(r)];if(n){var o,s,l,c,u,f=1/0,h=-(1/0),d=n.match(z);for("date"===t.type&&(a=g(a)),o=0;ou&&(f=u),u>h&&(h=u)));return h>=f?[f,h]:void 0}}var w=t("fast-isnumeric"),k=t("../../plotly"),A=t("../../lib"),M=t("../../plots/cartesian/axes"),T=t("../color"),E=t("../drawing"),L=t("../dragelement"),S=t("../../lib/setcursor"),C=e.exports={};C.layoutAttributes=t("./attributes"),C.supplyLayoutDefaults=function(t,e){for(var r=t.shapes||[],i=e.shapes=[],a=0;as&&(t="X"),t});return n>s&&(l=l.replace(/[\s,]*X.*/,""),A.log("Ignoring extra params in segment "+t)),i+l})},C.calcAutorange=function(t){var e,r,n,i,a,o=t._fullLayout,s=o.shapes;if(s.length&&t._fullData.length)for(e=0;eh?r=h:(u.left-=b.offsetLeft,u.right-=b.offsetLeft,u.top-=b.offsetTop,u.bottom-=b.offsetTop,b.selection.each(function(){var t=l.bBox(this);s.bBoxIntersect(u,t,c)&&(r=Math.max(r,o*(t[b.side]-u[a])+c))}),r=Math.min(h,r)),r>0||0>h){var d={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[b.side];e.attr("transform","translate("+d+")")}}}function p(){E=0,L=!0,S=z,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)})}var g=r.propContainer,v=r.propName,m=r.traceIndex,y=r.dfltName,b=r.avoid||{},x=r.attributes,_=r.transform,w=r.containerGroup,k=t._fullLayout,A=g.titlefont.family,M=g.titlefont.size,T=g.titlefont.color,E=1,L=!1,S=g.title.trim();""===S&&(E=0),S.match(/Click to enter .+ title/)&&(E=.2,L=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var z="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==m?a.restyle(t,v,e,m):a.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(x).selectAll("tspan.line").attr(x)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",L)}},{"../../lib":382,"../../lib/svg_text_utils":395,"../../plotly":402,"../../plots/plots":454,"../color":303,"../drawing":326,d3:113,"fast-isnumeric":117}],367:[function(t,e,r){"use strict";e.exports={solid:[1],dot:[1,1],dash:[4,1],longdash:[8,1],dashdot:[4,1,1,1],longdashdot:[8,1,1,1]}},{}],368:[function(t,e,r){"use strict";e.exports={solid:[[],0],dot:[[.5,1],200],dash:[[.5,1],50],longdash:[[.5,1],10],dashdot:[[.5,.625,.875,1],50],longdashdot:[[.5,.7,.8,1],10]}},{}],369:[function(t,e,r){"use strict";e.exports={circle:"\u25cf","circle-open":"\u25cb",square:"\u25a0","square-open":"\u25a1",diamond:"\u25c6","diamond-open":"\u25c7",cross:"+",x:"\u274c"}},{}],370:[function(t,e,r){"use strict";r.xmlns="http://www.w3.org/2000/xmlns/",r.svg="http://www.w3.org/2000/svg",r.xlink="http://www.w3.org/1999/xlink",r.svgAttrs={xmlns:r.svg,"xmlns:xlink":r.xlink}},{}],371:[function(t,e,r){"use strict";var n=t("./plotly");r.version="1.14.1",r.plot=n.plot,r.newPlot=n.newPlot,r.restyle=n.restyle,r.relayout=n.relayout,r.redraw=n.redraw,r.extendTraces=n.extendTraces,r.prependTraces=n.prependTraces,r.addTraces=n.addTraces,r.deleteTraces=n.deleteTraces,r.moveTraces=n.moveTraces,r.purge=n.purge,r.setPlotConfig=t("./plot_api/set_plot_config"),r.register=n.register,r.toImage=t("./plot_api/to_image"),r.downloadImage=t("./snapshot/download"),r.Icons=t("../build/ploticon"),r.Plots=n.Plots,r.Fx=n.Fx,r.Snapshot=n.Snapshot,r.PlotSchema=n.PlotSchema,r.Queue=n.Queue,r.d3=t("d3")},{"../build/ploticon":2,"./plot_api/set_plot_config":400,"./plot_api/to_image":401,"./plotly":402,"./snapshot/download":469,d3:113}],372:[function(t,e,r){"use strict";"undefined"!=typeof MathJax?(r.MathJax=!0,MathJax.Hub.Config({messageStyle:"none",skipStartupTypeset:!0,displayAlign:"left",tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]]}}),MathJax.Hub.Configured()):r.MathJax=!1},{}],373:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){Array.isArray(t)&&(e[r]=t[n])}},{}],374:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("tinycolor2"),a=t("./nested_property"),o=t("../components/colorscale/get_scale"),s=(Object.keys(t("../components/colorscale/scales")),/^([2-9]|[1-9][0-9]+)$/);r.valObjects={data_array:{coerceFunction:function(t,e,r){Array.isArray(t)?e.set(t):void 0!==r&&e.set(r)}},enumerated:{coerceFunction:function(t,e,r,n){n.coerceNumber&&(t=+t),-1===n.values.indexOf(t)?e.set(r):e.set(t)}},"boolean":{coerceFunction:function(t,e,r){t===!0||t===!1?e.set(t):e.set(r)}},number:{coerceFunction:function(t,e,r,i){!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if(n.strict===!0&&"string"!=typeof t)return void e.set(r);var i=String(t);void 0===t||n.noBlank===!0&&!i?e.set(r):e.set(i)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r){var n=r.length;return"string"==typeof t&&t.substr(0,n)===r&&s.test(t.substr(n))?void e.set(t):void e.set(r)}},flaglist:{coerceFunction:function(t,e,r,n){if("string"!=typeof t)return void e.set(r);if(-1!==(n.extras||[]).indexOf(t))return void e.set(t);for(var i=t.split("+"),a=0;a2)return!1;var l=o[0].split("-");if(l.length>3||3!==l.length&&o[1])return!1;if(4===l[0].length)r=Number(l[0]);else{if(2!==l[0].length)return!1;var c=(new Date).getFullYear();r=((Number(l[0])-c+70)%100+200)%100+c-70}return s(r)?1===l.length?new Date(r,0,1).getTime():(n=Number(l[1])-1,l[1].length>2||!(n>=0&&11>=n)?!1:2===l.length?new Date(r,n,1).getTime():(i=Number(l[2]),l[2].length>2||!(i>=1&&31>=i)?!1:(i=new Date(r,n,i).getTime(),o[1]?(l=o[1].split(":"),l.length>3?!1:(a=Number(l[0]),l[0].length>2||!(a>=0&&23>=a)?!1:(i+=36e5*a,1===l.length?i:(n=Number(l[1]),l[1].length>2||!(n>=0&&59>=n)?!1:(i+=6e4*n,2===l.length?i:(t=Number(l[2]),t>=0&&60>t?i+1e3*t:!1)))))):i))):!1},r.isDateTime=function(t){return r.dateTime2ms(t)!==!1},r.ms2DateTime=function(t,e){if("undefined"==typeof o)return void l.error("d3 is not defined.");e||(e=0);var r=new Date(t),i=o.time.format("%Y-%m-%d")(r);return 7776e6>e?(i+=" "+n(r.getHours(),2),432e6>e&&(i+=":"+n(r.getMinutes(),2),108e5>e&&(i+=":"+n(r.getSeconds(),2),3e5>e&&(i+="."+n(r.getMilliseconds(),3)))),i.replace(/([:\s]00)*\.?[0]*$/,"")):i};var c={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},u={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},f=o.time.format.utc,h={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(f),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(f)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(f)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){u[t].forEach(function(e){h[t].D.push(f(e)),["H","I","D"].forEach(function(r){c[r].forEach(function(n){var i=h[t][r];i.push(f(e+"~"+n)),i.push(f(n+"~"+e))})})})});var d=/[a-z]*/g,p=function(t){return t.substr(0,3)},g=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,v=/[\s,\/\-\.\(\)]+/g,m=/~?([ap])~?m(~|$)/,y=function(t,e){return e+"m "},b=/\d\d\d\d/,x=/(^|~)[a-z]{3}/,_=/[ap]m/,w=/:/,k=/q([1-4])/,A=["31~mar","30~jun","30~sep","31~dec"],M=function(t,e){return A[e-1]},T=/ ?([+\-]\d\d:?\d\d|Z)$/;r.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1; +t=t.toLowerCase().replace(d,p).replace(g,"").replace(v,"~").replace(m,y).replace(k,M).trim().replace(T,"");var e,r,n=null,o=i(t),s=a(t);e=h[o][s],r=e.length;for(var l=0;r>l&&!(n=e[l].parse(t));l++);if(!(n instanceof Date))return!1;var c=n.getTimezoneOffset();return n.setTime(n.getTime()+60*c*1e3),n}},{"../lib":382,d3:113,"fast-isnumeric":117}],376:[function(t,e,r){"use strict";var n=t("events").EventEmitter,i={init:function(t){if(t._ev instanceof n)return t;var e=new n;return t._ev=e,t.on=e.on.bind(e),t.once=e.once.bind(e),t.removeListener=e.removeListener.bind(e),t.removeAllListeners=e.removeAllListeners.bind(e),t.emit=function(r,n){"undefined"!=typeof jQuery&&jQuery(t).trigger(r,n),e.emit(r,n)},t},triggerHandler:function(t,e,r){var n,i;"undefined"!=typeof jQuery&&(n=jQuery(t).triggerHandler(e,r));var a=t._ev;if(!a)return n;var o=a._events[e];if(!o)return n;"function"==typeof o&&(o=[o]);for(var s=o.pop(),l=0;lp;p++){o=t[p];for(s in o)l=h[s],c=o[s],e&&c&&(i(c)||(u=a(c)))?(u?(u=!1,f=l&&a(l)?l:[]):f=l&&i(l)?l:{},h[s]=n([f,c],e,r)):("undefined"!=typeof c||r)&&(h[s]=c)}return h}var i=t("./is_plain_object.js"),a=Array.isArray;r.extendFlat=function(){return n(arguments,!1,!1)},r.extendDeep=function(){return n(arguments,!0,!1)},r.extendDeepAll=function(){return n(arguments,!0,!0)}},{"./is_plain_object.js":383}],378:[function(t,e,r){"use strict";e.exports=function(t){for(var e=[],r=0;ry;y++)f=s(p,y),d=l(e,y),m[y]=n(f,d);else m=n(p,e);return m}var s=t("tinycolor2"),l=t("fast-isnumeric"),c=t("../components/colorscale/make_scale_function"),u=t("../components/color/attributes").defaultLine,f=t("./str2rgbarray"),h=1;e.exports=o},{"../components/color/attributes":302,"../components/colorscale/make_scale_function":320,"./str2rgbarray":394,"fast-isnumeric":117,tinycolor2:274}],381:[function(t,e,r){"use strict";function n(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(e>r)break;t=t.slice(0,e)+l(t.slice(e+5,r))+t.slice(r+6)}return t}function i(t){return t.replace(/\/g,"\n")}function a(t){return t.replace(/\<.*\>/g,"")}function o(t){for(var e=0;(e=t.indexOf("&",e))>=0;){var r=t.indexOf(";",e);if(e>r)e+=1;else{var n=c[t.slice(e+1,r)];t=n?t.slice(0,e)+n+t.slice(r+1):t.slice(0,e)+t.slice(r+1)}}return t}function s(t){return""+o(a(n(i(t))))}var l=t("superscript-text"),c={mu:"\u03bc",amp:"&",lt:"<",gt:">"};e.exports=s},{"superscript-text":263}],382:[function(t,e,r){"use strict";var n=t("d3"),i=e.exports={};i.nestedProperty=t("./nested_property"),i.isPlainObject=t("./is_plain_object");var a=t("./coerce");i.valObjects=a.valObjects,i.coerce=a.coerce,i.coerce2=a.coerce2,i.coerceFont=a.coerceFont;var o=t("./dates");i.dateTime2ms=o.dateTime2ms,i.isDateTime=o.isDateTime,i.ms2DateTime=o.ms2DateTime,i.parseDate=o.parseDate;var s=t("./search");i.findBin=s.findBin,i.sorterAsc=s.sorterAsc,i.sorterDes=s.sorterDes,i.distinctVals=s.distinctVals,i.roundUp=s.roundUp;var l=t("./stats");i.aggNums=l.aggNums,i.len=l.len,i.mean=l.mean,i.variance=l.variance,i.stdev=l.stdev,i.interp=l.interp;var c=t("./matrix");i.init2dArray=c.init2dArray,i.transposeRagged=c.transposeRagged,i.dot=c.dot,i.translationMatrix=c.translationMatrix,i.rotationMatrix=c.rotationMatrix,i.rotationXYMatrix=c.rotationXYMatrix,i.apply2DTransform=c.apply2DTransform,i.apply2DTransform2=c.apply2DTransform2;var u=t("./extend");i.extendFlat=u.extendFlat,i.extendDeep=u.extendDeep,i.extendDeepAll=u.extendDeepAll;var f=t("./loggers");i.log=f.log,i.warn=f.warn,i.error=f.error,i.notifier=t("./notifier"),i.swapAttrs=function(t,e,r,n){r||(r="x"),n||(n="y");for(var a=0;ar?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},i.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},i.identity=function(t){return t},i.randstr=function h(t,e,r){if(r||(r=16),void 0===e&&(e=24),0>=e)return"0";var n,i,a,o=Math.log(Math.pow(2,e))/Math.log(r),s="";for(n=2;o===1/0;n*=2)o=Math.log(Math.pow(2,e/n))/Math.log(r)*n;var l=o-Math.floor(o);for(n=0;n-1||c!==1/0&&c>=Math.pow(2,e)?h(t,e,r):s},i.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={};return r.optionList=[],r._newoption=function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)},r["_"+e]=t,r},i.smooth=function(t,e){if(e=Math.round(e)||0,2>e)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,c=new Array(l),u=new Array(o);for(r=0;l>r;r++)c[r]=(1-Math.cos(Math.PI*(r+1)/e))/(2*e);for(r=0;o>r;r++){for(a=0,n=0;l>n;n++)i=r+n+1-e,-o>i?i-=s*Math.round(i/s):i>=s&&(i-=s*Math.floor(i/s)),0>i?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*c[n];u[r]=a}return u},i.syncOrAsync=function(t,e,r){function n(){return i.syncOrAsync(t,e,r)}for(var a,o;t.length;)if(o=t.splice(0,1)[0],a=o(e),a&&a.then)return a.then(n).then(void 0,i.promiseError);return r&&r(e)},i.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},i.noneOrAll=function(t,e,r){if(t){var n,i,a=!1,o=!0;for(n=0;ni;i++)e[i][r]=t[i]},i.minExtend=function(t,e){var r={};"object"!=typeof e&&(e={});var n,a,o,s=3,l=Object.keys(t);for(n=0;n1?n+a[1]:"";if(i&&(a.length>1||o.length>4))for(;r.test(o);)o=o.replace(r,"$1"+i+"$2");return o+s}},{"./coerce":374,"./dates":375,"./extend":377,"./is_plain_object":383,"./loggers":384,"./matrix":385,"./nested_property":386,"./notifier":387,"./search":390,"./stats":393,d3:113}],383:[function(t,e,r){"use strict";e.exports=function(t){return"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],384:[function(t,e,r){"use strict";var n=t("../plot_api/plot_config"),i=e.exports={};i.log=function(){if(n.logging>1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;en;n++)r[n]=new Array(e);return r},r.transposeRagged=function(t){var e,r,n=0,i=t.length;for(e=0;i>e;e++)n=Math.max(n,t[e].length);var a=new Array(n);for(e=0;n>e;e++)for(a[e]=new Array(i),r=0;i>r;r++)a[e][r]=t[r][e];return a},r.dot=function(t,e){if(!t.length||!e.length||t.length!==e.length)return null;var n,i,a=t.length;if(t[0].length)for(n=new Array(a),i=0;a>i;i++)n[i]=r.dot(t[i],e);else if(e[0].length){var o=r.transposeRagged(e);for(n=new Array(o.length),i=0;ii;i++)n+=t[i]*e[i];return n},r.translationMatrix=function(t,e){return[[1,0,t],[0,1,e],[0,0,1]]},r.rotationMatrix=function(t){var e=t*Math.PI/180;return[[Math.cos(e),-Math.sin(e),0],[Math.sin(e),Math.cos(e),0],[0,0,1]]},r.rotationXYMatrix=function(t,e,n){return r.dot(r.dot(r.translationMatrix(e,n),r.rotationMatrix(t)),r.translationMatrix(-e,-n))},r.apply2DTransform=function(t){return function(){var e=arguments;3===e.length&&(e=e[0]);var n=1===arguments.length?e[0]:[e[0],e[1]];return r.dot(t,[n[0],n[1],1]).slice(0,2)}},r.apply2DTransform2=function(t){var e=r.apply2DTransform(t);return function(t){return e(t.slice(0,2)).concat(e(t.slice(2,4)))}}},{}],386:[function(t,e,r){"use strict";function n(t,e){return function(){var r,i,a,o,s,l=t;for(o=0;o=0;e--){if(n=t[e],o=!1,Array.isArray(n))for(r=n.length-1;r>=0;r--)c(n[r])?o?n[r]=void 0:n.pop():o=!0;else if("object"==typeof n&&null!==n)for(a=Object.keys(n),o=!1,r=a.length-1;r>=0;r--)c(n[a[r]])&&!i(n[a[r]],a[r])?delete n[a[r]]:o=!0;if(o)return}}function c(t){return void 0===t||null===t?!0:"object"!=typeof t?!1:Array.isArray(t)?!t.length:!Object.keys(t).length}function u(t,e,r){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:r,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,l=e.split(".");sr||r>a||o>n||n>s?!1:!e||!c(t)}function r(t,e){var r=t[0],l=t[1];if(i>r||r>a||o>l||l>s)return!1;var c,u,f,h,d,p=n.length,g=n[0][0],v=n[0][1],m=0;for(c=1;p>c;c++)if(u=g,f=v,g=n[c][0],v=n[c][1],h=Math.min(u,g),!(h>r||r>Math.max(u,g)||l>Math.max(f,v)))if(l=l&&r!==h&&m++}return m%2===1}var n=t.slice(),i=n[0][0],a=i,o=n[0][1],s=o;n.push(n[0]);for(var l=1;la;a++)if(o=[t[a][0]-l[0],t[a][1]-l[1]],s=n(o,c),0>s||s>u||Math.abs(n(o,h))>i)return!0;return!1};i.filter=function(t,e){function r(r){t.push(r);var s=n.length,l=i;n.splice(o+1);for(var c=l+1;c1){var s=t.pop();r(s)}return{addPt:r,raw:t,filtered:n}}},{"./matrix":385}],389:[function(t,e,r){"use strict";function n(t,e){for(var r,n=[],a=0;a=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;rt}function i(t,e){return e>=t}function a(t,e){return t>e}function o(t,e){return t>=e}var s=t("fast-isnumeric"),l=t("../lib");r.findBin=function(t,e,r){if(s(e.start))return r?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var c,u,f=0,h=e.length,d=0;for(u=e[e.length-1]>=e[0]?r?n:i:r?o:a;h>f&&d++<100;)c=Math.floor((f+h)/2),u(e[c],t)?f=c+1:h=c;return d>90&&l.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;n>s;s++)e[s+1]>e[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,c=r?Math.ceil:Math.floor;a>i&&o++<100;)n=c((i+a)/2),e[n]<=t?i=n+s:a=n-l;return e[i]}},{"../lib":382,"fast-isnumeric":117}],391:[function(t,e,r){"use strict";e.exports=function(t,e){(t.attr("class")||"").split(" ").forEach(function(e){0===e.indexOf("cursor-")&&t.classed(e,!1)}),e&&t.classed("cursor-"+e,!0)}},{}],392:[function(t,e,r){"use strict";var n=t("../components/color"),i=function(){};e.exports=function(t){for(var e in t)"function"==typeof t[e]&&(t[e]=i);t.destroy=function(){t.container.parentNode.removeChild(t.container)};var r=document.createElement("div");return r.textContent="Webgl is not supported by your browser - visit http://get.webgl.org for more info",r.style.cursor="pointer",r.style.fontSize="24px",r.style.color=n.defaults[0],t.container.appendChild(r),t.container.style.background="#FFFFFF",t.container.onclick=function(){window.open("http://get.webgl.org")},!1}},{"../components/color":303}],393:[function(t,e,r){"use strict";var n=t("fast-isnumeric");r.aggNums=function(t,e,i,a){var o,s;if(a||(a=i.length),n(e)||(e=!1),Array.isArray(i[0])){for(s=new Array(a),o=0;a>o;o++)s[o]=r.aggNums(t,e,i[o]);i=s}for(o=0;a>o;o++)n(e)?n(i[o])&&(e=t(+e,+i[o])):e=i[o];return e},r.len=function(t){return r.aggNums(function(t){return t+1},0,t)},r.mean=function(t,e){return e||(e=r.len(t)),r.aggNums(function(t,e){return t+e},0,t)/e},r.variance=function(t,e,i){return e||(e=r.len(t)),n(i)||(i=r.mean(t,e)),r.aggNums(function(t,e){return t+Math.pow(e-i,2)},0,t)/e},r.stdev=function(t,e,n){return Math.sqrt(r.variance(t,e,n))},r.interp=function(t,e){if(!n(e))throw"n should be a finite number";if(e=e*t.length-.5,0>e)return t[0];if(e>t.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"fast-isnumeric":117}],394:[function(t,e,r){"use strict";function n(t){return t=i(t),a.str2RgbaArray(t.toRgbString())}var i=t("tinycolor2"),a=t("arraytools");e.exports=n},{arraytools:49,tinycolor2:274}],395:[function(t,e,r){"use strict";function n(t,e){return t.node().getBoundingClientRect()[e]}function i(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function a(t,e,r){var n="math-output-"+l.Lib.randstr([],64),a=c.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(i(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,a.node()],function(){var e=c.select("body").select("#MathJax_SVG_glyphs");if(a.select(".MathJax_SVG").empty()||!a.select("svg").node())u.log("There was an error in the tex syntax.",t),r();else{var n=a.select("svg").node().getBoundingClientRect();r(a.select(".MathJax_SVG"),e,n)}a.remove()})}function o(t){for(var e=l.util.html_entity_decode(t),r=e.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),r=e&&e[2].toLowerCase(),n=d[r];if(void 0!==n){var i=e[1],a=e[3],o=a.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===r){if(i)return"
";if("href"!==a.substr(0,4).toLowerCase())return"";var s=document.createElement("a");return s.href=a.substr(4).replace(/["'=]/g,""),-1===p.indexOf(s.protocol)?"":'"}if("br"===r)return"
";if(i)return"sup"===r?'':"sub"===r?'':"";var c=""}return l.util.xml_entity_encode(t).replace(/");i>0;i=r.indexOf("
",i+1))n.push(i);var a=0;n.forEach(function(t){for(var e=t+a,n=r.slice(0,e),i="",o=n.length-1;o>=0;o--){var s=n[o].match(/<(\/?).*>/i);if(s&&"
"!==n[o]){s[1]||(i=n[o]);break}}i&&(r.splice(e+1,0,i),r.splice(e,0,""),a+=2)});var o=r.join(""),s=o.split(/
/gi);return s.length>1&&(r=s.map(function(t,e){return''+t+""})),r.join("")}function s(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-c.top+"px",left:a()-c.left+"px","z-index":1e3}),this}}var l=t("../plotly"),c=t("d3"),u=t("../lib"),f=t("../constants/xmlns_namespaces"),h=e.exports={};c.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),r=(new DOMParser).parseFromString(e,"application/xml"),n=r.documentElement.firstChild;n;)this.node().appendChild(this.node().ownerDocument.importNode(n,!0)),n=n.nextSibling;return r.querySelector("parsererror")?(u.log(r.querySelector("parsererror div").textContent),null):c.select(this.node().lastChild)},h.html_entity_decode=function(t){var e=c.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),r},h.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},h.convertToTspans=function(t,e){function r(){d.empty()||(p=u.attr("class")+"-math",d.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),h=t.appendSVG(s),h||t.text(i),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(u)}var i=t.text(),s=o(i),u=t,f=!u.attr("data-notex")&&s.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),h=i,d=c.select(u.node().parentNode);if(!d.empty()){var p=u.attr("class")?u.attr("class").split(" ")[0]:"text";p+="-math",d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=l.Lib.getPlotDiv(u.node());(v&&v._promises||[]).push(new Promise(function(t){u.style({visibility:"hidden"});var i={fontSize:parseInt(u.style("font-size"),10)};a(f[2],i,function(i,a,o){d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove();var s=i&&i.select("svg");if(!s||!s.node())return r(),void t();var l=d.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});l.node().appendChild(s.node()),a&&a.node()&&s.node().insertBefore(a.node().cloneNode(!0),s.node().firstChild),s.attr({"class":p,height:o.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=u.style("fill")||"black";s.select("g").attr({fill:c,stroke:c});var f=n(s,"width"),h=n(s,"height"),g=+u.attr("x")-f*{start:0,middle:.5,end:1}[u.attr("text-anchor")||"start"],v=parseInt(u.style("font-size"),10)||n(u,"height"),m=-v/4;"y"===p[0]?(l.attr({transform:"rotate("+[-90,+u.attr("x"),+u.attr("y")]+") translate("+[-f/2,m-h/2]+")"}),s.attr({x:+u.attr("x"),y:+u.attr("y")})):"l"===p[0]?s.attr({x:u.attr("x"),y:m-h/2}):"a"===p[0]?s.attr({x:0,y:m}):s.attr({x:g,y:+u.attr("y")+m-h/2}),e&&e.call(u,l),t(l)})}))}else r();return t}};var d={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},p=["http:","https:","mailto:"],g=new RegExp("]*)?/?>","g");h.plainText=function(t){return(t||"").replace(g," ")},h.makeEditable=function(t,e,r){function n(){a(),o.style({opacity:0});var t,e=h.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0})}function i(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}function a(){var t=c.select(l.Lib.getPlotDiv(o.node())),e=t.select(".svg-container"),n=e.append("div");n.classed("plugin-editable editable",!0).style({position:"absolute","font-family":o.style("font-family")||"Arial","font-size":o.style("font-size")||12,color:r.fill||o.style("fill")||"black",opacity:1,"background-color":r.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(o.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(r.text||o.attr("data-unformatted")).call(s(o,e,r)).on("blur",function(){o.text(this.textContent).style({opacity:1});var t,e=c.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0});var r=this.textContent;c.select(this).transition().duration(0).remove(),c.select(document).on("mouseup",null),u.edit.call(o,r)}).on("focus",function(){var t=this;c.select(document).on("mouseup",function(){return c.event.target===t?!1:void(document.activeElement===n.node()&&n.node().blur())})}).on("keyup",function(){27===c.event.which?(o.style({opacity:1}),c.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),u.cancel.call(o,this.textContent)):(u.input.call(o,this.textContent),c.select(this).call(s(o,e,r)))}).on("keydown",function(){13===c.event.which&&this.blur()}).call(i)}r||(r={});var o=this,u=c.dispatch("edit","input","cancel"),f=c.select(this.node()).style({"pointer-events":"all"}),h=e||f;return e&&f.style({"pointer-events":"none"}),r.immediate?n():h.on("click",n),c.rebind(this,u,"on")}},{"../constants/xmlns_namespaces":370,"../lib":382,"../plotly":402,d3:113}],396:[function(t,e,r){"use strict";var n=e.exports={},i=t("../plots/geo/constants").locationmodeToLayer,a=t("topojson").feature;n.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},n.getTopojsonPath=function(t,e){return t+e+".json"},n.getTopojsonFeatures=function(t,e){var r=i[t.locationmode],n=e.objects[r];return a(e,n).features}},{"../plots/geo/constants":424,topojson:275}],397:[function(t,e,r){"use strict";function n(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function i(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function a(t,e){t._context||(t._context=R.extendFlat({},P.defaultConfig));var r=t._context;e&&(Object.keys(e).forEach(function(t){t in r&&("setBackground"===t&&"opaque"===e[t]?r[t]=i:r[t]=e[t])}),e.plot3dPixelRatio&&!r.plotGlPixelRatio&&(r.plotGlPixelRatio=r.plot3dPixelRatio)),r.staticPlot&&(r.editable=!1,r.autosizable=!1,r.scrollZoom=!1,r.doubleClick=!1,r.showTips=!1,r.showLink=!1,r.displayModeBar=!1)}function o(t,e,r){var n=S.select(t).selectAll(".plot-container").data([0]);n.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=n.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e),r&&(t.layout=r),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(w(t,{}),t._fullLayout.autosize=r.autosize=!0),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var a=t.framework.svg(),o=1,s=t._fullLayout.title;""!==s&&s||(o=0);var l="Click to enter title",c=function(){this.call(P.util.convertToTspans)},u=a.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":s}),s&&s!==l||(o=.2,u.attr({"data-unformatted":l}).text(l).style({opacity:o}).on("mouseover.opacity",function(){S.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){S.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),N.addLinks(t),Promise.resolve()}function s(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var n=P.Axes.list({_fullLayout:t});for(e=0;ee;e++){var o=t.annotations[e];o.ref&&("paper"===o.ref?(o.xref="paper",o.yref="paper"):"data"===o.ref&&(o.xref="x",o.yref="y"),delete o.ref),l(o,"xref"),l(o,"yref")}void 0===t.shapes||Array.isArray(t.shapes)||(R.warn("Shapes must be an array."),delete t.shapes);var s=(t.shapes||[]).length;for(e=0;s>e;e++){var c=t.shapes[e];l(c,"xref"),l(c,"yref")}var u=t.legend;u&&(u.x>3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var h=N.getSubplotIds(t,"gl3d");for(e=0;er;++r)b[r]=v[e]+m*y[2+4*r];d.camera={eye:{x:b[0],y:b[1],z:b[2]},center:{x:v[0],y:v[1],z:v[2]},up:{x:y[1],y:y[5],z:y[9]}},delete d.cameraposition}}return F.clean(t),t}function l(t,e){var r=t[e],n=e.charAt(0);r&&"paper"!==r&&(t[e]=P.Axes.cleanId(r,n))}function c(t,e){for(var r=[],n=(t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid})),i=0;ia&&(s=R.randstr(n),-1!==r.indexOf(s));a++);o.uid=R.randstr(n),n.push(o.uid)}if(r.push(o.uid),"histogramy"===o.type&&"xbins"in o&&!("ybins"in o)&&(o.ybins=o.xbins,delete o.xbins),o.error_y&&"opacity"in o.error_y){var l=F.defaults,c=o.error_y.color||(N.traceIs(o,"bar")?F.defaultLine:l[i%l.length]);o.error_y.color=F.addOpacity(F.rgb(c),F.opacity(c)*o.error_y.opacity),delete o.error_y.opacity}if("bardir"in o&&("h"!==o.bardir||!N.traceIs(o,"bar")&&"histogram"!==o.type.substr(0,9)||(o.orientation="h",x(o)),delete o.bardir),"histogramy"===o.type&&x(o),"histogramx"!==o.type&&"histogramy"!==o.type||(o.type="histogram"),"scl"in o&&(o.colorscale=o.scl,delete o.scl),"reversescl"in o&&(o.reversescale=o.reversescl,delete o.reversescl),o.xaxis&&(o.xaxis=P.Axes.cleanId(o.xaxis,"x")),o.yaxis&&(o.yaxis=P.Axes.cleanId(o.yaxis,"y")),N.traceIs(o,"gl3d")&&o.scene&&(o.scene=N.subplotsRegistry.gl3d.cleanId(o.scene)),N.traceIs(o,"pie")||(Array.isArray(o.textposition)?o.textposition=o.textposition.map(u):o.textposition&&(o.textposition=u(o.textposition))),N.traceIs(o,"2dMap")&&("YIGnBu"===o.colorscale&&(o.colorscale="YlGnBu"),"YIOrRd"===o.colorscale&&(o.colorscale="YlOrRd")),N.traceIs(o,"markerColorscale")&&o.marker){var h=o.marker;"YIGnBu"===h.colorscale&&(h.colorscale="YlGnBu"),"YIOrRd"===h.colorscale&&(h.colorscale="YlOrRd")}if("surface"===o.type&&R.isPlainObject(o.contours)){var d=["x","y","z"];for(a=0;an?a.push(i+n):a.push(n);return a}function p(t,e,r){var n,i;for(n=0;n=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||0>i&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function g(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),p(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&p(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function v(t,e,r){var n,i;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),n=0;n=0&&l0){var s=_(t._boundingBoxMargins),l=s.left+s.right,c=s.bottom+s.top,u=a._container.node().getBoundingClientRect(),f=1-2*o.frameMargins;i=Math.round(f*(u.width-l)),n=Math.round(f*(u.height-c))}else r=window.getComputedStyle(t),n=parseFloat(r.height)||a.height,i=parseFloat(r.width)||a.width;return Math.abs(a.width-i)>1||Math.abs(a.height-n)>1?(a.height=t.layout.height=n,a.width=t.layout.width=i):"initial"!==a.autosize&&(delete e.autosize,a.autosize=t.layout.autosize=!0),N.sanitizeMargins(a),e}function k(t){var e=S.select(t),r=t._fullLayout;if(r._container=e.selectAll(".plot-container").data([0]),r._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),r._paperdiv=r._container.selectAll(".svg-container").data([0]),r._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===r.autosize&&(w(t,{}),r.autosize=!0,t.layout.autosize=!0),r._glcontainer=r._paperdiv.selectAll(".gl-container").data([0]),r._glcontainer.enter().append("div").classed("gl-container",!0),r._geocontainer=r._paperdiv.selectAll(".geo-container").data([0]),r._geocontainer.enter().append("div").classed("geo-container",!0),r._paperdiv.selectAll(".main-svg").remove(),r._paper=r._paperdiv.insert("svg",":first-child").classed("main-svg",!0),r._toppaper=r._paperdiv.append("svg").classed("main-svg",!0),!r._uid){var n=[];S.selectAll("defs").each(function(){this.id&&n.push(this.id.split("-")[1])}),r._uid=R.randstr(n)}r._paperdiv.selectAll(".main-svg").attr(W.svgAttrs),r._defs=r._paper.append("defs").attr("id","defs-"+r._uid),r._topdefs=r._toppaper.append("defs").attr("id","topdefs-"+r._uid),r._draggers=r._paper.append("g").classed("draglayer",!0);var i=r._paper.append("g").classed("layer-below",!0);r._imageLowerLayer=i.append("g").classed("imagelayer",!0),r._shapeLowerLayer=i.append("g").classed("shapelayer",!0);var a=P.Axes.getSubplots(t);a.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,a),r._has("cartesian")&&M(t,a),r._ternarylayer=r._paper.append("g").classed("ternarylayer",!0);var o=r._paper.selectAll(".layer-subplot");r._imageSubplotLayer=o.selectAll(".imagelayer"),r._shapeSubplotLayer=o.selectAll(".shapelayer");var s=r._paper.append("g").classed("layer-above",!0);r._imageUpperLayer=s.append("g").classed("imagelayer",!0),r._shapeUpperLayer=s.append("g").classed("shapelayer",!0),r._pielayer=r._paper.append("g").classed("pielayer",!0),r._glimages=r._paper.append("g").classed("glimages",!0),r._geoimages=r._paper.append("g").classed("geoimages",!0),r._infolayer=r._toppaper.append("g").classed("infolayer",!0),r._zoomlayer=r._toppaper.append("g").classed("zoomlayer",!0),r._hoverlayer=r._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var l=R.syncOrAsync([T,function(){return P.Axes.doTicks(t,"redraw")},j.init],t);return l&&l.then&&t._promises.push(l),l}function A(t,e){function r(e,r){return function(){return P.Axes.getFromId(t,e,r)}}for(var n,i,a=t._fullLayout._plots={},o=0;o0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),A=w===_;x?t.framework===k&&!b&&A||(t.framework=k,k(t)):A?b&&k(t):(t.framework=k,k(t)),b&&P.Axes.saveRangeInitial(t);var M=t._fullLayout,E=!t.calcdata||t.calcdata.length!==(t.data||[]).length;E&&h(t);for(var L=0;LY.range[0]?[1,2]:[2,1]);else{var W=Y.range[0],Z=Y.range[1];"log"===O?(0>=W&&0>=Z&&i(q+".autorange",!0),0>=W?W=Z/1e6:0>=Z&&(Z=W/1e6),i(q+".range[0]",Math.log(W)/Math.LN10),i(q+".range[1]",Math.log(Z)/Math.LN10)):(i(q+".range[0]",Math.pow(10,W)),i(q+".range[1]",Math.pow(10,Z)))}else i(q+".autorange",!0)}if("reverse"===D)H.range?H.range.reverse():(i(q+".autorange",!0),H.range=[1,0]),G.autorange?_=!0:x=!0;else if("annotations"===z.parts[0]||"shapes"===z.parts[0]){var K=z.parts[1],$=z.parts[0],Q=p[$]||[],J=P[R.titleCase($)],tt=Q[K]||{};2===z.parts.length&&("add"===v[C]||R.isPlainObject(v[C])?E[C]="remove":"remove"===v[C]?-1===K?(E[$]=Q,delete E[C]):E[C]=tt:R.log("???",v)), +!a(tt,"x")&&!a(tt,"y")||R.containsAny(C,["color","opacity","align","dash"])||(_=!0),J.draw(t,K,z.parts.slice(2).join("."),v[C]),delete v[C]}else if("images"===z.parts[0]){var rt=R.objectFromPath(C,O);R.extendDeepAll(t.layout,rt),U.supplyLayoutDefaults(t.layout,t._fullLayout),U.draw(t)}else if("mapbox"===z.parts[0]&&"layers"===z.parts[1]){R.extendDeepAll(t.layout,R.objectFromPath(C,O));var nt=(t._fullLayout.mapbox||{}).layers||[],it=z.parts[2]+1-nt.length;for(d=0;it>d;d++)nt.push({});x=!0}else 0===z.parts[0].indexOf("scene")?x=!0:0===z.parts[0].indexOf("geo")?x=!0:0===z.parts[0].indexOf("ternary")?x=!0:!g._has("gl2d")||-1===C.indexOf("axis")&&"plot_bgcolor"!==z.parts[0]?"hiddenlabels"===C?_=!0:-1!==z.parts[0].indexOf("legend")?m=!0:-1!==C.indexOf("title")?y=!0:-1!==z.parts[0].indexOf("bgcolor")?b=!0:z.parts.length>1&&R.containsAny(z.parts[1],["tick","exponent","grid","zeroline"])?y=!0:-1!==C.indexOf(".linewidth")&&-1!==C.indexOf("axis")?y=b=!0:z.parts.length>1&&-1!==z.parts[1].indexOf("line")?b=!0:z.parts.length>1&&"mirror"===z.parts[1]?y=b=!0:"margin.pad"===C?y=b=!0:"margin"===z.parts[0]||"autorange"===z.parts[1]||"rangemode"===z.parts[1]||"type"===z.parts[1]||"domain"===z.parts[1]||C.match(/^(bar|box|font)/)?_=!0:-1!==["hovermode","dragmode"].indexOf(C)?k=!0:-1===["hovermode","dragmode","height","width","autosize"].indexOf(C)&&(x=!0):x=!0,z.set(O)}I&&I.add(t,et,[t,E],et,[t,M]),v.autosize&&(v=w(t,v)),(v.height||v.width||v.autosize)&&(_=!0);var at=Object.keys(v),ot=[N.previousPromises];if(x||_)ot.push(function(){return t.layout=void 0,_&&(t.calcdata=void 0),P.plot(t,"",p)});else if(at.length&&(N.supplyDefaults(t),g=t._fullLayout,m&&ot.push(function(){return V.draw(t),N.previousPromises(t)}),b&&ot.push(T),y&&ot.push(function(){return P.Axes.doTicks(t,"redraw"),L(t),N.previousPromises(t)}),k)){var st;for(X(t),st=N.getSubplotIds(g,"gl3d"),d=0;d1)};c(r.width)&&c(r.height)||s(new Error("Height and width should be pixel values."));var u=n.clone(e,{format:"png",height:r.height,width:r.width}),f=u.td;f.style.position="absolute",f.style.left="-5000px",document.body.appendChild(f);var h=n.getRedrawFunc(f);a.plot(f,u.data,u.layout,u.config).then(h).then(l).then(function(e){t(e)}).catch(function(t){s(t)})});return s}var i=t("fast-isnumeric"),a=t("../plotly"),o=t("../lib");e.exports=n},{"../lib":382,"../plotly":402,"../snapshot":471,"fast-isnumeric":117}],402:[function(t,e,r){"use strict";t("es6-promise").polyfill(),r.Lib=t("./lib"),r.util=t("./lib/svg_text_utils"),r.Queue=t("./lib/queue"),t("../build/plotcss"),r.MathJaxConfig=t("./fonts/mathjax_config"),r.defaultConfig=t("./plot_api/plot_config");var n=r.Plots=t("./plots/plots");r.Axes=t("./plots/cartesian/axes"),r.Fx=t("./plots/cartesian/graph_interact"),r.micropolar=t("./plots/polar/micropolar"),r.Color=t("./components/color"),r.Drawing=t("./components/drawing"),r.Colorscale=t("./components/colorscale"),r.Colorbar=t("./components/colorbar"),r.ErrorBars=t("./components/errorbars"),r.Annotations=t("./components/annotations"),r.Shapes=t("./components/shapes"),r.Legend=t("./components/legend"),r.Images=t("./components/images"),r.ModeBar=t("./components/modebar"),r.register=function(t){if(!t)throw new Error("No argument passed to Plotly.register.");t&&!Array.isArray(t)&&(t=[t]);for(var e=0;ec&&u>e&&(void 0===i[r]?a[f]=T.tickText(t,e):a[f]=s(t,e,String(i[r])),f++);return f=864e5?t._tickround="d":r>=36e5?t._tickround="H":r>=6e4?t._tickround="M":r>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(r/2)/Math.LN10);else{b(r)||(r=Number(r.substr(1))),t._tickround=2-Math.floor(Math.log(r)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var n=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(n)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((n-1)/3):t._tickexponent=n)}else"M"===r.charAt(0)?t._tickround=2===r.length?"m":"y":t._tickround=null}function o(t,e){var r=t.match(U),n=new Date(e);if(r){var i=Math.min(+r[1]||6,6),a=String(e/1e3%1+2.0000005).substr(2,i).replace(/0+$/,"")||"0";return y.time.format(t.replace(U,a))(n)}return y.time.format(t)(n)}function s(t,e,r){var n=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}function l(t,e,r,n){var i,a=e.x,s=t._tickround,l=new Date(a),c="";r&&t.hoverformat?i=o(t.hoverformat,a):t.tickformat?i=o(t.tickformat,a):(n&&(b(s)?s+=2:s={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[s]),"y"===s?i=I(l):"m"===s?i=N(l):(a!==t._tmin||r||(c="
"+I(l)),"d"===s?i=j(l):"H"===s?i=F(l):(a!==t._tmin||r||(c="
"+j(l)+", "+I(l)),i=D(l),"M"!==s&&(i+=B(l),"S"!==s&&(i+=h(m(a/1e3,1),t,"none",r).substr(1)))))),e.text=i+c}function c(t,e,r,n,i){var a=t.dtick,o=e.x;if(!n||"string"==typeof a&&"L"===a.charAt(0)||(a="L3"),t.tickformat||"string"==typeof a&&"L"===a.charAt(0))e.text=h(Math.pow(10,o),t,i,n);else if(b(a)||"D"===a.charAt(0)&&m(o+.01,1)<.1)if(-1!==["e","E","power"].indexOf(t.exponentformat)){var s=Math.round(o);0===s?e.text=1:1===s?e.text="10":s>1?e.text="10"+s+"":e.text="10\u2212"+-s+"",e.fontSize*=1.25}else e.text=h(Math.pow(10,o),t,"","fakehover"),"D1"===a&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==a.charAt(0))throw"unrecognized dtick "+String(a);e.text=String(Math.round(Math.pow(10,m(o,1)))),e.fontSize*=.75}if("D1"===t.dtick){var l=String(e.text).charAt(0);"0"!==l&&"1"!==l||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(0>o?.5:.25)))}}function u(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r=""),e.text=String(r)}function f(t,e,r,n,i){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide"),e.text=h(e.x,t,i,n)}function h(t,e,r,n){var i=0>t,o=e._tickround,s=r||e.exponentformat||"B",l=e._tickexponent,c=e.tickformat;if(n){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:b(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};a(u),o=(Number(u._tickround)||0)+4,l=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return y.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-o)/2;if("none"===s&&(l=0),t=Math.abs(t),f>t)t="0",i=!1;else{if(t+=f,l&&(t*=Math.pow(10,-l),o+=l),0===o)t=String(Math.floor(t));else if(0>o){t=String(Math.round(t)),t=t.substr(0,t.length+o);for(var h=o;0>h;h++)t+="0"}else{t=String(t);var d=t.indexOf(".")+1;d&&(t=t.substr(0,d+o).replace(/\.?0+$/,""))}t=_.numSeparate(t,e._gd._fullLayout.separators)}if(l&&"hide"!==s){var p;p=0>l?"\u2212"+-l:"power"!==s?"+"+l:String(l),"e"===s||("SI"===s||"B"===s)&&(l>12||-15>l)?t+="e"+p:"E"===s?t+="E"+p:"power"===s?t+="×10"+p+"":"B"===s&&9===l?t+="B":"SI"!==s&&"B"!==s||(t+=V[l/3+5])}return i?"\u2212"+t:t}function d(t,e){var r,n,i=[];for(r=0;r1)for(n=1;n2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.getAutoRange=function(t){var e,r=[],n=t._min[0].val,i=t._max[0].val;for(e=1;e0&&u>0&&f/u>h&&(l=o,c=s,h=f/u);return n===i?r=d?[n+1,"normal"!==t.rangemode?0:n-1]:["normal"!==t.rangemode?0:n-1,n+1]:h&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode&&l.val>=0?l={val:0,pad:0}:"nonnegative"===t.rangemode&&(l.val-h*l.pad<0&&(l={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),h=(c.val-l.val)/(t._length-l.pad-c.pad)),r=[l.val-h*l.pad,c.val+h*c.pad],r[0]===r[1]&&(r=[r[0]-1,r[0]+1]),d&&r.reverse()),r},T.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=T.getAutoRange(t);var r=t._gd.layout[t._name];r||(t._gd.layout[t._name]=r={}),r!==t&&(r.range=t.range.slice(),r.autorange=t.autorange)}},T.saveRangeInitial=function(t,e){for(var r=T.list(t,"",!0),n=!1,i=0;ip&&(p=g/10),c=t.c2l(p),u=t.c2l(g),y&&(c=Math.min(0,c),u=Math.max(0,u)),n(c)){for(d=!0,o=0;o=h?d=!1:s.val>=c&&s.pad<=h&&(t._min.splice(o,1),o--);d&&t._min.push({val:c,pad:y&&0===c?0:h})}if(n(u)){for(d=!0,o=0;o=u&&s.pad>=f?d=!1:s.val<=u&&s.pad<=f&&(t._max.splice(o,1),o--);d&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),r||(r={}),t._m||t.setScale();var a,o,s,l,c,u,f,h,d,p,g,v=e.length,m=r.padded?.05*t._length:0,y=r.tozero&&("linear"===t.type||"-"===t.type),x=n((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),_=n((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),w=n(r.vpadplus||r.vpad),k=n(r.vpadminus||r.vpad);for(a=0;6>a;a++)i(a);for(a=v-1;a>5;a--)i(a)}},T.autoBin=function(t,e,r,n){function i(t){return(1+100*(t-d)/f.dtick)%100<2}var a=_.aggNums(Math.min,null,t),o=_.aggNums(Math.max,null,t);if("category"===e.type)return{start:a-.5,end:o+.5,size:1};var s;if(r)s=(o-a)/r;else{var l=_.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(l.minDiff)/Math.LN10)),u=c*_.roundUp(l.minDiff/c,[.9,1.9,4.9,9.9],!0);s=Math.max(u,2*_.stdev(t)/Math.pow(t.length,n?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[a,o]};T.autoTicks(f,s);var h,d=T.tickIncrement(T.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;yg&&(p>.3*x||i(a)||i(o))){var w=f.dtick/2;d+=a>d+w?w:-w}var k=1+Math.floor((o-d)/f.dtick);h=d+k*f.dtick}else for(h=d;o>=h;)h=T.tickIncrement(h,f.dtick);return{start:d,end:h,size:f.dtick}},T.calcTicks=function(t){if("array"===t.tickmode)return n(t);if("auto"===t.tickmode||!t.dtick){var e,r=t.nticks;r||("category"===t.type?(e=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/e):(e="y"===t._id.charAt(0)?40:80,r=_.constrain(t._length/e,4,9)+1)),T.autoTicks(t,Math.abs(t.range[1]-t.range[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),a(t),t._tmin=T.tickFirst(t);var i=t.range[1]=s:s>=l)&&(o.push(l),!(o.length>1e3));l=T.tickIncrement(l,t.dtick,i));t._tmax=o[o.length-1];for(var c=new Array(o.length),u=0;u157788e5?(e/=315576e5,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*i(e,r,S)):e>12096e5?(e/=26298e5,t.dtick="M"+i(e,1,C)):e>432e5?(t.dtick=i(e,864e5,P),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=i(e,36e5,C):e>3e4?t.dtick=i(e,6e4,z):e>500?t.dtick=i(e,1e3,z):(r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,S));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var n=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/n,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+i(e,r,S)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,S));if(0===t.dtick&&(t.dtick=1),!b(t.dtick)&&"string"!=typeof t.dtick){var a=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(a)}},T.tickIncrement=function(t,e,r){var n=r?-1:1;if(b(e))return t+n*e;var i=e.charAt(0),a=n*Number(e.substr(1));if("M"===i){var o=new Date(t);return o.setMonth(o.getMonth()+a)}if("L"===i)return Math.log(Math.pow(10,t)+a)/Math.LN10;if("D"===i){var s="D2"===e?O:R,l=t+.01*n,c=_.roundUp(m(l,1),s,r);return Math.floor(l)+Math.log(y.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.range[1]n:n>c;)c=T.tickIncrement(c,i,e);return c}if("L"===u)return Math.log(r((Math.pow(10,n)-a)/f)*f+a)/Math.LN10;if("D"===u){var h="D2"===i?O:R,d=_.roundUp(m(n,1),h,e);return Math.floor(n)+Math.log(y.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(i)};var I=y.time.format("%Y"),N=y.time.format("%b %Y"),j=y.time.format("%b %-d"),F=y.time.format("%b %-d %Hh"),D=y.time.format("%H:%M"),B=y.time.format(":%S"),U=/%(\d?)f/g;T.tickText=function(t,e,r){function n(n){var i;return void 0===n?!0:r?"none"===n:(i={first:t._tmin,last:t._tmax}[n],"all"!==n&&e!==i)}var i,a,o=s(t,e),h="array"===t.tickmode,d=r||h;if(h&&Array.isArray(t.ticktext)){var p=Math.abs(t.range[1]-t.range[0])/1e4;for(a=0;a1&&er&&(A=90),i(u,A)}c._lastangle=A}return o(e),e+" done"}function l(){c._boundingBox=r.node().getBoundingClientRect()}var u=r.selectAll("g."+C).data(L,S);if(!c.showticklabels||!b(n))return u.remove(),void o(e);var f,h,p,m,x;"x"===v?(x="bottom"===B?1:-1,f=function(t){return t.dx+I*x},m=n+(O+R)*x,h=function(t){return t.dy+m+t.fontSize*("bottom"===B?1:-.5)},p=function(t){return b(t)&&0!==t&&180!==t?0>t*x?"end":"start":"middle"}):(x="right"===B?1:-1,h=function(t){return t.dy+t.fontSize/2-I*x},f=function(t){return t.dx+n+(O+R+(90===Math.abs(c.tickangle)?t.fontSize/2:0))*x},p=function(t){return b(t)&&90===Math.abs(t)?"middle":"right"===B?"start":"end"});var k=0,A=0,T=[];u.enter().append("g").classed(C,1).append("text").attr("text-anchor","middle").each(function(e){var r=y.select(this),n=t._promises.length;r.call(M.setPosition,f(e),h(e)).call(M.font,e.font,e.fontSize,e.fontColor).text(e.text).call(w.convertToTspans),n=t._promises[n],n?T.push(t._promises.pop().then(function(){i(r,c.tickangle)})):i(r,c.tickangle)}),u.exit().remove(),u.each(function(t){k=Math.max(k,t.fontSize)}),i(u,c._lastangle||c.tickangle);var E=_.syncOrAsync([a,s,l]);return E&&E.then&&t._promises.push(E),E}function o(e){if(!r){var n,i,a,o,s=E.getFromId(t,e),l=y.select(t).selectAll("g."+e+"tick"),c={selection:l,side:s.side},f=e.charAt(0),h=t._fullLayout._size,d=1.5,p=s.titlefont.size;if(l.size()){var g=y.select(l.node().parentNode).attr("transform").match(/translate\(([-\.\d]+),([-\.\d]+)\)/);g&&(c.offsetLeft=+g[1],c.offsetTop=+g[2])}"x"===f?(i="free"===s.anchor?{_offset:h.t+(1-(s.position||0))*h.h,_length:0}:E.getFromId(t,s.anchor),a=s._offset+s._length/2,o=i._offset+("top"===s.side?-10-p*(d+(s.showticklabels?1:0)):i._length+10+p*(d+(s.showticklabels?1.5:.5))),s.rangeslider&&s.rangeslider.visible&&s._boundingBox&&(o+=(u.height-u.margin.b-u.margin.t)*s.rangeslider.thickness+s._boundingBox.height),c.side||(c.side="bottom")):(i="free"===s.anchor?{_offset:h.l+(s.position||0)*h.w,_length:0}:E.getFromId(t,s.anchor),o=s._offset+s._length/2,a=i._offset+("right"===s.side?i._length+10+p*(d+(s.showticklabels?1:.5)):-10-p*(d+(s.showticklabels?.5:0))),n={rotate:"-90",offset:0},c.side||(c.side="left")),k.draw(t,e+"title",{propContainer:s,propName:s._name+".title",dfltName:f.toUpperCase()+" axis",avoid:c,transform:n,attributes:{x:a,y:o,"text-anchor":"middle"}})}}function s(t,e){return t.visible!==!0||t.xaxis+t.yaxis!==e?!1:x.Plots.traceIs(t,"bar")&&t.orientation==={x:"h",y:"v"}[v]?!0:t.fill&&t.fill.charAt(t.fill.length-1)===v}function l(e,r,i){var a=e.gridlayer,o=e.zerolinelayer,l=e["hidegrid"+v]?[]:V,u=c._gridpath||"M0,0"+("x"===v?"v":"h")+r._length,f=a.selectAll("path."+z).data(c.showgrid===!1?[]:l,S);if(f.enter().append("path").classed(z,1).classed("crisp",1).attr("d",u).each(function(t){c.zeroline&&("linear"===c.type||"-"===c.type)&&Math.abs(t.x)g;g++){var y=c.mirrors[o._id+h[g]];"ticks"!==y&&"labels"!==y||(f[g]=!0)}return void 0!==n[2]&&(f[2]=!0),f.forEach(function(t,e){var r=n[e],i=U[e];t&&b(r)&&(d+=p(r+R*i,i*c.ticklen))}),i(r,d),l(e,o,t),a(r,n[3])}}).filter(function(t){return t&&t.then});return H.length?Promise.all(H):0},T.swap=function(t,e){for(var r=d(t,e),n=0;n2*n}function u(t){for(var e,r=Math.max(1,(t.length-1)/1e3),n=0,i=0,a=0;a2*n}var f=t("fast-isnumeric"),h=t("tinycolor2").mix,d=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),b=t("./tick_label_defaults"),x=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),A=t("./axis_ids");e.exports=function(t,e,r,i){function a(r,n){return d.coerce2(t,e,v,r,n)}var o=i.letter,s=i.font||{},l="Click to enter "+(i.title||o.toUpperCase()+" axis")+" title";i.name&&(e._name=i.name,e._id=A.name2id(i.name));var c=r("type");"-"===c&&(n(e,i.data),"-"===e.type?e.type="linear":c=t.type=e.type),_(e);var u=r("color"),p=u===t.color?u:s.color;r("title",l),d.coerceFont(r,"titlefont",{family:s.family,size:Math.round(1.2*s.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),M=r("autorange",!k);M&&r("rangemode");var T=r("range",[-1,"x"===o?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),d.noneOrAll(t.range,e.range,[0,1]),r("fixedrange"),m(t,e,r,c),b(t,e,r,c,i),y(t,e,r,i),x(t,e,r);var E=a("linecolor",u),L=a("linewidth"),S=r("showline",!!E||!!L);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&r("mirror");var C=a("gridcolor",h(u,i.bgColor,g).toRgbString()),z=a("gridwidth"),P=r("showgrid",i.showGrid||!!C||!!z);P||(delete e.gridcolor,delete e.gridwidth);var R=a("zerolinecolor",u),O=a("zerolinewidth"),I=r("zeroline",i.showGrid||!!R||!!O);return I||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===c?w(o,e.categoryorder,e.categoryarray,i.data):[],e}},{"../../components/color/attributes":302,"../../lib":382,"../plots":454,"./axis_ids":407,"./category_order_defaults":408,"./clean_datum":409,"./layout_attributes":414,"./ordered_categories":416,"./set_convert":419,"./tick_label_defaults":420,"./tick_mark_defaults":421,"./tick_value_defaults":422,"fast-isnumeric":117,tinycolor2:274}],407:[function(t,e,r){"use strict";function n(t,e,r){function n(t,r){for(var n=Object.keys(t),i=/^[xyz]axis[0-9]*/,a=[],o=0;o0;a&&(n="array");var o=r("categoryorder",n);"array"===o&&r("categoryarray"),a||"array"!==o||(e.categoryorder="trace")}}},{}],409:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return i.ms2DateTime(t);if("string"!=typeof t&&!n(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){i.error(e,t)}return t}},{"../../lib":382,"fast-isnumeric":117}],410:[function(t,e,r){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5,REDRAWDELAY:50}},{}],411:[function(t,e,r){"use strict";function n(t,e){var r,n=t.range[e],i=Math.abs(n-t.range[1-e]);return"date"===t.type?c.ms2DateTime(n,i):"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,o.format("."+r+"g")(Math.pow(10,n))):(r=Math.floor(Math.log(Math.abs(n))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,o.format("."+String(r)+"g")(n))}function i(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function a(t){o.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var o=t("d3"),s=t("tinycolor2"),l=t("../../plotly"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../components/color"),h=t("../../components/drawing"),d=t("../../lib/setcursor"),p=t("../../components/dragelement"),g=t("./axes"),v=t("./select"),m=t("./constants"),y=!0;e.exports=function(t,e,r,o,b,x,_,w){function k(t,e){for(var r=0;r.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+ht+", "+dt+")").attr("d",ot+"Z"),ut=ft.append("path").attr("class","zoombox-corners").style({fill:f.background,stroke:f.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+ht+", "+dt+")").attr("d","M0,0Z"),T();for(var a=0;ai?(lt="",it.r=it.l,it.t=it.b,ut.attr("d","M0,0Z")):(it.t=0,it.b=V,lt="x",ut.attr("d","M"+(it.l-.5)+","+(nt-H-.5)+"h-3v"+(2*H+1)+"h3ZM"+(it.r+.5)+","+(nt-H-.5)+"h3v"+(2*H+1)+"h-3Z")):!Z||i.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),ut.transition().style("opacity",1).duration(200),st=!0)}function L(t,e,r){var n,i,a;for(n=0;nzoom back out","long"),y=!1)))}function C(e,r){var i=1===(_+w).length;if(e)I();else if(2!==r||i){if(1===r&&i){var a=_?B[0]:D[0],o="s"===_||"w"===w?0:1,s=a._name+".range["+o+"]",c=n(a,o),f="left",h="middle";if(a.fixedrange)return;_?(h="n"===_?"top":"bottom","right"===a.side&&(f="right")):"e"===w&&(f="right"),J.call(u.makeEditable,null,{immediate:!0,background:j.paper_bgcolor,text:String(c),fill:a.tickfont?a.tickfont.color:"#444",horizontalAlign:f,verticalAlign:h}).on("edit",function(e){var r="category"===a.type?a.c2l(e):a.d2l(e);void 0!==r&&l.relayout(t,s,r)})}}else O()}function z(e){function r(t,e,r){if(!t.fixedrange){A(t.range);var n=t.range,i=n[0]+(n[1]-n[0])*e;t.range=[i+(n[0]-i)*r,i+(n[1]-i)*r]}}if(t._context.scrollZoom||j._enablescrollzoom){var n=t.querySelector(".plotly");if(!(n.scrollHeight-n.clientHeight>10||n.scrollWidth-n.clientWidth>10)){clearTimeout(gt);var i=-e.deltaY;if(isFinite(i)||(i=e.wheelDelta/10),!isFinite(i))return void c.log("Did not find wheel motion attributes: ",e);var a,o=Math.exp(-Math.min(Math.max(i,-20),20)/100),s=mt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-s.left)/s.width,u=pt[0]+pt[2]*l,f=(s.bottom-e.clientY)/s.height,h=pt[1]+pt[3]*(1-f);if(w){for(a=0;a=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function i(t,e,r){for(var i=1-e,a=0,o=0;o0;n--)r.push(e);return r}function i(t,e){for(var r=[],n=0;nT;T++){var E=a[T],L=d[E];if(L)A[T]=w.getFromId(t,L.xaxis._id),M[T]=w.getFromId(t,L.yaxis._id);else{var S=o[E]._subplot;A[T]=S.xaxis,M[T]=S.yaxis}}var C=e.hovermode||o.hovermode;if(-1===["x","y","closest"].indexOf(C)||!t.calcdata||t.querySelector(".zoombox")||t._dragging)return _.unhoverRaw(t,e);var z,P,R,O,I,N,j,F,D,B,U,V,q=[],H=[];if(Array.isArray(e))for(C="array",R=0;RG||G>X.width||0>Y||Y>X.height)return _.unhoverRaw(t,e)}else G="xpx"in e?e.xpx:A[0]._length/2,Y="ypx"in e?e.ypx:M[0]._length/2;if(z="xval"in e?n(a,e.xval):i(A,G),P="yval"in e?n(a,e.yval):i(M,Y),!g(z[0])||!g(P[0]))return v.warn("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var W=1/0;for(O=0;O1||-1!==N.hoverinfo.indexOf("name")?N.name:void 0,index:!1,distance:Math.min(W,k.MAXDIST),color:b.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},V=q.length,"array"===F){var Z=e[O];"pointNumber"in Z?(U.index=Z.pointNumber,F="closest"):(F="","xval"in Z&&(D=Z.xval,F="x"),"yval"in Z&&(B=Z.yval,F=F?"closest":"y"))}else D=z[j],B=P[j];if(N._module&&N._module.hoverPoints){var K=N._module.hoverPoints(U,D,B,F);if(K)for(var $,Q=0;QV&&(q.splice(0,V),W=q[0].distance)}if(0===q.length)return _.unhoverRaw(t,e);var J="y"===C&&H.length>1;q.sort(function(t,e){return t.distance-e.distance});var tt=b.combine(o.plot_bgcolor||b.background,o.paper_bgcolor),et={hovermode:C,rotateLabels:J,bgColor:tt,container:o._hoverlayer,outerContainer:o._paperdiv},rt=c(q,et);u(q,J?"xa":"ya"),f(rt,J);var nt=t._hoverdata,it=[];for(R=0;R128?"#000":b.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,r=u.textContent||"",r.length>15&&(r=r.substr(0,12)+"...")}void 0!==t.extraText&&(n+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(n+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(n+="y: "+t.yLabel+"
"),n+=(n?"z: ":"")+t.zLabel):M&&t[i+"Label"]===g?n=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(n=t.yLabel):n=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(n+=(n?"
":"")+t.text),""===n&&(""===r&&e.remove(),n=r);var f=e.select("text.nums").style("fill",c).call(x.setPosition,0,0).text(n).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(x.setPosition,0,0);var h=e.select("text.name"),v=0;r&&r!==n?(h.style("fill",l).text(r).call(x.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),h.selectAll("tspan.line").call(x.setPosition,0,0),v=h.node().getBoundingClientRect().width+2*P):(h.remove(),e.select("rect").remove()),e.select("path").style({fill:l,stroke:c});var m,k,E=f.node().getBoundingClientRect(),L=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),R=Math.abs(t.y1-t.y0),O=E.width+z+P+v;t.ty0=_-E.top,t.bx=E.width+2*P,t.by=E.height+2*P,t.anchor="start",t.txwidth=E.width,t.tx2width=v,t.offset=0,a?(t.pos=L,m=A>=S+R/2+O,k=S-R/2-O>=0,"top"!==t.idealAlign&&m||!k?m?(S+=R/2,t.anchor="start"):t.anchor="middle":(S-=R/2,t.anchor="end")):(t.pos=S,m=w>=L+C/2+O,k=L-C/2-O>=0,"left"!==t.idealAlign&&m||!k?m?(L+=C/2,t.anchor="start"):t.anchor="middle":(L-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&h.attr("text-anchor",t.anchor),e.attr("transform","translate("+L+","+S+")"+(a?"rotate("+T+")":""))}),S}function u(t,e){function r(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(.01>a)){if(-.01>i){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var c=0;for(o=0;oe.pmax&&c++;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos>e.pmax-1&&(l.del=!0,c--);for(o=0;o=c);o++)if(l=t[o],l.pos=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(0>=c);o--)l=t[o],l.pos+l.dp+l.size>e.pmax&&(l.del=!0,c--)}}}for(var n,i,a,o,s,l,c,u=0,f=t.map(function(t,r){var n=t[e];return[{i:r,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===n._id.charAt(0)?L:1)/2,pmin:n._offset,pmax:n._offset+n._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!n&&u<=t.length;){for(u++,n=!0,o=0;o.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(s=d.length-1;s>=0;s--)d[s].dp+=i;for(h.push.apply(h,d),f.splice(o+1,1),c=0,s=h.length-1;s>=0;s--)c+=h[s].dp;for(a=c/h.length,s=h.length-1;s>=0;s--)h[s].dp-=a;n=!1}else o++}f.forEach(r)}for(o=f.length-1;o>=0;o--){var v=f[o];for(s=v.length-1;s>=0;s--){var m=v[s],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var r=d.select(this);if(t.del)return void r.remove();var n="end"===t.anchor?-1:1,i=r.select("text.nums"),a={start:1,end:-1,middle:0}[t.anchor],o=a*(z+P),s=o+a*(t.txwidth+P),l=0,c=t.offset;"middle"===t.anchor&&(o-=t.tx2width/2,s-=t.tx2width/2),e&&(c*=-C,l=t.offset*S),r.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(n*z+l)+","+(z+c)+"v"+(t.by/2-z)+"h"+n*t.bx+"v-"+t.by+"H"+(n*z+l)+"V"+(c-z)+"Z"),i.call(x.setPosition,o+l,c+t.ty0-t.by/2+P).selectAll("tspan.line").attr({x:i.attr("x"),y:i.attr("y")}),t.tx2width&&(r.select("text.name, text.name tspan.line").call(x.setPosition,s+a*P+l,c+t.ty0-t.by/2+P),r.select("rect").call(x.setRect,s+(a-1)*t.tx2width/2+l,c-t.by/2-1,t.tx2width,t.by+2))})}function h(t,e,r){if(!e.target)return!1;if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}var d=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),b=t("../../components/color"),x=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),A=t("./dragbox"),M=e.exports={};M.unhover=_.unhover,M.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},M.supplyLayoutDefaults=function(t,e,r){function n(r,n){return v.coerce(t,e,M.layoutAttributes,r,n)}n("dragmode");var i;if(e._has("cartesian")){var a=e._isHoriz=M.isHoriz(r);i=a?"y":"x"}else i="closest";n("hovermode",i)},M.isHoriz=function(t){for(var e=!0,r=0;rt._lastHoverTime+k.HOVERMINTIME?(o(t,e,r),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){o(t,e,r),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},M.getDistanceFunction=function(t,e,r,n){return"closest"===t?n||a(e,r):"x"===t?e:r},M.getClosest=function(t,e,r){if(r.index!==!1)r.index>=0&&r.indext*e||0===t?k.MAXDIST*(.6-.3/Math.max(3,Math.abs(t-e))):1/0}},{"../../components/color":303,"../../components/dragelement":324,"../../components/drawing":326,"../../lib":382,"../../lib/events":376,"../../lib/svg_text_utils":395,"./axes":405,"./constants":410,"./dragbox":411,d3:113,"fast-isnumeric":117,tinycolor2:274}],413:[function(t,e,r){"use strict";var n=t("../plots"),i=t("./constants");r.name="cartesian",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex=i.idRegex,r.attrRegex=i.attrRegex,r.attributes=t("./attributes"),r.plot=function(t){function e(t,e){for(var r=[],n=0;nf[1]-.01&&(e.domain=[0,1]),i.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":382,"fast-isnumeric":117}],418:[function(t,e,r){"use strict";function n(t){return t._id}var i=t("../../lib/polygon"),a=t("../../components/color"),o=t("./axes"),s=t("./constants"),l=i.filter,c=i.tester,u=s.MINSELECT;e.exports=function(t,e,r,i,f){function h(t){var e="y"===t._id.charAt(0)?1:0;return function(r){return t.p2d(r[e])}}function d(t,e){return t-e}var p,g=i.gd._fullLayout._zoomlayer,v=i.element.getBoundingClientRect(),m=i.plotinfo.x()._offset,y=i.plotinfo.y()._offset,b=e-v.left,x=r-v.top,_=b,w=x,k="M"+b+","+x,A=i.xaxes[0]._length,M=i.yaxes[0]._length,T=i.xaxes.map(n),E=i.yaxes.map(n),L=i.xaxes.concat(i.yaxes);"lasso"===f&&(p=l([[b,x]],s.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",k+"Z");var C,z,P,R,O,I=g.append("path").attr("class","zoombox-corners").style({fill:a.background,stroke:a.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),N=[],j=i.gd,F=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(0>=e&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-3*u*Math.abs(n-i))}return o.BADNUM}function r(t){return Math.pow(10,t)}function c(t){return i(t)?Number(t):o.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?r:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,r=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var n=l.getFromId(t._gd,t.overlaying);t.domain=n.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;2>e;e++)i(t.range[e])||(t.range[e]=i(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=r.t+(1-t.domain[1])*r.h,t._length=r.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=r.l+t.domain[0]*r.w,t._length=r.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw a.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return i(e)?n.round(t._b+t._m*e,2):o.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,r){return t.l2p(t.c2l(e,r))},t.p2c=function(e){return t.l2c(t.p2l(e))},-1!==["linear","log","-"].indexOf(t.type))t.c2d=c,t.d2c=function(t){return t=s(t),i(t)?Number(t):o.BADNUM},t.d2l=function(e,r){return"log"===t.type?t.c2l(t.d2c(e),r):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return i(t)?a.ms2DateTime(t):o.BADNUM},t.d2c=function(t){return i(t)?Number(t):a.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(a.dateTime2ms);!i(t.range[0])&&i(f[0])&&(t.range[0]=f[0]),!i(t.range[1])&&i(f[1])&&(t.range[1]=f[1])}catch(h){a.error(h,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&-1===t._categories.indexOf(e)&&t._categories.push(e);var r=t._categories.indexOf(e);return-1===r?o.BADNUM:r},t.d2l=t.d2c);t.makeCalcdata=function(e,r){var n,i,a;if(r in e)for(n=e[r],i=new Array(n.length),a=0;an?"0":"1.0"}var r=this.framework,n=r.select("g.choroplethlayer"),i=r.select("g.scattergeolayer"),a=this.projection,o=this.path,s=this.clipAngle;r.selectAll("path.basepath").attr("d",o),r.selectAll("path.graticulepath").attr("d",o),n.selectAll("path.choroplethlocation").attr("d",o),n.selectAll("path.basepath").attr("d",o),i.selectAll("path.js-line").attr("d",o),null!==s?(i.selectAll("path.point").style("opacity",e).attr("transform",t),i.selectAll("text").style("opacity",e).attr("transform",t)):(i.selectAll("path.point").attr("transform",t),i.selectAll("text").attr("transform",t))}},{"../../components/color":303,"../../components/drawing":326,"../../constants/xmlns_namespaces":370,"../../lib/filter_visible":378,"../../lib/topojson_utils":396,"../../plots/cartesian/axes":405,"./constants":424,"./projections":432,"./set_scale":433,"./zoom":434,"./zoom_reset":435,d3:113,topojson:275}],426:[function(t,e,r){"use strict";var n=t("./geo"),i=t("../../plots/plots");r.name="geo",r.attr="geo",r.idRoot="geo",r.idRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^geo([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"geo");void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var o=0;o=n}function a(t,e){for(var r=e[0],n=e[1],i=!1,a=0,o=t.length,s=o-1;o>a;s=a++){var l=t[a],c=l[0],u=l[1],f=t[s],h=f[0],d=f[1];u>n^d>n&&(h-c)*(n-u)/(d-u)+c>r&&(i=!i)}return i}function o(t){return t?t/Math.sin(t):1}function s(t){return t>1?P:-1>t?-P:Math.asin(t)}function l(t){return t>1?0:-1>t?z:Math.acos(t)}function c(t,e){var r=(2+P)*Math.sin(e);e/=2;for(var n=0,i=1/0;10>n&&Math.abs(i)>S;n++){var a=Math.cos(e);e-=i=(e+Math.sin(e)*(a+2)-r)/(2*a*(1+a))}return[2/Math.sqrt(z*(4+z))*t*(1+Math.cos(e)),2*Math.sqrt(z/(4+z))*Math.sin(e)]}function u(t,e){function r(r,n){var i=j(r/e,n);return i[0]*=t,i}return arguments.length<2&&(e=t),1===e?j:e===1/0?h:(r.invert=function(r,n){var i=j.invert(r/t,n);return i[0]*=e,i},r)}function f(){var t=2,e=N(u),r=e(t);return r.coefficient=function(r){return arguments.length?e(t=+r):t},r}function h(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function d(t,e){return[3*t/(2*z)*Math.sqrt(z*z/3-e*e),e]}function p(t,e){return[t,1.25*Math.log(Math.tan(z/4+.4*e))]}function g(t){return function(e){var r,n=t*Math.sin(e),i=30;do e-=r=(e+Math.sin(e)-n)/(1+Math.cos(e));while(Math.abs(r)>S&&--i>0);return e/2}}function v(t,e,r){function n(r,n){return[t*r*Math.cos(n=i(n)),e*Math.sin(n)]}var i=g(r);return n.invert=function(n,i){var a=s(i/e);return[n/(t*Math.cos(a)),s((2*a+Math.sin(2*a))/r)]},n}function m(t,e){var r=e*e,n=r*r;return[t*(.8707-.131979*r+n*(-.013791+n*(.003971*r-.001529*n))),e*(1.007226+r*(.015085+n*(-.044475+.028874*r-.005916*n)))]}function y(t,e){var r,n=Math.min(18,36*Math.abs(e)/z),i=Math.floor(n),a=n-i,o=(r=D[i])[0],s=r[1],l=(r=D[++i])[0],c=r[1],u=(r=D[Math.min(19,++i)])[0],f=r[1];return[t*(l+a*(u-o)/2+a*a*(u-2*l+o)/2),(e>0?P:-P)*(c+a*(f-s)/2+a*a*(f-2*c+s)/2)]}function b(t,e){return[t*Math.cos(e),e]}function x(t,e){var r=Math.cos(e),n=o(l(r*Math.cos(t/=2)));return[2*r*Math.sin(t)*n,Math.sin(e)*n]}function _(t,e){var r=x(t,e);return[(r[0]+t/P)/2,(r[1]+e)/2]}t.geo.project=function(t,e){var n=e.stream;if(!n)throw new Error("not yet supported");return(t&&w.hasOwnProperty(t.type)?w[t.type]:r)(t,n)};var w={Feature:e,FeatureCollection:function(t,r){return{type:"FeatureCollection",features:t.features.map(function(t){ +return e(t,r)})}}},k=[],A=[],M={point:function(t,e){k.push([t,e])},result:function(){var t=k.length?k.length<2?{type:"Point",coordinates:k[0]}:{type:"MultiPoint",coordinates:k}:null;return k=[],t}},T={lineStart:n,point:function(t,e){k.push([t,e])},lineEnd:function(){k.length&&(A.push(k),k=[])},result:function(){var t=A.length?A.length<2?{type:"LineString",coordinates:A[0]}:{type:"MultiLineString",coordinates:A}:null;return A=[],t}},E={polygonStart:n,lineStart:n,point:function(t,e){k.push([t,e])},lineEnd:function(){var t=k.length;if(t){do k.push(k[0].slice());while(++t<4);A.push(k),k=[]}},polygonEnd:n,result:function(){if(!A.length)return null;var t=[],e=[];return A.forEach(function(r){i(r)?t.push([r]):e.push(r)}),e.forEach(function(e){var r=e[0];t.some(function(t){return a(t[0],r)?(t.push(e),!0):void 0})||t.push([e])}),A=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},L={Point:M,MultiPoint:M,LineString:T,MultiLineString:T,Polygon:E,MultiPolygon:E,Sphere:E},S=1e-6,C=S*S,z=Math.PI,P=z/2,R=(Math.sqrt(z),z/180),O=180/z,I=t.geo.projection,N=t.geo.projectionMutator;t.geo.interrupt=function(e){function r(t,r){for(var n=0>r?-1:1,i=l[+(0>r)],a=0,o=i.length-1;o>a&&t>i[a][2][0];++a);var s=e(t-i[a][1][0],r);return s[0]+=e(i[a][1][0],n*r>n*i[a][0][1]?i[a][0][1]:r)[0],s}function n(){s=l.map(function(t){return t.map(function(t){var r,n=e(t[0][0],t[0][1])[0],i=e(t[2][0],t[2][1])[0],a=e(t[1][0],t[0][1])[1],o=e(t[1][0],t[1][1])[1];return a>o&&(r=a,a=o,o=r),[[n,a],[i,o]]})})}function i(){for(var e=1e-6,r=[],n=0,i=l[0].length;i>n;++n){var o=l[0][n],s=180*o[0][0]/z,c=180*o[0][1]/z,u=180*o[1][1]/z,f=180*o[2][0]/z,h=180*o[2][1]/z;r.push(a([[s+e,c+e],[s+e,u-e],[f-e,u-e],[f-e,h+e]],30))}for(var n=l[1].length-1;n>=0;--n){var o=l[1][n],s=180*o[0][0]/z,c=180*o[0][1]/z,u=180*o[1][1]/z,f=180*o[2][0]/z,h=180*o[2][1]/z;r.push(a([[f-e,h-e],[f-e,u+e],[s+e,u+e],[s+e,c-e]],30))}return{type:"Polygon",coordinates:[t.merge(r)]}}function a(t,e){for(var r,n,i,a=-1,o=t.length,s=t[0],l=[];++ac;++c)l.push([s[0]+c*n,s[1]+c*i]);s=r}return l.push(r),l}function o(t,e){return Math.abs(t[0]-e[0])n)],a=l[+(0>n)],c=0,u=i.length;u>c;++c){var f=i[c];if(f[0][0]<=t&&tS&&--i>0);return[t/(.8707+(a=n*n)*(-.131979+a*(-.013791+a*a*a*(.003971-.001529*a)))),n]},(t.geo.naturalEarth=function(){return I(m)}).raw=m;var D=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];D.forEach(function(t){t[1]*=1.0144}),y.invert=function(t,e){var r=e/P,n=90*r,i=Math.min(18,Math.abs(n/5)),a=Math.max(0,Math.floor(i));do{var o=D[a][1],s=D[a+1][1],l=D[Math.min(19,a+2)][1],c=l-o,u=l-2*s+o,f=2*(Math.abs(r)-s)/c,h=u/c,d=f*(1-h*f*(1-2*h*f));if(d>=0||1===a){n=(e>=0?5:-5)*(d+i);var p,g=50;do i=Math.min(18,Math.abs(n)/5),a=Math.floor(i),d=i-a,o=D[a][1],s=D[a+1][1],l=D[Math.min(19,a+2)][1],n-=(p=(e>=0?P:-P)*(s+d*(l-o)/2+d*d*(l-2*s+o)/2)-e)*O;while(Math.abs(p)>C&&--g>0);break}}while(--a>=0);var v=D[a][0],m=D[a+1][0],y=D[Math.min(19,a+2)][0];return[t/(m+d*(y-v)/2+d*d*(y-2*m+v)/2),n*R]},(t.geo.robinson=function(){return I(y)}).raw=y,b.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return I(b)}).raw=b,x.invert=function(t,e){if(!(t*t+4*e*e>z*z+S)){var r=t,n=e,i=25;do{var a,o=Math.sin(r),s=Math.sin(r/2),c=Math.cos(r/2),u=Math.sin(n),f=Math.cos(n),h=Math.sin(2*n),d=u*u,p=f*f,g=s*s,v=1-p*c*c,m=v?l(f*c)*Math.sqrt(a=1/v):a=0,y=2*m*f*s-t,b=m*u-e,x=a*(p*g+m*f*c*d),_=a*(.5*o*h-2*m*u*s),w=.25*a*(h*s-m*u*p*o),k=a*(d*c+m*g*f),A=_*w-k*x;if(!A)break;var M=(b*_-y*k)/A,T=(y*w-b*x)/A;r-=M,n-=T}while((Math.abs(M)>S||Math.abs(T)>S)&&--i>0);return[r,n]}},(t.geo.aitoff=function(){return I(x)}).raw=x,_.invert=function(t,e){var r=t,n=e,i=25;do{var a,o=Math.cos(n),s=Math.sin(n),c=Math.sin(2*n),u=s*s,f=o*o,h=Math.sin(r),d=Math.cos(r/2),p=Math.sin(r/2),g=p*p,v=1-f*d*d,m=v?l(o*d)*Math.sqrt(a=1/v):a=0,y=.5*(2*m*o*p+r/P)-t,b=.5*(m*s+n)-e,x=.5*a*(f*g+m*o*d*u)+.5/P,_=a*(h*c/4-m*s*p),w=.125*a*(c*p-m*s*f*h),k=.5*a*(u*d+m*g*o)+.5,A=_*w-k*x,M=(b*_-y*k)/A,T=(y*w-b*x)/A;r-=M,n-=T}while((Math.abs(M)>S||Math.abs(T)>S)&&--i>0);return[r,n]},(t.geo.winkel3=function(){return I(_)}).raw=_}e.exports=n},{}],433:[function(t,e,r){"use strict";function n(t,e){var r=t.projection,n=t.lonaxis,o=t.lataxis,l=t.domain,c=t.framewidth||0,u=e.w*(l.x[1]-l.x[0]),f=e.h*(l.y[1]-l.y[0]),h=n.range[0]+s,d=n.range[1]-s,p=o.range[0]+s,g=o.range[1]-s,v=n._fullRange[0]+s,m=n._fullRange[1]-s,y=o._fullRange[0]+s,b=o._fullRange[1]-s;r._translate0=[e.l+u/2,e.t+f/2];var x=d-h,_=g-p,w=[h+x/2,p+_/2],k=r._rotate;r._center=[w[0]+k[0],w[1]+k[1]];var A=function(e){function n(t){return Math.min(_*u/(t[1][0]-t[0][0]),_*f/(t[1][1]-t[0][1]))}var o,s,l,x,_=e.scale(),w=r._translate0,k=i(h,p,d,g),A=i(v,y,m,b);l=a(e,k),o=n(l),x=a(e,A),r._fullScale=n(x),e.scale(o),l=a(e,k),s=[w[0]-l[0][0]+c,w[1]-l[0][1]+c],r._translate=s,e.translate(s),l=a(e,k),t._isAlbersUsa||e.clipExtent(l),o=r.scale*o,r._scale=o,t._width=Math.round(l[1][0])+c,t._height=Math.round(l[1][1])+c,t._marginX=(u-Math.round(l[1][0]))/2,t._marginY=(f-Math.round(l[1][1]))/2};return A}function i(t,e,r,n){var i=(r-t)/4;return{type:"Polygon",coordinates:[[[t,e],[t,n],[t+i,n],[t+2*i,n],[t+3*i,n],[r,n],[r,e],[r-i,e],[r-2*i,e],[r-3*i,e],[t,e]]]}}function a(t,e){return o.geo.path().projection(t).bounds(e)}var o=t("d3"),s=t("./constants").clipPad;e.exports=n},{"./constants":424,d3:113}],434:[function(t,e,r){"use strict";function n(t,e){var r;return(r=e._isScoped?a:e._clipAngle?s:o)(t,e.projection)}function i(t,e){var r=e._fullScale;return _.behavior.zoom().translate(t.translate()).scale(t.scale()).scaleExtent([.5*r,100*r])}function a(t,e){function r(){_.select(this).style(A)}function n(){o.scale(_.event.scale).translate(_.event.translate),t.render()}function a(){_.select(this).style(M)}var o=t.projection,s=i(o,e);return s.on("zoomstart",r).on("zoom",n).on("zoomend",a),s}function o(t,e){function r(t){return v.invert(t)}function n(t){var e=v(r(t));return Math.abs(e[0]-t[0])>y||Math.abs(e[1]-t[1])>y}function a(){_.select(this).style(A),l=_.mouse(this),c=v.rotate(),u=v.translate(),f=c,h=r(l)}function o(){return d=_.mouse(this),n(l)?(m.scale(v.scale()),void m.translate(v.translate())):(v.scale(_.event.scale),v.translate([u[0],_.event.translate[1]]),h?r(d)&&(g=r(d),p=[f[0]+(g[0]-h[0]),c[1],c[2]],v.rotate(p),f=p):(l=d,h=r(l)),void t.render())}function s(){_.select(this).style(M)}var l,c,u,f,h,d,p,g,v=t.projection,m=i(v,e),y=2;return m.on("zoomstart",a).on("zoom",o).on("zoomend",s),m}function s(t,e){function r(t){m++||t({type:"zoomstart"})}function n(t){t({type:"zoom"})}function a(t){--m||t({type:"zoomend"})}var o,s=t.projection,d={r:s.rotate(),k:s.scale()},p=i(s,e),g=x(p,"zoomstart","zoom","zoomend"),m=0,y=p.on;return p.on("zoomstart",function(){_.select(this).style(A);var t=_.mouse(this),e=s.rotate(),i=e,a=s.translate(),m=c(e);o=l(s,t),y.call(p,"zoom",function(){var r=_.mouse(this);if(s.scale(d.k=_.event.scale),o){if(l(s,r)){s.rotate(e).translate(a);var c=l(s,r),p=f(o,c),y=v(u(m,p)),b=d.r=h(y,o,i);isFinite(b[0])&&isFinite(b[1])&&isFinite(b[2])||(b=i),s.rotate(b),i=b}}else t=r,o=l(s,t);n(g.of(this,arguments))}),r(g.of(this,arguments))}).on("zoomend",function(){_.select(this).style(M),y.call(p,"zoom",null),a(g.of(this,arguments))}).on("zoom.redraw",function(){t.render()}),_.rebind(p,g,"on")}function l(t,e){var r=t.invert(e);return r&&isFinite(r[0])&&isFinite(r[1])&&m(r)}function c(t){var e=.5*t[0]*w,r=.5*t[1]*w,n=.5*t[2]*w,i=Math.sin(e),a=Math.cos(e),o=Math.sin(r),s=Math.cos(r),l=Math.sin(n),c=Math.cos(n);return[a*s*c+i*o*l,i*s*c-a*o*l,a*o*c+i*s*l,a*s*l-i*o*c]}function u(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],o=e[0],s=e[1],l=e[2],c=e[3];return[r*o-n*s-i*l-a*c,r*s+n*o+i*c-a*l,r*l-n*c+i*o+a*s,r*c+n*l-i*s+a*o]}function f(t,e){if(t&&e){var r=b(t,e),n=Math.sqrt(y(r,r)),i=.5*Math.acos(Math.max(-1,Math.min(1,y(t,e)))),a=Math.sin(i)/n;return n&&[Math.cos(i),r[2]*a,-r[1]*a,r[0]*a]}}function h(t,e,r){var n=g(e,2,t[0]);n=g(n,1,t[1]),n=g(n,0,t[2]-r[2]);var i,a,o=e[0],s=e[1],l=e[2],c=n[0],u=n[1],f=n[2],h=Math.atan2(s,o)*k,p=Math.sqrt(o*o+s*s);Math.abs(u)>p?(a=(u>0?90:-90)-h,i=0):(a=Math.asin(u/p)*k-h,i=Math.sqrt(p*p-u*u));var v=180-a-2*h,m=(Math.atan2(f,c)-Math.atan2(l,i))*k,y=(Math.atan2(f,c)-Math.atan2(l,-i))*k,b=d(r[0],r[1],a,m),x=d(r[0],r[1],v,y);return x>=b?[a,m,r[2]]:[v,y,r[2]]}function d(t,e,r,n){var i=p(r-t),a=p(n-e);return Math.sqrt(i*i+a*a)}function p(t){return(t%360+540)%360-180}function g(t,e,r){var n=r*w,i=t.slice(),a=0===e?1:0,o=2===e?1:2,s=Math.cos(n),l=Math.sin(n);return i[a]=t[a]*s-t[o]*l,i[o]=t[o]*s+t[a]*l,i}function v(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*k,Math.asin(Math.max(-1,Math.min(1,2*(t[0]*t[2]-t[3]*t[1]))))*k,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*k]}function m(t){var e=t[0]*w,r=t[1]*w,n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function y(t,e){for(var r=0,n=0,i=t.length;i>n;++n)r+=t[n]*e[n];return r}function b(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function x(t){for(var e=0,r=arguments.length,n=[];++ed;++d){for(e=c[d],r=t[this.scene[e]._name],n=/Click to enter .+ title/.test(r.title)?"":r.title,p=0;2>=p;p+=2)this.labelEnable[d+p]=!1,this.labels[d+p]=o(n),this.labelColor[d+p]=s(r.titlefont.color),this.labelFont[d+p]=r.titlefont.family,this.labelSize[d+p]=r.titlefont.size,this.labelPad[d+p]=this.getLabelPad(e,r),this.tickEnable[d+p]=!1,this.tickColor[d+p]=s((r.tickfont||{}).color),this.tickAngle[d+p]="auto"===r.tickangle?0:Math.PI*-r.tickangle/180,this.tickPad[d+p]=this.getTickPad(r),this.tickMarkLength[d+p]=0,this.tickMarkWidth[d+p]=r.tickwidth||0,this.tickMarkColor[d+p]=s(r.tickcolor),this.borderLineEnable[d+p]=!1,this.borderLineColor[d+p]=s(r.linecolor),this.borderLineWidth[d+p]=r.linewidth||0;u=this.hasSharedAxis(r),a=this.hasAxisInDfltPos(e,r)&&!u,l=this.hasAxisInAltrPos(e,r)&&!u,i=r.mirror||!1,f=u?-1!==String(i).indexOf("all"):!!i,h=u?"allticks"===i:-1!==String(i).indexOf("ticks"),a?this.labelEnable[d]=!0:l&&(this.labelEnable[d+2]=!0),a?this.tickEnable[d]=r.showticklabels:l&&(this.tickEnable[d+2]=r.showticklabels),(a||f)&&(this.borderLineEnable[d]=r.showline),(l||f)&&(this.borderLineEnable[d+2]=r.showline),(a||h)&&(this.tickMarkLength[d]=this.getTickMarkLength(r)),(l||h)&&(this.tickMarkLength[d+2]=this.getTickMarkLength(r)),this.gridLineEnable[d]=r.showgrid,this.gridLineColor[d]=s(r.gridcolor),this.gridLineWidth[d]=r.gridwidth,this.zeroLineEnable[d]=r.zeroline,this.zeroLineColor[d]=s(r.zerolinecolor),this.zeroLineWidth[d]=r.zerolinewidth}},l.hasSharedAxis=function(t){var e=this.scene,r=a.Plots.getSubplotIds(e.fullLayout,"gl2d"),n=a.Axes.findSubplotsWithAxis(r,t);return 0!==n.indexOf(e.id)},l.hasAxisInDfltPos=function(t,e){var r=e.side;return"xaxis"===t?"bottom"===r:"yaxis"===t?"left"===r:void 0},l.hasAxisInAltrPos=function(t,e){var r=e.side;return"xaxis"===t?"top"===r:"yaxis"===t?"right"===r:void 0},l.getLabelPad=function(t,e){var r=1.5,n=e.titlefont.size,i=e.showticklabels;return"xaxis"===t?"top"===e.side?-10+n*(r+(i?1:0)):-10+n*(r+(i?.5:0)):"yaxis"===t?"right"===e.side?10+n*(r+(i?1:.5)):10+n*(r+(i?.5:0)):void 0},l.getTickPad=function(t){return"outside"===t.ticks?10+t.ticklen:15},l.getTickMarkLength=function(t){if(!t.ticks)return 0;var e=t.ticklen;return"inside"===t.ticks?-e:e},e.exports=i},{"../../lib/html2unicode":381,"../../lib/str2rgbarray":394,"../../plotly":402}],438:[function(t,e,r){"use strict";var n=t("./scene2d"),i=t("../plots"),a=t("../../constants/xmlns_namespaces");r.name="gl2d",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex={x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},r.attrRegex={x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},r.attributes=t("../cartesian/attributes"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"gl2d"),o=0;or;++r){var n=t[r],i=e[r];if(n.length!==i.length)return!0;for(var a=0;ao;++o,--s)for(var l=0;r>l;++l)for(var c=0;4>c;++c){var u=i[4*(r*o+l)+c];i[4*(r*o+l)+c]=i[4*(r*s+l)+c],i[4*(r*s+l)+c]=u}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticPlot&&this.container.removeChild(a),p},m.computeTickMarks=function(){this.xaxis._length=this.glplot.viewBox[2]-this.glplot.viewBox[0],this.yaxis._length=this.glplot.viewBox[3]-this.glplot.viewBox[1];for(var t=[s.calcTicks(this.xaxis),s.calcTicks(this.yaxis)],e=0;2>e;++e)for(var r=0;rk;++k)w[k]=Math.min(w[k],a.bounds[k]),w[k+2]=Math.max(w[k+2],a.bounds[k+2])}var A;for(n=0;2>n;++n)w[n]>w[n+2]&&(w[n]=-1,w[n+2]=1),A=this[v[n]],A._length=y.viewBox[n+2]-y.viewBox[n],s.doAutoRange(A);y.ticks=this.computeTickMarks();var M=this.xaxis.range,T=this.yaxis.range;y.dataBox=[M[0],T[0],M[1],T[1]],y.merge(r),o.update(y),this.glplot.draw()},m.draw=function(){if(!this.stopped){requestAnimationFrame(this.redraw);var t=this.glplot,e=this.camera,r=e.mouseListener,n=this.fullLayout;this.cameraChanged();var i=r.x*t.pixelRatio,a=this.canvas.height-t.pixelRatio*r.y;if(e.boxEnabled&&"zoom"===n.dragmode)this.selectBox.enabled=!0,this.selectBox.selectBox=[Math.min(e.boxStart[0],e.boxEnd[0]),Math.min(e.boxStart[1],e.boxEnd[1]),Math.max(e.boxStart[0],e.boxEnd[0]),Math.max(e.boxStart[1],e.boxEnd[1])],t.setDirty();else{this.selectBox.enabled=!1;var o=n._size,s=this.xaxis.domain,c=this.yaxis.domain,u=t.pick(i/t.pixelRatio+o.l+s[0]*o.w,a/t.pixelRatio-(o.t+(1-c[1])*o.h));if(u&&n.hovermode){var f=u.object._trace.handlePick(u);if(f&&(!this.lastPickResult||this.lastPickResult.trace!==f.trace||this.lastPickResult.dataCoord[0]!==f.dataCoord[0]||this.lastPickResult.dataCoord[1]!==f.dataCoord[1])){var h=this.lastPickResult=f;this.spikes.update({center:u.dataCoord}),h.screenCoord=[((t.viewBox[2]-t.viewBox[0])*(u.dataCoord[0]-t.dataBox[0])/(t.dataBox[2]-t.dataBox[0])+t.viewBox[0])/t.pixelRatio,(this.canvas.height-(t.viewBox[3]-t.viewBox[1])*(u.dataCoord[1]-t.dataBox[1])/(t.dataBox[3]-t.dataBox[1])-t.viewBox[1])/t.pixelRatio];var d=h.hoverinfo;if("all"!==d){var p=d.split("+");-1===p.indexOf("x")&&(h.traceCoord[0]=void 0),-1===p.indexOf("y")&&(h.traceCoord[1]=void 0),-1===p.indexOf("z")&&(h.traceCoord[2]=void 0),-1===p.indexOf("text")&&(h.textLabel=void 0),-1===p.indexOf("name")&&(h.name=void 0)}l.loneHover({x:h.screenCoord[0],y:h.screenCoord[1],xLabel:this.hoverFormatter("xaxis",h.traceCoord[0]),yLabel:this.hoverFormatter("yaxis",h.traceCoord[1]),zLabel:h.traceCoord[2],text:h.textLabel,name:h.name,color:h.color},{container:this.svgContainer}),this.lastPickResult={dataCoord:u.dataCoord}}}else!u&&this.lastPickResult&&(this.spikes.update({}),this.lastPickResult=null,l.loneUnhover(this.svgContainer))}t.draw()}},m.hoverFormatter=function(t,e){if(void 0!==e){var r=this[t];return s.tickText(r,r.c2l(e),"hover").text}}},{"../../lib/html2unicode":381,"../../lib/show_no_webgl_msg":392,"../../plots/cartesian/axes":405,"../../plots/cartesian/graph_interact":412,"./camera":436,"./convert":437,"gl-plot2d":165,"gl-select-box":195,"gl-spikes2d":215}],440:[function(t,e,r){"use strict";function n(t,e){t=t||document.body,e=e||{};var r=[.01,1/0];"distanceLimits"in e&&(r[0]=e.distanceLimits[0],r[1]=e.distanceLimits[1]),"zoomMin"in e&&(r[0]=e.zoomMin),"zoomMax"in e&&(r[1]=e.zoomMax);var n=a({center:e.center||[0,0,0],up:e.up||[0,1,0],eye:e.eye||[0,0,10],mode:e.mode||"orbit",distanceLimits:r}),l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=0,u=t.clientWidth,f=t.clientHeight,h={keyBindingMode:"rotate",view:n,element:t,delay:e.delay||16,rotateSpeed:e.rotateSpeed||1,zoomSpeed:e.zoomSpeed||1,translateSpeed:e.translateSpeed||1,flipX:!!e.flipX,flipY:!!e.flipY,modes:n.modes,tick:function(){var e=i(),r=this.delay,a=e-2*r;n.idle(e-r),n.recalcMatrix(a),n.flush(e-(100+2*r));for(var o=!0,s=n.computedMatrix,h=0;16>h;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){var e=n.computedUp.slice(),r=n.computedEye.slice(),a=n.computedCenter.slice();if(n.setMode(t),"turntable"===t){var o=i();n._active.lookAt(o,r,a,e),n._active.lookAt(o+500,r,a,[0,0,1]),n._active.flush(o)}return n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s="rotate"===h.keyBindingMode,l="pan"===h.keyBindingMode,u="zoom"===h.keyBindingMode,f=!!o.control,g=!!o.alt,v=!!o.shift,m=!!(1&e),y=!!(2&e),b=!!(4&e),x=1/t.clientHeight,_=x*(r-d),w=x*(a-p),k=h.flipX?1:-1,A=h.flipY?1:-1,M=i(),T=Math.PI*h.rotateSpeed;if((s&&m&&!f&&!g&&!v||m&&!f&&!g&&v)&&n.rotate(M,k*T*_,-A*T*w,0),(l&&m&&!f&&!g&&!v||y||m&&f&&!g&&!v)&&n.pan(M,-h.translateSpeed*_*c,h.translateSpeed*w*c,0),u&&m&&!f&&!g&&!v||b||m&&!f&&g&&!v){var E=-h.zoomSpeed*w/window.innerHeight*(M-n.lastT())*100;n.pan(M,0,0,c*(Math.exp(E)-1))}return d=r,p=a,!0}),s(t,function(t,e){var r=h.flipX?1:-1,a=h.flipY?1:-1,o=i();if(Math.abs(t)>Math.abs(e))n.rotate(o,0,0,-t*r*Math.PI*h.rotateSpeed/window.innerWidth);else{var s=-h.zoomSpeed*a*e/window.innerHeight*(o-n.lastT())/100;n.pan(o,0,0,c*(Math.exp(s)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":39,"mouse-change":241,"mouse-wheel":245,"right-now":255}],441:[function(t,e,r){"use strict";function n(t,e){for(var r=0;3>r;++r){var n=s[r];e[n]._gd=t}}var i=t("./scene"),a=t("../plots"),o=t("../../constants/xmlns_namespaces"),s=["xaxis","yaxis","zaxis"];r.name="gl3d",r.attr="scene",r.idRoot="scene",r.idRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^scene([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){var e=t._fullLayout,r=t._fullData,o=a.getSubplotIds(e,"gl3d");e._paperdiv.style({width:e.width+"px",height:e.height+"px"}),t._context.setBackground(t,e.paper_bgcolor);for(var s=0;sr;++r){var n=t[c[r]];e.labels[r]=o(n.title),"titlefont"in n&&(n.titlefont.color&&(e.labelColor[r]=s(n.titlefont.color)),n.titlefont.family&&(e.labelFont[r]=n.titlefont.family),n.titlefont.size&&(e.labelSize[r]=n.titlefont.size)),"showline"in n&&(e.lineEnable[r]=n.showline),"linecolor"in n&&(e.lineColor[r]=s(n.linecolor)),"linewidth"in n&&(e.lineWidth[r]=n.linewidth),"showgrid"in n&&(e.gridEnable[r]=n.showgrid),"gridcolor"in n&&(e.gridColor[r]=s(n.gridcolor)),"gridwidth"in n&&(e.gridWidth[r]=n.gridwidth),"log"===n.type?e.zeroEnable[r]=!1:"zeroline"in n&&(e.zeroEnable[r]=n.zeroline),"zerolinecolor"in n&&(e.zeroLineColor[r]=s(n.zerolinecolor)),"zerolinewidth"in n&&(e.zeroLineWidth[r]=n.zerolinewidth),"ticks"in n&&n.ticks?e.lineTickEnable[r]=!0:e.lineTickEnable[r]=!1,"ticklen"in n&&(e.lineTickLength[r]=e._defaultLineTickLength[r]=n.ticklen),"tickcolor"in n&&(e.lineTickColor[r]=s(n.tickcolor)),"tickwidth"in n&&(e.lineTickWidth[r]=n.tickwidth),"tickangle"in n&&(e.tickAngle[r]="auto"===n.tickangle?0:Math.PI*-n.tickangle/180),"showticklabels"in n&&(e.tickEnable[r]=n.showticklabels),"tickfont"in n&&(n.tickfont.color&&(e.tickColor[r]=s(n.tickfont.color)),n.tickfont.family&&(e.tickFont[r]=n.tickfont.family),n.tickfont.size&&(e.tickSize[r]=n.tickfont.size)),"mirror"in n?-1!==["ticks","all","allticks"].indexOf(n.mirror)?(e.lineTickMirror[r]=!0,e.lineMirror[r]=!0):n.mirror===!0?(e.lineTickMirror[r]=!1,e.lineMirror[r]=!0):(e.lineTickMirror[r]=!1,e.lineMirror[r]=!1):e.lineMirror[r]=!1,"showbackground"in n&&n.showbackground!==!1?(e.backgroundEnable[r]=!0,e.backgroundColor[r]=s(n.backgroundcolor)):e.backgroundEnable[r]=!1}},e.exports=i},{"../../../lib/html2unicode":381,"../../../lib/str2rgbarray":394,arraytools:49}],446:[function(t,e,r){"use strict";function n(t,e,r,n){for(var a=r("bgcolor"),l=i.combine(a,n.paper_bgcolor),c=Object.keys(o.camera),u=0;ue;++e){var r=t[o[e]];this.enabled[e]=r.showspikes,this.colors[e]=a(r.spikecolor),this.drawSides[e]=r.spikesides,this.lineWidth[e]=r.spikethickness}},e.exports=i},{"../../../lib/str2rgbarray":394}],449:[function(t,e,r){"use strict";function n(t){for(var e=new Array(3),r=0;3>r;++r){for(var n=t[r],i=new Array(n.length),a=0;au;++u){var f=i[s[u]];if(f._length=(r[u].hi-r[u].lo)*r[u].pixelsPerDataUnit/t.dataScale[u],Math.abs(f._length)===1/0)c[u]=[];else{f.range[0]=r[u].lo/t.dataScale[u],f.range[1]=r[u].hi/t.dataScale[u],f._m=1/(t.dataScale[u]*r[u].pixelsPerDataUnit),f.range[0]===f.range[1]&&(f.range[0]-=1,f.range[1]+=1);var h=f.tickmode;if("auto"===f.tickmode){f.tickmode="linear";var d=f.nticks||a.Lib.constrain(f._length/40,4,9);a.Axes.autoTicks(f,Math.abs(f.range[1]-f.range[0])/d)}for(var p=a.Axes.calcTicks(f),g=0;gu;++u){l[u]=.5*(t.glplot.bounds[0][u]+t.glplot.bounds[1][u]);for(var g=0;2>g;++g)e.bounds[g][u]=t.glplot.bounds[g][u]}t.contourLevels=n(c)}e.exports=i;var a=t("../../../plotly"),o=t("../../../lib/html2unicode"),s=["xaxis","yaxis","zaxis"],l=[0,0,0]},{"../../../lib/html2unicode":381,"../../../plotly":402}],450:[function(t,e,r){"use strict";function n(t,e){var r,n,i=[0,0,0,0];for(r=0;4>r;++r)for(n=0;4>n;++n)i[n]+=t[4*r+n]*e[r];return i}function i(t,e){var r=n(t.projection,n(t.view,n(t.model,[e[0],e[1],e[2],1])));return r}e.exports=i},{}],451:[function(t,e,r){"use strict";function n(t){function e(e,r){if("string"==typeof r)return r;var n=t.fullSceneLayout[e];return g.tickText(n,n.c2l(r),"hover").text}var r,n=t.svgContainer,i=t.container.getBoundingClientRect(),a=i.width,o=i.height;n.setAttributeNS(null,"viewBox","0 0 "+a+" "+o),n.setAttributeNS(null,"width",a),n.setAttributeNS(null,"height",o),A(t),t.glplot.axes.update(t.axesOptions);for(var s=Object.keys(t.traces),l=null,c=t.glplot.selection,u=0;ua;++a)l=u[T[a]],_(l);t?Array.isArray(t)||(t=[t]):t=[];var h=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]];for(a=0;ao;++o)h[0][o]>h[1][o]?d[o]=1:h[1][o]===h[0][o]?d[o]=1:d[o]=1/(h[1][o]-h[0][o]);for(this.dataScale=d,a=0;aa;++a){if(l=u[T[a]],c=l.type,c in x?(x[c].acc*=d[a],x[c].count+=1):x[c]={acc:d[a],count:1},l.autorange){for(y[0][a]=1/0,y[1][a]=-(1/0),o=0;oy[1][a])y[0][a]=-1,y[1][a]=1;else{var k=y[1][a]-y[0][a];y[0][a]-=k/32,y[1][a]+=k/32}}else{var A=u[T[a]].range;y[0][a]=A[0],y[1][a]=A[1]}y[0][a]===y[1][a]&&(y[0][a]-=1,y[1][a]+=1),b[a]=y[1][a]-y[0][a],this.glplot.bounds[0][a]=y[0][a]*d[a],this.glplot.bounds[1][a]=y[1][a]*d[a]}var M=[1,1,1];for(a=0;3>a;++a){l=u[T[a]],c=l.type;var E=x[c];M[a]=Math.pow(E.acc,1/E.count)/d[a]}var L,S=4;if("auto"===u.aspectmode)L=Math.max.apply(null,M)/Math.min.apply(null,M)<=S?M:[1,1,1];else if("cube"===u.aspectmode)L=[1,1,1];else if("data"===u.aspectmode)L=M;else{if("manual"!==u.aspectmode)throw new Error("scene.js aspectRatio was not one of the enumerated types");var C=u.aspectratio;L=[C.x,C.y,C.z]}u.aspectratio.x=f.aspectratio.x=L[0],u.aspectratio.y=f.aspectratio.y=L[1],u.aspectratio.z=f.aspectratio.z=L[2],this.glplot.aspect=L;var z=u.domain||null,P=e._size||null;if(z&&P){var R=this.container.style;R.position="absolute",R.left=P.l+z.x[0]*P.w+"px",R.top=P.t+(1-z.y[1])*P.h+"px",R.width=P.w*(z.x[1]-z.x[0])+"px",R.height=P.h*(z.y[1]-z.y[0])+"px"}this.glplot.redraw()}},M.destroy=function(){this.glplot.dispose(),this.container.parentNode.removeChild(this.container),this.glplot=null},M.setCameraToDefault=function(){this.setCamera({eye:{x:1.25,y:1.25,z:1.25},center:{x:0,y:0,z:0},up:{x:0,y:0,z:1}})},M.getCamera=function(){return this.glplot.camera.view.recalcMatrix(this.camera.view.lastT()),c(this.glplot.camera)},M.setCamera=function(t){var e={};e[this.id]=t,this.glplot.camera.lookAt.apply(this,l(t)),this.graphDiv.emit("plotly_relayout",e)},M.saveCamera=function(t){function e(t,e,r,n){var i=["up","center","eye"],a=["x","y","z"];return e[i[r]]&&t[i[r]][a[n]]===e[i[r]][a[n]]}var r=this.getCamera(),n=d.nestedProperty(t,this.id+".camera"),i=n.get(),a=!1;if(void 0===i)a=!0;else for(var o=0;3>o;o++)for(var s=0;3>s;s++)if(!e(r,i,o,s)){a=!0;break}return a&&n.set(r),a},M.updateFx=function(t,e){var r=this.camera;r&&("orbit"===t?(r.mode="orbit",r.keyBindingMode="rotate"):"turntable"===t?(r.up=[0,0,1],r.mode="turntable",r.keyBindingMode="rotate"):r.keyBindingMode=t),this.fullSceneLayout.hovermode=e},M.toImage=function(t){t||(t="png"),this.staticMode&&this.container.appendChild(u),this.glplot.redraw();var e=this.glplot.gl,r=e.drawingBufferWidth,n=e.drawingBufferHeight;e.bindFramebuffer(e.FRAMEBUFFER,null);var i=new Uint8Array(r*n*4);e.readPixels(0,0,r,n,e.RGBA,e.UNSIGNED_BYTE,i);for(var a=0,o=n-1;o>a;++a,--o)for(var s=0;r>s;++s)for(var l=0;4>l;++l){var c=i[4*(r*a+s)+l];i[4*(r*a+s)+l]=i[4*(r*o+s)+l],i[4*(r*o+s)+l]=c}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticMode&&this.container.removeChild(u),p},e.exports=a},{"../../lib":382,"../../lib/show_no_webgl_msg":392,"../../lib/str2rgbarray":394,"../../plots/cartesian/axes":405,"../../plots/cartesian/graph_interact":412,"../../plots/plots":454,"./camera":440,"./layout/convert":445,"./layout/spikes":448,"./layout/tick_marks":449,"./project":450,"./set_convert":452,"gl-plot3d":183}],452:[function(t,e,r){"use strict";var n=t("../cartesian/axes"),i=function(){};e.exports=function(t){n.setConvert(t),t.setScale=i}},{"../cartesian/axes":405}],453:[function(t,e,r){"use strict";var n=t("../plotly"),i=t("./font_attributes"),a=t("../components/color/attributes"),o=n.Lib.extendFlat;e.exports={font:{family:o({},i.family,{dflt:'"Open Sans", verdana, arial, sans-serif'}),size:o({},i.size,{dflt:12}),color:o({},i.color,{dflt:a.defaultLine})},title:{valType:"string",dflt:"Click to enter Plot title"},titlefont:o({},i,{}),autosize:{valType:"enumerated",values:[!0,!1,"initial"]},width:{valType:"number",min:10,dflt:700},height:{valType:"number",min:10,dflt:450},margin:{l:{valType:"number",min:0,dflt:80},r:{valType:"number",min:0,dflt:80},t:{valType:"number",min:0,dflt:100},b:{valType:"number",min:0,dflt:80},pad:{valType:"number",min:0,dflt:0},autoexpand:{valType:"boolean",dflt:!0}},paper_bgcolor:{valType:"color",dflt:a.background},plot_bgcolor:{valType:"color",dflt:a.background},separators:{valType:"string",dflt:".,"},hidesources:{valType:"boolean",dflt:!1},smith:{valType:"enumerated",values:[!1],dflt:!1},showlegend:{valType:"boolean"},_composedModules:{"*":"Fx"},_nestedModules:{xaxis:"Axes",yaxis:"Axes",scene:"gl3d",geo:"geo",legend:"Legend",annotations:"Annotations",shapes:"Shapes",images:"Images",ternary:"ternary",mapbox:"mapbox"}}},{"../components/color/attributes":302,"../plotly":402,"./font_attributes":423}],454:[function(t,e,r){"use strict";function n(t){return"object"==typeof t&&(t=t.type),t}function i(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#","class":"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){f.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}function a(t,e){for(var r,n=Object.keys(e),i=0;i=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var s=r.select(".js-link-to-tool"),l=r.select(".js-link-spacer"),c=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&i(t,s),l.text(s.text()&&c.text()?" - ":"")},f.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",r=o.select(t).append("div").attr("id","hiddenform").style("display","none"),n=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),i=n.append("input").attr({type:"text",name:"data"});return i.node().value=f.graphJson(t,!1,"keepdata"),n.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1},f.supplyDefaults=function(t){var e,r,n=t._fullLayout||{},i=t._fullLayout={},o=t.layout||{},s=t._fullData||[],u=t._fullData=[],h=t.data||[],d=i._modules=[],p=i._basePlotModules=[];for(f.supplyLayoutGlobalDefaults(o,i),i._dataLength=h.length,e=0;ea&&(e=(r-1)/(i.l+i.r),i.l=Math.floor(e*i.l),i.r=Math.floor(e*i.r)),0>o&&(e=(n-1)/(i.t+i.b),i.t=Math.floor(e*i.t),i.b=Math.floor(e*i.b))}},f.autoMargin=function(t,e,r){var n=t._fullLayout;if(n._pushmargin||(n._pushmargin={}),n.margin.autoexpand!==!1){if(r){var i=void 0===r.pad?12:r.pad;r.l+r.r>.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0),n._pushmargin[e]={l:{val:r.x,size:r.l+i},r:{val:r.x,size:r.r+i},b:{val:r.y,size:r.b+i},t:{val:r.y,size:r.t+i}}}else delete n._pushmargin[e];t._replotting||f.doAutoMargin(t)}},f.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var r=e._size,n=JSON.stringify(r),i=Math.max(e.margin.l||0,0),a=Math.max(e.margin.r||0,0),o=Math.max(e.margin.t||0,0),c=Math.max(e.margin.b||0,0),u=e._pushmargin;return e.margin.autoexpand!==!1&&(u.base={l:{val:0,size:i},r:{val:1,size:a},t:{val:1,size:o},b:{val:0,size:c}},Object.keys(u).forEach(function(t){var r=u[t].l||{},n=u[t].b||{},l=r.val,f=r.size,h=n.val,d=n.size;Object.keys(u).forEach(function(t){if(s(f)&&u[t].r){var r=u[t].r.val,n=u[t].r.size;if(r>l){var p=(f*r+(n-e.width)*l)/(r-l),g=(n*(1-l)+(f-e.width)*(1-r))/(r-l);p>=0&&g>=0&&p+g>i+a&&(i=p,a=g)}}if(s(d)&&u[t].t){var v=u[t].t.val,m=u[t].t.size;if(v>h){var y=(d*v+(m-e.height)*h)/(v-h),b=(m*(1-h)+(d-e.height)*(1-v))/(v-h);y>=0&&b>=0&&y+b>c+o&&(c=y,o=b)}}})})),r.l=Math.round(i),r.r=Math.round(a),r.t=Math.round(o),r.b=Math.round(c),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,t._replotting||"{}"===n||n===JSON.stringify(e._size)?void 0:l.plot(t)},f.graphJson=function(t,e,r,n,i){function a(t){if("function"==typeof t)return null;if(c.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0&&!c.isPlainObject(t.stream))continue}else if("keepall"!==r&&(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0))continue;i[e]=a(t[e])}return i}return Array.isArray(t)?t.map(a):t&&t.getTime?c.ms2DateTime(t):t}(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&f.supplyDefaults(t);var o=i?t._fullData:t.data,s=i?t._fullLayout:t.layout,l={data:(o||[]).map(function(t){var r=a(t);return e&&delete r.fit,r})};return e||(l.layout=a(s)),t.framework&&t.framework.isPolar&&(l=t.framework.getConfig()),"object"===n?l:JSON.stringify(l)}},{"../components/color":303,"../lib":382,"../plotly":402,"./attributes":403,"./font_attributes":423,"./layout_attributes":453,d3:113,"fast-isnumeric":117}],455:[function(t,e,r){"use strict";var n=t("../../traces/scatter/attributes"),i=n.marker;e.exports={r:n.r,t:n.t,marker:{color:i.color,size:i.size,symbol:i.symbol,opacity:i.opacity}}},{"../../traces/scatter/attributes":556}],456:[function(t,e,r){"use strict";function n(t,e){var r={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated", +values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return a({},e,r)}var i=t("../cartesian/layout_attributes"),a=t("../../lib/extend").extendFlat,o=a({},i.domain,{});e.exports={radialaxis:n("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:o,orientation:{valType:"number"}}),angularaxis:n("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:o}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":377,"../cartesian/layout_attributes":414}],457:[function(t,e,r){var n=t("../../plotly"),i=t("d3"),a=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},o=n.Lib.extendDeepAll;a.Axis=function(){function t(t){r=t||r;var c=l.data,f=l.layout;return("string"==typeof r||r.nodeName)&&(r=i.select(r)),r.datum(c).each(function(t,r){function l(t,e){return s(t)%360+f.orientation}var c=t.slice();u={data:a.util.cloneJson(c),layout:a.util.cloneJson(f)};var h=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[h],h=(h+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:i.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var d=c.filter(function(t,e){var r=t.visible;return"undefined"==typeof r||r===!0}),p=!1,g=d.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=i.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var r=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,n){t.yStack=[r],m.push(r),r=a.util.sumArrays(t.r,r)}),t.values});d=i.merge(y)}d.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var b=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;b=Math.max(10,b);var x,_=[f.margin.left+b,f.margin.top+b];if(p){var w=i.max(a.util.sumArrays(a.util.arrayLast(d).r[0],a.util.arrayLast(m)));x=[0,w]}else x=i.extent(a.util.flattenArray(d.map(function(t,e){return t.r})));f.radialAxis.domain!=a.DATAEXTENT&&(x[0]=0),n=i.scale.linear().domain(f.radialAxis.domain!=a.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:x).range([0,b]),u.layout.radialAxis.domain=n.domain();var k,A=a.util.flattenArray(d.map(function(t,e){return t.t})),M="string"==typeof A[0];M&&(A=a.util.deduplicate(A),k=A.slice(),A=i.range(A.length),d=d.map(function(t,e){var r=t;return t.t=[A],p&&(r.yStack=t.yStack),r}));var T=d.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===d.length,E=null===f.needsEndSpacing?M||!T:f.needsEndSpacing,L=f.angularAxis.domain&&f.angularAxis.domain!=a.DATAEXTENT&&!M&&f.angularAxis.domain[0]>=0,S=L?f.angularAxis.domain:i.extent(A),C=Math.abs(A[1]-A[0]);T&&!M&&(C=0);var z=S.slice();E&&M&&(z[1]+=C);var P=f.angularAxis.ticksCount||4;P>8&&(P=P/(P/8)+P%8),f.angularAxis.ticksStep&&(P=(z[1]-z[0])/P);var R=f.angularAxis.ticksStep||(z[1]-z[0])/(P*(f.minorTicks+1));k&&(R=Math.max(Math.round(R),1)),z[2]||(z[2]=R);var O=i.range.apply(this,z);if(O=O.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=i.scale.linear().domain(z.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=s.domain(),u.layout.angularAxis.endPadding=E?C:0,e=i.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var I="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",N=(new DOMParser).parseFromString(I,"application/xml"),j=this.appendChild(this.ownerDocument.importNode(N.documentElement,!0));e=i.select(j)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var F,D=e.select(".chart-group"),B={fill:"none",stroke:f.tickColor},U={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){F=e.select(".legend-group").attr({transform:"translate("+[b,f.margin.top]+")"}).style({display:"block"});var V=d.map(function(t,e){var r=a.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});a.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:o({},a.Legend.defaultConfig().legendConfig,{container:F,elements:V,reverseOrder:f.legend.reverseOrder})})();var q=F.node().getBBox();b=Math.min(f.width-q.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,b=Math.max(10,b),_=[f.margin.left+b,f.margin.top+b],n.range([0,b]),u.layout.radialAxis.domain=n.domain(),F.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else F=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),D.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(f.width-(f.margin.left+f.margin.right+2*b+(q?q.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*b))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),e.select(".outer-group").attr("transform","translate("+H+")"),f.title){var G=e.select("g.title-group text").style(U).text(f.title),Y=G.node().getBBox();G.attr({x:_[0]-Y.width/2,y:_[1]-b-20})}var X=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var W=X.selectAll("circle.grid-circle").data(n.ticks(5));W.enter().append("circle").attr({"class":"grid-circle"}).style(B),W.attr("r",n),W.exit().remove()}X.select("circle.outside-circle").attr({r:b}).style(B);var Z=e.select("circle.background-circle").attr({r:b}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var K=i.svg.axis().scale(n).ticks(5).tickSize(5);X.call(K).attr({transform:"rotate("+f.radialAxis.orientation+")"}),X.selectAll(".domain").style(B),X.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(U).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,U["font-size"]]+")":"translate("+[0,U["font-size"]]+")"}}),X.selectAll("g>line").style({stroke:"black"})}var $=e.select(".angular.axis-group").selectAll("g.angular-tick").data(O),Q=$.enter().append("g").classed("angular-tick",!0);$.attr({transform:function(t,e){return"rotate("+l(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),$.exit().remove(),Q.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(B),Q.selectAll(".minor").style({stroke:f.minorTickColor}),$.select("line.grid-line").attr({x1:f.tickLength?b-f.tickLength:0,x2:b}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),Q.append("text").classed("axis-text",!0).style(U);var J=$.select("text.axis-text").attr({x:b+f.labelOffset,dy:".35em",transform:function(t,e){var r=l(t,e),n=b+f.labelOffset,i=f.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?270>r&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(180>=r&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(U);f.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=i.max(D.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));F.attr({transform:"translate("+[b+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,rt=e.select("g.geometry-group").selectAll("g.geometry").data(d);if(rt.enter().append("g").attr({"class":function(t,e){return"geometry geometry"+e}}),rt.exit().remove(),d[0]||et){var nt=[];d.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=s,r.container=rt.filter(function(t,r){return r==e}),r.geometry=t.geometry,r.orientation=f.orientation,r.direction=f.direction,r.index=e,nt.push({data:t,geometryConfig:r})});var it=i.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(nt),at=[];it.forEach(function(t,e){"unstacked"===t.key?at=at.concat(t.values.map(function(t,e){return[t]})):at.push(t.values)}),at.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return o(a[r].defaultConfig(),t)});a[r]().config(n)()})}var ot,st,lt=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=a.tooltipPanel().config({container:ct,fontSize:8})(),ft=a.tooltipPanel().config({container:ct,fontSize:8})(),ht=a.tooltipPanel().config({container:ct,hasTick:!0})();if(!M){var dt=lt.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});D.on("mousemove.angular-guide",function(t,e){var r=a.util.getMousePos(Z).angle;dt.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-f.orientation)%360;ot=s.invert(n);var i=a.util.convertToCartesian(b+12,r+180);ut.text(a.util.round(ot)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){lt.select("line").style({opacity:0})})}var pt=lt.select("circle").style({stroke:"grey",fill:"none"});D.on("mousemove.radial-guide",function(t,e){var r=a.util.getMousePos(Z).radius;pt.attr({r:r}).style({opacity:.5}),st=n.invert(a.util.getMousePos(Z).radius);var i=a.util.convertToCartesian(r,f.radialAxis.orientation);ft.text(a.util.round(st)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),ht.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,r){var n=i.select(this),o=n.style("fill"),s="black",l=n.style("opacity")||1;if(n.attr({"data-opacity":l}),"none"!=o){n.attr({"data-fill":o}),s=i.hsl(o).darker().toString(),n.style({fill:s,opacity:1});var c={t:a.util.round(t[0]),r:a.util.round(t[1])};M&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),h=e.node().getBoundingClientRect(),d=[f.left+f.width/2-H[0]-h.left,f.top+f.height/2-H[1]-h.top];ht.config({color:s}).text(u),ht.move(d)}else o=n.style("stroke"),n.attr({"data-stroke":o}),s=i.hsl(o).darker().toString(),n.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0!=i.event.which?!1:void(i.select(this).attr("data-fill")&&ht.show())}).on("mouseout.tooltip",function(t,e){ht.hide();var r=i.select(this),n=r.attr("data-fill");n?r.style({fill:n,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})}),h}var e,r,n,s,l={data:[],layout:{}},c={},u={},f=i.dispatch("hover"),h={};return h.render=function(e){return t(e),this},h.config=function(t){if(!arguments.length)return l;var e=a.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),o(l.data[e],a.Axis.defaultConfig().data[0]),o(l.data[e],t)}),o(l.layout,a.Axis.defaultConfig().layout),o(l.layout,e.layout),this},h.getLiveConfig=function(){return u},h.getinputConfig=function(){return c},h.radialScale=function(t){return n},h.angularScale=function(t){return s},h.svg=function(){return e},i.rebind(h,f,"on"),h},a.Axis.defaultConfig=function(t,e){var r={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:i.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return r},a.util={},a.DATAEXTENT="dataExtent",a.AREA="AreaChart",a.LINE="LinePlot",a.DOT="DotPlot",a.BAR="BarChart",a.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},a.util._extend=function(t,e){for(var r in t)e[r]=t[r]},a.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},a.util.dataFromEquation2=function(t,e){var r=e||6,n=i.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180,i=t(n);return[e,i]});return n},a.util.dataFromEquation=function(t,e,r){var n=e||6,a=[],o=[];i.range(0,360+n,n).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},a.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return i.range(e).map(function(t,e){return r[e]||r[0]})},a.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=a.util.ensureArray(t[e],r)}),t},a.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},a.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},a.util.sumArrays=function(t,e){return i.zip(t,e).map(function(t,e){return i.sum(t)})},a.util.arrayLast=function(t){return t[t.length-1]},a.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},a.util.flattenArray=function(t){for(var e=[];!a.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},a.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},a.util.convertToCartesian=function(t,e){var r=e*Math.PI/180,n=t*Math.cos(r),i=t*Math.sin(r);return[n,i]},a.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},a.util.getMousePos=function(t){var e=i.mouse(t.node()),r=e[0],n=e[1],a={};return a.x=r,a.y=n,a.pos=e,a.angle=180*(Math.atan2(n,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+n*n),a},a.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;a>i;i++)e=t[i],e in r?(r[e]++,n[e]=r[e]):r[e]=1;return n},a.util.duplicates=function(t){return Object.keys(a.util.duplicatesCount(t))},a.util.translator=function(t,e,r,n){if(n){var i=r.slice();r=e,e=i}var a=e.reduce(function(t,e){return"undefined"!=typeof t?t[e]:void 0},t);"undefined"!=typeof a&&(e.reduce(function(t,r,n){return"undefined"!=typeof t?(n===e.length-1&&delete t[r],t[r]):void 0},t),r.reduce(function(t,e,n){return"undefined"==typeof t[e]&&(t[e]={}),n===r.length-1&&(t[e]=a),t[e]},t))},a.PolyChart=function(){function t(){var t=r[0].geometryConfig,e=t.container;"string"==typeof e&&(e=i.select(e)),e.datum(r).each(function(e,r){function n(e,r){var n=t.radialScale(e[1]),i=(t.angularScale(e[0])+t.orientation)*Math.PI/180;return{r:n,t:i}}function a(t){var e=t.r*Math.cos(t.t),r=t.r*Math.sin(t.t);return{x:e,y:r}}var o=!!e[0].data.yStack,l=e.map(function(t,e){return o?i.zip(t.data.t[0],t.data.r[0],t.data.yStack[0]):i.zip(t.data.t[0],t.data.r[0])}),c=t.angularScale,u=t.radialScale.domain()[0],f={};f.bar=function(r,n,a){var o=e[a].data,s=t.radialScale(r[1])-t.radialScale(0),l=t.radialScale(r[2]||0),u=o.barWidth;i.select(this).attr({"class":"mark bar",d:"M"+[[s+l,-u/2],[s+l,u/2],[l,u/2],[l,-u/2]].join("L")+"Z",transform:function(e,r){return"rotate("+(t.orientation+c(e[0]))+")"}})},f.dot=function(t,r,o){var s=t[2]?[t[0],t[1]+t[2]]:t,l=i.svg.symbol().size(e[o].data.dotSize).type(e[o].data.dotType)(t,r);i.select(this).attr({"class":"mark dot",d:l,transform:function(t,e){var r=a(n(s));return"translate("+[r.x,r.y]+")"}})};var h=i.svg.line.radial().interpolate(e[0].data.lineInterpolation).radius(function(e){return t.radialScale(e[1])}).angle(function(e){return t.angularScale(e[0])*Math.PI/180});f.line=function(r,n,a){var o=r[2]?l[a].map(function(t,e){return[t[0],t[1]+t[2]]}):l[a];if(i.select(this).each(f.dot).style({opacity:function(t,r){return+e[a].data.dotVisible},fill:v.stroke(r,n,a)}).attr({"class":"mark dot"}),!(n>0)){var s=i.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({"class":"line",d:h(o),transform:function(e,r){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(r,n,a)},"fill-opacity":0,stroke:function(t,e){return v.stroke(r,n,a)},"stroke-width":function(t,e){return v["stroke-width"](r,n,a)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](r,n,a)},opacity:function(t,e){return v.opacity(r,n,a)},display:function(t,e){return v.display(r,n,a)}})}};var d=t.angularScale.range(),p=Math.abs(d[1]-d[0])/l[0].length*Math.PI/180,g=i.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,r,n){i.select(this).attr({"class":"mark arc",d:g,transform:function(e,r){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var v={fill:function(t,r,n){return e[n].data.color},stroke:function(t,r,n){return e[n].data.strokeColor},"stroke-width":function(t,r,n){return e[n].data.strokeSize+"px"},"stroke-dasharray":function(t,r,n){return s[e[n].data.strokeDash]},opacity:function(t,r,n){return e[n].data.opacity},display:function(t,r,n){return"undefined"==typeof e[n].data.visible||e[n].data.visible?"block":"none"}},m=i.select(this).selectAll("g.layer").data(l);m.enter().append("g").attr({"class":"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({"class":"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,r=[a.PolyChart.defaultConfig()],n=i.dispatch("hover"),s={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){r[e]||(r[e]={}),o(r[e],a.PolyChart.defaultConfig()),o(r[e],t)}),this):r},t.getColorScale=function(){return e},i.rebind(t,n,"on"),t},a.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:i.scale.category20()}};return t},a.BarChart=function(){return a.PolyChart()},a.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},a.AreaChart=function(){return a.PolyChart()},a.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},a.DotPlot=function(){return a.PolyChart()},a.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},a.LinePlot=function(){return a.PolyChart()},a.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},a.Legend=function(){function t(){var r=e.legendConfig,n=e.data.map(function(t,e){return[].concat(t).map(function(t,n){var i=o({},r.elements[e]);return i.name=t,i.color=[].concat(r.elements[e].color)[n],i})}),a=i.merge(n);a=a.filter(function(t,e){return r.elements[e]&&(r.elements[e].visibleInLegend||"undefined"==typeof r.elements[e].visibleInLegend)}),r.reverseOrder&&(a=a.reverse());var s=r.container;("string"==typeof s||s.nodeName)&&(s=i.select(s));var l=a.map(function(t,e){return t.color}),c=r.fontSize,u=null==r.isContinuous?"number"==typeof a[0]:r.isContinuous,f=u?r.height:c*a.length,h=s.classed("legend-group",!0),d=h.selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=i.range(a.length),v=i.scale[u?"linear":"ordinal"]().domain(g).range(l),m=i.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var r=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=i.svg.symbolTypes.indexOf(t)?i.svg.symbol().type(t).size(r)():i.svg.symbol().type("square").size(r)()};if(u){var b=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);b.enter().append("stop"),b.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:r.height,width:r.colorBandWidth,fill:"url(#grad1)"})}else{var x=d.select(".legend-marks").selectAll("path.legend-mark").data(a);x.enter().append("path").classed("legend-mark",!0),x.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var r=t.symbol;return y(r,c)},fill:function(t,e){return v(e)}}),x.exit().remove()}var _=i.svg.axis().scale(m).orient("right"),w=d.select("g.legend-axis").attr({transform:"translate("+[u?r.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?r.textColor:"none"}),w.selectAll("text").style({fill:r.textColor,"font-size":r.fontSize}).text(function(t,e){return a[e].name}),t}var e=a.Legend.defaultConfig(),r=i.dispatch("hover");return t.config=function(t){return arguments.length?(o(e,t),this):e},i.rebind(t,r,"on"),t},a.Legend.defaultConfig=function(t,e){var r={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return r},a.tooltipPanel=function(){var t,e,r,n={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+a.tooltipPanel.uid++,l=10,c=function(){t=n.container.selectAll("g."+s).data([0]);var i=t.enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=i.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=i.append("text").attr({dx:n.padding+l,dy:.3*+n.fontSize}),c};return c.text=function(a){var o=i.hsl(n.color).l,s=o>=.5?"#aaa":"white",u=o>=.5?"black":"white",f=a||"";e.style({fill:u,"font-size":n.fontSize+"px"}).text(f);var h=n.padding,d=e.node().getBBox(),p={fill:n.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[n.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),c},c.move=function(e){return t?(t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c):void 0},c.hide=function(){return t?(t.style({display:"none"}),c):void 0},c.show=function(){return t?(t.style({display:"block"}),c):void 0},c.config=function(t){return o(n,t),c},c},a.tooltipPanel.uid=1,a.adapter={},a.adapter.plotly=function(){var t={};return t.convert=function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=o({},t),i=[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]];return i.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",n.dotVisible===!0?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var n=a.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var i=n.indexOf(t.geometry);-1!=i&&(r.data[e].groupId=i)})}if(t.layout){var s=o({},t.layout),l=[[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]];if(l.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};i.entries(s.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),s.margin=f}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r},t}},{"../../plotly":402,"./micropolar_manager":458,d3:113}],458:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("d3"),a=t("./undo_manager"),o=e.exports={},s=n.Lib.extendDeepAll;o.framework=function(t){function e(e,a){return a&&(f=a),i.select(i.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),r=r?s(r,e):e,c||(c=n.micropolar.Axis()),u=n.micropolar.adapter.plotly().convert(r),c.config(u).render(f),t.data=r.data,t.layout=r.layout,o.fillLayout(t),r}var r,l,c,u,f,h=new a;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return r},e.getLiveConfig=function(){return n.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=n.micropolar.util.cloneJson(r);!function(e,r){h.add({undo:function(){r&&t(r)},redo:function(){t(e)}})}(e,l),l=n.micropolar.util.cloneJson(e)},e.undo=function(){h.undo()},e.redo=function(){h.redo()},e},o.fillLayout=function(t){var e=i.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:n.Color.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../plotly":402,"./undo_manager":459,d3:113}],459:[function(t,e,r){"use strict";e.exports=function(){function t(t,e){return t?(i=!0,t[e](),i=!1,this):this}var e,r=[],n=-1,i=!1;return{add:function(t){return i?this:(r.splice(n+1,r.length-n),r.push(t),n=r.length-1,this)},setCallback:function(t){e=t},undo:function(){var i=r[n];return i?(t(i,"undo"),n-=1,e&&e(i.undo),this):this},redo:function(){var i=r[n+1];return i?(t(i,"redo"),n+=1,e&&e(i.redo),this):this},clear:function(){r=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return ng;g++){var v=d[g];s=t[v]?t[v]:t[v]={},e[v]=l={},o("domain."+h,[g/p,(g+1)/p]),o("domain."+{x:"y",y:"x"}[h]),a.id=v,f(s,l,o,a)}}},{"../lib":382,"./plots":454}],461:[function(t,e,r){"use strict";var n=t("./ternary"),i=t("../../plots/plots");r.name="ternary",r.attr="subplot",r.idRoot="ternary",r.idRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attrRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,r.attributes=t("./layout/attributes"),r.layoutAttributes=t("./layout/layout_attributes"),r.supplyLayoutDefaults=t("./layout/defaults"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"ternary"),o=0;o=o&&(d.min=0,p.min=0,g.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}var i=t("../../../components/color"),a=t("../../subplot_defaults"),o=t("./layout_attributes"),s=t("./axis_defaults"),l=["aaxis","baxis","caxis"];e.exports=function(t,e,r){a(t,e,r,{type:"ternary",attributes:o,handleDefaults:n,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../../components/color":303,"../../subplot_defaults":460,"./axis_defaults":464,"./layout_attributes":466}],466:[function(t,e,r){"use strict";var n=t("../../../components/color/attributes"),i=t("./axis_attributes");e.exports={domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},bgcolor:{valType:"color",dflt:n.background},sum:{valType:"number",dflt:1,min:0},aaxis:i,baxis:i,caxis:i}},{"../../../components/color/attributes":302,"./axis_attributes":463}],467:[function(t,e,r){"use strict";function n(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework()}function i(t){a.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var a=t("d3"),o=t("tinycolor2"),s=t("../../plotly"),l=t("../../lib"),c=t("../../components/color"),u=t("../../components/drawing"),f=t("../cartesian/set_convert"),h=t("../../lib/extend").extendFlat,d=t("../cartesian/axes"),p=t("../../lib/filter_visible"),g=t("../../components/dragelement"),v=t("../../components/titles"),m=t("../cartesian/select"),y=t("../cartesian/constants"),b=t("../cartesian/graph_interact");e.exports=n;var x=n.prototype;x.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={}},x.plot=function(t,e){var r,n=this,i=e[n.id],a=e._size;l.getPlotDiv(n.plotContainer.node())!==n.graphDiv&&(n.init(n.graphDiv._fullLayout),n.makeFramework()),n.adjustLayout(i,a);var o=n.traceHash,s={};for(r=0;r_*y?(a=y,i=a*_):(i=m,a=i/_),o=g*i/m,s=v*a/y,r=e.l+e.w*d-i/2,n=e.t+e.h*(1-p)-a/2,l.x0=r,l.y0=n,l.w=i,l.h=a,l.sum=b,l.xaxis={type:"linear",range:[x+2*k-b,b-x-2*w],domain:[d-o/2,d+o/2],_id:"x",_gd:l.graphDiv},f(l.xaxis),l.xaxis.setScale(),l.yaxis={type:"linear",range:[x,b-w-k],domain:[p-s/2,p+s/2],_id:"y",_gd:l.graphDiv},f(l.yaxis),l.yaxis.setScale();var A=l.yaxis.domain[0],M=l.aaxis=h({},t.aaxis,{range:[x,b-w-k],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[A,A+s*_],_axislayer:l.layers.aaxis,_gridlayer:l.layers.agrid,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l"+a+",-"+i/2});f(M);var T=l.baxis=h({},t.baxis,{range:[b-x-k,w],side:"bottom",_counterangle:30,domain:l.xaxis.domain,_axislayer:l.layers.baxis,_gridlayer:l.layers.bgrid,_counteraxis:l.aaxis,_pos:0,_gd:l.graphDiv,_id:"x",_length:i,_gridpath:"M0,0l-"+i/2+",-"+a});f(T),M._counteraxis=T;var E=l.caxis=h({},t.caxis,{range:[b-x-w,k],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[A,A+s*_],_axislayer:l.layers.caxis,_gridlayer:l.layers.cgrid,_counteraxis:l.baxis,_pos:0,_gd:l.graphDiv,_id:"y",_length:i,_gridpath:"M0,0l-"+a+","+i/2});f(E);var L="M"+r+","+(n+a)+"h"+i+"l-"+i/2+",-"+a+"Z";l.clipDef.select("path").attr("d",L),l.layers.plotbg.select("path").attr("d",L);var S="translate("+r+","+n+")";l.plotContainer.selectAll(".scatterlayer,.maplayer,.zoom").attr("transform",S);var C="translate("+r+","+(n+a)+")";l.layers.baxis.attr("transform",C),l.layers.bgrid.attr("transform",C);var z="translate("+(r+i/2)+","+n+")rotate(30)";l.layers.aaxis.attr("transform",z),l.layers.agrid.attr("transform",z);var P="translate("+(r+i/2)+","+n+")rotate(-30)";l.layers.caxis.attr("transform",P),l.layers.cgrid.attr("transform",P),l.drawAxes(!0),l.plotContainer.selectAll(".crisp").classed("crisp",!1);var R=l.layers.axlines;R.select(".aline").attr("d",M.showline?"M"+r+","+(n+a)+"l"+i/2+",-"+a:"M0,0").call(c.stroke,M.linecolor||"#000").style("stroke-width",(M.linewidth||0)+"px"),R.select(".bline").attr("d",T.showline?"M"+r+","+(n+a)+"h"+i:"M0,0").call(c.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),R.select(".cline").attr("d",E.showline?"M"+(r+i/2)+","+n+"l"+i/2+","+a:"M0,0").call(c.stroke,E.linecolor||"#000").style("stroke-width",(E.linewidth||0)+"px")},x.drawAxes=function(t){var e=this,r=e.graphDiv,n=e.id.substr(7)+"title",i=e.aaxis,a=e.baxis,o=e.caxis;if(d.doTicks(r,i,!0),d.doTicks(r,a,!0),d.doTicks(r,o,!0),t){var s=Math.max(i.showticklabels?i.tickfont.size/2:0,(o.showticklabels?.75*o.tickfont.size:0)+("outside"===o.ticks?.87*o.ticklen:0));v.draw(r,"a"+n,{propContainer:i,propName:e.id+".aaxis.title",dfltName:"Component A",attributes:{x:e.x0+e.w/2,y:e.y0-i.titlefont.size/3-s,"text-anchor":"middle"}});var l=(a.showticklabels?a.tickfont.size:0)+("outside"===a.ticks?a.ticklen:0)+3;v.draw(r,"b"+n,{propContainer:a,propName:e.id+".baxis.title",dfltName:"Component B",attributes:{x:e.x0-l,y:e.y0+e.h+.83*a.titlefont.size+l,"text-anchor":"middle"}}),v.draw(r,"c"+n,{propContainer:o,propName:e.id+".caxis.title",dfltName:"Component C",attributes:{x:e.x0+e.w+l,y:e.y0+e.h+.83*o.titlefont.size+l,"text-anchor":"middle"}})}};var w=y.MINZOOM/2+.87,k="m-0.87,.5h"+w+"v3h-"+(w+5.2)+"l"+(w/2+2.6)+",-"+(.87*w+4.5)+"l2.6,1.5l-"+w/2+","+.87*w+"Z",A="m0.87,.5h-"+w+"v3h"+(w+5.2)+"l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-2.6,1.5l"+w/2+","+.87*w+"Z",M="m0,1l"+w/2+","+.87*w+"l2.6,-1.5l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-"+(w/2+2.6)+","+(.87*w+4.5)+"l2.6,1.5l"+w/2+",-"+.87*w+"Z",T="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",E=!0;x.initInteractions=function(){function t(t,e,r){var n=j.getBoundingClientRect();x=e-n.left,w=r-n.top,L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L,S=N.aaxis.range[1]-L.a,z=o(N.graphDiv._fullLayout[N.id].bgcolor).getLuminance(),P="M0,"+N.h+"L"+N.w/2+", 0L"+N.w+","+N.h+"Z",R=!1,O=D.append("path").attr("class","zoombox").style({fill:z>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",P),I=D.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),p()}function e(t,e){return 1-e/N.h}function r(t,e){return 1-(t+(N.h-e)/Math.sqrt(3))/N.w}function n(t,e){return(t-(N.h-e)/Math.sqrt(3))/N.w}function a(t,i){var a=x+t,o=w+i,s=Math.max(0,Math.min(1,e(x,w),e(a,o))),l=Math.max(0,Math.min(1,r(x,w),r(a,o))),c=Math.max(0,Math.min(1,n(x,w),n(a,o))),u=(s/2+c)*N.w,f=(1-s/2-l)*N.w,h=(u+f)/2,d=f-u,p=(1-s)*N.h,g=p-d/_;d.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),I.transition().style("opacity",1).duration(200),R=!0)}function u(t,e){if(C===L)return 2===e&&v(),i(F);i(F);var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r),E&&F.data&&F._context.showTips&&(l.notifier("Double-click to
zoom back out","long"),E=!1)}function f(){L={a:N.aaxis.range[0],b:N.baxis.range[1],c:N.caxis.range[1]},C=L}function h(t,e){var r=t/N.xaxis._m,n=e/N.yaxis._m;C={a:L.a-n,b:L.b+(r+n)/2,c:L.c-(r-n)/2};var i=[C.a,C.b,C.c].sort(),a={a:i.indexOf(C.a),b:i.indexOf(C.b),c:i.indexOf(C.c)};i[0]<0&&(i[1]+i[0]/2<0?(i[2]+=i[0]+i[1],i[0]=i[1]=0):(i[2]+=i[0]/2,i[1]+=i[0]/2,i[0]=0),C={a:i[a.a],b:i[a.b],c:i[a.c]},e=(L.a-C.a)*N.yaxis._m,t=(L.c-C.c-L.b+C.b)*N.xaxis._m);var o="translate("+(N.x0+t)+","+(N.y0+e)+")";N.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",o),N.aaxis.range=[C.a,N.sum-C.b-C.c],N.baxis.range=[N.sum-C.a-C.c,C.b],N.caxis.range=[N.sum-C.a-C.b,C.c],N.drawAxes(!1),N.plotContainer.selectAll(".crisp").classed("crisp",!1)}function d(t,e){if(t){var r={};r[N.id+".aaxis.min"]=C.a,r[N.id+".baxis.min"]=C.b,r[N.id+".caxis.min"]=C.c,s.relayout(F,r)}else 2===e&&v()}function p(){N.plotContainer.selectAll(".select-outline").remove()}function v(){var t={};t[N.id+".aaxis.min"]=0,t[N.id+".baxis.min"]=0,t[N.id+".caxis.min"]=0,F.emit("plotly_doubleclick",null),s.relayout(F,t)}var x,w,L,S,C,z,P,R,O,I,N=this,j=N.layers.plotbg.select("path").node(),F=N.graphDiv,D=N.layers.zoom,B={element:j,gd:F,plotinfo:{plot:D},doubleclick:v,subplot:N.id,prepFn:function(e,r,n){B.xaxes=[N.xaxis],B.yaxes=[N.yaxis];var i=F._fullLayout.dragmode;e.shiftKey&&(i="pan"===i?"zoom":"pan"),"lasso"===i?B.minDrag=1:B.minDrag=void 0,"zoom"===i?(B.moveFn=a,B.doneFn=u,t(e,r,n)):"pan"===i?(B.moveFn=h,B.doneFn=d,f(),p()):"select"!==i&&"lasso"!==i||m(e,r,n,B,i)}};j.onmousemove=function(t){b.hover(F,t,N.id),F._fullLayout._lasthover=j,F._fullLayout._hoversubplot=N.id},j.onmouseout=function(t){F._dragging||g.unhover(F,t)},j.onclick=function(t){b.click(F,t)},g.init(B)}},{"../../components/color":303,"../../components/dragelement":324,"../../components/drawing":326,"../../components/titles":366,"../../lib":382,"../../lib/extend":377,"../../lib/filter_visible":378,"../../plotly":402,"../cartesian/axes":405,"../cartesian/constants":410,"../cartesian/graph_interact":412,"../cartesian/select":418,"../cartesian/set_convert":419,d3:113,tinycolor2:274}],468:[function(t,e,r){"use strict";function n(t){var e;switch(t){case"themes__thumb":e={autosize:!0,width:150,height:150,title:"",showlegend:!1,margin:{l:5,r:5,t:5,b:5,pad:0},annotations:[]};break;case"thumbnail":e={title:"",hidesources:!0,showlegend:!1,borderwidth:0,bordercolor:"",margin:{l:1,r:1,t:1,b:1,pad:0},annotations:[]};break;default:e={}}return e}function i(t){var e=["xaxis","yaxis","zaxis"];return e.indexOf(t.slice(0,5))>-1}var a=t("../plotly"),o=a.Lib.extendFlat,s=a.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var r,l=t.data,c=t.layout,u=s([],l),f=s({},c,n(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var h=Object.keys(f);for(r=0;rl;l++)n(r[l])&&d.push({p:r[l],s:s[l],b:0});return a(e,"marker")&&o(e,e.marker.color,"marker","c"),a(e,"marker.line")&&o(e,e.marker.line.color,"marker.line","c"),d}},{"../../components/colorscale/calc":310,"../../components/colorscale/has_colorscale":316,"../../plots/cartesian/axes":405,"fast-isnumeric":117}],478:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("../scatter/xy_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=a(t,e,u);return f?(u("orientation",e.x&&!e.y?"h":"v"),u("text"),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),void s(t,e,i.defaultLine,{axis:"x",inherit:"y"})):void(e.visible=!1)}},{"../../components/color":303,"../../components/errorbars/defaults":331,"../../lib":382,"../bar/style_defaults":486,"../scatter/xy_defaults":577,"./attributes":476}],479:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../components/errorbars"),a=t("../../components/color");e.exports=function(t,e,r,o){var s,l=t.cd,c=l[0].trace,u=l[0].t,f=t.xa,h=t.ya,d="closest"===o?u.barwidth/2:u.dbar*(1-f._gd._fullLayout.bargap)/2;s="closest"!==o?function(t){return t.p}:"h"===c.orientation?function(t){return t.y}:function(t){return t.x};var p,g;"h"===c.orientation?(p=function(t){return n.inbox(t.b-e,t.x-e)+(t.x-e)/(t.x-t.b)},g=function(t){var e=s(t)-r;return n.inbox(e-d,e+d)}):(g=function(t){return n.inbox(t.b-r,t.y-r)+(t.y-r)/(t.y-t.b)},p=function(t){var r=s(t)-e;return n.inbox(r-d,r+d)});var v=n.getDistanceFunction(o,p,g);if(n.getClosest(l,v,t),t.index!==!1){var m=l[t.index],y=m.mcc||c.marker.color,b=m.mlcc||c.marker.line.color,x=m.mlw||c.marker.line.width;return a.opacity(y)?t.color=y:a.opacity(b)&&x&&(t.color=b),"h"===c.orientation?(t.x0=t.x1=f.c2p(m.x,!0),t.xLabelVal=m.s,t.y0=h.c2p(s(m)-d,!0),t.y1=h.c2p(s(m)+d,!0),t.yLabelVal=m.p):(t.y0=t.y1=h.c2p(m.y,!0),t.yLabelVal=m.s,t.x0=f.c2p(s(m)-d,!0),t.x1=f.c2p(s(m)+d,!0),t.xLabelVal=m.p),m.tx&&(t.text=m.tx),i.hoverInfo(m,c,t),[t]}}},{"../../components/color":303,"../../components/errorbars":332,"../../plots/cartesian/graph_interact":412}],480:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("./layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.calc=t("./calc"),n.setPositions=t("./set_positions"),n.colorbar=t("../scatter/colorbar"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.moduleType="trace",n.name="bar",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","oriented","markerColorscale","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"../scatter/colorbar":559,"./arrays_to_calcdata":475,"./attributes":476,"./calc":477,"./defaults":478,"./hover":479,"./layout_attributes":481,"./layout_defaults":482,"./plot":483,"./set_positions":484,"./style":485}],481:[function(t,e,r){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","group","overlay","relative"],dflt:"group"},barnorm:{valType:"enumerated",values:["","fraction","percent"],dflt:""},bargap:{valType:"number",min:0,max:1},bargroupgap:{valType:"number",min:0,max:1,dflt:0}}},{}],482:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./layout_attributes");e.exports=function(t,e,r){function s(r,n){return a.coerce(t,e,o,r,n)}for(var l=!1,c=!1,u=!1,f={},h=0;h=2?a(t):t>e?Math.ceil(t):Math.floor(t)}var h,d,p,g;if("h"===s.orientation?(p=u.c2p(r.poffset+e.p,!0),g=u.c2p(r.poffset+e.p+r.barwidth,!0),h=c.c2p(e.b,!0),d=c.c2p(e.s+e.b,!0)):(h=c.c2p(r.poffset+e.p,!0),d=c.c2p(r.poffset+e.p+r.barwidth,!0),g=u.c2p(e.s+e.b,!0),p=u.c2p(e.b,!0)),!(i(h)&&i(d)&&i(p)&&i(g)&&h!==d&&p!==g))return void n.select(this).remove();var v=(e.mlw+1||s.marker.line.width+1||(e.trace?e.trace.marker.line.width:0)+1)-1,m=n.round(v/2%1,2);if(!t._context.staticPlot){var y=o.opacity(e.mc||s.marker.color),b=1>y||v>.01?a:l;h=b(h,d),d=b(d,h),p=b(p,g),g=b(g,p)}n.select(this).attr("d","M"+h+","+p+"V"+g+"H"+d+"V"+p+"Z")})}),h.call(s.plot,e)}},{"../../components/color":303,"../../components/errorbars":332,"../../lib":382,"./arrays_to_calcdata":475,d3:113,"fast-isnumeric":117}],484:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/plots"),a=t("../../plots/cartesian/axes"),o=t("../../lib");e.exports=function(t,e){var r,s,l=t._fullLayout,c=e.x(),u=e.y();["v","h"].forEach(function(f){function h(e){function r(t){t[p]=t.p+h}var n=[];e.forEach(function(e){t.calcdata[e].forEach(function(t){n.push(t.p)})});var i=o.distinctVals(n),s=i.vals,c=i.minDiff,u=!1,f=[];"group"===l.barmode&&e.forEach(function(e){u||(t.calcdata[e].forEach(function(t){u||f.forEach(function(e){Math.abs(t.p-e)_&&(S=!0,M=_),_>A+R&&(S=!0,A=_))}a.expand(m,[M,A],{tozero:!0,padded:S})}else{var O=function(t){return t[g]=t.s,t.s};for(r=0;r1||0===s.bargap&&0===s.bargroupgap&&!t[0].trace.marker.line.width)&&n.select(this).attr("shape-rendering","crispEdges")}),e.selectAll("g.points").each(function(t){var e=t[0].trace,r=e.marker,o=r.line,s=(e._input||{}).marker||{},l=a.tryColorscale(r,s,""),c=a.tryColorscale(r,s,"line.");n.select(this).selectAll("path").each(function(t){var e,a,s=(t.mlw+1||o.width+1)-1,u=n.select(this);e="mc"in t?t.mcc=l(t.mc):Array.isArray(r.color)?i.defaultLine:r.color,u.style("stroke-width",s+"px").call(i.fill,e),s&&(a="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(o.color)?i.defaultLine:o.color,u.call(i.stroke,a))})}),e.call(o.style)}},{"../../components/color":303,"../../components/drawing":326,"../../components/errorbars":332,d3:113}],486:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,r,o,s){r("marker.color",o),i(t,"marker")&&a(t,e,s,r,{prefix:"marker.",cLetter:"c"}),r("marker.line.color",n.defaultLine),i(t,"marker.line")&&a(t,e,s,r,{prefix:"marker.line.",cLetter:"c"}),r("marker.line.width")}},{"../../components/color":303,"../../components/colorscale/defaults":313,"../../components/colorscale/has_colorscale":316}],487:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/color/attributes"),a=t("../../lib/extend").extendFlat,o=n.marker,s=o.line;e.exports={y:{valType:"data_array"},x:{valType:"data_array"},x0:{valType:"any"},y0:{valType:"any"},whiskerwidth:{valType:"number",min:0,max:1,dflt:.5},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1},jitter:{valType:"number",min:0,max:1},pointpos:{valType:"number",min:-2,max:2},orientation:{valType:"enumerated",values:["v","h"]},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)"},symbol:a({},o.symbol,{arrayOk:!1}),opacity:a({},o.opacity,{arrayOk:!1,dflt:1}),size:a({},o.size,{arrayOk:!1}),color:a({},o.color,{arrayOk:!1}),line:{color:a({},s.color,{arrayOk:!1,dflt:i.defaultLine}),width:a({},s.width,{arrayOk:!1,dflt:0}),outliercolor:{valType:"color"},outlierwidth:{valType:"number",min:0,dflt:1}}},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2}},fillcolor:n.fillcolor}},{"../../components/color/attributes":302,"../../lib/extend":377,"../scatter/attributes":556}],488:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../../plots/cartesian/axes");e.exports=function(t,e){function r(t,e,r,a,o){var s;return r in e?p=a.makeCalcdata(e,r):(s=r+"0"in e?e[r+"0"]:"name"in e&&("category"===a.type||n(e.name)&&-1!==["linear","log"].indexOf(a.type)||i.isDateTime(e.name)&&"date"===a.type)?e.name:t.numboxes,s=a.d2c(s),p=o.map(function(){ +return s})),p}function o(t,e,r,a,o){var s,l,c,u,f=a.length,h=e.length,d=[],p=[];for(s=0;f>s;++s)l=a[s],t[s]={pos:l},p[s]=l-o,d[s]=[];for(p.push(a[f-1]+o),s=0;h>s;++s)u=e[s],n(u)&&(c=i.findBin(r[s],p),c>=0&&h>c&&d[c].push(u));return d}function s(t,e){var r,n,a,o;for(o=0;o1,m=r.dPos*(1-h.boxgap)*(1-h.boxgroupgap)/(v?t.numboxes:1),y=v?2*r.dPos*(-.5+(r.boxnum+.5)/t.numboxes)*(1-h.boxgap):0,b=m*g.whiskerwidth;return g.visible!==!0||r.emptybox?void a.select(this).remove():("h"===g.orientation?(l=p,f=d):(l=d,f=p),r.bPos=y,r.bdPos=m,n(),a.select(this).selectAll("path.box").data(o.identity).enter().append("path").attr("class","box").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=l.c2p(t.pos+y-b,!0),s=l.c2p(t.pos+y+b,!0),c=f.c2p(t.q1,!0),u=f.c2p(t.q3,!0),h=o.constrain(f.c2p(t.med,!0),Math.min(c,u)+1,Math.max(c,u)-1),d=f.c2p(g.boxpoints===!1?t.min:t.lf,!0),p=f.c2p(g.boxpoints===!1?t.max:t.uf,!0);"h"===g.orientation?a.select(this).attr("d","M"+h+","+r+"V"+n+"M"+c+","+r+"V"+n+"H"+u+"V"+r+"ZM"+c+","+e+"H"+d+"M"+u+","+e+"H"+p+(0===g.whiskerwidth?"":"M"+d+","+i+"V"+s+"M"+p+","+i+"V"+s)):a.select(this).attr("d","M"+r+","+h+"H"+n+"M"+r+","+c+"H"+n+"V"+u+"H"+r+"ZM"+e+","+c+"V"+d+"M"+e+","+u+"V"+p+(0===g.whiskerwidth?"":"M"+i+","+d+"H"+s+"M"+i+","+p+"H"+s))}),g.boxpoints&&a.select(this).selectAll("g.points").data(function(t){return t.forEach(function(t){t.t=r,t.trace=g}),t}).enter().append("g").attr("class","points").selectAll("path").data(function(t){var e,r,n,a,s,l,f,h="all"===g.boxpoints?t.val:t.val.filter(function(e){return et.uf}),d=(t.q3-t.q1)*u,p=[],v=0;if(g.jitter){for(e=0;et.lo&&(n.so=!0),n})}).enter().append("path").call(s.translatePoints,d,p),void(g.boxmean&&a.select(this).selectAll("path.mean").data(o.identity).enter().append("path").attr("class","mean").style("fill","none").each(function(t){var e=l.c2p(t.pos+y,!0),r=l.c2p(t.pos+y-m,!0),n=l.c2p(t.pos+y+m,!0),i=f.c2p(t.mean,!0),o=f.c2p(t.mean-t.sd,!0),s=f.c2p(t.mean+t.sd,!0);"h"===g.orientation?a.select(this).attr("d","M"+i+","+r+"V"+n+("sd"!==g.boxmean?"":"m0,0L"+o+","+e+"L"+i+","+r+"L"+s+","+e+"Z")):a.select(this).attr("d","M"+r+","+i+"H"+n+("sd"!==g.boxmean?"":"m0,0L"+e+","+o+"L"+r+","+i+"L"+e+","+s+"Z"))})))})}},{"../../components/drawing":326,"../../lib":382,d3:113}],495:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("../../plots/cartesian/axes"),a=t("../../lib");e.exports=function(t,e){var r,o,s,l,c=t._fullLayout,u=e.x(),f=e.y(),h=["v","h"];for(o=0;ol&&(e.z=u.slice(0,l)),s("locationmode"),s("text"),s("marker.line.color"),s("marker.line.width"),i(t,e,o,s,{prefix:"",cLetter:"z"}),void s("hoverinfo",1===o._dataLength?"location+z+text":void 0)):void(e.visible=!1)}},{"../../components/colorscale/defaults":313,"../../lib":382,"./attributes":497}],500:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../heatmap/colorbar"),n.calc=t("./calc"),n.plot=t("./plot").plot,n.moduleType="trace",n.name="choropleth",n.basePlotModule=t("../../plots/geo"),n.categories=["geo","noOpacity"],n.meta={},e.exports=n},{"../../plots/geo":426,"../heatmap/colorbar":514,"./attributes":497,"./calc":498,"./defaults":499,"./plot":501}],501:[function(t,e,r){"use strict";function n(t,e){function r(e){var r=t.mockAxis;return o.tickText(r,r.c2l(e),"hover").text}var n=e.hoverinfo;if("none"===n)return function(t){delete t.nameLabel,delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("name"),s=-1!==i.indexOf("location"),l=-1!==i.indexOf("z"),c=-1!==i.indexOf("text"),u=!a&&s;return function(t){var n=[];u?t.nameLabel=t.id:(a&&(t.nameLabel=e.name),s&&n.push(t.id)),l&&n.push(r(t.z)),c&&n.push(t.tx),t.textLabel=n.join("
")}}function i(t){return function(e,r){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:r,location:e.id,z:e.z}]}}}var a=t("d3"),o=t("../../plots/cartesian/axes"),s=t("../../plots/cartesian/graph_interact"),l=t("../../components/color"),c=t("../../components/drawing"),u=t("../../components/colorscale/get_scale"),f=t("../../components/colorscale/make_scale_function"),h=t("../../lib/topojson_utils").getTopojsonFeatures,d=t("../../lib/geo_location_utils").locationToFeature,p=t("../../lib/array_to_calc_item"),g=t("../../plots/geo/constants"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){for(var r,n=[],i=t.locations,a=i.length,o=h(t,e),s=(t.marker||{}).line||{},l=0;a>l;l++)r=d(t.locationmode,i[l],o),void 0!==r&&(r.z=t.z[l],void 0!==t.text&&(r.tx=t.text[l]),p(s.color,r,"mlc",l),p(s.width,r,"mlw",l),n.push(r));return n.length>0&&(n[0].trace=t),n},m.plot=function(t,e,r){var o,l=t.framework,c=l.select("g.choroplethlayer"),u=l.select("g.baselayer"),f=l.select("g.baselayeroverchoropleth"),h=g.baseLayersOverChoropleth,d=c.selectAll("g.trace.choropleth").data(e,function(t){return t.uid});d.enter().append("g").attr("class","trace choropleth"),d.exit().remove(),d.each(function(e){function r(e,r){if(t.showHover){var n=t.projection(e.properties.ct);c(e),s.loneHover({x:n[0],y:n[1],name:e.nameLabel,text:e.textLabel},{container:t.hoverContainer.node()}),f=u(e,r),t.graphDiv.emit("plotly_hover",f)}}function o(e,r){t.graphDiv.emit("plotly_click",u(e,r))}var l=m.calcGeoJSON(e,t.topojson),c=n(t,e),u=i(e),f=null,h=a.select(this).selectAll("path.choroplethlocation").data(l);h.enter().append("path").classed("choroplethlocation",!0).on("mouseover",r).on("click",o).on("mouseout",function(){s.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",f)}).on("mousedown",function(){s.loneUnhover(t.hoverContainer)}).on("mouseup",r),h.exit().remove()}),f.selectAll("*").remove();for(var p=0;pr;r++)e=f[r],d[r]=e[0]*(t.zmax-t.zmin)+t.zmin,p[r]=e[1];var g=n.extent([t.zmin,t.zmax,a.start,a.start+l*(c-1)]),v=g[t.zminr;r++)e=f[r],d[r]=(e[0]*(c+u-1)-u/2)*l+o,p[r]=e[1];var y=n.scale.linear().interpolate(n.interpolateRgb).domain(d).range(p);return y}},{"../../components/colorscale/get_scale":315,d3:113}],509:[function(t,e,r){"use strict";function n(t,e,r){var n=r[0].trace,a=r[0].x,s=r[0].y,c=n.contours,u=n.uid,f=e.x(),h=e.y(),v=t._fullLayout,b="contour"+u,x=i(c,e,r[0]);if(n.visible!==!0)return v._paper.selectAll("."+b+",.hm"+u).remove(),void v._infolayer.selectAll(".cb"+u).remove();"heatmap"===c.coloring?(n.zauto&&n.autocontour===!1&&(n._input.zmin=n.zmin=c.start-c.size/2,n._input.zmax=n.zmax=n.zmin+x.length*c.size),k(t,e,[r])):v._paper.selectAll(".hm"+u).remove(),o(x),l(x);var _=f.c2p(a[0],!0),w=f.c2p(a[a.length-1],!0),A=h.c2p(s[0],!0),M=h.c2p(s[s.length-1],!0),T=[[_,M],[w,M],[w,A],[_,A]],E=d(e,r,b);p(E,T,c),g(E,x,T,c),m(E,x,c),y(E,e,r[0],T)}function i(t,e,r){for(var n=t.size||1,i=[],a=t.start;at?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);if(5===r||10===r){var n=(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4;return t>n?5===r?713:1114:5===r?104:208}return 15===r?0:r}function o(t){var e,r,n,i,o,s,l,c,u,f=t[0].z,h=f.length,d=f[0].length,p=2===h||2===d;for(r=0;h-1>r;r++)for(i=[],0===r&&(i=i.concat(A)),r===h-2&&(i=i.concat(M)),e=0;d-1>e;e++)for(n=i.slice(),0===e&&(n=n.concat(T)),e===d-2&&(n=n.concat(E)),o=e+","+r,s=[[f[r][e],f[r][e+1]],[f[r+1][e],f[r+1][e+1]]],u=0;ui;i++){if(s>20?(s=S[s][(l[0]||l[1])<0?0:1],t.crossings[o]=C[s]):delete t.crossings[o],l=L[s],!l){_.log("Found bad marching index:",s,e,t.level);break}if(d.push(h(t,e,l)),e[0]+=l[0],e[1]+=l[1],u(d[d.length-1],d[d.length-2])&&d.pop(),o=e.join(","),o===a&&l.join(",")===p||r&&(l[0]&&(e[0]<0||e[0]>v-2)||l[1]&&(e[1]<0||e[1]>g-2)))break;s=t.crossings[o]}1e4===i&&_.log("Infinite loop in contour?");var m,y,b,x,w,k,A,M=u(d[0],d[d.length-1]),T=0,E=.2*t.smoothing,z=[],P=0;for(i=1;i=P;i--)if(m=z[i],R>m){for(b=0,y=i-1;y>=P&&m+z[y]b&&m+z[b]e;)e++,r=Object.keys(i.crossings)[0].split(",").map(Number),s(i,r);1e4===e&&_.log("Infinite loop in contour?")}}function c(t,e,r){var n=0,i=0;return t>20&&e?208===t||1114===t?n=0===r[0]?1:-1:i=0===r[1]?1:-1:-1!==A.indexOf(t)?i=1:-1!==T.indexOf(t)?n=1:-1!==M.indexOf(t)?i=-1:n=-1,[n,i]}function u(t,e){return Math.abs(t[0]-e[0])<.01&&Math.abs(t[1]-e[1])<.01}function f(t,e){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function h(t,e,r){var n=e[0]+Math.max(r[0],0),i=e[1]+Math.max(r[1],0),a=t.z[i][n],o=t.xaxis,s=t.yaxis;if(r[1]){var l=(t.level-a)/(t.z[i][n+1]-a);return[o.c2p((1-l)*t.x[n]+l*t.x[n+1],!0),s.c2p(t.y[i],!0)]}var c=(t.level-a)/(t.z[i+1][n]-a);return[o.c2p(t.x[n],!0),s.c2p((1-c)*t.y[i]+c*t.y[i+1],!0)]}function d(t,e,r){var n=t.plot.select(".maplayer").selectAll("g.contour."+r).data(e);return n.enter().append("g").classed("contour",!0).classed(r,!0),n.exit().remove(),n}function p(t,e,r){var n=t.selectAll("g.contourbg").data([0]);n.enter().append("g").classed("contourbg",!0);var i=n.selectAll("path").data("fill"===r.coloring?[0]:[]);i.enter().append("path"),i.exit().remove(),i.attr("d","M"+e.join("L")+"Z").style("stroke","none")}function g(t,e,r,n){var i=t.selectAll("g.contourfill").data([0]);i.enter().append("g").classed("contourfill",!0);var a=i.selectAll("path").data("fill"===n.coloring?e:[]);a.enter().append("path"),a.exit().remove(),a.each(function(t){var e=v(t,r);e?x.select(this).attr("d",e).style("stroke","none"):x.select(this).remove()})}function v(t,e){function r(t){return Math.abs(t[1]-e[0][1])<.01}function n(t){return Math.abs(t[1]-e[2][1])<.01}function i(t){return Math.abs(t[0]-e[0][0])<.01}function a(t){return Math.abs(t[0]-e[2][0])<.01}for(var o,s,l,c,u,f,h=t.edgepaths.length||t.z[0][0]l;l++){if(!o){_.log("Missing end?",d,t);break}for(r(o)&&!a(o)?s=e[1]:i(o)?s=e[0]:n(o)?s=e[3]:a(o)&&(s=e[2]),u=0;u=0&&(s=v,c=u):Math.abs(o[1]-s[1])<.01?Math.abs(o[1]-v[1])<.01&&(v[0]-o[0])*(s[0]-v[0])>=0&&(s=v,c=u):_.log("endpt to newendpt is not vert. or horz.",o,s,v)}if(o=s,c>=0)break;h+="L"+s}if(c===t.edgepaths.length){_.log("unclosed perimeter path");break}d=c,g=-1===p.indexOf(d),g&&(d=p[0],h+="Z")}for(d=0;de;e++)s.push(1);for(e=0;a>e;e++)i.push(s.slice());for(e=0;eo;o++)for(n=i(l,o),u[o]=new Array(n),s=0;n>s;s++)u[o][s]=e(a(l,o,s));return u}function i(t,e,r,n,i,a){var o,s,l,c=[],u=h.traceIs(t,"contour"),f=h.traceIs(t,"histogram"),d=h.traceIs(t,"gl2d"),p=Array.isArray(e)&&e.length>1;if(p&&!f&&"category"!==a.type){e=e.map(a.d2c);var g=e.length;if(!(i>=g))return u?e.slice(0,i):e.slice(0,i+1);if(u||d)c=e.slice(0,i);else if(1===i)c=[e[0]-.5,e[0]+.5];else{for(c=[1.5*e[0]-.5*e[1]],l=1;g>l;l++)c.push(.5*(e[l-1]+e[l]));c.push(1.5*e[g-1]-.5*e[g-2])}if(i>g){var v=c[c.length-1],m=v-c[c.length-2];for(l=g;i>l;l++)v+=m,c.push(v)}}else for(s=n||1,o=Array.isArray(e)&&1===e.length?e[0]:void 0===r?0:f||"category"===a.type?r:a.d2c(r),l=u||d?0:-.5;i>l;l++)c.push(o+s*l);return c}function a(t){return.5-.25*Math.min(1,.5*t)}function o(t,e,r){var n,i,o=1;if(Array.isArray(r))for(n=0;nn&&o>y;n++)o=l(t,e,a(o));return o>y&&u.log("interp2d didn't converge quickly",o),t}function s(t){var e,r,n,i,a,o,s,l,c=[],u={},f=[],h=t[0],d=[],p=[0,0,0],g=m(t);for(r=0;rn;n++)void 0===d[n]&&(o=(void 0!==d[n-1]?1:0)+(void 0!==d[n+1]?1:0)+(void 0!==e[n]?1:0)+(void 0!==h[n]?1:0),o?(0===r&&o++,0===n&&o++,r===t.length-1&&o++,n===d.length-1&&o++,4>o&&(u[[r,n]]=[r,n,o]),c.push([r,n,o])):f.push([r,n]));for(;f.length;){for(s={},l=!1,a=f.length-1;a>=0;a--)i=f[a],r=i[0],n=i[1],o=((u[[r-1,n]]||p)[2]+(u[[r+1,n]]||p)[2]+(u[[r,n-1]]||p)[2]+(u[[r,n+1]]||p)[2])/20,o&&(s[i]=[r,n,o],f.splice(a,1),l=!0);if(!l)throw"findEmpties iterated with no new neighbors";for(i in s)u[i]=s[i],c.push(s[i])}return c.sort(function(t,e){return e[2]-t[2]})}function l(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g,v=0;for(o=0;os;s++)l=b[s],c=t[i+l[0]],c&&(u=c[a+l[1]],void 0!==u&&(0===h?p=g=u:(p=Math.min(p,u),g=Math.max(g,u)),f++,h+=u));if(0===f)throw"iterateInterp2d order is wrong: no defined neighbors";t[i][a]=h/f,void 0===d?4>f&&(v=1):(t[i][a]=(1+r)*t[i][a]-r*d,g>p&&(v=Math.max(v,Math.abs(t[i][a]-d)/(g-p))))}return v}var c=t("fast-isnumeric"),u=t("../../lib"),f=t("../../plots/cartesian/axes"),h=t("../../plots/plots"),d=t("../histogram2d/calc"),p=t("../../components/colorscale/calc"),g=t("./has_columns"),v=t("./convert_column_xyz"),m=t("./max_row_length");e.exports=function(t,e){function r(t){E=e._input.zsmooth=e.zsmooth=!1,u.notifier("cannot fast-zsmooth: "+t)}var a,l,c,y,b,x,_,w,k=f.getFromId(t,e.xaxis||"x"),A=f.getFromId(t,e.yaxis||"y"),M=h.traceIs(e,"contour"),T=h.traceIs(e,"histogram"),E=M?"best":e.zsmooth;if(k._minDtick=0,A._minDtick=0,T){var L=d(t,e);a=L.x,l=L.x0,c=L.dx,y=L.y,b=L.y0,x=L.dy,_=L.z}else g(e)&&v(e,k,A),a=e.x?k.makeCalcdata(e,"x"):[],y=e.y?A.makeCalcdata(e,"y"):[],l=e.x0||0,c=e.dx||1,b=e.y0||0,x=e.dy||1,_=n(e),(M||e.connectgaps)&&(e._emptypoints=s(_),e._interpz=o(_,e._emptypoints,e._interpz));if("fast"===E)if("log"===k.type||"log"===A.type)r("log axis found");else if(!T){if(a.length){var S=(a[a.length-1]-a[0])/(a.length-1),C=Math.abs(S/100);for(w=0;wC){r("x scale is not linear"); +break}}if(y.length&&"fast"===E){var z=(y[y.length-1]-y[0])/(y.length-1),P=Math.abs(z/100);for(w=0;wP){r("y scale is not linear");break}}}var R=m(_),O="scaled"===e.xtype?"":e.x,I=i(e,O,l,c,R,k),N="scaled"===e.ytype?"":e.y,j=i(e,N,b,x,_.length,A);f.expand(k,I),f.expand(A,j);var F={x:I,y:j,z:_};if(p(e,_,"","z"),M&&e.contours&&"heatmap"===e.contours.coloring){var D="contour"===e.type?"heatmap":"histogram2d";F.xfill=i(D,O,l,c,R,k),F.yfill=i(D,N,b,x,_.length,A)}return[F]};var y=.01,b=[[-1,0],[1,0],[0,-1],[0,1]]},{"../../components/colorscale/calc":310,"../../lib":382,"../../plots/cartesian/axes":405,"../../plots/plots":454,"../histogram2d/calc":533,"./convert_column_xyz":515,"./has_columns":517,"./max_row_length":520,"fast-isnumeric":117}],514:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c="cb"+r.uid,u=s(r.colorscale),f=r.zmin,h=r.zmax;if(i(f)||(f=a.aggNums(Math.min,null,r.z)),i(h)||(h=a.aggNums(Math.max,null,r.z)),t._fullLayout._infolayer.selectAll("."+c).remove(),!r.showscale)return void o.autoMargin(t,c);var d=e[0].t.cb=l(t,c);d.fillcolor(n.scale.linear().domain(u.map(function(t){return f+t[0]*(h-f)})).range(u.map(function(t){return t[1]}))).filllevels({start:f,end:h,size:(h-f)/254}).options(r.colorbar)()}},{"../../components/colorbar/draw":306,"../../components/colorscale/get_scale":315,"../../lib":382,"../../plots/plots":454,d3:113,"fast-isnumeric":117}],515:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a=t.x.slice(),o=t.y.slice(),s=t.z,l=t.text,c=Math.min(a.length,o.length,s.length),u=void 0!==l&&!Array.isArray(l[0]);for(ci;i++)a[i]=e.d2c(a[i]),o[i]=r.d2c(o[i]);var f,h,d,p=n.distinctVals(a),g=p.vals,v=n.distinctVals(o),m=v.vals,y=n.init2dArray(m.length,g.length);for(u&&(d=n.init2dArray(m.length,g.length)),i=0;c>i;i++)f=n.findBin(a[i]+p.minDiff/2,g),h=n.findBin(o[i]+v.minDiff/2,m),y[h][f]=s[i],u&&(d[h][f]=l[i]);t.x=g,t.y=m,t.z=y,u&&(t.text=d)}},{"../../lib":382}],516:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./has_columns"),a=t("./xyz_defaults"),o=t("../../components/colorscale/defaults"),s=t("./attributes");e.exports=function(t,e,r,l){function c(r,i){return n.coerce(t,e,s,r,i)}var u=a(t,e,c);return u?(c("text"),c("zsmooth"),c("connectgaps",i(e)&&e.zsmooth!==!1),void o(t,e,l,c,{prefix:"",cLetter:"z"})):void(e.visible=!1)}},{"../../components/colorscale/defaults":313,"../../lib":382,"./attributes":512,"./has_columns":517,"./xyz_defaults":523}],517:[function(t,e,r){"use strict";e.exports=function(t){return!Array.isArray(t.z[0])}},{}],518:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/graph_interact"),i=t("../../lib"),a=t("../../plots/cartesian/constants").MAXDIST;e.exports=function(t,e,r,o,s){if(!(t.distanceu||u>=y[0].length||0>f||f>y.length)return}else{if(n.inbox(e-v[0],e-v[v.length-1])>a||n.inbox(r-m[0],r-m[m.length-1])>a)return;if(s){var k;for(x=[2*v[0]-v[1]],k=1;k0;)_=v.c2p(C[M]),M--;for(x>_&&(w=_,_=x,x=w,N=!0),M=0;void 0===k&&M0;)A=m.c2p(z[M]),M--;if(k>A&&(w=k,k=A,A=w,j=!0),P&&(C=r[0].xfill,z=r[0].yfill),"fast"!==R){var F="best"===R?0:.5;x=Math.max(-F*v._length,x),_=Math.min((1+F)*v._length,_),k=Math.max(-F*m._length,k),A=Math.min((1+F)*m._length,A)}var D=Math.round(_-x),B=Math.round(A-k),U=0>=D||0>=B,V=e.plot.select(".imagelayer").selectAll("g.hm."+b).data(U?[]:[0]);if(V.enter().append("g").classed("hm",!0).classed(b,!0),V.exit().remove(),!U){var q,H;"fast"===R?(q=I,H=O):(q=D,H=B);var G=document.createElement("canvas");G.width=q,G.height=H;var Y,X,W=G.getContext("2d"),Z=i.scale.linear().domain(S.map(function(t){return t[0]})).range(S.map(function(t){var e=a(t[1]).toRgb();return[e.r,e.g,e.b,e.a]})).clamp(!0);"fast"===R?(Y=N?function(t){return I-1-t}:o.identity,X=j?function(t){return O-1-t}:o.identity):(Y=function(t){return o.constrain(Math.round(v.c2p(C[t])-x),0,D)},X=function(t){return o.constrain(Math.round(m.c2p(z[t])-k),0,B)});var K,$,Q,J,tt,et,rt=X(0),nt=[rt,rt],it=N?0:1,at=j?0:1,ot=0,st=0,lt=0,ct=0;if(R){var ut=0,ft=new Uint8Array(D*B*4);if("best"===R){var ht,dt,pt,gt=new Array(C.length),vt=new Array(z.length),mt=new Array(D);for(M=0;MM;M++)mt[M]=n(M,gt);for($=0;B>$;$++)for(ht=n($,vt),dt=T[ht.bin0],pt=T[ht.bin1],M=0;D>M;M++,ut+=4)et=d(dt,pt,mt[M],ht),h(ft,ut,et)}else for($=0;O>$;$++)for(tt=T[$],nt=X($),M=0;D>M;M++)et=f(tt[M],1),ut=4*(nt*D+Y(M)),h(ft,ut,et);var yt=W.createImageData(D,B);yt.data.set(ft),W.putImageData(yt,0,0)}else for($=0;O>$;$++)if(tt=T[$],nt.reverse(),nt[at]=X($+1),nt[0]!==nt[1]&&void 0!==nt[0]&&void 0!==nt[1])for(Q=Y(0),K=[Q,Q],M=0;I>M;M++)K.reverse(),K[it]=Y(M+1),K[0]!==K[1]&&void 0!==K[0]&&void 0!==K[1]&&(J=tt[M],et=f(J,(K[1]-K[0])*(nt[1]-nt[0])),W.fillStyle="rgba("+et.join(",")+")",W.fillRect(K[0],nt[0],K[1]-K[0],nt[1]-nt[0]));st=Math.round(st/ot),lt=Math.round(lt/ot),ct=Math.round(ct/ot);var bt=a("rgb("+st+","+lt+","+ct+")");t._hmpixcount=(t._hmpixcount||0)+ot,t._hmlumcount=(t._hmlumcount||0)+ot*bt.getLuminance();var xt=V.selectAll("image").data(r);xt.enter().append("svg:image").attr({xmlns:c.svg,preserveAspectRatio:"none"}),xt.attr({height:B,width:D,x:x,y:k,"xlink:href":G.toDataURL("image/png")}),xt.exit().remove()}}var i=t("d3"),a=t("tinycolor2"),o=t("../../lib"),s=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),c=t("../../constants/xmlns_namespaces"),u=t("./max_row_length");e.exports=function(t,e,r){for(var i=0;i0&&(n=!0);for(var s=0;si;i++)e[i]?(t[i]/=e[i],n+=t[i]):t[i]=null;return n}},{}],526:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){return r("histnorm"),n.forEach(function(t){var e=r(t+"bins.start"),n=r(t+"bins.end"),i=r("autobin"+t,!(e&&n));r(i?"nbins"+t:t+"bins.size")}),e}},{}],527:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports={count:function(t,e,r){return r[t]++,1},sum:function(t,e,r,i){var a=i[e];return n(a)?(a=Number(a),r[t]+=a,a):0},avg:function(t,e,r,i,a){var o=i[e];return n(o)&&(o=Number(o),r[t]+=o,a[t]++),0},min:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]>a)return r[t]=a,a-r[t]}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]r&&c.length<5e3;)g=a.tickIncrement(r,b.size),c.push((r+g)/2),u.push(S),x&&_.push(r),E&&w.push(1/(g-r)),P&&k.push(0),r=g;var R=u.length;for(r=0;r=0&&R>m&&(A+=C(m,r,u,y,k));P&&(A=l(u,k)),z&&z(u,A,w);var O=Math.min(c.length,u.length),I=[],N=0,j=O-1;for(r=0;O>r;r++)if(u[r]){N=r;break}for(r=O-1;r>N;r--)if(u[r]){j=r;break}for(r=N;j>=r;r++)n(c[r])&&n(u[r])&&I.push({p:c[r],s:u[r],b:0});return I}}},{"../../lib":382,"../../plots/cartesian/axes":405,"./average":525,"./bin_functions":527,"./norm_functions":531,"fast-isnumeric":117}],529:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/color"),a=t("./bin_defaults"),o=t("../bar/style_defaults"),s=t("../../components/errorbars/defaults"),l=t("./attributes");e.exports=function(t,e,r,c){function u(r,i){return n.coerce(t,e,l,r,i)}var f=u("x"),h=u("y");u("text");var d=u("orientation",h&&!f?"h":"v"),p=e["v"===d?"x":"y"];if(!p||!p.length)return void(e.visible=!1);var g=e["h"===d?"x":"y"];g&&u("histfunc");var v="h"===d?["y"]:["x"];a(t,e,u,v),o(t,e,u,r,c),s(t,e,i.defaultLine,{axis:"y"}),s(t,e,i.defaultLine,{axis:"x",inherit:"y"})}},{"../../components/color":303,"../../components/errorbars/defaults":331,"../../lib":382,"../bar/style_defaults":486,"./attributes":524,"./bin_defaults":526}],530:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.layoutAttributes=t("../bar/layout_attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("../bar/layout_defaults"),n.calc=t("./calc"),n.setPositions=t("../bar/set_positions"),n.plot=t("../bar/plot"),n.style=t("../bar/style"),n.colorbar=t("../scatter/colorbar"),n.hoverPoints=t("../bar/hover"),n.moduleType="trace",n.name="histogram",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","bar","histogram","oriented","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"../bar/hover":479,"../bar/layout_attributes":481,"../bar/layout_defaults":482,"../bar/plot":483,"../bar/set_positions":484,"../bar/style":485,"../scatter/colorbar":559,"./attributes":524,"./calc":528,"./defaults":529}],531:[function(t,e,r){"use strict";e.exports={percent:function(t,e){for(var r=t.length,n=100/e,i=0;r>i;i++)t[i]*=n},probability:function(t,e){for(var r=t.length,n=0;r>n;n++)t[n]/=e},density:function(t,e,r,n){var i=t.length;n=n||1;for(var a=0;i>a;a++)t[a]*=r[a]*n},"probability density":function(t,e,r,n){var i=t.length;n&&(e/=n);for(var a=0;i>a;a++)t[a]*=r[a]/e}}},{}],532:[function(t,e,r){"use strict";var n=t("../histogram/attributes"),i=t("../heatmap/attributes"),a=t("../../components/colorscale/attributes"),o=t("../../lib/extend").extendFlat;e.exports=o({},{x:n.x,y:n.y,z:{valType:"data_array"},marker:{color:{valType:"data_array"}},histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,zsmooth:i.zsmooth,_nestedModules:{colorbar:"Colorbar"}},a,{autocolorscale:o({},a.autocolorscale,{dflt:!1})})},{"../../components/colorscale/attributes":309,"../../lib/extend":377,"../heatmap/attributes":512,"../histogram/attributes":524}],533:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("../histogram/bin_functions"),o=t("../histogram/norm_functions"),s=t("../histogram/average");e.exports=function(t,e){var r,l,c,u,f,h,d=i.getFromId(t,e.xaxis||"x"),p=e.x?d.makeCalcdata(e,"x"):[],g=i.getFromId(t,e.yaxis||"y"),v=e.y?g.makeCalcdata(e,"y"):[],m=Math.min(p.length,v.length);p.length>m&&p.splice(m,p.length-m),v.length>m&&v.splice(m,v.length-m),!e.autobinx&&"xbins"in e||(e.xbins=i.autoBin(p,d,e.nbinsx,"2d"),"histogram2dcontour"===e.type&&(e.xbins.start-=e.xbins.size,e.xbins.end+=e.xbins.size),e._input.xbins=e.xbins),!e.autobiny&&"ybins"in e||(e.ybins=i.autoBin(v,g,e.nbinsy,"2d"),"histogram2dcontour"===e.type&&(e.ybins.start-=e.ybins.size,e.ybins.end+=e.ybins.size),e._input.ybins=e.ybins),f=[];var y,b,x=[],_=[],w="string"==typeof e.xbins.size?[]:e.xbins,k="string"==typeof e.xbins.size?[]:e.ybins,A=0,M=[],T=e.histnorm,E=e.histfunc,L=-1!==T.indexOf("density"),S="max"===E||"min"===E,C=S?null:0,z=a.count,P=o[T],R=!1,O=[],I=[],N="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";N&&"count"!==E&&(R="avg"===E,z=a[E]);var j=e.xbins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6;for(h=j.start;F>h;h=i.tickIncrement(h,j.size))x.push(C),Array.isArray(w)&&w.push(h),R&&_.push(0);Array.isArray(w)&&w.push(h);var D=x.length;for(r=e.xbins.start,l=(h-r)/D,r+=l/2,j=e.ybins,F=j.end+(j.start-i.tickIncrement(j.start,j.size))/1e6,h=j.start;F>h;h=i.tickIncrement(h,j.size))f.push(x.concat()),Array.isArray(k)&&k.push(h),R&&M.push(_.concat());Array.isArray(k)&&k.push(h);var B=f.length;for(c=e.ybins.start,u=(h-c)/B,c+=u/2,L&&(O=x.map(function(t,e){return Array.isArray(w)?1/(w[e+1]-w[e]):1/l}),I=f.map(function(t,e){return Array.isArray(k)?1/(k[e+1]-k[e]):1/u})),h=0;m>h;h++)y=n.findBin(p[h],w),b=n.findBin(v[h],k),y>=0&&D>y&&b>=0&&B>b&&(A+=z(y,h,f[b],N,M[b]));if(R)for(b=0;B>b;b++)A+=s(f[b],M[b]);if(P)for(b=0;B>b;b++)P(f[b],A,O,I[b]);return{x:p,x0:r,dx:l,y:v,y0:c,dy:u,z:f}}},{"../../lib":382,"../../plots/cartesian/axes":405,"../histogram/average":525,"../histogram/bin_functions":527,"../histogram/norm_functions":531}],534:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./sample_defaults"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r){function s(r,i){return n.coerce(t,e,o,r,i)}i(t,e,s),s("zsmooth"),a(t,e,r,s,{prefix:"",cLetter:"z"})}},{"../../components/colorscale/defaults":313,"../../lib":382,"./attributes":532,"./sample_defaults":536}],535:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../heatmap/calc"),n.plot=t("../heatmap/plot"),n.colorbar=t("../heatmap/colorbar"),n.style=t("../heatmap/style"),n.hoverPoints=t("../heatmap/hover"),n.moduleType="trace",n.name="histogram2d",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"../heatmap/calc":513,"../heatmap/colorbar":514,"../heatmap/hover":518,"../heatmap/plot":521,"../heatmap/style":522,"./attributes":532,"./defaults":534}],536:[function(t,e,r){"use strict";var n=t("../histogram/bin_defaults");e.exports=function(t,e,r){var i=r("x"),a=r("y");if(!(i&&i.length&&a&&a.length))return void(e.visible=!1);var o=r("z")||r("marker.color");o&&r("histfunc");var s=["x","y"];n(t,e,r,s)}},{"../histogram/bin_defaults":526}],537:[function(t,e,r){"use strict";var n=t("../histogram2d/attributes"),i=t("../contour/attributes"),a=t("../../components/colorscale/attributes"),o=t("../../lib/extend").extendFlat;e.exports=o({},{x:n.x,y:n.y,z:n.z,marker:n.marker,histnorm:n.histnorm,histfunc:n.histfunc,autobinx:n.autobinx,nbinsx:n.nbinsx,xbins:n.xbins,autobiny:n.autobiny,nbinsy:n.nbinsy,ybins:n.ybins,autocontour:i.autocontour,ncontours:i.ncontours,contours:i.contours,line:i.line,_nestedModules:{colorbar:"Colorbar"}},a)},{"../../components/colorscale/attributes":309,"../../lib/extend":377,"../contour/attributes":502,"../histogram2d/attributes":532}],538:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../histogram2d/sample_defaults"),a=t("../contour/style_defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,i){return n.coerce(t,e,o,r,i)}i(t,e,l);var c=n.coerce2(t,e,o,"contours.start"),u=n.coerce2(t,e,o,"contours.end"),f=l("autocontour",!(c&&u));l(f?"ncontours":"contours.size"),a(t,e,l,s)}},{"../../lib":382,"../contour/style_defaults":511,"../histogram2d/sample_defaults":536,"./attributes":537}],539:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.calc=t("../contour/calc"),n.plot=t("../contour/plot"),n.style=t("../contour/style"),n.colorbar=t("../contour/colorbar"),n.hoverPoints=t("../contour/hover"),n.moduleType="trace",n.name="histogram2dcontour",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","2dMap","contour","histogram"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"../contour/calc":503,"../contour/colorbar":504,"../contour/hover":506,"../contour/plot":509,"../contour/style":510,"./attributes":537,"./defaults":538}],540:[function(t,e,r){"use strict";var n=t("../../components/colorscale/attributes"),i=t("../surface/attributes"),a=t("../../lib/extend").extendFlat;e.exports={x:{valType:"data_array"},y:{valType:"data_array"},z:{valType:"data_array"},i:{valType:"data_array"},j:{valType:"data_array"},k:{valType:"data_array"},delaunayaxis:{valType:"enumerated",values:["x","y","z"],dflt:"z"},alphahull:{valType:"number",dflt:-1},intensity:{valType:"data_array"},color:{valType:"color"},vertexcolor:{valType:"data_array"},facecolor:{valType:"data_array"},opacity:a({},i.opacity),flatshading:{valType:"boolean",dflt:!1},contour:{show:a({},i.contours.x.show,{}),color:a({},i.contours.x.color),width:a({},i.contours.x.width)},colorscale:n.colorscale,reversescale:n.reversescale,showscale:n.showscale,lightposition:{x:a({},i.lightposition.x,{dflt:1e5}),y:a({},i.lightposition.y,{dflt:1e5}),z:a({},i.lightposition.z,{dflt:0})},lighting:a({},{vertexnormalsepsilon:{valType:"number",min:0,max:1,dflt:1e-12},facenormalsepsilon:{valType:"number",min:0,max:1,dflt:1e-6}},i.lighting),_nestedModules:{colorbar:"Colorbar"}}},{"../../components/colorscale/attributes":309,"../../lib/extend":377,"../surface/attributes":601}],541:[function(t,e,r){"use strict";function n(t,e,r){this.scene=t,this.uid=r,this.mesh=e,this.name="",this.color="#fff",this.data=null,this.showContour=!1}function i(t){return t.map(function(t){var e=t[0],r=c(t[1]),n=r.toRgb();return{index:e,rgb:[n.r,n.g,n.b,1]}})}function a(t){return t.map(d)}function o(t,e,r){for(var n=new Array(t.length),i=0;i0)s=f(t.alphahull,l);else{var c=["x","y","z"].indexOf(t.delaunayaxis);s=u(l.map(function(t){return[t[(c+1)%3],t[(c+2)%3]]}))}var p={positions:l,cells:s,lightPosition:[t.lightposition.x,t.lightposition.y,t.lightposition.z],ambient:t.lighting.ambient,diffuse:t.lighting.diffuse,specular:t.lighting.specular,roughness:t.lighting.roughness,fresnel:t.lighting.fresnel,vertexNormalsEpsilon:t.lighting.vertexnormalsepsilon,faceNormalsEpsilon:t.lighting.facenormalsepsilon,opacity:t.opacity,contourEnable:t.contour.show,contourColor:d(t.contour.color).slice(0,3),contourWidth:t.contour.width,useFacetNormals:t.flatshading};t.intensity?(this.color="#fff",p.vertexIntensity=t.intensity,p.colormap=i(t.colorscale)):t.vertexcolor?(this.color=t.vertexcolors[0],p.vertexColors=a(t.vertexcolor)):t.facecolor?(this.color=t.facecolor[0],p.cellColors=a(t.facecolor)):(this.color=t.color,p.meshColor=d(t.color)),this.mesh.update(p)},p.dispose=function(){this.scene.glplot.remove(this.mesh),this.mesh.dispose()},e.exports=s},{"../../lib/str2rgbarray":394,"alpha-shape":40,"convex-hull":102,"delaunay-triangulate":114,"gl-mesh3d":150,tinycolor2:274}],542:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../components/colorbar/defaults"),a=t("./attributes");e.exports=function(t,e,r,o){function s(r,i){return n.coerce(t,e,a,r,i)}function l(t){var e=t.map(function(t){var e=s(t);return e&&Array.isArray(e)?e:null});return e.every(function(t){return t&&t.length===e[0].length})&&e}var c=l(["x","y","z"]),u=l(["i","j","k"]);return c?(u&&u.forEach(function(t){for(var e=0;el||(c=p[r],void 0!==c&&""!==c||(c=r),c=String(c),void 0===y[c]&&(y[c]=!0,u=a(e.marker.colors[r]),u.isValid()?(u=o.addOpacity(u,u.getAlpha()),m[c]||(m[c]=u)):m[c]?u=m[c]:(u=!1,b=!0),f=-1!==_.indexOf(c),f||(x+=l),g.push({v:l,label:c,color:u,i:r,hidden:f}))));if(e.sort&&g.sort(function(t,e){return e.v-t.v}),b)for(r=0;r")}return g};var l},{"../../components/color":303,"./helpers":548,"fast-isnumeric":117,tinycolor2:274}],547:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(r,a){return n.coerce(t,e,i,r,a)}var s=n.coerceFont,l=o("values");if(!Array.isArray(l)||!l.length)return void(e.visible=!1);var c=o("labels");Array.isArray(c)||(o("label0"),o("dlabel"));var u=o("marker.line.width");u&&o("marker.line.color");var f=o("marker.colors");Array.isArray(f)||(e.marker.colors=[]),o("scalegroup");var h=o("text"),d=o("textinfo",Array.isArray(h)?"text+percent":"percent");if(o("hoverinfo",1===a._dataLength?"label+text+value+percent":void 0),d&&"none"!==d){var p=o("textposition"),g=Array.isArray(p)||"auto"===p,v=g||"inside"===p,m=g||"outside"===p;if(v||m){var y=s(o,"textfont",a.font);v&&s(o,"insidetextfont",y),m&&s(o,"outsidetextfont",y)}}o("domain.x"),o("domain.y"),o("hole"),o("sort"),o("direction"),o("rotation"),o("pull")}},{"../../lib":382,"./attributes":544}],548:[function(t,e,r){"use strict";var n=t("../../lib");r.formatPiePercent=function(t,e){var r=(100*t).toPrecision(3);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)+"%"},r.formatPieValue=function(t,e){var r=t.toPrecision(10);return-1!==r.lastIndexOf(".")&&(r=r.replace(/[.]?0+$/,"")),n.numSeparate(r,e)}},{"../../lib":382}],549:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.supplyLayoutDefaults=t("./layout_defaults"),n.layoutAttributes=t("./layout_attributes"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.styleOne=t("./style_one"),n.moduleType="trace",n.name="pie",n.basePlotModule=t("./base_plot"),n.categories=["pie","showLegend"],n.meta={},e.exports=n},{"./attributes":544,"./base_plot":545,"./calc":546,"./defaults":547,"./layout_attributes":550,"./layout_defaults":551,"./plot":552,"./style":553,"./style_one":554}],550:[function(t,e,r){"use strict";e.exports={hiddenlabels:{valType:"data_array"}}},{}],551:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e){function r(r,a){return n.coerce(t,e,i,r,a)}r("hiddenlabels")}},{"../../lib":382,"./layout_attributes":550}],552:[function(t,e,r){"use strict";function n(t,e,r){var n=Math.sqrt(t.width*t.width+t.height*t.height),a=t.width/t.height,o=Math.PI*Math.min(e.v/r.vTotal,.5),s=1-r.trace.hole,l=i(e,r),c={scale:l*r.r*2/n,rCenter:1-l,rotate:0};if(c.scale>=1)return c;var u=a+1/(2*Math.tan(o)),f=r.r*Math.min(1/(Math.sqrt(u*u+.5)+u),s/(Math.sqrt(a*a+s/2)+a)),h={scale:2*f/t.height,rCenter:Math.cos(f/r.r)-f*a/r.r,rotate:(180/Math.PI*e.midangle+720)%180-90},d=1/a,p=d+1/(2*Math.tan(o)),g=r.r*Math.min(1/(Math.sqrt(p*p+.5)+p),s/(Math.sqrt(d*d+s/2)+d)),v={scale:2*g/t.width,rCenter:Math.cos(g/r.r)-g/a/r.r, +rotate:(180/Math.PI*e.midangle+810)%180-90},m=v.scale>h.scale?v:h;return c.scale<1&&m.scale>c.scale?m:c}function i(t,e){if(t.v===e.vTotal&&!e.trace.hole)return 1;var r=Math.PI*Math.min(t.v/e.vTotal,.5);return Math.min(1/(1+1/Math.sin(r)),(1-e.trace.hole)/2)}function a(t,e){var r=e.pxmid[0],n=e.pxmid[1],i=t.width/2,a=t.height/2;return 0>r&&(i*=-1),0>n&&(a*=-1),{scale:1,rCenter:1,rotate:0,x:i+Math.abs(a)*(i>0?1:-1)/2,y:a/(1+r*r/(n*n)),outside:!0}}function o(t,e){function r(t,e){return t.pxmid[1]-e.pxmid[1]}function n(t,e){return e.pxmid[1]-t.pxmid[1]}function i(t,r){r||(r={});var n,i,a,s,h,d,g=r.labelExtraY+(o?r.yLabelMax:r.yLabelMin),v=o?t.yLabelMin:t.yLabelMax,m=o?t.yLabelMax:t.yLabelMin,y=t.cyFinal+c(t.px0[1],t.px1[1]),b=g-v;if(b*f>0&&(t.labelExtraY=b),Array.isArray(e.pull))for(i=0;i=e.pull[a.i]||((t.pxmid[1]-a.pxmid[1])*f>0?(s=a.cyFinal+c(a.px0[1],a.px1[1]),b=s-v-t.labelExtraY,b*f>0&&(t.labelExtraY+=b)):(m+t.labelExtraY-y)*f>0&&(n=3*u*Math.abs(i-p.indexOf(t)),h=a.cxFinal+l(a.px0[0],a.px1[0]),d=h+n-(t.cxFinal+t.pxmid[0])-t.labelExtraX,d*u>0&&(t.labelExtraX+=d)))}var a,o,s,l,c,u,f,h,d,p,g,v,m;for(o=0;2>o;o++)for(s=o?r:n,c=o?Math.max:Math.min,f=o?1:-1,a=0;2>a;a++){for(l=a?Math.max:Math.min,u=a?1:-1,h=t[o][a],h.sort(s),d=t[1-o][a],p=d.concat(h),v=[],g=0;gu&&(u=s.pull[a]);o.r=Math.min(r/c(s.tilt,Math.sin(l),s.depth),n/c(s.tilt,Math.cos(l),s.depth))/(2+2*u),o.cx=e.l+e.w*(s.domain.x[1]+s.domain.x[0])/2,o.cy=e.t+e.h*(2-s.domain.y[1]-s.domain.y[0])/2,s.scalegroup&&-1===d.indexOf(s.scalegroup)&&d.push(s.scalegroup)}for(a=0;af.vTotal/2?1:0)}function c(t,e,r){if(!t)return 1;var n=Math.sin(t*Math.PI/180);return Math.max(.01,r*n*Math.abs(e)+2*Math.sqrt(1-n*n*e*e))}var u=t("d3"),f=t("../../plots/cartesian/graph_interact"),h=t("../../components/color"),d=t("../../components/drawing"),p=t("../../lib/svg_text_utils"),g=t("./helpers");e.exports=function(t,e){var r=t._fullLayout;s(e,r._size);var c=r._pielayer.selectAll("g.trace").data(e);c.enter().append("g").attr({"stroke-linejoin":"round","class":"trace"}),c.exit().remove(),c.order(),c.each(function(e){var s=u.select(this),c=e[0],v=c.trace,m=0,y=(v.depth||0)*c.r*Math.sin(m)/2,b=v.tiltaxis||0,x=b*Math.PI/180,_=[y*Math.sin(x),y*Math.cos(x)],w=c.r*Math.cos(m),k=s.selectAll("g.part").data(v.tilt?["top","sides"]:["top"]);k.enter().append("g").attr("class",function(t){return t+" part"}),k.exit().remove(),k.order(),l(e),s.selectAll(".top").each(function(){var s=u.select(this).selectAll("g.slice").data(e);s.enter().append("g").classed("slice",!0),s.exit().remove();var l=[[[],[]],[[],[]]],m=!1;s.each(function(o){function s(e){var n=t._fullLayout,a=t._fullData[v.index],s=a.hoverinfo;if("all"===s&&(s="label+text+value+percent+name"),!t._dragging&&n.hovermode!==!1&&"none"!==s&&s){var l=i(o,c),u=k+o.pxmid[0]*(1-l),h=A+o.pxmid[1]*(1-l),d=r.separators,p=[];-1!==s.indexOf("label")&&p.push(o.label),a.text&&a.text[o.i]&&-1!==s.indexOf("text")&&p.push(a.text[o.i]),-1!==s.indexOf("value")&&p.push(g.formatPieValue(o.v,d)),-1!==s.indexOf("percent")&&p.push(g.formatPiePercent(o.v/c.vTotal,d)),f.loneHover({x0:u-l*c.r,x1:u+l*c.r,y:h,text:p.join("
"),name:-1!==s.indexOf("name")?a.name:void 0,color:o.color,idealAlign:o.pxmid[0]<0?"left":"right"},{container:n._hoverlayer.node(),outerContainer:n._paper.node()}),f.hover(t,e,"pie"),E=!0}}function h(e){t.emit("plotly_unhover",{points:[e]}),E&&(f.loneUnhover(r._hoverlayer.node()),E=!1)}function y(){t._hoverdata=[o],t._hoverdata.trace=e.trace,f.click(t,{target:!0})}function x(t,e,r,n){return"a"+n*c.r+","+n*w+" "+b+" "+o.largeArc+(r?" 1 ":" 0 ")+n*(e[0]-t[0])+","+n*(e[1]-t[1])}if(o.hidden)return void u.select(this).selectAll("path,g").remove();l[o.pxmid[1]<0?0:1][o.pxmid[0]<0?0:1].push(o);var k=c.cx+_[0],A=c.cy+_[1],M=u.select(this),T=M.selectAll("path.surface").data([o]),E=!1;if(T.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),M.select("path.textline").remove(),M.on("mouseover",s).on("mouseout",h).on("click",y),v.pull){var L=+(Array.isArray(v.pull)?v.pull[o.i]:v.pull)||0;L>0&&(k+=L*o.pxmid[0],A+=L*o.pxmid[1])}o.cxFinal=k,o.cyFinal=A;var S=v.hole;if(o.v===c.vTotal){var C="M"+(k+o.px0[0])+","+(A+o.px0[1])+x(o.px0,o.pxmid,!0,1)+x(o.pxmid,o.px0,!0,1)+"Z";S?T.attr("d","M"+(k+S*o.px0[0])+","+(A+S*o.px0[1])+x(o.px0,o.pxmid,!1,S)+x(o.pxmid,o.px0,!1,S)+"Z"+C):T.attr("d",C)}else{var z=x(o.px0,o.px1,!0,1);if(S){var P=1-S;T.attr("d","M"+(k+S*o.px1[0])+","+(A+S*o.px1[1])+x(o.px1,o.px0,!1,S)+"l"+P*o.px0[0]+","+P*o.px0[1]+z+"Z")}else T.attr("d","M"+k+","+A+"l"+o.px0[0]+","+o.px0[1]+z+"Z")}var R=Array.isArray(v.textposition)?v.textposition[o.i]:v.textposition,O=M.selectAll("g.slicetext").data(o.text&&"none"!==R?[0]:[]);O.enter().append("g").classed("slicetext",!0),O.exit().remove(),O.each(function(){var t=u.select(this).selectAll("text").data([0]);t.enter().append("text").attr("data-notex",1),t.exit().remove(),t.text(o.text).attr({"class":"slicetext",transform:"","data-bb":"","text-anchor":"middle",x:0,y:0}).call(d.font,"outside"===R?v.outsidetextfont:v.insidetextfont).call(p.convertToTspans),t.selectAll("tspan.line").attr({x:0,y:0});var e,r=d.bBox(t.node());"outside"===R?e=a(r,o):(e=n(r,o,c),"auto"===R&&e.scale<1&&(t.call(d.font,v.outsidetextfont),v.outsidetextfont.family===v.insidetextfont.family&&v.outsidetextfont.size===v.insidetextfont.size||(t.attr({"data-bb":""}),r=d.bBox(t.node())),e=a(r,o)));var i=k+o.pxmid[0]*e.rCenter+(e.x||0),s=A+o.pxmid[1]*e.rCenter+(e.y||0);e.outside&&(o.yLabelMin=s-r.height/2,o.yLabelMid=s,o.yLabelMax=s+r.height/2,o.labelExtraX=0,o.labelExtraY=0,m=!0),t.attr("transform","translate("+i+","+s+")"+(e.scale<1?"scale("+e.scale+")":"")+(e.rotate?"rotate("+e.rotate+")":"")+"translate("+-(r.left+r.right)/2+","+-(r.top+r.bottom)/2+")")})}),m&&o(l,v),s.each(function(t){if(t.labelExtraX||t.labelExtraY){var e=u.select(this),r=e.select("g.slicetext text");r.attr("transform","translate("+t.labelExtraX+","+t.labelExtraY+")"+r.attr("transform"));var n=t.cxFinal+t.pxmid[0],i=t.cyFinal+t.pxmid[1],a="M"+n+","+i,o=(t.yLabelMax-t.yLabelMin)*(t.pxmid[0]<0?-1:1)/4;if(t.labelExtraX){var s=t.labelExtraX*t.pxmid[1]/t.pxmid[0],l=t.yLabelMid+t.labelExtraY-(t.cyFinal+t.pxmid[1]);a+=Math.abs(s)>Math.abs(l)?"l"+l*t.pxmid[0]/t.pxmid[1]+","+l+"H"+(n+t.labelExtraX+o):"l"+t.labelExtraX+","+s+"v"+(l-s)+"h"+o}else a+="V"+(t.yLabelMid+t.labelExtraY)+"h"+o;e.append("path").classed("textline",!0).call(h.stroke,v.outsidetextfont.color).attr({"stroke-width":Math.min(2,v.outsidetextfont.size/8),d:a,fill:"none"})}})})}),setTimeout(function(){c.selectAll("tspan").each(function(){var t=u.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":303,"../../components/drawing":326,"../../lib/svg_text_utils":395,"../../plots/cartesian/graph_interact":412,"./helpers":548,d3:113}],553:[function(t,e,r){"use strict";var n=t("d3"),i=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0],r=e.trace,a=n.select(this);a.style({opacity:r.opacity}),a.selectAll(".top path.surface").each(function(t){n.select(this).call(i,t,r)})})}},{"./style_one":554,d3:113}],554:[function(t,e,r){"use strict";var n=t("../../components/color");e.exports=function(t,e,r){var i=r.marker.line.color;Array.isArray(i)&&(i=i[e.i]||n.defaultLine);var a=r.marker.line.width||0;Array.isArray(a)&&(a=a[e.i]||0),t.style({"stroke-width":a,fill:e.color}).call(n.stroke,i)}},{"../../components/color":303}],555:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t){var e=t[0].trace,r=e.marker;if(n.mergeArray(e.text,t,"tx"),n.mergeArray(e.textposition,t,"tp"),e.textfont&&(n.mergeArray(e.textfont.size,t,"ts"),n.mergeArray(e.textfont.color,t,"tc"),n.mergeArray(e.textfont.family,t,"tf")),r&&r.line){var i=r.line;n.mergeArray(r.opacity,t,"mo"),n.mergeArray(r.symbol,t,"mx"),n.mergeArray(r.color,t,"mc"),n.mergeArray(i.color,t,"mlc"),n.mergeArray(i.width,t,"mlw")}}},{"../../lib":382}],556:[function(t,e,r){"use strict";var n=t("../../components/colorscale/color_attributes"),i=t("../../components/drawing"),a=(t("./constants"),t("../../lib/extend").extendFlat);e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},hoveron:{valType:"flaglist",flags:["points","fills"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number",min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:a({},{symbol:{valType:"enumerated",values:i.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number",dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},showscale:{valType:"boolean",dflt:!1},line:a({},{width:{valType:"number",min:0,arrayOk:!0}},n("marker.line"))},n("marker")),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:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":311,"../../components/drawing":326,"../../lib/extend":377,"./constants":561}],557:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./subtypes"),s=t("./colorscale_calc");e.exports=function(t,e){var r,l,c,u=i.getFromId(t,e.xaxis||"x"),f=i.getFromId(t,e.yaxis||"y"),h=u.makeCalcdata(e,"x"),d=f.makeCalcdata(e,"y"),p=Math.min(h.length,d.length);u._minDtick=0,f._minDtick=0,h.length>p&&h.splice(p,h.length-p),d.length>p&&d.splice(p,d.length-p);var g={padded:!0},v={padded:!0};if(o.hasMarkers(e)){if(r=e.marker,l=r.size,Array.isArray(l)){var m={type:"linear"};i.setConvert(m),l=m.makeCalcdata(e.marker,"size"),l.length>p&&l.splice(p,l.length-p)}var y,b=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/b),3)}:function(t){return Math.max((t||0)/b,3)},g.ppad=v.ppad=Array.isArray(l)?l.map(y):y(l)}s(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||h[0]===h[p-1]&&d[0]===d[p-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(o.hasMarkers(e)||o.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||h[0]===h[p-1]&&d[0]===d[p-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(v.padded=!1):v.tozero=!0,i.expand(u,h,g),i.expand(f,d,v);var x=new Array(p);for(c=0;p>c;c++)x[c]=n(h[c])&&n(d[c])?{x:h[c],y:d[c]}:{x:!1,y:!1};return void 0!==typeof l&&a.mergeArray(l,x,"ms"),t.firstscatter=!1,x}},{"../../lib":382,"../../plots/cartesian/axes":405,"./colorscale_calc":560,"./subtypes":575,"fast-isnumeric":117}],558:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i,a;for(e=0;e=0;i--)if(a=t[i],"scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}},{}],559:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,c=r.marker,u="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void o.autoMargin(t,u);var f=s(c.colorscale),h=c.color,d=c.cmin,p=c.cmax;i(d)||(d=a.aggNums(Math.min,null,h)),i(p)||(p=a.aggNums(Math.max,null,h));var g=e[0].t.cb=l(t,u);g.fillcolor(n.scale.linear().domain(f.map(function(t){return d+t[0]*(p-d)})).range(f.map(function(t){return t[1]}))).filllevels({start:d,end:p,size:(p-d)/254}).options(c.colorbar)()}},{"../../components/colorbar/draw":306,"../../components/colorscale/get_scale":315,"../../lib":382,"../../plots/plots":454,d3:113,"fast-isnumeric":117}],560:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("./subtypes");e.exports=function(t){a.hasLines(t)&&n(t,"line")&&i(t,t.line.color,"line","c"),a.hasMarkers(t)&&(n(t,"marker")&&i(t,t.marker.color,"marker","c"),n(t,"marker.line")&&i(t,t.marker.line.color,"marker.line","c"))}},{"../../components/colorscale/calc":310,"../../components/colorscale/has_colorscale":316,"./subtypes":575}],561:[function(t,e,r){"use strict";e.exports={PTS_LINESONLY:20}},{}],562:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("./constants"),o=t("./subtypes"),s=t("./xy_defaults"),l=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),h=t("./fillcolor_defaults"),d=t("../../components/errorbars/defaults");e.exports=function(t,e,r,p){function g(r,a){return n.coerce(t,e,i,r,a)}var v=s(t,e,g),m=vU!=R>=U&&(C=L[T-1][0],z=L[T][0],S=C+(z-C)*(U-P)/(R-P),j=Math.min(j,S),F=Math.max(F,S));j=Math.max(j,0),F=Math.min(F,h._length);var V=l.defaultLine;return l.opacity(f.fillcolor)?V=f.fillcolor:l.opacity((f.line||{}).color)&&(V=f.line.color),n.extendFlat(t,{distance:a.MAXDIST+10,x0:j,x1:F,y0:U,y1:U,color:V}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":303,"../../components/errorbars":332,"../../lib":382,"../../plots/cartesian/constants":410,"../../plots/cartesian/graph_interact":412,"./get_trace_color":564}],566:[function(t,e,r){"use strict";var n={},i=t("./subtypes");n.hasLines=i.hasLines,n.hasMarkers=i.hasMarkers,n.hasText=i.hasText,n.isBubble=i.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.cleanData=t("./clean_data"),n.calc=t("./calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./colorbar"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","symbols","markerColorscale","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":413,"./arrays_to_calcdata":555,"./attributes":556,"./calc":557,"./clean_data":558,"./colorbar":559,"./defaults":562,"./hover":565,"./plot":572,"./select":573,"./style":574,"./subtypes":575}],567:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,a,o){var s=(t.marker||{}).color;o("line.color",r),n(t,"line")?i(t,e,a,o,{prefix:"line.",cLetter:"c"}):o("line.color",(Array.isArray(s)?!1:s)||r),o("line.width"),o("line.dash")}},{"../../components/colorscale/defaults":313,"../../components/colorscale/has_colorscale":316}],568:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes");e.exports=function(t,e){function r(e){var r=w.c2p(t[e].x),n=k.c2p(t[e].y);return r===L||n===L?!1:[r,n]}function i(t){var e=t[0]/w._length,r=t[1]/k._length;return(1+10*Math.max(0,-e,e-1,-r,r-1))*M}function a(t,e){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}var o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w=e.xaxis,k=e.yaxis,A=e.connectGaps,M=e.baseTolerance,T=e.linear,E=[],L=n.BADNUM,S=.2,C=new Array(t.length),z=0;for(o=0;oi(f))break;l=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,c=f,d=!1):m>y&&(m=y,u=f,d=!0)}if(d?(C[z++]=c,l!==u&&(C[z++]=u)):(u!==s&&(C[z++]=u),l!==c&&(C[z++]=c)),C[z++]=l,o>=t.length||!f)break;C[z++]=f,s=f}}else C[z++]=c}E.push(C.slice(0,z))}return E}},{"../../plots/cartesian/axes":405}],569:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=r("line.shape");"spline"===n&&r("line.smoothing")}},{}],570:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t){var e=t.marker,r=e.sizeref||1,i=e.sizemin||0,a="area"===e.sizemode?function(t){return Math.sqrt(t/r)}:function(t){return t/r};return function(t){var e=a(t/2);return n(e)&&e>0?Math.max(e,i):0}}},{"fast-isnumeric":117}],571:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l){var c,u=o.isBubble(t),f=Array.isArray(t.line)?void 0:(t.line||{}).color;f&&(r=f),l("marker.symbol"),l("marker.opacity",u?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),c=f&&e.marker.color!==f?f:u?n.background:n.defaultLine,l("marker.line.color",c),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",u?1:0),u&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode"))}},{"../../components/color":303,"../../components/colorscale/defaults":313,"../../components/colorscale/has_colorscale":316,"./subtypes":575}],572:[function(t,e,r){"use strict";function n(t,e,r){var n=e.x(),a=e.y(),o=i.extent(n.range.map(n.l2c)),s=i.extent(a.range.map(a.l2c));r.forEach(function(t,e){var n=t[0].trace;if(c.hasMarkers(n)){var i=n.marker.maxdisplayed;if(0!==i){var a=t.filter(function(t){return t.x>=o[0]&&t.x<=o[1]&&t.y>=s[0]&&t.y<=s[1]}),l=Math.ceil(a.length/i),u=0;r.forEach(function(t,r){var n=t[0].trace;c.hasMarkers(n)&&n.marker.maxdisplayed>0&&e>r&&u++});var f=Math.round(u*l/3+Math.floor(u/3)*l/7.1);t.forEach(function(t){delete t.vis}),a.forEach(function(t,e){0===Math.round((e+f)%l)&&(t.vis=!0)})}}})}var i=t("d3"),a=t("../../lib"),o=t("../../components/drawing"),s=t("../../components/errorbars"),l=t("../../lib/polygon").tester,c=t("./subtypes"),u=t("./arrays_to_calcdata"),f=t("./line_points");e.exports=function(t,e,r){function h(t){return t.filter(function(t){return t.vis})}n(t,e,r);var d=e.x(),p=e.y(),g=e.plot.select(".scatterlayer").selectAll("g.trace.scatter").data(r);g.enter().append("g").attr("class","trace scatter").style("stroke-miterlimit",2),g.call(s.plot,e);var v,m,y,b,x="",_=[];g.each(function(t){var e=t[0].trace,r=e.line,n=i.select(this);if(e.visible===!0&&(m=e.fill.charAt(e.fill.length-1),"x"!==m&&"y"!==m&&(m=""),t[0].node3=n,u(t),c.hasLines(e)||"none"!==e.fill)){var a,s,h,g,w,k="",A="";v="tozero"===e.fill.substr(0,6)||"toself"===e.fill||"to"===e.fill.substr(0,2)&&!x?n.append("path").classed("js-fill",!0):null,b&&(y=b.datum(t)),b=n.append("path").classed("js-fill",!0),-1!==["hv","vh","hvh","vhv"].indexOf(r.shape)?(h=o.steps(r.shape),g=o.steps(r.shape.split("").reverse().join(""))):h=g="spline"===r.shape?function(t){var e=t[t.length-1];return t[0][0]===e[0]&&t[0][1]===e[1]?o.smoothclosed(t.slice(1),r.smoothing):o.smoothopen(t,r.smoothing)}:function(t){return"M"+t.join("L")},w=function(t){return g(t.reverse())};var M,T=f(t,{xaxis:d,yaxis:p,connectGaps:e.connectgaps,baseTolerance:Math.max(r.width||1,3)/4,linear:"linear"===r.shape}),E=e._polygons=new Array(T.length);for(M=0;M1&&n.append("path").classed("js-line",!0).attr("d",a)}v?L&&C&&(m?("y"===m?L[1]=C[1]=p.c2p(0,!0):"x"===m&&(L[0]=C[0]=d.c2p(0,!0)),v.attr("d",k+"L"+C+"L"+L+"Z")):v.attr("d",k+"Z")):"tonext"===e.fill.substr(0,6)&&k&&x&&("tonext"===e.fill?y.attr("d",k+"Z"+x+"Z"):y.attr("d",k+"L"+x.substr(1)+"Z"),e._polygons=e._polygons.concat(_)),x=A,_=E}}}),g.selectAll("path:not([d])").remove(),g.append("g").attr("class","points").each(function(t){var e=t[0].trace,r=i.select(this),n=c.hasMarkers(e),s=c.hasText(e);!n&&!s||e.visible!==!0?r.remove():(n&&r.selectAll("path.point").data(e.marker.maxdisplayed?h:a.identity).enter().append("path").classed("point",!0).call(o.translatePoints,d,p),s&&r.selectAll("g").data(e.marker.maxdisplayed?h:a.identity).enter().append("g").append("text").call(o.translatePoints,d,p))})}},{"../../components/drawing":326,"../../components/errorbars":332,"../../lib":382,"../../lib/polygon":388,"./arrays_to_calcdata":555,"./line_points":568,"./subtypes":575,d3:113}],573:[function(t,e,r){"use strict";var n=t("./subtypes"),i=.2;e.exports=function(t,e){var r,a,o,s,l=t.cd,c=t.xaxis,u=t.yaxis,f=[],h=l[0].trace,d=h.index,p=h.marker,g=!n.hasMarkers(h)&&!n.hasText(h);if(h.visible===!0&&!g){var v=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(r=0;rs;s++){for(var l=[[0,0,0],[0,0,0]],c=0;3>c;c++)if(r[c])for(var u=0;2>u;u++)l[u][c]=r[c][s][u];o[s]=l}return o}var o=t("../../components/errorbars/compute_error");e.exports=a},{"../../components/errorbars/compute_error":330}],581:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.linePlot=null,this.scatterPlot=null,this.errorBars=null,this.textMarkers=null,this.delaunayMesh=null,this.color=null,this.mode="",this.dataPoints=[],this.axesBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.textLabels=null,this.data=null}function i(t,e,r){var n,i=(r+1)%3,a=(r+2)%3,o=[],s=[];for(n=0;ni;i++){var a=t[i];a&&a.copy_zstyle!==!1&&(a=t[2]),a&&(e[i]=a.width/2,r[i]=b(a.color),n=a.thickness)}return{capSize:e,color:r,lineWidth:n}}function o(t){var e=[0,0];return Array.isArray(t)?[0,-1]:(t.indexOf("bottom")>=0&&(e[1]+=1),t.indexOf("top")>=0&&(e[1]-=1),t.indexOf("left")>=0&&(e[0]-=1),t.indexOf("right")>=0&&(e[0]+=1),e)}function s(t,e){return e(4*t)}function l(t){return k[t]}function c(t,e,r,n,i){var a=null;if(Array.isArray(t)){a=[];for(var o=0;e>o;o++)void 0===t[o]?a[o]=n:a[o]=r(t[o],i)}else a=r(t,y.identity);return a}function u(t,e){var r,n,i,u,f,h,d=[],p=t.fullSceneLayout,g=t.dataScale,v=p.xaxis,m=p.yaxis,w=p.zaxis,k=e.marker,M=e.line,T=e.x||[],E=e.y||[],L=e.z||[],S=T.length;for(n=0;S>n;n++)i=v.d2l(T[n])*g[0],u=m.d2l(E[n])*g[1],f=w.d2l(L[n])*g[2],d[n]=[i,u,f];if(Array.isArray(e.text))h=e.text;else if(void 0!==e.text)for(h=new Array(S),n=0;S>n;n++)h[n]=e.text;if(r={position:d,mode:e.mode,text:h},"line"in e&&(r.lineColor=x(M,1,S),r.lineWidth=M.width,r.lineDashes=M.dash),"marker"in e){var C=_(e);r.scatterColor=x(k,1,S),r.scatterSize=c(k.size,S,s,20,C),r.scatterMarker=c(k.symbol,S,l,"\u25cf"),r.scatterLineWidth=k.line.width,r.scatterLineColor=x(k.line,1,S),r.scatterAngle=0}"textposition"in e&&(r.textOffset=o(e.textposition),r.textColor=x(e.textfont,1,S),r.textSize=c(e.textfont.size,S,y.identity,12),r.textFont=e.textfont.family,r.textAngle=0);var z=["x","y","z"];for(r.project=[!1,!1,!1],r.projectScale=[1,1,1],r.projectOpacity=[1,1,1],n=0;3>n;++n){var P=e.projection[z[n]];(r.project[n]=P.show)&&(r.projectOpacity[n]=P.opacity,r.projectScale[n]=P.scale); +}r.errorBounds=A(e,g);var R=a([e.error_x,e.error_y,e.error_z]);return r.errorColor=R.color,r.errorLineWidth=R.lineWidth,r.errorCapSize=R.capSize,r.delaunayAxis=e.surfaceaxis,r.delaunayColor=b(e.surfacecolor),r}function f(t){if(Array.isArray(t)){var e=t[0];return Array.isArray(e)&&(t=e),"rgb("+t.slice(0,3).map(function(t){return Math.round(255*t)})+")"}return null}function h(t,e){var r=new n(t,e.uid);return r.update(e),r}var d=t("gl-line3d"),p=t("gl-scatter3d"),g=t("gl-error3d"),v=t("gl-mesh3d"),m=t("delaunay-triangulate"),y=t("../../lib"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/make_bubble_size_func"),w=t("../../constants/gl3d_dashes"),k=t("../../constants/gl_markers"),A=t("./calc_errors"),M=n.prototype;M.handlePick=function(t){if(t.object&&(t.object===this.linePlot||t.object===this.delaunayMesh||t.object===this.textMarkers||t.object===this.scatterPlot)){t.object.highlight&&t.object.highlight(null),this.scatterPlot&&(t.object=this.scatterPlot,this.scatterPlot.highlight(t.data)),this.textLabels&&void 0!==this.textLabels[t.data.index]?t.textLabel=this.textLabels[t.data.index]:t.textLabel="";var e=t.data.index;return t.traceCoordinate=[this.data.x[e],this.data.y[e],this.data.z[e]],!0}},M.update=function(t){var e,r,n,a,o=this.scene.glplot.gl,s=w.solid;this.data=t;var l=u(this.scene,t);"mode"in l&&(this.mode=l.mode),"lineDashes"in l&&l.lineDashes in w&&(s=w[l.lineDashes]),this.color=f(l.scatterColor)||f(l.lineColor),this.dataPoints=l.position,e={gl:o,position:l.position,color:l.lineColor,lineWidth:l.lineWidth||1,dashes:s[0],dashScale:s[1],opacity:t.opacity,connectGaps:t.connectgaps},-1!==this.mode.indexOf("lines")?this.linePlot?this.linePlot.update(e):(this.linePlot=d(e),this.scene.glplot.add(this.linePlot)):this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose(),this.linePlot=null);var c=t.opacity;if(t.marker&&t.marker.opacity&&(c*=t.marker.opacity),r={gl:o,position:l.position,color:l.scatterColor,size:l.scatterSize,glyph:l.scatterMarker,opacity:c,orthographic:!0,lineWidth:l.scatterLineWidth,lineColor:l.scatterLineColor,project:l.project,projectScale:l.projectScale,projectOpacity:l.projectOpacity},-1!==this.mode.indexOf("markers")?this.scatterPlot?this.scatterPlot.update(r):(this.scatterPlot=p(r),this.scatterPlot.highlightScale=1,this.scene.glplot.add(this.scatterPlot)):this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose(),this.scatterPlot=null),a={gl:o,position:l.position,glyph:l.text,color:l.textColor,size:l.textSize,angle:l.textAngle,alignment:l.textOffset,font:l.textFont,orthographic:!0,lineWidth:0,project:!1,opacity:t.opacity},this.textLabels=l.text,-1!==this.mode.indexOf("text")?this.textMarkers?this.textMarkers.update(a):(this.textMarkers=p(a),this.textMarkers.highlightScale=1,this.scene.glplot.add(this.textMarkers)):this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose(),this.textMarkers=null),n={gl:o,position:l.position,color:l.errorColor,error:l.errorBounds,lineWidth:l.errorLineWidth,capSize:l.errorCapSize,opacity:t.opacity},this.errorBars?l.errorBounds?this.errorBars.update(n):(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose(),this.errorBars=null):l.errorBounds&&(this.errorBars=g(n),this.scene.glplot.add(this.errorBars)),l.delaunayAxis>=0){var h=i(l.position,l.delaunayColor,l.delaunayAxis);h.opacity=t.opacity,this.delaunayMesh?this.delaunayMesh.update(h):(h.gl=o,this.delaunayMesh=v(h),this.scene.glplot.add(this.delaunayMesh))}else this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose(),this.delaunayMesh=null)},M.dispose=function(){this.linePlot&&(this.scene.glplot.remove(this.linePlot),this.linePlot.dispose()),this.scatterPlot&&(this.scene.glplot.remove(this.scatterPlot),this.scatterPlot.dispose()),this.errorBars&&(this.scene.glplot.remove(this.errorBars),this.errorBars.dispose()),this.textMarkers&&(this.scene.glplot.remove(this.textMarkers),this.textMarkers.dispose()),this.delaunayMesh&&(this.scene.glplot.remove(this.delaunayMesh),this.delaunayMesh.dispose())},e.exports=h},{"../../constants/gl3d_dashes":368,"../../constants/gl_markers":369,"../../lib":382,"../../lib/gl_format_color":380,"../../lib/str2rgbarray":394,"../scatter/make_bubble_size_func":570,"./calc_errors":580,"delaunay-triangulate":114,"gl-error3d":121,"gl-line3d":127,"gl-mesh3d":150,"gl-scatter3d":193}],582:[function(t,e,r){"use strict";function n(t,e,r){var n=0,i=r("x"),a=r("y"),o=r("z");return i&&a&&o&&(n=Math.min(i.length,a.length,o.length),n=0&&h("surfacecolor",p||g);for(var v=["x","y","z"],m=0;3>m;++m){var y="projection."+v[m];h(y+".show")&&(h(y+".opacity"),h(y+".scale"))}c(t,e,r,{axis:"z"}),c(t,e,r,{axis:"y",inherit:"z"}),c(t,e,r,{axis:"x",inherit:"z"})}},{"../../components/errorbars/defaults":331,"../../lib":382,"../scatter/line_defaults":567,"../scatter/marker_defaults":571,"../scatter/subtypes":575,"../scatter/text_defaults":576,"./attributes":578}],583:[function(t,e,r){"use strict";var n={};n.plot=t("./convert"),n.attributes=t("./attributes"),n.markerSymbols=t("../../constants/gl_markers"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.moduleType="trace",n.name="scatter3d",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../constants/gl_markers":369,"../../plots/gl3d":441,"../scatter/colorbar":559,"./attributes":578,"./calc":579,"./convert":581,"./defaults":582}],584:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../plots/attributes"),a=t("../../components/colorscale/color_attributes"),o=t("../../lib/extend").extendFlat,s=n.marker,l=n.line,c=s.line;e.exports={lon:{valType:"data_array"},lat:{valType:"data_array"},locations:{valType:"data_array"},locationmode:{valType:"enumerated",values:["ISO-3","USA-states","country names"],dflt:"ISO-3"},mode:o({},n.mode,{dflt:"markers"}),text:o({},n.text,{}),line:{color:l.color,width:l.width,dash:l.dash},marker:o({},{symbol:s.symbol,opacity:s.opacity,size:s.size,sizeref:s.sizeref,sizemin:s.sizemin,sizemode:s.sizemode,showscale:s.showscale,line:o({},{width:c.width},a("marker.line"))},a("marker")),textfont:n.textfont,textposition:n.textposition,hoverinfo:o({},i.hoverinfo,{flags:["lon","lat","location","text","name"]}),_nestedModules:{"marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":311,"../../lib/extend":377,"../../plots/attributes":403,"../scatter/attributes":556}],585:[function(t,e,r){"use strict";var n=t("../scatter/colorscale_calc");e.exports=function(t,e){var r=[{x:!1,y:!1,trace:e,t:{}}];return n(e),r}},{"../scatter/colorscale_calc":560}],586:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=0,o=r("locations");return o?(r("locationmode"),a=o.length):(n=r("lon")||[],i=r("lat")||[],a=Math.min(n.length,i.length),an;n++)r[n]=[t.lon[n],t.lat[n]];return{type:"LineString",coordinates:r,trace:t}}function a(t,e){function r(e){var r=t.mockAxis;return c.tickText(r,r.c2l(e),"hover").text+"\xb0"}var n=e.hoverinfo;if("none"===n)return function(t){delete t.textLabel};var i="all"===n?v.hoverinfo.flags:n.split("+"),a=-1!==i.indexOf("location")&&Array.isArray(e.locations),o=-1!==i.indexOf("lon"),s=-1!==i.indexOf("lat"),l=-1!==i.indexOf("text");return function(t){var n=[];a?n.push(t.location):o&&s?n.push("("+r(t.lon)+", "+r(t.lat)+")"):o?n.push("lon: "+r(t.lon)):s&&n.push("lat: "+r(t.lat)),l&&n.push(t.tx||e.text),t.textLabel=n.join("
")}}function o(t){var e=Array.isArray(t.locations);return function(r,n){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:n,lon:r.lon,lat:r.lat,location:e?r.location:null}]}}}var s=t("d3"),l=t("../../plots/cartesian/graph_interact"),c=t("../../plots/cartesian/axes"),u=t("../../lib/topojson_utils").getTopojsonFeatures,f=t("../../lib/geo_location_utils").locationToFeature,h=t("../../lib/array_to_calc_item"),d=t("../../components/color"),p=t("../../components/drawing"),g=t("../scatter/subtypes"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){var r,i,a,o,s=[],l=Array.isArray(t.locations);l?(o=t.locations,r=o.length,i=u(t,e),a=function(t,e){var r=f(t.locationmode,o[e],i);return void 0!==r?r.properties.ct:void 0}):(r=t.lon.length,a=function(t,e){return[t.lon[e],t.lat[e]]});for(var c=0;r>c;c++){var h=a(t,c);if(h){var d={lon:h[0],lat:h[1],location:l?t.locations[c]:null};n(t,d,c),s.push(d)}}return s.length>0&&(s[0].trace=t),s},m.plot=function(t,e){var r=t.framework.select(".scattergeolayer").selectAll("g.trace.scattergeo").data(e,function(t){return t.uid});r.enter().append("g").attr("class","trace scattergeo"),r.exit().remove(),r.selectAll("*").remove(),r.each(function(t){var e=s.select(this);g.hasLines(t)&&e.selectAll("path.js-line").data([i(t)]).enter().append("path").classed("js-line",!0)}),r.each(function(e){function r(r,n){if(t.showHover){var i=t.projection([r.lon,r.lat]);h(r),l.loneHover({x:i[0],y:i[1],name:v?e.name:void 0,text:r.textLabel,color:r.mc||(e.marker||{}).color},{container:t.hoverContainer.node()}),y=d(r,n),t.graphDiv.emit("plotly_hover",y)}}function n(e,r){t.graphDiv.emit("plotly_click",d(e,r))}var i=s.select(this),c=g.hasMarkers(e),u=g.hasText(e);if(c||u){var f=m.calcGeoJSON(e,t.topojson),h=a(t,e),d=o(e),p=e.hoverinfo,v="all"===p||-1!==p.indexOf("name"),y=null;c&&i.selectAll("path.point").data(f).enter().append("path").classed("point",!0).on("mouseover",r).on("click",n).on("mouseout",function(){l.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",y)}).on("mousedown",function(){l.loneUnhover(t.hoverContainer)}).on("mouseup",r),u&&i.selectAll("g").data(f).enter().append("g").append("text")}}),m.style(t)},m.style=function(t){var e=t.framework.selectAll("g.trace.scattergeo");e.style("opacity",function(t){return t.opacity}),e.each(function(t){s.select(this).selectAll("path.point").call(p.pointStyle,t),s.select(this).selectAll("text").call(p.textPointStyle,t)}),e.selectAll("path.js-line").style("fill","none").each(function(t){var e=t.trace,r=e.line||{};s.select(this).call(d.stroke,r.color).call(p.dashLine,r.dash||"",r.width||0)})}},{"../../components/color":303,"../../components/drawing":326,"../../lib/array_to_calc_item":373,"../../lib/geo_location_utils":379,"../../lib/topojson_utils":396,"../../plots/cartesian/axes":405,"../../plots/cartesian/graph_interact":412,"../scatter/subtypes":575,"./attributes":584,d3:113}],589:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/colorscale/color_attributes"),a=t("../../constants/gl2d_dashes"),o=t("../../constants/gl_markers"),s=t("../../lib/extend").extendFlat,l=t("../../lib/extend").extendDeep,c=n.line,u=n.marker,f=u.line;e.exports={x:n.x,x0:n.x0,dx:n.dx,y:n.y,y0:n.y0,dy:n.dy,text:s({},n.text,{}),mode:{valType:"flaglist",flags:["lines","markers"],extras:["none"]},line:{color:c.color,width:c.width,dash:{valType:"enumerated",values:Object.keys(a),dflt:"solid"}},marker:l({},i("marker"),{symbol:{valType:"enumerated",values:Object.keys(o),dflt:"circle",arrayOk:!0},size:u.size,sizeref:u.sizeref,sizemin:u.sizemin,sizemode:u.sizemode,opacity:u.opacity,showscale:u.showscale,line:l({},i("marker.line"),{width:f.width})}),connectgaps:n.connectgaps,fill:s({},n.fill,{values:["none","tozeroy","tozerox"]}),fillcolor:n.fillcolor,_nestedModules:{error_x:"ErrorBars",error_y:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":311,"../../constants/gl2d_dashes":367,"../../constants/gl_markers":369,"../../lib/extend":377,"../scatter/attributes":556}],590:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.pickXData=[],this.pickYData=[],this.xData=[],this.yData=[],this.textLabels=[],this.color="rgb(0, 0, 0)",this.name="",this.hoverinfo="all",this.connectgaps=!0,this.idToIndex=[],this.bounds=[0,0,0,0],this.hasLines=!1,this.lineOptions={positions:new Float32Array(0),color:[0,0,0,1],width:1,fill:[!1,!1,!1,!1],fillColor:[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],dashes:[1]},this.line=d(t.glplot,this.lineOptions),this.line._trace=this,this.hasErrorX=!1,this.errorXOptions={positions:new Float32Array(0),errors:new Float32Array(0),lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorX=p(t.glplot,this.errorXOptions),this.errorX._trace=this,this.hasErrorY=!1,this.errorYOptions={positions:new Float32Array(0),errors:new Float32Array(0),lineWidth:1,capSize:0,color:[0,0,0,1]},this.errorY=p(t.glplot,this.errorYOptions),this.errorY._trace=this,this.hasMarkers=!1,this.scatterOptions={positions:new Float32Array(0),sizes:[],colors:[],glyphs:[],borderWidths:[],borderColors:[],size:12,color:[0,0,0,1],borderSize:1,borderColor:[0,0,0,1]},this.scatter=f(t.glplot,this.scatterOptions),this.scatter._trace=this,this.fancyScatter=h(t.glplot,this.scatterOptions),this.fancyScatter._trace=this}function i(t,e,r){return Array.isArray(e)||(e=[e]),a(t,e,r)}function a(t,e,r){for(var n=new Array(r),i=e[0],a=0;r>a;++a)n[a]=t(a>=e.length?i:e[a]);return n}function o(t,e,r){return l(S(t,r),L(e,r),r)}function s(t,e,r,n){var i=x(t,e,n);return i=Array.isArray(i[0])?i:a(v.identity,[i],n),l(i,L(r,n),n)}function l(t,e,r){for(var n=new Array(4*r),i=0;r>i;++i){for(var a=0;3>a;++a)n[4*i+a]=t[i][a];n[4*i+3]=t[i][3]*e[i]}return n}function c(t,e){if(void 0===Float32Array.slice){for(var r=new Float32Array(e),n=0;e>n;n++)r[n]=t[n];return r}return t.slice(0,e)}function u(t,e){var r=new n(t,e.uid);return r.update(e),r}var f=t("gl-scatter2d"),h=t("gl-scatter2d-fancy"),d=t("gl-line2d"),p=t("gl-error2d"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../plots/cartesian/axes"),y=t("../../components/errorbars"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/subtypes"),w=t("../scatter/make_bubble_size_func"),k=t("../scatter/get_trace_color"),A=t("../../constants/gl_markers"),M=t("../../constants/gl2d_dashes"),T=["xaxis","yaxis"],E=n.prototype;E.handlePick=function(t){var e=t.pointId;return(t.object!==this.line||this.connectgaps)&&(e=this.idToIndex[t.pointId]),{trace:this,dataCoord:t.dataCoord,traceCoord:[this.pickXData[e],this.pickYData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:Array.isArray(this.color)?this.color[e]:this.color,name:this.name,hoverinfo:this.hoverinfo}},E.isFancy=function(t){if("linear"!==this.scene.xaxis.type)return!0;if("linear"!==this.scene.yaxis.type)return!0;if(!t.x||!t.y)return!0;if(this.hasMarkers){var e=t.marker||{};if(Array.isArray(e.symbol)||"circle"!==e.symbol||Array.isArray(e.size)||Array.isArray(e.color)||Array.isArray(e.line.width)||Array.isArray(e.line.color)||Array.isArray(e.opacity))return!0}return this.hasLines&&!this.connectgaps?!0:this.hasErrorX?!0:!!this.hasErrorY};var L=i.bind(null,function(t){return+t}),S=i.bind(null,b),C=i.bind(null,function(t){return A[t]||"\u25cf"});E.update=function(t){t.visible!==!0?(this.hasLines=!1,this.hasErrorX=!1,this.hasErrorY=!1,this.hasMarkers=!1):(this.hasLines=_.hasLines(t),this.hasErrorX=t.error_x.visible===!0,this.hasErrorY=t.error_y.visible===!0,this.hasMarkers=_.hasMarkers(t)),this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.connectgaps=!!t.connectgaps,this.isFancy(t)?this.updateFancy(t):this.updateFast(t),this.color=k(t,{})},E.updateFast=function(t){for(var e,r,n=this.xData=this.pickXData=t.x,i=this.yData=this.pickYData=t.y,a=n.length,o=new Array(a),s=new Float32Array(2*a),l=this.bounds,u=0,f=0,h=0;a>h;++h)e=n[h],r=i[h],g(e)&&g(r)&&(o[u++]=h,s[f++]=e,s[f++]=r,l[0]=Math.min(l[0],e),l[1]=Math.min(l[1],r),l[2]=Math.max(l[2],e),l[3]=Math.max(l[3],r));s=c(s,f),this.idToIndex=o,this.updateLines(t,s),this.updateError("X",t),this.updateError("Y",t);var d;if(this.hasMarkers){this.scatterOptions.positions=s;var p=b(t.marker.color),v=b(t.marker.line.color),m=t.opacity*t.marker.opacity;p[3]*=m,this.scatterOptions.color=p,v[3]*=m,this.scatterOptions.borderColor=v,d=t.marker.size,this.scatterOptions.size=d,this.scatterOptions.borderSize=t.marker.line.width,this.scatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions),this.expandAxesFast(l,d)},E.updateFancy=function(t){var e=this.scene,r=e.xaxis,n=e.yaxis,a=this.bounds,o=this.pickXData=r.makeCalcdata(t,"x").slice(),l=this.pickYData=n.makeCalcdata(t,"y").slice();this.xData=o.slice(),this.yData=l.slice();var u,f,h,d,p,g,v,m,b=y.calcFromTrace(t,e.fullLayout),x=o.length,_=new Array(x),k=new Float32Array(2*x),A=new Float32Array(4*x),M=new Float32Array(4*x),T=0,E=0,S=0,z=0,P="log"===r.type?function(t){return r.d2l(t)}:function(t){return t},R="log"===n.type?function(t){return n.d2l(t)}:function(t){return t};for(u=0;x>u;++u)this.xData[u]=h=P(o[u]),this.yData[u]=d=R(l[u]),isNaN(h)||isNaN(d)||(_[T++]=u,k[E++]=h,k[E++]=d,p=A[S++]=h-b[u].xs||0,g=A[S++]=b[u].xh-h||0,A[S++]=0,A[S++]=0,M[z++]=0,M[z++]=0,v=M[z++]=d-b[u].ys||0,m=M[z++]=b[u].yh-d||0,a[0]=Math.min(a[0],h-p),a[1]=Math.min(a[1],d-v),a[2]=Math.max(a[2],h+g),a[3]=Math.max(a[3],d+m));k=c(k,E),this.idToIndex=_,this.updateLines(t,k),this.updateError("X",t,k,A),this.updateError("Y",t,k,M);var O;if(this.hasMarkers){this.scatterOptions.positions=k,this.scatterOptions.sizes=new Array(T),this.scatterOptions.glyphs=new Array(T),this.scatterOptions.borderWidths=new Array(T),this.scatterOptions.colors=new Array(4*T),this.scatterOptions.borderColors=new Array(4*T);var I,N=w(t),j=t.marker,F=j.opacity,D=t.opacity,B=s(j,F,D,x),U=C(j.symbol,x),V=L(j.line.width,x),q=s(j.line,F,D,x);for(O=i(N,j.size,x),u=0;T>u;++u)for(I=_[u],this.scatterOptions.sizes[u]=4*O[I],this.scatterOptions.glyphs[u]=U[I],this.scatterOptions.borderWidths[u]=.5*V[I],f=0;4>f;++f)this.scatterOptions.colors[4*u+f]=B[4*I+f],this.scatterOptions.borderColors[4*u+f]=q[4*I+f];this.fancyScatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions),this.expandAxesFancy(o,l,O)},E.updateLines=function(t,e){var r;if(this.hasLines){var n=e;if(!t.connectgaps){var i=0,a=this.xData,s=this.yData;for(n=new Float32Array(2*a.length),r=0;ro;o++)r=this.scene[T[o]],n=r._min,n||(n=[]),n.push({val:t[o],pad:a}),i=r._max,i||(i=[]),i.push({val:t[o+2],pad:a})},E.expandAxesFancy=function(t,e,r){var n=this.scene,i={padded:!0,ppad:r};m.expand(n.xaxis,t,i),m.expand(n.yaxis,e,i)},E.dispose=function(){this.line.dispose(),this.errorX.dispose(),this.errorY.dispose(),this.scatter.dispose(),this.fancyScatter.dispose()},e.exports=u},{"../../components/errorbars":332,"../../constants/gl2d_dashes":367,"../../constants/gl_markers":369,"../../lib":382,"../../lib/gl_format_color":380,"../../lib/str2rgbarray":394,"../../plots/cartesian/axes":405,"../scatter/get_trace_color":564,"../scatter/make_bubble_size_func":570,"../scatter/subtypes":575,"fast-isnumeric":117,"gl-error2d":119,"gl-line2d":125,"gl-scatter2d":190,"gl-scatter2d-fancy":185}],591:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/xy_defaults"),s=t("../scatter/marker_defaults"),l=t("../scatter/line_defaults"),c=t("../scatter/fillcolor_defaults"),u=t("../../components/errorbars/defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p=o(t,e,d);return p?(d("text"),d("mode",pr;r++)y=e.a[r],b=e.b[r],x=e.c[r],n(y)&&n(b)&&n(x)?(y=+y,b=+b,x=+x,_=v/(y+b+x),1!==_&&(y*=_,b*=_,x*=_),k=y,w=x-b,M[r]={x:w,y:k,a:y,b:b,c:x}):M[r]={x:!1,y:!1};var T,E;if(o.hasMarkers(e)&&(T=e.marker,E=T.size,Array.isArray(E))){var L={type:"linear"};i.setConvert(L),E=L.makeCalcdata(e.marker,"size"),E.length>A&&E.splice(A,E.length-A)}return s(e),void 0!==typeof E&&a.mergeArray(E,M,"ms"),M}},{"../../lib":382,"../../plots/cartesian/axes":405,"../scatter/colorscale_calc":560,"../scatter/subtypes":575,"fast-isnumeric":117}],595:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/marker_defaults"),s=t("../scatter/line_defaults"),l=t("../scatter/line_shape_defaults"),c=t("../scatter/text_defaults"),u=t("../scatter/fillcolor_defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p,g=d("a"),v=d("b"),m=d("c");if(g?(p=g.length,v?(p=Math.min(p,v.length),m&&(p=Math.min(p,m.length))):p=m?Math.min(p,m.length):0):v&&m&&(p=Math.min(v.length,m.length)),!p)return void(e.visible=!1);g&&p"),s}}},{"../../plots/cartesian/axes":405,"../scatter/hover":565}],597:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("../scatter/colorbar"),n.calc=t("./calc"),n.plot=t("./plot"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scatterternary",n.basePlotModule=t("../../plots/ternary"),n.categories=["ternary","symbols","markerColorscale","showLegend"],n.meta={},e.exports=n},{"../../plots/ternary":461,"../scatter/colorbar":559,"./attributes":593,"./calc":594,"./defaults":595,"./hover":596,"./plot":598,"./select":599,"./style":600}],598:[function(t,e,r){"use strict";var n=t("../scatter/plot");e.exports=function(t,e){var r=t.plotContainer;r.select(".scatterlayer").selectAll("*").remove();for(var i={x:function(){return t.xaxis},y:function(){return t.yaxis},plot:r},a=new Array(e.length),o=t.graphDiv.calcdata,s=0;se){for(var r=g/e,n=[0|Math.floor(t[0].shape[0]*r+1),0|Math.floor(t[0].shape[1]*r+1)],i=n[0]*n[1],o=0;or;++r)this.showContour[r]&&(e=!0,t[r]=this.scene.contourLevels[r]);e&&this.surface.update({levels:t})},v.update=function(t){var e,r=this.scene,n=r.fullSceneLayout,a=this.surface,s=t.opacity,l=i(t.colorscale,s),u=t.z,h=t.x,d=t.y,g=n.xaxis,v=n.yaxis,m=n.zaxis,y=r.dataScale,b=u[0].length,x=u.length,_=[c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x]),c(new Float32Array(b*x),[b,x])],w=_[0],k=_[1],A=r.contourLevels;this.data=t,f(_[2],function(t,e){return m.d2l(u[e][t])*y[2]}),Array.isArray(h[0])?f(w,function(t,e){return g.d2l(h[e][t])*y[0]}):f(w,function(t){return g.d2l(h[t])*y[0]}),Array.isArray(d[0])?f(k,function(t,e){return v.d2l(d[e][t])*y[1]}):f(k,function(t,e){return v.d2l(d[e])*y[1]});var M={colormap:l,levels:[[],[],[]],showContour:[!0,!0,!0],showSurface:!t.hidesurface,contourProject:[[!1,!1,!1],[!1,!1,!1],[!1,!1,!1]],contourWidth:[1,1,1],contourColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],contourTint:[1,1,1],dynamicColor:[[1,1,1,1],[1,1,1,1],[1,1,1,1]],dynamicWidth:[1,1,1],dynamicTint:[1,1,1],opacity:1};if(M.intensityBounds=[t.cmin,t.cmax],t.surfacecolor){var T=c(new Float32Array(b*x),[b,x]);f(T,function(e,r){return t.surfacecolor[r][e]}),_.push(T)}else M.intensityBounds[0]*=y[2],M.intensityBounds[1]*=y[2];this.dataScale=o(_),t.surfacecolor&&(M.intensity=_.pop()),"opacity"in t&&t.opacity<1&&(M.opacity=.25*t.opacity);var E=[!0,!0,!0],L=["x","y","z"];for(e=0;3>e;++e){var S=t.contours[L[e]];E[e]=S.highlight,M.showContour[e]=S.show||S.highlight,M.showContour[e]&&(M.contourProject[e]=[S.project.x,S.project.y,S.project.z],S.show?(this.showContour[e]=!0,M.levels[e]=A[e],a.highlightColor[e]=M.contourColor[e]=p(S.color),S.usecolormap?a.highlightTint[e]=M.contourTint[e]=0:a.highlightTint[e]=M.contourTint[e]=1,M.contourWidth[e]=S.width):this.showContour[e]=!1,S.highlight&&(M.dynamicColor[e]=p(S.highlightcolor),M.dynamicWidth[e]=S.highlightwidth))}M.coords=_,a.update(M),a.visible=t.visible,a.enableDynamic=E,a.snapToData=!0,"lighting"in t&&(a.ambientLight=t.lighting.ambient,a.diffuseLight=t.lighting.diffuse,a.specularLight=t.lighting.specular,a.roughness=t.lighting.roughness,a.fresnel=t.lighting.fresnel),"lightposition"in t&&(a.lightPosition=[t.lightposition.x,t.lightposition.y,t.lightposition.z]),s&&1>s&&(a.supportsTransparency=!0)},v.dispose=function(){this.scene.glplot.remove(this.surface),this.surface.dispose()},e.exports=s},{"../../lib/str2rgbarray":394,"gl-surface3d":221,ndarray:253,"ndarray-fill":246,"ndarray-homography":251,"ndarray-ops":252,tinycolor2:274}],605:[function(t,e,r){"use strict";function n(t,e,r){e in t&&!(r in t)&&(t[r]=t[e])}var i=t("../../lib"),a=t("../../components/colorscale/defaults"),o=t("./attributes");e.exports=function(t,e,r,s){function l(r,n){return i.coerce(t,e,o,r,n)}var c,u,f=l("z");if(!f)return void(e.visible=!1);var h=f[0].length,d=f.length;if(l("x"),l("y"),!Array.isArray(e.x))for(e.x=[],c=0;h>c;++c)e.x[c]=c;if(l("text"),!Array.isArray(e.y))for(e.y=[],c=0;d>c;++c)e.y[c]=c;["lighting.ambient","lighting.diffuse","lighting.specular","lighting.roughness","lighting.fresnel","lightposition.x","lightposition.y","lightposition.z","hidesurface","opacity"].forEach(function(t){l(t)});var p=l("surfacecolor");l("colorscale");var g=["x","y","z"];for(c=0;3>c;++c){var v="contours."+g[c],m=l(v+".show"),y=l(v+".highlight");if(m||y)for(u=0;3>u;++u)l(v+".project."+g[u]);m&&(l(v+".color"),l(v+".width"),l(v+".usecolormap")),y&&(l(v+".highlightcolor"),l(v+".highlightwidth"))}p||(n(t,"zmin","cmin"),n(t,"zmax","cmax"),n(t,"zauto","cauto")),a(t,e,s,l,{prefix:"",cLetter:"c"})}},{"../../components/colorscale/defaults":313,"../../lib":382,"./attributes":601}],606:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.colorbar=t("./colorbar"),n.calc=t("./calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="surface",n.basePlotModule=t("../../plots/gl3d"),n.categories=["gl3d","noOpacity"],n.meta={},e.exports=n},{"../../plots/gl3d":441,"./attributes":601,"./calc":602,"./colorbar":603,"./convert":604,"./defaults":605}]},{},[12])(12)}); \ No newline at end of file diff --git a/inst/htmlwidgets/plotly.yaml b/inst/htmlwidgets/plotly.yaml index 01777e0659..99b14025f8 100644 --- a/inst/htmlwidgets/plotly.yaml +++ b/inst/htmlwidgets/plotly.yaml @@ -1,6 +1,6 @@ dependencies: - name: plotlyjs - version: 1.13.0 + version: 1.14.1 src: "htmlwidgets/lib/plotlyjs" script: plotly-latest.min.js stylesheet: plotly-htmlwidgets.css From d7053712324649d93a55e3253f0dcf5b749804ba Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 13 Jul 2016 15:25:35 -0500 Subject: [PATCH 71/73] provide scaling escape hatch via I(); add alpha argument; get missing values + group_by() working; various bug fixes and tests --- NEWS | 18 +- R/add.R | 55 ++--- R/layers2traces.R | 14 +- R/plotly.R | 29 ++- R/plotly_build.R | 296 ++++++++++++++++---------- R/sysdata.rda | Bin 9730 -> 9805 bytes R/utils.R | 36 ++-- README.md | 14 +- man/add_trace.Rd | 21 +- man/plot_ly.Rd | 29 ++- tests/testthat/test-plotly-color.R | 80 +++++++ tests/testthat/test-plotly-group.R | 54 +++++ tests/testthat/test-plotly-linetype.R | 42 ++++ tests/testthat/test-plotly-symbol.R | 39 ++++ tests/testthat/test-plotly.R | 138 +++++------- 15 files changed, 583 insertions(+), 282 deletions(-) create mode 100644 tests/testthat/test-plotly-color.R create mode 100644 tests/testthat/test-plotly-group.R create mode 100644 tests/testthat/test-plotly-linetype.R create mode 100644 tests/testthat/test-plotly-symbol.R diff --git a/NEWS b/NEWS index ff92aede34..55b60747fe 100644 --- a/NEWS +++ b/NEWS @@ -5,23 +5,25 @@ BREAKING CHANGES & IMPROVEMENTS: * Formulas (instead of plain expressions) are now required when using variable mappings. For example, `plot_ly(mtcars, x = wt, y = mpg, color = vs)` should now be `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~vs)`. This is a major breaking change, but it is necessary to ensure that evaluation is correct in all contexts (as a result, `evaluate` argument is now deprecated as it is no longer needed). It also has the benefit of being easier to program with (i.e., writing your own custom functions that wrap `plot_ly()`). For more details, see the [lazyeval vignette](https://github.com/hadley/lazyeval/blob/master/vignettes/lazyeval.Rmd) * The data structure used to represent plotly objects is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, the `as.widget()` function has been deprecated, and [serialization/memory leak problems](https://github.com/rstudio/shiny/issues/1151) are no longer an issue. This change also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `?plotly_data` for examples). * The `group` variable mapping no longer create multiple traces, but instead defines "gaps" within a trace (fixes #418, #381, #577). Groupings should be declared via the new `group_by()` function (see `help(plotly_data)` for examples) instead of the `group` argument (which is now deprecated). -* `plot_ly()` now _initializes_ a plotly object (i.e., won't add a scatter trace by default), meaning that something like `plot_ly(x = 1:10, y = 1:10) %>% add_trace(y = 10:1)` will create one trace, instead of two. However, `plot_ly()` will draw a trace if you manually specify a trace type, for example, `plot_ly(x = 1:10, y = 1:10, type = "scatter") %>% add_trace(y = 10:1)` will draw two scatter traces. If no trace type is provided, a sensible type is inferred from the supplied data, and automatically added (i.e., `plot_ly(x = rnorm(100))` now creates a histogram). +* `plot_ly()` now _initializes_ a plotly object (i.e., won't add a scatter trace by default), meaning that something like `plot_ly(x = 1:10, y = 1:10) %>% add_trace(y = 10:1)` creates one trace, instead of two. That being said, if you manually specify a trace type in `plot_ly()`, it will add a layer with that trace type (e.g. `plot_ly(x = 1:10, y = 1:10, type = "scatter") %>% add_trace(y = 10:1)` draws two scatter traces). If no trace type is provided, a sensible type is inferred from the supplied data, and automatically added (i.e., `plot_ly(x = rnorm(100))` now creates a histogram). * The `inherit` argument is deprecated. Any arguments/attributes specified in `plot_ly()` will automatically be passed along to additional traces added via `add_trace()` (or any of it's `add_*()` siblings). -* Scales for aesthetics (e.g., `color`, `symbol`, `linetype`) are now applied at the plot-level, instead of the trace level. To avoid scaling, wrap the aesthetic value with `I()`, for example: `plot_ly(x = 1:10, y = 1:10, color = I("red"))`. +* Aesthetic scaling (e.g., `color`, `symbol`, `size`) is applied at the plot-level, instead of the trace level. NEW FEATURES & IMPROVEMENTS: -* Error checking for trace and layout attributes. -* New `add_polygons()`/`add_ribbons()`/`add_area()`/`add_segments()`/`add_lines()`/`add_markers()`/`add_paths()`/`add_text()` functions provide a shorthand for common visual markings. -* New `plotly_data()` function for returning/inspecting data frame(s) associated with a plotly object. -* New `plotly_json()` function for inspecting the data sent to plotly.js (as an R list or JSON). -* Added `linetype`/`linetypes` arguments for mapping discrete variables to line types (this works very much like the `symbol`/`symbols`). +* Added `linetype`/`linetypes` arguments for mapping discrete variables to line types (works very much like the `symbol`/`symbols`). +* Scaling for aesthetics can be avoided via `I()` (closes #428). This is mainly useful for changing default appearance (e.g. `plot_ly(x = 1:10, y = 1:10, color = I(rainbow(10)))`). +* Symbols and linetypes now recognize `pch` and `lty` values (e.g. `plot_ly(x = 1:25, y = 1:25, symbol = I(0:24))`) +* A new `alpha` argument controls the alpha transparency of `color` (e.g. `plot_ly(x = 1:10, y = 1:10, color = I("red"), alpha = 0.1)`). * Added a `sizes` argument for controlling the range of marker size scaling. +* New `add_polygons()`/`add_ribbons()`/`add_area()`/`add_segments()`/`add_lines()`/`add_markers()`/`add_paths()`/`add_text()` functions provide a shorthand for common special cases of `add_trace()`. * New `toWebGL()` function for easy conversion from SVG to WebGL. * New `export()` function makes it easy to save plots as png/jpeg/pdf (fixes #311). +* Misspecified trace/layout attributes produce a warning. +* New `plotly_data()` function for returning/inspecting data frame(s) associated with a plotly object. +* New `plotly_json()` function for inspecting the data sent to plotly.js (as an R list or JSON). * `layout()` is now a generic function and uses method dispatch to avoid conflicts with `graphics:layout()` (fixes #464). - OTHER CHANGES: * Upgraded to plotly.js v1.14.1 -- https://github.com/plotly/plotly.js/releases/tag/v1.14.1 diff --git a/R/add.R b/R/add.R index 7736066b19..aabe29ea32 100644 --- a/R/add.R +++ b/R/add.R @@ -30,6 +30,7 @@ add_data <- function(p, data = NULL) { #' @param ymin a variable used to define the lower boundary of a polygon. #' @param ymax a variable used to define the upper boundary of a polygon. #' @param color Either a variable name or a vector to use for color mapping. +#' @param alpha alpha channel applied to color (on 0-1 scale). #' @param symbol Either a variable name or a (discrete) vector to use for symbol encoding. #' @param size A variable name or numeric vector to encode the size of markers. #' @param linetype Either a variable name or a (discrete) vector to use for linetype encoding. @@ -84,26 +85,18 @@ add_trace <- function(p, ..., #' @inheritParams add_trace #' @rdname add_trace -#' @param fill fill color. Supplies defaults for -#' \url{https://plot.ly/r/reference/#scatter-marker-color} -#' @param stroke stroke color. Supplies defaults for -#' \url{https://plot.ly/r/reference/#scatter-marker-line-color} -#' @param alpha alpha channel for fill/stroke (on 0-1 scale). #' @export -add_markers <- function(p, x = NULL, y = NULL, fill = "rgba(31, 119, 180, 1)", - stroke = "rgba(31, 119, 180, 1)", alpha = 1, ...) { +add_markers <- function(p, x = NULL, y = NULL, z = NULL, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { stop("Must supply `y` attribute", call. = FALSE) } - # TODO: should stroke/fill inherit from the top-level? - marker <- modify_list(p$x$attrs[[1]][["marker"]], list(...)[["marker"]]) - marker <- modify_list(marker, list(color = toRGB(fill, alpha))) - marker$line <- modify_list(marker$line, list(color = toRGB(stroke, alpha))) + hasZ <- !is.null(z <- z %||% p$x$attrs[[1]][["z"]]) + type <- if (hasZ) "scatter3d" else "scatter" add_trace( - p, x = x, y = y, marker = marker, type = "scatter", mode = "markers", ... + p, x = x, y = y, type = type, mode = "markers", ... ) } @@ -111,7 +104,7 @@ add_markers <- function(p, x = NULL, y = NULL, fill = "rgba(31, 119, 180, 1)", #' @inheritParams add_trace #' @rdname add_trace #' @export -add_text <- function(p, x = NULL, y = NULL, text = NULL, ...) { +add_text <- function(p, x = NULL, y = NULL, z = NULL, text = NULL, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } @@ -121,22 +114,26 @@ add_text <- function(p, x = NULL, y = NULL, text = NULL, ...) { if (is.null(text <- text %||% p$x$attrs[[1]][["text"]])) { stop("Must supply `text` attribute", call. = FALSE) } - add_trace(p, x = x, y = y, text = text, type = "scatter", mode = "text", ...) + hasZ <- !is.null(z <- z %||% p$x$attrs[[1]][["z"]]) + type <- if (hasZ) "scatter3d" else "scatter" + add_trace(p, x = x, y = y, text = text, type = type, mode = "text", ...) } #' @inheritParams add_trace #' @rdname add_trace #' @export -add_paths <- function(p, x = NULL, y = NULL, ...) { +add_paths <- function(p, x = NULL, y = NULL, z = NULL, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { stop("Must supply `y` attribute", call. = FALSE) } + hasZ <- !is.null(z <- z %||% p$x$attrs[[1]][["z"]]) + type <- if (hasZ) "scatter3d" else "scatter" add_trace_classed( - p, x = x, y = y, class = "plotly_path", type = "scatter", mode = "lines", ... + p, x = x, y = y, class = "plotly_path", type = type, mode = "lines", ... ) } @@ -148,19 +145,18 @@ add_paths <- function(p, x = NULL, y = NULL, ...) { #' group_by(city) %>% #' plot_ly(x = ~date, y = ~median) %>% #' add_lines(fill = "black") -add_lines <- function(p, x = NULL, y = NULL, stroke = NULL, alpha = 1, ...) { +add_lines <- function(p, x = NULL, y = NULL, z = NULL, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } if (is.null(y <- y %||% p$x$attrs[[1]][["y"]])) { stop("Must supply `y` attribute", call. = FALSE) } - - line <- modify_list(p$x$attrs[[1]][["line"]], list(...)[["line"]]) - line <- modify_list(line, list(color = toRGB(stroke, alpha))) + hasZ <- !is.null(z <- z %||% p$x$attrs[[1]][["z"]]) + type <- if (hasZ) "scatter3d" else "scatter" add_trace_classed( - p, x = x, y = y, line = line, class = "plotly_line", type = "scatter", mode = "lines", ... + p, x = x, y = y, class = "plotly_line", type = type, mode = "lines", ... ) } @@ -223,9 +219,7 @@ add_polygons <- function(p, x = NULL, y = NULL, ...) { #' plot_ly(economics, x = ~date) %>% #' add_ribbons(ymin = ~pce - 1e3, ymax = ~pce + 1e3) -add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, - fill = "rgba(31, 119, 180, 1)", - stroke = "transparent", alpha = 1, ...) { +add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, ...) { if (is.null(x <- x %||% p$x$attrs[[1]][["x"]])) { stop("Must supply `x` attribute", call. = FALSE) } @@ -235,15 +229,11 @@ add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, if (is.null(ymax <- ymax %||% p$x$attrs[[1]][["ymax"]])) { stop("Must supply `ymax` attribute", call. = FALSE) } - # TODO: should stroke/fill inherit from the top-level? - # probably not, since fill conflicts with scatter's fill attribute! - line <- modify_list(p$x$attrs[[1]][["line"]], list(...)[["line"]]) - line <- modify_list(line, list(color = toRGB(stroke, alpha))) add_trace_classed( p, class = c("plotly_ribbon", "plotly_polygon"), x = x, ymin = ymin, ymax = ymax, type = "scatter", mode = "lines", - line = line, fillcolor = toRGB(fill, alpha), fill = "toself", ... + fill = "toself", ... ) } @@ -426,9 +416,9 @@ add_surface <- function(p, z = NULL, ...) { #' @export #' @examples #' plot_ly() %>% add_scattergeo() -add_scattergeo <- function(p, ...) { +add_scattergeo <- function(p, geo = "geo", ...) { add_trace_classed( - p, class = "plotly_scattergeo", type = "scattergeo", ... + p, class = "plotly_scattergeo", type = "scattergeo", geo = geo, ... ) } @@ -450,9 +440,6 @@ add_choropleth <- function(p, z = NULL, ...) { ) } - - - # attach a class to a trace which informs data processing in plotly_build add_trace_classed <- function(p, class = "plotly_polygon", ...) { p <- add_trace(p, ...) diff --git a/R/layers2traces.R b/R/layers2traces.R index 65b0f00237..3686fc2153 100644 --- a/R/layers2traces.R +++ b/R/layers2traces.R @@ -723,7 +723,12 @@ pch2symbol <- function(x) { "O" = "circle-open", "+" = "cross-thin-open" ) - as.character(lookup[as.character(x)]) + x <- as.character(x) + idx <- x %in% names(lookup) + if (any(idx)) { + x[idx] <- lookup[x[idx]] + } + as.character(x) } # Convert R lty line type codes to plotly "dash" codes. @@ -756,5 +761,10 @@ lty2dash <- function(x) { "224282F2" = "dash", "F1" = "dash" ) - as.character(lookup[as.character(x)]) + x <- as.character(x) + idx <- x %in% names(lookup) + if (any(idx)) { + x[idx] <- lookup[x[idx]] + } + as.character(x) } diff --git a/R/plotly.R b/R/plotly.R index 334be23b19..7de4c32198 100644 --- a/R/plotly.R +++ b/R/plotly.R @@ -10,16 +10,25 @@ #' Note that acceptable arguments depend on the value of \code{type}. #' @param type A character string describing the type of trace. If \code{NULL} #' (the default), the initial trace type is determined by \code{add_trace} -#' @param color Either a variable name or a vector to use for color mapping. +#' @param color A formula containing a name or expression. +#' Values are scaled and mapped to color codes based on the value of +#' \code{colors} and \code{alpha}. To avoid scaling, wrap with \code{\link{I}()}, +#' and provide value(s) that can be converted to rgb color codes by +#' \code{\link[grDevices]{col2rgb}()}. #' @param colors Either a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"), #' or a vector of colors to interpolate in hexadecimal "#RRGGBB" format, #' or a color interpolation function like \code{colorRamp()}. -#' @param symbol Either a variable name or a (discrete) vector to use for symbol encoding. +#' @param alpha A number between 0 and 1 specifying the alpha channel applied to color. +#' @param symbol A formula containing a name or expression. +#' Values are scaled and mapped to symbols based on the value of \code{symbols}. +#' To avoid scaling, wrap with \code{\link{I}()}, and provide valid +#' \code{\link{pch}()} values and/or valid plotly symbol(s) as a string +#' \url{} #' @param symbols A character vector of symbol types. For possible values, see \link{schema}. #' @param linetype Either a variable name or a (discrete) vector to use for linetype encoding. #' @param linetypes A character vector of line types. For possible values, see \link{schema}. #' @param size A variable name or numeric vector to encode the size of markers. -#' @param sizes a numeric vector of length 2 used to scale sizes to pixels. +#' @param sizes A numeric vector of length 2 used to scale sizes to pixels. #' @param width Width in pixels (optional, defaults to automatic sizing). #' @param height Height in pixels (optional, defaults to automatic sizing). #' @param source Only relevant for \link{event_data}. @@ -35,15 +44,15 @@ #' plot_ly(economics, x = ~date, y = ~pop) #' # plot_ly() doesn't require data frame(s), which allows one to take #' # advantage of trace type(s) designed specifically for numeric matrices -#' plot_ly(z = volcano) -#' plot_ly(z = volcano, type = "surface") +#' plot_ly(z = ~volcano) +#' plot_ly(z = ~volcano, type = "surface") #' #' # plotly has a functional interface: every plotly function takes a plotly #' # object as it's first input argument and returns a modified plotly object -#' add_points(plot_ly(economics, x = ~date, y = ~unemploy/pop)) +#' add_lines(plot_ly(economics, x = ~date, y = ~unemploy/pop)) #' #' # To make code more readable, plotly imports the pipe operator from magrittr -#' economics %>% plot_ly(x = ~date, y = ~unemploy/pop) %>% add_points() +#' economics %>% plot_ly(x = ~date, y = ~unemploy/pop) %>% add_lines() #' #' # Attributes defined via plot_ly() set 'global' attributes that #' # are carried onto subsequent traces @@ -66,9 +75,12 @@ #' } #' plot_ly <- function(data = data.frame(), ..., type = NULL, group, - color, colors = NULL, symbol, symbols = NULL, + color, colors = NULL, alpha = 1, symbol, symbols = NULL, size, sizes = c(10, 100), linetype, linetypes = NULL, width = NULL, height = NULL, source = "A") { + if (!is.data.frame(data)) { + stop("First argument, `data`, must be a data frame.", call. = FALSE) + } # "native" plotly arguments attrs <- list(...) # warn about old arguments that are no longer supported @@ -96,6 +108,7 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, group, attrs$size <- if (!missing(size)) size attrs$colors <- colors + attrs$alpha <- alpha attrs$symbols <- symbols attrs$linetypes <- linetypes attrs$sizes <- sizes diff --git a/R/plotly_build.R b/R/plotly_build.R index 6188b52e64..a03a658fe9 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -53,13 +53,23 @@ plotly_build.plotly <- function(p) { dats <- Map(function(x, y) { + # perform the evaluation + dat <- plotly_data(p, y) + trace <- structure( + rapply(x, eval_attr, data = dat, how = "list"), + class = oldClass(x) + ) + # determine trace type (if not specified, can depend on the # of data points) + # note that this should also determine a sensible mode, if appropriate + trace <- verify_type(trace) + # add sensible axis names to layout for (i in c("x", "y", "z")) { nm <- paste0(i, "axis") - idx <- which(names(x) %in% i) + idx <- which(names(trace) %in% i) if (length(idx) == 1) { title <- deparse2(x[[idx]]) - if (is3d(x$type) || i == "z") { + if (is3d(trace$type) || i == "z") { p$x$layout$scene[[nm]]$title <<- p$x$layout$scene[[nm]]$title %||% title } else { p$x$layout[[nm]]$title <<- p$x$layout[[nm]]$title %||% title @@ -67,81 +77,90 @@ plotly_build.plotly <- function(p) { } } - # perform the evaluation - # TODO: remove/warn about missing values here? Provide a way to control na.color? - dat <- plotly_data(p, y) - x <- structure(rapply(x, eval_attr, data = dat, how = "list"), class = class(x)) - # ensure we have a trace type (depends on the # of data points) - x <- verify_type(x) - - # do some attribute type checking for special trace types - if (inherits(x, c("plotly_heatmap", "plotly_surface", "plotly_contour"))) { - if (!is.matrix(x$z)) { - stop("`z` must be a matrix", call. = FALSE) - } - if (!is.numeric(x$z)) { - stop("`z` must be numeric", call. = FALSE) + # attribute type checking for special trace types + if (inherits(trace, c("plotly_heatmap", "plotly_surface", "plotly_contour"))) { + if (!is.matrix(trace[["z"]]) || !is.numeric(trace[["z"]])) { + stop("`z` must be a numeric matrix", call. = FALSE) } } - - # TODO: if we ever provide some semantics for statistics, it should probably go here + # TODO: if we ever provide some semantics for summary statistics, + # it should go here # gather the "built" or "evaluated" data nobs <- NROW(dat) - attrLengths <- lengths(x) + attrLengths <- lengths(trace) if (nobs == 0) nobs <- max(attrLengths) - isVar <- attrLengths == nobs - builtData <- data.frame(x[isVar & !names(x) %in% c("colors", "symbols", "linetypes")]) + # NOTE: it's hard to distinguish variables/constants when there is 1 row. + # Fortunately, variable mappings don't make much sense with one observation, + # and that is the whole point of "recovering" the built data here, so we just ignore + # cases with one row + isVar <- attrLengths > 1 & attrLengths == nobs & !vapply(trace, is.matrix, logical(1)) + builtData <- data.frame(trace[isVar], stringsAsFactors = FALSE) - # find any groupings, so we can arrange the data now, - # and insert missing values (to create gaps between traces) later - grps <- as.character(dplyr::groups(dat)) - # does grouping even make sense for this trace type? - hasGrp <- inherits(x, c("plotly_segment", "plotly_path", "plotly_line", "plotly_polygon")) || - (grepl("scatter", x$type) && grepl("lines", x$mode %||% "lines")) - if (length(grps) && hasGrp) { - if (isTRUE(x$connectgaps)) { - stop( - "Can't set connectgaps=T in a trace that has 1 or more groups.", - call. = FALSE + if (NROW(builtData) > 0) { + # Build the index used to split one "trace" into multiple traces + isAsIs <- vapply(builtData, function(x) inherits(x, "AsIs"), logical(1)) + isDiscrete <- vapply(builtData, is.discrete, logical(1)) + # note: can only have one linetype per trace + isSplit <- names(builtData) %in% "linetype" | + !isAsIs & isDiscrete & names(builtData) %in% c("symbol", "color") + if (any(isSplit)) { + paste2 <- function(x, y) paste(x, y, sep = "
") + builtData$.plotlyTraceIndex <- Reduce(paste2, builtData[isSplit]) + } + # Build the index used to determine grouping (later on, NAs are inserted + # via group2NA() to create the groups). This is done in 2 parts: + # 1. Translate missing values on positional scales to a grouping variable. + # If grouping isn't relevant for this trace, a warning is thrown since + # NAs are removed. + # 2. The grouping from (1) and any groups detected via dplyr::groups() + # are combined into a single grouping variable, .plotlyGroupIndex + isComplete <- complete.cases(builtData[names(builtData) %in% c("x", "y", "z")]) + # is grouping relevant for this geometry? (e.g., grouping doesn't effect a scatterplot) + hasGrp <- inherits(trace, paste0("plotly_", c("segment", "path", "line", "polygon"))) || + (grepl("scatter", trace[["type"]]) && grepl("lines", trace[["mode"]])) + # warn about missing values if groups aren't relevant for this trace type + if (any(!isComplete) && !hasGrp) { + warning("Ignoring ", sum(!isComplete), " observations", call. = FALSE) + } + builtData$.plotlyGroupIndex <- cumsum(!isComplete) + builtData <- builtData[isComplete, ] + grps <- tryCatch( + as.character(dplyr::groups(dat)), + error = function(e) character(0) + ) + if (length(grps) && hasGrp) { + if (isTRUE(trace[["connectgaps"]])) { + stop( + "Can't use connectgaps=TRUE when data has group(s).", + call. = FALSE + ) + } + builtData$.plotlyGroupIndex <- interaction( + interaction(dat[isComplete, grps, drop = FALSE]), + builtData$.plotlyGroupIndex %||% "" ) } - builtData$.plotlyGroupIndex <- interaction(dat[, grps, drop = FALSE]) - } - - builtData <- train_data(builtData, x) - # TODO: provide a better way to clean up "high-level" attrs - x[c("ymin", "ymax", "yend", "xend")] <- NULL - x$.plotlyVariableMapping <- names(builtData) - - # build the index used to transform one "trace" into multiple traces - discreteData <- builtData[vapply(builtData, is.discrete, logical(1))] - discreteData <- discreteData[names(discreteData) %in% c("symbol", "linetype", "color")] - if (NCOL(discreteData) > 0) { - paste2 <- function(x, y) paste(x, y, sep = "
") - builtData$.plotlyTraceIndex <- Reduce(paste2, discreteData) - } - # arrange the built data - arrangeVars <- c( - ".plotlyTraceIndex", "group", if (inherits(x, "plotly_line")) "x" - ) - arrangeVars <- arrangeVars[arrangeVars %in% names(builtData)] - if (length(arrangeVars)) { - builtData <- dplyr::arrange_(builtData, arrangeVars) - } - - # copy over to the trace data - for (i in names(builtData)) { - x[[i]] <- builtData[[i]] + builtData <- train_data(builtData, trace) + # TODO: provide a better way to clean up "high-level" attrs + trace[c("ymin", "ymax", "yend", "xend")] <- NULL + trace$.plotlyVariableMapping <- names(builtData) + # arrange the built data + arrangeVars <- c( + ".plotlyTraceIndex", "group", if (inherits(trace, "plotly_line")) "x" + ) + arrangeVars <- arrangeVars[arrangeVars %in% names(builtData)] + if (length(arrangeVars)) { + builtData <- dplyr::arrange_(builtData, arrangeVars) + } + # copy over to the trace data + for (i in names(builtData)) { + trace[[i]] <- builtData[[i]] + } } - # if appropriate, set the mode now since we need to reference it later - if (grepl("scatter", x$type) && is.null(x$mode)) { - x$mode <- if (any(attrLengths > 20)) "lines" else "markers+lines" - } - - x[lengths(x) > 0] + trace[lengths(trace) > 0] }, p$x$attrs, names2(p$x$attrs)) @@ -149,24 +168,23 @@ plotly_build.plotly <- function(p) { traces <- list() for (i in seq_along(dats)) { d <- dats[[i]] - scaleAttrs <- names(d) %in% c("colors", "linetypes", "symbols", "sizes") + scaleAttrs <- names(d) %in% paste0(npscales(), "s") traces <- c(traces, traceify(d[!scaleAttrs], d$.plotlyTraceIndex)) if (i == 1) traces[[1]] <- c(traces[[1]], d[scaleAttrs]) } # insert NAs to differentiate groups traces <- lapply(traces, function(x) { - d <- data.frame(x[names(x) %in% c(x$.plotlyVariableMapping)]) + d <- data.frame(x[names(x) %in% x$.plotlyVariableMapping], stringsAsFactors = FALSE) d <- group2NA( d, ".plotlyGroupIndex", ordered = if (inherits(x, "plotly_line")) "x", retrace.first = inherits(x, "plotly_polygon") ) for (i in x$.plotlyVariableMapping) { - x[[i]] <- uniq(d[[i]]) + x[[i]] <- structure(uniq(d[[i]]), class = oldClass(x[[i]])) } x }) - # "transforms" of (i.e., apply scaling to) special arguments # IMPORTANT: scales are applied at the plot-level!! colorTitle <- unlist(lapply(p$x$attrs, function(x) { @@ -180,8 +198,7 @@ plotly_build.plotly <- function(p) { # remove special mapping attributes for (i in seq_along(traces)) { mappingAttrs <- c( - "color", "colors", "symbol", "symbols", - "linetype", "linetypes", "size", "sizes", + "alpha", npscales(), paste0(npscales(), "s"), ".plotlyGroupIndex", ".plotlyTraceIndex", ".plotlyVariableMapping" ) for (j in mappingAttrs) { @@ -212,7 +229,6 @@ plotly_build.plotly <- function(p) { ) } } - # verify plot attributes are legal according to the plotly.js spec p <- verify_attr_names(p) # box up 'data_array' attributes where appropriate @@ -276,21 +292,44 @@ map_size <- function(traces) { hasText <- has_text(types, modes) for (i in which(nSizes > 0)) { - sizeI <- scales::rescale(sizeList[[i]], from = sizeRange, to = traces[[1]]$sizes) - traces[[i]]$marker <- modify_list( - list(size = sizeI, sizemode = "area"), - traces[[i]]$marker - ) + s <- sizeList[[i]] + isConstant <- inherits(s, "AsIs") + sizeI <- if (isConstant) { + structure(s, class = setdiff(class(s), "AsIs")) + } else { + scales::rescale(s, from = sizeRange, to = traces[[1]]$sizes) + } + if (hasMarker[[i]]) { + # plotly.js + sizeI <- rep(sizeI, length.out = max(lengths(traces[[i]]))) + traces[[i]]$marker <- modify_list( + list(size = sizeI, sizemode = "area"), + traces[[i]]$marker + ) + } if (hasLine[[i]]) { - warning( - "Can't map size to lines since plotly.js doesn't yet support line.width arrays", - call. = FALSE + if (!isConstant || length(sizeI) > 1) { + warning( + "plotly.js doesn't yet support line.width arrays, track this issue for progress\n", + " https://github.com/plotly/plotly.js/issues/147", + call. = FALSE + ) + } + traces[[i]]$line <- modify_list( + list(width = sizeI[1]), + traces[[i]]$line ) } if (hasText[[i]]) { - warning( - "Can't map size to text since plotly.js doesn't yet support textfont.size arrays", - call. = FALSE + if (!isConstant || length(sizeI) > 1) { + warning( + "plotly.js doesn't yet support textfont.size arrays", + call. = FALSE + ) + } + traces[[i]]$textfont <- modify_list( + list(size = sizeI[1]), + traces[[i]]$textfont ) } } @@ -307,8 +346,9 @@ map_color <- function(traces, title = "", na.color = "transparent") { if (all(nColors == 0)) { return(traces) } - isNumeric <- vapply(color, is.numeric, logical(1)) - isDiscrete <- vapply(color, is.discrete, logical(1)) + isConstant <- vapply(color, function(x) inherits(x, "AsIs"), logical(1)) + isNumeric <- vapply(color, is.numeric, logical(1)) & !isConstant + isDiscrete <- vapply(color, is.discrete, logical(1)) & !isConstant if (any(isNumeric & isDiscrete)) { stop("Can't have both discrete and numeric color mappings", call. = FALSE) } @@ -321,6 +361,27 @@ map_color <- function(traces, title = "", na.color = "transparent") { hasZ <- has_attr(types, "colorscale") & any(vapply(traces, function(tr) !is.null(tr$z), logical(1))) + for (i in which(isConstant)) { + if (hasLine[[i]]) { + traces[[i]]$line <- modify_list( + list(color = toRGB(color[[i]], traces[[i]]$alpha %||% 1)), + traces[[i]]$line + ) + } + if (hasMarker[[i]]) { + traces[[i]]$marker <- modify_list( + list(color = toRGB(color[[i]], traces[[i]]$alpha %||% 1)), + traces[[i]]$marker + ) + } + if (hasText[[i]]) { + traces[[i]]$textfont <- modify_list( + list(color = toRGB(color[[i]], traces[[i]]$alpha %||% 1)), + traces[[i]]$textfont + ) + } + } + if (any(isNumeric)) { palette <- traces[[1]][["colors"]] %||% viridisLite::viridis(10) # TODO: use ggstat::frange() when it's on CRAN? @@ -333,7 +394,11 @@ map_color <- function(traces, title = "", na.color = "transparent") { } else { c(0, 1) } - colorScale <- matrix(c(scales::rescale(vals), colScale(vals)), ncol = 2) + + colorScale <- matrix( + c(scales::rescale(vals), toRGB(colScale(vals), traces[[1]]$alpha %||% 1)), + ncol = 2 + ) colorObj <- list( colorbar = list(title = as.character(title), ticklen = 2), cmin = rng[1], @@ -356,6 +421,10 @@ map_color <- function(traces, title = "", na.color = "transparent") { " when the trace type is 'scatter' or 'scattergl'.\n", call. = FALSE) traces[[i]]$mode <- paste0(traces[[i]]$mode, "+markers") hasMarker[[i]] <- TRUE + } else { + # scatter3d supports data arrays for color + traces[[i]]$line <- modify_list(colorObj, traces[[i]]$line) + traces[[i]]$marker$colorscale <- as_df(traces[[i]]$marker$colorscale) } } if (hasMarker[[i]]) { @@ -444,29 +513,34 @@ map_symbol <- function(traces) { if (N > 8) { warning("You've mapped a variable with ", N, " different levels to symbol.\n", "It's very difficult to perceive more than 8 different symbols\n", - "in a single plot.") + "in a single plot.", call. = FALSE) } # symbol values are duplicated (there is a valid numeric and character string for each symbol) validSymbols <- as.character(Schema$traces$scatter$attributes$marker$symbol$values) # give a sensible ordering the valid symbols so that we map # to a palette that can be easily perceived - symbolPalette <- c( + defaultPalette <- c( 'circle', 'cross', 'diamond', 'square', 'triangle-down', 'triangle-left', 'triangle-right', 'triangle-up' ) - symbols <- unique(unlist(traces[[1]]$symbols)) %||% symbolPalette - illegalSymbols <- setdiff(symbols, validSymbols) - if (length(illegalSymbols)) { - stop("The following are not valid symbol codes:\n", - paste(illegalSymbols, collapse = ", "), - "Valid symbols include:\n'", - paste(validSymbols, collapse = "', '"), - call. = FALSE) - } + symbols <- traces[[1]]$symbols %||% defaultPalette palette <- setNames(symbols[seq_len(N)], unique(symbol)) for (i in which(nSymbols > 0)) { - symbols <- as.character(palette[symbolList[[i]]]) - traces[[i]]$marker <- modify_list(list(symbol = symbols), traces[[i]]$marker) + s <- symbolList[[i]] + symbols <- pch2symbol(if (inherits(s, "AsIs")) s else as.character(palette[s])) + illegalSymbols <- setdiff(symbols, validSymbols) + if (length(illegalSymbols)) { + warning( + "The following are not valid symbol codes:\n'", + paste(illegalSymbols, collapse = "', '"), "'\n", + "Valid symbols include:\n'", + paste(validSymbols, collapse = "', '"), call. = FALSE + ) + } + traces[[i]]$marker <- modify_list( + list(symbol = symbols), + traces[[i]]$marker + ) # ensure the mode is set so that the symbol is relevant if (!grepl("markers", traces[[i]]$mode %||% "")) { message("Adding markers to mode; otherwise symbol would have no effect.") @@ -498,18 +572,22 @@ map_linetype <- function(traces) { length(validLinetypes), " different line types", call. = TRUE) } linetypes <- unique(unlist(lapply(traces, "[[", "linetypes"))) %||% validLinetypes - illegalLinetypes <- setdiff(linetypes, validLinetypes) - if (length(illegalLinetypes)) { - stop("The following are not valid linetype codes:\n'", - paste(illegalLinetypes, collapse = "', '"), - "Valid linetypes include:\n'", - paste(validLinetypes, collapse = "', '"), - call. = FALSE) - } palette <- setNames(linetypes[seq_len(N)], unique(linetype)) for (i in which(nLinetypes > 0)) { - dashes <- as.character(palette[linetypeList[[i]]]) - traces[[i]][["line"]] <- modify_list(list(dash = dashes), traces[[i]][["line"]]) + l <- linetypeList[[i]] + dashes <- lty2dash(if (inherits(l, "AsIs")) l else as.character(palette[l])) + illegalLinetypes <- setdiff(dashes, validLinetypes) + if (length(illegalLinetypes)) { + warning( + "The following are not valid linetype codes:\n'", + paste(illegalLinetypes, collapse = "', '"), "'\n", + "Valid linetypes include:\n'", + paste(validLinetypes, collapse = "', '"), "'", call. = FALSE + ) + } + traces[[i]][["line"]] <- modify_list( + list(dash = dashes), traces[[i]][["line"]] + ) # ensure the mode is set so that the linetype is relevant if (!grepl("lines", traces[[i]]$mode %||% "")) { message("Adding lines to mode; otherwise linetype would have no effect.") diff --git a/R/sysdata.rda b/R/sysdata.rda index 111c4cdd0984d0c49f4d5deb856257abbfb86ddf..66b49a4434c19ab809d7abfe8272ab9955574547 100644 GIT binary patch literal 9805 zcmV-TCbHQ=T4*^jL0KkKSvd&5?E%z}fB*mg|NsC0|Ns9l|9}7g|Nde^NU%U4LSV@z zNB}}QM8V)X-0zc}x006r%do=Uih28G-mw*`~pa)$HK%k&`oB-B^ zrV8HgXc$DRb~cV(mu5h9&^dJXwFVh)Q@gpghMJIiZrbPr%b{9pK%>rW66iX}16(r# zf)u4Es(YGLR-~7uJhyv}+n0l2ijhx2H9atlsqCZLnwW--H1v%S%}t^(o{gj?Pe4ye zqeDyqJv9tX27nm=4^fCBkO&Y!L8DaKdJ1|4GHK-0{U(~8fi&`giJsPOsAC5>SP){Oqu`y7|3XYLq-V1 z00T#$pS8gpDKbki1u!W{5XcfF1eE|u5P#1<)7<|5<{m-eVire1KkE#>uS#C~6z{C1 z>18X3&l@M>vDZd9rv2eF8 zwYB~WOOn#zZEb0B5A;luX*8l)Dv+2;rBew+z>t>`f>k7vNE7T^Q7D^}ybh|h=ETPgwH{_q3k<|>o)~96YMiMGV$n`Qa1wHH z5^{7?*G&ZArztsUNjYiBOR2<6ewSo;oR!HX%9NZv7f=c0>G^N6+Q+f$*2FL?qm9Rg7#Yq5F@OSNLf+OcBAi{(J9N( zF`;mXVaS=pO{-QJ2Z0xynP8=uS()LE7by-BmR1H<^p)f`h_xZfF7DrPGUyH=)a6qj zU+Zw9C@*OsvC^2#jO=7PRn6=EAK~T~qorQo1vgN1^x>$$iX=i|2vUMnARq*ZLeiK7 z!?hsLu)Imirh;*SKK@fsK z&=j31jF(E|wM&KB+v`YlCqS~Nk{Y`ki8BgJ0WyR@!!=1j69Rd5Wi+G75Id$`NQuc6 zkSYP_fG}*DgE-yTBeOaa&?I_!61WB=C<%P7pqilB}-O=Uc-$NvqSjrL*1T5ka zH22-#MO|rtae#;%7lRo*u9LoyC}=t44s?nX!W}sP%1Am8=qGiKnV?Q6N)y(g+$^K6 zg`r@;5<6^$)a_6XBxu0>D3Q59)h+4^lLO z{UpB5ePRUaS94>{fHx$KwU}iejw@k7Few(K`9CaP(I2r;~(wp(LCtJeaIw1C`y)`Rld}4t2LZBdsH85L-EVO zMLZ{C$WWgVOL(nPvkeh43q}G65Qbt{fGKD^Lf|=iXv-10dnd0v6sQJ zVCoj4++IOo_V;UkB+BfYh0!Mhnf~Hwnaj4M%wLBM9tHY$A_fF`p(T%w_CLk@_Sye- z8s;wh!Wu7D9TTCN!JvSeNvN0-mX&?Vpoj=t$f^^jKvU9s7YLrVtdk=IjXMI73Pveb z^9a4>5(-Kc@LY1HP5cf*|qig^1ib>>_~<6AnrGqYBeyyx-q;V5(5RG5BC zMW!nSgb_?Ik8Z|!#h+$#R$}OMctQoq19q1M9492Jl$3HpcodnQYVM9zXDv6w&@$#w zYMi&4(DJJoa?<3swOYAzhPXxybC=NU5pc@%ff-In*kT3h;EY1a3jk1a3xZOGE!KGp zL&;H+1tb_k77~EahGCpxQ7lC*&k3^E5HoZ=*KqybBXnE=W_v(9(Ujxmm* z9s$UyGKS1@GDtA8Ng!fK$UHfhk|%I#9w2Fh2Rh6zOAFO-E+}om;AT*ZN*v~SE2E64 zb4kO7oHnsffb@MMkIMPWYhb!#dA-;`C?Uk*abSpyXU(>wlu97dwAL$}lq!J&0o*{- z2B>|grpHzOuDb7ny=|yyA2_EOJzqb4okl%dc@Q38iI|9{q@Wr_@6+M9jw4JgE##6& zltoFiC`xvmr!pS=L=q)}cq`S3ndu5zff{DcV*pk{!I?*Ha@`^3WM(;tve2C1jWDM& zbsR#4P6%ro;WH!S)Ycn5#{TWz7H)3#W^`Jt>$C3X$zKI4seUZ5FYrsk1VkYV322dD zfqL0a==KgW?5kpOD0Utnye4h)F?spAbm{$?g%}r25Qh=*n9F;SuEu zZlr}N+n)anxwoGoBq`tOmfUkA1b2Cgio4sI7)FT=xcon$u!D9E>~7Sl9Y%F z2!wz%)3||rxl_?ke!>#JroVa zl1U4$T{AC97-9&BAYveJr3qayoRpZ1pjm>}O6GE7LPrZ~1vA3R#>CS)Q 39QQr z&`hxs$XhU$N}xzntW(hmDcd(TO%j*kM3putu$o@f9Gp53loIKa8p2Tm<;+fCTn-uT zK-z?=k}`TbX#yE)mMs;hB{yGL@4^JWTXC{c0_h0?>ezuwOfuHWQ7w{@ zb4tOMlabC?ZY(HQK*=i!aITl06ooNlv?U1U$P3v5K=4YYQ@lz8B8wR_#HK4U#x)l~ zm0^>9J9&4UkR{<=@{lEr=esdtt2IWXtnc{pq0rem{vnf=_O3S-Yhd_l8&j3;8Nw=ppe-#+{rV9 z@mEQSVVNW!jWZ^&Q4*{~C_2EYG=$bOg--f&yQZDUP(2;`s&MS=tvy=b0=@F2ihW3c zrcxmuOppch6_CD-WjMX1p#h;mKecSyq)~i$iWfFP3OVcv6BwWu(uaUXS7)`R1l6R5DfsK z7$D$sVHDzW9H)3~{moDFF(nR+6kDn|@nx9i-8$w3RF7h36p*sQgTVx)O_@T69Y+F6 z0U=&a4y8^kaX27CU>P{!!bBvX_XY=$B(R`iWe|c8bO@u&$kzEbRumqo>YX!Su61ON z3k9W$hG2_J35%lArCOK`Of@k%=0v5bfL2ws(ILJ$=5IFDOLW;Z$%RFdOps)eOqfl~ zl1afKIV5C|WR=MZVI=?qh!#tUl1NRHBr7W$7#qdWoOixNH%EHJ;2`FOvB&d_@%Ow$7+2gna9%O^yzQ9<;FFQ zxph4k%8HQ+%js}cWPLCQJF`g`Io|VJ&s?e&OOJlGCFjYPkwY)QWb4_iL_{Pfg9YN9 zc}#*4oW2axw+B}0+DE#MeO$QXEsjxnkEp=DW*LjZp&GF!o($(%Gwk!H*=AITky(|A z+9d`hA}uKqxUBvF1RZfZQYJ^#w9fKvsnf6qQtFCp+=94I)yd^oEfL|u1En7x*5t@h zmv+s!<=dZXcKH5J?wsM~56~R`B=yWpoy6}z**2YX-9IGZIg^Th(rlcjPE+fg(`m+Z zPb}2?W+%d8WXc&bWWb$sCQiANCQO{k_D)ktxJ}7qy1FEj33R$#O9^o%CggGh!tR}O8Rr*< zzIpra=zC$de)~^$#AP0+1m5_E!6bfWTa!)SKTNt3kArAal6pp zWlBc)+6)LEivS4wK*EaFNy(;@Qvo!SH8hiknn{kG)Tow{`B$!4dYDw1f+m(r7tFlg zPZyc@ool2g0+UoiAv@cykg0c!(s-I`1b@!n$wNGN1a zPefEsA!6XFCpf)^lkB03kieAUcf5@aC$^2D`q{{%Cqbd9UmCeqYq#BcJkh z`-9`z!fXsD?1mF{2hf&$U$g$*AJ+eAY@Yf;3QiJ|PE4fSC!mzlVkx7sUJWD!E)*!@ zmnCxv?+SMNUhh}f`ZMxR39nQt0VMcdG(%C|*#1ZJyXG=t%)x&8rw0_+rpoTbYxjPy zJEoTIdH2jrn3*v$WWf_rwCY3*&#~G&bW)^H#mf8WfCxvWfe)YG*uO>+!Pok0^}8bS ztf5XPdaNh=FKQZfJx#9?Z|0SEY$eYTd2*qd_<3)Z^R%s1jNgZy(5uKV4E#!Tf(-n& zQ4ZX^-W;1F)7(WqlPH0QmE43`nAto02!(}#NEkL{+!`vT3Vt|L>i~Zyy-l5X)}+z< z$`35Wu}?LXYfouMmY-cVp6YdP?q_K4_|G7`Q_DUfWmp~j{;hc_@v#SF?VoMayUR?- zoe@J>TMcRLcEiWFZC2rn_!cSnJD2fE;N|9<-yQh8 z5Pr^7UaQw1o87OLnd9!)hli8Rsn=3kpg%7++p+L&D4wpiD;oi2&>(Fp*Tp^ny?K>30+NRn2e>dOWC)DSw)jx)9Jyr0YN#8n^JDAB! z%Y`(ssW8Pm=WR>Y^xm*LossIoJZ0NJSH%L4iWhVXDZ!*kS-7W%&=TNwrDYkFyuCt0 zH3`r>bC|U1t1**%S2CVZ)#~)9@=2BLR|+^Xc6oMh>9=ao&Qi;KYKVx;0v6^9RRVin zQpqwz=PLrF)m}O4nLDSm+actTvnEdRXm?BEDWg)!!!E3wCODHBW@S_--ye^IiS3E^ z9)P|M0nOMj(QuB*@z)&jO>27B8Y@wzojFF3x6iG4)nLKr8bo$f9c@pU$vGVjI$27& zjLRbn1%%8iEMVvBd{>(7dulr;GZJOI^=RrjDNuoMv7uVNFfBGMujAXNP=c03P?!;3I>Igff|SjNQodw z0+ni#mZBI4p$Z~e2^$n%>#t(y?pB9Z^^>!j&5k=_^rGh$vg1+L6gyRBzP~|5!Mx1X zkkE&`2^G)@ys_^3Gd*LjE!etcG|a%=D+^0z^j$ie@WWjW4U{Lig-f@Prt-M0zyNAc z-zkWMKMlm<-5hDnF}4`pqTiFDlWDZcz`+1fCpHFzBqV{Tp`|s48=e>qK4z3gj`%Hbq_vO0}}X= zFiAXFkbIOtd{3jjUjw?XbXqFxkLAV$=c(qzPN|5E#S%94 zc;;@o-btHFLrv*2q9i&%FE3Q~Q`t2My$2>!DT>N5l!h206h?$Zm=tu1dKf9< z@KaT*&7x-=xaGfYnllDEN28M7t~l1wDfxp)+VA7=$~CVf?o)=t1`abon2-boK_oz5 zsZ47GEp>!hb2T{d#BZB&yurk=GG!)Wi1LQJMCP0_4DM4lK`U+)pxn&hE>CTt(A$Wa zikauYgIh@#TtJgGHD;v~$pF4Vbj|XoS2^k`>Aaq0K9x2(m?NZLqeyJ!?EeSH`%BNE z<6w2$AEfcGukY94+ZDO`9V_v#TBk#C!hNJTy6m!yQxwWRS@%-iFE8iyDN=J&%u~;y z)2wD|+NLX8A6tivY&fZk=_%{$bB%$OK|v#+=ilbB$5nUyRTi(_ia!P8mD<{$HYs!4}A5AA9CCaDJRiD#257m;tpT1+ZzX zA8bC!Z?bTI952N=NcyrZRmH1=9PQ*B$;y1ppOvuZSo6PMJWiP17gi276Di2K*XEaI zI~tXKU%UA3l-^YL;Z|&=tV%n*FxAvBkSn510QBKZ5S5 z^y;_@`abUIJJmQWbp>>~pII+voF}0N=LeSm9<#cAXmlr+lkN0U({%7#@%uD(cW>#( zc`IK3Ht>~ZI+)W`-K?pNWpY) zi7Qlq8cazFd`JQDdksyHH=PX_nnE;<3adeCu^gxUA|-3AQ|3H>v5KY4p#&Zu+Gi zA+GzLX=~#BS$?nNleTe(;aWsE;#ab$Jt3g#>JpACerP!37_Y#2ef4_Vu~%)=q&3g0 zY=+q`5H-@BELAzcuE3^2N`O{QXc#0nOA}i|MLS7Y`<&*BvZyw;T-8^WCz^J1d{B#4 zqU}^W*_J~vGR%fWwXGECm04k|4PuVlg4*1BThlzlQ zPfyV5LXF-Jy94wClK+v3!c_b7NgtIV+ zKoWsrBF6HEq`sf1jFRf9^)H6%MidVqDZ|b+%g7^FpemUpm%yHJ(rDo7)L9~#(D+41 z*MZO;REvwV5YH(sCCq0Erl}n8{B(La-N(Dz@XWE$9K|x96F9uR9&_^XUj;jBoOqwR zecp6`a^T^PDXXR>ZP%KldDVFaw)+#-Pl&+5qHPV}R|Ze3Wbyr(!P6$|MH!}bOf=Q0 zroF9OtRfg+)%Wv_%2 zH6~?TGG~lgOB^jzE3~8LPGn}P9--Ab%Eyw zYcL7x46Mr1n!prWhR}pgS4KqWRy?3WXJ1GPPyGZOZBmy zk2Bb{yxEx9?b}TIq!J*lQc(oUK~6M@vDG<}i*)%Z(dM==ZTK3LtT)NyfQw|Q)wVY6FgKv$-oF2LApKNOr zK`bUBSxZT2CZ{bjljTp*KU9$OeA6aPAak|55%e2lakSkpl&F0W$e2q4 z463c!7Wv&3W^5o#hIB1s+hP7 zAzF)R&SCj;o@-i|O=T=)wv0~yZf4F%=V9;ReDQnK#P$6BSY~^tx^WJyGMMq#iBA>$ zzV*?&_RG5iOr@_Tk-i6-5NF0uEUbG0Gm%FRqAzF@AjUvvB4ow&3!PKQr|47Y7m!;i zfRO%HJAl*0jr3tc@)! zyo0!1sarTDbEV>BZn|x?OQ68?Y~1Qq=ak*#Y4oD;&l%Qrbu*@CCa(h2=r!E#VC;4$ zr?0M>r!KedbH&-o9A~P2Nt5*^SG-ubTrL+2#Jtt+*SlL=TU%dZxvwdDi=ybdE{khx zYinz@aItW)aI$(-_*1fx=E4>JpR-|i`+c6ld13R*RmceH1LF`L!!Oa1G9Hq9H`~5F zhDv5fVx1c@ABICdyMoWIc)w`}Z!YzUzGVf9o$tpEH`C0|7tH3J1c3i26loAs)c23) zBO~cAzF-e(tbG)wsA9dC=&Vf-PNzg2-p+@*=iyE(9V%=5N0Uf+qO2C@fAOn6udsm) zxG9p1YFq^r^YM4aUReqzD!_$!lnAgeL2KmW?a7tdYilcr8DVy%T8w$oUhGcg`ddr{ zf>tKeQ)#KB$&=P@pB4)JKZu{L{A=A`KfQgzIm3^n!_i`}vK=Plb?ikrrzp=)mz!6; z=DlG{os_4Mdcm6TwO}P7LsW&F3<4&fJCWpf)o5V2gvYH*c2!z`0P3Ape6!}6K1uK# z&k!E!In}1liY&U=3~l+9n?r3B+S?0MhXQ&C}ZTAWAU$Wh6XQG&GJJl&SpuWgz)ExeTE=kSAUZC!CsB=t{HXxOGJC&wY?aD@DBf-z&!Ulp>O$7Fn>Q7NODSnlcO*GQVdCAmG z1g4ub=p}^Or-#<^D@(oQnv!s)q5VKZQ^;x_P`HI;zf1(ElBM!_y)q=H)BgNw$*L|& zlv0XcB&oPcDNQ9yX@r;QgqG5fDNMrnB0NCq1c606mnZq-!n@ana$W19@Ggma|N9^L nuz&7KjL13XG|>&QPyf5e@>j$u6ZZuK|NLFa6yZWZn@1(5{cIDT-y60L@003y(J{3r z#%jQ;-ci%RO1s(J)2`bzor9`3ZCKt;hj8g_ajgR;5cjj!r32RX4EJ-O33E1y%mjhZ z;oZtKrYTFdc^;0QgRQYZ?>D>GJ8nD-5mF|Co*{(LF*Fg8iHVXjdYXEMn2$9HiR9Gv z7>`hCfS#ku7@7?LGyobg1X2XhK{Pam2pVZJO{CG9iTY1e)5(%%DAAA}pfu5=KzfEi zXld#+27mwr8e%lU444x}35ljA0Wg{{2*4&L6Gngy7(sv`kTlaFk*19d5TZ#Yl+83# z^-b!UdOazo8iAt;p^2tI00003K=m3lG#NAi00004)gnSnrcFI2l-?;HsXV8Y)5$&R zk&t?ZfY1#905kvq00007r~otor6fTB5CpKe>{Ao_lZlBYrlgWd z#L+v`Q~DDVq{QNCYGQCt^h{D|G@@B5ke5oOQt3pvkeCTUDw0Vg3H^yw`)PEtRVbH9 zq|>P;p88QFpJ6DT!e*GI(*%-HD4Nrp997ROBy~84l#|H8LL9u1UIoQDvKKon-7L!f=zWorLYD3W)DrwqjC!3ZruW5NTeT6~?iC{`*nv=>`;HBi_GgnDY{z|0 z{Nseos5L;AXlaS{&5ZH`1kF9F8i*^-nVI}QwSc+NJ5YCd*+ViVpGGEPja0@dh)N6) zhT)L7A{aP{ju9qWu*x2aFFIv{mSJXRia1=9I7(Sq8C#^UF|>uL4;^yq`^lIfH-|%o zOWWYtKu}&pg2wc@iv&ZtTz)U%{vOeKdX??+NxFlps~U_kks=caLX;Ar0RSXQ7D`|V zgPBM)IG7FtzZ=v2Zyr8T4+wk?HNQ*hwLMYS9y!rhO&Gh{H6j>5$iRr0Ay#lOTo95W zNm5+$NNEOSux+bL7Aa&(KqzJbD}ZB|dU~mcagt$?F-s7^02GRQWCZnnTm*4UrikCz zEK#LzyHYgMQfa23=3|+Fm|=;A6*E{aWlYv#g+yixg625HV4psJ50}sOp!0zR=eWt? zQ?r8hI?2s#OhAJOGYl3{r5IWYDgG|K2Z3}b;nbv&5k``jMHL5ih*b?l6jJv?l7xW- zLJ0#vQgKW%E(?cBmX}9C=78Xw1(iD?mqVJ9Fr>f}C`1f1RFnZQCvJ>WB^{9is%6%eC`dpMvxFjK z?=IXZDpN>p1oXlt-Q2_t=5`B_X`CS@ z6qrI9-Wu(;7G=#h8x7%VY*d#cgHaI2R~Kk7u451eBXhVF!Rk+Nbz{A(hy%5_CvU-$ zB|IJ#sT7YURE`k-lvL|lqHfHQdVJwli^4o7W-CCu9;|J z1s{y3>6yYrpzR>|0;GRWDI7nCOS8vcyvQ%1Ew7$wMf<{_0^Il%t_6Y zV>=Ek%s8!C-4Vk-bE72nZbAS))C}oyRe&;}I1p4%N-rQ-1NU(Lzo}yKMvz}~FR-6v zK%9lm%sf~DhQS$`V+^6~&|L*pEQFNaZdaz0y7q4?3wG=nMc5E9)hNj_2$K*zh?;7g zmBda)ZtMgUrkjdr3CTdJ2irzE$L@FYPUK%M)Dj?+B};=suaJZz3Z+4yBoPQ03P}R6 zKF`xE&H9pLy-ujpab)#XoJQ$&+GW#nX}%rot=MvEx7v;sX0wM6a)S%_&N$kiGv#;+ z6WS?mt5mGRAWTBhaDoIOn1yKd3v}JSjITNS9?D%%qXr-rET4ZD@YymsMX0z7@x_DK z*QOgumDHNW%_jnxe)?yT!>dAN@Y}aHX@@4XK)R0%A~1H|bKCgSnf-7Qz`SoPG+!1S zGo_lrqXt=%3}uvN49c&Rl_*YF0$+;zjxe5`Stdp;ug{B7ZZ6(D_g~%IqOv$W4qjb3 z^QXB;9&1t1Ds7GwhyfoFHE;jClH2SC_|6f+pu#E@ZR zl0d>p#2q&mWKN*U9YD#019^-u78jMFYKB>(fsCORN*lQBE=IB;xh9%q;MrkL0iJ~4 zCc@fSFiY$oDU1PG3kF3UTxGcf%*e=c5oMVvv7OZ7PGf*5RN97-vJ)a2G87=o ze4Gn*^tjw@9V>BZ+m3C%JeQZrc%?yVK&g64AVfq*WjV^L-0jxNa}QA89;&t{B8O4n z`{HJ}0k?rQig-g6GLcbfJ0L4DM~U&IIL{yt zpdj2^yuVXh3u)5v=+^JX;p90!rh57`;J@8TyXW9>8K-CyQJ}nBP-x1&my>;REAeok z9iTS>1jQ~WfGf*@P@B6}hu+JAItoX9sLP2^&>V)7`|ESGshbBD*@% zY|up|kPfZ(sBzGV3mAkNLAFX&m^A5|>6mY$>{ZWg+@#g zP%{wEG>1r5^`b(Mo&AL!^bKW_NeiYtlQ5)?dAF%Xwhgs@Ad>P!YuEWv9fayMTx zM%!owGP=sfqG^>Wqkch?3&vqX-qcJB~3*237!_9 z;@!-IpqM5sX$eFO3=7U+UZG&ah*gB^qz=DT*D zyrKAev=;Y4m+u=?d{mVb^{63Cks_D6tcCvdl-=tz0M!*z{&wxv2wwa|r_qH;6P=JE zV+sQHrF5jhtvO7_Zzk&9h}=lTfTe<*Ok^T-tV9h0NLU5}7-E5$0vQG%3{}FD5HQRD z#FR;Z!qW_3Qb`gC5|R)zF~Y%mz)>-TWRis`0N_4pLY|0}g~m{DTvHrSs*z5#bxl%8 zTr&}6-U-&O1HfcTb_8e=g_r_Rg+e7#kWkaCcoB{WPT+1Ch)K~_>|IGihKZza6>AEK zE_jI&`;l1`Dqjv(rgLg-tq^M@jA+Akykv`Oc{E(|xBWU_X@mv12VE0KZVAo6MM&_N z;YkZDC^{gNshG+XIC3;3pb{0?z~rf`8k!(NU<{hz;E^U#aKlBm6Dt%ntfXOxwS=X% znHt|F%F03UPl|NSiaMhbxhxizDj9+;EGAAeVq!wFvPlUF!bu4U zD+z%lAqj$DxUGqZrb1##l2DkENg&A}Ncocg~z zy=MI<4r%lk^G%9f8B+ABO`Ad#YEUv=;wnN4#j$j%$UdmNvq_gY-gdbkB&rrn2cotm z-jgp1hChVK)4!xdL<9$R<`GNCf)SLx38!KXT~)M?bsTwjUu?8D3&MS71@kb>U9||& zi8StII?11YUel*Gu;!l5-quHhFuP_Ki0gepW6f`FT3)rLb0)10O+w=?Sf-s&R_Xfq zyei|GJ9fZwBiE|iu@q&&GIYmmdSY$i>i&?pyn^{fzQH+?1(U#@C>tizvV4>9&J&Vx zPu)$EqGafwROL3DXH4_WPp)EovlAvz$&)4o?3prlOqnud2%Ob34oImM1;{aOcH5i$vWnzT*=!q zWW`;b1pX$(r;S49TfHIEw!#`16}}q;RnaPEGXo0I82Zu`6g@Xk3@VV&`4!EiX1NZ}zmg zKV94+O*ilIP$dto1#2e) zJo{AY>~q>}R^A^wqkZ$cJ2A}<^>8KnODQedO-;0zl~ZXv^x91%+DwG(r6jPI3b$)7 za|)9%MAFG(_iua2<@0@ad32XhDKSJM6Sd@YMT|^8cXt?*MIa{y$;W)8Wm6R91&X`= z%)(ey9UO4XQ4Fcc!1$H^71`G<3VZ=?f4hkBzk9F+R19BCf&Z4%?%=D@3ewCMSX=RB zCvxL`z?6thp=ewjl0=La0GcIXH&A`_v)}x0=F$DH_Lj-;re!&&a$P<$da312sbo{~ zeFgURAR**4)p}q{0_o}sUtZh5?rO)69Mqv+3V=kJxX6V8l*SxwdTET9voK%4slmlI zDYCpV8vhgN^tz(m&VE^mlM^N;OqeFoaod6*W__N)*`k#qh43r(5LG~riF6hJ4cRBu zRGC*t`;+r(5D}cP9RcSBAn|HIYF6rl<@nu*ZJpL_tsqwJ~ zZ1104v(HS(oe@J>U1(F`R$?9RQ~vh*H_X9|!;9HGhRz$bo$&H)-&MU>zlCC-W5Iu1 zo>Fz5^bm?hKSq`qwQVx4v z2Lx)rdwLh9;9Q`tZi63pTw)-r<^eo@4lw#LX6_5(du;IZEM2eWtw>qL^;MZiIdswv z;(Rck5xOQl}(T;!Qt zCFCSCP@My=a~7P{W-@SO;3>QUPcLW?;{=817NQj)HSd{D*KePkZl`J1Xh@mFM{dHK zfW_a?c8gU#^!ADnuI4`#@>d7Dmh50F@&T6}WtoTte( zH6@aWDN#rxo?*=!p>icKsa^=MwKs67*`>!Ut##b3mA?go=;^376}@m( zRH;K`#6oYVSS(ON%3zRe5yKScdEq3~)RUvYKyf!%cu5LKS(8+>om4ATLlq`Sz@(J1 zz*cl~#X9*-EM?N#cpFn}M$fw~PID$qnK;f9Q=HsQ(;~@}CMG6Kn3*zm%}q__rwOUT zZqX#1P9`T4h$D$4pBLc#H#`3O;p%C_`Z(6sH0-OKdvYBq2bVW?yzG_FkxUdj(x?}g z$BBYT;ATPd5dp#+<;j4`ksEH!W7WoESyd+H7iJslM@D?J(H#fx#wt0~^kOGm$u3Gv z?E8E>c)hc;I$b@}XKGBku&$4adui>Ooyxl)u1dw%4GUBcm~kV$G9Q_$;C8WE)z2)^ z-miN~(C8+^Wge=xQ=JNQR~yHVH;y`J)1dozJWzL%l8~~5N<$103L`=yOd>fVo%j@b z9zjf8e7FgA-qX(gG-eES4_89ot~l1!6#T)YZFuqda*b=vJQU%u!<)lsY?v_MEIE|E zkV4x?1(pPo)qx5`@p%9&3?T^uBtW2s@Y7UIX}1u|0+})iTUsRt10!g-y_Sad+yZ1O zWtP$nEhJqp0!+}+nv_orDELIpDGHigIYC_BK0!|zO^!?v)GyDZHgtP`?)d+8dUU*u z4$EWq&m#K2F22tAtp{iYWt3u=rcw8&uL~n{U-swV6_h7)J!O=4SCa1Z zr-^M(ZBBJwJd=4X{)00@x7_(-=3!HewiR2_+uNX=Rb=aBSiPz96W+dO!WnY)Jnu%| z3J;z?LZ186@?uY~nir8w$P^<6Fl3m@mQ{>lo_#%g9|`52Dd$Q6ac~A2NjwSYC!I1$ zCMoAhq|#|Q`n#RQIDNei>+&uF?&@2(KBw7EK2HHYmNex$XECZgu_qzSsp<3n=ga!% zuP5$)hur!fLSFaUnfjy?J)95B$twxFcVCG?U<4V683*Nj=B^Lh#ImdvHz|M{QZQQv zn!)wM@k@P^gY<>+&WRsRMXI>9aATW!2PEj9d6V)s9M(NA+Ro=xZi}x68wr%?E^G5k zx3!Y5$@u?EsW+8A86sJVWXYGypz`jYxOP=1Y&@TREmczBc+GyMy74TOM34;s&i1I% zRLF^B0e6|Slqrgm3UV%%^@c;prg9K_3c;cSBg2@Q4Sh^=&fMExduwVo0ybO7SHQ z!s>*9PJTfI3nEXYS@s33YYW;oCLXXHSLc+IvW2G&EU+jUKVK6 zn=8HDMAYo5B`#2e?qfweD)z{On8i2o_k|=(=^@Bj z^53(d2=jKs0l2S0<4Ym~F&Xfjs>#7JZBTE%_E;ke5r!fJE@-%zC?gX?hHOwRhG@Qa zn(Q%DlZX@poVB7>R(d4gbINqSx$i`<5Cb&DSWAflNmvpUg!258&v{f6&F0HJoMHsd zE&%W2*U&KC3F&Dq%WouRBTbAdZL7#`srZS|qHOD!3uMfOFs7seO64ovPg`=EQ`t|Y zkZ7%pDVS8O4uv7i#*U5gwIfa2qZNg-@1%S^zCl;dJYOB-PM?#@;_^<{c49}Nsb~*y z793Epb@9BM;+h7Qi!m~rh=wr%8S9+{(17Sgi8(SY*IZdnI9V&75EaO%w+o~(#TGLz z&KRS`z3wdeWM@pxZ4Y7UdcW=Nq;X5`-4)Gt$X`hKeR`Xz>z;}DC*_;InMY7-#^*G( z@BNv6&*7uKafjJjq8xH7+ekfOpzG@*jw^mpamF!UVDtPc_BUd#`w-4rCbC<=*GhD; zROBk`Da_x1aMjTcZ7x%bYU7sl^u=TGxtcD@LAA2wRe9oiCx0(|O0{Y(#Y453WHSRS z$Y8d$qMa~hhOjk?J1z@raq{=UUnSs4>%Q|YE|;<74!mz@mhE+5m!pTX(yP;PakW;v z)n1Z=d<-16XQ^;+7j!NW3bfMDYbe5cS+TUWLlr*qzb*Jh(3wt9JU%@9Mwo~wxxxUV zNQEUGle6KyMSjj8dZ(&&&(}IGnDrw%PfngL!uir;t%stz@-GK(l~w5C>D6w@=2MLy z0-p=_?+e=KTwae)4)r@J!GLA>_ES=*a+r+>a%ok!nXSZSVrZ2jNLNeX2DquMCpS`Q zQP_we%xGEw!Ak)$zzj*#4bml?g9QyVu^k8lAvQtTAfSXLnUM$#g~gojM&kLC+wM&+ zfWJ4VQ=w;3SHGh0_YE=dh}GT|Oj1kTPT|OA+|o!epeY?MlvI6K9USX8}jT2sbTJ-ZCin`_MeN`5cpb^g2}6@C2iT7 zq?gdy!J=&qz^)9RPRZo_S;5sN>qQx+b<8x?speixp0bIxS-%&sI^gMf z?+fAJa$V)w3Vy~}F;Vi1X{nXd)X|LAwW&rGgzK`nAmBgrrrZ|VYAl*DJQ$giKWZ<) zonES+32UnEqgwLhJ{_3I?7-EQHET4~`Ll|+oZQ>1iIm0^oSB#gjYCZ_SEA#X)2n!n!*wn-<0uh-6yj@dw`%qHg(u(^XL>O;YZaE< z2y*d5+NWP)u|%^b&V9pbvI3w1C|*e9O=$}792u$J(J9g|-5eo8bO4sD@t+qmcDPN3 z_ko9v;5joRQQ1wWs$hd7#1r<-uS)&>#RNtLH) z=cCJ8nsX%<bdGZMOLCGuh=`dCW|F*TDpK1BT!^+^&$ zo}F~21|dkfE-u8V!Gai%xevdIAA10=EN^tbW#q0a|@~VD`#qaj;dwt&jIWc$F zWIqh2-9F+6+dg@dCXhKbyAk*8vfOPq7v7~S*;R^JNrHm`yCUB^qO8q=zfRlz1C))f zO6MEX@AKq?q;kn=2Hx%H)r{(JQ);oIYon`vqT*yYP1vqQ)0}oA9_DRFLC|P*fgqt^ z#-h$;fPgB)s7yV-Q!YeZpCjdw0~t6m9aE}g$&)5bpQrXWbS*PYEeh=g3x-a8;)>56PV7wW);GQpQ_o z#PRoLZ0JWe9}XAM7r{(VXVKS&XURTE#5(ZGW6530cVEBax_5q}@W9h4Yt5u@g7V~B zcxv)%i}sD4G`Zh}UXpYi`Ug&%HW$(^YMy03I-h(zbvGBOZZ0DA*G1bFMZ1PDtfPvb zLYSs0(5F;f6VdH?yYtRjD`oGmUmO+YF`0~Egf1o|dv$zCb|q}!mCl!yk-F)&>X$*1 zzJ_eM!{ege=4tp5c_)zUI{MkwGoh=>TAe1m9t<6>)b;juQ&i~ee!g*b^dpS;r{S4D zVr2b^lX<+}Z#{F_KH2uot*x!Epj_8|dyAszx-N@rYiny~RNiFXWZq=;sq)jdk?6__ z{#UnUJbm8ZXuRL^98U!eqs{$3G zKq9Mpqgyj0JeOIscV4i8pcd&vR_rqfeNlP9piZ^8xGGG*C+rpgzL%25ZFCfYzeD1%~or zOSA2JU9U!~LgoS!9+esps>t{kMA2Tf@T4bH`9~*kA0-^srp}tCU5o}c{L0Otwu)_5 zQXC$*cqs6_6P+M>QVywa2RX19smxF}O%TwIkXSg9WhRjD@i%4}Rj5XW3Kb?mHp^DV zrdeKE+VP$+~fvA*|Q9X3}Q_W5aQ%b3}n`wNNlct)9beSpZCNgHHca`8)=e6OOl6n&m{-7b> z@E!BQ8E9RlM5>gM%3LRl%pyy!m-qOqB?B(XQA#OrmQ#L|Qt2$Eq`^vwf|iox6uK~d z=#KC`@Q^5_!bta^)JkblBuZ&9E>dDA6aH7h9aaDKDvZcE&QnA-#XrH~KgnM7h@Y&W QPyfZ-kxmpOJk>pPfWBie*#H0l diff --git a/R/utils.R b/R/utils.R index 089349c2ca..acab4d56d0 100644 --- a/R/utils.R +++ b/R/utils.R @@ -39,6 +39,11 @@ names2 <- function(x) { names(x) %||% rep("", length(x)) } +# currently implemented non-positional scales in plot_ly() +npscales <- function() { + c("color", "symbol", "linetype", "size") +} + # modifyList turns elements that are data.frames into lists # which changes the behavior of toJSON as_df <- function(x) { @@ -129,29 +134,31 @@ verify_box <- function(proposed, schema) { # make sure trace type is valid # TODO: add an argument to verify trace properties are valid (https://github.com/ropensci/plotly/issues/540) verify_type <- function(trace) { - if (is.null(trace$type)) { + isNULL <- is.null(trace$type) + if (isNULL) { attrs <- names(trace) attrLengths <- lengths(trace) if (all(c("x", "y", "z") %in% attrs)) { - trace$type <- if (all(c("i", "j", "k") %in% attrs)) relay_type("mesh3d") else relay_type("scatter3d") + trace$type <- if (all(c("i", "j", "k") %in% attrs)) "mesh3d" else "scatter3d" } else if (all(c("x", "y") %in% attrs)) { if (!is.discrete(trace$x) && !is.discrete(trace$y)) { - trace$type <- if (any(attrLengths) > 15000) relay_type("scattergl") else relay_type("scatter") + trace$type <- if (any(attrLengths) > 15000) "scattergl" else "scatter" } else if (!is.discrete(trace$x)) { - trace$type <- relay_type("bar") + trace$type <- "bar" trace$orientation <- "h" } else if (!is.discrete(trace$y)) { - trace$type <- relay_type("bar") + trace$type <- "bar" } else { - trace$type <- relay_type("histogram2d") + trace$type <- "histogram2d" } } else if ("y" %in% attrs || "x" %in% attrs) { - trace$type <- relay_type("histogram") + trace$type <- "histogram" } else if ("z" %in% attrs) { - trace$type <- relay_type("heatmap") + trace$type <- "heatmap" } else { - warning("No trace type specified and no positional attributes specified", call. = FALSE) - trace$type <- relay_type("scatter") + warning("No trace type specified and no positional attributes specified", + call. = FALSE) + trace$type <- "scatter" } } if (!is.character(trace$type) || length(trace$type) != 1) { @@ -163,12 +170,17 @@ verify_type <- function(trace) { "'", paste(names(Schema$traces), collapse = "', '"), "'", call. = FALSE) } + # if scatter/scatter3d/scattergl, default to a scatterplot + if (grepl("scatter", trace$type)) { + trace$mode <- trace$mode %||% "markers" + } + if (isNULL) relay_type(trace$type, trace$mode) trace } -relay_type <- function(type) { +relay_type <- function(type, mode = NULL) { message( - "No trace type specified. Applying `add_", type, "()`.\n", + "No trace type specified. Applying `add_", mode %||% type, "()`.\n", "Read more about this trace type here -> https://plot.ly/r/reference/#", type ) type diff --git a/README.md b/README.md index dea425f831..322c106e94 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # plotly -An R package for creating interactive web graphics via [plotly.js](https://github.com/plotly/plotly.js). +An R package for creating interactive web graphics via the open source JavaScript graphing library [plotly.js](https://github.com/plotly/plotly.js). ## Installation @@ -34,21 +34,21 @@ ggplotly(g) ![https://plot.ly/~cpsievert/9836](http://i.imgur.com/6G4zv7b.png) -If you'd like to see how `ggplotly()` does in converting different ggplot2 examples, we host a [plotly version](http://ropensci.github.io/plotly/) of the [official ggplot2 documentation](http://docs.ggplot2.org). We also have some of our own examples [here](https://plot.ly/ggplot2/). +If you'd like to see how `ggplotly()` does in converting different ggplot2 examples, we host a [plotly version](http://ropensci.github.io/plotly/ggplot2/) of the [official ggplot2 documentation](http://docs.ggplot2.org). We also have some of our own examples [here](https://plot.ly/ggplot2/). ### plotly's custom R interface -__plotly__ supports some chart types that ggplot2 doesn't (such as 3D [surface](https://plot.ly/r/3d-surface-plots/), [point](https://plot.ly/r/3d-scatter-plots/), and [line](https://plot.ly/r/3d-line-plots/) plots). You can create these (or any other plotly) charts using `plot_ly()`. +[plotly.js](https://github.com/plotly/plotly.js) supports some chart types that ggplot2 doesn't (our [cheatsheet](https://images.plot.ly/plotly-documentation/images/r_cheat_sheet.pdf) provides a nice summary of the available chart types). You can create any of these charts via `plot_ly()`. ```r -plot_ly(z = volcano, type = "surface") +plot_ly(z = ~volcano) ``` ![https://plot.ly/~brnvg/1134](https://plot.ly/~brnvg/1134.png) -For a more concise overview of the `plot_ly()` interface, see [here](https://cran.r-project.org/web/packages/plotly/vignettes/intro.html). You might also find our [examples](https://plot.ly/r/#basic-charts) and the [figure reference](https://plot.ly/r/reference/) to be helpful. +We have a number of [vignettes](https://ropensci.github.io/plotly/) which explain the `plot_ly()` interface in depth as well as numerous examples on the [plotly website](https://plot.ly/r/#basic-charts) and [bundled with the package](https://github.com/ropensci/plotly/tree/master/inst/examples). -### Hooking onto plotly events +### Capturing plotly events [plotly.js](https://github.com/plotly/plotly.js) exposes a number of 'standard' events that work consistently across plot types. It's easy to hook into these events using the `event_data()` function in shiny apps, as these examples demonstrate: @@ -58,7 +58,7 @@ For a more concise overview of the `plot_ly()` interface, see [here](https://cra ![http://104.131.111.111:3838/plotlyLinkedBrush/](http://i.imgur.com/eVqsZma.gif) -You can also hook into these events without shiny using `htmlwidgets::onRender()` ([example](https://github.com/ropensci/plotly/tree/master/inst/examples/onRenderHover)). This, however, requires JavaScript knowledge and makes it much harder, if not impossible, to coordinate views between htmlwidgets. +You can also hook into these events without shiny using `htmlwidgets::onRender()` ([example](https://github.com/ropensci/plotly/tree/master/inst/examples/onRenderHover)). This, however, requires JavaScript knowledge and makes it much harder to coordinate views between htmlwidgets. ## Contributing diff --git a/man/add_trace.Rd b/man/add_trace.Rd index dd16c61fd8..4d7426c17b 100644 --- a/man/add_trace.Rd +++ b/man/add_trace.Rd @@ -24,14 +24,13 @@ \usage{ add_trace(p, ..., color, symbol, size, linetype, data = NULL) -add_markers(p, x = NULL, y = NULL, fill = NULL, stroke = NULL, - alpha = 1, ...) +add_markers(p, x = NULL, y = NULL, z = NULL, ...) -add_text(p, x = NULL, y = NULL, text = NULL, ...) +add_text(p, x = NULL, y = NULL, z = NULL, text = NULL, ...) -add_paths(p, x = NULL, y = NULL, ...) +add_paths(p, x = NULL, y = NULL, z = NULL, ...) -add_lines(p, x = NULL, y = NULL, ...) +add_lines(p, x = NULL, y = NULL, z = NULL, ...) add_segments(p, x = NULL, y = NULL, xend = NULL, yend = NULL, ...) @@ -57,7 +56,7 @@ add_boxplot(p, x = NULL, y = NULL, ...) add_surface(p, z = NULL, ...) -add_scattergeo(p, ...) +add_scattergeo(p, geo = "geo", ...) add_choropleth(p, z = NULL, ...) } @@ -82,17 +81,13 @@ provided, arguments are evaluated using the data frame in \code{\link{plot_ly}() \item{y}{the y variable.} -\item{fill}{fill color} - -\item{stroke}{stroke color} - -\item{alpha}{alpha transparency} - \item{text}{textual labels.} \item{ymin}{a variable used to define the lower boundary of a polygon.} \item{ymax}{a variable used to define the upper boundary of a polygon.} + +\item{alpha}{alpha channel applied to color (on 0-1 scale).} } \description{ Add trace(s) to a plotly visualization @@ -114,7 +109,7 @@ plot_ly(economics, x = ~date, y = ~uempmed) \%>\% txhousing \%>\% group_by(city) \%>\% plot_ly(x = ~date, y = ~median) \%>\% - add_lines(line = list(color = toRGB("black", 0.2))) + add_lines(fill = "black") ggplot2::map_data("world", "canada") \%>\% group_by(group) \%>\% diff --git a/man/plot_ly.Rd b/man/plot_ly.Rd index d21e028737..5b074bb050 100644 --- a/man/plot_ly.Rd +++ b/man/plot_ly.Rd @@ -5,8 +5,9 @@ \title{Initiate a plotly visualization} \usage{ plot_ly(data = data.frame(), ..., type = NULL, group, color, - colors = NULL, symbol, symbols = NULL, size, sizes = c(10, 100), - linetype, linetypes = NULL, width = NULL, height = NULL, source = "A") + colors = NULL, alpha = 1, symbol, symbols = NULL, size, sizes = c(10, + 100), linetype, linetypes = NULL, width = NULL, height = NULL, + source = "A") } \arguments{ \item{data}{A data frame (optional).} @@ -17,19 +18,29 @@ Note that acceptable arguments depend on the value of \code{type}.} \item{type}{A character string describing the type of trace. If \code{NULL} (the default), the initial trace type is determined by \code{add_trace}} -\item{color}{Either a variable name or a vector to use for color mapping.} +\item{color}{A formula containing a name or expression. +Values are scaled and mapped to color codes based on the value of +\code{colors} and \code{alpha}. To avoid scaling, wrap with \code{\link{I}()}, +and provide value(s) that can be converted to rgb color codes by +\code{\link[grDevices]{col2rgb}()}.} \item{colors}{Either a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"), or a vector of colors to interpolate in hexadecimal "#RRGGBB" format, or a color interpolation function like \code{colorRamp()}.} -\item{symbol}{Either a variable name or a (discrete) vector to use for symbol encoding.} +\item{alpha}{A number between 0 and 1 specifying the alpha channel applied to color.} + +\item{symbol}{A formula containing a name or expression. +Values are scaled and mapped to symbols based on the value of \code{symbols}. +To avoid scaling, wrap with \code{\link{I}()}, and provide valid +\code{\link{pch}()} values and/or valid plotly symbol(s) as a string +\url{}} \item{symbols}{A character vector of symbol types. For possible values, see \link{schema}.} \item{size}{A variable name or numeric vector to encode the size of markers.} -\item{sizes}{a numeric vector of length 2 used to scale sizes to pixels.} +\item{sizes}{A numeric vector of length 2 used to scale sizes to pixels.} \item{linetype}{Either a variable name or a (discrete) vector to use for linetype encoding.} @@ -57,15 +68,15 @@ plot_ly(economics, x = ~pop) plot_ly(economics, x = ~date, y = ~pop) # plot_ly() doesn't require data frame(s), which allows one to take # advantage of trace type(s) designed specifically for numeric matrices -plot_ly(z = volcano) -plot_ly(z = volcano, type = "surface") +plot_ly(z = ~volcano) +plot_ly(z = ~volcano, type = "surface") # plotly has a functional interface: every plotly function takes a plotly # object as it's first input argument and returns a modified plotly object -add_points(plot_ly(economics, x = ~date, y = ~unemploy/pop)) +add_lines(plot_ly(economics, x = ~date, y = ~unemploy/pop)) # To make code more readable, plotly imports the pipe operator from magrittr -economics \%>\% plot_ly(x = ~date, y = ~unemploy/pop) \%>\% add_points() +economics \%>\% plot_ly(x = ~date, y = ~unemploy/pop) \%>\% add_lines() # Attributes defined via plot_ly() set 'global' attributes that # are carried onto subsequent traces diff --git a/tests/testthat/test-plotly-color.R b/tests/testthat/test-plotly-color.R new file mode 100644 index 0000000000..966db824ce --- /dev/null +++ b/tests/testthat/test-plotly-color.R @@ -0,0 +1,80 @@ +context("plotly-color") + +expect_traces <- function(p, n.traces, name){ + stopifnot(is.numeric(n.traces)) + L <- save_outputs(p, paste0("plotly-", name)) + expect_equal(length(L$data), n.traces) + L +} + +test_that("plot_ly() handles a simple scatterplot", { + p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, color = ~Petal.Width) +}) + +test_that("Mapping a factor variable to color works", { + p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, color = ~Species) + l <- expect_traces(p, 3, "scatterplot-color-factor") + markers <- lapply(l$data, "[[", "marker") + cols <- unlist(lapply(markers, "[[", "color")) + expect_equal(length(cols), 3) +}) + +test_that("Custom RColorBrewer pallette works for factor variable", { + cols <- RColorBrewer::brewer.pal(9, "Set1") + # specifying a pallette set should "span the gamut" + p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, color = ~Species, + colors = "Set1") + l <- expect_traces(p, 3, "scatterplot-color-factor-custom") + markers <- lapply(l$data, "[[", "marker") + colz <- unlist(lapply(markers, "[[", "color")) + expect_identical(sort(cols[c(1, 5, 9)]), sort(colz)) + # providing vector of RGB codes should also work + p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, color = ~Species, + colors = cols[1:3]) + l <- expect_traces(p, 3, "scatterplot-color-factor-custom2") + markers <- lapply(l$data, "[[", "marker") + colz <- unlist(lapply(markers, "[[", "color")) + expect_identical(sort(cols[1:3]), sort(colz)) +}) + +test_that("Passing hex codes to colors argument works", { + colz <- c('#FE8268', '#81E8FE', '#FED681', '#81FED6', '#FE81A9') + d <- data.frame(Category = LETTERS[1:5], Value = 1:5, stringsAsFactors = FALSE) + p <- plot_ly(d, x = ~Category, y = ~Value, type = "bar", + color = ~Category, colors = colz) + l <- expect_traces(p, 5, "bar-color-factor-custom") + colz2 <- sapply(l$data, function(x) x[["marker"]][["color"]]) + expect_identical(sort(colz), sort(colz2)) +}) + +test_that("Mapping a numeric variable to color works", { + p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, color = ~Petal.Width) + # one trace is for the colorbar + l <- expect_traces(p, 2, "scatterplot-color-numeric") + idx <- vapply(l$data, is.colorbar, logical(1)) + markerScale <- l$data[[which(idx)]]$marker + markerDat <- l$data[[which(!idx)]]$marker + expect_identical(markerDat$color, iris$Petal.Width) + expect_identical(markerScale$colorbar$title, "Petal.Width") + expect_equal(min(iris$Petal.Width), markerScale$cmin) + expect_equal(max(iris$Petal.Width), markerScale$cmax) + expect_true(all(0 <= markerScale$colorscale[,1] & markerScale$colorscale[,1] <= 1)) +}) + +test_that("Custom RColorBrewer pallette works for numeric variable", { + p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, + color = ~Petal.Width, colors = "Greens") + # one trace is for the colorbar + l <- expect_traces(p, 2, "scatterplot-color-numeric-custom") +}) + +test_that("axis titles get attached to scene object for 3D plots", { + p <- plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width, z = ~Sepal.Width, + type = "scatter3d", mode = "markers") + l <- expect_traces(p, 1, "scatterplot-scatter3d-axes") + scene <- l$layout$scene + expect_identical(scene$xaxis$title, "Petal.Length") + expect_identical(scene$yaxis$title, "Petal.Width") + expect_identical(scene$zaxis$title, "Sepal.Width") +}) + diff --git a/tests/testthat/test-plotly-group.R b/tests/testthat/test-plotly-group.R new file mode 100644 index 0000000000..66ef1cedc9 --- /dev/null +++ b/tests/testthat/test-plotly-group.R @@ -0,0 +1,54 @@ +context("plotly-group") + +expect_traces <- function(p, n.traces, name){ + stopifnot(is.numeric(n.traces)) + L <- save_outputs(p, paste0("plotly-", name)) + expect_equal(length(L$data), n.traces) + L +} + +# oh no, June is missing! +e <- economics +isMissing <- format(economics$date, "%m") == "06" +e[isMissing, ] <- NA + +p <- plot_ly(e, x = ~date, y = ~pce) + +test_that("Missing values are preserved for lines", { + l <- expect_traces(add_lines(p), 1, "NAs") + expect_equal(sum(is.na(l$data[[1]]$x)), sum(isMissing)) +}) + +test_that("Can connectgaps without groups", { + l <- expect_traces(add_lines(p, connectgaps = TRUE), 1, "NAs-connect") + expect_true(l$data[[1]]$connectgaps) + expect_equal(sum(is.na(l$data[[1]]$x)), sum(isMissing)) +}) + +test_that("Warning is thrown when missing values are ignored", { + expect_warning( + plotly_build(add_markers(p)), + paste("Ignoring", sum(isMissing)) + ) +}) + +e2 <- tidyr::gather(e, variable, value, -date) + +p2 <- e2 %>% + group_by(variable) %>% + plot_ly(x = ~date, y = ~value) + +test_that("Missing values are preserved for lines within a group variable", { + l <- expect_traces(add_lines(p2), 1, "NAs-within-group") + expect_true(sum(is.na(l$data[[1]]$x)) >= sum(is.na(e2$date))) + p2b <- add_lines(p2, connectgaps = TRUE) + expect_error(plotly_build(p2b), "connectgaps") +}) + +p3 <- plot_ly(e2, x = ~date, y = ~value, color = ~variable) + +test_that("Missing values are preserved for lines within a color variable", { + l <- expect_traces(add_lines(p3), 5, "NAs-within-color") + # connectgaps makes sense in this case + l <- expect_traces(add_lines(p3, connectgaps = TRUE), 5, "NAs-within-color2") +}) diff --git a/tests/testthat/test-plotly-linetype.R b/tests/testthat/test-plotly-linetype.R new file mode 100644 index 0000000000..ec617acc9a --- /dev/null +++ b/tests/testthat/test-plotly-linetype.R @@ -0,0 +1,42 @@ +context("plotly-linetype") + +expect_traces <- function(p, n.traces, name){ + stopifnot(is.numeric(n.traces)) + L <- save_outputs(p, paste0("plotly-", name)) + expect_equal(length(L$data), n.traces) + L +} + +# subset to five cities +cities <- unique(txhousing$city)[1:5] +tx <- txhousing[txhousing$city %in% cities, ] +tx$city_ <- match(tx$city, cities) + +test_that("Mapping a variable to linetype works", { + p <- plot_ly(tx, x = ~date, y = ~median, linetype = ~city) + l <- expect_traces(p, 5, "linetype") + lines <- lapply(l$data, "[[", "line") + dashes <- unlist(lapply(lines, "[[", "dash")) + expect_equal(length(dashes), 5) +}) + +test_that("Can set the linetype range.", { + p <- plot_ly(tx, x = ~date, y = ~median, linetype = ~city, linetypes = 5:1) + l <- expect_traces(p, 5, "linetype") + lines <- lapply(l$data, "[[", "line") + dashes <- unlist(lapply(lines, "[[", "dash")) + expect_equal(dashes, plotly:::lty2dash(5:1)) +}) + +test_that("Can avoid scaling", { + p <- plot_ly(tx, x = ~date, y = ~median, linetype = I(3)) + l <- expect_traces(p, 1, "linetype") + lines <- lapply(l$data, "[[", "line") + dashes <- unlist(lapply(lines, "[[", "dash")) + expect_equal(dashes, plotly:::lty2dash(3)) +}) + +test_that("Warn about invalid linetypes", { + p <- plot_ly(x = 1:2, y = 1:2, linetype = I("DNE")) + expect_warning(plotly_build(p), "DNE") +}) diff --git a/tests/testthat/test-plotly-symbol.R b/tests/testthat/test-plotly-symbol.R new file mode 100644 index 0000000000..3ad5b8908d --- /dev/null +++ b/tests/testthat/test-plotly-symbol.R @@ -0,0 +1,39 @@ +context("plotly-symbol") + +expect_traces <- function(p, n.traces, name){ + stopifnot(is.numeric(n.traces)) + L <- save_outputs(p, paste0("plotly-", name)) + expect_equal(length(L$data), n.traces) + L +} + +test_that("Mapping a variable to symbol works", { + p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, symbol = ~Species) + l <- expect_traces(p, 3, "scatterplot-symbol") + markers <- lapply(l$data, "[[", "marker") + syms <- unlist(lapply(markers, "[[", "symbol")) + expect_identical(syms, c("circle", "cross", "diamond")) +}) + +test_that("Can set the symbol range.", { + p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, symbol = ~Species, + symbols = 1:3) + l <- expect_traces(p, 3, "scatterplot-symbol2") + markers <- lapply(l$data, "[[", "marker") + syms <- unlist(lapply(markers, "[[", "symbol")) + expect_identical(syms, plotly:::pch2symbol(1:3)) +}) + + +test_that("Setting a constant symbol works", { + p <- plot_ly(iris, x = 1:25, y = 1:25, symbol = I(0:24)) + l <- expect_traces(p, 1, "pch") + markers <- lapply(l$data, "[[", "marker") + syms <- unlist(lapply(markers, "[[", "symbol")) + expect_identical(syms, plotly:::pch2symbol(0:24)) +}) + +test_that("Warn about invalid symbol codes", { + p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, symbol = I("DNE")) + expect_warning(plotly_build(p), "DNE") +}) diff --git a/tests/testthat/test-plotly.R b/tests/testthat/test-plotly.R index cf79d19f1c..92051c121a 100644 --- a/tests/testthat/test-plotly.R +++ b/tests/testthat/test-plotly.R @@ -1,4 +1,4 @@ -context("plot_ly") +context("plotly") expect_traces <- function(p, n.traces, name){ stopifnot(is.numeric(n.traces)) @@ -7,6 +7,46 @@ expect_traces <- function(p, n.traces, name){ L } +# expect 2 plotly graphs to have the same traces +expect_same_data <- function(p1, p2) { + if (!is.plotly(p1) || !is.plotly(p2)) { + stop("Both arguments must be plotly objects", call. = FALSE) + } + d1 <- plotly_build(p1)$x$data + d2 <- plotly_build(p2)$x$data + if (length(d1) != length(d2)) { + stop("Number of traces is different.", call. = FALSE) + } + # for each trace, align the names (since ordering doesn't matter) + d1 <- Map(function(x, y) structure(x[names(y)], class = oldClass(x)), d1, d2) + expect_identical(d1, d2) +} + +test_that("plot_ly defaults to scatterplot", { + p1 <- plot_ly(mtcars, x = ~wt, y = ~mpg) + p2 <- plot_ly(mtcars, x = ~wt, y = ~mpg) %>% add_markers() + expect_same_data(p1, p2) +}) + +test_that("Variable mappings return same result regardless of where they appear", { + p1 <- plot_ly(mtcars, x = ~wt, y = ~mpg, size = ~disp) + p2 <- plot_ly(mtcars, x = ~wt, y = ~mpg) %>% add_markers(size = ~disp) + expect_same_data(p1, p2) + p1 <- plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~disp) + p2 <- plot_ly(mtcars, x = ~wt, y = ~mpg) %>% add_markers(color = ~disp) + expect_same_data(p1, p2) + p1 <- plot_ly(mtcars, x = ~wt, y = ~mpg, symbol = ~factor(am)) + p2 <- plot_ly(mtcars, x = ~wt, y = ~mpg) %>% add_markers(symbol = ~factor(am)) + expect_same_data(p1, p2) + p1 <- plot_ly(mtcars, x = ~wt, y = ~mpg, linetype = ~factor(am)) + p2 <- plot_ly(mtcars, x = ~wt, y = ~mpg) %>% add_markers(linetype = ~factor(am)) + expect_message(plotly_build(p1), "Adding lines to mode") + expect_message(plotly_build(p2), "Adding lines to mode") + expect_same_data(p1, p2) +}) + + + test_that("plot_ly() handles a simple scatterplot", { p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, mode = "markers") l <- expect_traces(p, 1, "scatterplot") @@ -18,83 +58,7 @@ test_that("plot_ly() handles a simple scatterplot", { }) -test_that("Mapping a variable to symbol works", { - p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, symbol = ~Species) - expect_message(plotly_build(p), "Adding markers to mode") - l <- expect_traces(p, 3, "scatterplot-symbol") - markers <- lapply(l$data, "[[", "marker") - syms <- unlist(lapply(markers, "[[", "symbol")) - expect_identical(syms, c("circle", "cross", "diamond")) -}) - -test_that("Mapping a factor variable to color works", { - p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, - color = ~Species, mode = "markers") - l <- expect_traces(p, 3, "scatterplot-color-factor") - markers <- lapply(l$data, "[[", "marker") - cols <- unlist(lapply(markers, "[[", "color")) - expect_equal(length(cols), 3) -}) - -test_that("Custom RColorBrewer pallette works for factor variable", { - cols <- RColorBrewer::brewer.pal(9, "Set1") - # specifying a pallette set should "span the gamut" - p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, - color = ~Species, colors = "Set1", mode = "markers") - l <- expect_traces(p, 3, "scatterplot-color-factor-custom") - markers <- lapply(l$data, "[[", "marker") - colz <- unlist(lapply(markers, "[[", "color")) - expect_identical(sort(cols[c(1, 5, 9)]), sort(colz)) - # providing vector of RGB codes should also work - p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, - color = ~Species, colors = cols[1:3], mode = "markers") - l <- expect_traces(p, 3, "scatterplot-color-factor-custom2") - markers <- lapply(l$data, "[[", "marker") - colz <- unlist(lapply(markers, "[[", "color")) - expect_identical(sort(cols[1:3]), sort(colz)) -}) - -test_that("Passing hex codes to colors argument works", { - colz <- c('#FE8268', '#81E8FE', '#FED681', '#81FED6', '#FE81A9') - d <- data.frame(Category = LETTERS[1:5], Value = 1:5, stringsAsFactors = F) - p <- plot_ly(d, x = ~Category, y = ~Value, type = "bar", - color = ~Category, colors = colz) - l <- expect_traces(p, 5, "bar-color-factor-custom") - colz2 <- sapply(l$data, function(x) x[["marker"]][["color"]]) - expect_identical(sort(colz), sort(colz2)) -}) -test_that("Mapping a numeric variable to color works", { - p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, - color = ~Petal.Width, mode = "markers") - # one trace is for the colorbar - l <- expect_traces(p, 2, "scatterplot-color-numeric") - idx <- vapply(l$data, is.colorbar, logical(1)) - markerScale <- l$data[[which(idx)]]$marker - markerDat <- l$data[[which(!idx)]]$marker - expect_identical(markerDat$color, iris$Petal.Width) - expect_identical(markerScale$colorbar$title, "Petal.Width") - expect_equal(min(iris$Petal.Width), markerScale$cmin) - expect_equal(max(iris$Petal.Width), markerScale$cmax) - expect_true(all(0 <= markerScale$colorscale[,1] & markerScale$colorscale[,1] <= 1)) -}) - -test_that("Custom RColorBrewer pallette works for numeric variable", { - p <- plot_ly(iris, x = ~Sepal.Length, y = ~Petal.Length, - color = ~Petal.Width, colors = "Greens", mode = "markers") - # one trace is for the colorbar - l <- expect_traces(p, 2, "scatterplot-color-numeric-custom") -}) - -test_that("axis titles get attached to scene object for 3D plots", { - p <- plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width, z = ~Sepal.Width, - type = "scatter3d", mode = "markers") - l <- expect_traces(p, 1, "scatterplot-scatter3d-axes") - scene <- l$layout$scene - expect_identical(scene$xaxis$title, "Petal.Length") - expect_identical(scene$yaxis$title, "Petal.Width") - expect_identical(scene$zaxis$title, "Sepal.Width") -}) test_that("type inference + add_data + layering works as expected", { p <- plot_ly(iris, x = ~Species) %>% @@ -124,11 +88,25 @@ test_that("grouping within multiples traces works", { g$response <- rnorm(nrow(g)) d <- group_by(g, id) p <- plot_ly(d, x = ~visit, y = ~response, color = ~cohort, colors = c("red", "blue")) - l <- expect_traces(p, 2, "group-within-trace") + l <- expect_traces(add_lines(p), 2, "group-within-trace") expect_equal(l$data[[1]]$x, c(1, 2, NA, 1, 2, NA, 1, 2)) expect_equal(l$data[[2]]$x, c(1, 2, NA, 1, 2, NA, 1, 2)) - expect_true(l$data[[1]]$marker$color == "#FF0000") expect_true(l$data[[1]]$line$color == "#FF0000") - expect_true(l$data[[2]]$marker$color == "#0000FF") expect_true(l$data[[2]]$line$color == "#0000FF") }) + +test_that("Alpha can be applied to both constant and scaled colors", { + p <- plot_ly(x = rnorm(100), y = rnorm(100), color = ~rnorm(100)) + p <- add_markers(p, alpha = 0.05) + p <- add_lines(p, x = -1:1, y = -1:1, color = I("red"), alpha = 0.4) + # one trace for the colorbar + l <- expect_traces(p, 3, "alpha-blending") + # verify the correct alpha for the points + rgbs <- l$data[[1]]$marker$colorscale[, 2] + alphas <- unique(sub("\\)", "", sapply(strsplit(rgbs, ","), "[[", 4))) + expect_equal("0.05", alphas) + # verify the correct alpha for the lines + rgb <- l$data[[2]]$line$color + alpha <- sub("\\)", "", sapply(strsplit(rgb, ","), "[[", 4)) + expect_equal("0.4", alpha) +}) From 1bd9d6a1f8b17739a4ff5417d03941bcd4f59eab Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 13 Jul 2016 15:35:46 -0500 Subject: [PATCH 72/73] fix bad example --- R/add.R | 2 +- man/add_data.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/add.R b/R/add.R index aabe29ea32..79149fc2eb 100644 --- a/R/add.R +++ b/R/add.R @@ -5,7 +5,7 @@ #' @export #' @examples #' -#' NULL %>% plot_ly() %>% add_data(economics) %>% add_trace(x = ~date, y = ~pce) +#' plot_ly() %>% add_data(economics) %>% add_trace(x = ~date, y = ~pce) add_data <- function(p, data = NULL) { if (is.null(data)) return(p) if (!is.plotly(p)) { diff --git a/man/add_data.Rd b/man/add_data.Rd index 0dbceb40e9..d22df35d6e 100644 --- a/man/add_data.Rd +++ b/man/add_data.Rd @@ -16,6 +16,6 @@ Add data to a plotly visualization } \examples{ -NULL \%>\% plot_ly() \%>\% add_data(economics) \%>\% add_trace(x = ~date, y = ~pce) +plot_ly() \%>\% add_data(economics) \%>\% add_trace(x = ~date, y = ~pce) } From 63e0ddbb5698b11a6e28c21f427abdd70ca168c4 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 13 Jul 2016 15:54:58 -0500 Subject: [PATCH 73/73] curse you cbind --- R/layers2traces.R | 2 +- R/plotly_data.R | 1 + man/plotly_data.Rd | 46 ---------------------------------------------- 3 files changed, 2 insertions(+), 47 deletions(-) diff --git a/R/layers2traces.R b/R/layers2traces.R index 3686fc2153..a7a00f2967 100644 --- a/R/layers2traces.R +++ b/R/layers2traces.R @@ -645,7 +645,7 @@ ribbon_dat <- function(dat) { tmp <- dat[o, ] others <- tmp[not_used] dat1 <- cbind(x = tmp$x, y = tmp$ymin, others) - dat1[n+1, ] <- cbind(x = tmp$x[n], y = tmp$ymin[n], others[n, ]) + dat1[n+1, ] <- data.frame(x = tmp$x[n], y = tmp$ymin[n], others[n, ]) # bottom-half of ribbon tmp2 <- dat[o2, ] others2 <- tmp2[not_used] diff --git a/R/plotly_data.R b/R/plotly_data.R index a5abfd757e..929ff0a2ed 100644 --- a/R/plotly_data.R +++ b/R/plotly_data.R @@ -8,6 +8,7 @@ #' @param id a character string or number referencing an "attribute layer". #' @return returns a data frame #' @examples +#' @export #' #' # use group_by() to define groups of visual markings #' p <- txhousing %>% diff --git a/man/plotly_data.Rd b/man/plotly_data.Rd index 064ed70362..ebb1e55f83 100644 --- a/man/plotly_data.Rd +++ b/man/plotly_data.Rd @@ -19,50 +19,4 @@ returns a data frame a plotly visualization (if there are multiple data frames, by default, it returns the most recent one). } -\examples{ - -# use group_by() to define groups of visual markings -p <- txhousing \%>\% - group_by(city) \%>\% - plot_ly(x = ~date, y = ~sales) -p - -# plotly objects preserve data groupings -groups(p) -plotly_data(p) - -# dplyr verbs operate on plotly objects as if they were data frames -p <- economics \%>\% - plot_ly(x = ~date, y = ~unemploy / pop) \%>\% - add_lines() \%>\% - mutate(rate = unemploy / pop) \%>\% - filter(rate == max(rate)) -plotly_data(p) -add_markers(p) -layout(p, annotations = list(x = ~date, y = ~rate, text = "peak")) - -# use group_by() + do() + subplot() for trellis displays -d <- group_by(mpg, drv) -plots <- do(d, p = plot_ly(., x = ~cty, name = ~drv)) -subplot(plots[["p"]], nrows = 3, shareX = TRUE) - -# arrange displays by their mean -means <- summarise(d, mn = mean(cty, na.rm = TRUE)) -means \%>\% - left_join(plots) \%>\% - arrange(mn) \%>\% - .[["p"]] \%>\% - subplot(nrows = NROW(.), shareX = TRUE) - -# more dplyr verbs applied to plotly objects -p <- mtcars \%>\% - plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") \%>\% - add_markers() -p \%>\% slice(1) \%>\% plotly_data() -p \%>\% slice(1) \%>\% add_markers(name = "first observation") -p \%>\% filter(cyl == 4) \%>\% plotly_data() -p \%>\% filter(cyl == 4) \%>\% add_markers(name = "four cylinders") - - -}