From 0892b71eec68895764782d1993c63d54677d3307 Mon Sep 17 00:00:00 2001 From: Carson Date: Mon, 19 Apr 2021 13:10:32 -0500 Subject: [PATCH 01/11] Follow up to #3315: reduce complexity and 'black-boxed' nature of tab panel logic --- DESCRIPTION | 6 +- R/bootstrap.R | 135 ++++++++++--------------------- inst/www/shared/shiny.js | 16 +--- inst/www/shared/shiny.js.map | 4 +- inst/www/shared/shiny.min.js | 2 +- inst/www/shared/shiny.min.js.map | 4 +- srcts/src/main.ts | 26 ++---- 7 files changed, 62 insertions(+), 131 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2c7cf54211..69192e4b7c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -80,7 +80,7 @@ Imports: mime (>= 0.3), jsonlite (>= 0.9.16), xtable, - htmltools (>= 0.5.0.9001), + htmltools (>= 0.5.1.9002), R6 (>= 2.0), sourcetools, later (>= 1.0.0), @@ -92,7 +92,7 @@ Imports: withr, commonmark (>= 1.7), glue (>= 1.3.2), - bslib (>= 0.2.2.9002), + bslib (>= 0.2.4.9003), cachem, ellipsis, lifecycle (>= 0.2.0) @@ -113,6 +113,8 @@ Suggests: ragg, showtext, sass +Remotes: + rstudio/htmltools URL: https://shiny.rstudio.com/ BugReports: https://github.com/rstudio/shiny/issues Collate: diff --git a/R/bootstrap.R b/R/bootstrap.R index be672094f0..ebc60beffb 100644 --- a/R/bootstrap.R +++ b/R/bootstrap.R @@ -1026,119 +1026,72 @@ buildNavItem <- function(divTag, tabsetId, index) { divTag$attribs$title <- NULL list( divTag = divTag, - liTag = tagFunction(function() { - navItem <- if ("3" %in% getCurrentVersion()) bs3NavItem else bs4NavItem - navItem(id, title, value, icon, active) - }) - ) -} - -buildDropdown <- function(divTag, tabset) { - title <- divTag$title - value <- divTag$menuName - icon <- getIcon(iconClass = divTag$iconClass) - active <- containsSelectedTab(divTag$tabs) - list( - # list of tab content divs from the child tabset - divTag = tabset$content$children, - liTag = tagFunction(function() { - if ("3" %in% getCurrentVersion()) { - bs3NavItemDropdown(title, value, icon, active, tabset$navList) - } else { - # In BS4, dropdown nav anchors can't be wrapped in a
  • tag - # and also need .nav-link replaced with .dropdown-item to be - # styled sensibly - items <- tabset$navList - items$children <- lapply(items$children, function(x) { - # x should be a tagFunction() due to the else block below - x <- if (inherits(x, "shiny.tag.function")) x() else x - # Replace
  • - # with - if (tagHasClass(x, "nav-item")) { - x <- x$children[[1]] - x$attribs$class <- "dropdown-item" - } - x - }) - bs4NavItemDropdown(title, value, icon, active, items) + liTag = tagRenderHook( + liTag(id, title, value, icon), + function(x) { + if (isTRUE(getCurrentVersion() >= 4)) { + tagQuery(x)$ + addClass("nav-item")$ + find("a")$ + addClass(c("nav-link", if (active) "active"))$ + asTags(selected = FALSE) + } else { + tagAppendAttributes(x, class = if (active) "active") + } } - }) + ) ) } - -bs3NavItemDropdown <- function(title, value, icon, active, items) { +liTag <- function(id, title, value, icon) { tags$li( - class = "dropdown", - class = if (active) "active", # BS3 tags$a( - href = "#", - class = "dropdown-toggle", - `data-toggle` = "dropdown", - `data-value` = value, - icon, - title, tags$b(class = "caret") - ), - items + `data-toggle` = "tab", `data-value` = value, + href = paste0("#", id), icon, title + ) ) } -bs3NavItem <- function(id, title, value, icon, active) { - tags$li( - class = if (active) "active", - tags$a( - href = paste0("#", id), - `data-toggle` = "tab", - `data-value` = value, - icon, - title - ) +buildDropdown <- function(divTag, tabset) { + + navList <- tagRenderHook( + tabset$navList, + function(x) { + if (isTRUE(getCurrentVersion() >= 4)) { + tagQuery(x)$ + removeClass("nav-item")$ + find(".nav-link")$ + removeClass("nav-link")$ + addClass("dropdown-item")$ + asTags(selected = FALSE) + } else { + x + } + } ) -} -bs4NavItemDropdown <- function(title, value, icon, active, items) { - tags$li( + active <- containsSelectedTab(divTag$tabs) + + dropdown <- tags$li( class = "dropdown", - class = "nav-item", tags$a( href = "#", class = "dropdown-toggle", - class = "nav-link", - class = if (active) "active", `data-toggle` = "dropdown", - `data-value` = value, - icon, - title, - tags$b(class = "caret") # TODO: can be removed? + `data-value` = divTag$menuName, + getIcon(iconClass = divTag$iconClass), + divTag$title, + tags$b(class = "caret") ), - items + navList ) -} -bs4NavItem <- function(id, title, value, icon, active) { - tags$li( - class = "nav-item", - tags$a( - class = "nav-link", - class = if (active) "active", - href = paste0("#", id), - `data-toggle` = "tab", - `data-value` = value, - icon, - title - ) + list( + divTag = tabset$content$children, + liTag = dropdown ) } -# TODO: something like this should exist in htmltools -tagHasClass <- function(x, class) { - if (!inherits(x, "shiny.tag")) return(FALSE) - classes <- unlist(x$attribs[names(x$attribs) %in% "class"], use.names = FALSE) - if (!length(classes)) return(FALSE) - classes <- unlist(strsplit(classes, split = "\\s+"), use.names = FALSE) - isTRUE(class %in% classes) -} - #' Create a text output element #' #' Render a reactive output variable as text within an application page. diff --git a/inst/www/shared/shiny.js b/inst/www/shared/shiny.js index 92c4b45f17..83cfef8741 100644 --- a/inst/www/shared/shiny.js +++ b/inst/www/shared/shiny.js @@ -2996,9 +2996,7 @@ function getTargetTabs($tabset, $tabContent, target) { var dataValue = "[data-value='" + $escape(target) + "']"; var $aTag = $tabset.find("a" + dataValue); - var $liTag = $aTag.parent("li"); - if ($liTag.length === 0) - $liTag = $aTag; + var $liTag = $aTag.parent(); if ($liTag.length === 0) { throw "There is no tabPanel (or navbarMenu) with value (or menuName) equal to '" + target + "'"; } @@ -3008,9 +3006,7 @@ var $dropdownTabset = $aTag.find("+ ul.dropdown-menu"); var dropdownId = $dropdownTabset.attr("data-tabsetid"); var $dropdownLiTags = $dropdownTabset.find("a[data-toggle='tab']"); - if ($dropdownLiTags.parent("li").length > 0) { - $dropdownLiTags = $dropdownLiTags.parent("li"); - } + parent("li"); $dropdownLiTags.each(function(i, el) { $liTags.push(import_jquery6.default(el)); }); @@ -3041,9 +3037,6 @@ if (message.target !== null) { target = getTargetTabs($tabset, $tabContent, message.target); $targetLiTag = target.$liTag; - if ($targetLiTag.hasClass("dropdown-item")) { - $liTag = $aTag.removeClass("nav-link").addClass("dropdown-item"); - } } var dropdown = getDropdown(); if (dropdown !== null) { @@ -3055,10 +3048,7 @@ if ($aTag.attr("data-toggle") === "tab") { var index = getTabIndex($tabset, tabsetId); var tabId = "tab-" + tabsetId + "-" + index; - var anchor = $liTag.find("> a"); - if (anchor.length === 0) - anchor = $liTag; - anchor.attr("href", "#" + tabId); + $liTag.find("> a").attr("href", "#" + tabId); $divTag.attr("id", tabId); } if (message.position === "before") { diff --git a/inst/www/shared/shiny.js.map b/inst/www/shared/shiny.js.map index f4c0ce351c..a6b254633f 100644 --- a/inst/www/shared/shiny.js.map +++ b/inst/www/shared/shiny.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["globals:jquery", "../../../srcts/node_modules/core-js/internals/global.js", "../../../srcts/node_modules/core-js/internals/fails.js", "../../../srcts/node_modules/core-js/internals/descriptors.js", "../../../srcts/node_modules/core-js/internals/object-property-is-enumerable.js", "../../../srcts/node_modules/core-js/internals/create-property-descriptor.js", "../../../srcts/node_modules/core-js/internals/classof-raw.js", "../../../srcts/node_modules/core-js/internals/indexed-object.js", "../../../srcts/node_modules/core-js/internals/require-object-coercible.js", "../../../srcts/node_modules/core-js/internals/to-indexed-object.js", "../../../srcts/node_modules/core-js/internals/is-object.js", "../../../srcts/node_modules/core-js/internals/to-primitive.js", "../../../srcts/node_modules/core-js/internals/has.js", "../../../srcts/node_modules/core-js/internals/document-create-element.js", "../../../srcts/node_modules/core-js/internals/ie8-dom-define.js", "../../../srcts/node_modules/core-js/internals/object-get-own-property-descriptor.js", "../../../srcts/node_modules/core-js/internals/an-object.js", "../../../srcts/node_modules/core-js/internals/object-define-property.js", "../../../srcts/node_modules/core-js/internals/create-non-enumerable-property.js", "../../../srcts/node_modules/core-js/internals/set-global.js", "../../../srcts/node_modules/core-js/internals/shared-store.js", "../../../srcts/node_modules/core-js/internals/inspect-source.js", "../../../srcts/node_modules/core-js/internals/native-weak-map.js", "../../../srcts/node_modules/core-js/internals/is-pure.js", "../../../srcts/node_modules/core-js/internals/shared.js", "../../../srcts/node_modules/core-js/internals/uid.js", "../../../srcts/node_modules/core-js/internals/shared-key.js", "../../../srcts/node_modules/core-js/internals/hidden-keys.js", "../../../srcts/node_modules/core-js/internals/internal-state.js", "../../../srcts/node_modules/core-js/internals/redefine.js", "../../../srcts/node_modules/core-js/internals/path.js", "../../../srcts/node_modules/core-js/internals/get-built-in.js", "../../../srcts/node_modules/core-js/internals/to-integer.js", "../../../srcts/node_modules/core-js/internals/to-length.js", "../../../srcts/node_modules/core-js/internals/to-absolute-index.js", "../../../srcts/node_modules/core-js/internals/array-includes.js", "../../../srcts/node_modules/core-js/internals/object-keys-internal.js", "../../../srcts/node_modules/core-js/internals/enum-bug-keys.js", "../../../srcts/node_modules/core-js/internals/object-get-own-property-names.js", "../../../srcts/node_modules/core-js/internals/object-get-own-property-symbols.js", "../../../srcts/node_modules/core-js/internals/own-keys.js", "../../../srcts/node_modules/core-js/internals/copy-constructor-properties.js", "../../../srcts/node_modules/core-js/internals/is-forced.js", "../../../srcts/node_modules/core-js/internals/export.js", "../../../srcts/node_modules/core-js/internals/array-method-is-strict.js", "../../../srcts/node_modules/core-js/internals/whitespaces.js", "../../../srcts/node_modules/core-js/internals/string-trim.js", "../../../srcts/node_modules/core-js/internals/number-parse-int.js", "../../../srcts/node_modules/core-js/internals/is-array.js", "../../../srcts/node_modules/core-js/internals/to-object.js", "../../../srcts/node_modules/core-js/internals/create-property.js", "../../../srcts/node_modules/core-js/internals/native-symbol.js", "../../../srcts/node_modules/core-js/internals/use-symbol-as-uid.js", "../../../srcts/node_modules/core-js/internals/well-known-symbol.js", "../../../srcts/node_modules/core-js/internals/array-species-create.js", "../../../srcts/node_modules/core-js/internals/engine-user-agent.js", "../../../srcts/node_modules/core-js/internals/engine-v8-version.js", "../../../srcts/node_modules/core-js/internals/array-method-has-species-support.js", "../../../srcts/node_modules/core-js/internals/this-number-value.js", "../../../srcts/node_modules/core-js/internals/object-keys.js", "../../../srcts/node_modules/core-js/internals/to-string-tag-support.js", "../../../srcts/node_modules/core-js/internals/classof.js", "../../../srcts/node_modules/core-js/internals/object-to-string.js", "../../../srcts/node_modules/core-js/internals/number-parse-float.js", "../../../srcts/node_modules/core-js/internals/regexp-flags.js", "../../../srcts/node_modules/core-js/internals/regexp-sticky-helpers.js", "../../../srcts/node_modules/core-js/internals/regexp-exec.js", "../../../srcts/node_modules/core-js/modules/es.regexp.exec.js", "../../../srcts/node_modules/core-js/internals/fix-regexp-well-known-symbol-logic.js", "../../../srcts/node_modules/core-js/internals/string-multibyte.js", "../../../srcts/node_modules/core-js/internals/advance-string-index.js", "../../../srcts/node_modules/core-js/internals/regexp-exec-abstract.js", "../../../srcts/node_modules/core-js/internals/get-substitution.js", "../../../srcts/node_modules/core-js/internals/is-regexp.js", "../../../srcts/node_modules/core-js/internals/a-function.js", "../../../srcts/node_modules/core-js/internals/species-constructor.js", "../../../srcts/node_modules/core-js/internals/function-bind-context.js", "../../../srcts/node_modules/core-js/internals/array-iteration.js", "../../../srcts/node_modules/core-js/internals/object-define-properties.js", "../../../srcts/node_modules/core-js/internals/html.js", "../../../srcts/node_modules/core-js/internals/object-create.js", "../../../srcts/node_modules/core-js/internals/add-to-unscopables.js", "../../../srcts/node_modules/core-js/internals/array-for-each.js", "../../../srcts/node_modules/core-js/internals/array-reduce.js", "../../../srcts/node_modules/core-js/internals/engine-is-node.js", "../../../srcts/node_modules/core-js/internals/array-buffer-native.js", "../../../srcts/node_modules/core-js/internals/redefine-all.js", "../../../srcts/node_modules/core-js/internals/an-instance.js", "../../../srcts/node_modules/core-js/internals/to-index.js", "../../../srcts/node_modules/core-js/internals/ieee754.js", "../../../srcts/node_modules/core-js/internals/correct-prototype-getter.js", "../../../srcts/node_modules/core-js/internals/object-get-prototype-of.js", "../../../srcts/node_modules/core-js/internals/a-possible-prototype.js", "../../../srcts/node_modules/core-js/internals/object-set-prototype-of.js", "../../../srcts/node_modules/core-js/internals/array-fill.js", "../../../srcts/node_modules/core-js/internals/set-to-string-tag.js", "../../../srcts/node_modules/core-js/internals/array-buffer.js", "../../../srcts/node_modules/core-js/internals/set-species.js", "../../../srcts/node_modules/core-js/internals/inherit-if-required.js", "../../../srcts/node_modules/core-js/internals/same-value.js", "../../../srcts/node_modules/core-js/internals/string-trim-forced.js", "../../../srcts/node_modules/core-js/internals/dom-iterables.js", "../../../srcts/src/main.ts", "../../../srcts/src/initialize/disableForm.ts", "../../../srcts/src/initialize/history.ts", "../../../srcts/node_modules/core-js/modules/es.array.index-of.js", "../../../srcts/node_modules/core-js/modules/es.parse-int.js", "../../../srcts/src/initialize/browser.ts", "../../../srcts/src/utils/browser.ts", "../../../srcts/src/utils/userAgent.ts", "../../../srcts/src/window/libraries.ts", "../../../srcts/node_modules/core-js/modules/es.array.concat.js", "../../../srcts/node_modules/core-js/modules/es.array.slice.js", "../../../srcts/node_modules/core-js/modules/es.array.splice.js", "../../../srcts/node_modules/core-js/modules/es.number.to-precision.js", "../../../srcts/node_modules/core-js/modules/es.object.keys.js", "../../../srcts/node_modules/core-js/modules/es.object.to-string.js", "../../../srcts/node_modules/core-js/modules/es.parse-float.js", "../../../srcts/src/utils/index.ts", "../../../srcts/node_modules/core-js/modules/es.regexp.to-string.js", "../../../srcts/node_modules/core-js/modules/es.string.match.js", "../../../srcts/node_modules/core-js/modules/es.string.replace.js", "../../../srcts/node_modules/core-js/modules/es.string.split.js", "../../../srcts/src/window/pixelRatio.ts", "../../../srcts/src/utils/blob.ts", "../../../srcts/src/shiny.ts", "../../../srcts/src/window/blobBuilder.ts", "../../../srcts/src/window/userAgent.ts", "../../../srcts/src/initialize/index.ts", "../../../srcts/node_modules/core-js/modules/es.array.filter.js", "../../../srcts/node_modules/core-js/modules/es.array.find.js", "../../../srcts/node_modules/core-js/modules/es.array.for-each.js", "../../../srcts/node_modules/core-js/modules/es.array.join.js", "../../../srcts/node_modules/core-js/modules/es.array.map.js", "../../../srcts/node_modules/core-js/modules/es.array.reduce.js", "../../../srcts/node_modules/core-js/modules/es.array-buffer.constructor.js", "../../../srcts/node_modules/core-js/modules/es.array-buffer.slice.js", "../../../srcts/node_modules/core-js/modules/es.data-view.js", "../../../srcts/node_modules/core-js/modules/es.function.name.js", "../../../srcts/node_modules/core-js/modules/es.number.constructor.js", "../../../srcts/node_modules/core-js/modules/es.string.search.js", "../../../srcts/node_modules/core-js/modules/es.string.trim.js", "../../../srcts/node_modules/core-js/modules/web.dom-collections.for-each.js", "../../../srcts/src/file/FileProcessor.ts", "../../../srcts/src/index.ts"], - "sourcesContent": ["module.exports = window.jQuery", "var check = function (it) {\n return it && it.Math == Math && it;\n};\n\n// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028\nmodule.exports =\n /* global globalThis -- safe */\n check(typeof globalThis == 'object' && globalThis) ||\n check(typeof window == 'object' && window) ||\n check(typeof self == 'object' && self) ||\n check(typeof global == 'object' && global) ||\n // eslint-disable-next-line no-new-func -- fallback\n (function () { return this; })() || Function('return this')();\n", "module.exports = function (exec) {\n try {\n return !!exec();\n } catch (error) {\n return true;\n }\n};\n", "var fails = require('../internals/fails');\n\n// Detect IE8's incomplete defineProperty implementation\nmodule.exports = !fails(function () {\n return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;\n});\n", "'use strict';\nvar nativePropertyIsEnumerable = {}.propertyIsEnumerable;\nvar getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\n\n// Nashorn ~ JDK8 bug\nvar NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);\n\n// `Object.prototype.propertyIsEnumerable` method implementation\n// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable\nexports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {\n var descriptor = getOwnPropertyDescriptor(this, V);\n return !!descriptor && descriptor.enumerable;\n} : nativePropertyIsEnumerable;\n", "module.exports = function (bitmap, value) {\n return {\n enumerable: !(bitmap & 1),\n configurable: !(bitmap & 2),\n writable: !(bitmap & 4),\n value: value\n };\n};\n", "var toString = {}.toString;\n\nmodule.exports = function (it) {\n return toString.call(it).slice(8, -1);\n};\n", "var fails = require('../internals/fails');\nvar classof = require('../internals/classof-raw');\n\nvar split = ''.split;\n\n// fallback for non-array-like ES3 and non-enumerable old V8 strings\nmodule.exports = fails(function () {\n // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346\n // eslint-disable-next-line no-prototype-builtins -- safe\n return !Object('z').propertyIsEnumerable(0);\n}) ? function (it) {\n return classof(it) == 'String' ? split.call(it, '') : Object(it);\n} : Object;\n", "// `RequireObjectCoercible` abstract operation\n// https://tc39.es/ecma262/#sec-requireobjectcoercible\nmodule.exports = function (it) {\n if (it == undefined) throw TypeError(\"Can't call method on \" + it);\n return it;\n};\n", "// toObject with fallback for non-array-like ES3 strings\nvar IndexedObject = require('../internals/indexed-object');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\n\nmodule.exports = function (it) {\n return IndexedObject(requireObjectCoercible(it));\n};\n", "module.exports = function (it) {\n return typeof it === 'object' ? it !== null : typeof it === 'function';\n};\n", "var isObject = require('../internals/is-object');\n\n// `ToPrimitive` abstract operation\n// https://tc39.es/ecma262/#sec-toprimitive\n// instead of the ES6 spec version, we didn't implement @@toPrimitive case\n// and the second argument - flag - preferred type is a string\nmodule.exports = function (input, PREFERRED_STRING) {\n if (!isObject(input)) return input;\n var fn, val;\n if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;\n if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;\n if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;\n throw TypeError(\"Can't convert object to primitive value\");\n};\n", "var hasOwnProperty = {}.hasOwnProperty;\n\nmodule.exports = function (it, key) {\n return hasOwnProperty.call(it, key);\n};\n", "var global = require('../internals/global');\nvar isObject = require('../internals/is-object');\n\nvar document = global.document;\n// typeof document.createElement is 'object' in old IE\nvar EXISTS = isObject(document) && isObject(document.createElement);\n\nmodule.exports = function (it) {\n return EXISTS ? document.createElement(it) : {};\n};\n", "var DESCRIPTORS = require('../internals/descriptors');\nvar fails = require('../internals/fails');\nvar createElement = require('../internals/document-create-element');\n\n// Thank's IE8 for his funny defineProperty\nmodule.exports = !DESCRIPTORS && !fails(function () {\n return Object.defineProperty(createElement('div'), 'a', {\n get: function () { return 7; }\n }).a != 7;\n});\n", "var DESCRIPTORS = require('../internals/descriptors');\nvar propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar toPrimitive = require('../internals/to-primitive');\nvar has = require('../internals/has');\nvar IE8_DOM_DEFINE = require('../internals/ie8-dom-define');\n\nvar nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\n\n// `Object.getOwnPropertyDescriptor` method\n// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor\nexports.f = DESCRIPTORS ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {\n O = toIndexedObject(O);\n P = toPrimitive(P, true);\n if (IE8_DOM_DEFINE) try {\n return nativeGetOwnPropertyDescriptor(O, P);\n } catch (error) { /* empty */ }\n if (has(O, P)) return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]);\n};\n", "var isObject = require('../internals/is-object');\n\nmodule.exports = function (it) {\n if (!isObject(it)) {\n throw TypeError(String(it) + ' is not an object');\n } return it;\n};\n", "var DESCRIPTORS = require('../internals/descriptors');\nvar IE8_DOM_DEFINE = require('../internals/ie8-dom-define');\nvar anObject = require('../internals/an-object');\nvar toPrimitive = require('../internals/to-primitive');\n\nvar nativeDefineProperty = Object.defineProperty;\n\n// `Object.defineProperty` method\n// https://tc39.es/ecma262/#sec-object.defineproperty\nexports.f = DESCRIPTORS ? nativeDefineProperty : function defineProperty(O, P, Attributes) {\n anObject(O);\n P = toPrimitive(P, true);\n anObject(Attributes);\n if (IE8_DOM_DEFINE) try {\n return nativeDefineProperty(O, P, Attributes);\n } catch (error) { /* empty */ }\n if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');\n if ('value' in Attributes) O[P] = Attributes.value;\n return O;\n};\n", "var DESCRIPTORS = require('../internals/descriptors');\nvar definePropertyModule = require('../internals/object-define-property');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\n\nmodule.exports = DESCRIPTORS ? function (object, key, value) {\n return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));\n} : function (object, key, value) {\n object[key] = value;\n return object;\n};\n", "var global = require('../internals/global');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\n\nmodule.exports = function (key, value) {\n try {\n createNonEnumerableProperty(global, key, value);\n } catch (error) {\n global[key] = value;\n } return value;\n};\n", "var global = require('../internals/global');\nvar setGlobal = require('../internals/set-global');\n\nvar SHARED = '__core-js_shared__';\nvar store = global[SHARED] || setGlobal(SHARED, {});\n\nmodule.exports = store;\n", "var store = require('../internals/shared-store');\n\nvar functionToString = Function.toString;\n\n// this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper\nif (typeof store.inspectSource != 'function') {\n store.inspectSource = function (it) {\n return functionToString.call(it);\n };\n}\n\nmodule.exports = store.inspectSource;\n", "var global = require('../internals/global');\nvar inspectSource = require('../internals/inspect-source');\n\nvar WeakMap = global.WeakMap;\n\nmodule.exports = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));\n", "module.exports = false;\n", "var IS_PURE = require('../internals/is-pure');\nvar store = require('../internals/shared-store');\n\n(module.exports = function (key, value) {\n return store[key] || (store[key] = value !== undefined ? value : {});\n})('versions', []).push({\n version: '3.9.0',\n mode: IS_PURE ? 'pure' : 'global',\n copyright: '\u00A9 2021 Denis Pushkarev (zloirock.ru)'\n});\n", "var id = 0;\nvar postfix = Math.random();\n\nmodule.exports = function (key) {\n return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);\n};\n", "var shared = require('../internals/shared');\nvar uid = require('../internals/uid');\n\nvar keys = shared('keys');\n\nmodule.exports = function (key) {\n return keys[key] || (keys[key] = uid(key));\n};\n", "module.exports = {};\n", "var NATIVE_WEAK_MAP = require('../internals/native-weak-map');\nvar global = require('../internals/global');\nvar isObject = require('../internals/is-object');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar objectHas = require('../internals/has');\nvar shared = require('../internals/shared-store');\nvar sharedKey = require('../internals/shared-key');\nvar hiddenKeys = require('../internals/hidden-keys');\n\nvar WeakMap = global.WeakMap;\nvar set, get, has;\n\nvar enforce = function (it) {\n return has(it) ? get(it) : set(it, {});\n};\n\nvar getterFor = function (TYPE) {\n return function (it) {\n var state;\n if (!isObject(it) || (state = get(it)).type !== TYPE) {\n throw TypeError('Incompatible receiver, ' + TYPE + ' required');\n } return state;\n };\n};\n\nif (NATIVE_WEAK_MAP) {\n var store = shared.state || (shared.state = new WeakMap());\n var wmget = store.get;\n var wmhas = store.has;\n var wmset = store.set;\n set = function (it, metadata) {\n metadata.facade = it;\n wmset.call(store, it, metadata);\n return metadata;\n };\n get = function (it) {\n return wmget.call(store, it) || {};\n };\n has = function (it) {\n return wmhas.call(store, it);\n };\n} else {\n var STATE = sharedKey('state');\n hiddenKeys[STATE] = true;\n set = function (it, metadata) {\n metadata.facade = it;\n createNonEnumerableProperty(it, STATE, metadata);\n return metadata;\n };\n get = function (it) {\n return objectHas(it, STATE) ? it[STATE] : {};\n };\n has = function (it) {\n return objectHas(it, STATE);\n };\n}\n\nmodule.exports = {\n set: set,\n get: get,\n has: has,\n enforce: enforce,\n getterFor: getterFor\n};\n", "var global = require('../internals/global');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar has = require('../internals/has');\nvar setGlobal = require('../internals/set-global');\nvar inspectSource = require('../internals/inspect-source');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar getInternalState = InternalStateModule.get;\nvar enforceInternalState = InternalStateModule.enforce;\nvar TEMPLATE = String(String).split('String');\n\n(module.exports = function (O, key, value, options) {\n var unsafe = options ? !!options.unsafe : false;\n var simple = options ? !!options.enumerable : false;\n var noTargetGet = options ? !!options.noTargetGet : false;\n var state;\n if (typeof value == 'function') {\n if (typeof key == 'string' && !has(value, 'name')) {\n createNonEnumerableProperty(value, 'name', key);\n }\n state = enforceInternalState(value);\n if (!state.source) {\n state.source = TEMPLATE.join(typeof key == 'string' ? key : '');\n }\n }\n if (O === global) {\n if (simple) O[key] = value;\n else setGlobal(key, value);\n return;\n } else if (!unsafe) {\n delete O[key];\n } else if (!noTargetGet && O[key]) {\n simple = true;\n }\n if (simple) O[key] = value;\n else createNonEnumerableProperty(O, key, value);\n// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative\n})(Function.prototype, 'toString', function toString() {\n return typeof this == 'function' && getInternalState(this).source || inspectSource(this);\n});\n", "var global = require('../internals/global');\n\nmodule.exports = global;\n", "var path = require('../internals/path');\nvar global = require('../internals/global');\n\nvar aFunction = function (variable) {\n return typeof variable == 'function' ? variable : undefined;\n};\n\nmodule.exports = function (namespace, method) {\n return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace])\n : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];\n};\n", "var ceil = Math.ceil;\nvar floor = Math.floor;\n\n// `ToInteger` abstract operation\n// https://tc39.es/ecma262/#sec-tointeger\nmodule.exports = function (argument) {\n return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);\n};\n", "var toInteger = require('../internals/to-integer');\n\nvar min = Math.min;\n\n// `ToLength` abstract operation\n// https://tc39.es/ecma262/#sec-tolength\nmodule.exports = function (argument) {\n return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991\n};\n", "var toInteger = require('../internals/to-integer');\n\nvar max = Math.max;\nvar min = Math.min;\n\n// Helper for a popular repeating case of the spec:\n// Let integer be ? ToInteger(index).\n// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).\nmodule.exports = function (index, length) {\n var integer = toInteger(index);\n return integer < 0 ? max(integer + length, 0) : min(integer, length);\n};\n", "var toIndexedObject = require('../internals/to-indexed-object');\nvar toLength = require('../internals/to-length');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\n\n// `Array.prototype.{ indexOf, includes }` methods implementation\nvar createMethod = function (IS_INCLUDES) {\n return function ($this, el, fromIndex) {\n var O = toIndexedObject($this);\n var length = toLength(O.length);\n var index = toAbsoluteIndex(fromIndex, length);\n var value;\n // Array#includes uses SameValueZero equality algorithm\n // eslint-disable-next-line no-self-compare -- NaN check\n if (IS_INCLUDES && el != el) while (length > index) {\n value = O[index++];\n // eslint-disable-next-line no-self-compare -- NaN check\n if (value != value) return true;\n // Array#indexOf ignores holes, Array#includes - not\n } else for (;length > index; index++) {\n if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;\n } return !IS_INCLUDES && -1;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.includes` method\n // https://tc39.es/ecma262/#sec-array.prototype.includes\n includes: createMethod(true),\n // `Array.prototype.indexOf` method\n // https://tc39.es/ecma262/#sec-array.prototype.indexof\n indexOf: createMethod(false)\n};\n", "var has = require('../internals/has');\nvar toIndexedObject = require('../internals/to-indexed-object');\nvar indexOf = require('../internals/array-includes').indexOf;\nvar hiddenKeys = require('../internals/hidden-keys');\n\nmodule.exports = function (object, names) {\n var O = toIndexedObject(object);\n var i = 0;\n var result = [];\n var key;\n for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);\n // Don't enum bug & hidden keys\n while (names.length > i) if (has(O, key = names[i++])) {\n ~indexOf(result, key) || result.push(key);\n }\n return result;\n};\n", "// IE8- don't enum bug keys\nmodule.exports = [\n 'constructor',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n 'toLocaleString',\n 'toString',\n 'valueOf'\n];\n", "var internalObjectKeys = require('../internals/object-keys-internal');\nvar enumBugKeys = require('../internals/enum-bug-keys');\n\nvar hiddenKeys = enumBugKeys.concat('length', 'prototype');\n\n// `Object.getOwnPropertyNames` method\n// https://tc39.es/ecma262/#sec-object.getownpropertynames\nexports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {\n return internalObjectKeys(O, hiddenKeys);\n};\n", "exports.f = Object.getOwnPropertySymbols;\n", "var getBuiltIn = require('../internals/get-built-in');\nvar getOwnPropertyNamesModule = require('../internals/object-get-own-property-names');\nvar getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols');\nvar anObject = require('../internals/an-object');\n\n// all object keys, includes non-enumerable and symbols\nmodule.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {\n var keys = getOwnPropertyNamesModule.f(anObject(it));\n var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;\n return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;\n};\n", "var has = require('../internals/has');\nvar ownKeys = require('../internals/own-keys');\nvar getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');\nvar definePropertyModule = require('../internals/object-define-property');\n\nmodule.exports = function (target, source) {\n var keys = ownKeys(source);\n var defineProperty = definePropertyModule.f;\n var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));\n }\n};\n", "var fails = require('../internals/fails');\n\nvar replacement = /#|\\.prototype\\./;\n\nvar isForced = function (feature, detection) {\n var value = data[normalize(feature)];\n return value == POLYFILL ? true\n : value == NATIVE ? false\n : typeof detection == 'function' ? fails(detection)\n : !!detection;\n};\n\nvar normalize = isForced.normalize = function (string) {\n return String(string).replace(replacement, '.').toLowerCase();\n};\n\nvar data = isForced.data = {};\nvar NATIVE = isForced.NATIVE = 'N';\nvar POLYFILL = isForced.POLYFILL = 'P';\n\nmodule.exports = isForced;\n", "var global = require('../internals/global');\nvar getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefine = require('../internals/redefine');\nvar setGlobal = require('../internals/set-global');\nvar copyConstructorProperties = require('../internals/copy-constructor-properties');\nvar isForced = require('../internals/is-forced');\n\n/*\n options.target - name of the target object\n options.global - target is the global object\n options.stat - export as static methods of target\n options.proto - export as prototype methods of target\n options.real - real prototype method for the `pure` version\n options.forced - export even if the native feature is available\n options.bind - bind methods to the target, required for the `pure` version\n options.wrap - wrap constructors to preventing global pollution, required for the `pure` version\n options.unsafe - use the simple assignment of property instead of delete + defineProperty\n options.sham - add a flag to not completely full polyfills\n options.enumerable - export as enumerable property\n options.noTargetGet - prevent calling a getter on target\n*/\nmodule.exports = function (options, source) {\n var TARGET = options.target;\n var GLOBAL = options.global;\n var STATIC = options.stat;\n var FORCED, target, key, targetProperty, sourceProperty, descriptor;\n if (GLOBAL) {\n target = global;\n } else if (STATIC) {\n target = global[TARGET] || setGlobal(TARGET, {});\n } else {\n target = (global[TARGET] || {}).prototype;\n }\n if (target) for (key in source) {\n sourceProperty = source[key];\n if (options.noTargetGet) {\n descriptor = getOwnPropertyDescriptor(target, key);\n targetProperty = descriptor && descriptor.value;\n } else targetProperty = target[key];\n FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);\n // contained in target\n if (!FORCED && targetProperty !== undefined) {\n if (typeof sourceProperty === typeof targetProperty) continue;\n copyConstructorProperties(sourceProperty, targetProperty);\n }\n // add a flag to not completely full polyfills\n if (options.sham || (targetProperty && targetProperty.sham)) {\n createNonEnumerableProperty(sourceProperty, 'sham', true);\n }\n // extend global\n redefine(target, key, sourceProperty, options);\n }\n};\n", "'use strict';\nvar fails = require('../internals/fails');\n\nmodule.exports = function (METHOD_NAME, argument) {\n var method = [][METHOD_NAME];\n return !!method && fails(function () {\n // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing\n method.call(null, argument || function () { throw 1; }, 1);\n });\n};\n", "// a string of all valid unicode whitespaces\nmodule.exports = '\\u0009\\u000A\\u000B\\u000C\\u000D\\u0020\\u00A0\\u1680\\u2000\\u2001\\u2002' +\n '\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF';\n", "var requireObjectCoercible = require('../internals/require-object-coercible');\nvar whitespaces = require('../internals/whitespaces');\n\nvar whitespace = '[' + whitespaces + ']';\nvar ltrim = RegExp('^' + whitespace + whitespace + '*');\nvar rtrim = RegExp(whitespace + whitespace + '*$');\n\n// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation\nvar createMethod = function (TYPE) {\n return function ($this) {\n var string = String(requireObjectCoercible($this));\n if (TYPE & 1) string = string.replace(ltrim, '');\n if (TYPE & 2) string = string.replace(rtrim, '');\n return string;\n };\n};\n\nmodule.exports = {\n // `String.prototype.{ trimLeft, trimStart }` methods\n // https://tc39.es/ecma262/#sec-string.prototype.trimstart\n start: createMethod(1),\n // `String.prototype.{ trimRight, trimEnd }` methods\n // https://tc39.es/ecma262/#sec-string.prototype.trimend\n end: createMethod(2),\n // `String.prototype.trim` method\n // https://tc39.es/ecma262/#sec-string.prototype.trim\n trim: createMethod(3)\n};\n", "var global = require('../internals/global');\nvar trim = require('../internals/string-trim').trim;\nvar whitespaces = require('../internals/whitespaces');\n\nvar $parseInt = global.parseInt;\nvar hex = /^[+-]?0[Xx]/;\nvar FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22;\n\n// `parseInt` method\n// https://tc39.es/ecma262/#sec-parseint-string-radix\nmodule.exports = FORCED ? function parseInt(string, radix) {\n var S = trim(String(string));\n return $parseInt(S, (radix >>> 0) || (hex.test(S) ? 16 : 10));\n} : $parseInt;\n", "var classof = require('../internals/classof-raw');\n\n// `IsArray` abstract operation\n// https://tc39.es/ecma262/#sec-isarray\nmodule.exports = Array.isArray || function isArray(arg) {\n return classof(arg) == 'Array';\n};\n", "var requireObjectCoercible = require('../internals/require-object-coercible');\n\n// `ToObject` abstract operation\n// https://tc39.es/ecma262/#sec-toobject\nmodule.exports = function (argument) {\n return Object(requireObjectCoercible(argument));\n};\n", "'use strict';\nvar toPrimitive = require('../internals/to-primitive');\nvar definePropertyModule = require('../internals/object-define-property');\nvar createPropertyDescriptor = require('../internals/create-property-descriptor');\n\nmodule.exports = function (object, key, value) {\n var propertyKey = toPrimitive(key);\n if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));\n else object[propertyKey] = value;\n};\n", "var fails = require('../internals/fails');\n\nmodule.exports = !!Object.getOwnPropertySymbols && !fails(function () {\n // Chrome 38 Symbol has incorrect toString conversion\n /* global Symbol -- required for testing */\n return !String(Symbol());\n});\n", "var NATIVE_SYMBOL = require('../internals/native-symbol');\n\nmodule.exports = NATIVE_SYMBOL\n /* global Symbol -- safe */\n && !Symbol.sham\n && typeof Symbol.iterator == 'symbol';\n", "var global = require('../internals/global');\nvar shared = require('../internals/shared');\nvar has = require('../internals/has');\nvar uid = require('../internals/uid');\nvar NATIVE_SYMBOL = require('../internals/native-symbol');\nvar USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid');\n\nvar WellKnownSymbolsStore = shared('wks');\nvar Symbol = global.Symbol;\nvar createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;\n\nmodule.exports = function (name) {\n if (!has(WellKnownSymbolsStore, name)) {\n if (NATIVE_SYMBOL && has(Symbol, name)) WellKnownSymbolsStore[name] = Symbol[name];\n else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);\n } return WellKnownSymbolsStore[name];\n};\n", "var isObject = require('../internals/is-object');\nvar isArray = require('../internals/is-array');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar SPECIES = wellKnownSymbol('species');\n\n// `ArraySpeciesCreate` abstract operation\n// https://tc39.es/ecma262/#sec-arrayspeciescreate\nmodule.exports = function (originalArray, length) {\n var C;\n if (isArray(originalArray)) {\n C = originalArray.constructor;\n // cross-realm fallback\n if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;\n else if (isObject(C)) {\n C = C[SPECIES];\n if (C === null) C = undefined;\n }\n } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);\n};\n", "var getBuiltIn = require('../internals/get-built-in');\n\nmodule.exports = getBuiltIn('navigator', 'userAgent') || '';\n", "var global = require('../internals/global');\nvar userAgent = require('../internals/engine-user-agent');\n\nvar process = global.process;\nvar versions = process && process.versions;\nvar v8 = versions && versions.v8;\nvar match, version;\n\nif (v8) {\n match = v8.split('.');\n version = match[0] + match[1];\n} else if (userAgent) {\n match = userAgent.match(/Edge\\/(\\d+)/);\n if (!match || match[1] >= 74) {\n match = userAgent.match(/Chrome\\/(\\d+)/);\n if (match) version = match[1];\n }\n}\n\nmodule.exports = version && +version;\n", "var fails = require('../internals/fails');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar V8_VERSION = require('../internals/engine-v8-version');\n\nvar SPECIES = wellKnownSymbol('species');\n\nmodule.exports = function (METHOD_NAME) {\n // We can't use this feature detection in V8 since it causes\n // deoptimization and serious performance degradation\n // https://github.com/zloirock/core-js/issues/677\n return V8_VERSION >= 51 || !fails(function () {\n var array = [];\n var constructor = array.constructor = {};\n constructor[SPECIES] = function () {\n return { foo: 1 };\n };\n return array[METHOD_NAME](Boolean).foo !== 1;\n });\n};\n", "var classof = require('../internals/classof-raw');\n\n// `thisNumberValue` abstract operation\n// https://tc39.es/ecma262/#sec-thisnumbervalue\nmodule.exports = function (value) {\n if (typeof value != 'number' && classof(value) != 'Number') {\n throw TypeError('Incorrect invocation');\n }\n return +value;\n};\n", "var internalObjectKeys = require('../internals/object-keys-internal');\nvar enumBugKeys = require('../internals/enum-bug-keys');\n\n// `Object.keys` method\n// https://tc39.es/ecma262/#sec-object.keys\nmodule.exports = Object.keys || function keys(O) {\n return internalObjectKeys(O, enumBugKeys);\n};\n", "var wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\nvar test = {};\n\ntest[TO_STRING_TAG] = 'z';\n\nmodule.exports = String(test) === '[object z]';\n", "var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');\nvar classofRaw = require('../internals/classof-raw');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\n// ES3 wrong here\nvar CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';\n\n// fallback for IE11 Script Access Denied error\nvar tryGet = function (it, key) {\n try {\n return it[key];\n } catch (error) { /* empty */ }\n};\n\n// getting tag from ES6+ `Object.prototype.toString`\nmodule.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {\n var O, tag, result;\n return it === undefined ? 'Undefined' : it === null ? 'Null'\n // @@toStringTag case\n : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag\n // builtinTag case\n : CORRECT_ARGUMENTS ? classofRaw(O)\n // ES3 arguments fallback\n : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;\n};\n", "'use strict';\nvar TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');\nvar classof = require('../internals/classof');\n\n// `Object.prototype.toString` method implementation\n// https://tc39.es/ecma262/#sec-object.prototype.tostring\nmodule.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {\n return '[object ' + classof(this) + ']';\n};\n", "var global = require('../internals/global');\nvar trim = require('../internals/string-trim').trim;\nvar whitespaces = require('../internals/whitespaces');\n\nvar $parseFloat = global.parseFloat;\nvar FORCED = 1 / $parseFloat(whitespaces + '-0') !== -Infinity;\n\n// `parseFloat` method\n// https://tc39.es/ecma262/#sec-parsefloat-string\nmodule.exports = FORCED ? function parseFloat(string) {\n var trimmedString = trim(String(string));\n var result = $parseFloat(trimmedString);\n return result === 0 && trimmedString.charAt(0) == '-' ? -0 : result;\n} : $parseFloat;\n", "'use strict';\nvar anObject = require('../internals/an-object');\n\n// `RegExp.prototype.flags` getter implementation\n// https://tc39.es/ecma262/#sec-get-regexp.prototype.flags\nmodule.exports = function () {\n var that = anObject(this);\n var result = '';\n if (that.global) result += 'g';\n if (that.ignoreCase) result += 'i';\n if (that.multiline) result += 'm';\n if (that.dotAll) result += 's';\n if (that.unicode) result += 'u';\n if (that.sticky) result += 'y';\n return result;\n};\n", "'use strict';\n\nvar fails = require('./fails');\n\n// babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError,\n// so we use an intermediate function.\nfunction RE(s, f) {\n return RegExp(s, f);\n}\n\nexports.UNSUPPORTED_Y = fails(function () {\n // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError\n var re = RE('a', 'y');\n re.lastIndex = 2;\n return re.exec('abcd') != null;\n});\n\nexports.BROKEN_CARET = fails(function () {\n // https://bugzilla.mozilla.org/show_bug.cgi?id=773687\n var re = RE('^r', 'gy');\n re.lastIndex = 2;\n return re.exec('str') != null;\n});\n", "'use strict';\nvar regexpFlags = require('./regexp-flags');\nvar stickyHelpers = require('./regexp-sticky-helpers');\n\nvar nativeExec = RegExp.prototype.exec;\n// This always refers to the native implementation, because the\n// String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,\n// which loads this file before patching the method.\nvar nativeReplace = String.prototype.replace;\n\nvar patchedExec = nativeExec;\n\nvar UPDATES_LAST_INDEX_WRONG = (function () {\n var re1 = /a/;\n var re2 = /b*/g;\n nativeExec.call(re1, 'a');\n nativeExec.call(re2, 'a');\n return re1.lastIndex !== 0 || re2.lastIndex !== 0;\n})();\n\nvar UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET;\n\n// nonparticipating capturing group, copied from es5-shim's String#split patch.\n// eslint-disable-next-line regexp/no-assertion-capturing-group, regexp/no-empty-group -- required for testing\nvar NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;\n\nvar PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y;\n\nif (PATCH) {\n patchedExec = function exec(str) {\n var re = this;\n var lastIndex, reCopy, match, i;\n var sticky = UNSUPPORTED_Y && re.sticky;\n var flags = regexpFlags.call(re);\n var source = re.source;\n var charsAdded = 0;\n var strCopy = str;\n\n if (sticky) {\n flags = flags.replace('y', '');\n if (flags.indexOf('g') === -1) {\n flags += 'g';\n }\n\n strCopy = String(str).slice(re.lastIndex);\n // Support anchored sticky behavior.\n if (re.lastIndex > 0 && (!re.multiline || re.multiline && str[re.lastIndex - 1] !== '\\n')) {\n source = '(?: ' + source + ')';\n strCopy = ' ' + strCopy;\n charsAdded++;\n }\n // ^(? + rx + ) is needed, in combination with some str slicing, to\n // simulate the 'y' flag.\n reCopy = new RegExp('^(?:' + source + ')', flags);\n }\n\n if (NPCG_INCLUDED) {\n reCopy = new RegExp('^' + source + '$(?!\\\\s)', flags);\n }\n if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;\n\n match = nativeExec.call(sticky ? reCopy : re, strCopy);\n\n if (sticky) {\n if (match) {\n match.input = match.input.slice(charsAdded);\n match[0] = match[0].slice(charsAdded);\n match.index = re.lastIndex;\n re.lastIndex += match[0].length;\n } else re.lastIndex = 0;\n } else if (UPDATES_LAST_INDEX_WRONG && match) {\n re.lastIndex = re.global ? match.index + match[0].length : lastIndex;\n }\n if (NPCG_INCLUDED && match && match.length > 1) {\n // Fix browsers whose `exec` methods don't consistently return `undefined`\n // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/\n nativeReplace.call(match[0], reCopy, function () {\n for (i = 1; i < arguments.length - 2; i++) {\n if (arguments[i] === undefined) match[i] = undefined;\n }\n });\n }\n\n return match;\n };\n}\n\nmodule.exports = patchedExec;\n", "'use strict';\nvar $ = require('../internals/export');\nvar exec = require('../internals/regexp-exec');\n\n// `RegExp.prototype.exec` method\n// https://tc39.es/ecma262/#sec-regexp.prototype.exec\n$({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {\n exec: exec\n});\n", "'use strict';\n// TODO: Remove from `core-js@4` since it's moved to entry points\nrequire('../modules/es.regexp.exec');\nvar redefine = require('../internals/redefine');\nvar fails = require('../internals/fails');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar regexpExec = require('../internals/regexp-exec');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\n\nvar SPECIES = wellKnownSymbol('species');\n\nvar REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {\n // #replace needs built-in support for named groups.\n // #match works fine because it just return the exec results, even if it has\n // a \"grops\" property.\n var re = /./;\n re.exec = function () {\n var result = [];\n result.groups = { a: '7' };\n return result;\n };\n return ''.replace(re, '$') !== '7';\n});\n\n// IE <= 11 replaces $0 with the whole match, as if it was $&\n// https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0\nvar REPLACE_KEEPS_$0 = (function () {\n return 'a'.replace(/./, '$0') === '$0';\n})();\n\nvar REPLACE = wellKnownSymbol('replace');\n// Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string\nvar REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {\n if (/./[REPLACE]) {\n return /./[REPLACE]('a', '$0') === '';\n }\n return false;\n})();\n\n// Chrome 51 has a buggy \"split\" implementation when RegExp#exec !== nativeExec\n// Weex JS has frozen built-in prototypes, so use try / catch wrapper\nvar SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {\n // eslint-disable-next-line regexp/no-empty-group -- required for testing\n var re = /(?:)/;\n var originalExec = re.exec;\n re.exec = function () { return originalExec.apply(this, arguments); };\n var result = 'ab'.split(re);\n return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';\n});\n\nmodule.exports = function (KEY, length, exec, sham) {\n var SYMBOL = wellKnownSymbol(KEY);\n\n var DELEGATES_TO_SYMBOL = !fails(function () {\n // String methods call symbol-named RegEp methods\n var O = {};\n O[SYMBOL] = function () { return 7; };\n return ''[KEY](O) != 7;\n });\n\n var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {\n // Symbol-named RegExp methods call .exec\n var execCalled = false;\n var re = /a/;\n\n if (KEY === 'split') {\n // We can't use real regex here since it causes deoptimization\n // and serious performance degradation in V8\n // https://github.com/zloirock/core-js/issues/306\n re = {};\n // RegExp[@@split] doesn't call the regex's exec method, but first creates\n // a new one. We need to return the patched regex when creating the new one.\n re.constructor = {};\n re.constructor[SPECIES] = function () { return re; };\n re.flags = '';\n re[SYMBOL] = /./[SYMBOL];\n }\n\n re.exec = function () { execCalled = true; return null; };\n\n re[SYMBOL]('');\n return !execCalled;\n });\n\n if (\n !DELEGATES_TO_SYMBOL ||\n !DELEGATES_TO_EXEC ||\n (KEY === 'replace' && !(\n REPLACE_SUPPORTS_NAMED_GROUPS &&\n REPLACE_KEEPS_$0 &&\n !REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE\n )) ||\n (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)\n ) {\n var nativeRegExpMethod = /./[SYMBOL];\n var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {\n if (regexp.exec === regexpExec) {\n if (DELEGATES_TO_SYMBOL && !forceStringMethod) {\n // The native String method already delegates to @@method (this\n // polyfilled function), leasing to infinite recursion.\n // We avoid it by directly calling the native @@method method.\n return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };\n }\n return { done: true, value: nativeMethod.call(str, regexp, arg2) };\n }\n return { done: false };\n }, {\n REPLACE_KEEPS_$0: REPLACE_KEEPS_$0,\n REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE: REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE\n });\n var stringMethod = methods[0];\n var regexMethod = methods[1];\n\n redefine(String.prototype, KEY, stringMethod);\n redefine(RegExp.prototype, SYMBOL, length == 2\n // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)\n // 21.2.5.11 RegExp.prototype[@@split](string, limit)\n ? function (string, arg) { return regexMethod.call(string, this, arg); }\n // 21.2.5.6 RegExp.prototype[@@match](string)\n // 21.2.5.9 RegExp.prototype[@@search](string)\n : function (string) { return regexMethod.call(string, this); }\n );\n }\n\n if (sham) createNonEnumerableProperty(RegExp.prototype[SYMBOL], 'sham', true);\n};\n", "var toInteger = require('../internals/to-integer');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\n\n// `String.prototype.{ codePointAt, at }` methods implementation\nvar createMethod = function (CONVERT_TO_STRING) {\n return function ($this, pos) {\n var S = String(requireObjectCoercible($this));\n var position = toInteger(pos);\n var size = S.length;\n var first, second;\n if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;\n first = S.charCodeAt(position);\n return first < 0xD800 || first > 0xDBFF || position + 1 === size\n || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF\n ? CONVERT_TO_STRING ? S.charAt(position) : first\n : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;\n };\n};\n\nmodule.exports = {\n // `String.prototype.codePointAt` method\n // https://tc39.es/ecma262/#sec-string.prototype.codepointat\n codeAt: createMethod(false),\n // `String.prototype.at` method\n // https://github.com/mathiasbynens/String.prototype.at\n charAt: createMethod(true)\n};\n", "'use strict';\nvar charAt = require('../internals/string-multibyte').charAt;\n\n// `AdvanceStringIndex` abstract operation\n// https://tc39.es/ecma262/#sec-advancestringindex\nmodule.exports = function (S, index, unicode) {\n return index + (unicode ? charAt(S, index).length : 1);\n};\n", "var classof = require('./classof-raw');\nvar regexpExec = require('./regexp-exec');\n\n// `RegExpExec` abstract operation\n// https://tc39.es/ecma262/#sec-regexpexec\nmodule.exports = function (R, S) {\n var exec = R.exec;\n if (typeof exec === 'function') {\n var result = exec.call(R, S);\n if (typeof result !== 'object') {\n throw TypeError('RegExp exec method returned something other than an Object or null');\n }\n return result;\n }\n\n if (classof(R) !== 'RegExp') {\n throw TypeError('RegExp#exec called on incompatible receiver');\n }\n\n return regexpExec.call(R, S);\n};\n\n", "var toObject = require('../internals/to-object');\n\nvar floor = Math.floor;\nvar replace = ''.replace;\nvar SUBSTITUTION_SYMBOLS = /\\$([$&'`]|\\d\\d?|<[^>]*>)/g;\nvar SUBSTITUTION_SYMBOLS_NO_NAMED = /\\$([$&'`]|\\d\\d?)/g;\n\n// https://tc39.es/ecma262/#sec-getsubstitution\nmodule.exports = function (matched, str, position, captures, namedCaptures, replacement) {\n var tailPos = position + matched.length;\n var m = captures.length;\n var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;\n if (namedCaptures !== undefined) {\n namedCaptures = toObject(namedCaptures);\n symbols = SUBSTITUTION_SYMBOLS;\n }\n return replace.call(replacement, symbols, function (match, ch) {\n var capture;\n switch (ch.charAt(0)) {\n case '$': return '$';\n case '&': return matched;\n case '`': return str.slice(0, position);\n case \"'\": return str.slice(tailPos);\n case '<':\n capture = namedCaptures[ch.slice(1, -1)];\n break;\n default: // \\d\\d?\n var n = +ch;\n if (n === 0) return match;\n if (n > m) {\n var f = floor(n / 10);\n if (f === 0) return match;\n if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);\n return match;\n }\n capture = captures[n - 1];\n }\n return capture === undefined ? '' : capture;\n });\n};\n", "var isObject = require('../internals/is-object');\nvar classof = require('../internals/classof-raw');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar MATCH = wellKnownSymbol('match');\n\n// `IsRegExp` abstract operation\n// https://tc39.es/ecma262/#sec-isregexp\nmodule.exports = function (it) {\n var isRegExp;\n return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');\n};\n", "module.exports = function (it) {\n if (typeof it != 'function') {\n throw TypeError(String(it) + ' is not a function');\n } return it;\n};\n", "var anObject = require('../internals/an-object');\nvar aFunction = require('../internals/a-function');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar SPECIES = wellKnownSymbol('species');\n\n// `SpeciesConstructor` abstract operation\n// https://tc39.es/ecma262/#sec-speciesconstructor\nmodule.exports = function (O, defaultConstructor) {\n var C = anObject(O).constructor;\n var S;\n return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S);\n};\n", "var aFunction = require('../internals/a-function');\n\n// optional / simple context binding\nmodule.exports = function (fn, that, length) {\n aFunction(fn);\n if (that === undefined) return fn;\n switch (length) {\n case 0: return function () {\n return fn.call(that);\n };\n case 1: return function (a) {\n return fn.call(that, a);\n };\n case 2: return function (a, b) {\n return fn.call(that, a, b);\n };\n case 3: return function (a, b, c) {\n return fn.call(that, a, b, c);\n };\n }\n return function (/* ...args */) {\n return fn.apply(that, arguments);\n };\n};\n", "var bind = require('../internals/function-bind-context');\nvar IndexedObject = require('../internals/indexed-object');\nvar toObject = require('../internals/to-object');\nvar toLength = require('../internals/to-length');\nvar arraySpeciesCreate = require('../internals/array-species-create');\n\nvar push = [].push;\n\n// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterOut }` methods implementation\nvar createMethod = function (TYPE) {\n var IS_MAP = TYPE == 1;\n var IS_FILTER = TYPE == 2;\n var IS_SOME = TYPE == 3;\n var IS_EVERY = TYPE == 4;\n var IS_FIND_INDEX = TYPE == 6;\n var IS_FILTER_OUT = TYPE == 7;\n var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;\n return function ($this, callbackfn, that, specificCreate) {\n var O = toObject($this);\n var self = IndexedObject(O);\n var boundFunction = bind(callbackfn, that, 3);\n var length = toLength(self.length);\n var index = 0;\n var create = specificCreate || arraySpeciesCreate;\n var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_OUT ? create($this, 0) : undefined;\n var value, result;\n for (;length > index; index++) if (NO_HOLES || index in self) {\n value = self[index];\n result = boundFunction(value, index, O);\n if (TYPE) {\n if (IS_MAP) target[index] = result; // map\n else if (result) switch (TYPE) {\n case 3: return true; // some\n case 5: return value; // find\n case 6: return index; // findIndex\n case 2: push.call(target, value); // filter\n } else switch (TYPE) {\n case 4: return false; // every\n case 7: push.call(target, value); // filterOut\n }\n }\n }\n return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.forEach` method\n // https://tc39.es/ecma262/#sec-array.prototype.foreach\n forEach: createMethod(0),\n // `Array.prototype.map` method\n // https://tc39.es/ecma262/#sec-array.prototype.map\n map: createMethod(1),\n // `Array.prototype.filter` method\n // https://tc39.es/ecma262/#sec-array.prototype.filter\n filter: createMethod(2),\n // `Array.prototype.some` method\n // https://tc39.es/ecma262/#sec-array.prototype.some\n some: createMethod(3),\n // `Array.prototype.every` method\n // https://tc39.es/ecma262/#sec-array.prototype.every\n every: createMethod(4),\n // `Array.prototype.find` method\n // https://tc39.es/ecma262/#sec-array.prototype.find\n find: createMethod(5),\n // `Array.prototype.findIndex` method\n // https://tc39.es/ecma262/#sec-array.prototype.findIndex\n findIndex: createMethod(6),\n // `Array.prototype.filterOut` method\n // https://github.com/tc39/proposal-array-filtering\n filterOut: createMethod(7)\n};\n", "var DESCRIPTORS = require('../internals/descriptors');\nvar definePropertyModule = require('../internals/object-define-property');\nvar anObject = require('../internals/an-object');\nvar objectKeys = require('../internals/object-keys');\n\n// `Object.defineProperties` method\n// https://tc39.es/ecma262/#sec-object.defineproperties\nmodule.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {\n anObject(O);\n var keys = objectKeys(Properties);\n var length = keys.length;\n var index = 0;\n var key;\n while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]);\n return O;\n};\n", "var getBuiltIn = require('../internals/get-built-in');\n\nmodule.exports = getBuiltIn('document', 'documentElement');\n", "var anObject = require('../internals/an-object');\nvar defineProperties = require('../internals/object-define-properties');\nvar enumBugKeys = require('../internals/enum-bug-keys');\nvar hiddenKeys = require('../internals/hidden-keys');\nvar html = require('../internals/html');\nvar documentCreateElement = require('../internals/document-create-element');\nvar sharedKey = require('../internals/shared-key');\n\nvar GT = '>';\nvar LT = '<';\nvar PROTOTYPE = 'prototype';\nvar SCRIPT = 'script';\nvar IE_PROTO = sharedKey('IE_PROTO');\n\nvar EmptyConstructor = function () { /* empty */ };\n\nvar scriptTag = function (content) {\n return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;\n};\n\n// Create object with fake `null` prototype: use ActiveX Object with cleared prototype\nvar NullProtoObjectViaActiveX = function (activeXDocument) {\n activeXDocument.write(scriptTag(''));\n activeXDocument.close();\n var temp = activeXDocument.parentWindow.Object;\n activeXDocument = null; // avoid memory leak\n return temp;\n};\n\n// Create object with fake `null` prototype: use iframe Object with cleared prototype\nvar NullProtoObjectViaIFrame = function () {\n // Thrash, waste and sodomy: IE GC bug\n var iframe = documentCreateElement('iframe');\n var JS = 'java' + SCRIPT + ':';\n var iframeDocument;\n iframe.style.display = 'none';\n html.appendChild(iframe);\n // https://github.com/zloirock/core-js/issues/475\n iframe.src = String(JS);\n iframeDocument = iframe.contentWindow.document;\n iframeDocument.open();\n iframeDocument.write(scriptTag('document.F=Object'));\n iframeDocument.close();\n return iframeDocument.F;\n};\n\n// Check for document.domain and active x support\n// No need to use active x approach when document.domain is not set\n// see https://github.com/es-shims/es5-shim/issues/150\n// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346\n// avoid IE GC bug\nvar activeXDocument;\nvar NullProtoObject = function () {\n try {\n /* global ActiveXObject -- old IE */\n activeXDocument = document.domain && new ActiveXObject('htmlfile');\n } catch (error) { /* ignore */ }\n NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();\n var length = enumBugKeys.length;\n while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];\n return NullProtoObject();\n};\n\nhiddenKeys[IE_PROTO] = true;\n\n// `Object.create` method\n// https://tc39.es/ecma262/#sec-object.create\nmodule.exports = Object.create || function create(O, Properties) {\n var result;\n if (O !== null) {\n EmptyConstructor[PROTOTYPE] = anObject(O);\n result = new EmptyConstructor();\n EmptyConstructor[PROTOTYPE] = null;\n // add \"__proto__\" for Object.getPrototypeOf polyfill\n result[IE_PROTO] = O;\n } else result = NullProtoObject();\n return Properties === undefined ? result : defineProperties(result, Properties);\n};\n", "var wellKnownSymbol = require('../internals/well-known-symbol');\nvar create = require('../internals/object-create');\nvar definePropertyModule = require('../internals/object-define-property');\n\nvar UNSCOPABLES = wellKnownSymbol('unscopables');\nvar ArrayPrototype = Array.prototype;\n\n// Array.prototype[@@unscopables]\n// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables\nif (ArrayPrototype[UNSCOPABLES] == undefined) {\n definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {\n configurable: true,\n value: create(null)\n });\n}\n\n// add a key to Array.prototype[@@unscopables]\nmodule.exports = function (key) {\n ArrayPrototype[UNSCOPABLES][key] = true;\n};\n", "'use strict';\nvar $forEach = require('../internals/array-iteration').forEach;\nvar arrayMethodIsStrict = require('../internals/array-method-is-strict');\n\nvar STRICT_METHOD = arrayMethodIsStrict('forEach');\n\n// `Array.prototype.forEach` method implementation\n// https://tc39.es/ecma262/#sec-array.prototype.foreach\nmodule.exports = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {\n return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n} : [].forEach;\n", "var aFunction = require('../internals/a-function');\nvar toObject = require('../internals/to-object');\nvar IndexedObject = require('../internals/indexed-object');\nvar toLength = require('../internals/to-length');\n\n// `Array.prototype.{ reduce, reduceRight }` methods implementation\nvar createMethod = function (IS_RIGHT) {\n return function (that, callbackfn, argumentsLength, memo) {\n aFunction(callbackfn);\n var O = toObject(that);\n var self = IndexedObject(O);\n var length = toLength(O.length);\n var index = IS_RIGHT ? length - 1 : 0;\n var i = IS_RIGHT ? -1 : 1;\n if (argumentsLength < 2) while (true) {\n if (index in self) {\n memo = self[index];\n index += i;\n break;\n }\n index += i;\n if (IS_RIGHT ? index < 0 : length <= index) {\n throw TypeError('Reduce of empty array with no initial value');\n }\n }\n for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {\n memo = callbackfn(memo, self[index], index, O);\n }\n return memo;\n };\n};\n\nmodule.exports = {\n // `Array.prototype.reduce` method\n // https://tc39.es/ecma262/#sec-array.prototype.reduce\n left: createMethod(false),\n // `Array.prototype.reduceRight` method\n // https://tc39.es/ecma262/#sec-array.prototype.reduceright\n right: createMethod(true)\n};\n", "var classof = require('../internals/classof-raw');\nvar global = require('../internals/global');\n\nmodule.exports = classof(global.process) == 'process';\n", "module.exports = typeof ArrayBuffer !== 'undefined' && typeof DataView !== 'undefined';\n", "var redefine = require('../internals/redefine');\n\nmodule.exports = function (target, src, options) {\n for (var key in src) redefine(target, key, src[key], options);\n return target;\n};\n", "module.exports = function (it, Constructor, name) {\n if (!(it instanceof Constructor)) {\n throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');\n } return it;\n};\n", "var toInteger = require('../internals/to-integer');\nvar toLength = require('../internals/to-length');\n\n// `ToIndex` abstract operation\n// https://tc39.es/ecma262/#sec-toindex\nmodule.exports = function (it) {\n if (it === undefined) return 0;\n var number = toInteger(it);\n var length = toLength(number);\n if (number !== length) throw RangeError('Wrong length or index');\n return length;\n};\n", "// IEEE754 conversions based on https://github.com/feross/ieee754\nvar abs = Math.abs;\nvar pow = Math.pow;\nvar floor = Math.floor;\nvar log = Math.log;\nvar LN2 = Math.LN2;\n\nvar pack = function (number, mantissaLength, bytes) {\n var buffer = new Array(bytes);\n var exponentLength = bytes * 8 - mantissaLength - 1;\n var eMax = (1 << exponentLength) - 1;\n var eBias = eMax >> 1;\n var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0;\n var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0;\n var index = 0;\n var exponent, mantissa, c;\n number = abs(number);\n // eslint-disable-next-line no-self-compare -- NaN check\n if (number != number || number === Infinity) {\n // eslint-disable-next-line no-self-compare -- NaN check\n mantissa = number != number ? 1 : 0;\n exponent = eMax;\n } else {\n exponent = floor(log(number) / LN2);\n if (number * (c = pow(2, -exponent)) < 1) {\n exponent--;\n c *= 2;\n }\n if (exponent + eBias >= 1) {\n number += rt / c;\n } else {\n number += rt * pow(2, 1 - eBias);\n }\n if (number * c >= 2) {\n exponent++;\n c /= 2;\n }\n if (exponent + eBias >= eMax) {\n mantissa = 0;\n exponent = eMax;\n } else if (exponent + eBias >= 1) {\n mantissa = (number * c - 1) * pow(2, mantissaLength);\n exponent = exponent + eBias;\n } else {\n mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength);\n exponent = 0;\n }\n }\n for (; mantissaLength >= 8; buffer[index++] = mantissa & 255, mantissa /= 256, mantissaLength -= 8);\n exponent = exponent << mantissaLength | mantissa;\n exponentLength += mantissaLength;\n for (; exponentLength > 0; buffer[index++] = exponent & 255, exponent /= 256, exponentLength -= 8);\n buffer[--index] |= sign * 128;\n return buffer;\n};\n\nvar unpack = function (buffer, mantissaLength) {\n var bytes = buffer.length;\n var exponentLength = bytes * 8 - mantissaLength - 1;\n var eMax = (1 << exponentLength) - 1;\n var eBias = eMax >> 1;\n var nBits = exponentLength - 7;\n var index = bytes - 1;\n var sign = buffer[index--];\n var exponent = sign & 127;\n var mantissa;\n sign >>= 7;\n for (; nBits > 0; exponent = exponent * 256 + buffer[index], index--, nBits -= 8);\n mantissa = exponent & (1 << -nBits) - 1;\n exponent >>= -nBits;\n nBits += mantissaLength;\n for (; nBits > 0; mantissa = mantissa * 256 + buffer[index], index--, nBits -= 8);\n if (exponent === 0) {\n exponent = 1 - eBias;\n } else if (exponent === eMax) {\n return mantissa ? NaN : sign ? -Infinity : Infinity;\n } else {\n mantissa = mantissa + pow(2, mantissaLength);\n exponent = exponent - eBias;\n } return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength);\n};\n\nmodule.exports = {\n pack: pack,\n unpack: unpack\n};\n", "var fails = require('../internals/fails');\n\nmodule.exports = !fails(function () {\n function F() { /* empty */ }\n F.prototype.constructor = null;\n return Object.getPrototypeOf(new F()) !== F.prototype;\n});\n", "var has = require('../internals/has');\nvar toObject = require('../internals/to-object');\nvar sharedKey = require('../internals/shared-key');\nvar CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');\n\nvar IE_PROTO = sharedKey('IE_PROTO');\nvar ObjectPrototype = Object.prototype;\n\n// `Object.getPrototypeOf` method\n// https://tc39.es/ecma262/#sec-object.getprototypeof\nmodule.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {\n O = toObject(O);\n if (has(O, IE_PROTO)) return O[IE_PROTO];\n if (typeof O.constructor == 'function' && O instanceof O.constructor) {\n return O.constructor.prototype;\n } return O instanceof Object ? ObjectPrototype : null;\n};\n", "var isObject = require('../internals/is-object');\n\nmodule.exports = function (it) {\n if (!isObject(it) && it !== null) {\n throw TypeError(\"Can't set \" + String(it) + ' as a prototype');\n } return it;\n};\n", "/* eslint-disable no-proto -- safe */\nvar anObject = require('../internals/an-object');\nvar aPossiblePrototype = require('../internals/a-possible-prototype');\n\n// `Object.setPrototypeOf` method\n// https://tc39.es/ecma262/#sec-object.setprototypeof\n// Works with __proto__ only. Old v8 can't work with null proto objects.\nmodule.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {\n var CORRECT_SETTER = false;\n var test = {};\n var setter;\n try {\n setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;\n setter.call(test, []);\n CORRECT_SETTER = test instanceof Array;\n } catch (error) { /* empty */ }\n return function setPrototypeOf(O, proto) {\n anObject(O);\n aPossiblePrototype(proto);\n if (CORRECT_SETTER) setter.call(O, proto);\n else O.__proto__ = proto;\n return O;\n };\n}() : undefined);\n", "'use strict';\nvar toObject = require('../internals/to-object');\nvar toAbsoluteIndex = require('../internals/to-absolute-index');\nvar toLength = require('../internals/to-length');\n\n// `Array.prototype.fill` method implementation\n// https://tc39.es/ecma262/#sec-array.prototype.fill\nmodule.exports = function fill(value /* , start = 0, end = @length */) {\n var O = toObject(this);\n var length = toLength(O.length);\n var argumentsLength = arguments.length;\n var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);\n var end = argumentsLength > 2 ? arguments[2] : undefined;\n var endPos = end === undefined ? length : toAbsoluteIndex(end, length);\n while (endPos > index) O[index++] = value;\n return O;\n};\n", "var defineProperty = require('../internals/object-define-property').f;\nvar has = require('../internals/has');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\n\nmodule.exports = function (it, TAG, STATIC) {\n if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {\n defineProperty(it, TO_STRING_TAG, { configurable: true, value: TAG });\n }\n};\n", "'use strict';\nvar global = require('../internals/global');\nvar DESCRIPTORS = require('../internals/descriptors');\nvar NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-native');\nvar createNonEnumerableProperty = require('../internals/create-non-enumerable-property');\nvar redefineAll = require('../internals/redefine-all');\nvar fails = require('../internals/fails');\nvar anInstance = require('../internals/an-instance');\nvar toInteger = require('../internals/to-integer');\nvar toLength = require('../internals/to-length');\nvar toIndex = require('../internals/to-index');\nvar IEEE754 = require('../internals/ieee754');\nvar getPrototypeOf = require('../internals/object-get-prototype-of');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\nvar getOwnPropertyNames = require('../internals/object-get-own-property-names').f;\nvar defineProperty = require('../internals/object-define-property').f;\nvar arrayFill = require('../internals/array-fill');\nvar setToStringTag = require('../internals/set-to-string-tag');\nvar InternalStateModule = require('../internals/internal-state');\n\nvar getInternalState = InternalStateModule.get;\nvar setInternalState = InternalStateModule.set;\nvar ARRAY_BUFFER = 'ArrayBuffer';\nvar DATA_VIEW = 'DataView';\nvar PROTOTYPE = 'prototype';\nvar WRONG_LENGTH = 'Wrong length';\nvar WRONG_INDEX = 'Wrong index';\nvar NativeArrayBuffer = global[ARRAY_BUFFER];\nvar $ArrayBuffer = NativeArrayBuffer;\nvar $DataView = global[DATA_VIEW];\nvar $DataViewPrototype = $DataView && $DataView[PROTOTYPE];\nvar ObjectPrototype = Object.prototype;\nvar RangeError = global.RangeError;\n\nvar packIEEE754 = IEEE754.pack;\nvar unpackIEEE754 = IEEE754.unpack;\n\nvar packInt8 = function (number) {\n return [number & 0xFF];\n};\n\nvar packInt16 = function (number) {\n return [number & 0xFF, number >> 8 & 0xFF];\n};\n\nvar packInt32 = function (number) {\n return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF];\n};\n\nvar unpackInt32 = function (buffer) {\n return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0];\n};\n\nvar packFloat32 = function (number) {\n return packIEEE754(number, 23, 4);\n};\n\nvar packFloat64 = function (number) {\n return packIEEE754(number, 52, 8);\n};\n\nvar addGetter = function (Constructor, key) {\n defineProperty(Constructor[PROTOTYPE], key, { get: function () { return getInternalState(this)[key]; } });\n};\n\nvar get = function (view, count, index, isLittleEndian) {\n var intIndex = toIndex(index);\n var store = getInternalState(view);\n if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX);\n var bytes = getInternalState(store.buffer).bytes;\n var start = intIndex + store.byteOffset;\n var pack = bytes.slice(start, start + count);\n return isLittleEndian ? pack : pack.reverse();\n};\n\nvar set = function (view, count, index, conversion, value, isLittleEndian) {\n var intIndex = toIndex(index);\n var store = getInternalState(view);\n if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX);\n var bytes = getInternalState(store.buffer).bytes;\n var start = intIndex + store.byteOffset;\n var pack = conversion(+value);\n for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1];\n};\n\nif (!NATIVE_ARRAY_BUFFER) {\n $ArrayBuffer = function ArrayBuffer(length) {\n anInstance(this, $ArrayBuffer, ARRAY_BUFFER);\n var byteLength = toIndex(length);\n setInternalState(this, {\n bytes: arrayFill.call(new Array(byteLength), 0),\n byteLength: byteLength\n });\n if (!DESCRIPTORS) this.byteLength = byteLength;\n };\n\n $DataView = function DataView(buffer, byteOffset, byteLength) {\n anInstance(this, $DataView, DATA_VIEW);\n anInstance(buffer, $ArrayBuffer, DATA_VIEW);\n var bufferLength = getInternalState(buffer).byteLength;\n var offset = toInteger(byteOffset);\n if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset');\n byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);\n if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);\n setInternalState(this, {\n buffer: buffer,\n byteLength: byteLength,\n byteOffset: offset\n });\n if (!DESCRIPTORS) {\n this.buffer = buffer;\n this.byteLength = byteLength;\n this.byteOffset = offset;\n }\n };\n\n if (DESCRIPTORS) {\n addGetter($ArrayBuffer, 'byteLength');\n addGetter($DataView, 'buffer');\n addGetter($DataView, 'byteLength');\n addGetter($DataView, 'byteOffset');\n }\n\n redefineAll($DataView[PROTOTYPE], {\n getInt8: function getInt8(byteOffset) {\n return get(this, 1, byteOffset)[0] << 24 >> 24;\n },\n getUint8: function getUint8(byteOffset) {\n return get(this, 1, byteOffset)[0];\n },\n getInt16: function getInt16(byteOffset /* , littleEndian */) {\n var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);\n return (bytes[1] << 8 | bytes[0]) << 16 >> 16;\n },\n getUint16: function getUint16(byteOffset /* , littleEndian */) {\n var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);\n return bytes[1] << 8 | bytes[0];\n },\n getInt32: function getInt32(byteOffset /* , littleEndian */) {\n return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined));\n },\n getUint32: function getUint32(byteOffset /* , littleEndian */) {\n return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0;\n },\n getFloat32: function getFloat32(byteOffset /* , littleEndian */) {\n return unpackIEEE754(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23);\n },\n getFloat64: function getFloat64(byteOffset /* , littleEndian */) {\n return unpackIEEE754(get(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52);\n },\n setInt8: function setInt8(byteOffset, value) {\n set(this, 1, byteOffset, packInt8, value);\n },\n setUint8: function setUint8(byteOffset, value) {\n set(this, 1, byteOffset, packInt8, value);\n },\n setInt16: function setInt16(byteOffset, value /* , littleEndian */) {\n set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setUint16: function setUint16(byteOffset, value /* , littleEndian */) {\n set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setInt32: function setInt32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setUint32: function setUint32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined);\n },\n setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) {\n set(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined);\n }\n });\n} else {\n /* eslint-disable no-new -- required for testing */\n if (!fails(function () {\n NativeArrayBuffer(1);\n }) || !fails(function () {\n new NativeArrayBuffer(-1);\n }) || fails(function () {\n new NativeArrayBuffer();\n new NativeArrayBuffer(1.5);\n new NativeArrayBuffer(NaN);\n return NativeArrayBuffer.name != ARRAY_BUFFER;\n })) {\n /* eslint-enable no-new -- required for testing */\n $ArrayBuffer = function ArrayBuffer(length) {\n anInstance(this, $ArrayBuffer);\n return new NativeArrayBuffer(toIndex(length));\n };\n var ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE] = NativeArrayBuffer[PROTOTYPE];\n for (var keys = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys.length > j;) {\n if (!((key = keys[j++]) in $ArrayBuffer)) {\n createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]);\n }\n }\n ArrayBufferPrototype.constructor = $ArrayBuffer;\n }\n\n // WebKit bug - the same parent prototype for typed arrays and data view\n if (setPrototypeOf && getPrototypeOf($DataViewPrototype) !== ObjectPrototype) {\n setPrototypeOf($DataViewPrototype, ObjectPrototype);\n }\n\n // iOS Safari 7.x bug\n var testView = new $DataView(new $ArrayBuffer(2));\n var nativeSetInt8 = $DataViewPrototype.setInt8;\n testView.setInt8(0, 2147483648);\n testView.setInt8(1, 2147483649);\n if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll($DataViewPrototype, {\n setInt8: function setInt8(byteOffset, value) {\n nativeSetInt8.call(this, byteOffset, value << 24 >> 24);\n },\n setUint8: function setUint8(byteOffset, value) {\n nativeSetInt8.call(this, byteOffset, value << 24 >> 24);\n }\n }, { unsafe: true });\n}\n\nsetToStringTag($ArrayBuffer, ARRAY_BUFFER);\nsetToStringTag($DataView, DATA_VIEW);\n\nmodule.exports = {\n ArrayBuffer: $ArrayBuffer,\n DataView: $DataView\n};\n", "'use strict';\nvar getBuiltIn = require('../internals/get-built-in');\nvar definePropertyModule = require('../internals/object-define-property');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\nvar DESCRIPTORS = require('../internals/descriptors');\n\nvar SPECIES = wellKnownSymbol('species');\n\nmodule.exports = function (CONSTRUCTOR_NAME) {\n var Constructor = getBuiltIn(CONSTRUCTOR_NAME);\n var defineProperty = definePropertyModule.f;\n\n if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {\n defineProperty(Constructor, SPECIES, {\n configurable: true,\n get: function () { return this; }\n });\n }\n};\n", "var isObject = require('../internals/is-object');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\n\n// makes subclassing work correct for wrapped built-ins\nmodule.exports = function ($this, dummy, Wrapper) {\n var NewTarget, NewTargetPrototype;\n if (\n // it can work only with native `setPrototypeOf`\n setPrototypeOf &&\n // we haven't completely correct pre-ES6 way for getting `new.target`, so use this\n typeof (NewTarget = dummy.constructor) == 'function' &&\n NewTarget !== Wrapper &&\n isObject(NewTargetPrototype = NewTarget.prototype) &&\n NewTargetPrototype !== Wrapper.prototype\n ) setPrototypeOf($this, NewTargetPrototype);\n return $this;\n};\n", "// `SameValue` abstract operation\n// https://tc39.es/ecma262/#sec-samevalue\nmodule.exports = Object.is || function is(x, y) {\n // eslint-disable-next-line no-self-compare -- NaN check\n return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;\n};\n", "var fails = require('../internals/fails');\nvar whitespaces = require('../internals/whitespaces');\n\nvar non = '\\u200B\\u0085\\u180E';\n\n// check that a method works with the correct list\n// of whitespaces and has a correct name\nmodule.exports = function (METHOD_NAME) {\n return fails(function () {\n return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME;\n });\n};\n", "// iterable DOM collections\n// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods\nmodule.exports = {\n CSSRuleList: 0,\n CSSStyleDeclaration: 0,\n CSSValueList: 0,\n ClientRectList: 0,\n DOMRectList: 0,\n DOMStringList: 0,\n DOMTokenList: 1,\n DataTransferItemList: 0,\n FileList: 0,\n HTMLAllCollection: 0,\n HTMLCollection: 0,\n HTMLFormElement: 0,\n HTMLSelectElement: 0,\n MediaList: 0,\n MimeTypeArray: 0,\n NamedNodeMap: 0,\n NodeList: 1,\n PaintRequestList: 0,\n Plugin: 0,\n PluginArray: 0,\n SVGLengthList: 0,\n SVGNumberList: 0,\n SVGPathSegList: 0,\n SVGPointList: 0,\n SVGStringList: 0,\n SVGTransformList: 0,\n SourceBufferList: 0,\n StyleSheetList: 0,\n TextTrackCueList: 0,\n TextTrackList: 0,\n TouchList: 0\n};\n", "import \"core-js/modules/es.array.concat.js\";\nimport \"core-js/modules/es.array.filter.js\";\nimport \"core-js/modules/es.array.find.js\";\nimport \"core-js/modules/es.array.for-each.js\";\nimport \"core-js/modules/es.array.index-of.js\";\nimport \"core-js/modules/es.array.join.js\";\nimport \"core-js/modules/es.array.map.js\";\nimport \"core-js/modules/es.array.reduce.js\";\nimport \"core-js/modules/es.array.slice.js\";\nimport \"core-js/modules/es.array.splice.js\";\nimport \"core-js/modules/es.array-buffer.constructor.js\";\nimport \"core-js/modules/es.array-buffer.slice.js\";\nimport \"core-js/modules/es.data-view.js\";\nimport \"core-js/modules/es.function.name.js\";\nimport \"core-js/modules/es.number.constructor.js\";\nimport \"core-js/modules/es.object.keys.js\";\nimport \"core-js/modules/es.object.to-string.js\";\nimport \"core-js/modules/es.parse-float.js\";\nimport \"core-js/modules/es.parse-int.js\";\nimport \"core-js/modules/es.regexp.exec.js\";\nimport \"core-js/modules/es.regexp.to-string.js\";\nimport \"core-js/modules/es.string.match.js\";\nimport \"core-js/modules/es.string.replace.js\";\nimport \"core-js/modules/es.string.search.js\";\nimport \"core-js/modules/es.string.split.js\";\nimport \"core-js/modules/es.string.trim.js\";\nimport \"core-js/modules/web.dom-collections.for-each.js\";\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n/* eslint \"@typescript-eslint/ban-ts-comment\": 0 */\n// @ts-nocheck\n\n/* eslint \"camelcase\": 0 */\n\n/* eslint \"@typescript-eslint/no-unused-vars\": 0 */\n\n/* eslint \"@typescript-eslint/no-this-alias\": 0 */\n\n/* eslint \"@typescript-eslint/no-empty-function\": 0 */\n\n/* eslint \"no-prototype-builtins\": 0 */\n\n/* eslint \"prefer-const\": 0 */\n\n/* eslint \"no-constant-condition\": 0 */\nimport $ from \"jquery\";\njQuery = $;\nimport { escapeHTML, randomId, strToBool, getStyle, roundSignif, parseDate, formatDateUTC, makeResizeFilter, pixelRatio, scopeExprToFunc, asArray, mergeSort, $escape, mapValues, isnan, equal, updateLabel, getComputedLinkColor, makeBlob, isBS3 } from \"./utils\";\nimport { isQt, isIE, IEVersion } from \"./utils/browser\";\nimport { FileProcessor } from \"./file/FileProcessor\";\nimport { Shiny } from \"./shiny\";\n\nfunction main() {\n // \"_start.js\"\n // \u221A\n // \"utils.js\"\n // \u221A\n // \"browser.js\"\n // \u221A\n // \"input_rate.js\"\n var Invoker = function Invoker(target, func) {\n this.target = target;\n this.func = func;\n };\n\n (function () {\n this.normalCall = this.immediateCall = function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n this.func.apply(this.target, args);\n };\n }).call(Invoker.prototype);\n\n var Debouncer = function Debouncer(target, func, delayMs) {\n this.target = target;\n this.func = func;\n this.delayMs = delayMs;\n this.timerId = null;\n this.args = null;\n };\n\n (function () {\n this.normalCall = function () {\n var self = this;\n this.$clearTimer();\n\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n this.args = args;\n this.timerId = setTimeout(function () {\n // IE8 doesn't reliably clear timeout, so this additional\n // check is needed\n if (self.timerId === null) return;\n self.$clearTimer();\n self.$invoke();\n }, this.delayMs);\n };\n\n this.immediateCall = function () {\n this.$clearTimer();\n\n for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n\n this.args = args;\n this.$invoke();\n };\n\n this.isPending = function () {\n return this.timerId !== null;\n };\n\n this.$clearTimer = function () {\n if (this.timerId !== null) {\n clearTimeout(this.timerId);\n this.timerId = null;\n }\n };\n\n this.$invoke = function () {\n this.func.apply(this.target, this.args);\n this.args = null;\n };\n }).call(Debouncer.prototype);\n\n var Throttler = function Throttler(target, func, delayMs) {\n this.target = target;\n this.func = func;\n this.delayMs = delayMs;\n this.timerId = null;\n this.args = null;\n };\n\n (function () {\n this.normalCall = function () {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n\n var self = this;\n this.args = args;\n\n if (this.timerId === null) {\n this.$invoke();\n this.timerId = setTimeout(function () {\n var _self$normalCall;\n\n // IE8 doesn't reliably clear timeout, so this additional\n // check is needed\n if (self.timerId === null) return;\n self.$clearTimer();\n if (args.length > 0) (_self$normalCall = self.normalCall).apply.apply(_self$normalCall, [self].concat(args));\n }, this.delayMs);\n }\n };\n\n this.immediateCall = function () {\n this.$clearTimer();\n\n for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {\n args[_key5] = arguments[_key5];\n }\n\n this.args = args;\n this.$invoke();\n };\n\n this.isPending = function () {\n return this.timerId !== null;\n };\n\n this.$clearTimer = function () {\n if (this.timerId !== null) {\n clearTimeout(this.timerId);\n this.timerId = null;\n }\n };\n\n this.$invoke = function () {\n this.func.apply(this.target, this.args);\n this.args = null;\n };\n }).call(Throttler.prototype); // Returns a debounced version of the given function.\n // Debouncing means that when the function is invoked,\n // there is a delay of `threshold` milliseconds before\n // it is actually executed, and if the function is\n // invoked again before that threshold has elapsed then\n // the clock starts over.\n //\n // For example, if a function is debounced with a\n // threshold of 1000ms, then calling it 17 times at\n // 900ms intervals will result in a single execution\n // of the underlying function, 1000ms after the 17th\n // call.\n\n function debounce(threshold, func) {\n var timerId = null;\n var self, args;\n return function () {\n for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {\n args[_key6] = arguments[_key6];\n }\n\n self = this;\n\n if (timerId !== null) {\n clearTimeout(timerId);\n timerId = null;\n }\n\n timerId = setTimeout(function () {\n // IE8 doesn't reliably clear timeout, so this additional\n // check is needed\n if (timerId === null) return;\n timerId = null;\n func.apply(self, args);\n }, threshold);\n };\n } // Returns a throttled version of the given function.\n // Throttling means that the underlying function will\n // be executed no more than once every `threshold`\n // milliseconds.\n //\n // For example, if a function is throttled with a\n // threshold of 1000ms, then calling it 17 times at\n // 900ms intervals will result in something like 15\n // or 16 executions of the underlying function.\n // eslint-disable-next-line no-unused-vars\n\n\n function throttle(threshold, func) {\n var executionPending = false;\n var timerId = null;\n var self, args;\n\n function throttled() {\n self = null;\n args = null;\n\n for (var _len7 = arguments.length, argumentVals = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {\n argumentVals[_key7] = arguments[_key7];\n }\n\n if (timerId === null) {\n // Haven't seen a call recently. Execute now and\n // start a timer to buffer any subsequent calls.\n timerId = setTimeout(function () {\n // When time expires, clear the timer; and if\n // there has been a call in the meantime, repeat.\n timerId = null;\n\n if (executionPending) {\n executionPending = false;\n throttled.apply(self, args);\n }\n }, threshold);\n func.apply(this, argumentVals);\n } else {\n // Something executed recently. Don't do anything\n // except set up target/arguments to be called later\n executionPending = true;\n self = this;\n args = argumentVals;\n }\n }\n\n return throttled;\n } // Schedules data to be sent to shinyapp at the next setTimeout(0).\n // Batches multiple input calls into one websocket message.\n\n\n var InputBatchSender = function InputBatchSender(shinyapp) {\n this.shinyapp = shinyapp;\n this.timerId = null;\n this.pendingData = {};\n this.reentrant = false;\n this.lastChanceCallback = [];\n };\n\n (function () {\n this.setInput = function (nameType, value, opts) {\n this.pendingData[nameType] = value;\n\n if (!this.reentrant) {\n if (opts.priority === \"event\") {\n this.$sendNow();\n } else if (!this.timerId) {\n this.timerId = setTimeout(this.$sendNow.bind(this), 0);\n }\n }\n };\n\n this.$sendNow = function () {\n if (this.reentrant) {\n console.trace(\"Unexpected reentrancy in InputBatchSender!\");\n }\n\n this.reentrant = true;\n\n try {\n this.timerId = null;\n $.each(this.lastChanceCallback, function (i, callback) {\n callback();\n });\n var currentData = this.pendingData;\n this.pendingData = {};\n this.shinyapp.sendInput(currentData);\n } finally {\n this.reentrant = false;\n }\n };\n }).call(InputBatchSender.prototype);\n\n var InputNoResendDecorator = function InputNoResendDecorator(target, initialValues) {\n this.target = target;\n this.lastSentValues = this.reset(initialValues);\n };\n\n (function () {\n this.setInput = function (nameType, value, opts) {\n var _splitInputNameType = splitInputNameType(nameType),\n inputName = _splitInputNameType.name,\n inputType = _splitInputNameType.inputType;\n\n var jsonValue = JSON.stringify(value);\n\n if (opts.priority !== \"event\" && this.lastSentValues[inputName] && this.lastSentValues[inputName].jsonValue === jsonValue && this.lastSentValues[inputName].inputType === inputType) {\n return;\n }\n\n this.lastSentValues[inputName] = {\n jsonValue: jsonValue,\n inputType: inputType\n };\n this.target.setInput(nameType, value, opts);\n };\n\n this.reset = function () {\n var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n // Given an object with flat name-value format:\n // { x: \"abc\", \"y.shiny.number\": 123 }\n // Create an object in cache format and save it:\n // { x: { jsonValue: '\"abc\"', inputType: \"\" },\n // y: { jsonValue: \"123\", inputType: \"shiny.number\" } }\n var cacheValues = {};\n\n for (var inputName in values) {\n if (values.hasOwnProperty(inputName)) {\n var _splitInputNameType2 = splitInputNameType(inputName),\n name = _splitInputNameType2.name,\n inputType = _splitInputNameType2.inputType;\n\n cacheValues[name] = {\n jsonValue: JSON.stringify(values[inputName]),\n inputType: inputType\n };\n }\n }\n\n this.lastSentValues = cacheValues;\n };\n\n this.forget = function (name) {\n delete this.lastSentValues[name];\n };\n }).call(InputNoResendDecorator.prototype);\n\n var InputEventDecorator = function InputEventDecorator(target) {\n this.target = target;\n };\n\n (function () {\n this.setInput = function (nameType, value, opts) {\n var evt = jQuery.Event(\"shiny:inputchanged\");\n var input = splitInputNameType(nameType);\n evt.name = input.name;\n evt.inputType = input.inputType;\n evt.value = value;\n evt.binding = opts.binding;\n evt.el = opts.el;\n evt.priority = opts.priority;\n $(opts.el).trigger(evt);\n\n if (!evt.isDefaultPrevented()) {\n var name = evt.name;\n if (evt.inputType !== \"\") name += \":\" + evt.inputType; // Most opts aren't passed along to lower levels in the input decorator\n // stack.\n\n this.target.setInput(name, evt.value, {\n priority: opts.priority\n });\n }\n };\n }).call(InputEventDecorator.prototype);\n\n var InputRateDecorator = function InputRateDecorator(target) {\n this.target = target;\n this.inputRatePolicies = {};\n };\n\n (function () {\n // Note that the first argument of setInput() and setRatePolicy()\n // are passed both the input name (i.e., inputId) and type.\n // https://github.com/rstudio/shiny/blob/67d3a/srcjs/init_shiny.js#L111-L126\n // However, $ensureInit() and $doSetInput() are meant to be passed just\n // the input name (i.e., inputId), which is why we distinguish between\n // nameType and name.\n this.setInput = function (nameType, value, opts) {\n var _splitInputNameType3 = splitInputNameType(nameType),\n inputName = _splitInputNameType3.name;\n\n this.$ensureInit(inputName);\n if (opts.priority !== \"deferred\") this.inputRatePolicies[inputName].immediateCall(nameType, value, opts);else this.inputRatePolicies[inputName].normalCall(nameType, value, opts);\n };\n\n this.setRatePolicy = function (nameType, mode, millis) {\n var _splitInputNameType4 = splitInputNameType(nameType),\n inputName = _splitInputNameType4.name;\n\n if (mode === \"direct\") {\n this.inputRatePolicies[inputName] = new Invoker(this, this.$doSetInput);\n } else if (mode === \"debounce\") {\n this.inputRatePolicies[inputName] = new Debouncer(this, this.$doSetInput, millis);\n } else if (mode === \"throttle\") {\n this.inputRatePolicies[inputName] = new Throttler(this, this.$doSetInput, millis);\n }\n };\n\n this.$ensureInit = function (name) {\n if (!(name in this.inputRatePolicies)) this.setRatePolicy(name, \"direct\");\n };\n\n this.$doSetInput = function (nameType, value, opts) {\n this.target.setInput(nameType, value, opts);\n };\n }).call(InputRateDecorator.prototype);\n\n var InputDeferDecorator = function InputDeferDecorator(target) {\n this.target = target;\n this.pendingInput = {};\n };\n\n (function () {\n this.setInput = function (nameType, value, opts) {\n if (/^\\./.test(nameType)) this.target.setInput(nameType, value, opts);else this.pendingInput[nameType] = {\n value: value,\n opts: opts\n };\n };\n\n this.submit = function () {\n for (var nameType in this.pendingInput) {\n if (this.pendingInput.hasOwnProperty(nameType)) {\n var _this$pendingInput$na = this.pendingInput[nameType],\n value = _this$pendingInput$na.value,\n opts = _this$pendingInput$na.opts;\n this.target.setInput(nameType, value, opts);\n }\n }\n };\n }).call(InputDeferDecorator.prototype);\n\n var InputValidateDecorator = function InputValidateDecorator(target) {\n this.target = target;\n };\n\n (function () {\n this.setInput = function (nameType, value, opts) {\n if (!nameType) throw \"Can't set input with empty name.\";\n opts = addDefaultInputOpts(opts);\n this.target.setInput(nameType, value, opts);\n };\n }).call(InputValidateDecorator.prototype); // Merge opts with defaults, and return a new object.\n\n function addDefaultInputOpts(opts) {\n opts = $.extend({\n priority: \"immediate\",\n binding: null,\n el: null\n }, opts);\n\n if (opts && typeof opts.priority !== \"undefined\") {\n switch (opts.priority) {\n case \"deferred\":\n case \"immediate\":\n case \"event\":\n break;\n\n default:\n throw new Error(\"Unexpected input value mode: '\" + opts.priority + \"'\");\n }\n }\n\n return opts;\n }\n\n function splitInputNameType(nameType) {\n var name2 = nameType.split(\":\");\n return {\n name: name2[0],\n inputType: name2.length > 1 ? name2[1] : \"\"\n };\n } // \"shinyapp.js\"\n\n\n var ShinyApp = function ShinyApp() {\n this.$socket = null; // Cached input values\n\n this.$inputValues = {}; // Input values at initialization (and reconnect)\n\n this.$initialInput = {}; // Output bindings\n\n this.$bindings = {}; // Cached values/errors\n\n this.$values = {};\n this.$errors = {}; // Conditional bindings (show/hide element based on expression)\n\n this.$conditionals = {};\n this.$pendingMessages = [];\n this.$activeRequests = {};\n this.$nextRequestId = 0;\n this.$allowReconnect = false;\n };\n\n (function () {\n this.connect = function (initialInput) {\n if (this.$socket) throw \"Connect was already called on this application object\";\n this.$socket = this.createSocket();\n this.$initialInput = initialInput;\n $.extend(this.$inputValues, initialInput);\n this.$updateConditionals();\n };\n\n this.isConnected = function () {\n return !!this.$socket;\n };\n\n var scheduledReconnect = null;\n\n this.reconnect = function () {\n // This function can be invoked directly even if there's a scheduled\n // reconnect, so be sure to clear any such scheduled reconnects.\n clearTimeout(scheduledReconnect);\n if (this.isConnected()) throw \"Attempted to reconnect, but already connected.\";\n this.$socket = this.createSocket();\n this.$initialInput = $.extend({}, this.$inputValues);\n this.$updateConditionals();\n };\n\n this.createSocket = function () {\n var self = this;\n\n var createSocketFunc = Shiny.createSocket || function () {\n var protocol = \"ws:\";\n if (window.location.protocol === \"https:\") protocol = \"wss:\";\n var defaultPath = window.location.pathname; // some older WebKit browsers return the pathname already decoded;\n // if we find invalid URL characters in the path, encode them\n\n if (!/^([$#!&-;=?-[\\]_a-z~]|%[0-9a-fA-F]{2})+$/.test(defaultPath)) {\n defaultPath = encodeURI(defaultPath); // Bizarrely, QtWebKit requires us to encode these characters *twice*\n\n if (isQt()) {\n defaultPath = encodeURI(defaultPath);\n }\n }\n\n if (!/\\/$/.test(defaultPath)) defaultPath += \"/\";\n defaultPath += \"websocket/\";\n var ws = new WebSocket(protocol + \"//\" + window.location.host + defaultPath);\n ws.binaryType = \"arraybuffer\";\n return ws;\n };\n\n var socket = createSocketFunc();\n var hasOpened = false;\n\n socket.onopen = function () {\n hasOpened = true;\n $(document).trigger({\n type: \"shiny:connected\",\n socket: socket\n });\n self.onConnected();\n socket.send(JSON.stringify({\n method: \"init\",\n data: self.$initialInput\n }));\n\n while (self.$pendingMessages.length) {\n var msg = self.$pendingMessages.shift();\n socket.send(msg);\n }\n };\n\n socket.onmessage = function (e) {\n self.dispatchMessage(e.data);\n }; // Called when a successfully-opened websocket is closed, or when an\n // attempt to open a connection fails.\n\n\n socket.onclose = function () {\n // These things are needed only if we've successfully opened the\n // websocket.\n if (hasOpened) {\n $(document).trigger({\n type: \"shiny:disconnected\",\n socket: socket\n });\n self.$notifyDisconnected();\n }\n\n self.onDisconnected(); // Must be run before self.$removeSocket()\n\n self.$removeSocket();\n };\n\n return socket;\n };\n\n this.sendInput = function (values) {\n var msg = JSON.stringify({\n method: \"update\",\n data: values\n });\n this.$sendMsg(msg);\n $.extend(this.$inputValues, values);\n this.$updateConditionals();\n };\n\n this.$notifyDisconnected = function () {\n if (window.parent) {\n window.parent.postMessage(\"disconnected\", \"*\");\n }\n };\n\n this.$removeSocket = function () {\n this.$socket = null;\n };\n\n this.$scheduleReconnect = function (delay) {\n var self = this;\n scheduledReconnect = setTimeout(function () {\n self.reconnect();\n }, delay);\n }; // How long should we wait before trying the next reconnection?\n // The delay will increase with subsequent attempts.\n // .next: Return the time to wait for next connection, and increment counter.\n // .reset: Reset the attempt counter.\n\n\n var reconnectDelay = function () {\n var attempts = 0; // Time to wait before each reconnection attempt. If we go through all of\n // these values, repeated use the last one. Add 500ms to each one so that\n // in the last 0.5s, it shows \"...\"\n\n var delays = [1500, 1500, 2500, 2500, 5500, 5500, 10500];\n return {\n next: function next() {\n var i = attempts; // Instead of going off the end, use the last one\n\n if (i >= delays.length) {\n i = delays.length - 1;\n }\n\n attempts++;\n return delays[i];\n },\n reset: function reset() {\n attempts = 0;\n }\n };\n }();\n\n this.onDisconnected = function () {\n // Add gray-out overlay, if not already present\n var $overlay = $(\"#shiny-disconnected-overlay\");\n\n if ($overlay.length === 0) {\n $(document.body).append('
    ');\n } // To try a reconnect, both the app (this.$allowReconnect) and the\n // server (this.$socket.allowReconnect) must allow reconnections, or\n // session$allowReconnect(\"force\") was called. The \"force\" option should\n // only be used for testing.\n\n\n if (this.$allowReconnect === true && this.$socket.allowReconnect === true || this.$allowReconnect === \"force\") {\n var delay = reconnectDelay.next();\n Shiny.showReconnectDialog(delay);\n this.$scheduleReconnect(delay);\n }\n };\n\n this.onConnected = function () {\n $(\"#shiny-disconnected-overlay\").remove();\n Shiny.hideReconnectDialog();\n reconnectDelay.reset();\n }; // NB: Including blobs will cause IE to break!\n // TODO: Make blobs work with Internet Explorer\n //\n // Websocket messages are normally one-way--i.e. the client passes a\n // message to the server but there is no way for the server to provide\n // a response to that specific message. makeRequest provides a way to\n // do asynchronous RPC over websocket. Each request has a method name\n // and arguments, plus optionally one or more binary blobs can be\n // included as well. The request is tagged with a unique number that\n // the server will use to label the corresponding response.\n //\n // @param method A string that tells the server what logic to run.\n // @param args An array of objects that should also be passed to the\n // server in JSON-ified form.\n // @param onSuccess A function that will be called back if the server\n // responds with success. If the server provides a value in the\n // response, the function will be called with it as the only argument.\n // @param onError A function that will be called back if the server\n // responds with error, or if the request fails for any other reason.\n // The parameter to onError will be a string describing the error.\n // @param blobs Optionally, an array of Blob, ArrayBuffer, or string\n // objects that will be made available to the server as part of the\n // request. Strings will be encoded using UTF-8.\n\n\n this.makeRequest = function (method, args, onSuccess, onError, blobs) {\n var requestId = this.$nextRequestId;\n\n while (this.$activeRequests[requestId]) {\n requestId = (requestId + 1) % 1000000000;\n }\n\n this.$nextRequestId = requestId + 1;\n this.$activeRequests[requestId] = {\n onSuccess: onSuccess,\n onError: onError\n };\n var msg = JSON.stringify({\n method: method,\n args: args,\n tag: requestId\n });\n\n if (blobs) {\n // We have binary data to transfer; form a different kind of packet.\n // Start with a 4-byte signature, then for each blob, emit 4 bytes for\n // the length followed by the blob. The json payload is UTF-8 encoded\n // and used as the first blob.\n var uint32_to_buf = function uint32_to_buf(val) {\n var buffer = new ArrayBuffer(4);\n var view = new DataView(buffer);\n view.setUint32(0, val, true); // little-endian\n\n return buffer;\n };\n\n var payload = [];\n payload.push(uint32_to_buf(0x01020202)); // signature\n\n var jsonBuf = makeBlob([msg]);\n payload.push(uint32_to_buf(jsonBuf.size));\n payload.push(jsonBuf);\n\n for (var i = 0; i < blobs.length; i++) {\n payload.push(uint32_to_buf(blobs[i].byteLength || blobs[i].size || 0));\n payload.push(blobs[i]);\n }\n\n msg = makeBlob(payload);\n }\n\n this.$sendMsg(msg);\n };\n\n this.$sendMsg = function (msg) {\n if (!this.$socket.readyState) {\n this.$pendingMessages.push(msg);\n } else {\n this.$socket.send(msg);\n }\n };\n\n this.receiveError = function (name, error) {\n if (this.$errors[name] === error) return;\n this.$errors[name] = error;\n delete this.$values[name];\n var binding = this.$bindings[name];\n var evt = jQuery.Event(\"shiny:error\");\n evt.name = name;\n evt.error = error;\n evt.binding = binding;\n $(binding ? binding.el : document).trigger(evt);\n\n if (!evt.isDefaultPrevented() && binding && binding.onValueError) {\n binding.onValueError(evt.error);\n }\n };\n\n this.receiveOutput = function (name, value) {\n var binding = this.$bindings[name];\n var evt = jQuery.Event(\"shiny:value\");\n evt.name = name;\n evt.value = value;\n evt.binding = binding;\n\n if (this.$values[name] === value) {\n $(binding ? binding.el : document).trigger(evt);\n return undefined;\n }\n\n this.$values[name] = value;\n delete this.$errors[name];\n $(binding ? binding.el : document).trigger(evt);\n\n if (!evt.isDefaultPrevented() && binding) {\n binding.onValueChange(evt.value);\n }\n\n return value;\n };\n\n this.bindOutput = function (id, binding) {\n if (!id) throw \"Can't bind an element with no ID\";\n if (this.$bindings[id]) throw \"Duplicate binding for ID \" + id;\n this.$bindings[id] = binding;\n if (this.$values[id] !== undefined) binding.onValueChange(this.$values[id]);else if (this.$errors[id] !== undefined) binding.onValueError(this.$errors[id]);\n return binding;\n };\n\n this.unbindOutput = function (id, binding) {\n if (this.$bindings[id] === binding) {\n delete this.$bindings[id];\n return true;\n } else {\n return false;\n }\n }; // Narrows a scopeComponent -- an input or output object -- to one constrained\n // by nsPrefix. Returns a new object with keys removed and renamed as\n // necessary.\n\n\n function narrowScopeComponent(scopeComponent, nsPrefix) {\n return Object.keys(scopeComponent).filter(function (k) {\n return k.indexOf(nsPrefix) === 0;\n }).map(function (k) {\n return _defineProperty({}, k.substring(nsPrefix.length), scopeComponent[k]);\n }).reduce(function (obj, pair) {\n return $.extend(obj, pair);\n }, {});\n } // Narrows a scope -- an object with input and output \"subComponents\" -- to\n // one constrained by the nsPrefix string.\n //\n // If nsPrefix is null or empty, returns scope without modification.\n //\n // Otherwise, returns a new object with keys in subComponents removed and\n // renamed as necessary.\n\n\n function narrowScope(scope, nsPrefix) {\n if (nsPrefix) {\n return {\n input: narrowScopeComponent(scope.input, nsPrefix),\n output: narrowScopeComponent(scope.output, nsPrefix)\n };\n }\n\n return scope;\n }\n\n this.$updateConditionals = function () {\n $(document).trigger({\n type: \"shiny:conditional\"\n });\n var inputs = {}; // Input keys use \"name:type\" format; we don't want the user to\n // have to know about the type suffix when referring to inputs.\n\n for (var name in this.$inputValues) {\n if (this.$inputValues.hasOwnProperty(name)) {\n var shortName = name.replace(/:.*/, \"\");\n inputs[shortName] = this.$inputValues[name];\n }\n }\n\n var scope = {\n input: inputs,\n output: this.$values\n };\n var conditionals = $(document).find(\"[data-display-if]\");\n\n for (var i = 0; i < conditionals.length; i++) {\n var el = $(conditionals[i]);\n var condFunc = el.data(\"data-display-if-func\");\n\n if (!condFunc) {\n var condExpr = el.attr(\"data-display-if\");\n condFunc = scopeExprToFunc(condExpr);\n el.data(\"data-display-if-func\", condFunc);\n }\n\n var nsPrefix = el.attr(\"data-ns-prefix\");\n var nsScope = narrowScope(scope, nsPrefix);\n var show = condFunc(nsScope);\n var showing = el.css(\"display\") !== \"none\";\n\n if (show !== showing) {\n if (show) {\n el.trigger(\"show\");\n el.show();\n el.trigger(\"shown\");\n } else {\n el.trigger(\"hide\");\n el.hide();\n el.trigger(\"hidden\");\n }\n }\n }\n }; // Message handler management functions =================================\n // Records insertion order of handlers. Maps number to name. This is so\n // we can dispatch messages to handlers in the order that handlers were\n // added.\n\n\n var messageHandlerOrder = []; // Keep track of handlers by name. Maps name to handler function.\n\n var messageHandlers = {}; // Two categories of message handlers: those that are from Shiny, and those\n // that are added by the user. The Shiny ones handle messages in\n // msgObj.values, msgObj.errors, and so on. The user ones handle messages\n // in msgObj.custom.foo and msgObj.custom.bar.\n\n var customMessageHandlerOrder = [];\n var customMessageHandlers = {}; // Adds Shiny (internal) message handler\n\n function addMessageHandler(type, handler) {\n if (messageHandlers[type]) {\n throw 'handler for message of type \"' + type + '\" already added.';\n }\n\n if (typeof handler !== \"function\") {\n throw \"handler must be a function.\";\n }\n\n if (handler.length !== 1) {\n throw \"handler must be a function that takes one argument.\";\n }\n\n messageHandlerOrder.push(type);\n messageHandlers[type] = handler;\n } // Adds custom message handler - this one is exposed to the user\n\n\n function addCustomMessageHandler(type, handler) {\n // Remove any previously defined handlers so that only the most recent one\n // will be called\n if (customMessageHandlers[type]) {\n var typeIdx = customMessageHandlerOrder.indexOf(type);\n\n if (typeIdx !== -1) {\n customMessageHandlerOrder.splice(typeIdx, 1);\n delete customMessageHandlers[type];\n }\n }\n\n if (typeof handler !== \"function\") {\n throw \"handler must be a function.\";\n }\n\n if (handler.length !== 1) {\n throw \"handler must be a function that takes one argument.\";\n }\n\n customMessageHandlerOrder.push(type);\n customMessageHandlers[type] = handler;\n }\n\n Shiny.addCustomMessageHandler = addCustomMessageHandler;\n\n this.dispatchMessage = function (data) {\n var msgObj = {};\n\n if (typeof data === \"string\") {\n msgObj = JSON.parse(data);\n } else {\n // data is arraybuffer\n var len = new DataView(data, 0, 1).getUint8(0);\n var typedv = new DataView(data, 1, len);\n var typebuf = [];\n\n for (var i = 0; i < len; i++) {\n typebuf.push(String.fromCharCode(typedv.getUint8(i)));\n }\n\n var type = typebuf.join(\"\");\n data = data.slice(len + 1);\n msgObj.custom = {};\n msgObj.custom[type] = data;\n }\n\n var evt = jQuery.Event(\"shiny:message\");\n evt.message = msgObj;\n $(document).trigger(evt);\n if (evt.isDefaultPrevented()) return; // Send msgObj.foo and msgObj.bar to appropriate handlers\n\n this._sendMessagesToHandlers(evt.message, messageHandlers, messageHandlerOrder);\n\n this.$updateConditionals();\n }; // A function for sending messages to the appropriate handlers.\n // - msgObj: the object containing messages, with format {msgObj.foo, msObj.bar\n\n\n this._sendMessagesToHandlers = function (msgObj, handlers, handlerOrder) {\n // Dispatch messages to handlers, if handler is present\n for (var i = 0; i < handlerOrder.length; i++) {\n var msgType = handlerOrder[i];\n\n if (msgObj.hasOwnProperty(msgType)) {\n // Execute each handler with 'this' referring to the present value of\n // 'this'\n handlers[msgType].call(this, msgObj[msgType]);\n }\n }\n }; // Message handlers =====================================================\n\n\n addMessageHandler(\"values\", function (message) {\n for (var name in this.$bindings) {\n if (this.$bindings.hasOwnProperty(name)) this.$bindings[name].showProgress(false);\n }\n\n for (var key in message) {\n if (message.hasOwnProperty(key)) this.receiveOutput(key, message[key]);\n }\n });\n addMessageHandler(\"errors\", function (message) {\n for (var key in message) {\n if (message.hasOwnProperty(key)) this.receiveError(key, message[key]);\n }\n });\n addMessageHandler(\"inputMessages\", function (message) {\n // inputMessages should be an array\n for (var i = 0; i < message.length; i++) {\n var $obj = $(\".shiny-bound-input#\" + $escape(message[i].id));\n var inputBinding = $obj.data(\"shiny-input-binding\"); // Dispatch the message to the appropriate input object\n\n if ($obj.length > 0) {\n if (!$obj.attr(\"aria-live\")) $obj.attr(\"aria-live\", \"polite\");\n var el = $obj[0];\n var evt = jQuery.Event(\"shiny:updateinput\");\n evt.message = message[i].message;\n evt.binding = inputBinding;\n $(el).trigger(evt);\n if (!evt.isDefaultPrevented()) inputBinding.receiveMessage(el, evt.message);\n }\n }\n });\n addMessageHandler(\"javascript\", function (message) {\n /*jshint evil: true */\n eval(message);\n });\n addMessageHandler(\"console\", function (message) {\n for (var i = 0; i < message.length; i++) {\n if (console.log) console.log(message[i]);\n }\n });\n addMessageHandler(\"progress\", function (message) {\n if (message.type && message.message) {\n var handler = progressHandlers[message.type];\n if (handler) handler.call(this, message.message);\n }\n });\n addMessageHandler(\"notification\", function (message) {\n if (message.type === \"show\") Shiny.notifications.show(message.message);else if (message.type === \"remove\") Shiny.notifications.remove(message.message);else throw \"Unkown notification type: \" + message.type;\n });\n addMessageHandler(\"modal\", function (message) {\n if (message.type === \"show\") Shiny.modal.show(message.message);else if (message.type === \"remove\") Shiny.modal.remove(); // For 'remove', message content isn't used\n else throw \"Unkown modal type: \" + message.type;\n });\n addMessageHandler(\"response\", function (message) {\n var requestId = message.tag;\n var request = this.$activeRequests[requestId];\n\n if (request) {\n delete this.$activeRequests[requestId];\n if (\"value\" in message) request.onSuccess(message.value);else request.onError(message.error);\n }\n });\n addMessageHandler(\"allowReconnect\", function (message) {\n if (message === true || message === false || message === \"force\") {\n this.$allowReconnect = message;\n } else {\n throw \"Invalid value for allowReconnect: \" + message;\n }\n });\n addMessageHandler(\"custom\", function (message) {\n // For old-style custom messages - should deprecate and migrate to new\n // method\n if (Shiny.oncustommessage) {\n Shiny.oncustommessage(message);\n } // Send messages.foo and messages.bar to appropriate handlers\n\n\n this._sendMessagesToHandlers(message, customMessageHandlers, customMessageHandlerOrder);\n });\n addMessageHandler(\"config\", function (message) {\n this.config = {\n workerId: message.workerId,\n sessionId: message.sessionId\n };\n if (message.user) Shiny.user = message.user;\n $(document).trigger(\"shiny:sessioninitialized\");\n });\n addMessageHandler(\"busy\", function (message) {\n if (message === \"busy\") {\n $(document.documentElement).addClass(\"shiny-busy\");\n $(document).trigger(\"shiny:busy\");\n } else if (message === \"idle\") {\n $(document.documentElement).removeClass(\"shiny-busy\");\n $(document).trigger(\"shiny:idle\");\n }\n });\n addMessageHandler(\"recalculating\", function (message) {\n if (message.hasOwnProperty(\"name\") && message.hasOwnProperty(\"status\")) {\n var binding = this.$bindings[message.name];\n $(binding ? binding.el : null).trigger({\n type: \"shiny:\" + message.status\n });\n }\n });\n addMessageHandler(\"reload\", function (message) {\n window.location.reload();\n });\n addMessageHandler(\"shiny-insert-ui\", function (message) {\n var targets = $(message.selector);\n\n if (targets.length === 0) {\n // render the HTML and deps to a null target, so\n // the side-effect of rendering the deps, singletons,\n // and still occur\n console.warn('The selector you chose (\"' + message.selector + '\") could not be found in the DOM.');\n Shiny.renderHtml(message.content.html, $([]), message.content.deps);\n } else {\n targets.each(function (i, target) {\n Shiny.renderContent(target, message.content, message.where);\n return message.multiple;\n });\n }\n });\n addMessageHandler(\"shiny-remove-ui\", function (message) {\n var els = $(message.selector);\n els.each(function (i, el) {\n Shiny.unbindAll(el, true);\n $(el).remove(); // If `multiple` is false, returning false terminates the function\n // and no other elements are removed; if `multiple` is true,\n // returning true continues removing all remaining elements.\n\n return message.multiple;\n });\n });\n addMessageHandler(\"frozen\", function (message) {\n for (var i = 0; i < message.ids.length; i++) {\n Shiny.forgetLastInputValue(message.ids[i]);\n }\n });\n\n function getTabset(id) {\n var $tabset = $(\"#\" + $escape(id));\n if ($tabset.length === 0) throw \"There is no tabsetPanel (or navbarPage or navlistPanel) \" + \"with id equal to '\" + id + \"'\";\n return $tabset;\n }\n\n function getTabContent($tabset) {\n var tabsetId = $tabset.attr(\"data-tabsetid\");\n var $tabContent = $(\"div.tab-content[data-tabsetid='\" + $escape(tabsetId) + \"']\");\n return $tabContent;\n }\n\n function getTargetTabs($tabset, $tabContent, target) {\n var dataValue = \"[data-value='\" + $escape(target) + \"']\";\n var $aTag = $tabset.find(\"a\" + dataValue);\n var $liTag = $aTag.parent(\"li\"); // BS3 dropdown anchors are wrapped in
  • , but they can't be in BS4\n\n if ($liTag.length === 0) $liTag = $aTag;\n\n if ($liTag.length === 0) {\n throw \"There is no tabPanel (or navbarMenu) with value\" + \" (or menuName) equal to '\" + target + \"'\";\n }\n\n var $liTags = [];\n var $divTags = [];\n\n if ($aTag.attr(\"data-toggle\") === \"dropdown\") {\n // dropdown\n var $dropdownTabset = $aTag.find(\"+ ul.dropdown-menu\");\n var dropdownId = $dropdownTabset.attr(\"data-tabsetid\");\n var $dropdownLiTags = $dropdownTabset.find(\"a[data-toggle='tab']\"); // BS3 dropdown anchors are wrapped in
  • , but they can't be in BS4\n\n if ($dropdownLiTags.parent(\"li\").length > 0) {\n $dropdownLiTags = $dropdownLiTags.parent(\"li\");\n }\n\n $dropdownLiTags.each(function (i, el) {\n $liTags.push($(el));\n });\n var selector = \"div.tab-pane[id^='tab-\" + $escape(dropdownId) + \"']\";\n var $dropdownDivs = $tabContent.find(selector);\n $dropdownDivs.each(function (i, el) {\n $divTags.push($(el));\n });\n } else {\n // regular tab\n $divTags.push($tabContent.find(\"div\" + dataValue));\n }\n\n return {\n $liTag: $liTag,\n $liTags: $liTags,\n $divTags: $divTags\n };\n }\n\n addMessageHandler(\"shiny-insert-tab\", function (message) {\n var $parentTabset = getTabset(message.inputId);\n var $tabset = $parentTabset;\n var $tabContent = getTabContent($tabset);\n var tabsetId = $parentTabset.attr(\"data-tabsetid\");\n var $divTag = $(message.divTag.html);\n var $liTag = $(message.liTag.html);\n var $aTag = $liTag.find(\"> a\"); // Unless the item is being prepended/appended, the target tab\n // must be provided\n\n var target = null;\n var $targetLiTag = null;\n\n if (message.target !== null) {\n target = getTargetTabs($tabset, $tabContent, message.target);\n $targetLiTag = target.$liTag; // If the target is a (BS4) .dropdown-item, then we can't insert\n //
  • ,\n // instead, we need ...\n\n if ($targetLiTag.hasClass(\"dropdown-item\")) {\n $liTag = $aTag.removeClass(\"nav-link\").addClass(\"dropdown-item\");\n }\n } // If the item is to be placed inside a navbarMenu (dropdown),\n // change the value of $tabset from the parent's ul tag to the\n // dropdown's ul tag\n\n\n var dropdown = getDropdown();\n\n if (dropdown !== null) {\n if ($aTag.attr(\"data-toggle\") === \"dropdown\") throw \"Cannot insert a navbarMenu inside another one\";\n $tabset = dropdown.$tabset;\n tabsetId = dropdown.id;\n } // For regular tab items, fix the href (of the li > a tag)\n // and the id (of the div tag). This does not apply to plain\n // text items (which function as dividers and headers inside\n // navbarMenus) and whole navbarMenus (since those get\n // constructed from scratch on the R side and therefore\n // there are no ids that need matching)\n\n\n if ($aTag.attr(\"data-toggle\") === \"tab\") {\n var index = getTabIndex($tabset, tabsetId);\n var tabId = \"tab-\" + tabsetId + \"-\" + index;\n var anchor = $liTag.find(\"> a\"); // BS3 dropdown anchors are wrapped in
  • , but they can't be in BS4\n\n if (anchor.length === 0) anchor = $liTag;\n anchor.attr(\"href\", \"#\" + tabId);\n $divTag.attr(\"id\", tabId);\n } // actually insert the item into the right place\n\n\n if (message.position === \"before\") {\n if ($targetLiTag) {\n $targetLiTag.before($liTag);\n } else {\n $tabset.append($liTag);\n }\n } else if (message.position === \"after\") {\n if ($targetLiTag) {\n $targetLiTag.after($liTag);\n } else {\n $tabset.prepend($liTag);\n }\n }\n\n Shiny.renderContent($liTag[0], {\n html: $liTag.html(),\n deps: message.liTag.deps\n }); // jcheng 2017-07-28: This next part might look a little insane versus the\n // more obvious `$tabContent.append($divTag);`, but there's a method to the\n // madness.\n //\n // 1) We need to load the dependencies, and this needs to happen before\n // any scripts in $divTag get a chance to run.\n // 2) The scripts in $divTag need to run only once.\n // 3) The contents of $divTag need to be sent through renderContent so that\n // singletons may be registered and/or obeyed, and so that inputs/outputs\n // may be bound.\n //\n // Add to these constraints these facts:\n //\n // A) The (non-jQuery) DOM manipulation functions don't cause scripts to\n // run, but the jQuery functions all do.\n // B) renderContent must be called on an element that's attached to the\n // document.\n // C) $divTag may be of length > 1 (e.g. navbarMenu). I also noticed text\n // elements consisting of just \"\\n\" being included in the nodeset of\n // $divTag.\n // D) renderContent has a bug where only position \"replace\" (the default)\n // uses the jQuery functions, so other positions like \"beforeend\" will\n // prevent child script tags from running.\n //\n // In theory the same problem exists for $liTag but since that content is\n // much less likely to include arbitrary scripts, we're skipping it.\n //\n // This code could be nicer if we didn't use renderContent, but rather the\n // lower-level functions that renderContent uses. Like if we pre-process\n // the value of message.divTag.html for singletons, we could do that, then\n // render dependencies, then do $tabContent.append($divTag).\n\n Shiny.renderContent($tabContent[0], {\n html: \"\",\n deps: message.divTag.deps\n }, \"beforeend\");\n $divTag.get().forEach(function (el) {\n // Must not use jQuery for appending el to the doc, we don't want any\n // scripts to run (since they will run when renderContent takes a crack).\n $tabContent[0].appendChild(el); // If `el` itself is a script tag, this approach won't work (the script\n // won't be run), since we're only sending innerHTML through renderContent\n // and not the whole tag. That's fine in this case because we control the\n // R code that generates this HTML, and we know that the element is not\n // a script tag.\n\n Shiny.renderContent(el, el.innerHTML || el.textContent);\n });\n\n if (message.select) {\n $liTag.find(\"a\").tab(\"show\");\n }\n /* Barbara -- August 2017\n Note: until now, the number of tabs in a tabsetPanel (or navbarPage\n or navlistPanel) was always fixed. So, an easy way to give an id to\n a tab was simply incrementing a counter. (Just like it was easy to\n give a random 4-digit number to identify the tabsetPanel). Now that\n we're introducing dynamic tabs, we must retrieve these numbers and\n fix the dummy id given to the tab in the R side -- there, we always\n set the tab id (counter dummy) to \"id\" and the tabset id to \"tsid\")\n */\n\n\n function getTabIndex($tabset, tabsetId) {\n // The 0 is to ensure this works for empty tabsetPanels as well\n var existingTabIds = [0]; // loop through all existing tabs, find the one with highest id\n // (since this is based on a numeric counter), and increment\n\n $tabset.find(\"a[data-toggle='tab']\").each(function () {\n var $tab = $(this);\n\n if ($tab.length > 0) {\n // remove leading url if it exists. (copy of bootstrap url stripper)\n var href = $tab.attr(\"href\").replace(/.*(?=#[^\\s]+$)/, \"\"); // remove tab id to get the index\n\n var _index = href.replace(\"#tab-\" + tabsetId + \"-\", \"\");\n\n existingTabIds.push(Number(_index));\n }\n });\n return Math.max.apply(null, existingTabIds) + 1;\n } // Finds out if the item will be placed inside a navbarMenu\n // (dropdown). If so, returns the dropdown tabset (ul tag)\n // and the dropdown tabsetid (to be used to fix the tab ID)\n\n\n function getDropdown() {\n if (message.menuName !== null) {\n // menuName is only provided if the user wants to prepend\n // or append an item inside a navbarMenu (dropdown)\n var $dropdownATag = $(\"a.dropdown-toggle[data-value='\" + $escape(message.menuName) + \"']\");\n\n if ($dropdownATag.length === 0) {\n throw \"There is no navbarMenu with menuName equal to '\" + message.menuName + \"'\";\n }\n\n var $dropdownTabset = $dropdownATag.find(\"+ ul.dropdown-menu\");\n var dropdownId = $dropdownTabset.attr(\"data-tabsetid\");\n return {\n $tabset: $dropdownTabset,\n id: dropdownId\n };\n } else if (message.target !== null) {\n // if our item is to be placed next to a tab that is inside\n // a navbarMenu, our item will also be inside\n var $uncleTabset = $targetLiTag.parent(\"ul\");\n\n if ($uncleTabset.hasClass(\"dropdown-menu\")) {\n var uncleId = $uncleTabset.attr(\"data-tabsetid\");\n return {\n $tabset: $uncleTabset,\n id: uncleId\n };\n }\n }\n\n return null;\n }\n }); // If the given tabset has no active tabs, select the first one\n\n function ensureTabsetHasVisibleTab($tabset) {\n var inputBinding = $tabset.data(\"shiny-input-binding\"); // Use the getValue() method to avoid duplicating the CSS selector\n // for querying the DOM for the currently active tab\n\n if (!inputBinding.getValue($tabset)) {\n // Note: destTabValue may be null. We still want to proceed\n // through the below logic and setValue so that the input\n // value for the tabset gets updated (i.e. input$tabsetId\n // should be null if there are no tabs).\n var destTabValue = getFirstTab($tabset);\n var evt = jQuery.Event(\"shiny:updateinput\");\n evt.binding = inputBinding;\n $tabset.trigger(evt);\n inputBinding.setValue($tabset[0], destTabValue);\n }\n } // Given a tabset ul jquery object, return the value of the first tab\n // (in document order) that's visible and able to be selected.\n\n\n function getFirstTab($ul) {\n return $ul.find(\"li:visible a[data-toggle='tab']\").first().attr(\"data-value\") || null;\n }\n\n function tabApplyFunction(target, func) {\n var liTags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n $.each(target, function (key, el) {\n if (key === \"$liTag\") {\n // $liTag is always just one jQuery element\n func(el);\n } else if (key === \"$divTags\") {\n // $divTags is always an array (even if length = 1)\n $.each(el, function (i, div) {\n func(div);\n });\n } else if (liTags && key === \"$liTags\") {\n // $liTags is always an array (even if length = 0)\n $.each(el, function (i, div) {\n func(div);\n });\n }\n });\n }\n\n addMessageHandler(\"shiny-remove-tab\", function (message) {\n var $tabset = getTabset(message.inputId);\n var $tabContent = getTabContent($tabset);\n var target = getTargetTabs($tabset, $tabContent, message.target);\n tabApplyFunction(target, removeEl);\n ensureTabsetHasVisibleTab($tabset);\n\n function removeEl($el) {\n Shiny.unbindAll($el, true);\n $el.remove();\n }\n });\n addMessageHandler(\"shiny-change-tab-visibility\", function (message) {\n var $tabset = getTabset(message.inputId);\n var $tabContent = getTabContent($tabset);\n var target = getTargetTabs($tabset, $tabContent, message.target);\n tabApplyFunction(target, changeVisibility, true);\n ensureTabsetHasVisibleTab($tabset);\n\n function changeVisibility($el) {\n if (message.type === \"show\") $el.css(\"display\", \"\");else if (message.type === \"hide\") {\n $el.hide();\n $el.removeClass(\"active\");\n }\n }\n });\n addMessageHandler(\"updateQueryString\", function (message) {\n // leave the bookmarking code intact\n if (message.mode === \"replace\") {\n window.history.replaceState(null, null, message.queryString);\n return;\n }\n\n var what = null;\n if (message.queryString.charAt(0) === \"#\") what = \"hash\";else if (message.queryString.charAt(0) === \"?\") what = \"query\";else throw \"The 'query' string must start with either '?' \" + \"(to update the query string) or with '#' (to \" + \"update the hash).\";\n var path = window.location.pathname;\n var oldQS = window.location.search;\n var oldHash = window.location.hash;\n /* Barbara -- December 2016\n Note: we could check if the new QS and/or hash are different\n from the old one(s) and, if not, we could choose not to push\n a new state (whether or not we would replace it is moot/\n inconsequential). However, I think that it is better to\n interpret each call to `updateQueryString` as representing\n new state (even if the message.queryString is the same), so\n that check isn't even performed as of right now.\n */\n\n var relURL = path;\n if (what === \"query\") relURL += message.queryString;else relURL += oldQS + message.queryString; // leave old QS if it exists\n\n window.history.pushState(null, null, relURL); // for the case when message.queryString has both a query string\n // and a hash (`what = \"hash\"` allows us to trigger the\n // hashchange event)\n\n if (message.queryString.indexOf(\"#\") !== -1) what = \"hash\"; // for the case when there was a hash before, but there isn't\n // any hash now (e.g. for when only the query string is updated)\n\n if (window.location.hash !== oldHash) what = \"hash\"; // This event needs to be triggered manually because pushState() never\n // causes a hashchange event to be fired,\n\n if (what === \"hash\") $(document).trigger(\"hashchange\");\n });\n addMessageHandler(\"resetBrush\", function (message) {\n Shiny.resetBrush(message.brushId);\n }); // Progress reporting ====================================================\n\n var progressHandlers = {\n // Progress for a particular object\n binding: function binding(message) {\n var key = message.id;\n var binding = this.$bindings[key];\n\n if (binding) {\n $(binding.el).trigger({\n type: \"shiny:outputinvalidated\",\n binding: binding,\n name: key\n });\n if (binding.showProgress) binding.showProgress(true);\n }\n },\n // Open a page-level progress bar\n open: function open(message) {\n if (message.style === \"notification\") {\n // For new-style (starting in Shiny 0.14) progress indicators that use\n // the notification API.\n // Progress bar starts hidden; will be made visible if a value is provided\n // during updates.\n Shiny.notifications.show({\n html: \"
    \") + '
    ' + '
    ' + 'message ' + '' + \"
    \" + \"
    \",\n id: message.id,\n duration: null\n });\n } else if (message.style === \"old\") {\n // For old-style (Shiny <=0.13.2) progress indicators.\n // Add progress container (for all progress items) if not already present\n var $container = $(\".shiny-progress-container\");\n\n if ($container.length === 0) {\n $container = $('
    ');\n $(document.body).append($container);\n } // Add div for just this progress ID\n\n\n var depth = $(\".shiny-progress.open\").length; // The 'bar' class is needed for backward compatibility with Bootstrap 2.\n\n var $progress = $('
    ' + '
    ' + '
    ' + 'message' + '' + \"
    \" + \"
    \");\n $progress.attr(\"id\", message.id);\n $container.append($progress); // Stack bars\n\n var $progressBar = $progress.find(\".progress\");\n $progressBar.css(\"top\", depth * $progressBar.height() + \"px\"); // Stack text objects\n\n var $progressText = $progress.find(\".progress-text\");\n $progressText.css(\"top\", 3 * $progressBar.height() + depth * $progressText.outerHeight() + \"px\");\n $progress.hide();\n }\n },\n // Update page-level progress bar\n update: function update(message) {\n if (message.style === \"notification\") {\n // For new-style (starting in Shiny 0.14) progress indicators that use\n // the notification API.\n var $progress = $(\"#shiny-progress-\" + message.id);\n if ($progress.length === 0) return;\n\n if (typeof message.message !== \"undefined\") {\n $progress.find(\".progress-message\").text(message.message);\n }\n\n if (typeof message.detail !== \"undefined\") {\n $progress.find(\".progress-detail\").text(message.detail);\n }\n\n if (typeof message.value !== \"undefined\" && message.value !== null) {\n $progress.find(\".progress\").show();\n $progress.find(\".progress-bar\").width(message.value * 100 + \"%\");\n }\n } else if (message.style === \"old\") {\n // For old-style (Shiny <=0.13.2) progress indicators.\n var _$progress = $(\"#\" + message.id + \".shiny-progress\");\n\n if (typeof message.message !== \"undefined\") {\n _$progress.find(\".progress-message\").text(message.message);\n }\n\n if (typeof message.detail !== \"undefined\") {\n _$progress.find(\".progress-detail\").text(message.detail);\n }\n\n if (typeof message.value !== \"undefined\" && message.value !== null) {\n _$progress.find(\".progress\").show();\n\n _$progress.find(\".bar\").width(message.value * 100 + \"%\");\n }\n\n _$progress.fadeIn();\n }\n },\n // Close page-level progress bar\n close: function close(message) {\n if (message.style === \"notification\") {\n Shiny.notifications.remove(message.id);\n } else if (message.style === \"old\") {\n var $progress = $(\"#\" + message.id + \".shiny-progress\");\n $progress.removeClass(\"open\");\n $progress.fadeOut({\n complete: function complete() {\n $progress.remove(); // If this was the last shiny-progress, remove container\n\n if ($(\".shiny-progress\").length === 0) $(\".shiny-progress-container\").remove();\n }\n });\n }\n }\n };\n Shiny.progressHandlers = progressHandlers; // Returns a URL which can be queried to get values from inside the server\n // function. This is enabled with `options(shiny.testmode=TRUE)`.\n\n this.getTestSnapshotBaseUrl = function () {\n var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref2$fullUrl = _ref2.fullUrl,\n fullUrl = _ref2$fullUrl === void 0 ? true : _ref2$fullUrl;\n\n var loc = window.location;\n var url = \"\";\n\n if (fullUrl) {\n // Strip off everything after last slash in path, like dirname() in R\n url = loc.origin + loc.pathname.replace(/\\/[^/]*$/, \"\");\n }\n\n url += \"/session/\" + encodeURIComponent(this.config.sessionId) + \"/dataobj/shinytest?w=\" + encodeURIComponent(this.config.workerId) + \"&nonce=\" + randomId();\n return url;\n };\n }).call(ShinyApp.prototype);\n\n Shiny.showReconnectDialog = function () {\n var reconnectTime = null;\n\n function updateTime() {\n var $time = $(\"#shiny-reconnect-time\"); // If the time has been removed, exit and don't reschedule this function.\n\n if ($time.length === 0) return;\n var seconds = Math.floor((reconnectTime - new Date().getTime()) / 1000);\n\n if (seconds > 0) {\n $time.text(\" in \" + seconds + \"s\");\n } else {\n $time.text(\"...\");\n } // Reschedule this function after 1 second\n\n\n setTimeout(updateTime, 1000);\n }\n\n return function (delay) {\n reconnectTime = new Date().getTime() + delay; // If there's already a reconnect dialog, don't add another\n\n if ($(\"#shiny-reconnect-text\").length > 0) return;\n var html = 'Attempting to reconnect' + '';\n var action = 'Try now';\n Shiny.notifications.show({\n id: \"reconnect\",\n html: html,\n action: action,\n duration: null,\n closeButton: false,\n type: \"warning\"\n });\n updateTime();\n };\n }();\n\n Shiny.hideReconnectDialog = function () {\n Shiny.notifications.remove(\"reconnect\");\n }; // \"notifications.js\"\n\n\n Shiny.notifications = function () {\n // Milliseconds to fade in or out\n var fadeDuration = 250;\n\n function show() {\n var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref3$html = _ref3.html,\n html = _ref3$html === void 0 ? \"\" : _ref3$html,\n _ref3$action = _ref3.action,\n action = _ref3$action === void 0 ? \"\" : _ref3$action,\n _ref3$deps = _ref3.deps,\n deps = _ref3$deps === void 0 ? [] : _ref3$deps,\n _ref3$duration = _ref3.duration,\n duration = _ref3$duration === void 0 ? 5000 : _ref3$duration,\n _ref3$id = _ref3.id,\n id = _ref3$id === void 0 ? null : _ref3$id,\n _ref3$closeButton = _ref3.closeButton,\n closeButton = _ref3$closeButton === void 0 ? true : _ref3$closeButton,\n _ref3$type = _ref3.type,\n type = _ref3$type === void 0 ? null : _ref3$type;\n\n if (!id) id = randomId(); // Create panel if necessary\n\n _createPanel(); // Get existing DOM element for this ID, or create if needed.\n\n\n var $notification = _get(id);\n\n if ($notification.length === 0) $notification = _create(id); // Render html and dependencies\n\n var newHtml = \"
    \".concat(html, \"
    \") + \"
    \".concat(action, \"
    \");\n var $content = $notification.find(\".shiny-notification-content\");\n Shiny.renderContent($content, {\n html: newHtml,\n deps: deps\n }); // Remove any existing classes of the form 'shiny-notification-xxxx'.\n // The xxxx would be strings like 'warning'.\n\n var classes = $notification.attr(\"class\").split(/\\s+/).filter(function (cls) {\n return cls.match(/^shiny-notification-/);\n }).join(\" \");\n $notification.removeClass(classes); // Add class. 'default' means no additional CSS class.\n\n if (type && type !== \"default\") $notification.addClass(\"shiny-notification-\" + type); // Make sure that the presence/absence of close button matches with value\n // of `closeButton`.\n\n var $close = $notification.find(\".shiny-notification-close\");\n\n if (closeButton && $close.length === 0) {\n $notification.append('
    ×
    ');\n } else if (!closeButton && $close.length !== 0) {\n $close.remove();\n } // If duration was provided, schedule removal. If not, clear existing\n // removal callback (this happens if a message was first added with\n // a duration, and then updated with no duration).\n\n\n if (duration) _addRemovalCallback(id, duration);else _clearRemovalCallback(id);\n return id;\n }\n\n function remove(id) {\n _get(id).fadeOut(fadeDuration, function () {\n Shiny.unbindAll(this);\n $(this).remove(); // If no more notifications, remove the panel from the DOM.\n\n if (_ids().length === 0) {\n _getPanel().remove();\n }\n });\n } // Returns an individual notification DOM object (wrapped in jQuery).\n\n\n function _get(id) {\n if (!id) return null;\n return _getPanel().find(\"#shiny-notification-\" + $escape(id));\n } // Return array of all notification IDs\n\n\n function _ids() {\n return _getPanel().find(\".shiny-notification\").map(function () {\n return this.id.replace(/shiny-notification-/, \"\");\n }).get();\n } // Returns the notification panel DOM object (wrapped in jQuery).\n\n\n function _getPanel() {\n return $(\"#shiny-notification-panel\");\n } // Create notifications panel and return the jQuery object. If the DOM\n // element already exists, just return it.\n\n\n function _createPanel() {\n var $panel = _getPanel();\n\n if ($panel.length > 0) return $panel;\n $(document.body).append('
    ');\n return $panel;\n } // Create a notification DOM element and return the jQuery object. If the\n // DOM element already exists for the ID, just return it without creating.\n\n\n function _create(id) {\n var $notification = _get(id);\n\n if ($notification.length === 0) {\n $notification = $(\"
    \") + '
    ×
    ' + '
    ' + \"
    \");\n $notification.find(\".shiny-notification-close\").on(\"click\", function (e) {\n e.preventDefault();\n e.stopPropagation();\n remove(id);\n });\n\n _getPanel().append($notification);\n }\n\n return $notification;\n } // Add a callback to remove a notification after a delay in ms.\n\n\n function _addRemovalCallback(id, delay) {\n // If there's an existing removalCallback, clear it before adding the new\n // one.\n _clearRemovalCallback(id); // Attach new removal callback\n\n\n var removalCallback = setTimeout(function () {\n remove(id);\n }, delay);\n\n _get(id).data(\"removalCallback\", removalCallback);\n } // Clear a removal callback from a notification, if present.\n\n\n function _clearRemovalCallback(id) {\n var $notification = _get(id);\n\n var oldRemovalCallback = $notification.data(\"removalCallback\");\n\n if (oldRemovalCallback) {\n clearTimeout(oldRemovalCallback);\n }\n }\n\n return {\n show: show,\n remove: remove\n };\n }(); // \"modal.js\"\n\n\n Shiny.modal = {\n // Show a modal dialog. This is meant to handle two types of cases: one is\n // that the content is a Bootstrap modal dialog, and the other is that the\n // content is non-Bootstrap. Bootstrap modals require some special handling,\n // which is coded in here.\n show: function show() {\n var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref4$html = _ref4.html,\n html = _ref4$html === void 0 ? \"\" : _ref4$html,\n _ref4$deps = _ref4.deps,\n deps = _ref4$deps === void 0 ? [] : _ref4$deps;\n\n // If there was an existing Bootstrap modal, then there will be a modal-\n // backdrop div that was added outside of the modal wrapper, and it must be\n // removed; otherwise there can be multiple of these divs.\n $(\".modal-backdrop\").remove(); // Get existing wrapper DOM element, or create if needed.\n\n var $modal = $(\"#shiny-modal-wrapper\");\n\n if ($modal.length === 0) {\n $modal = $('
    ');\n $(document.body).append($modal); // If the wrapper's content is a Bootstrap modal, then when the inner\n // modal is hidden, remove the entire thing, including wrapper.\n\n $modal.on(\"hidden.bs.modal\", function (e) {\n if (e.target === $(\"#shiny-modal\")[0]) {\n Shiny.unbindAll($modal);\n $modal.remove();\n }\n });\n }\n\n $modal.on(\"keydown.shinymodal\", function (e) {\n // If we're listening for Esc, don't let the event propagate. See\n // https://github.com/rstudio/shiny/issues/1453. The value of\n // data(\"keyboard\") needs to be checked inside the handler, because at\n // the time that $modal.on() is called, the $(\"#shiny-modal\") div doesn't\n // yet exist.\n if ($(\"#shiny-modal\").data(\"keyboard\") === false) return;\n\n if (e.keyCode === 27) {\n e.stopPropagation();\n e.preventDefault();\n }\n }); // Set/replace contents of wrapper with html.\n\n Shiny.renderContent($modal, {\n html: html,\n deps: deps\n });\n },\n remove: function remove() {\n var $modal = $(\"#shiny-modal-wrapper\");\n $modal.off(\"keydown.shinymodal\"); // Look for a Bootstrap modal and if present, trigger hide event. This will\n // trigger the hidden.bs.modal callback that we set in show(), which unbinds\n // and removes the element.\n\n if ($modal.find(\".modal\").length > 0) {\n $modal.find(\".modal\").modal(\"hide\");\n } else {\n // If not a Bootstrap modal dialog, simply unbind and remove it.\n Shiny.unbindAll($modal);\n $modal.remove();\n }\n }\n }; // \"file_processor.js\"\n // \u221A\n // \"binding_registry.js\"\n\n var BindingRegistry = function BindingRegistry() {\n this.bindings = [];\n this.bindingNames = {};\n };\n\n (function () {\n this.register = function (binding, bindingName, priority) {\n var bindingObj = {\n binding: binding,\n priority: priority || 0\n };\n this.bindings.unshift(bindingObj);\n\n if (bindingName) {\n this.bindingNames[bindingName] = bindingObj;\n binding.name = bindingName;\n }\n };\n\n this.setPriority = function (bindingName, priority) {\n var bindingObj = this.bindingNames[bindingName];\n if (!bindingObj) throw \"Tried to set priority on unknown binding \" + bindingName;\n bindingObj.priority = priority || 0;\n };\n\n this.getPriority = function (bindingName) {\n var bindingObj = this.bindingNames[bindingName];\n if (!bindingObj) return false;\n return bindingObj.priority;\n };\n\n this.getBindings = function () {\n // Sort the bindings. The ones with higher priority are consulted\n // first; ties are broken by most-recently-registered.\n return mergeSort(this.bindings, function (a, b) {\n return b.priority - a.priority;\n });\n };\n }).call(BindingRegistry.prototype);\n var inputBindings = Shiny.inputBindings = new BindingRegistry();\n var outputBindings = Shiny.outputBindings = new BindingRegistry(); // \"output_binding.js\"\n\n var OutputBinding = Shiny.OutputBinding = function () {};\n\n (function () {\n // Returns a jQuery object or element array that contains the\n // descendants of scope that match this binding\n this.find = function (scope) {\n throw \"Not implemented\";\n };\n\n this.getId = function (el) {\n return el[\"data-input-id\"] || el.id;\n };\n\n this.onValueChange = function (el, data) {\n this.clearError(el);\n this.renderValue(el, data);\n };\n\n this.onValueError = function (el, err) {\n this.renderError(el, err);\n };\n\n this.renderError = function (el, err) {\n this.clearError(el);\n\n if (err.message === \"\") {\n // not really error, but we just need to wait (e.g. action buttons)\n $(el).empty();\n return;\n }\n\n var errClass = \"shiny-output-error\";\n\n if (err.type !== null) {\n // use the classes of the error condition as CSS class names\n errClass = errClass + \" \" + $.map(asArray(err.type), function (type) {\n return errClass + \"-\" + type;\n }).join(\" \");\n }\n\n $(el).addClass(errClass).text(err.message);\n };\n\n this.clearError = function (el) {\n $(el).attr(\"class\", function (i, c) {\n return c.replace(/(^|\\s)shiny-output-error\\S*/g, \"\");\n });\n };\n\n this.showProgress = function (el, show) {\n var RECALC_CLASS = \"recalculating\";\n if (show) $(el).addClass(RECALC_CLASS);else $(el).removeClass(RECALC_CLASS);\n };\n }).call(OutputBinding.prototype); // \"output_binding_text.js\"\n\n var textOutputBinding = new OutputBinding();\n $.extend(textOutputBinding, {\n find: function find(scope) {\n return $(scope).find(\".shiny-text-output\");\n },\n renderValue: function renderValue(el, data) {\n $(el).text(data);\n }\n });\n outputBindings.register(textOutputBinding, \"shiny.textOutput\"); // \"output_binding_image.js\"\n\n var imageOutputBinding = new OutputBinding();\n $.extend(imageOutputBinding, {\n find: function find(scope) {\n return $(scope).find(\".shiny-image-output, .shiny-plot-output\");\n },\n renderValue: function renderValue(el, data) {\n // The overall strategy:\n // * Clear out existing image and event handlers.\n // * Create new image.\n // * Create various event handlers.\n // * Bind those event handlers to events.\n // * Insert the new image.\n var outputId = this.getId(el);\n var $el = $(el);\n var img; // Get existing img element if present.\n\n var $img = $el.find(\"img\");\n\n if ($img.length === 0) {\n // If a img element is not already present, that means this is either\n // the first time renderValue() has been called, or this is after an\n // error.\n img = document.createElement(\"img\");\n $el.append(img);\n $img = $(img);\n } else {\n // Trigger custom 'reset' event for any existing images in the div\n img = $img[0];\n $img.trigger(\"reset\");\n }\n\n if (!data) {\n $el.empty();\n return;\n } // If value is undefined, return alternate. Sort of like ||, except it won't\n // return alternate for other falsy values (0, false, null).\n\n\n function OR(value, alternate) {\n if (value === undefined) return alternate;\n return value;\n }\n\n var opts = {\n clickId: $el.data(\"click-id\"),\n clickClip: OR(strToBool($el.data(\"click-clip\")), true),\n dblclickId: $el.data(\"dblclick-id\"),\n dblclickClip: OR(strToBool($el.data(\"dblclick-clip\")), true),\n dblclickDelay: OR($el.data(\"dblclick-delay\"), 400),\n hoverId: $el.data(\"hover-id\"),\n hoverClip: OR(strToBool($el.data(\"hover-clip\")), true),\n hoverDelayType: OR($el.data(\"hover-delay-type\"), \"debounce\"),\n hoverDelay: OR($el.data(\"hover-delay\"), 300),\n hoverNullOutside: OR(strToBool($el.data(\"hover-null-outside\")), false),\n brushId: $el.data(\"brush-id\"),\n brushClip: OR(strToBool($el.data(\"brush-clip\")), true),\n brushDelayType: OR($el.data(\"brush-delay-type\"), \"debounce\"),\n brushDelay: OR($el.data(\"brush-delay\"), 300),\n brushFill: OR($el.data(\"brush-fill\"), \"#666\"),\n brushStroke: OR($el.data(\"brush-stroke\"), \"#000\"),\n brushOpacity: OR($el.data(\"brush-opacity\"), 0.3),\n brushDirection: OR($el.data(\"brush-direction\"), \"xy\"),\n brushResetOnNew: OR(strToBool($el.data(\"brush-reset-on-new\")), false),\n coordmap: data.coordmap\n };\n\n if (opts.brushFill === \"auto\") {\n opts.brushFill = getComputedLinkColor($el[0]);\n }\n\n if (opts.brushStroke === \"auto\") {\n opts.brushStroke = getStyle($el[0], \"color\");\n } // Copy items from data to img. Don't set the coordmap as an attribute.\n\n\n $.each(data, function (key, value) {\n if (value === null || key === \"coordmap\") {\n return;\n } // this checks only against base64 encoded src values\n // images put here are only from renderImage and renderPlot\n\n\n if (key === \"src\" && value === img.getAttribute(\"src\")) {\n // Ensure the browser actually fires an onLoad event, which doesn't\n // happen on WebKit if the value we set on src is the same as the\n // value it already has\n // https://github.com/rstudio/shiny/issues/2197\n // https://stackoverflow.com/questions/5024111/javascript-image-onload-doesnt-fire-in-webkit-if-loading-same-image\n img.removeAttribute(\"src\");\n }\n\n img.setAttribute(key, value);\n }); // Unset any attributes in the current img that were not provided in the\n // new data.\n\n for (var i = 0; i < img.attributes.length; i++) {\n var attrib = img.attributes[i]; // Need to check attrib.specified on IE because img.attributes contains\n // all possible attributes on IE.\n\n if (attrib.specified && !data.hasOwnProperty(attrib.name)) {\n img.removeAttribute(attrib.name);\n }\n }\n\n if (!opts.coordmap) {\n opts.coordmap = {\n panels: [],\n dims: {\n // These values be set to the naturalWidth and naturalHeight once the image has loaded\n height: null,\n width: null\n }\n };\n } // Remove event handlers that were added in previous runs of this function.\n\n\n $el.off(\".image_output\");\n $img.off(\".image_output\"); // When the image loads, initialize all the interaction handlers. When the\n // value of src is set, the browser may not load the image immediately,\n // even if it's a data URL. If we try to initialize this stuff\n // immediately, it can cause problems because we use we need the raw image\n // height and width\n\n $img.off(\"load.shiny_image_interaction\");\n $img.one(\"load.shiny_image_interaction\", function () {\n imageutils.initCoordmap($el, opts.coordmap); // This object listens for mousedowns, and triggers mousedown2 and dblclick2\n // events as appropriate.\n\n var clickInfo = imageutils.createClickInfo($el, opts.dblclickId, opts.dblclickDelay);\n $el.on(\"mousedown.image_output\", clickInfo.mousedown);\n\n if (isIE() && IEVersion() === 8) {\n $el.on(\"dblclick.image_output\", clickInfo.dblclickIE8);\n } // ----------------------------------------------------------\n // Register the various event handlers\n // ----------------------------------------------------------\n\n\n if (opts.clickId) {\n imageutils.disableDrag($el, $img);\n var clickHandler = imageutils.createClickHandler(opts.clickId, opts.clickClip, opts.coordmap);\n $el.on(\"mousedown2.image_output\", clickHandler.mousedown);\n $el.on(\"resize.image_output\", clickHandler.onResize); // When img is reset, do housekeeping: clear $el's mouse listener and\n // call the handler's onResetImg callback.\n\n $img.on(\"reset.image_output\", clickHandler.onResetImg);\n }\n\n if (opts.dblclickId) {\n imageutils.disableDrag($el, $img); // We'll use the clickHandler's mousedown function, but register it to\n // our custom 'dblclick2' event.\n\n var dblclickHandler = imageutils.createClickHandler(opts.dblclickId, opts.clickClip, opts.coordmap);\n $el.on(\"dblclick2.image_output\", dblclickHandler.mousedown);\n $el.on(\"resize.image_output\", dblclickHandler.onResize);\n $img.on(\"reset.image_output\", dblclickHandler.onResetImg);\n }\n\n if (opts.hoverId) {\n imageutils.disableDrag($el, $img);\n var hoverHandler = imageutils.createHoverHandler(opts.hoverId, opts.hoverDelay, opts.hoverDelayType, opts.hoverClip, opts.hoverNullOutside, opts.coordmap);\n $el.on(\"mousemove.image_output\", hoverHandler.mousemove);\n $el.on(\"mouseout.image_output\", hoverHandler.mouseout);\n $el.on(\"resize.image_output\", hoverHandler.onResize);\n $img.on(\"reset.image_output\", hoverHandler.onResetImg);\n }\n\n if (opts.brushId) {\n imageutils.disableDrag($el, $img);\n var brushHandler = imageutils.createBrushHandler(opts.brushId, $el, opts, opts.coordmap, outputId);\n $el.on(\"mousedown.image_output\", brushHandler.mousedown);\n $el.on(\"mousemove.image_output\", brushHandler.mousemove);\n $el.on(\"resize.image_output\", brushHandler.onResize);\n $img.on(\"reset.image_output\", brushHandler.onResetImg);\n }\n\n if (opts.clickId || opts.dblclickId || opts.hoverId || opts.brushId) {\n $el.addClass(\"crosshair\");\n }\n\n if (data.error) console.log(\"Error on server extracting coordmap: \" + data.error);\n });\n },\n renderError: function renderError(el, err) {\n $(el).find(\"img\").trigger(\"reset\");\n OutputBinding.prototype.renderError.call(this, el, err);\n },\n clearError: function clearError(el) {\n // Remove all elements except img and the brush; this is usually just\n // error messages.\n $(el).contents().filter(function () {\n return this.tagName !== \"IMG\" && this.id !== el.id + \"_brush\";\n }).remove();\n OutputBinding.prototype.clearError.call(this, el);\n },\n resize: function resize(el, width, height) {\n $(el).find(\"img\").trigger(\"resize\");\n }\n });\n outputBindings.register(imageOutputBinding, \"shiny.imageOutput\");\n var imageutils = {};\n\n imageutils.disableDrag = function ($el, $img) {\n // Make image non-draggable (Chrome, Safari)\n $img.css(\"-webkit-user-drag\", \"none\"); // Firefox, IE<=10\n // First remove existing handler so we don't keep adding handlers.\n\n $img.off(\"dragstart.image_output\");\n $img.on(\"dragstart.image_output\", function () {\n return false;\n }); // Disable selection of image and text when dragging in IE<=10\n\n $el.off(\"selectstart.image_output\");\n $el.on(\"selectstart.image_output\", function () {\n return false;\n });\n }; // Modifies the panel objects in a coordmap, adding scaleImgToData(),\n // scaleDataToImg(), and clipImg() functions to each one. The panel objects\n // use img and data coordinates only; they do not use css coordinates. The\n // domain is in data coordinates; the range is in img coordinates.\n\n\n imageutils.initPanelScales = function (panels) {\n // Map a value x from a domain to a range. If clip is true, clip it to the\n // range.\n function mapLinear(x, domainMin, domainMax, rangeMin, rangeMax, clip) {\n // By default, clip to range\n clip = clip || true;\n var factor = (rangeMax - rangeMin) / (domainMax - domainMin);\n var val = x - domainMin;\n var newval = val * factor + rangeMin;\n\n if (clip) {\n var max = Math.max(rangeMax, rangeMin);\n var min = Math.min(rangeMax, rangeMin);\n if (newval > max) newval = max;else if (newval < min) newval = min;\n }\n\n return newval;\n } // Create scale and inverse-scale functions for a single direction (x or y).\n\n\n function scaler1D(domainMin, domainMax, rangeMin, rangeMax, logbase) {\n return {\n scale: function scale(val, clip) {\n if (logbase) val = Math.log(val) / Math.log(logbase);\n return mapLinear(val, domainMin, domainMax, rangeMin, rangeMax, clip);\n },\n scaleInv: function scaleInv(val, clip) {\n var res = mapLinear(val, rangeMin, rangeMax, domainMin, domainMax, clip);\n if (logbase) res = Math.pow(logbase, res);\n return res;\n }\n };\n } // Modify panel, adding scale and inverse-scale functions that take objects\n // like {x:1, y:3}, and also add clip function.\n\n\n function addScaleFuns(panel) {\n var d = panel.domain;\n var r = panel.range;\n var xlog = panel.log && panel.log.x ? panel.log.x : null;\n var ylog = panel.log && panel.log.y ? panel.log.y : null;\n var xscaler = scaler1D(d.left, d.right, r.left, r.right, xlog);\n var yscaler = scaler1D(d.bottom, d.top, r.bottom, r.top, ylog); // Given an object of form {x:1, y:2}, or {x:1, xmin:2:, ymax: 3}, convert\n // from data coordinates to img. Whether a value is converted as x or y\n // depends on the first character of the key.\n\n panel.scaleDataToImg = function (val, clip) {\n return mapValues(val, function (value, key) {\n var prefix = key.substring(0, 1);\n\n if (prefix === \"x\") {\n return xscaler.scale(value, clip);\n } else if (prefix === \"y\") {\n return yscaler.scale(value, clip);\n }\n\n return null;\n });\n };\n\n panel.scaleImgToData = function (val, clip) {\n return mapValues(val, function (value, key) {\n var prefix = key.substring(0, 1);\n\n if (prefix === \"x\") {\n return xscaler.scaleInv(value, clip);\n } else if (prefix === \"y\") {\n return yscaler.scaleInv(value, clip);\n }\n\n return null;\n });\n }; // Given a scaled offset (in img pixels), clip it to the nearest panel region.\n\n\n panel.clipImg = function (offset_img) {\n var newOffset = {\n x: offset_img.x,\n y: offset_img.y\n };\n var bounds = panel.range;\n if (offset_img.x > bounds.right) newOffset.x = bounds.right;else if (offset_img.x < bounds.left) newOffset.x = bounds.left;\n if (offset_img.y > bounds.bottom) newOffset.y = bounds.bottom;else if (offset_img.y < bounds.top) newOffset.y = bounds.top;\n return newOffset;\n };\n } // Add the functions to each panel object.\n\n\n for (var i = 0; i < panels.length; i++) {\n var panel = panels[i];\n addScaleFuns(panel);\n }\n }; // This adds functions to the coordmap object to handle various\n // coordinate-mapping tasks, and send information to the server. The input\n // coordmap is an array of objects, each of which represents a panel. coordmap\n // must be an array, even if empty, so that it can be modified in place; when\n // empty, we add a dummy panel to the array. It also calls initPanelScales,\n // which modifies each panel object to have scaleImgToData, scaleDataToImg,\n // and clip functions.\n //\n // There are three coordinate spaces which we need to translate between:\n //\n // 1. css: The pixel coordinates in the web browser, also known as CSS pixels.\n // The origin is the upper-left corner of the (not including padding\n // and border).\n // 2. img: The pixel coordinates of the image data. A common case is on a\n // HiDPI device, where the source PNG image could be 1000 pixels wide but\n // be displayed in 500 CSS pixels. Another case is when the image has\n // additional scaling due to CSS transforms or width.\n // 3. data: The coordinates in the data space. This is a bit more complicated\n // than the other two, because there can be multiple panels (as in facets).\n\n\n imageutils.initCoordmap = function ($el, coordmap) {\n var $img = $el.find(\"img\");\n var img = $img[0]; // If we didn't get any panels, create a dummy one where the domain and range\n // are simply the pixel dimensions.\n // that we modify.\n\n if (coordmap.panels.length === 0) {\n var bounds = {\n top: 0,\n left: 0,\n right: img.clientWidth - 1,\n bottom: img.clientHeight - 1\n };\n coordmap.panels[0] = {\n domain: bounds,\n range: bounds,\n mapping: {}\n };\n } // If no dim height and width values are found, set them to the raw image height and width\n // These values should be the same...\n // This is only done to initialize an image output, whose height and width are unknown until the image is retrieved\n\n\n coordmap.dims.height = coordmap.dims.height || img.naturalHeight;\n coordmap.dims.width = coordmap.dims.width || img.naturalWidth; // Add scaling functions to each panel\n\n imageutils.initPanelScales(coordmap.panels); // This returns the offset of the mouse in CSS pixels relative to the img,\n // but not including the padding or border, if present.\n\n coordmap.mouseOffsetCss = function (mouseEvent) {\n var img_origin = findOrigin($img); // The offset of the mouse from the upper-left corner of the img, in\n // pixels.\n\n return {\n x: mouseEvent.pageX - img_origin.x,\n y: mouseEvent.pageY - img_origin.y\n };\n }; // Given an offset in an img in CSS pixels, return the corresponding offset\n // in source image pixels. The offset_css can have properties like \"x\",\n // \"xmin\", \"y\", and \"ymax\" -- anything that starts with \"x\" and \"y\". If the\n // img content is 1000 pixels wide, but is scaled to 400 pixels on screen,\n // and the input is x:400, then this will return x:1000.\n\n\n coordmap.scaleCssToImg = function (offset_css) {\n var pixel_scaling = coordmap.imgToCssScalingRatio();\n var result = mapValues(offset_css, function (value, key) {\n var prefix = key.substring(0, 1);\n\n if (prefix === \"x\") {\n return offset_css[key] / pixel_scaling.x;\n } else if (prefix === \"y\") {\n return offset_css[key] / pixel_scaling.y;\n }\n\n return null;\n });\n return result;\n }; // Given an offset in an img, in source image pixels, return the\n // corresponding offset in CSS pixels. If the img content is 1000 pixels\n // wide, but is scaled to 400 pixels on screen, and the input is x:1000,\n // then this will return x:400.\n\n\n coordmap.scaleImgToCss = function (offset_img) {\n var pixel_scaling = coordmap.imgToCssScalingRatio();\n var result = mapValues(offset_img, function (value, key) {\n var prefix = key.substring(0, 1);\n\n if (prefix === \"x\") {\n return offset_img[key] * pixel_scaling.x;\n } else if (prefix === \"y\") {\n return offset_img[key] * pixel_scaling.y;\n }\n\n return null;\n });\n return result;\n }; // Returns the x and y ratio the image content is scaled to on screen. If\n // the image data is 1000 pixels wide and is scaled to 300 pixels on screen,\n // then this returns 0.3. (Note the 300 pixels refers to CSS pixels.)\n\n\n coordmap.imgToCssScalingRatio = function () {\n var img_dims = findDims($img);\n return {\n x: img_dims.x / coordmap.dims.width,\n y: img_dims.y / coordmap.dims.height\n };\n };\n\n coordmap.cssToImgScalingRatio = function () {\n var res = coordmap.imgToCssScalingRatio();\n return {\n x: 1 / res.x,\n y: 1 / res.y\n };\n }; // Given an offset in css pixels, return an object representing which panel\n // it's in. The `expand` argument tells it to expand the panel area by that\n // many pixels. It's possible for an offset to be within more than one\n // panel, because of the `expand` value. If that's the case, find the\n // nearest panel.\n\n\n coordmap.getPanelCss = function (offset_css) {\n var expand = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n var offset_img = coordmap.scaleCssToImg(offset_css);\n var x = offset_img.x;\n var y = offset_img.y; // Convert expand from css pixels to img pixels\n\n var cssToImgRatio = coordmap.cssToImgScalingRatio();\n var expand_img = {\n x: expand * cssToImgRatio.x,\n y: expand * cssToImgRatio.y\n };\n var matches = []; // Panels that match\n\n var dists = []; // Distance of offset to each matching panel\n\n var b;\n var i;\n\n for (i = 0; i < coordmap.panels.length; i++) {\n b = coordmap.panels[i].range;\n\n if (x <= b.right + expand_img.x && x >= b.left - expand_img.x && y <= b.bottom + expand_img.y && y >= b.top - expand_img.y) {\n matches.push(coordmap.panels[i]); // Find distance from edges for x and y\n\n var xdist = 0;\n var ydist = 0;\n\n if (x > b.right && x <= b.right + expand_img.x) {\n xdist = x - b.right;\n } else if (x < b.left && x >= b.left - expand_img.x) {\n xdist = x - b.left;\n }\n\n if (y > b.bottom && y <= b.bottom + expand_img.y) {\n ydist = y - b.bottom;\n } else if (y < b.top && y >= b.top - expand_img.y) {\n ydist = y - b.top;\n } // Cartesian distance\n\n\n dists.push(Math.sqrt(Math.pow(xdist, 2) + Math.pow(ydist, 2)));\n }\n }\n\n if (matches.length) {\n // Find shortest distance\n var min_dist = Math.min.apply(null, dists);\n\n for (i = 0; i < matches.length; i++) {\n if (dists[i] === min_dist) {\n return matches[i];\n }\n }\n }\n\n return null;\n }; // Is an offset (in css pixels) in a panel? If supplied, `expand` tells us\n // to expand the panels by that many pixels in all directions.\n\n\n coordmap.isInPanelCss = function (offset_css) {\n var expand = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n if (coordmap.getPanelCss(offset_css, expand)) return true;\n return false;\n }; // Returns a function that sends mouse coordinates, scaled to data space.\n // If that function is passed a null event, it will send null.\n\n\n coordmap.mouseCoordinateSender = function (inputId, clip, nullOutside) {\n if (clip === undefined) clip = true;\n if (nullOutside === undefined) nullOutside = false;\n return function (e) {\n if (e === null) {\n Shiny.setInputValue(inputId, null);\n return;\n }\n\n var coords = {};\n var coords_css = coordmap.mouseOffsetCss(e); // If outside of plotting region\n\n if (!coordmap.isInPanelCss(coords_css)) {\n if (nullOutside) {\n Shiny.setInputValue(inputId, null);\n return;\n }\n\n if (clip) return;\n coords.coords_css = coords_css;\n coords.coords_img = coordmap.scaleCssToImg(coords_css);\n Shiny.setInputValue(inputId, coords, {\n priority: \"event\"\n });\n return;\n }\n\n var panel = coordmap.getPanelCss(coords_css);\n var coords_img = coordmap.scaleCssToImg(coords_css);\n var coords_data = panel.scaleImgToData(coords_img);\n coords.x = coords_data.x;\n coords.y = coords_data.y;\n coords.coords_css = coords_css;\n coords.coords_img = coords_img;\n coords.img_css_ratio = coordmap.cssToImgScalingRatio(); // Add the panel (facet) variables, if present\n\n $.extend(coords, panel.panel_vars); // Add variable name mappings\n\n coords.mapping = panel.mapping; // Add scaling information\n\n coords.domain = panel.domain;\n coords.range = panel.range;\n coords.log = panel.log;\n Shiny.setInputValue(inputId, coords, {\n priority: \"event\"\n });\n };\n };\n }; // Given two sets of x/y coordinates, return an object representing the min\n // and max x and y values. (This could be generalized to any number of\n // points).\n\n\n imageutils.findBox = function (offset1, offset2) {\n return {\n xmin: Math.min(offset1.x, offset2.x),\n xmax: Math.max(offset1.x, offset2.x),\n ymin: Math.min(offset1.y, offset2.y),\n ymax: Math.max(offset1.y, offset2.y)\n };\n }; // Shift an array of values so that they are within a min and max. The vals\n // will be shifted so that they maintain the same spacing internally. If the\n // range in vals is larger than the range of min and max, the result might not\n // make sense.\n\n\n imageutils.shiftToRange = function (vals, min, max) {\n if (!(vals instanceof Array)) vals = [vals];\n var maxval = Math.max.apply(null, vals);\n var minval = Math.min.apply(null, vals);\n var shiftAmount = 0;\n\n if (maxval > max) {\n shiftAmount = max - maxval;\n } else if (minval < min) {\n shiftAmount = min - minval;\n }\n\n var newvals = [];\n\n for (var i = 0; i < vals.length; i++) {\n newvals[i] = vals[i] + shiftAmount;\n }\n\n return newvals;\n }; // This object provides two public event listeners: mousedown, and\n // dblclickIE8.\n // We need to make sure that, when the image is listening for double-\n // clicks, that a double-click doesn't trigger two click events. We'll\n // trigger custom mousedown2 and dblclick2 events with this mousedown\n // listener.\n\n\n imageutils.createClickInfo = function ($el, dblclickId, dblclickDelay) {\n var clickTimer = null;\n var pending_e = null; // A pending mousedown2 event\n // Create a new event of type eventType (like 'mousedown2'), and trigger\n // it with the information stored in this.e.\n\n function triggerEvent(newEventType, e) {\n // Extract important info from e and construct a new event with type\n // eventType.\n var e2 = $.Event(newEventType, {\n which: e.which,\n pageX: e.pageX,\n pageY: e.pageY\n });\n $el.trigger(e2);\n }\n\n function triggerPendingMousedown2() {\n // It's possible that between the scheduling of a mousedown2 and the\n // time this callback is executed, someone else triggers a\n // mousedown2, so check for that.\n if (pending_e) {\n triggerEvent(\"mousedown2\", pending_e);\n pending_e = null;\n }\n } // Set a timer to trigger a mousedown2 event, using information from the\n // last recorded mousdown event.\n\n\n function scheduleMousedown2(e) {\n pending_e = e;\n clickTimer = setTimeout(function () {\n triggerPendingMousedown2();\n }, dblclickDelay);\n }\n\n function mousedown(e) {\n // Listen for left mouse button only\n if (e.which !== 1) return; // If no dblclick listener, immediately trigger a mousedown2 event.\n\n if (!dblclickId) {\n triggerEvent(\"mousedown2\", e);\n return;\n } // If there's a dblclick listener, make sure not to count this as a\n // click on the first mousedown; we need to wait for the dblclick\n // delay before we can be sure this click was a single-click.\n\n\n if (pending_e === null) {\n scheduleMousedown2(e);\n } else {\n clearTimeout(clickTimer); // If second click is too far away, it doesn't count as a double\n // click. Instead, immediately trigger a mousedown2 for the previous\n // click, and set this click as a new first click.\n\n if (pending_e && Math.abs(pending_e.pageX - e.pageX) > 2 || Math.abs(pending_e.pageY - e.pageY) > 2) {\n triggerPendingMousedown2();\n scheduleMousedown2(e);\n } else {\n // The second click was close to the first one. If it happened\n // within specified delay, trigger our custom 'dblclick2' event.\n pending_e = null;\n triggerEvent(\"dblclick2\", e);\n }\n }\n } // IE8 needs a special hack because when you do a double-click it doesn't\n // trigger the click event twice - it directly triggers dblclick.\n\n\n function dblclickIE8(e) {\n e.which = 1; // In IE8, e.which is 0 instead of 1. ???\n\n triggerEvent(\"dblclick2\", e);\n }\n\n return {\n mousedown: mousedown,\n dblclickIE8: dblclickIE8\n };\n }; // ----------------------------------------------------------\n // Handler creators for click, hover, brush.\n // Each of these returns an object with a few public members. These public\n // members are callbacks that are meant to be bound to events on $el with\n // the same name (like 'mousedown').\n // ----------------------------------------------------------\n\n\n imageutils.createClickHandler = function (inputId, clip, coordmap) {\n var clickInfoSender = coordmap.mouseCoordinateSender(inputId, clip);\n return {\n mousedown: function mousedown(e) {\n // Listen for left mouse button only\n if (e.which !== 1) return;\n clickInfoSender(e);\n },\n onResetImg: function onResetImg() {\n clickInfoSender(null);\n },\n onResize: null\n };\n };\n\n imageutils.createHoverHandler = function (inputId, delay, delayType, clip, nullOutside, coordmap) {\n var sendHoverInfo = coordmap.mouseCoordinateSender(inputId, clip, nullOutside);\n var hoverInfoSender;\n if (delayType === \"throttle\") hoverInfoSender = new Throttler(null, sendHoverInfo, delay);else hoverInfoSender = new Debouncer(null, sendHoverInfo, delay); // What to do when mouse exits the image\n\n var mouseout;\n if (nullOutside) mouseout = function mouseout() {\n hoverInfoSender.normalCall(null);\n };else mouseout = function mouseout() {};\n return {\n mousemove: function mousemove(e) {\n hoverInfoSender.normalCall(e);\n },\n mouseout: mouseout,\n onResetImg: function onResetImg() {\n hoverInfoSender.immediateCall(null);\n },\n onResize: null\n };\n }; // Returns a brush handler object. This has three public functions:\n // mousedown, mousemove, and onResetImg.\n\n\n imageutils.createBrushHandler = function (inputId, $el, opts, coordmap, outputId) {\n // Parameter: expand the area in which a brush can be started, by this\n // many pixels in all directions. (This should probably be a brush option)\n var expandPixels = 20; // Represents the state of the brush\n\n var brush = imageutils.createBrush($el, opts, coordmap, expandPixels); // Brush IDs can span multiple image/plot outputs. When an output is brushed,\n // if a brush with the same ID is active on a different image/plot, it must\n // be dismissed (but without sending any data to the server). We implement\n // this by sending the shiny-internal:brushed event to all plots, and letting\n // each plot decide for itself what to do.\n //\n // The decision to have the event sent to each plot (as opposed to a single\n // event triggered on, say, the document) was made to make cleanup easier;\n // listening on an event on the document would prevent garbage collection\n // of plot outputs that are removed from the document.\n\n $el.on(\"shiny-internal:brushed.image_output\", function (e, coords) {\n // If the new brush shares our ID but not our output element ID, we\n // need to clear our brush (if any).\n if (coords.brushId === inputId && coords.outputId !== outputId) {\n $el.data(\"mostRecentBrush\", false);\n brush.reset();\n }\n }); // Set cursor to one of 7 styles. We need to set the cursor on the whole\n // el instead of the brush div, because the brush div has\n // 'pointer-events:none' so that it won't intercept pointer events.\n // If `style` is null, don't add a cursor style.\n\n function setCursorStyle(style) {\n $el.removeClass(\"crosshair grabbable grabbing ns-resize ew-resize nesw-resize nwse-resize\");\n if (style) $el.addClass(style);\n }\n\n function sendBrushInfo() {\n var coords = brush.boundsData(); // We're in a new or reset state\n\n if (isNaN(coords.xmin)) {\n Shiny.setInputValue(inputId, null); // Must tell other brushes to clear.\n\n imageOutputBinding.find(document).trigger(\"shiny-internal:brushed\", {\n brushId: inputId,\n outputId: null\n });\n return;\n }\n\n var panel = brush.getPanel(); // Add the panel (facet) variables, if present\n\n $.extend(coords, panel.panel_vars);\n coords.coords_css = brush.boundsCss();\n coords.coords_img = coordmap.scaleCssToImg(coords.coords_css);\n coords.img_css_ratio = coordmap.cssToImgScalingRatio(); // Add variable name mappings\n\n coords.mapping = panel.mapping; // Add scaling information\n\n coords.domain = panel.domain;\n coords.range = panel.range;\n coords.log = panel.log;\n coords.direction = opts.brushDirection;\n coords.brushId = inputId;\n coords.outputId = outputId; // Send data to server\n\n Shiny.setInputValue(inputId, coords);\n $el.data(\"mostRecentBrush\", true);\n imageOutputBinding.find(document).trigger(\"shiny-internal:brushed\", coords);\n }\n\n var brushInfoSender;\n\n if (opts.brushDelayType === \"throttle\") {\n brushInfoSender = new Throttler(null, sendBrushInfo, opts.brushDelay);\n } else {\n brushInfoSender = new Debouncer(null, sendBrushInfo, opts.brushDelay);\n }\n\n function mousedown(e) {\n // This can happen when mousedown inside the graphic, then mouseup\n // outside, then mousedown inside. Just ignore the second\n // mousedown.\n if (brush.isBrushing() || brush.isDragging() || brush.isResizing()) return; // Listen for left mouse button only\n\n if (e.which !== 1) return; // In general, brush uses css pixels, and coordmap uses img pixels.\n\n var offset_css = coordmap.mouseOffsetCss(e); // Ignore mousedown events outside of plotting region, expanded by\n // a number of pixels specified in expandPixels.\n\n if (opts.brushClip && !coordmap.isInPanelCss(offset_css, expandPixels)) return;\n brush.up({\n x: NaN,\n y: NaN\n });\n brush.down(offset_css);\n\n if (brush.isInResizeArea(offset_css)) {\n brush.startResizing(offset_css); // Attach the move and up handlers to the window so that they respond\n // even when the mouse is moved outside of the image.\n\n $(document).on(\"mousemove.image_brush\", mousemoveResizing).on(\"mouseup.image_brush\", mouseupResizing);\n } else if (brush.isInsideBrush(offset_css)) {\n brush.startDragging(offset_css);\n setCursorStyle(\"grabbing\"); // Attach the move and up handlers to the window so that they respond\n // even when the mouse is moved outside of the image.\n\n $(document).on(\"mousemove.image_brush\", mousemoveDragging).on(\"mouseup.image_brush\", mouseupDragging);\n } else {\n var panel = coordmap.getPanelCss(offset_css, expandPixels);\n brush.startBrushing(panel.clipImg(coordmap.scaleCssToImg(offset_css))); // Attach the move and up handlers to the window so that they respond\n // even when the mouse is moved outside of the image.\n\n $(document).on(\"mousemove.image_brush\", mousemoveBrushing).on(\"mouseup.image_brush\", mouseupBrushing);\n }\n } // This sets the cursor style when it's in the el\n\n\n function mousemove(e) {\n // In general, brush uses css pixels, and coordmap uses img pixels.\n var offset_css = coordmap.mouseOffsetCss(e);\n\n if (!(brush.isBrushing() || brush.isDragging() || brush.isResizing())) {\n // Set the cursor depending on where it is\n if (brush.isInResizeArea(offset_css)) {\n var r = brush.whichResizeSides(offset_css);\n\n if (r.left && r.top || r.right && r.bottom) {\n setCursorStyle(\"nwse-resize\");\n } else if (r.left && r.bottom || r.right && r.top) {\n setCursorStyle(\"nesw-resize\");\n } else if (r.left || r.right) {\n setCursorStyle(\"ew-resize\");\n } else if (r.top || r.bottom) {\n setCursorStyle(\"ns-resize\");\n }\n } else if (brush.isInsideBrush(offset_css)) {\n setCursorStyle(\"grabbable\");\n } else if (coordmap.isInPanelCss(offset_css, expandPixels)) {\n setCursorStyle(\"crosshair\");\n } else {\n setCursorStyle(null);\n }\n }\n } // mousemove handlers while brushing or dragging\n\n\n function mousemoveBrushing(e) {\n brush.brushTo(coordmap.mouseOffsetCss(e));\n brushInfoSender.normalCall();\n }\n\n function mousemoveDragging(e) {\n brush.dragTo(coordmap.mouseOffsetCss(e));\n brushInfoSender.normalCall();\n }\n\n function mousemoveResizing(e) {\n brush.resizeTo(coordmap.mouseOffsetCss(e));\n brushInfoSender.normalCall();\n } // mouseup handlers while brushing or dragging\n\n\n function mouseupBrushing(e) {\n // Listen for left mouse button only\n if (e.which !== 1) return;\n $(document).off(\"mousemove.image_brush\").off(\"mouseup.image_brush\");\n brush.up(coordmap.mouseOffsetCss(e));\n brush.stopBrushing();\n setCursorStyle(\"crosshair\"); // If the brush didn't go anywhere, hide the brush, clear value,\n // and return.\n\n if (brush.down().x === brush.up().x && brush.down().y === brush.up().y) {\n brush.reset();\n brushInfoSender.immediateCall();\n return;\n } // Send info immediately on mouseup, but only if needed. If we don't\n // do the pending check, we might send the same data twice (with\n // with difference nonce).\n\n\n if (brushInfoSender.isPending()) brushInfoSender.immediateCall();\n }\n\n function mouseupDragging(e) {\n // Listen for left mouse button only\n if (e.which !== 1) return;\n $(document).off(\"mousemove.image_brush\").off(\"mouseup.image_brush\");\n brush.up(coordmap.mouseOffsetCss(e));\n brush.stopDragging();\n setCursorStyle(\"grabbable\");\n if (brushInfoSender.isPending()) brushInfoSender.immediateCall();\n }\n\n function mouseupResizing(e) {\n // Listen for left mouse button only\n if (e.which !== 1) return;\n $(document).off(\"mousemove.image_brush\").off(\"mouseup.image_brush\");\n brush.up(coordmap.mouseOffsetCss(e));\n brush.stopResizing();\n if (brushInfoSender.isPending()) brushInfoSender.immediateCall();\n } // Brush maintenance: When an image is re-rendered, the brush must either\n // be removed (if brushResetOnNew) or imported (if !brushResetOnNew). The\n // \"mostRecentBrush\" bit is to ensure that when multiple outputs share the\n // same brush ID, inactive brushes don't send null values up to the server.\n // This should be called when the img (not the el) is reset\n\n\n function onResetImg() {\n if (opts.brushResetOnNew) {\n if ($el.data(\"mostRecentBrush\")) {\n brush.reset();\n brushInfoSender.immediateCall();\n }\n }\n }\n\n if (!opts.brushResetOnNew) {\n if ($el.data(\"mostRecentBrush\")) {\n // Importing an old brush must happen after the image data has loaded\n // and the DOM element has the updated size. If importOldBrush()\n // is called before this happens, then the css-img coordinate mappings\n // will give the wrong result, and the brush will have the wrong\n // position.\n //\n // jcheng 09/26/2018: This used to happen in img.onLoad, but recently\n // we moved to all brush initialization moving to img.onLoad so this\n // logic can be executed inline.\n brush.importOldBrush();\n brushInfoSender.immediateCall();\n }\n }\n\n function onResize() {\n brush.onResize();\n brushInfoSender.immediateCall();\n }\n\n return {\n mousedown: mousedown,\n mousemove: mousemove,\n onResetImg: onResetImg,\n onResize: onResize\n };\n }; // Returns an object that represents the state of the brush. This gets wrapped\n // in a brushHandler, which provides various event listeners.\n\n\n imageutils.createBrush = function ($el, opts, coordmap, expandPixels) {\n // Number of pixels outside of brush to allow start resizing\n var resizeExpand = 10;\n var el = $el[0];\n var $div = null; // The div representing the brush\n\n var state = {}; // Aliases for conciseness\n\n var cssToImg = coordmap.scaleCssToImg;\n var imgToCss = coordmap.scaleImgToCss;\n reset();\n\n function reset() {\n // Current brushing/dragging/resizing state\n state.brushing = false;\n state.dragging = false;\n state.resizing = false; // Offset of last mouse down and up events (in CSS pixels)\n\n state.down = {\n x: NaN,\n y: NaN\n };\n state.up = {\n x: NaN,\n y: NaN\n }; // Which side(s) we're currently resizing\n\n state.resizeSides = {\n left: false,\n right: false,\n top: false,\n bottom: false\n }; // Bounding rectangle of the brush, in CSS pixel and data dimensions. We\n // need to record data dimensions along with pixel dimensions so that when\n // a new plot is sent, we can re-draw the brush div with the appropriate\n // coords.\n\n state.boundsCss = {\n xmin: NaN,\n xmax: NaN,\n ymin: NaN,\n ymax: NaN\n };\n state.boundsData = {\n xmin: NaN,\n xmax: NaN,\n ymin: NaN,\n ymax: NaN\n }; // Panel object that the brush is in\n\n state.panel = null; // The bounds at the start of a drag/resize (in CSS pixels)\n\n state.changeStartBounds = {\n xmin: NaN,\n xmax: NaN,\n ymin: NaN,\n ymax: NaN\n };\n if ($div) $div.remove();\n } // If there's an existing brush div, use that div to set the new brush's\n // settings, provided that the x, y, and panel variables have the same names,\n // and there's a panel with matching panel variable values.\n\n\n function importOldBrush() {\n var oldDiv = $el.find(\"#\" + el.id + \"_brush\");\n if (oldDiv.length === 0) return;\n var oldBoundsData = oldDiv.data(\"bounds-data\");\n var oldPanel = oldDiv.data(\"panel\");\n if (!oldBoundsData || !oldPanel) return; // Find a panel that has matching vars; if none found, we can't restore.\n // The oldPanel and new panel must match on their mapping vars, and the\n // values.\n\n for (var i = 0; i < coordmap.panels.length; i++) {\n var curPanel = coordmap.panels[i];\n\n if (equal(oldPanel.mapping, curPanel.mapping) && equal(oldPanel.panel_vars, curPanel.panel_vars)) {\n // We've found a matching panel\n state.panel = coordmap.panels[i];\n break;\n }\n } // If we didn't find a matching panel, remove the old div and return\n\n\n if (state.panel === null) {\n oldDiv.remove();\n return;\n }\n\n $div = oldDiv;\n boundsData(oldBoundsData);\n updateDiv();\n } // This will reposition the brush div when the image is resized, maintaining\n // the same data coordinates. Note that the \"resize\" here refers to the\n // wrapper div/img being resized; elsewhere, \"resize\" refers to the brush\n // div being resized.\n\n\n function onResize() {\n var bounds_data = boundsData(); // Check to see if we have valid boundsData\n\n for (var val in bounds_data) {\n if (isnan(bounds_data[val])) return;\n }\n\n boundsData(bounds_data);\n updateDiv();\n } // Return true if the offset is inside min/max coords\n\n\n function isInsideBrush(offset_css) {\n var bounds = state.boundsCss;\n return offset_css.x <= bounds.xmax && offset_css.x >= bounds.xmin && offset_css.y <= bounds.ymax && offset_css.y >= bounds.ymin;\n } // Return true if offset is inside a region to start a resize\n\n\n function isInResizeArea(offset_css) {\n var sides = whichResizeSides(offset_css);\n return sides.left || sides.right || sides.top || sides.bottom;\n } // Return an object representing which resize region(s) the cursor is in.\n\n\n function whichResizeSides(offset_css) {\n var b = state.boundsCss; // Bounds with expansion\n\n var e = {\n xmin: b.xmin - resizeExpand,\n xmax: b.xmax + resizeExpand,\n ymin: b.ymin - resizeExpand,\n ymax: b.ymax + resizeExpand\n };\n var res = {\n left: false,\n right: false,\n top: false,\n bottom: false\n };\n\n if ((opts.brushDirection === \"xy\" || opts.brushDirection === \"x\") && offset_css.y <= e.ymax && offset_css.y >= e.ymin) {\n if (offset_css.x < b.xmin && offset_css.x >= e.xmin) res.left = true;else if (offset_css.x > b.xmax && offset_css.x <= e.xmax) res.right = true;\n }\n\n if ((opts.brushDirection === \"xy\" || opts.brushDirection === \"y\") && offset_css.x <= e.xmax && offset_css.x >= e.xmin) {\n if (offset_css.y < b.ymin && offset_css.y >= e.ymin) res.top = true;else if (offset_css.y > b.ymax && offset_css.y <= e.ymax) res.bottom = true;\n }\n\n return res;\n } // Sets the bounds of the brush (in CSS pixels), given a box and optional\n // panel. This will fit the box bounds into the panel, so we don't brush\n // outside of it. This knows whether we're brushing in the x, y, or xy\n // directions, and sets bounds accordingly. If no box is passed in, just\n // return current bounds.\n\n\n function boundsCss(box_css) {\n if (box_css === undefined) {\n return $.extend({}, state.boundsCss);\n }\n\n var min_css = {\n x: box_css.xmin,\n y: box_css.ymin\n };\n var max_css = {\n x: box_css.xmax,\n y: box_css.ymax\n };\n var panel = state.panel;\n var panelBounds_img = panel.range;\n\n if (opts.brushClip) {\n min_css = imgToCss(panel.clipImg(cssToImg(min_css)));\n max_css = imgToCss(panel.clipImg(cssToImg(max_css)));\n }\n\n if (opts.brushDirection === \"xy\") {// No change\n } else if (opts.brushDirection === \"x\") {\n // Extend top and bottom of plotting area\n min_css.y = imgToCss({\n y: panelBounds_img.top\n }).y;\n max_css.y = imgToCss({\n y: panelBounds_img.bottom\n }).y;\n } else if (opts.brushDirection === \"y\") {\n min_css.x = imgToCss({\n x: panelBounds_img.left\n }).x;\n max_css.x = imgToCss({\n x: panelBounds_img.right\n }).x;\n }\n\n state.boundsCss = {\n xmin: min_css.x,\n xmax: max_css.x,\n ymin: min_css.y,\n ymax: max_css.y\n }; // Positions in data space\n\n var min_data = state.panel.scaleImgToData(cssToImg(min_css));\n var max_data = state.panel.scaleImgToData(cssToImg(max_css)); // For reversed scales, the min and max can be reversed, so use findBox\n // to ensure correct order.\n\n state.boundsData = imageutils.findBox(min_data, max_data); // Round to 14 significant digits to avoid spurious changes in FP values\n // (#1634).\n\n state.boundsData = mapValues(state.boundsData, function (val) {\n return roundSignif(val, 14);\n }); // We also need to attach the data bounds and panel as data attributes, so\n // that if the image is re-sent, we can grab the data bounds to create a new\n // brush. This should be fast because it doesn't actually modify the DOM.\n\n $div.data(\"bounds-data\", state.boundsData);\n $div.data(\"panel\", state.panel);\n return undefined;\n } // Get or set the bounds of the brush using coordinates in the data space.\n\n\n function boundsData(box_data) {\n if (box_data === undefined) {\n return $.extend({}, state.boundsData);\n }\n\n var box_css = imgToCss(state.panel.scaleDataToImg(box_data)); // Round to 13 significant digits to avoid spurious changes in FP values\n // (#2197).\n\n box_css = mapValues(box_css, function (val) {\n return roundSignif(val, 13);\n }); // The scaling function can reverse the direction of the axes, so we need to\n // find the min and max again.\n\n boundsCss({\n xmin: Math.min(box_css.xmin, box_css.xmax),\n xmax: Math.max(box_css.xmin, box_css.xmax),\n ymin: Math.min(box_css.ymin, box_css.ymax),\n ymax: Math.max(box_css.ymin, box_css.ymax)\n });\n return undefined;\n }\n\n function getPanel() {\n return state.panel;\n } // Add a new div representing the brush.\n\n\n function addDiv() {\n if ($div) $div.remove(); // Start hidden; we'll show it when movement occurs\n\n $div = $(document.createElement(\"div\")).attr(\"id\", el.id + \"_brush\").css({\n \"background-color\": opts.brushFill,\n opacity: opts.brushOpacity,\n \"pointer-events\": \"none\",\n position: \"absolute\"\n }).hide();\n var borderStyle = \"1px solid \" + opts.brushStroke;\n\n if (opts.brushDirection === \"xy\") {\n $div.css({\n border: borderStyle\n });\n } else if (opts.brushDirection === \"x\") {\n $div.css({\n \"border-left\": borderStyle,\n \"border-right\": borderStyle\n });\n } else if (opts.brushDirection === \"y\") {\n $div.css({\n \"border-top\": borderStyle,\n \"border-bottom\": borderStyle\n });\n }\n\n $el.append($div);\n $div.offset({\n x: 0,\n y: 0\n }).width(0).outerHeight(0);\n } // Update the brush div to reflect the current brush bounds.\n\n\n function updateDiv() {\n // Need parent offset relative to page to calculate mouse offset\n // relative to page.\n var img_offset_css = findOrigin($el.find(\"img\"));\n var b = state.boundsCss;\n $div.offset({\n top: img_offset_css.y + b.ymin,\n left: img_offset_css.x + b.xmin\n }).outerWidth(b.xmax - b.xmin + 1).outerHeight(b.ymax - b.ymin + 1);\n }\n\n function down(offset_css) {\n if (offset_css === undefined) return state.down;\n state.down = offset_css;\n return undefined;\n }\n\n function up(offset_css) {\n if (offset_css === undefined) return state.up;\n state.up = offset_css;\n return undefined;\n }\n\n function isBrushing() {\n return state.brushing;\n }\n\n function startBrushing() {\n state.brushing = true;\n addDiv();\n state.panel = coordmap.getPanelCss(state.down, expandPixels);\n boundsCss(imageutils.findBox(state.down, state.down));\n updateDiv();\n }\n\n function brushTo(offset_css) {\n boundsCss(imageutils.findBox(state.down, offset_css));\n $div.show();\n updateDiv();\n }\n\n function stopBrushing() {\n state.brushing = false; // Save the final bounding box of the brush\n\n boundsCss(imageutils.findBox(state.down, state.up));\n }\n\n function isDragging() {\n return state.dragging;\n }\n\n function startDragging() {\n state.dragging = true;\n state.changeStartBounds = $.extend({}, state.boundsCss);\n }\n\n function dragTo(offset_css) {\n // How far the brush was dragged\n var dx = offset_css.x - state.down.x;\n var dy = offset_css.y - state.down.y; // Calculate what new positions would be, before clipping.\n\n var start = state.changeStartBounds;\n var newBounds_css = {\n xmin: start.xmin + dx,\n xmax: start.xmax + dx,\n ymin: start.ymin + dy,\n ymax: start.ymax + dy\n }; // Clip to the plotting area\n\n if (opts.brushClip) {\n var panelBounds_img = state.panel.range;\n var newBounds_img = cssToImg(newBounds_css); // Convert to format for shiftToRange\n\n var xvals_img = [newBounds_img.xmin, newBounds_img.xmax];\n var yvals_img = [newBounds_img.ymin, newBounds_img.ymax];\n xvals_img = imageutils.shiftToRange(xvals_img, panelBounds_img.left, panelBounds_img.right);\n yvals_img = imageutils.shiftToRange(yvals_img, panelBounds_img.top, panelBounds_img.bottom); // Convert back to bounds format\n\n newBounds_css = imgToCss({\n xmin: xvals_img[0],\n xmax: xvals_img[1],\n ymin: yvals_img[0],\n ymax: yvals_img[1]\n });\n }\n\n boundsCss(newBounds_css);\n updateDiv();\n }\n\n function stopDragging() {\n state.dragging = false;\n }\n\n function isResizing() {\n return state.resizing;\n }\n\n function startResizing() {\n state.resizing = true;\n state.changeStartBounds = $.extend({}, state.boundsCss);\n state.resizeSides = whichResizeSides(state.down);\n }\n\n function resizeTo(offset_css) {\n // How far the brush was dragged\n var d_css = {\n x: offset_css.x - state.down.x,\n y: offset_css.y - state.down.y\n };\n var d_img = cssToImg(d_css); // Calculate what new positions would be, before clipping.\n\n var b_img = cssToImg(state.changeStartBounds);\n var panelBounds_img = state.panel.range;\n\n if (state.resizeSides.left) {\n var xmin_img = imageutils.shiftToRange(b_img.xmin + d_img.x, panelBounds_img.left, b_img.xmax)[0];\n b_img.xmin = xmin_img;\n } else if (state.resizeSides.right) {\n var xmax_img = imageutils.shiftToRange(b_img.xmax + d_img.x, b_img.xmin, panelBounds_img.right)[0];\n b_img.xmax = xmax_img;\n }\n\n if (state.resizeSides.top) {\n var ymin_img = imageutils.shiftToRange(b_img.ymin + d_img.y, panelBounds_img.top, b_img.ymax)[0];\n b_img.ymin = ymin_img;\n } else if (state.resizeSides.bottom) {\n var ymax_img = imageutils.shiftToRange(b_img.ymax + d_img.y, b_img.ymin, panelBounds_img.bottom)[0];\n b_img.ymax = ymax_img;\n }\n\n boundsCss(imgToCss(b_img));\n updateDiv();\n }\n\n function stopResizing() {\n state.resizing = false;\n }\n\n return {\n reset: reset,\n importOldBrush: importOldBrush,\n isInsideBrush: isInsideBrush,\n isInResizeArea: isInResizeArea,\n whichResizeSides: whichResizeSides,\n onResize: onResize,\n // A callback when the wrapper div or img is resized.\n boundsCss: boundsCss,\n boundsData: boundsData,\n getPanel: getPanel,\n down: down,\n up: up,\n isBrushing: isBrushing,\n startBrushing: startBrushing,\n brushTo: brushTo,\n stopBrushing: stopBrushing,\n isDragging: isDragging,\n startDragging: startDragging,\n dragTo: dragTo,\n stopDragging: stopDragging,\n isResizing: isResizing,\n startResizing: startResizing,\n resizeTo: resizeTo,\n stopResizing: stopResizing\n };\n };\n\n Shiny.resetBrush = function (brushId) {\n Shiny.setInputValue(brushId, null);\n imageOutputBinding.find(document).trigger(\"shiny-internal:brushed\", {\n brushId: brushId,\n outputId: null\n });\n }; // -----------------------------------------------------------------------\n // Utility functions for finding dimensions and locations of DOM elements\n // -----------------------------------------------------------------------\n // Returns the ratio that an element has been scaled (for example, by CSS\n // transforms) in the x and y directions.\n\n\n function findScalingRatio($el) {\n var boundingRect = $el[0].getBoundingClientRect();\n return {\n x: boundingRect.width / $el.outerWidth(),\n y: boundingRect.height / $el.outerHeight()\n };\n }\n\n function findOrigin($el) {\n var offset = $el.offset();\n var scaling_ratio = findScalingRatio($el); // Find the size of the padding and border, for the top and left. This is\n // before any transforms.\n\n var paddingBorder = {\n left: parseInt($el.css(\"border-left-width\")) + parseInt($el.css(\"padding-left\")),\n top: parseInt($el.css(\"border-top-width\")) + parseInt($el.css(\"padding-top\"))\n }; // offset() returns the upper left corner of the element relative to the\n // page, but it includes padding and border. Here we find the upper left\n // of the element, not including padding and border.\n\n return {\n x: offset.left + scaling_ratio.x * paddingBorder.left,\n y: offset.top + scaling_ratio.y * paddingBorder.top\n };\n } // Find the dimensions of a tag, after transforms, and without padding and\n // border.\n\n\n function findDims($el) {\n // If there's any padding/border, we need to find the ratio of the actual\n // element content compared to the element plus padding and border.\n var content_ratio = {\n x: $el.width() / $el.outerWidth(),\n y: $el.height() / $el.outerHeight()\n }; // Get the dimensions of the element _after_ any CSS transforms. This\n // includes the padding and border.\n\n var bounding_rect = $el[0].getBoundingClientRect(); // Dimensions of the element after any CSS transforms, and without\n // padding/border.\n\n return {\n x: content_ratio.x * bounding_rect.width,\n y: content_ratio.y * bounding_rect.height\n };\n } // \"output_binding_html.js\"\n\n\n var htmlOutputBinding = new OutputBinding();\n $.extend(htmlOutputBinding, {\n find: function find(scope) {\n return $(scope).find(\".shiny-html-output\");\n },\n onValueError: function onValueError(el, err) {\n Shiny.unbindAll(el);\n this.renderError(el, err);\n },\n renderValue: function renderValue(el, data) {\n Shiny.renderContent(el, data);\n }\n });\n outputBindings.register(htmlOutputBinding, \"shiny.htmlOutput\");\n\n var renderDependencies = Shiny.renderDependencies = function (dependencies) {\n if (dependencies) {\n $.each(dependencies, function (i, dep) {\n renderDependency(dep);\n });\n }\n }; // Render HTML in a DOM element, add dependencies, and bind Shiny\n // inputs/outputs. `content` can be null, a string, or an object with\n // properties 'html' and 'deps'.\n\n\n Shiny.renderContent = function (el, content) {\n var where = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : \"replace\";\n\n if (where === \"replace\") {\n Shiny.unbindAll(el);\n }\n\n var html;\n var dependencies = [];\n\n if (content === null) {\n html = \"\";\n } else if (typeof content === \"string\") {\n html = content;\n } else if (_typeof(content) === \"object\") {\n html = content.html;\n dependencies = content.deps || [];\n }\n\n Shiny.renderHtml(html, el, dependencies, where);\n var scope = el;\n\n if (where === \"replace\") {\n Shiny.initializeInputs(el);\n Shiny.bindAll(el);\n } else {\n var $parent = $(el).parent();\n\n if ($parent.length > 0) {\n scope = $parent;\n\n if (where === \"beforeBegin\" || where === \"afterEnd\") {\n var $grandparent = $parent.parent();\n if ($grandparent.length > 0) scope = $grandparent;\n }\n }\n\n Shiny.initializeInputs(scope);\n Shiny.bindAll(scope);\n }\n }; // Render HTML in a DOM element, inserting singletons into head as needed\n\n\n Shiny.renderHtml = function (html, el, dependencies) {\n var where = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : \"replace\";\n renderDependencies(dependencies);\n return singletons.renderHtml(html, el, where);\n };\n\n var htmlDependencies = {};\n\n function registerDependency(name, version) {\n htmlDependencies[name] = version;\n } // Re-render stylesheet(s) if the dependency has specificially requested it\n // and it matches an existing dependency (name and version)\n\n\n function needsRestyle(dep) {\n if (!dep.restyle) {\n return false;\n }\n\n var names = Object.keys(htmlDependencies);\n var idx = names.indexOf(dep.name);\n\n if (idx === -1) {\n return false;\n }\n\n return htmlDependencies[names[idx]] === dep.version;\n } // Client-side dependency resolution and rendering\n\n\n function renderDependency(dep) {\n var restyle = needsRestyle(dep);\n if (htmlDependencies.hasOwnProperty(dep.name) && !restyle) return false;\n registerDependency(dep.name, dep.version);\n var href = dep.src.href;\n var $head = $(\"head\").first();\n\n if (dep.meta && !restyle) {\n var metas = $.map(asArray(dep.meta), function (obj, idx) {\n // only one named pair is expected in obj as it's already been decomposed\n var name = Object.keys(obj)[0];\n return $(\"\").attr(\"name\", name).attr(\"content\", obj[name]);\n });\n $head.append(metas);\n }\n\n if (dep.stylesheet) {\n var links = $.map(asArray(dep.stylesheet), function (stylesheet) {\n return $(\"\").attr(\"href\", href + \"/\" + encodeURI(stylesheet));\n });\n\n if (!restyle) {\n $head.append(links);\n } else {\n // This inline